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.

Dependency Surface

Detected Declarations

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

Implementation Notes