drivers/media/i2c/ov13858.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ov13858.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ov13858.c- Extension
.c- Size
- 38783 bytes
- Lines
- 1782
- 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/i2c.hlinux/module.hlinux/pm_runtime.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fwnode.h
Detected Declarations
struct ov13858_regstruct ov13858_reg_liststruct ov13858_link_freq_configstruct ov13858_modestruct ov13858function link_freq_to_pixel_ratefunction ov13858_read_regfunction ov13858_write_regfunction ov13858_write_regsfunction ov13858_write_reg_listfunction ov13858_openfunction ov13858_update_digital_gainfunction ov13858_enable_test_patternfunction ov13858_set_ctrlfunction ov13858_enum_mbus_codefunction ov13858_enum_frame_sizefunction ov13858_update_pad_formatfunction ov13858_do_get_pad_formatfunction ov13858_get_pad_formatfunction ov13858_set_pad_formatfunction ov13858_get_skip_framesfunction ov13858_start_streamingfunction ov13858_stop_streamingfunction ov13858_set_streamfunction ov13858_identify_modulefunction ov13858_init_controlsfunction ov13858_free_controlsfunction ov13858_probefunction ov13858_remove
Annotated Snippet
struct ov13858_reg {
u16 address;
u8 val;
};
struct ov13858_reg_list {
u32 num_of_regs;
const struct ov13858_reg *regs;
};
/* Link frequency config */
struct ov13858_link_freq_config {
u32 pixels_per_line;
/* PLL registers for this link frequency */
struct ov13858_reg_list reg_list;
};
/* Mode : resolution and related config&values */
struct ov13858_mode {
/* Frame width */
u32 width;
/* Frame height */
u32 height;
/* V-timing */
u32 vts_def;
u32 vts_min;
/* Index of Link frequency config to be used */
u32 link_freq_index;
/* Default register values */
struct ov13858_reg_list reg_list;
};
/* 4224x3136 needs 1080Mbps/lane, 4 lanes */
static const struct ov13858_reg mipi_data_rate_1080mbps[] = {
/* PLL1 registers */
{OV13858_REG_PLL1_CTRL_0, 0x07},
{OV13858_REG_PLL1_CTRL_1, 0x01},
{OV13858_REG_PLL1_CTRL_2, 0xc2},
{OV13858_REG_PLL1_CTRL_3, 0x00},
{OV13858_REG_PLL1_CTRL_4, 0x00},
{OV13858_REG_PLL1_CTRL_5, 0x01},
/* PLL2 registers */
{OV13858_REG_PLL2_CTRL_B, 0x05},
{OV13858_REG_PLL2_CTRL_C, 0x01},
{OV13858_REG_PLL2_CTRL_D, 0x0e},
{OV13858_REG_PLL2_CTRL_E, 0x05},
{OV13858_REG_PLL2_CTRL_F, 0x01},
{OV13858_REG_PLL2_CTRL_12, 0x01},
{OV13858_REG_MIPI_SC_CTRL0, 0x72},
{OV13858_REG_MIPI_SC_CTRL1, 0x01},
};
/*
* 2112x1568, 2112x1188, 1056x784 need 540Mbps/lane,
* 4 lanes
*/
static const struct ov13858_reg mipi_data_rate_540mbps[] = {
/* PLL1 registers */
{OV13858_REG_PLL1_CTRL_0, 0x07},
{OV13858_REG_PLL1_CTRL_1, 0x01},
{OV13858_REG_PLL1_CTRL_2, 0xc2},
{OV13858_REG_PLL1_CTRL_3, 0x01},
{OV13858_REG_PLL1_CTRL_4, 0x00},
{OV13858_REG_PLL1_CTRL_5, 0x01},
/* PLL2 registers */
{OV13858_REG_PLL2_CTRL_B, 0x05},
{OV13858_REG_PLL2_CTRL_C, 0x01},
{OV13858_REG_PLL2_CTRL_D, 0x0e},
{OV13858_REG_PLL2_CTRL_E, 0x05},
{OV13858_REG_PLL2_CTRL_F, 0x01},
{OV13858_REG_PLL2_CTRL_12, 0x01},
{OV13858_REG_MIPI_SC_CTRL0, 0x72},
{OV13858_REG_MIPI_SC_CTRL1, 0x01},
};
static const struct ov13858_reg mode_4224x3136_regs[] = {
{0x3013, 0x32},
{0x301b, 0xf0},
{0x301f, 0xd0},
{0x3106, 0x15},
{0x3107, 0x23},
{0x350a, 0x00},
{0x350e, 0x00},
{0x3510, 0x00},
{0x3511, 0x02},
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/clk.h`, `linux/i2c.h`, `linux/module.h`, `linux/pm_runtime.h`, `media/v4l2-ctrls.h`, `media/v4l2-device.h`, `media/v4l2-event.h`.
- Detected declarations: `struct ov13858_reg`, `struct ov13858_reg_list`, `struct ov13858_link_freq_config`, `struct ov13858_mode`, `struct ov13858`, `function link_freq_to_pixel_rate`, `function ov13858_read_reg`, `function ov13858_write_reg`, `function ov13858_write_regs`, `function ov13858_write_reg_list`.
- 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.