drivers/media/i2c/ov5640.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ov5640.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ov5640.c- Extension
.c- Size
- 104705 bytes
- Lines
- 4028
- 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/clk-provider.hlinux/clkdev.hlinux/ctype.hlinux/delay.hlinux/device.hlinux/gpio/consumer.hlinux/i2c.hlinux/init.hlinux/mod_devicetable.hlinux/module.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/slab.hlinux/types.hmedia/v4l2-async.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct ov5640_pixfmtstruct reg_valuestruct ov5640_timingsstruct ov5640_mode_infostruct ov5640_ctrlsstruct ov5640_devenum ov5640_mode_idenum ov5640_frame_rateenum ov5640_pixel_rate_idenum ov5640_format_muxenum ov5640_downsize_modefunction ov5640_is_csi2function ov5640_formatsfunction ov5640_code_to_pixfmtfunction ov5640_code_to_bppfunction ov5640_timingsfunction ov5640_init_slave_idfunction ov5640_write_regfunction ov5640_read_regfunction ov5640_read_reg16function ov5640_write_reg16function ov5640_mod_regfunction ov5640_compute_sys_clkfunction ov5640_calc_sys_clkfunction ov5640_set_mipi_pclkfunction ov5640_calc_pixel_ratefunction ov5640_calc_pclkfunction ov5640_set_dvp_pclkfunction ov5640_set_jpeg_timingsfunction ov5640_set_timingsfunction ov5640_load_regsfunction ov5640_set_autoexposurefunction ov5640_get_exposurefunction ov5640_set_exposurefunction ov5640_get_gainfunction ov5640_set_gainfunction ov5640_set_autogainfunction ov5640_set_stream_dvpfunction ov5640_set_stream_mipifunction ov5640_get_sysclkfunction ov5640_set_night_modefunction ov5640_get_htsfunction ov5640_get_vtsfunction ov5640_set_vtsfunction ov5640_get_light_freqfunction ov5640_set_bandingfilterfunction ov5640_set_ae_targetfunction ov5640_get_binning
Annotated Snippet
struct ov5640_pixfmt {
u32 code;
u32 colorspace;
u8 bpp;
u8 ctrl00;
enum ov5640_format_mux mux;
};
static const struct ov5640_pixfmt ov5640_dvp_formats[] = {
{
/* YUV422, YUYV */
.code = MEDIA_BUS_FMT_JPEG_1X8,
.colorspace = V4L2_COLORSPACE_JPEG,
.bpp = 16,
.ctrl00 = 0x30,
.mux = OV5640_FMT_MUX_YUV422,
}, {
/* YUV422, UYVY */
.code = MEDIA_BUS_FMT_UYVY8_2X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 16,
.ctrl00 = 0x3f,
.mux = OV5640_FMT_MUX_YUV422,
}, {
/* YUV422, YUYV */
.code = MEDIA_BUS_FMT_YUYV8_2X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 16,
.ctrl00 = 0x30,
.mux = OV5640_FMT_MUX_YUV422,
}, {
/* RGB565 {g[2:0],b[4:0]},{r[4:0],g[5:3]} */
.code = MEDIA_BUS_FMT_RGB565_2X8_LE,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 16,
.ctrl00 = 0x6f,
.mux = OV5640_FMT_MUX_RGB,
}, {
/* RGB565 {r[4:0],g[5:3]},{g[2:0],b[4:0]} */
.code = MEDIA_BUS_FMT_RGB565_2X8_BE,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 16,
.ctrl00 = 0x61,
.mux = OV5640_FMT_MUX_RGB,
}, {
/* Raw, BGBG... / GRGR... */
.code = MEDIA_BUS_FMT_SBGGR8_1X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 8,
.ctrl00 = 0x00,
.mux = OV5640_FMT_MUX_RAW_DPC,
}, {
/* Raw bayer, GBGB... / RGRG... */
.code = MEDIA_BUS_FMT_SGBRG8_1X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 8,
.ctrl00 = 0x01,
.mux = OV5640_FMT_MUX_RAW_DPC,
}, {
/* Raw bayer, GRGR... / BGBG... */
.code = MEDIA_BUS_FMT_SGRBG8_1X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 8,
.ctrl00 = 0x02,
.mux = OV5640_FMT_MUX_RAW_DPC,
}, {
/* Raw bayer, RGRG... / GBGB... */
.code = MEDIA_BUS_FMT_SRGGB8_1X8,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 8,
.ctrl00 = 0x03,
.mux = OV5640_FMT_MUX_RAW_DPC,
},
{ /* sentinel */ }
};
static const struct ov5640_pixfmt ov5640_csi2_formats[] = {
{
/* YUV422, YUYV */
.code = MEDIA_BUS_FMT_JPEG_1X8,
.colorspace = V4L2_COLORSPACE_JPEG,
.bpp = 16,
.ctrl00 = 0x30,
.mux = OV5640_FMT_MUX_YUV422,
}, {
/* YUV422, UYVY */
.code = MEDIA_BUS_FMT_UYVY8_1X16,
.colorspace = V4L2_COLORSPACE_SRGB,
.bpp = 16,
.ctrl00 = 0x3f,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/clkdev.h`, `linux/ctype.h`, `linux/delay.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/i2c.h`.
- Detected declarations: `struct ov5640_pixfmt`, `struct reg_value`, `struct ov5640_timings`, `struct ov5640_mode_info`, `struct ov5640_ctrls`, `struct ov5640_dev`, `enum ov5640_mode_id`, `enum ov5640_frame_rate`, `enum ov5640_pixel_rate_id`, `enum ov5640_format_mux`.
- 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.