drivers/media/i2c/ov5648.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ov5648.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ov5648.c- Extension
.c- Size
- 67751 bytes
- Lines
- 2636
- 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/device.hlinux/i2c.hlinux/module.hlinux/of_graph.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/videodev2.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-fwnode.hmedia/v4l2-image-sizes.hmedia/v4l2-mediabus.h
Detected Declarations
struct ov5648_register_valuestruct ov5648_pll1_configstruct ov5648_pll2_configstruct ov5648_modestruct ov5648_statestruct ov5648_ctrlsstruct ov5648_sensorfunction ov5648_readfunction ov5648_writefunction ov5648_write_sequencefunction ov5648_update_bitsfunction ov5648_sw_resetfunction ov5648_sw_standbyfunction ov5648_chip_id_checkfunction ov5648_avdd_internal_powerfunction ov5648_pad_configurefunction ov5648_mipi_configurefunction ov5648_black_level_configurefunction ov5648_isp_configurefunction ov5648_mode_pll1_ratefunction ov5648_mode_pll1_configurefunction ov5648_mode_pll2_configurefunction ov5648_mode_configurefunction ov5648_mode_mipi_clk_ratefunction ov5648_exposure_auto_configurefunction ov5648_exposure_configurefunction ov5648_exposure_valuefunction ov5648_gain_auto_configurefunction ov5648_gain_configurefunction ov5648_gain_valuefunction ov5648_white_balance_auto_configurefunction ov5648_white_balance_configurefunction ov5648_flip_vert_configurefunction ov5648_flip_horz_configurefunction ov5648_test_pattern_configurefunction ov5648_state_mipi_configurefunction ov5648_state_configurefunction ov5648_state_initfunction ov5648_sensor_initfunction ov5648_sensor_powerfunction ov5648_g_volatile_ctrlfunction ov5648_s_ctrlfunction ov5648_ctrls_initfunction ov5648_s_streamfunction ov5648_enum_mbus_codefunction ov5648_mbus_format_fillfunction ov5648_get_fmtfunction ov5648_set_fmt
Annotated Snippet
struct ov5648_register_value {
u16 address;
u8 value;
unsigned int delay_ms;
};
/*
* PLL1 Clock Tree:
*
* +-< XVCLK
* |
* +-+ pll_pre_div (0x3037 [3:0], special values: 5: 1.5, 7: 2.5)
* |
* +-+ pll_mul (0x3036 [7:0])
* |
* +-+ sys_div (0x3035 [7:4])
* |
* +-+ mipi_div (0x3035 [3:0])
* | |
* | +-> MIPI_SCLK
* | |
* | +-+ mipi_phy_div (2)
* | |
* | +-> MIPI_CLK
* |
* +-+ root_div (0x3037 [4])
* |
* +-+ bit_div (0x3034 [3:0], 8 bits: 2, 10 bits: 2.5, other: 1)
* |
* +-+ sclk_div (0x3106 [3:2])
* |
* +-> SCLK
* |
* +-+ mipi_div (0x3035, 1: PCLK = SCLK)
* |
* +-> PCLK
*/
struct ov5648_pll1_config {
unsigned int pll_pre_div;
unsigned int pll_mul;
unsigned int sys_div;
unsigned int root_div;
unsigned int sclk_div;
unsigned int mipi_div;
};
/*
* PLL2 Clock Tree:
*
* +-< XVCLK
* |
* +-+ plls_pre_div (0x303d [5:4], special values: 0: 1, 1: 1.5)
* |
* +-+ plls_div_r (0x303d [2])
* |
* +-+ plls_mul (0x303b [4:0])
* |
* +-+ sys_div (0x303c [3:0])
* |
* +-+ sel_div (0x303d [1:0], special values: 0: 1, 3: 2.5)
* |
* +-> ADCLK
*/
struct ov5648_pll2_config {
unsigned int plls_pre_div;
unsigned int plls_div_r;
unsigned int plls_mul;
unsigned int sys_div;
unsigned int sel_div;
};
/*
* General formulas for (array-centered) mode calculation:
* - photo_array_width = 2624
* - crop_start_x = (photo_array_width - output_size_x) / 2
* - crop_end_x = crop_start_x + offset_x + output_size_x - 1
*
* - photo_array_height = 1956
* - crop_start_y = (photo_array_height - output_size_y) / 2
* - crop_end_y = crop_start_y + offset_y + output_size_y - 1
*/
struct ov5648_mode {
unsigned int crop_start_x;
unsigned int offset_x;
unsigned int output_size_x;
unsigned int crop_end_x;
unsigned int hts;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/i2c.h`, `linux/module.h`, `linux/of_graph.h`, `linux/pm_runtime.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct ov5648_register_value`, `struct ov5648_pll1_config`, `struct ov5648_pll2_config`, `struct ov5648_mode`, `struct ov5648_state`, `struct ov5648_ctrls`, `struct ov5648_sensor`, `function ov5648_read`, `function ov5648_write`, `function ov5648_write_sequence`.
- 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.