drivers/media/platform/xilinx/xilinx-dma.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/xilinx/xilinx-dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/xilinx/xilinx-dma.c- Extension
.c- Size
- 20702 bytes
- Lines
- 742
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma/xilinx_dma.hlinux/lcm.hlinux/list.hlinux/module.hlinux/of.hlinux/slab.hmedia/v4l2-dev.hmedia/v4l2-fh.hmedia/v4l2-ioctl.hmedia/videobuf2-v4l2.hmedia/videobuf2-dma-contig.hxilinx-dma.hxilinx-vip.hxilinx-vipp.h
Detected Declarations
struct xvip_dma_bufferfunction Copyrightfunction xvip_dma_verify_formatfunction xvip_pipeline_start_stopfunction xvip_pipeline_set_streamfunction xvip_pipeline_validatefunction __xvip_pipeline_cleanupfunction xvip_pipeline_cleanupfunction xvip_pipeline_preparefunction xvip_dma_completefunction xvip_dma_queue_setupfunction xvip_dma_buffer_preparefunction xvip_dma_buffer_queuefunction xvip_dma_start_streamingfunction xvip_dma_stop_streamingfunction xvip_dma_querycapfunction xvip_dma_enum_formatfunction xvip_dma_get_formatfunction __xvip_dma_try_formatfunction xvip_dma_try_formatfunction xvip_dma_set_formatfunction xvip_dma_initfunction xvip_dma_cleanup
Annotated Snippet
struct xvip_dma_buffer {
struct vb2_v4l2_buffer buf;
struct list_head queue;
struct xvip_dma *dma;
};
#define to_xvip_dma_buffer(vb) container_of(vb, struct xvip_dma_buffer, buf)
static void xvip_dma_complete(void *param)
{
struct xvip_dma_buffer *buf = param;
struct xvip_dma *dma = buf->dma;
spin_lock(&dma->queued_lock);
list_del(&buf->queue);
spin_unlock(&dma->queued_lock);
buf->buf.field = V4L2_FIELD_NONE;
buf->buf.sequence = dma->sequence++;
buf->buf.vb2_buf.timestamp = ktime_get_ns();
vb2_set_plane_payload(&buf->buf.vb2_buf, 0, dma->format.sizeimage);
vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);
}
static int
xvip_dma_queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], struct device *alloc_devs[])
{
struct xvip_dma *dma = vb2_get_drv_priv(vq);
/* Make sure the image size is large enough. */
if (*nplanes)
return sizes[0] < dma->format.sizeimage ? -EINVAL : 0;
*nplanes = 1;
sizes[0] = dma->format.sizeimage;
return 0;
}
static int xvip_dma_buffer_prepare(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
struct xvip_dma *dma = vb2_get_drv_priv(vb->vb2_queue);
struct xvip_dma_buffer *buf = to_xvip_dma_buffer(vbuf);
buf->dma = dma;
return 0;
}
static void xvip_dma_buffer_queue(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
struct xvip_dma *dma = vb2_get_drv_priv(vb->vb2_queue);
struct xvip_dma_buffer *buf = to_xvip_dma_buffer(vbuf);
struct dma_async_tx_descriptor *desc;
dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb, 0);
u32 flags;
if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
dma->xt.dir = DMA_DEV_TO_MEM;
dma->xt.src_sgl = false;
dma->xt.dst_sgl = true;
dma->xt.dst_start = addr;
} else {
flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
dma->xt.dir = DMA_MEM_TO_DEV;
dma->xt.src_sgl = true;
dma->xt.dst_sgl = false;
dma->xt.src_start = addr;
}
dma->xt.frame_size = 1;
dma->sgl.size = dma->format.width * dma->fmtinfo->bpp;
dma->sgl.icg = dma->format.bytesperline - dma->sgl.size;
dma->xt.numf = dma->format.height;
desc = dmaengine_prep_interleaved_dma(dma->dma, &dma->xt, flags);
if (!desc) {
dev_err(dma->xdev->dev, "Failed to prepare DMA transfer\n");
vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_ERROR);
return;
}
desc->callback = xvip_dma_complete;
desc->callback_param = buf;
spin_lock_irq(&dma->queued_lock);
Annotation
- Immediate include surface: `linux/dma/xilinx_dma.h`, `linux/lcm.h`, `linux/list.h`, `linux/module.h`, `linux/of.h`, `linux/slab.h`, `media/v4l2-dev.h`, `media/v4l2-fh.h`.
- Detected declarations: `struct xvip_dma_buffer`, `function Copyright`, `function xvip_dma_verify_format`, `function xvip_pipeline_start_stop`, `function xvip_pipeline_set_stream`, `function xvip_pipeline_validate`, `function __xvip_pipeline_cleanup`, `function xvip_pipeline_cleanup`, `function xvip_pipeline_prepare`, `function xvip_dma_complete`.
- 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.
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.