drivers/media/i2c/ov7251.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/ov7251.c
Extension
.c
Size
43687 bytes
Lines
1825
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 reg_value {
	u16 reg;
	u8 val;
};

struct ov7251_mode_info {
	u32 width;
	u32 height;
	u32 vts;
	const struct reg_value *data;
	u32 data_size;
	u32 pixel_clock;
	u32 link_freq;
	u16 exposure_max;
	u16 exposure_def;
	struct v4l2_fract timeperframe;
};

struct ov7251_pll1_cfg {
	unsigned int pre_div;
	unsigned int mult;
	unsigned int div;
	unsigned int pix_div;
	unsigned int mipi_div;
};

struct ov7251_pll2_cfg {
	unsigned int pre_div;
	unsigned int mult;
	unsigned int div;
	unsigned int sys_div;
	unsigned int adc_div;
};

/*
 * Rubbish ordering, but only PLL1 needs to have a separate configuration per
 * link frequency and the array member needs to be last.
 */
struct ov7251_pll_cfgs {
	const struct ov7251_pll2_cfg *pll2;
	const struct ov7251_pll1_cfg *pll1[];
};

enum xclk_rate {
	OV7251_19_2_MHZ,
	OV7251_24_MHZ,
	OV7251_NUM_SUPPORTED_RATES
};

enum supported_link_freqs {
	OV7251_LINK_FREQ_240_MHZ,
	OV7251_LINK_FREQ_319_2_MHZ,
	OV7251_NUM_SUPPORTED_LINK_FREQS
};

struct ov7251 {
	struct i2c_client *i2c_client;
	struct device *dev;
	struct v4l2_subdev sd;
	struct media_pad pad;
	struct v4l2_fwnode_endpoint ep;
	struct v4l2_mbus_framefmt fmt;
	struct v4l2_rect crop;
	struct clk *xclk;
	u32 xclk_freq;

	struct regulator *io_regulator;
	struct regulator *core_regulator;
	struct regulator *analog_regulator;

	const struct ov7251_pll_cfgs *pll_cfgs;
	enum supported_link_freqs link_freq_idx;
	const struct ov7251_mode_info *current_mode;

	struct v4l2_ctrl_handler ctrls;
	struct v4l2_ctrl *pixel_clock;
	struct v4l2_ctrl *link_freq;
	struct v4l2_ctrl *exposure;
	struct v4l2_ctrl *gain;
	struct v4l2_ctrl *hblank;
	struct v4l2_ctrl *vblank;

	/* Cached register values */
	u8 aec_pk_manual;
	u8 pre_isp_00;
	u8 timing_format1;
	u8 timing_format2;

	struct mutex lock; /* lock to protect power state, ctrls and mode */
	bool power_on;

Annotation

Implementation Notes