This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-compliance: Add test for V4L2_FMTDESC_FLAG_ENUM_ALL flag
Author:  Benjamin Gaignard <benjamin.gaign...@collabora.com>
Date:    Mon Aug 26 17:20:11 2024 +0000

If V4L2_FMTDESC_FLAG_ENUM_ALL flag is supported, test if all
pixel formats list with VIDIOC_ENUM_FMT without the flag been set
is a subset of the list created with the flag.
Also Test that the flag is cleared of calling VIDIOC_ENUM_FMT.

Signed-off-by: Benjamin Gaignard <benjamin.gaign...@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>

 utils/v4l2-compliance/v4l2-test-formats.cpp | 35 +++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=d08acb5185d1a8dc6c0a3b50d3d89a59a4879766
diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp 
b/utils/v4l2-compliance/v4l2-test-formats.cpp
index fc16ad3968f1..bac28cbae2bf 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -224,6 +224,7 @@ static int testEnumFrameSizes(struct node *node, __u32 
pixfmt)
 static int testEnumFormatsType(struct node *node, unsigned type)
 {
        pixfmt_map &map = node->buftype_pixfmts[type];
+       pixfmt_map enum_all;
        struct v4l2_fmtdesc fmtdesc;
        unsigned f = 0;
        int ret;
@@ -318,6 +319,40 @@ static int testEnumFormatsType(struct node *node, unsigned 
type)
                map[fmtdesc.pixelformat] = fmtdesc.flags;
        }
        info("found %d formats for buftype %d\n", f, type);
+
+       /* Test V4L2_FMTDESC_FLAG_ENUM_ALL if supported */
+       f = 0;
+       for (;;) {
+               memset(&fmtdesc, 0xff, sizeof(fmtdesc));
+               fmtdesc.type = type;
+               fmtdesc.index = f | V4L2_FMTDESC_FLAG_ENUM_ALL;
+               fmtdesc.mbus_code = 0;
+
+               ret = doioctl(node, VIDIOC_ENUM_FMT, &fmtdesc);
+               if (f == 0 && ret == EINVAL)
+                       return 0;
+               if (ret == EINVAL)
+                       break;
+               if (ret)
+                       return fail("expected EINVAL, but got %d when 
enumerating buftype %d\n", ret, type);
+               if (fmtdesc.index != f)
+                       return fail("V4L2_FMTDESC_FLAG_ENUM_ALL hasn't been 
cleared from fmtdesc.index 0x%x f 0x%x\n", fmtdesc.index, f);
+               f++;
+               if (type == V4L2_BUF_TYPE_PRIVATE)
+                       continue;
+               assert(type <= V4L2_BUF_TYPE_LAST);
+               if (enum_all.find(fmtdesc.pixelformat) != enum_all.end())
+                       return fail("duplicate format %08x (%s)\n",
+                                   fmtdesc.pixelformat, 
fcc2s(fmtdesc.pixelformat).c_str());
+               enum_all[fmtdesc.pixelformat] = fmtdesc.flags;
+       }
+       info("found %d formats for buftype %d (with 
V4L2_FMTDESC_FLAG_ENUM_ALL)\n", f, type);
+
+       /* if V4L2_FMTDESC_FLAG_ENUM_ALL is supported, verify that the list is 
a subset of VIDIOC_ENUM_FMT list */
+       for (auto it = map.begin(); it != map.end(); it++)
+               if (enum_all.find(it->first) == enum_all.end())
+                       return fail("V4L2_FMTDESC_FLAG_ENUM_ALL failed to 
enumerate format %08x (%s)\n", it->first, fcc2s(it->first).c_str());
+
        return 0;
 }
 

Reply via email to