drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c- Extension
.c- Size
- 46854 bytes
- Lines
- 1806
- 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/bitfield.hlinux/dmaengine.hlinux/module.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.hlinux/property.hmedia/cadence/cdns-csi2rx.hmedia/mipi-csi2.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/v4l2-mc.hmedia/videobuf2-dma-contig.h
Detected Declarations
struct ti_csi2rx_fmtstruct ti_csi2rx_bufferstruct ti_csi2rx_dmastruct ti_csi2rx_devstruct ti_csi2rx_ctxstruct ti_csi2rx_devenum ti_csi2rx_dma_statefunction ti_csi2rx_fill_fmtfunction ti_csi2rx_querycapfunction ti_csi2rx_enum_fmt_vid_capfunction ti_csi2rx_g_fmt_vid_capfunction ti_csi2rx_try_fmt_vid_capfunction ti_csi2rx_s_fmt_vid_capfunction ti_csi2rx_enum_framesizesfunction csi_async_notifier_boundfunction csi_async_notifier_completefunction ti_csi2rx_notifier_registerfunction ti_csi2rx_request_max_ppcfunction ti_csi2rx_setup_shimfunction ti_csi2rx_drain_callbackfunction ti_csi2rx_drain_dmafunction ti_csi2rx_dma_submit_pendingfunction ti_csi2rx_dma_callbackfunction ti_csi2rx_start_dmafunction ti_csi2rx_stop_dmafunction ti_csi2rx_cleanup_buffersfunction ti_csi2rx_queue_setupfunction ti_csi2rx_buffer_preparefunction ti_csi2rx_buffer_queuefunction ti_csi2rx_get_streamfunction for_each_active_routefunction ti_csi2rx_get_vc_and_dtfunction ti_csi2rx_start_streamingfunction ti_csi2rx_stop_streamingfunction ti_csi2rx_enum_mbus_codefunction ti_csi2rx_sd_set_fmtfunction _ti_csi2rx_sd_set_routingfunction ti_csi2rx_sd_set_routingfunction ti_csi2rx_sd_init_statefunction ti_csi2rx_sd_enable_streamsfunction ti_csi2rx_sd_disable_streamsfunction ti_csi2rx_cleanup_v4l2function ti_csi2rx_cleanup_notifierfunction ti_csi2rx_cleanup_ctxfunction ti_csi2rx_init_vb2qfunction ti_csi2rx_link_validatefunction ti_csi2rx_init_dmafunction ti_csi2rx_v4l2_init
Annotated Snippet
struct ti_csi2rx_fmt {
u32 fourcc; /* Four character code. */
u32 code; /* Mbus code. */
u32 csi_dt; /* CSI Data type. */
u8 bpp; /* Bits per pixel. */
u8 size; /* Data size shift when unpacking. */
};
struct ti_csi2rx_buffer {
/* Common v4l2 buffer. Must be first. */
struct vb2_v4l2_buffer vb;
struct list_head list;
struct ti_csi2rx_ctx *ctx;
};
enum ti_csi2rx_dma_state {
TI_CSI2RX_DMA_STOPPED, /* Streaming not started yet. */
TI_CSI2RX_DMA_ACTIVE, /* Streaming and pending DMA operation. */
TI_CSI2RX_DMA_DRAINING, /* Dumping all the data in drain buffer */
};
struct ti_csi2rx_dma {
/* Protects all fields in this struct. */
spinlock_t lock;
struct dma_chan *chan;
/* Buffers queued to the driver, waiting to be processed by DMA. */
struct list_head queue;
enum ti_csi2rx_dma_state state;
/*
* Queue of buffers submitted to DMA engine.
*/
struct list_head submitted;
};
struct ti_csi2rx_dev;
struct ti_csi2rx_ctx {
struct ti_csi2rx_dev *csi;
struct video_device vdev;
struct vb2_queue vidq;
struct mutex mutex; /* To serialize ioctls. */
struct v4l2_format v_fmt;
struct ti_csi2rx_dma dma;
struct media_pad pad;
struct completion drain_complete;
u32 sequence;
u32 idx;
u32 vc;
u32 dt;
u32 stream;
};
struct ti_csi2rx_dev {
struct device *dev;
void __iomem *shim;
unsigned int enable_count;
unsigned int num_ctx;
struct v4l2_device v4l2_dev;
struct media_device mdev;
struct media_pipeline pipe;
struct media_pad pads[TI_CSI2RX_MAX_PADS];
struct v4l2_async_notifier notifier;
struct v4l2_subdev *source;
struct v4l2_subdev subdev;
struct ti_csi2rx_ctx ctx[TI_CSI2RX_MAX_CTX];
struct notifier_block pm_notifier;
u8 pix_per_clk;
/* Buffer to drain stale data from PSI-L endpoint */
struct {
void *vaddr;
dma_addr_t paddr;
size_t len;
} drain;
};
static inline struct ti_csi2rx_dev *to_csi2rx_dev(struct v4l2_subdev *sd)
{
return container_of(sd, struct ti_csi2rx_dev, subdev);
}
static const struct ti_csi2rx_fmt ti_csi2rx_formats[] = {
{
.fourcc = V4L2_PIX_FMT_YUYV,
.code = MEDIA_BUS_FMT_YUYV8_1X16,
.csi_dt = MIPI_CSI2_DT_YUV422_8B,
.bpp = 16,
.size = SHIM_DMACNTX_SIZE_8,
}, {
.fourcc = V4L2_PIX_FMT_UYVY,
.code = MEDIA_BUS_FMT_UYVY8_1X16,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/dmaengine.h`, `linux/module.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/property.h`, `media/cadence/cdns-csi2rx.h`.
- Detected declarations: `struct ti_csi2rx_fmt`, `struct ti_csi2rx_buffer`, `struct ti_csi2rx_dma`, `struct ti_csi2rx_dev`, `struct ti_csi2rx_ctx`, `struct ti_csi2rx_dev`, `enum ti_csi2rx_dma_state`, `function ti_csi2rx_fill_fmt`, `function ti_csi2rx_querycap`, `function ti_csi2rx_enum_fmt_vid_cap`.
- 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.