linux/drivers/media/i2c/mt9m111.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Driver for MT9M111/MT9M112/MT9M131 CMOS Image Sensor from Micron/Aptina
 *
 * Copyright (C) 2008, Robert Jarzmik <[email protected]>
 */
#include <linux/clk.h>
#include <linux/videodev2.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/log2.h>
#include <linux/delay.h>
#include <linux/regulator/consumer.h>
#include <linux/v4l2-mediabus.h>
#include <linux/module.h>
#include <linux/property.h>

#include <media/v4l2-async.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>

/*
 * MT9M111, MT9M112 and MT9M131:
 * i2c address is 0x48 or 0x5d (depending on SADDR pin)
 * The platform has to define struct i2c_board_info objects and link to them
 * from struct soc_camera_host_desc
 */

/*
 * Sensor core register addresses (0x000..0x0ff)
 */
#define MT9M111_CHIP_VERSION
#define MT9M111_ROW_START
#define MT9M111_COLUMN_START
#define MT9M111_WINDOW_HEIGHT
#define MT9M111_WINDOW_WIDTH
#define MT9M111_HORIZONTAL_BLANKING_B
#define MT9M111_VERTICAL_BLANKING_B
#define MT9M111_HORIZONTAL_BLANKING_A
#define MT9M111_VERTICAL_BLANKING_A
#define MT9M111_SHUTTER_WIDTH
#define MT9M111_ROW_SPEED
#define MT9M111_EXTRA_DELAY
#define MT9M111_SHUTTER_DELAY
#define MT9M111_RESET
#define MT9M111_READ_MODE_B
#define MT9M111_READ_MODE_A
#define MT9M111_FLASH_CONTROL
#define MT9M111_GREEN1_GAIN
#define MT9M111_BLUE_GAIN
#define MT9M111_RED_GAIN
#define MT9M111_GREEN2_GAIN
#define MT9M111_GLOBAL_GAIN
#define MT9M111_CONTEXT_CONTROL
#define MT9M111_PAGE_MAP
#define MT9M111_BYTE_WISE_ADDR

#define MT9M111_RESET_SYNC_CHANGES
#define MT9M111_RESET_RESTART_BAD_FRAME
#define MT9M111_RESET_SHOW_BAD_FRAMES
#define MT9M111_RESET_RESET_SOC
#define MT9M111_RESET_OUTPUT_DISABLE
#define MT9M111_RESET_CHIP_ENABLE
#define MT9M111_RESET_ANALOG_STANDBY
#define MT9M111_RESET_RESTART_FRAME
#define MT9M111_RESET_RESET_MODE

#define MT9M111_RM_FULL_POWER_RD
#define MT9M111_RM_LOW_POWER_RD
#define MT9M111_RM_COL_SKIP_4X
#define MT9M111_RM_ROW_SKIP_4X
#define MT9M111_RM_COL_SKIP_2X
#define MT9M111_RM_ROW_SKIP_2X
#define MT9M111_RMB_MIRROR_COLS
#define MT9M111_RMB_MIRROR_ROWS
#define MT9M111_CTXT_CTRL_RESTART
#define MT9M111_CTXT_CTRL_DEFECTCOR_B
#define MT9M111_CTXT_CTRL_RESIZE_B
#define MT9M111_CTXT_CTRL_CTRL2_B
#define MT9M111_CTXT_CTRL_GAMMA_B
#define MT9M111_CTXT_CTRL_XENON_EN
#define MT9M111_CTXT_CTRL_READ_MODE_B
#define MT9M111_CTXT_CTRL_LED_FLASH_EN
#define MT9M111_CTXT_CTRL_VBLANK_SEL_B
#define MT9M111_CTXT_CTRL_HBLANK_SEL_B

/*
 * Colorpipe register addresses (0x100..0x1ff)
 */
#define MT9M111_OPER_MODE_CTRL
#define MT9M111_OUTPUT_FORMAT_CTRL
#define MT9M111_TPG_CTRL
#define MT9M111_REDUCER_XZOOM_B
#define MT9M111_REDUCER_XSIZE_B
#define MT9M111_REDUCER_YZOOM_B
#define MT9M111_REDUCER_YSIZE_B
#define MT9M111_REDUCER_XZOOM_A
#define MT9M111_REDUCER_XSIZE_A
#define MT9M111_REDUCER_YZOOM_A
#define MT9M111_REDUCER_YSIZE_A
#define MT9M111_EFFECTS_MODE

#define MT9M111_OUTPUT_FORMAT_CTRL2_A
#define MT9M111_OUTPUT_FORMAT_CTRL2_B

#define MT9M111_OPMODE_AUTOEXPO_EN
#define MT9M111_OPMODE_AUTOWHITEBAL_EN
#define MT9M111_OUTFMT_FLIP_BAYER_COL
#define MT9M111_OUTFMT_FLIP_BAYER_ROW
#define MT9M111_OUTFMT_PROCESSED_BAYER
#define MT9M111_OUTFMT_BYPASS_IFP
#define MT9M111_OUTFMT_INV_PIX_CLOCK
#define MT9M111_OUTFMT_RGB
#define MT9M111_OUTFMT_RGB565
#define MT9M111_OUTFMT_RGB555
#define MT9M111_OUTFMT_RGB444x
#define MT9M111_OUTFMT_RGBx444
#define MT9M111_OUTFMT_TST_RAMP_OFF
#define MT9M111_OUTFMT_TST_RAMP_COL
#define MT9M111_OUTFMT_TST_RAMP_ROW
#define MT9M111_OUTFMT_TST_RAMP_FRAME
#define MT9M111_OUTFMT_SHIFT_3_UP
#define MT9M111_OUTFMT_AVG_CHROMA
#define MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN
#define MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B
#define MT9M111_TPG_SEL_MASK
#define MT9M111_EFFECTS_MODE_MASK
#define MT9M111_RM_PWR_MASK
#define MT9M111_RM_SKIP2_MASK

/*
 * Camera control register addresses (0x200..0x2ff not implemented)
 */

#define reg_read(reg)
#define reg_write(reg, val)
#define reg_set(reg, val)
#define reg_clear(reg, val)
#define reg_mask(reg, val, mask)

#define MT9M111_MIN_DARK_ROWS
#define MT9M111_MIN_DARK_COLS
#define MT9M111_MAX_HEIGHT
#define MT9M111_MAX_WIDTH

struct mt9m111_context {};

static struct mt9m111_context context_a =;

static struct mt9m111_context context_b =;

/* MT9M111 has only one fixed colorspace per pixelcode */
struct mt9m111_datafmt {};

static const struct mt9m111_datafmt mt9m111_colour_fmts[] =;

enum mt9m111_mode_id {};

struct mt9m111_mode_info {};

struct mt9m111 {};

static const struct mt9m111_mode_info mt9m111_mode_data[MT9M111_NUM_MODES] =;

/* Find a data format by a pixel code */
static const struct mt9m111_datafmt *mt9m111_find_datafmt(struct mt9m111 *mt9m111,
						u32 code)
{}

static struct mt9m111 *to_mt9m111(const struct i2c_client *client)
{}

static int reg_page_map_set(struct i2c_client *client, const u16 reg)
{}

static int mt9m111_reg_read(struct i2c_client *client, const u16 reg)
{}

static int mt9m111_reg_write(struct i2c_client *client, const u16 reg,
			     const u16 data)
{}

static int mt9m111_reg_set(struct i2c_client *client, const u16 reg,
			   const u16 data)
{}

static int mt9m111_reg_clear(struct i2c_client *client, const u16 reg,
			     const u16 data)
{}

static int mt9m111_reg_mask(struct i2c_client *client, const u16 reg,
			    const u16 data, const u16 mask)
{}

static int mt9m111_set_context(struct mt9m111 *mt9m111,
			       struct mt9m111_context *ctx)
{}

static int mt9m111_setup_rect_ctx(struct mt9m111 *mt9m111,
			struct mt9m111_context *ctx, struct v4l2_rect *rect,
			unsigned int width, unsigned int height)
{}

static int mt9m111_setup_geometry(struct mt9m111 *mt9m111, struct v4l2_rect *rect,
			int width, int height, u32 code)
{}

static int mt9m111_enable(struct mt9m111 *mt9m111)
{}

static int mt9m111_reset(struct mt9m111 *mt9m111)
{}

static int mt9m111_set_selection(struct v4l2_subdev *sd,
				 struct v4l2_subdev_state *sd_state,
				 struct v4l2_subdev_selection *sel)
{}

static int mt9m111_get_selection(struct v4l2_subdev *sd,
				 struct v4l2_subdev_state *sd_state,
				 struct v4l2_subdev_selection *sel)
{}

static int mt9m111_get_fmt(struct v4l2_subdev *sd,
		struct v4l2_subdev_state *sd_state,
		struct v4l2_subdev_format *format)
{}

static int mt9m111_set_pixfmt(struct mt9m111 *mt9m111,
			      u32 code)
{}

static int mt9m111_set_fmt(struct v4l2_subdev *sd,
		struct v4l2_subdev_state *sd_state,
		struct v4l2_subdev_format *format)
{}

static const struct mt9m111_mode_info *
mt9m111_find_mode(struct mt9m111 *mt9m111, unsigned int req_fps,
		  unsigned int width, unsigned int height)
{}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int mt9m111_g_register(struct v4l2_subdev *sd,
			      struct v4l2_dbg_register *reg)
{}

static int mt9m111_s_register(struct v4l2_subdev *sd,
			      const struct v4l2_dbg_register *reg)
{}
#endif

static int mt9m111_set_flip(struct mt9m111 *mt9m111, int flip, int mask)
{}

static int mt9m111_get_global_gain(struct mt9m111 *mt9m111)
{}

static int mt9m111_set_global_gain(struct mt9m111 *mt9m111, int gain)
{}

static int mt9m111_set_autoexposure(struct mt9m111 *mt9m111, int val)
{}

static int mt9m111_set_autowhitebalance(struct mt9m111 *mt9m111, int on)
{}

static const char * const mt9m111_test_pattern_menu[] =;

static int mt9m111_set_test_pattern(struct mt9m111 *mt9m111, int val)
{}

static int mt9m111_set_colorfx(struct mt9m111 *mt9m111, int val)
{}

static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl)
{}

static int mt9m111_suspend(struct mt9m111 *mt9m111)
{}

static void mt9m111_restore_state(struct mt9m111 *mt9m111)
{}

static int mt9m111_resume(struct mt9m111 *mt9m111)
{}

static int mt9m111_init(struct mt9m111 *mt9m111)
{}

static int mt9m111_power_on(struct mt9m111 *mt9m111)
{}

static void mt9m111_power_off(struct mt9m111 *mt9m111)
{}

static int mt9m111_s_power(struct v4l2_subdev *sd, int on)
{}

static const struct v4l2_ctrl_ops mt9m111_ctrl_ops =;

static const struct v4l2_subdev_core_ops mt9m111_subdev_core_ops =;

static int mt9m111_get_frame_interval(struct v4l2_subdev *sd,
				      struct v4l2_subdev_state *sd_state,
				      struct v4l2_subdev_frame_interval *fi)
{}

static int mt9m111_set_frame_interval(struct v4l2_subdev *sd,
				      struct v4l2_subdev_state *sd_state,
				      struct v4l2_subdev_frame_interval *fi)
{}

static int mt9m111_enum_mbus_code(struct v4l2_subdev *sd,
		struct v4l2_subdev_state *sd_state,
		struct v4l2_subdev_mbus_code_enum *code)
{}

static int mt9m111_s_stream(struct v4l2_subdev *sd, int enable)
{}

static int mt9m111_init_state(struct v4l2_subdev *sd,
			      struct v4l2_subdev_state *sd_state)
{}

static int mt9m111_get_mbus_config(struct v4l2_subdev *sd,
				   unsigned int pad,
				   struct v4l2_mbus_config *cfg)
{}

static const struct v4l2_subdev_video_ops mt9m111_subdev_video_ops =;

static const struct v4l2_subdev_pad_ops mt9m111_subdev_pad_ops =;

static const struct v4l2_subdev_ops mt9m111_subdev_ops =;

static const struct v4l2_subdev_internal_ops mt9m111_internal_ops =;

/*
 * Interface active, can use i2c. If it fails, it can indeed mean, that
 * this wasn't our capture interface, so, we wait for the right one
 */
static int mt9m111_video_probe(struct i2c_client *client)
{}

static int mt9m111_probe_fw(struct i2c_client *client, struct mt9m111 *mt9m111)
{}

static int mt9m111_probe(struct i2c_client *client)
{}

static void mt9m111_remove(struct i2c_client *client)
{}
static const struct of_device_id mt9m111_of_match[] =;
MODULE_DEVICE_TABLE(of, mt9m111_of_match);

static const struct i2c_device_id mt9m111_id[] =;
MODULE_DEVICE_TABLE(i2c, mt9m111_id);

static struct i2c_driver mt9m111_i2c_driver =;

module_i2c_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();