drivers/staging/media/sunxi/cedrus/cedrus_video.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/sunxi/cedrus/cedrus_video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/sunxi/cedrus/cedrus_video.c- Extension
.c- Size
- 15378 bytes
- Lines
- 622
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pm_runtime.hmedia/videobuf2-dma-contig.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/v4l2-event.hmedia/v4l2-mem2mem.hcedrus.hcedrus_video.hcedrus_dec.hcedrus_hw.h
Detected Declarations
function cedrus_prepare_formatfunction cedrus_querycapfunction cedrus_enum_fmtfunction cedrus_enum_fmt_vid_capfunction cedrus_enum_fmt_vid_outfunction cedrus_g_fmt_vid_capfunction cedrus_g_fmt_vid_outfunction cedrus_try_fmt_vid_cap_pfunction cedrus_try_fmt_vid_capfunction cedrus_try_fmt_vid_out_pfunction cedrus_try_fmt_vid_outfunction cedrus_s_fmt_vid_capfunction cedrus_reset_cap_formatfunction cedrus_s_fmt_vid_out_pfunction cedrus_reset_out_formatfunction cedrus_s_fmt_vid_outfunction cedrus_queue_setupfunction cedrus_queue_cleanupfunction cedrus_buf_out_validatefunction cedrus_buf_preparefunction cedrus_start_streamingfunction cedrus_stop_streamingfunction cedrus_buf_queuefunction cedrus_buf_request_completefunction cedrus_queue_init
Annotated Snippet
if (ctx->current_codec->start) {
ret = ctx->current_codec->start(ctx);
if (ret)
goto err_pm;
}
}
return 0;
err_pm:
pm_runtime_put(dev->dev);
err_cleanup:
cedrus_queue_cleanup(vq, VB2_BUF_STATE_QUEUED);
return ret;
}
static void cedrus_stop_streaming(struct vb2_queue *vq)
{
struct cedrus_ctx *ctx = vb2_get_drv_priv(vq);
struct cedrus_dev *dev = ctx->dev;
if (V4L2_TYPE_IS_OUTPUT(vq->type)) {
if (ctx->current_codec->stop)
ctx->current_codec->stop(ctx);
pm_runtime_put(dev->dev);
}
cedrus_queue_cleanup(vq, VB2_BUF_STATE_ERROR);
}
static void cedrus_buf_queue(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
struct cedrus_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
}
static void cedrus_buf_request_complete(struct vb2_buffer *vb)
{
struct cedrus_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->hdl);
}
static const struct vb2_ops cedrus_qops = {
.queue_setup = cedrus_queue_setup,
.buf_prepare = cedrus_buf_prepare,
.buf_queue = cedrus_buf_queue,
.buf_out_validate = cedrus_buf_out_validate,
.buf_request_complete = cedrus_buf_request_complete,
.start_streaming = cedrus_start_streaming,
.stop_streaming = cedrus_stop_streaming,
};
int cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
struct vb2_queue *dst_vq)
{
struct cedrus_ctx *ctx = priv;
int ret;
src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
src_vq->io_modes = VB2_MMAP | VB2_DMABUF;
src_vq->drv_priv = ctx;
src_vq->buf_struct_size = sizeof(struct cedrus_buffer);
src_vq->ops = &cedrus_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->dev->dev_mutex;
src_vq->dev = ctx->dev->dev;
src_vq->supports_requests = true;
src_vq->requires_requests = true;
ret = vb2_queue_init(src_vq);
if (ret)
return ret;
dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
dst_vq->io_modes = VB2_MMAP | VB2_DMABUF;
dst_vq->drv_priv = ctx;
dst_vq->buf_struct_size = sizeof(struct cedrus_buffer);
dst_vq->ops = &cedrus_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->dev->dev_mutex;
dst_vq->dev = ctx->dev->dev;
return vb2_queue_init(dst_vq);
Annotation
- Immediate include surface: `linux/pm_runtime.h`, `media/videobuf2-dma-contig.h`, `media/v4l2-device.h`, `media/v4l2-ioctl.h`, `media/v4l2-event.h`, `media/v4l2-mem2mem.h`, `cedrus.h`, `cedrus_video.h`.
- Detected declarations: `function cedrus_prepare_format`, `function cedrus_querycap`, `function cedrus_enum_fmt`, `function cedrus_enum_fmt_vid_cap`, `function cedrus_enum_fmt_vid_out`, `function cedrus_g_fmt_vid_cap`, `function cedrus_g_fmt_vid_out`, `function cedrus_try_fmt_vid_cap_p`, `function cedrus_try_fmt_vid_cap`, `function cedrus_try_fmt_vid_out_p`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
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.