drivers/media/pci/cx25821/cx25821-video.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cx25821/cx25821-video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cx25821/cx25821-video.c- Extension
.c- Size
- 21272 bytes
- Lines
- 775
- 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
cx25821-video.h
Detected Declarations
function cx25821_start_video_dmafunction cx25821_video_irqfunction cx25821_queue_setupfunction cx25821_buffer_preparefunction cx25821_buffer_finishfunction cx25821_buffer_queuefunction cx25821_start_streamingfunction cx25821_stop_streamingfunction cx25821_vidioc_enum_fmt_vid_capfunction cx25821_vidioc_g_fmt_vid_capfunction cx25821_vidioc_try_fmt_vid_capfunction vidioc_s_fmt_vid_capfunction vidioc_log_statusfunction cx25821_vidioc_querycapfunction cx25821_vidioc_g_stdfunction cx25821_vidioc_s_stdfunction cx25821_vidioc_enum_inputfunction cx25821_vidioc_g_inputfunction cx25821_vidioc_s_inputfunction cx25821_s_ctrlfunction cx25821_vidioc_enum_outputfunction cx25821_vidioc_g_outputfunction cx25821_vidioc_s_outputfunction cx25821_vidioc_try_fmt_vid_outfunction vidioc_s_fmt_vid_outfunction cx25821_video_unregisterfunction cx25821_video_register
Annotated Snippet
if (!list_empty(&dmaq->active)) {
buf = list_entry(dmaq->active.next,
struct cx25821_buffer, queue);
buf->vb.vb2_buf.timestamp = ktime_get_ns();
buf->vb.sequence = dmaq->count++;
list_del(&buf->queue);
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
}
spin_unlock(&dev->slock);
handled++;
}
return handled;
}
static int cx25821_queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], struct device *alloc_devs[])
{
struct cx25821_channel *chan = q->drv_priv;
unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3;
if (*num_planes)
return sizes[0] < size ? -EINVAL : 0;
*num_planes = 1;
sizes[0] = size;
return 0;
}
static int cx25821_buffer_prepare(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
struct cx25821_channel *chan = vb->vb2_queue->drv_priv;
struct cx25821_dev *dev = chan->dev;
struct cx25821_buffer *buf =
container_of(vbuf, struct cx25821_buffer, vb);
struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
u32 line0_offset;
int bpl_local = LINE_SIZE_D1;
int ret;
if (chan->pixel_formats == PIXEL_FRMT_411)
buf->bpl = (chan->fmt->depth * chan->width) >> 3;
else
buf->bpl = (chan->fmt->depth >> 3) * chan->width;
if (vb2_plane_size(vb, 0) < chan->height * buf->bpl)
return -EINVAL;
vb2_set_plane_payload(vb, 0, chan->height * buf->bpl);
buf->vb.field = chan->field;
if (chan->pixel_formats == PIXEL_FRMT_411) {
bpl_local = buf->bpl;
} else {
bpl_local = buf->bpl; /* Default */
if (chan->use_cif_resolution) {
if (dev->tvnorm & V4L2_STD_625_50)
bpl_local = 352 << 1;
else
bpl_local = chan->cif_width << 1;
}
}
switch (chan->field) {
case V4L2_FIELD_TOP:
ret = cx25821_risc_buffer(dev->pci, &buf->risc,
sgt->sgl, 0, UNSET,
buf->bpl, 0, chan->height);
break;
case V4L2_FIELD_BOTTOM:
ret = cx25821_risc_buffer(dev->pci, &buf->risc,
sgt->sgl, UNSET, 0,
buf->bpl, 0, chan->height);
break;
case V4L2_FIELD_INTERLACED:
/* All other formats are top field first */
line0_offset = 0;
dprintk(1, "top field first\n");
ret = cx25821_risc_buffer(dev->pci, &buf->risc,
sgt->sgl, line0_offset,
bpl_local, bpl_local, bpl_local,
chan->height >> 1);
break;
case V4L2_FIELD_SEQ_TB:
ret = cx25821_risc_buffer(dev->pci, &buf->risc,
sgt->sgl,
0, buf->bpl * (chan->height >> 1),
Annotation
- Immediate include surface: `cx25821-video.h`.
- Detected declarations: `function cx25821_start_video_dma`, `function cx25821_video_irq`, `function cx25821_queue_setup`, `function cx25821_buffer_prepare`, `function cx25821_buffer_finish`, `function cx25821_buffer_queue`, `function cx25821_start_streaming`, `function cx25821_stop_streaming`, `function cx25821_vidioc_enum_fmt_vid_cap`, `function cx25821_vidioc_g_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.
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.