drivers/media/i2c/imx334.c

Source file repositories/reference/linux-study-clean/drivers/media/i2c/imx334.c

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/imx334.c
Extension
.c
Size
34116 bytes
Lines
1268
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct imx334_reg_list {
	u32 num_of_regs;
	const struct cci_reg_sequence *regs;
};

/**
 * struct imx334_mode - imx334 sensor mode structure
 * @width: Frame width
 * @height: Frame height
 * @hblank: Horizontal blanking in lines
 * @vblank: Vertical blanking in lines
 * @vblank_min: Minimal vertical blanking in lines
 * @vblank_max: Maximum vertical blanking in lines
 * @pclk: Sensor pixel clock
 * @link_freq_idx: Link frequency index
 * @reg_list: Register list for sensor mode
 */
struct imx334_mode {
	u32 width;
	u32 height;
	u32 hblank;
	u32 vblank;
	u32 vblank_min;
	u32 vblank_max;
	u64 pclk;
	u32 link_freq_idx;
	struct imx334_reg_list reg_list;
};

/**
 * struct imx334 - imx334 sensor device structure
 * @dev: Pointer to generic device
 * @cci: CCI register map
 * @client: Pointer to i2c client
 * @sd: V4L2 sub-device
 * @pad: Media pad. Only one pad supported
 * @reset_gpio: Sensor reset gpio
 * @inclk: Sensor input clock
 * @ctrl_handler: V4L2 control handler
 * @link_freq_ctrl: Pointer to link frequency control
 * @pclk_ctrl: Pointer to pixel clock control
 * @hblank_ctrl: Pointer to horizontal blanking control
 * @vblank_ctrl: Pointer to vertical blanking control
 * @exp_ctrl: Pointer to exposure control
 * @again_ctrl: Pointer to analog gain control
 * @vblank: Vertical blanking in lines
 * @cur_mode: Pointer to current selected sensor mode
 * @link_freq_bitmap: Menu bitmap for link_freq_ctrl
 * @cur_code: current selected format code
 */
struct imx334 {
	struct device *dev;
	struct regmap *cci;
	struct i2c_client *client;
	struct v4l2_subdev sd;
	struct media_pad pad;
	struct gpio_desc *reset_gpio;
	struct clk *inclk;
	struct v4l2_ctrl_handler ctrl_handler;
	struct v4l2_ctrl *link_freq_ctrl;
	struct v4l2_ctrl *pclk_ctrl;
	struct v4l2_ctrl *hblank_ctrl;
	struct v4l2_ctrl *vblank_ctrl;
	struct {
		struct v4l2_ctrl *exp_ctrl;
		struct v4l2_ctrl *again_ctrl;
	};
	u32 vblank;
	const struct imx334_mode *cur_mode;
	unsigned long link_freq_bitmap;
	u32 cur_code;
};

static const s64 link_freq[] = {
	IMX334_LINK_FREQ_891M,
	IMX334_LINK_FREQ_445M,
};

/* Sensor common mode registers values */
static const struct cci_reg_sequence common_mode_regs[] = {
	{ IMX334_REG_MODE_SELECT, IMX334_MODE_STANDBY },
	{ IMX334_REG_WINMODE,		0x04 },
	{ IMX334_REG_VMAX,		0x0008ca },
	{ IMX334_REG_HMAX,		0x044c },
	{ IMX334_REG_BLACK_OFSET_ADR,	0x0000 },
	{ IMX334_REG_UNRD_LINE_MAX,	0x0000 },
	{ IMX334_REG_OPB_SIZE_V,	0x00 },
	{ IMX334_REG_HREVERSE,		0x00 },
	{ IMX334_REG_VREVERSE,		0x00 },
	{ IMX334_REG_UNREAD_PARAM5,	0x0000 },

Annotation

Implementation Notes