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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/device.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/mod_devicetable.hlinux/pm_runtime.hlinux/regmap.hlinux/regulator/consumer.hmedia/v4l2-cci.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct gc0308_exposurestruct gc0308_awb_gainsstruct gc0308_formatstruct gc0308_frame_sizestruct gc0308_mode_registersstruct gc0308struct gc0308_colormodeenum gc0308_exp_valfunction gc0308_power_onfunction gc0308_power_offfunction gc0308_g_registerfunction gc0308_s_registerfunction gc0308_set_exposurefunction gc0308_set_awb_modefunction gc0308_set_colormodefunction gc0308_set_power_line_freqfunction gc0308_update_mirrorfunction gc0308_update_blankingfunction _gc0308_s_ctrlfunction gc0308_s_ctrlfunction gc0308_enum_mbus_codefunction gc0308_get_format_idxfunction gc0308_enum_frame_sizefunction gc0308_update_pad_formatfunction gc0308_set_formatfunction gc0308_init_statefunction gc0308_set_resolutionfunction gc0308_start_streamfunction gc0308_stop_streamfunction gc0308_s_streamfunction gc0308_bus_configfunction gc0308_init_controlsfunction gc0308_probefunction gc0308_remove
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
- Immediate include surface: `linux/clk.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/pm_runtime.h`, `linux/regmap.h`.
- Detected declarations: `struct gc0308_exposure`, `struct gc0308_awb_gains`, `struct gc0308_format`, `struct gc0308_frame_size`, `struct gc0308_mode_registers`, `struct gc0308`, `struct gc0308_colormode`, `enum gc0308_exp_val`, `function gc0308_power_on`, `function gc0308_power_off`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.