drivers/media/platform/nvidia/tegra-vde/v4l2.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/nvidia/tegra-vde/v4l2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/nvidia/tegra-vde/v4l2.c- Extension
.c- Size
- 25768 bytes
- Lines
- 1015
- 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.
- 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/err.hlinux/slab.hvde.h
Detected Declarations
function tegra_set_control_datafunction tegra_vde_prepare_control_datafunction tegra_queue_setupfunction tegra_buf_out_validatefunction __tegra_buf_cleanupfunction tegra_buf_initfunction tegra_buf_cleanupfunction tegra_buf_preparefunction tegra_buf_queuefunction tegra_buf_request_completefunction tegra_start_streamingfunction tegra_stop_streamingfunction tegra_queue_initfunction tegra_reset_fmtfunction tegra_reset_coded_fmtfunction tegra_fill_pixfmt_mpfunction tegra_reset_decoded_fmtfunction tegra_job_finishfunction tegra_decode_completefunction tegra_querycapfunction tegra_enum_decoded_fmtfunction tegra_g_decoded_fmtfunction tegra_try_decoded_fmtfunction tegra_s_decoded_fmtfunction tegra_enum_coded_fmtfunction tegra_g_coded_fmtfunction tegra_find_coded_fmt_descfunction tegra_try_coded_fmtfunction tegra_s_coded_fmtfunction tegra_enum_framesizesfunction tegra_init_ctrlsfunction tegra_init_m2mfunction tegra_openfunction tegra_releasefunction tegra_device_runfunction tegra_request_validatefunction tegra_vde_v4l2_initfunction tegra_vde_v4l2_deinit
Annotated Snippet
if (ctx->ctrls[i]->id == id) {
tegra_set_control_data(ctx, ctx->ctrls[i]->p_cur.p, id);
return;
}
}
tegra_set_control_data(ctx, NULL, id);
}
static int tegra_queue_setup(struct vb2_queue *vq,
unsigned int *nbufs,
unsigned int *num_planes,
unsigned int sizes[],
struct device *alloc_devs[])
{
struct tegra_ctx *ctx = vb2_get_drv_priv(vq);
struct v4l2_format *f;
unsigned int i;
if (V4L2_TYPE_IS_OUTPUT(vq->type))
f = &ctx->coded_fmt;
else
f = &ctx->decoded_fmt;
if (*num_planes) {
if (*num_planes != f->fmt.pix_mp.num_planes)
return -EINVAL;
for (i = 0; i < f->fmt.pix_mp.num_planes; i++) {
if (sizes[i] < f->fmt.pix_mp.plane_fmt[i].sizeimage)
return -EINVAL;
}
} else {
*num_planes = f->fmt.pix_mp.num_planes;
for (i = 0; i < f->fmt.pix_mp.num_planes; i++)
sizes[i] = f->fmt.pix_mp.plane_fmt[i].sizeimage;
}
return 0;
}
static int tegra_buf_out_validate(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
vbuf->field = V4L2_FIELD_NONE;
return 0;
}
static void __tegra_buf_cleanup(struct vb2_buffer *vb, unsigned int i)
{
struct vb2_queue *vq = vb->vb2_queue;
struct tegra_ctx *ctx = vb2_get_drv_priv(vq);
struct tegra_m2m_buffer *tb = vb_to_tegra_buf(vb);
while (i--) {
if (tb->a[i]) {
tegra_vde_dmabuf_cache_unmap(ctx->vde, tb->a[i], true);
tb->a[i] = NULL;
}
if (tb->iova[i]) {
tegra_vde_iommu_unmap(ctx->vde, tb->iova[i]);
tb->iova[i] = NULL;
}
}
if (tb->aux) {
tegra_vde_free_bo(tb->aux);
tb->aux = NULL;
}
}
static int tegra_buf_init(struct vb2_buffer *vb)
{
struct vb2_queue *vq = vb->vb2_queue;
struct tegra_ctx *ctx = vb2_get_drv_priv(vq);
struct tegra_m2m_buffer *tb = vb_to_tegra_buf(vb);
struct tegra_vde *vde = ctx->vde;
enum dma_data_direction dma_dir;
struct sg_table *sgt;
unsigned int i;
int err;
if (V4L2_TYPE_IS_CAPTURE(vq->type) && vb->num_planes > 1) {
/*
* Tegra decoder writes auxiliary data for I/P frames.
* This data is needed for decoding of B frames.
*/
Annotation
- Immediate include surface: `linux/err.h`, `linux/slab.h`, `vde.h`.
- Detected declarations: `function tegra_set_control_data`, `function tegra_vde_prepare_control_data`, `function tegra_queue_setup`, `function tegra_buf_out_validate`, `function __tegra_buf_cleanup`, `function tegra_buf_init`, `function tegra_buf_cleanup`, `function tegra_buf_prepare`, `function tegra_buf_queue`, `function tegra_buf_request_complete`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- 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.