drivers/media/i2c/ov4689.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/ov4689.c
Extension
.c
Size
27653 bytes
Lines
1046
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 ov4689_mode {
	enum ov4689_mode_id id;
	u32 width;
	u32 height;
	u32 hts_def;
	u32 hts_min;
	u32 vts_def;
	u32 exp_def;
	u32 pixel_rate;
	const struct cci_reg_sequence *reg_list;
	unsigned int num_regs;
};

struct ov4689 {
	struct device *dev;
	struct regmap *regmap;
	struct clk *xvclk;
	struct gpio_desc *reset_gpio;
	struct gpio_desc *pwdn_gpio;
	struct regulator_bulk_data supplies[ARRAY_SIZE(ov4689_supply_names)];

	struct v4l2_subdev subdev;
	struct media_pad pad;

	u32 clock_rate;

	struct v4l2_ctrl_handler ctrl_handler;
	struct v4l2_ctrl *exposure;

	const struct ov4689_mode *cur_mode;
};

#define to_ov4689(sd) container_of(sd, struct ov4689, subdev)

struct ov4689_gain_range {
	u32 logical_min;
	u32 logical_max;
	u32 offset;
	u32 divider;
	u32 physical_min;
	u32 physical_max;
};

/*
 * Xclk 24Mhz
 * max_framerate 90fps
 * mipi_datarate per lane 1008Mbps
 */
static const struct cci_reg_sequence ov4689_2688x1520_regs[] = {
	/* System control*/
	{ CCI_REG8(0x0103), 0x01 }, /* SC_CTRL0103 software_reset = 1 */
	{ CCI_REG8(0x3000), 0x20 }, /* SC_CMMN_PAD_OEN0 FSIN_output_enable = 1 */
	{ CCI_REG8(0x3021), 0x03 }, /*
				     * SC_CMMN_MISC_CTRL fst_stby_ctr = 0,
				     * sleep_no_latch_enable = 0
				     */

	/* AEC PK */
	{ CCI_REG8(0x3503), 0x04 }, /* AEC_MANUAL gain_input_as_sensor_gain_format = 1 */

	/* ADC and analog control*/
	{ CCI_REG8(0x3603), 0x40 },
	{ CCI_REG8(0x3604), 0x02 },
	{ CCI_REG8(0x3609), 0x12 },
	{ CCI_REG8(0x360c), 0x08 },
	{ CCI_REG8(0x360f), 0xe5 },
	{ CCI_REG8(0x3608), 0x8f },
	{ CCI_REG8(0x3611), 0x00 },
	{ CCI_REG8(0x3613), 0xf7 },
	{ CCI_REG8(0x3616), 0x58 },
	{ CCI_REG8(0x3619), 0x99 },
	{ CCI_REG8(0x361b), 0x60 },
	{ CCI_REG8(0x361e), 0x79 },
	{ CCI_REG8(0x3634), 0x10 },
	{ CCI_REG8(0x3635), 0x10 },
	{ CCI_REG8(0x3636), 0x15 },
	{ CCI_REG8(0x3646), 0x86 },
	{ CCI_REG8(0x364a), 0x0b },

	/* Sensor control */
	{ CCI_REG8(0x3700), 0x17 },
	{ CCI_REG8(0x3701), 0x22 },
	{ CCI_REG8(0x3703), 0x10 },
	{ CCI_REG8(0x370a), 0x37 },
	{ CCI_REG8(0x3706), 0x63 },
	{ CCI_REG8(0x3709), 0x3c },
	{ CCI_REG8(0x370c), 0x30 },
	{ CCI_REG8(0x3710), 0x24 },
	{ CCI_REG8(0x3720), 0x28 },
	{ CCI_REG8(0x3729), 0x7b },

Annotation

Implementation Notes