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.
- 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/delay.hlinux/io.hlinux/iopoll.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hlinux/slab.hmedia/mipi-csi2.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct stm32_csi_eventstruct stm32_csi_devstruct stm32_csi_fmtsstruct stm32_csi_mbps_phy_regenum stm32_csi_padsenum stm32_csi_clkfunction stm32_csi_setup_lane_mergerfunction stm32_csi_phy_reg_writefunction stm32_csi_startfunction stm32_csi_stopfunction stm32_csi_start_vcfunction stm32_csi_stop_vcfunction stm32_csi_disable_streamsfunction stm32_csi_enable_streamsfunction stm32_csi_init_statefunction stm32_csi_enum_mbus_codefunction stm32_csi_set_pad_formatfunction stm32_csi_log_statusfunction stm32_csi_async_boundfunction stm32_csi_irq_threadfunction stm32_csi_get_resourcesfunction stm32_csi_parse_dtfunction stm32_csi_probefunction stm32_csi_removefunction stm32_csi_runtime_suspendfunction stm32_csi_runtime_resume
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
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/io.h`, `linux/iopoll.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/reset.h`.
- Detected declarations: `struct stm32_csi_event`, `struct stm32_csi_dev`, `struct stm32_csi_fmts`, `struct stm32_csi_mbps_phy_reg`, `enum stm32_csi_pads`, `enum stm32_csi_clk`, `function stm32_csi_setup_lane_merger`, `function stm32_csi_phy_reg_write`, `function stm32_csi_start`, `function stm32_csi_stop`.
- 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.