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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/acpi.hlinux/clk.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/mod_devicetable.hlinux/module.hlinux/of.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/unaligned.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fwnode.h
Detected Declarations
struct ov5670_regstruct ov5670_reg_liststruct ov5670_link_freq_configstruct ov5670_modestruct ov5670function ov5670_read_regfunction ov5670_write_regfunction ov5670_write_regsfunction ov5670_write_reg_listfunction ov5670_update_digital_gainfunction ov5670_enable_test_patternfunction ov5670_set_ctrlfunction ov5670_init_controlsfunction ov5670_init_statefunction ov5670_enum_mbus_codefunction ov5670_enum_frame_sizefunction ov5670_update_pad_formatfunction ov5670_do_get_pad_formatfunction ov5670_get_pad_formatfunction ov5670_set_pad_formatfunction ov5670_get_skip_framesfunction ov5670_identify_modulefunction ov5670_mipi_configurefunction ov5670_start_streamingfunction ov5670_stop_streamingfunction ov5670_set_streamfunction ov5670_runtime_resumefunction ov5670_runtime_suspendfunction __ov5670_get_pad_cropfunction ov5670_get_selectionfunction ov5670_regulators_probefunction ov5670_gpio_probefunction ov5670_probefunction ov5670_remove
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
- Immediate include surface: `linux/acpi.h`, `linux/clk.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct ov5670_reg`, `struct ov5670_reg_list`, `struct ov5670_link_freq_config`, `struct ov5670_mode`, `struct ov5670`, `function ov5670_read_reg`, `function ov5670_write_reg`, `function ov5670_write_regs`, `function ov5670_write_reg_list`, `function ov5670_update_digital_gain`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.