aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-03-12 10:24:42 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-03-12 10:24:42 +0100
commite78f2c82fdcdd648aa3b8570c14202fef2628cd9 (patch)
tree17f1bf2d15454c9cc44153e6e9d24fbf063f9859
parentf53c2fa1a95154f75cf4a510113179ff39d548e7 (diff)
downloadv4l-utils-e78f2c82fdcdd648aa3b8570c14202fef2628cd9.tar.gz
v4l2-compliance: improve compound control checks
Verify that QUERY_EXT_CTRLS and QUERYCTRLS handle enumerating only regular controls or only compound controls correctly. Before v4l2-compliance only checked that enumerating all controls was done correctly. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.cpp6
-rw-r--r--utils/v4l2-compliance/v4l2-test-controls.cpp61
2 files changed, 62 insertions, 5 deletions
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index b6e0d57b..9f71332c 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -1304,7 +1304,11 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
printf("\ttest VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: %s\n", ok(testEvents(&node)));
printf("\ttest VIDIOC_G/S_JPEGCOMP: %s\n", ok(testJpegComp(&node)));
printf("\tStandard Controls: %d Private Controls: %d\n",
- node.std_controls, node.priv_controls);
+ node.std_controls - node.std_compound_controls,
+ node.priv_controls - node.priv_compound_controls);
+ if (node.std_compound_controls || node.priv_compound_controls)
+ printf("\tStandard Compound Controls: %d Private Compound Controls: %d\n",
+ node.std_compound_controls, node.priv_compound_controls);
printf("\n");
/* Format ioctls */
diff --git a/utils/v4l2-compliance/v4l2-test-controls.cpp b/utils/v4l2-compliance/v4l2-test-controls.cpp
index 9a68b7e8..4be2f61c 100644
--- a/utils/v4l2-compliance/v4l2-test-controls.cpp
+++ b/utils/v4l2-compliance/v4l2-test-controls.cpp
@@ -231,11 +231,11 @@ int testQueryExtControls(struct node *node)
}
if (V4L2_CTRL_DRIVER_PRIV(id)) {
node->priv_controls++;
- if (qctrl.type >= V4L2_CTRL_COMPOUND_TYPES)
+ if (qctrl.type >= V4L2_CTRL_COMPOUND_TYPES || qctrl.nr_of_dims)
node->priv_compound_controls++;
} else {
node->std_controls++;
- if (qctrl.type >= V4L2_CTRL_COMPOUND_TYPES)
+ if (qctrl.type >= V4L2_CTRL_COMPOUND_TYPES || qctrl.nr_of_dims)
node->std_compound_controls++;
}
node->controls[qctrl.id] = qctrl;
@@ -247,6 +247,42 @@ int testQueryExtControls(struct node *node)
if (which && !class_count)
return fail("no controls in class %08x\n", which);
+ id = 0;
+ unsigned regular_ctrls = 0;
+ for (;;) {
+ memset(&qctrl, 0xff, sizeof(qctrl));
+ qctrl.id = id | V4L2_CTRL_FLAG_NEXT_CTRL;
+ ret = doioctl(node, VIDIOC_QUERY_EXT_CTRL, &qctrl);
+ if (ret)
+ break;
+ id = qctrl.id;
+ if (qctrl.type >= V4L2_CTRL_COMPOUND_TYPES || qctrl.nr_of_dims)
+ return fail("V4L2_CTRL_FLAG_NEXT_CTRL enumerates compound controls!\n");
+ regular_ctrls++;
+ }
+ unsigned num_compound_ctrls = node->std_compound_controls + node->priv_compound_controls;
+ unsigned num_regular_ctrls = node->std_controls + node->priv_controls - num_compound_ctrls;
+ if (regular_ctrls != num_regular_ctrls)
+ return fail("expected to find %d standard controls, got %d instead\n",
+ num_regular_ctrls, regular_ctrls);
+
+ id = 0;
+ unsigned compound_ctrls = 0;
+ for (;;) {
+ memset(&qctrl, 0xff, sizeof(qctrl));
+ qctrl.id = id | V4L2_CTRL_FLAG_NEXT_COMPOUND;
+ ret = doioctl(node, VIDIOC_QUERY_EXT_CTRL, &qctrl);
+ if (ret)
+ break;
+ id = qctrl.id;
+ if (qctrl.type < V4L2_CTRL_COMPOUND_TYPES && !qctrl.nr_of_dims)
+ return fail("V4L2_CTRL_FLAG_NEXT_COMPOUND enumerates regular controls!\n");
+ compound_ctrls++;
+ }
+ if (compound_ctrls != num_compound_ctrls)
+ return fail("expected to find %d compound controls, got %d instead\n",
+ num_compound_ctrls, compound_ctrls);
+
for (id = V4L2_CID_BASE; id < V4L2_CID_LASTP1; id++) {
memset(&qctrl, 0xff, sizeof(qctrl));
qctrl.id = id;
@@ -294,9 +330,13 @@ int testQueryControls(struct node *node)
{
struct v4l2_queryctrl qctrl;
unsigned controls = 0;
+ unsigned compound_controls = 0;
__u32 id = 0;
int ret;
+ unsigned num_compound_ctrls = node->std_compound_controls + node->priv_compound_controls;
+ unsigned num_regular_ctrls = node->std_controls + node->priv_controls - num_compound_ctrls;
+
for (;;) {
memset(&qctrl, 0xff, sizeof(qctrl));
qctrl.id = id | V4L2_CTRL_FLAG_NEXT_CTRL;
@@ -312,8 +352,21 @@ int testQueryControls(struct node *node)
fail_on_test(qctrl.step < 0);
controls++;
}
- fail_on_test(node->controls.size() !=
- controls + node->std_compound_controls + node->priv_compound_controls);
+ fail_on_test(controls != num_regular_ctrls);
+
+ id = 0;
+ for (;;) {
+ memset(&qctrl, 0xff, sizeof(qctrl));
+ qctrl.id = id | V4L2_CTRL_FLAG_NEXT_COMPOUND;
+ ret = doioctl(node, VIDIOC_QUERYCTRL, &qctrl);
+ if (ret)
+ break;
+ id = qctrl.id;
+ fail_on_test(node->controls.find(qctrl.id) == node->controls.end());
+ fail_on_test(qctrl.step || qctrl.minimum || qctrl.maximum || qctrl.default_value);
+ compound_controls++;
+ }
+ fail_on_test(compound_controls != num_compound_ctrls);
for (id = V4L2_CID_BASE; id < V4L2_CID_LASTP1; id++) {
memset(&qctrl, 0xff, sizeof(qctrl));