drivers/media/platform/cadence/cdns-csi2rx.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/cadence/cdns-csi2rx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/cadence/cdns-csi2rx.c- Extension
.c- Size
- 30544 bytes
- Lines
- 1114
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/clk.hlinux/delay.hlinux/export.hlinux/io.hlinux/iopoll.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/phy/phy.hlinux/platform_device.hlinux/reset.hlinux/slab.hmedia/cadence/cdns-csi2rx.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct csi2rx_fmtstruct csi2rx_eventstruct csi2rx_privenum csi2rx_padsfunction csi2rx_configure_error_irq_maskfunction csi2rx_irq_handlerfunction csi2rx_get_frame_desc_from_sourcefunction csi2rx_resetfunction csi2rx_configure_ext_dphyfunction v4l2_get_link_freqfunction csi2rx_startfunction csi2rx_stopfunction csi2rx_log_statusfunction csi2rx_update_vc_selectfunction for_each_active_routefunction csi2rx_enable_streamsfunction csi2rx_disable_streamsfunction csi2rx_enum_mbus_codefunction _csi2rx_set_routingfunction csi2rx_set_routingfunction csi2rx_set_fmtfunction csi2rx_init_statefunction cdns_csi2rx_negotiate_ppcfunction csi2rx_async_boundfunction csi2rx_get_resourcesfunction csi2rx_parse_dtfunction csi2rx_probefunction csi2rx_removefunction csi2rx_runtime_suspendfunction csi2rx_runtime_resume
Annotated Snippet
struct csi2rx_fmt {
u32 code;
/* width of a single pixel on CSI-2 bus */
u8 bpp;
/* max pixels per clock supported on output bus */
u8 max_pixels;
};
struct csi2rx_event {
u32 mask;
const char *name;
};
static const struct csi2rx_event csi2rx_events[] = {
{ CSI2RX_STREAM3_FIFO_OVERFLOW_IRQ, "Overflow of the Stream 3 FIFO detected" },
{ CSI2RX_STREAM2_FIFO_OVERFLOW_IRQ, "Overflow of the Stream 2 FIFO detected" },
{ CSI2RX_STREAM1_FIFO_OVERFLOW_IRQ, "Overflow of the Stream 1 FIFO detected" },
{ CSI2RX_STREAM0_FIFO_OVERFLOW_IRQ, "Overflow of the Stream 0 FIFO detected" },
{ CSI2RX_FRONT_TRUNC_HDR_IRQ, "A truncated header [short or long] has been received" },
{ CSI2RX_PROT_TRUNCATED_PACKET_IRQ, "A truncated long packet has been received" },
{ CSI2RX_FRONT_LP_NO_PAYLOAD_IRQ, "A truncated long packet has been received. No payload" },
{ CSI2RX_SP_INVALID_RCVD_IRQ, "A reserved or invalid short packet has been received" },
{ CSI2RX_DATA_ID_IRQ, "Data ID error in the header packet" },
{ CSI2RX_HEADER_CORRECTED_ECC_IRQ, "ECC error detected and corrected" },
{ CSI2RX_HEADER_ECC_IRQ, "Unrecoverable ECC error" },
{ CSI2RX_PAYLOAD_CRC_IRQ, "CRC error" },
};
#define CSI2RX_NUM_EVENTS ARRAY_SIZE(csi2rx_events)
struct csi2rx_priv {
struct device *dev;
unsigned int count;
int error_irq;
void __iomem *base;
struct clk *sys_clk;
struct clk *p_clk;
struct clk *pixel_clk[CSI2RX_STREAMS_MAX];
struct reset_control *sys_rst;
struct reset_control *p_rst;
struct reset_control *pixel_rst[CSI2RX_STREAMS_MAX];
struct phy *dphy;
u8 num_pixels[CSI2RX_STREAMS_MAX];
u32 vc_select[CSI2RX_STREAMS_MAX];
u8 lanes[CSI2RX_LANES_MAX];
u8 num_lanes;
u8 max_lanes;
u8 max_streams;
bool has_internal_dphy;
u32 events[CSI2RX_NUM_EVENTS];
struct v4l2_subdev subdev;
struct v4l2_async_notifier notifier;
struct media_pad pads[CSI2RX_PAD_MAX];
/* Remote source */
struct v4l2_subdev *source_subdev;
int source_pad;
};
static const struct csi2rx_fmt formats[] = {
{ .code = MEDIA_BUS_FMT_YUYV8_1X16, .bpp = 16, .max_pixels = 2, },
{ .code = MEDIA_BUS_FMT_UYVY8_1X16, .bpp = 16, .max_pixels = 2, },
{ .code = MEDIA_BUS_FMT_YVYU8_1X16, .bpp = 16, .max_pixels = 2, },
{ .code = MEDIA_BUS_FMT_VYUY8_1X16, .bpp = 16, .max_pixels = 2, },
{ .code = MEDIA_BUS_FMT_SBGGR8_1X8, .bpp = 8, .max_pixels = 4, },
{ .code = MEDIA_BUS_FMT_SGBRG8_1X8, .bpp = 8, .max_pixels = 4, },
{ .code = MEDIA_BUS_FMT_SGRBG8_1X8, .bpp = 8, .max_pixels = 4, },
{ .code = MEDIA_BUS_FMT_SRGGB8_1X8, .bpp = 8, .max_pixels = 4, },
{ .code = MEDIA_BUS_FMT_Y8_1X8, .bpp = 8, .max_pixels = 4, },
{ .code = MEDIA_BUS_FMT_SBGGR10_1X10, .bpp = 10, .max_pixels = 2, },
{ .code = MEDIA_BUS_FMT_SGBRG10_1X10, .bpp = 10, .max_pixels = 2, },
{ .code = MEDIA_BUS_FMT_SGRBG10_1X10, .bpp = 10, .max_pixels = 2, },
{ .code = MEDIA_BUS_FMT_SRGGB10_1X10, .bpp = 10, .max_pixels = 2, },
{ .code = MEDIA_BUS_FMT_RGB565_1X16, .bpp = 16, .max_pixels = 1, },
{ .code = MEDIA_BUS_FMT_RGB888_1X24, .bpp = 24, .max_pixels = 1, },
{ .code = MEDIA_BUS_FMT_BGR888_1X24, .bpp = 24, .max_pixels = 1, },
};
static void csi2rx_configure_error_irq_mask(void __iomem *base,
struct csi2rx_priv *csi2rx)
{
u32 error_irq_mask = 0;
error_irq_mask |= CSI2RX_ECC_ERRORS;
error_irq_mask |= CSI2RX_PACKET_ERRORS;
/*
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/export.h`, `linux/io.h`, `linux/iopoll.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct csi2rx_fmt`, `struct csi2rx_event`, `struct csi2rx_priv`, `enum csi2rx_pads`, `function csi2rx_configure_error_irq_mask`, `function csi2rx_irq_handler`, `function csi2rx_get_frame_desc_from_source`, `function csi2rx_reset`, `function csi2rx_configure_ext_dphy`, `function v4l2_get_link_freq`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- 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.