[RFC PATCH 2/2] media: tegra-vde: map capture planes bidirectionally
From: Florian Krischer
Date: Sun Nov 29 2026 - 12:47:03 EST
The decoder writes pictures into CAPTURE buffers and reads those
pictures again when they are used as H.264 references. The CAPTURE
queue and the driver's DMA-BUF import path currently describe the
planes as device-write-only.
Mark the CAPTURE queue bidirectional and use the direction set by
videobuf2 for the driver's DMA-BUF imports. This keeps both mapping
paths in sync and preserves the OUTPUT direction. Leave allocation
attributes and auxiliary buffers unchanged.
Signed-off-by: Florian Krischer <florian.krischer@xxxxxxx>
---
Build-tested for ARM with W=1 on media-committers/next with the
separately submitted mutex fix applied.
On an ASUS SL101 running v7.4-rc4 with the mutex fix, both the
baseline and the two-patch RFC completed three 60-frame H.264
decodes (4 I-frames, 56 P-frames) with identical I420 hashes.
Ioctl tracing confirmed MMAP CAPTURE on both kernels. Neither
run logged a new VDE warning. DMA-BUF import and cross-direction
reuse remain untested.
Does this scope make sense for CAPTURE planes? I would also welcome
feedback on cache-maintenance costs on noncoherent systems.
Thanks for taking a look.
drivers/media/platform/nvidia/tegra-vde/v4l2.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c
+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
@@ -151,7 +151,6 @@
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;
@@ -167,17 +166,12 @@
return err;
}
- if (V4L2_TYPE_IS_OUTPUT(vq->type))
- dma_dir = DMA_TO_DEVICE;
- else
- dma_dir = DMA_FROM_DEVICE;
-
for (i = 0; i < vb->num_planes; i++) {
if (vq->memory == VB2_MEMORY_DMABUF) {
get_dma_buf(vb->planes[i].dbuf);
err = tegra_vde_dmabuf_cache_map(vde, vb->planes[i].dbuf,
- dma_dir, &tb->a[i],
+ vq->dma_dir, &tb->a[i],
&tb->dma_base[i]);
if (err) {
dma_buf_put(vb->planes[i].dbuf);
@@ -386,6 +380,8 @@
dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
dst_vq->io_modes = VB2_DMABUF | VB2_MMAP;
dst_vq->lock = &vde->v4l2_lock;
+ /* VDE reads decoded pictures back as references. */
+ dst_vq->bidirectional = true;
dst_vq->dma_attrs = dma_attrs;
dst_vq->mem_ops = mem_ops;
dst_vq->ops = &tegra_qops;
base-commit: fb8b2c10a588f1384b98280b1c32307da9db4747