From 1690dfaa795fff293b3a5b6068200460194d704b Mon Sep 17 00:00:00 2001 From: Markus Fritsche Date: Fri, 1 May 2026 12:00:00 +0000 Subject: [PATCH] DEBUG: sentinel-pattern test for CAPTURE buffer write MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Diagnostic-only. Writes 0xab×32 into the CAPTURE buffer's first 32 bytes immediately before VIDIOC_QBUF. The 0010 hex-dump after DQBUF reveals which case we're in: - All 0xab → kernel never wrote to this buffer (wrong buffer chosen, alias, or no decode actually happened despite bytesused=3655712 reported). - All zeros → kernel did write 0x00s (overwriting our sentinel), and the apparent "no picture" output is the kernel-side decode actually producing zeros (e.g. parser rejected the bitstream). - Mix of zeros and real luma values → kernel wrote real decoded pixels; CPU read sees stale-cached zeros somewhere OR the sentinel area was a header that decoder zeroed but rest is real. Need to check more bytes. - All 0xab still → kernel never touched this region but other parts of buffer may be filled (incomplete decode). Removed once Step 1 decode is verified. Signed-off-by: Markus Fritsche --- src/picture.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/picture.c b/src/picture.c index a0c82a2..bab34f3 100644 --- a/src/picture.c +++ b/src/picture.c @@ -349,6 +349,24 @@ VAStatus RequestEndPicture(VADriverContextP context, VAContextID context_id) if (rc != VA_STATUS_SUCCESS) return rc; + /* + * DEBUG INSTRUMENTATION (0011): write a sentinel pattern into + * the CAPTURE buffer's first 32 bytes BEFORE QBUF. If after + * DQBUF the sentinel survives (per surface.c hex dump), the + * kernel never wrote to this buffer. If the sentinel is gone + * (replaced by zeros), the kernel did write but our CPU read + * sees stale-cached data — cache-coherency issue. + */ + { + unsigned char *p = (unsigned char *) + surface_object->destination_map[0]; + if (p != NULL) { + unsigned int i; + for (i = 0; i < 32; i++) + p[i] = 0xab; + } + } + rc = v4l2_queue_buffer(driver_data->video_fd, -1, capture_type, NULL, surface_object->destination_index, 0, surface_object->destination_buffers_count);