drivers/media/i2c/ov5670.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/ov5670.c
Extension
.c
Size
58657 bytes
Lines
2830
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 ov5670_reg {
	u16 address;
	u8 val;
};

struct ov5670_reg_list {
	u32 num_of_regs;
	const struct ov5670_reg *regs;
};

struct ov5670_link_freq_config {
	const struct ov5670_reg_list reg_list;
};

static const char * const ov5670_supply_names[] = {
	"avdd",		/* Analog power */
	"dvdd",		/* Digital power */
	"dovdd",	/* Digital output power */
};

#define OV5670_NUM_SUPPLIES ARRAY_SIZE(ov5670_supply_names)

struct ov5670_mode {
	/* Frame width in pixels */
	u32 width;

	/* Frame height in pixels */
	u32 height;

	/* Default vertical timining size */
	u32 vts_def;

	/* Min vertical timining size */
	u32 vts_min;

	/* Link frequency needed for this resolution */
	u32 link_freq_index;

	/* Analog crop rectangle */
	const struct v4l2_rect *analog_crop;

	/* Sensor register settings for this resolution */
	const struct ov5670_reg_list reg_list;
};

/*
 * All the modes supported by the driver are obtained by subsampling the
 * full pixel array. The below values are reflected in registers from
 * 0x3800-0x3807 in the modes register-value tables.
 */
static const struct v4l2_rect ov5670_analog_crop = {
	.left	= 12,
	.top	= 4,
	.width	= 2600,
	.height	= 1952,
};

static const struct ov5670_reg mipi_data_rate_840mbps[] = {
	{0x0300, 0x04},
	{0x0301, 0x00},
	{0x0302, 0x84},
	{0x0303, 0x00},
	{0x0304, 0x03},
	{0x0305, 0x01},
	{0x0306, 0x01},
	{0x030a, 0x00},
	{0x030b, 0x00},
	{0x030c, 0x00},
	{0x030d, 0x26},
	{0x030e, 0x00},
	{0x030f, 0x06},
	{0x0312, 0x01},
	{0x3031, 0x0a},
};

static const struct ov5670_reg mode_2592x1944_regs[] = {
	{0x3000, 0x00},
	{0x3002, 0x21},
	{0x3005, 0xf0},
	{0x3007, 0x00},
	{0x3015, 0x0f},
	{0x301a, 0xf0},
	{0x301b, 0xf0},
	{0x301c, 0xf0},
	{0x301d, 0xf0},
	{0x301e, 0xf0},
	{0x3030, 0x00},
	{0x3031, 0x0a},
	{0x303c, 0xff},
	{0x303e, 0xff},

Annotation

Implementation Notes