diff mbox series

[v4l-utils,v2,4/7] v4l2-compliance: Add tests for V4L2_FMT_FLAG_META_LINE_BASED flag

Message ID 20240424152230.31923-5-laurent.pinchart@ideasonboard.com
State New
Headers show
Series Support for the generic line-based metadata support | expand

Commit Message

Laurent Pinchart April 24, 2024, 3:22 p.m. UTC
The metadata API supports a new flag, V4L2_FMT_FLAG_META_LINE_BASED. It
can be set for metadata formats only, and is the only flag that can be
set for metadata formats. When set, the width, height and bytesperline
fields must not be zero. Add corresponding tests.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 utils/v4l2-compliance/v4l2-test-formats.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 423567fe573b..5507e45ef3dd 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -281,12 +281,23 @@  static int testEnumFormatsType(struct node *node, unsigned type)
 				      V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL |
 				      V4L2_FMT_FLAG_CSC_COLORSPACE |
 				      V4L2_FMT_FLAG_CSC_YCBCR_ENC | V4L2_FMT_FLAG_CSC_HSV_ENC |
-				      V4L2_FMT_FLAG_CSC_QUANTIZATION | V4L2_FMT_FLAG_CSC_XFER_FUNC))
+				      V4L2_FMT_FLAG_CSC_QUANTIZATION | V4L2_FMT_FLAG_CSC_XFER_FUNC |
+				      V4L2_FMT_FLAG_META_LINE_BASED))
 			return fail("unknown flag %08x returned\n", fmtdesc.flags);
 		if (!(fmtdesc.flags & V4L2_FMT_FLAG_COMPRESSED))
 			fail_on_test(fmtdesc.flags & (V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM |
 						      V4L2_FMT_FLAG_DYN_RESOLUTION |
 						      V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL));
+
+		// Checks for metadata formats.
+		// The META_LINE_BASED flag can be set for metadata formats only.
+		if (type == V4L2_BUF_TYPE_META_OUTPUT || type == V4L2_BUF_TYPE_META_CAPTURE)
+			fail_on_test(fmtdesc.flags & ~V4L2_FMT_FLAG_META_LINE_BASED);
+		// Only the META_LINE_BASED flag is valid for metadata formats.
+		if (fmtdesc.flags & V4L2_FMT_FLAG_META_LINE_BASED)
+			fail_on_test(type != V4L2_BUF_TYPE_META_OUTPUT &&
+				     type != V4L2_BUF_TYPE_META_CAPTURE);
+
 		ret = testEnumFrameSizes(node, fmtdesc.pixelformat);
 		if (ret)
 			fail_on_test(node->codec_mask & STATEFUL_ENCODER);
@@ -590,6 +601,10 @@  static int testFormatsType(struct node *node, int ret,  unsigned type, struct v4
 			return fail("dataformat %08x (%s) for buftype %d not reported by ENUM_FMT\n",
 					meta.dataformat, fcc2s(meta.dataformat).c_str(), type);
 		fail_on_test(meta.buffersize == 0);
+		if (map.at(meta.dataformat) & V4L2_FMT_FLAG_META_LINE_BASED) {
+			fail_on_test(!meta.width || !meta.height);
+			fail_on_test(!meta.bytesperline);
+		}
 		break;
 	case V4L2_BUF_TYPE_PRIVATE:
 		break;