drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c- Extension
.c- Size
- 34946 bytes
- Lines
- 1427
- 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/errno.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/of.hlinux/pm_runtime.hlinux/slab.hmedia/v4l2-event.hmedia/v4l2-ioctl.hbdisp.h
Detected Declarations
enum bdisp_dev_flagsfunction Copyrightfunction bdisp_ctx_state_lock_setfunction bdisp_ctx_state_lock_clearfunction bdisp_ctx_state_is_setfunction bdisp_job_finishfunction bdisp_ctx_stop_reqfunction __bdisp_job_abortfunction bdisp_job_abortfunction bdisp_get_addrfunction bdisp_get_bufsfunction bdisp_device_runfunction __bdisp_s_ctrlfunction bdisp_s_ctrlfunction bdisp_ctrls_createfunction bdisp_ctrls_deletefunction bdisp_queue_setupfunction bdisp_buf_preparefunction bdisp_buf_queuefunction bdisp_start_streamingfunction bdisp_stop_streamingfunction queue_initfunction bdisp_openfunction bdisp_releasefunction bdisp_querycapfunction bdisp_enum_fmtfunction bdisp_g_fmtfunction bdisp_try_fmtfunction bdisp_s_fmtfunction bdisp_g_selectionfunction is_rect_enclosedfunction bdisp_s_selectionfunction bdisp_streamonfunction bdisp_register_devicefunction bdisp_unregister_devicefunction bdisp_irq_threadfunction bdisp_irq_handlerfunction bdisp_irq_timeoutfunction bdisp_m2m_suspendfunction bdisp_m2m_resumefunction bdisp_runtime_resumefunction bdisp_runtime_suspendfunction bdisp_resumefunction bdisp_suspendfunction bdisp_removefunction bdisp_probe
Annotated Snippet
if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
while ((buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx)))
v4l2_m2m_buf_done(buf, VB2_BUF_STATE_QUEUED);
} else {
while ((buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx)))
v4l2_m2m_buf_done(buf, VB2_BUF_STATE_QUEUED);
}
return ret;
}
return 0;
}
static void bdisp_stop_streaming(struct vb2_queue *q)
{
struct bdisp_ctx *ctx = q->drv_priv;
__bdisp_job_abort(ctx);
pm_runtime_put(ctx->bdisp_dev->dev);
}
static const struct vb2_ops bdisp_qops = {
.queue_setup = bdisp_queue_setup,
.buf_prepare = bdisp_buf_prepare,
.buf_queue = bdisp_buf_queue,
.stop_streaming = bdisp_stop_streaming,
.start_streaming = bdisp_start_streaming,
};
static int queue_init(void *priv,
struct vb2_queue *src_vq, struct vb2_queue *dst_vq)
{
struct bdisp_ctx *ctx = priv;
int ret;
memset(src_vq, 0, sizeof(*src_vq));
src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
src_vq->io_modes = VB2_MMAP | VB2_DMABUF;
src_vq->drv_priv = ctx;
src_vq->ops = &bdisp_qops;
src_vq->mem_ops = &vb2_dma_contig_memops;
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->bdisp_dev->lock;
src_vq->dev = ctx->bdisp_dev->v4l2_dev.dev;
ret = vb2_queue_init(src_vq);
if (ret)
return ret;
memset(dst_vq, 0, sizeof(*dst_vq));
dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
dst_vq->io_modes = VB2_MMAP | VB2_DMABUF;
dst_vq->drv_priv = ctx;
dst_vq->ops = &bdisp_qops;
dst_vq->mem_ops = &vb2_dma_contig_memops;
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
dst_vq->lock = &ctx->bdisp_dev->lock;
dst_vq->dev = ctx->bdisp_dev->v4l2_dev.dev;
return vb2_queue_init(dst_vq);
}
static int bdisp_open(struct file *file)
{
struct bdisp_dev *bdisp = video_drvdata(file);
struct bdisp_ctx *ctx = NULL;
int ret;
if (mutex_lock_interruptible(&bdisp->lock))
return -ERESTARTSYS;
/* Allocate memory for both context and node */
ctx = kzalloc_obj(*ctx);
if (!ctx) {
ret = -ENOMEM;
goto unlock;
}
ctx->bdisp_dev = bdisp;
if (bdisp_hw_alloc_nodes(ctx)) {
dev_err(bdisp->dev, "no memory for nodes\n");
ret = -ENOMEM;
goto mem_ctx;
}
v4l2_fh_init(&ctx->fh, bdisp->m2m.vdev);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/pm_runtime.h`, `linux/slab.h`, `media/v4l2-event.h`.
- Detected declarations: `enum bdisp_dev_flags`, `function Copyright`, `function bdisp_ctx_state_lock_set`, `function bdisp_ctx_state_lock_clear`, `function bdisp_ctx_state_is_set`, `function bdisp_job_finish`, `function bdisp_ctx_stop_req`, `function __bdisp_job_abort`, `function bdisp_job_abort`, `function bdisp_get_addr`.
- 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.