drivers/media/platform/renesas/rcar_drif.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/renesas/rcar_drif.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/renesas/rcar_drif.c- Extension
.c- Size
- 40294 bytes
- Lines
- 1486
- 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/bitops.hlinux/clk.hlinux/dma-mapping.hlinux/dmaengine.hlinux/ioctl.hlinux/iopoll.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/of_platform.hlinux/platform_device.hlinux/sched.hmedia/v4l2-async.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fh.hmedia/v4l2-ioctl.hmedia/videobuf2-v4l2.hmedia/videobuf2-vmalloc.h
Detected Declarations
struct rcar_drif_formatstruct rcar_drif_frame_bufstruct rcar_drif_graph_epstruct rcar_drif_hwbufstruct rcar_drifstruct rcar_drif_sdrfunction rcar_drif_writefunction rcar_drif_readfunction rcar_drif_release_dmachannelsfunction for_each_rcar_drif_channelfunction rcar_drif_alloc_dmachannelsfunction for_each_rcar_drif_channelfunction rcar_drif_release_queued_bufsfunction rcar_drif_set_mdr1function rcar_drif_set_formatfunction rcar_drif_release_buffunction for_each_rcar_drif_channelfunction rcar_drif_request_buffunction for_each_rcar_drif_channelfunction rcar_drif_queue_setupfunction rcar_drif_buf_queuefunction rcar_drif_get_fbuffunction rcar_drif_bufs_donefunction rcar_drif_bufs_overflowfunction rcar_drif_bufs_clearfunction rcar_drif_channel_completefunction rcar_drif_dma_completefunction rcar_drif_qbuffunction rcar_drif_enable_rxfunction rcar_drif_disable_rxfunction rcar_drif_stop_channelfunction rcar_drif_stopfunction rcar_drif_start_channelfunction rcar_drif_startfunction for_each_rcar_drif_channelfunction rcar_drif_start_streamingfunction for_each_rcar_drif_channelfunction rcar_drif_stop_streamingfunction rcar_drif_querycapfunction rcar_drif_set_default_formatfunction rcar_drif_enum_fmt_sdr_capfunction rcar_drif_g_fmt_sdr_capfunction rcar_drif_s_fmt_sdr_capfunction rcar_drif_try_fmt_sdr_capfunction rcar_drif_enum_freq_bandsfunction rcar_drif_g_frequencyfunction rcar_drif_s_frequencyfunction rcar_drif_g_tuner
Annotated Snippet
struct rcar_drif_format {
u32 pixelformat;
u32 buffersize;
u32 bitlen;
u32 wdcnt;
u32 num_ch;
};
/* Format descriptions for capture */
static const struct rcar_drif_format formats[] = {
{
.pixelformat = V4L2_SDR_FMT_PCU16BE,
.buffersize = RCAR_SDR_BUFFER_SIZE,
.bitlen = 16,
.wdcnt = 1,
.num_ch = 2,
},
{
.pixelformat = V4L2_SDR_FMT_PCU18BE,
.buffersize = RCAR_SDR_BUFFER_SIZE,
.bitlen = 18,
.wdcnt = 1,
.num_ch = 2,
},
{
.pixelformat = V4L2_SDR_FMT_PCU20BE,
.buffersize = RCAR_SDR_BUFFER_SIZE,
.bitlen = 20,
.wdcnt = 1,
.num_ch = 2,
},
};
/* Buffer for a received frame from one or both internal channels */
struct rcar_drif_frame_buf {
/* Common v4l buffer stuff -- must be first */
struct vb2_v4l2_buffer vb;
struct list_head list;
};
/* OF graph endpoint's V4L2 async data */
struct rcar_drif_graph_ep {
struct v4l2_subdev *subdev; /* Async matched subdev */
};
/* DMA buffer */
struct rcar_drif_hwbuf {
void *addr; /* CPU-side address */
unsigned int status; /* Buffer status flags */
};
/* Internal channel */
struct rcar_drif {
struct rcar_drif_sdr *sdr; /* Group device */
struct platform_device *pdev; /* Channel's pdev */
void __iomem *base; /* Base register address */
resource_size_t start; /* I/O resource offset */
struct dma_chan *dmach; /* Reserved DMA channel */
struct clk *clk; /* Module clock */
struct rcar_drif_hwbuf buf[RCAR_DRIF_NUM_HWBUFS]; /* H/W bufs */
dma_addr_t dma_handle; /* Handle for all bufs */
unsigned int num; /* Channel number */
bool acting_sdr; /* Channel acting as SDR device */
};
/* DRIF V4L2 SDR */
struct rcar_drif_sdr {
struct device *dev; /* Platform device */
struct video_device *vdev; /* V4L2 SDR device */
struct v4l2_device v4l2_dev; /* V4L2 device */
/* Videobuf2 queue and queued buffers list */
struct vb2_queue vb_queue;
struct list_head queued_bufs;
spinlock_t queued_bufs_lock; /* Protects queued_bufs */
spinlock_t dma_lock; /* To serialize DMA cb of channels */
struct mutex v4l2_mutex; /* To serialize ioctls */
struct mutex vb_queue_mutex; /* To serialize streaming ioctls */
struct v4l2_ctrl_handler ctrl_hdl; /* SDR control handler */
struct v4l2_async_notifier notifier; /* For subdev (tuner) */
struct rcar_drif_graph_ep ep; /* Endpoint V4L2 async data */
/* Current V4L2 SDR format ptr */
const struct rcar_drif_format *fmt;
/* Device tree SYNC properties */
u32 mdr1;
/* Internals */
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/ioctl.h`, `linux/iopoll.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct rcar_drif_format`, `struct rcar_drif_frame_buf`, `struct rcar_drif_graph_ep`, `struct rcar_drif_hwbuf`, `struct rcar_drif`, `struct rcar_drif_sdr`, `function rcar_drif_write`, `function rcar_drif_read`, `function rcar_drif_release_dmachannels`, `function for_each_rcar_drif_channel`.
- 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.