drivers/media/i2c/ov7251.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ov7251.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ov7251.c- Extension
.c- Size
- 43687 bytes
- Lines
- 1825
- 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/bitops.hlinux/clk.hlinux/delay.hlinux/device.hlinux/gpio/consumer.hlinux/i2c.hlinux/init.hlinux/module.hlinux/mod_devicetable.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/slab.hlinux/types.hmedia/v4l2-ctrls.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct reg_valuestruct ov7251_mode_infostruct ov7251_pll1_cfgstruct ov7251_pll2_cfgstruct ov7251_pll_cfgsstruct ov7251enum xclk_rateenum supported_link_freqsfunction ov7251_regulators_enablefunction ov7251_regulators_disablefunction ov7251_write_regfunction ov7251_write_seq_regsfunction ov7251_read_regfunction ov7251_pll_configurefunction ov7251_set_exposurefunction ov7251_set_gainfunction ov7251_set_register_arrayfunction ov7251_set_power_onfunction ov7251_set_power_offfunction ov7251_set_hflipfunction ov7251_set_vflipfunction ov7251_set_test_patternfunction ov7251_vts_configurefunction ov7251_s_ctrlfunction ov7251_enum_mbus_codefunction ov7251_enum_frame_sizefunction ov7251_enum_frame_ivalfunction __ov7251_get_pad_formatfunction ov7251_get_formatfunction __ov7251_get_pad_cropfunction avg_fpsfunction ov7251_find_mode_by_ivalfunction ov7251_set_formatfunction ov7251_init_statefunction ov7251_get_selectionfunction ov7251_s_streamfunction ov7251_get_frame_intervalfunction ov7251_set_frame_intervalfunction ov7251_check_hwcfgfunction ov7251_detect_chipfunction ov7251_init_ctrlsfunction ov7251_probefunction ov7251_remove
Annotated Snippet
struct reg_value {
u16 reg;
u8 val;
};
struct ov7251_mode_info {
u32 width;
u32 height;
u32 vts;
const struct reg_value *data;
u32 data_size;
u32 pixel_clock;
u32 link_freq;
u16 exposure_max;
u16 exposure_def;
struct v4l2_fract timeperframe;
};
struct ov7251_pll1_cfg {
unsigned int pre_div;
unsigned int mult;
unsigned int div;
unsigned int pix_div;
unsigned int mipi_div;
};
struct ov7251_pll2_cfg {
unsigned int pre_div;
unsigned int mult;
unsigned int div;
unsigned int sys_div;
unsigned int adc_div;
};
/*
* Rubbish ordering, but only PLL1 needs to have a separate configuration per
* link frequency and the array member needs to be last.
*/
struct ov7251_pll_cfgs {
const struct ov7251_pll2_cfg *pll2;
const struct ov7251_pll1_cfg *pll1[];
};
enum xclk_rate {
OV7251_19_2_MHZ,
OV7251_24_MHZ,
OV7251_NUM_SUPPORTED_RATES
};
enum supported_link_freqs {
OV7251_LINK_FREQ_240_MHZ,
OV7251_LINK_FREQ_319_2_MHZ,
OV7251_NUM_SUPPORTED_LINK_FREQS
};
struct ov7251 {
struct i2c_client *i2c_client;
struct device *dev;
struct v4l2_subdev sd;
struct media_pad pad;
struct v4l2_fwnode_endpoint ep;
struct v4l2_mbus_framefmt fmt;
struct v4l2_rect crop;
struct clk *xclk;
u32 xclk_freq;
struct regulator *io_regulator;
struct regulator *core_regulator;
struct regulator *analog_regulator;
const struct ov7251_pll_cfgs *pll_cfgs;
enum supported_link_freqs link_freq_idx;
const struct ov7251_mode_info *current_mode;
struct v4l2_ctrl_handler ctrls;
struct v4l2_ctrl *pixel_clock;
struct v4l2_ctrl *link_freq;
struct v4l2_ctrl *exposure;
struct v4l2_ctrl *gain;
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *vblank;
/* Cached register values */
u8 aec_pk_manual;
u8 pre_isp_00;
u8 timing_format1;
u8 timing_format2;
struct mutex lock; /* lock to protect power state, ctrls and mode */
bool power_on;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/init.h`, `linux/module.h`.
- Detected declarations: `struct reg_value`, `struct ov7251_mode_info`, `struct ov7251_pll1_cfg`, `struct ov7251_pll2_cfg`, `struct ov7251_pll_cfgs`, `struct ov7251`, `enum xclk_rate`, `enum supported_link_freqs`, `function ov7251_regulators_enable`, `function ov7251_regulators_disable`.
- 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.