drivers/media/platform/st/stm32/stm32-dcmi.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/st/stm32/stm32-dcmi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/st/stm32/stm32-dcmi.c- Extension
.c- Size
- 58214 bytes
- Lines
- 2302
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/completion.hlinux/delay.hlinux/dmaengine.hlinux/genalloc.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hlinux/videodev2.hmedia/v4l2-ctrls.hmedia/v4l2-dev.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fwnode.hmedia/v4l2-image-sizes.hmedia/v4l2-ioctl.hmedia/v4l2-rect.hmedia/videobuf2-dma-contig.h
Detected Declarations
struct dcmi_formatstruct dcmi_framesizestruct dcmi_bufstruct stm32_dcmienum statefunction reg_readfunction reg_writefunction reg_setfunction reg_clearfunction dcmi_buffer_donefunction dcmi_restart_capturefunction dcmi_start_dmafunction dcmi_start_capturefunction dcmi_set_cropfunction dcmi_process_framefunction dcmi_irq_threadfunction dcmi_irq_callbackfunction dcmi_queue_setupfunction dcmi_buf_initfunction dcmi_buf_preparefunction for_each_sgfunction for_each_sgfunction dcmi_buf_cleanupfunction dcmi_buf_queuefunction dcmi_pipeline_s_fmtfunction dcmi_start_streamingfunction dcmi_stop_streamingfunction dcmi_g_fmt_vid_capfunction __find_outer_frame_sizefunction dcmi_try_fmtfunction dcmi_set_fmtfunction dcmi_s_fmt_vid_capfunction dcmi_try_fmt_vid_capfunction dcmi_enum_fmt_vid_capfunction dcmi_get_sensor_formatfunction dcmi_set_sensor_formatfunction dcmi_get_sensor_boundsfunction dcmi_g_selectionfunction dcmi_s_selectionfunction dcmi_querycapfunction dcmi_enum_inputfunction dcmi_g_inputfunction dcmi_s_inputfunction dcmi_enum_framesizesfunction dcmi_g_parmfunction dcmi_s_parmfunction dcmi_enum_frameintervalsfunction dcmi_open
Annotated Snippet
struct dcmi_format {
u32 fourcc;
u32 mbus_code;
u8 bpp;
};
struct dcmi_framesize {
u32 width;
u32 height;
};
struct dcmi_buf {
struct vb2_v4l2_buffer vb;
bool prepared;
struct sg_table sgt;
struct sg_table sgt_mdma;
struct dma_async_tx_descriptor *dma_desc;
struct dma_async_tx_descriptor *mdma_desc;
size_t size;
struct list_head list;
};
struct stm32_dcmi {
/* Protects the access of variables shared within the interrupt */
spinlock_t irqlock;
struct device *dev;
void __iomem *regs;
struct resource *res;
struct reset_control *rstc;
int sequence;
struct list_head buffers;
struct dcmi_buf *active;
int irq;
struct v4l2_device v4l2_dev;
struct video_device *vdev;
struct v4l2_async_notifier notifier;
struct v4l2_subdev *source;
struct v4l2_subdev *s_subdev;
struct v4l2_format fmt;
struct v4l2_rect crop;
bool do_crop;
const struct dcmi_format **sd_formats;
unsigned int num_of_sd_formats;
const struct dcmi_format *sd_format;
struct dcmi_framesize *sd_framesizes;
unsigned int num_of_sd_framesizes;
struct dcmi_framesize sd_framesize;
struct v4l2_rect sd_bounds;
/* Protect this data structure */
struct mutex lock;
struct vb2_queue queue;
struct v4l2_mbus_config_parallel bus;
enum v4l2_mbus_type bus_type;
struct completion complete;
struct clk *mclk;
enum state state;
struct dma_chan *dma_chan;
dma_cookie_t dma_cookie;
u32 dma_max_burst;
/* Elements for the MDMA - DMA chaining */
struct gen_pool *sram_pool;
struct dma_chan *mdma_chan;
void *sram_buf;
u32 sram_buf_size;
dma_addr_t sram_dma_buf;
dma_cookie_t mdma_cookie;
u32 misr;
int errors_count;
int overrun_count;
int buffers_count;
struct media_device mdev;
struct media_pad vid_cap_pad;
struct media_pipeline pipeline;
};
static inline struct stm32_dcmi *notifier_to_dcmi(struct v4l2_async_notifier *n)
{
return container_of(n, struct stm32_dcmi, notifier);
}
static inline u32 reg_read(void __iomem *base, u32 reg)
{
return readl_relaxed(base + reg);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/dmaengine.h`, `linux/genalloc.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`.
- Detected declarations: `struct dcmi_format`, `struct dcmi_framesize`, `struct dcmi_buf`, `struct stm32_dcmi`, `enum state`, `function reg_read`, `function reg_write`, `function reg_set`, `function reg_clear`, `function dcmi_buffer_done`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.