Linux Media Controller development
 help / color / mirror / Atom feed
* [v4l-utils] [RFC/PATCH] v4l2-compliance: Don't check bytesused or timestamp for error buffers
@ 2026-10-27 19:19 Laurent Pinchart
  2026-10-29 10:07 ` Hans Verkuil
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2026-10-27 19:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Sakari Ailus, Jacopo Mondi, Kieran Bingham

When DQBUF returns a buffer marked with the ERROR flag, the bytesused
and timestamp fields are not meaningful. Don't check them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
I'm sending this as an RFC because the V4L2 API documentation isn't
clear on the subject.

For the bytesused fields, I'm fairly confident that this change is good.
A driver can't be expected to provide data for buffers with errors,
especially if a transmission error occurred.

Similarly, timestamping a buffer upon error may not be something we can
always expect from drivers. I'm a bit more hesitant here though: while
precise timestamping can't be guaranteed, a driver can always use some
sort of timestamp. Doing so could cause issues though, as a driver for a
device that provides hardware timestamping would need to switch to a
software timestamp source for buffers with errors. That would not just
complicate drivers, but would also make it awkward for userspace.

There are a few open questions:

- Are there other buffer fields that we should ignore ?

- Shoulg (some of) the ignored fields be required to have a specific
  value ? For instance we could require the timestamp to be 0 on error.
---
 utils/v4l2-compliance/v4l2-test-buffers.cpp | 22 ++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp
index dba471e5b488..47d4627ee373 100644
--- a/utils/v4l2-compliance/v4l2-test-buffers.cpp
+++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp
@@ -393,16 +393,20 @@ int buffer::check(unsigned type, unsigned memory, unsigned index,
 		warn_once("V4L2_BUF_FLAG_TIMECODE was used!\n");
 
 	if (mode == Dequeued) {
-		for (unsigned p = 0; p < g_num_planes(); p++) {
-			if (!(g_flags() & V4L2_BUF_FLAG_LAST))
-				fail_on_test(!g_bytesused(p));
-			if (!g_bytesused(p))
-				fail_on_test(g_data_offset(p));
-			else
-				fail_on_test(g_data_offset(p) >= g_bytesused(p));
-			fail_on_test(g_bytesused(p) > g_length(p));
+		if (!(g_flags() & V4L2_BUF_FLAG_ERROR)) {
+			for (unsigned p = 0; p < g_num_planes(); p++) {
+				if (!(g_flags() & V4L2_BUF_FLAG_LAST))
+					fail_on_test(!g_bytesused(p));
+				if (!g_bytesused(p))
+					fail_on_test(g_data_offset(p));
+				else
+					fail_on_test(g_data_offset(p) >= g_bytesused(p));
+				fail_on_test(g_bytesused(p) > g_length(p));
+			}
+
+			fail_on_test(!g_timestamp().tv_sec && !g_timestamp().tv_usec);
 		}
-		fail_on_test(!g_timestamp().tv_sec && !g_timestamp().tv_usec);
+
 		fail_on_test(g_flags() & V4L2_BUF_FLAG_DONE);
 
 		// The vivid driver has unreliable timings causing wrong

base-commit: c6600a7e342ef6e336fba02212c90b60a36ca02d
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-29 11:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 19:19 [v4l-utils] [RFC/PATCH] v4l2-compliance: Don't check bytesused or timestamp for error buffers Laurent Pinchart
2026-10-29 10:07 ` Hans Verkuil
2026-10-29 11:22   ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox