drivers/media/i2c/ov7740.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/ov7740.c
Extension
.c
Size
27361 bytes
Lines
1182
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 ov7740 {
	struct v4l2_subdev subdev;
	struct media_pad pad;
	struct v4l2_mbus_framefmt format;
	const struct ov7740_pixfmt *fmt;  /* Current format */
	const struct ov7740_framesize *frmsize;
	struct regmap *regmap;
	struct clk *xvclk;
	struct v4l2_ctrl_handler ctrl_handler;
	struct {
		/* gain cluster */
		struct v4l2_ctrl *auto_gain;
		struct v4l2_ctrl *gain;
	};
	struct {
		struct v4l2_ctrl *auto_wb;
		struct v4l2_ctrl *blue_balance;
		struct v4l2_ctrl *red_balance;
	};
	struct {
		struct v4l2_ctrl *hflip;
		struct v4l2_ctrl *vflip;
	};
	struct {
		/* exposure cluster */
		struct v4l2_ctrl *auto_exposure;
		struct v4l2_ctrl *exposure;
	};
	struct {
		/* saturation/hue cluster */
		struct v4l2_ctrl *saturation;
		struct v4l2_ctrl *hue;
	};
	struct v4l2_ctrl *brightness;
	struct v4l2_ctrl *contrast;

	struct mutex mutex;	/* To serialize asynchronous callbacks */

	struct gpio_desc *resetb_gpio;
	struct gpio_desc *pwdn_gpio;
};

struct ov7740_pixfmt {
	u32 mbus_code;
	enum v4l2_colorspace colorspace;
	const struct reg_sequence *regs;
	u32 reg_num;
};

struct ov7740_framesize {
	u16 width;
	u16 height;
	const struct reg_sequence *regs;
	u32 reg_num;
};

static const struct reg_sequence ov7740_vga[] = {
	{0x55, 0x40},
	{0x11, 0x02},

	{0xd5, 0x10},
	{0x0c, 0x12},
	{0x0d, 0x34},
	{0x17, 0x25},
	{0x18, 0xa0},
	{0x19, 0x03},
	{0x1a, 0xf0},
	{0x1b, 0x89},
	{0x22, 0x03},
	{0x29, 0x18},
	{0x2b, 0xf8},
	{0x2c, 0x01},
	{REG_HOUTSIZE, 0xa0},
	{REG_VOUTSIZE, 0xf0},
	{0x33, 0xc4},
	{REG_OUTSIZE_LSB, 0x0},
	{0x35, 0x05},
	{0x04, 0x60},
	{0x27, 0x80},
	{0x3d, 0x0f},
	{0x3e, 0x80},
	{0x3f, 0x40},
	{0x40, 0x7f},
	{0x41, 0x6a},
	{0x42, 0x29},
	{0x44, 0x22},
	{0x45, 0x41},
	{0x47, 0x02},
	{0x49, 0x64},
	{0x4a, 0xa1},

Annotation

Implementation Notes