drivers/media/i2c/ov2680.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ov2680.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ov2680.c- Extension
.c- Size
- 34087 bytes
- Lines
- 1325
- 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/clk.hlinux/delay.hlinux/err.hlinux/gpio/consumer.hlinux/i2c.hlinux/init.hlinux/mod_devicetable.hlinux/module.hlinux/pm_runtime.hlinux/regmap.hlinux/regulator/consumer.hmedia/v4l2-cci.hmedia/v4l2-common.hmedia/v4l2-ctrls.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct ov2680_ctrlsstruct ov2680_modestruct ov2680_devfunction ov2680_power_upfunction ov2680_power_downfunction ov2680_set_bayer_orderfunction __ov2680_get_pad_formatfunction __ov2680_get_pad_cropfunction ov2680_fill_formatfunction ov2680_calc_modefunction ov2680_set_modefunction ov2680_set_vflipfunction ov2680_set_hflipfunction ov2680_test_pattern_setfunction ov2680_gain_setfunction ov2680_exposure_setfunction ov2680_exposure_update_rangefunction ov2680_stream_enablefunction ov2680_stream_disablefunction ov2680_power_offfunction ov2680_power_onfunction ov2680_get_frame_intervalfunction ov2680_s_streamfunction ov2680_enum_mbus_codefunction ov2680_get_fmtfunction ov2680_set_fmtfunction ov2680_get_selectionfunction ov2680_set_selectionfunction ov2680_init_statefunction ov2680_enum_frame_sizefunction ov2680_valid_frame_sizefunction ov2680_enum_frame_intervalfunction ov2680_s_ctrlfunction ov2680_mode_initfunction ov2680_v4l2_registerfunction ov2680_get_regulatorsfunction ov2680_check_idfunction ov2680_parse_dtfunction ov2680_probefunction ov2680_removefunction ov2680_suspendfunction ov2680_resume
Annotated Snippet
struct ov2680_ctrls {
struct v4l2_ctrl_handler handler;
struct v4l2_ctrl *exposure;
struct v4l2_ctrl *gain;
struct v4l2_ctrl *hflip;
struct v4l2_ctrl *vflip;
struct v4l2_ctrl *test_pattern;
struct v4l2_ctrl *link_freq;
struct v4l2_ctrl *pixel_rate;
struct v4l2_ctrl *vblank;
struct v4l2_ctrl *hblank;
};
struct ov2680_mode {
struct v4l2_rect crop;
struct v4l2_mbus_framefmt fmt;
struct v4l2_fract frame_interval;
bool binning;
u16 h_start;
u16 v_start;
u16 h_end;
u16 v_end;
u16 h_output_size;
u16 v_output_size;
};
struct ov2680_dev {
struct device *dev;
struct regmap *regmap;
struct v4l2_subdev sd;
struct media_pad pad;
struct clk *xvclk;
u32 xvclk_freq;
u8 pll_mult;
s64 link_freq[1];
u64 pixel_rate;
struct regulator_bulk_data supplies[OV2680_NUM_SUPPLIES];
struct gpio_desc *pwdn_gpio;
struct mutex lock; /* protect members */
bool is_streaming;
struct ov2680_ctrls ctrls;
struct ov2680_mode mode;
};
static const struct v4l2_rect ov2680_default_crop = {
.left = OV2680_ACTIVE_START_LEFT,
.top = OV2680_ACTIVE_START_TOP,
.width = OV2680_ACTIVE_WIDTH,
.height = OV2680_ACTIVE_HEIGHT,
};
static const char * const test_pattern_menu[] = {
"Disabled",
"Color Bars",
"Random Data",
"Square",
"Black Image",
};
static const int ov2680_hv_flip_bayer_order[] = {
MEDIA_BUS_FMT_SBGGR10_1X10,
MEDIA_BUS_FMT_SGRBG10_1X10,
MEDIA_BUS_FMT_SGBRG10_1X10,
MEDIA_BUS_FMT_SRGGB10_1X10,
};
static const struct reg_sequence ov2680_global_setting[] = {
/* MIPI PHY, 0x10 -> 0x1c enable bp_c_hs_en_lat and bp_d_hs_en_lat */
{0x3016, 0x1c},
/* R MANUAL set exposure and gain to manual (hw does not do auto) */
{0x3503, 0x03},
/* Analog control register tweaks */
{0x3603, 0x39}, /* Reset value 0x99 */
{0x3604, 0x24}, /* Reset value 0x74 */
{0x3621, 0x37}, /* Reset value 0x44 */
/* Sensor control register tweaks */
{0x3701, 0x64}, /* Reset value 0x61 */
{0x3705, 0x3c}, /* Reset value 0x21 */
{0x370c, 0x50}, /* Reset value 0x10 */
{0x370d, 0xc0}, /* Reset value 0x00 */
{0x3718, 0x88}, /* Reset value 0x80 */
/* PSRAM tweaks */
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/init.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct ov2680_ctrls`, `struct ov2680_mode`, `struct ov2680_dev`, `function ov2680_power_up`, `function ov2680_power_down`, `function ov2680_set_bayer_order`, `function __ov2680_get_pad_format`, `function __ov2680_get_pad_crop`, `function ov2680_fill_format`, `function ov2680_calc_mode`.
- 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.