drivers/media/i2c/imx111.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/imx111.c
Extension
.c
Size
50377 bytes
Lines
1611
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 imx111_mode {
	u32 width;
	u32 height;

	/* Default vertical and horizontal total length */
	u32 vtl_def;
	u32 htl_def;

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

struct imx111_pll {
	u64 extclk_rate;
	u8 pre_div;
	u8 mult;
};

struct imx111 {
	struct regmap *regmap;

	struct clk *extclk;
	struct gpio_desc *reset;
	struct regulator_bulk_data *supplies;

	struct v4l2_fwnode_endpoint bus_cfg;
	struct v4l2_subdev sd;
	struct media_pad pad;

	/* V4L2 Controls */
	struct v4l2_ctrl_handler hdl;
	struct v4l2_ctrl *pixel_rate;
	struct v4l2_ctrl *link_freq;
	struct v4l2_ctrl *exposure;
	struct v4l2_ctrl *vblank;
	struct v4l2_ctrl *hblank;
	struct v4l2_ctrl *hflip;
	struct v4l2_ctrl *vflip;

	/* Current mode */
	const struct imx111_mode *cur_mode;
	const struct imx111_pll *pll;
	u32 data_depth;

	u64 pixel_clk_raw;
	s64 default_link_freq;
};

static const struct imx111_pll imx111_pll[] = {
	{ .extclk_rate =  6000000, .pre_div = 1, .mult = 113, },
	{ .extclk_rate = 12000000, .pre_div = 2, .mult = 113, },
	{ .extclk_rate = 13500000, .pre_div = 1, .mult = 50, },
	{ .extclk_rate = 18000000, .pre_div = 2, .mult = 75, },
	{ .extclk_rate = 24000000, .pre_div = 4, .mult = 113, },
	{ .extclk_rate = 27000000, .pre_div = 2, .mult = 50, },
	{ .extclk_rate = 36000000, .pre_div = 4, .mult = 75, },
	{ .extclk_rate = 54000000, .pre_div = 4, .mult = 50, },
};

/*
 * This table MUST contain 4 entries per format, to cover the various flip
 * combinations in the order
 * - no flip
 * - h flip
 * - v flip
 * - h&v flips
 */
static const u32 imx111_mbus_formats[] = {
	MEDIA_BUS_FMT_SGBRG10_1X10,
	MEDIA_BUS_FMT_SBGGR10_1X10,
	MEDIA_BUS_FMT_SRGGB10_1X10,
	MEDIA_BUS_FMT_SGRBG10_1X10,

	MEDIA_BUS_FMT_SGBRG8_1X8,
	MEDIA_BUS_FMT_SBGGR8_1X8,
	MEDIA_BUS_FMT_SRGGB8_1X8,
	MEDIA_BUS_FMT_SGRBG8_1X8,
};

static const struct cci_reg_sequence imx111_global_init[] = {
	{ CCI_REG8(0x3080), 0x50 },
	{ CCI_REG8(0x3087), 0x53 },
	{ CCI_REG8(0x309d), 0x94 },
	{ CCI_REG8(0x30b1), 0x03 },
	{ CCI_REG8(0x30c6), 0x00 },
	{ CCI_REG8(0x30c7), 0x00 },
	{ CCI_REG8(0x3115), 0x0b },
	{ CCI_REG8(0x3118), 0x30 },

Annotation

Implementation Notes