drivers/media/platform/st/stm32/stm32-csi.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/st/stm32/stm32-csi.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/st/stm32/stm32-csi.c
Extension
.c
Size
34861 bytes
Lines
1142
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 stm32_csi_event {
	u32 mask;
	const char * const name;
};

static const struct stm32_csi_event stm32_csi_events_sr0[] = {
	{STM32_CSI_SR0_SYNCERRF,	"Synchronization error"},
	{STM32_CSI_SR0_SPKTERRF,	"Short packet error"},
	{STM32_CSI_SR0_IDERRF,		"Data type ID error"},
	{STM32_CSI_SR0_CECCERRF,	"Corrected ECC error"},
	{STM32_CSI_SR0_ECCERRF,		"ECC error"},
	{STM32_CSI_SR0_CRCERRF,		"CRC error"},
	{STM32_CSI_SR0_CCFIFOFF,	"Clk changer FIFO full error"},
};

#define STM32_CSI_NUM_SR0_EVENTS ARRAY_SIZE(stm32_csi_events_sr0)

static const struct stm32_csi_event stm32_csi_events_sr1[] = {
	{STM32_CSI_SR1_ECTRLDL1F,	"L1: D-PHY control error"},
	{STM32_CSI_SR1_ESYNCESCDL1F,
		"L1: D-PHY low power data transmission synchro error"},
	{STM32_CSI_SR1_EESCDL1F,	"L1: D-PHY escape entry error"},
	{STM32_CSI_SR1_ESOTSYNCDL1F,
		"L1: Start of transmission synchro error"},
	{STM32_CSI_SR1_ESOTDL1F,	"L1: Start of transmission error"},
	{STM32_CSI_SR1_ECTRLDL0F,	"L0: D-PHY control error"},
	{STM32_CSI_SR1_ESYNCESCDL0F,
		"L0: D-PHY low power data transmission synchro error"},
	{STM32_CSI_SR1_EESCDL0F,	"L0: D-PHY escape entry error"},
	{STM32_CSI_SR1_ESOTSYNCDL0F,
		"L0: Start of transmission synchro error"},
	{STM32_CSI_SR1_ESOTDL0F,	"L0: Start of transmission error"},
};

#define STM32_CSI_NUM_SR1_EVENTS ARRAY_SIZE(stm32_csi_events_sr1)

enum stm32_csi_clk {
	STM32_CSI_CLK_PCLK,
	STM32_CSI_CLK_TXESC,
	STM32_CSI_CLK_CSI2PHY,
	STM32_CSI_CLK_NB,
};

static const char * const stm32_csi_clks_id[] = {
	"pclk",
	"txesc",
	"csi2phy",
};

struct stm32_csi_dev {
	struct device			*dev;

	void __iomem			*base;

	struct clk_bulk_data		clks[STM32_CSI_CLK_NB];
	struct regulator_bulk_data	supplies[2];

	u8				lanes[STM32_CSI_LANES_MAX];
	u8				num_lanes;

	/*
	 * spinlock slock is used to protect to srX_counters tables being
	 * accessed from log_status and interrupt context
	 */
	spinlock_t			slock;

	u32				sr0_counters[STM32_CSI_NUM_SR0_EVENTS];
	u32				sr1_counters[STM32_CSI_NUM_SR1_EVENTS];

	struct v4l2_subdev		sd;
	struct v4l2_async_notifier	notifier;
	struct media_pad		pads[STM32_CSI_PAD_MAX];

	/* Remote source */
	struct v4l2_subdev		*s_subdev;
	u32				s_subdev_pad_nb;
};

struct stm32_csi_fmts {
	u32 code;
	u32 datatype;
	u32 input_fmt;
	u8 bpp;
};

#define FMT_MBUS_DT_DTFMT_BPP(mbus, dt, input, byteperpixel)		\
	{								\
		.code = MEDIA_BUS_FMT_##mbus,				\
		.datatype = MIPI_CSI2_DT_##dt,				\
		.input_fmt = STM32_CSI_INPUT_##input,	\

Annotation

Implementation Notes