drivers/media/i2c/gc0308.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/gc0308.c
Extension
.c
Size
44474 bytes
Lines
1445
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 gc0308_exposure {
	u8 luma_offset;
	u8 aec_target_y;
};

#define GC0308_EXPOSURE(luma_offset_reg, aec_target_y_reg) \
	{ .luma_offset = luma_offset_reg, .aec_target_y = aec_target_y_reg }

static const struct gc0308_exposure gc0308_exposure_values[] = {
	[GC0308_EXP_M4] = GC0308_EXPOSURE(0xc0, 0x30),
	[GC0308_EXP_M3] = GC0308_EXPOSURE(0xd0, 0x38),
	[GC0308_EXP_M2] = GC0308_EXPOSURE(0xe0, 0x40),
	[GC0308_EXP_M1] = GC0308_EXPOSURE(0xf0, 0x48),
	[GC0308_EXP_0]  = GC0308_EXPOSURE(0x08, 0x50),
	[GC0308_EXP_P1] = GC0308_EXPOSURE(0x10, 0x5c),
	[GC0308_EXP_P2] = GC0308_EXPOSURE(0x20, 0x60),
	[GC0308_EXP_P3] = GC0308_EXPOSURE(0x30, 0x68),
	[GC0308_EXP_P4] = GC0308_EXPOSURE(0x40, 0x70),
};

struct gc0308_awb_gains {
	u8 r;
	u8 g;
	u8 b;
};

#define GC0308_AWB_GAINS(red, green, blue) \
	{ .r = red, .g = green, .b = blue }

static const struct gc0308_awb_gains gc0308_awb_gains[] = {
	[V4L2_WHITE_BALANCE_AUTO]         = GC0308_AWB_GAINS(0x56, 0x40, 0x4a),
	[V4L2_WHITE_BALANCE_CLOUDY]       = GC0308_AWB_GAINS(0x8c, 0x50, 0x40),
	[V4L2_WHITE_BALANCE_DAYLIGHT]     = GC0308_AWB_GAINS(0x74, 0x52, 0x40),
	[V4L2_WHITE_BALANCE_INCANDESCENT] = GC0308_AWB_GAINS(0x48, 0x40, 0x5c),
	[V4L2_WHITE_BALANCE_FLUORESCENT]  = GC0308_AWB_GAINS(0x40, 0x42, 0x50),
};

struct gc0308_format {
	u32 code;
	u8 regval;
};

#define GC0308_FORMAT(v4l2_code, gc0308_regval) \
	{ .code = v4l2_code, .regval = gc0308_regval }

static const struct gc0308_format gc0308_formats[] = {
	GC0308_FORMAT(MEDIA_BUS_FMT_UYVY8_2X8, 0x00),
	GC0308_FORMAT(MEDIA_BUS_FMT_VYUY8_2X8, 0x01),
	GC0308_FORMAT(MEDIA_BUS_FMT_YUYV8_2X8, 0x02),
	GC0308_FORMAT(MEDIA_BUS_FMT_YVYU8_2X8, 0x03),
	GC0308_FORMAT(MEDIA_BUS_FMT_RGB565_2X8_BE, 0x06),
	GC0308_FORMAT(MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, 0x07),
	GC0308_FORMAT(MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE, 0x09),
};

struct gc0308_frame_size {
	u8 subsample;
	u32 width;
	u32 height;
};

#define GC0308_FRAME_SIZE(s, w, h) \
	{ .subsample = s, .width = w, .height = h }

static const struct gc0308_frame_size gc0308_frame_sizes[] = {
	GC0308_FRAME_SIZE(0x11, 640, 480),
	GC0308_FRAME_SIZE(0x22, 320, 240),
	GC0308_FRAME_SIZE(0x44, 160, 120),
};

struct gc0308_mode_registers {
	u8 out_format;
	u8 subsample;
	u16 width;
	u16 height;
};

struct gc0308 {
	struct v4l2_subdev sd;
	struct v4l2_ctrl_handler hdl;
	struct media_pad pad;
	struct device *dev;
	struct clk *clk;
	struct regmap *regmap;
	struct regulator *vdd;
	struct gpio_desc *pwdn_gpio;
	struct gpio_desc *reset_gpio;
	unsigned int mbus_config;
	struct gc0308_mode_registers mode;
	struct {

Annotation

Implementation Notes