drivers/media/i2c/ov2640.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ov2640.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ov2640.c- Extension
.c- Size
- 38178 bytes
- Lines
- 1300
- 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/init.hlinux/module.hlinux/i2c.hlinux/clk.hlinux/slab.hlinux/delay.hlinux/gpio/consumer.hlinux/v4l2-mediabus.hlinux/videodev2.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-subdev.hmedia/v4l2-ctrls.hmedia/v4l2-image-sizes.h
Detected Declarations
struct regval_liststruct ov2640_win_sizestruct ov2640_privfunction ov2640_write_arrayfunction ov2640_mask_setfunction ov2640_resetfunction ov2640_s_ctrlfunction ov2640_g_registerfunction ov2640_s_registerfunction ov2640_set_powerfunction ov2640_s_powerfunction ov2640_set_paramsfunction ov2640_get_fmtfunction ov2640_set_fmtfunction ov2640_init_statefunction ov2640_enum_mbus_codefunction ov2640_get_selectionfunction ov2640_s_streamfunction ov2640_video_probefunction ov2640_probe_dtfunction ov2640_probefunction ov2640_remove
Annotated Snippet
struct regval_list {
u8 reg_num;
u8 value;
};
struct ov2640_win_size {
char *name;
u32 width;
u32 height;
const struct regval_list *regs;
};
struct ov2640_priv {
struct v4l2_subdev subdev;
struct media_pad pad;
struct v4l2_ctrl_handler hdl;
u32 cfmt_code;
struct clk *clk;
const struct ov2640_win_size *win;
struct gpio_desc *resetb_gpio;
struct gpio_desc *pwdn_gpio;
struct mutex lock; /* lock to protect streaming and power_count */
bool streaming;
int power_count;
};
/*
* Registers settings
*/
#define ENDMARKER { 0xff, 0xff }
static const struct regval_list ov2640_init_regs[] = {
{ BANK_SEL, BANK_SEL_DSP },
{ 0x2c, 0xff },
{ 0x2e, 0xdf },
{ BANK_SEL, BANK_SEL_SENS },
{ 0x3c, 0x32 },
{ CLKRC, CLKRC_DIV_SET(1) },
{ COM2, COM2_OCAP_Nx_SET(3) },
{ REG04, REG04_DEF | REG04_HREF_EN },
{ COM8, COM8_DEF | COM8_BNDF_EN | COM8_AGC_EN | COM8_AEC_EN },
{ COM9, COM9_AGC_GAIN_8x | 0x08},
{ 0x2c, 0x0c },
{ 0x33, 0x78 },
{ 0x3a, 0x33 },
{ 0x3b, 0xfb },
{ 0x3e, 0x00 },
{ 0x43, 0x11 },
{ 0x16, 0x10 },
{ 0x39, 0x02 },
{ 0x35, 0x88 },
{ 0x22, 0x0a },
{ 0x37, 0x40 },
{ 0x23, 0x00 },
{ ARCOM2, 0xa0 },
{ 0x06, 0x02 },
{ 0x06, 0x88 },
{ 0x07, 0xc0 },
{ 0x0d, 0xb7 },
{ 0x0e, 0x01 },
{ 0x4c, 0x00 },
{ 0x4a, 0x81 },
{ 0x21, 0x99 },
{ AEW, 0x40 },
{ AEB, 0x38 },
{ VV, VV_HIGH_TH_SET(0x08) | VV_LOW_TH_SET(0x02) },
{ 0x5c, 0x00 },
{ 0x63, 0x00 },
{ FLL, 0x22 },
{ COM3, 0x38 | COM3_BAND_AUTO },
{ REG5D, 0x55 },
{ REG5E, 0x7d },
{ REG5F, 0x7d },
{ REG60, 0x55 },
{ HISTO_LOW, 0x70 },
{ HISTO_HIGH, 0x80 },
{ 0x7c, 0x05 },
{ 0x20, 0x80 },
{ 0x28, 0x30 },
{ 0x6c, 0x00 },
{ 0x6d, 0x80 },
{ 0x6e, 0x00 },
{ 0x70, 0x02 },
{ 0x71, 0x94 },
{ 0x73, 0xc1 },
{ 0x3d, 0x34 },
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/i2c.h`, `linux/clk.h`, `linux/slab.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/v4l2-mediabus.h`.
- Detected declarations: `struct regval_list`, `struct ov2640_win_size`, `struct ov2640_priv`, `function ov2640_write_array`, `function ov2640_mask_set`, `function ov2640_reset`, `function ov2640_s_ctrl`, `function ov2640_g_register`, `function ov2640_s_register`, `function ov2640_set_power`.
- 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.