v4l2-compliance: Basic support for array controls
PATCH 1/1 v4l2-compliance: Basic support for array controls
Without this patch:
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
fail: v4l2-test-controls.cpp(411): g_ctrl returned an error (22) test VIDIOC_G/S_CTRL: FAIL
fail: v4l2-test-controls.cpp(637): g_ext_ctrls returned an error (28) test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 55 Private Controls: 0
--- utils/v4l2-compliance/v4l2-test-controls.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
utils/v4l2-compliance/v4l2-test-controls.cpp +18 -2
@@ -377,6 +377,9 @@ int testSimpleControls(struct node *node) for (iter = node->controls.begin(); iter != node->controls.end(); ++iter) { test_query_ext_ctrl &qctrl = iter->second; + if (qctrl.elems > 1) + continue; + info("checking control '%s' (0x%08x)\n", qctrl.name, qctrl.id); ctrl.id = qctrl.id; if (qctrl.type == V4L2_CTRL_TYPE_INTEGER64 ||
@@ -518,6 +521,10 @@ static int checkExtendedCtrl(struct v4l2_ext_control &ctrl, struct test_query_ex if (ctrl.id != qctrl.id) return fail("control id mismatch\n"); + + if (qctrl.elems > 1) + return 0; + switch (qctrl.type) { case V4L2_CTRL_TYPE_INTEGER: case V4L2_CTRL_TYPE_INTEGER64:
@@ -620,7 +627,8 @@ int testExtendedControls(struct node *node) ctrl.id = qctrl.id; ctrl.value = qctrl.default_value; } else { - if (ret != ENOSPC && qctrl.type == V4L2_CTRL_TYPE_STRING) + if (ret != ENOSPC && + (qctrl.type == V4L2_CTRL_TYPE_STRING || qctrl.elems > 1 )) return fail("did not check against size\n"); if (ret == ENOSPC && qctrl.type == V4L2_CTRL_TYPE_STRING) { if (ctrls.error_idx != 0)
@@ -629,6 +637,10 @@ int testExtendedControls(struct node *node) ctrl.size = qctrl.maximum + 1; ret = doioctl(node, VIDIOC_G_EXT_CTRLS, &ctrls); } + if (ret == ENOSPC && qctrl.elems > 1){ + ctrl.ptr = new char[ctrl.size]; + ret = doioctl(node, VIDIOC_G_EXT_CTRLS, &ctrls); + } if (ret == EIO) { warn("g_ext_ctrls returned EIO\n"); ret = 0;
@@ -668,7 +680,7 @@ int testExtendedControls(struct node *node) if (checkExtendedCtrl(ctrl, qctrl)) return fail("s_ext_ctrls returned invalid control contents (%08x)\n", qctrl.id); } - if (qctrl.type == V4L2_CTRL_TYPE_STRING) + if (qctrl.type == V4L2_CTRL_TYPE_STRING || qctrl.elems > 1) delete [] ctrl.string; ctrl.string = NULL; }
@@ -708,6 +720,10 @@ int testExtendedControls(struct node *node) ctrl.size = qctrl.maximum + 1; ctrl.string = new char[ctrl.size]; } + if (qctrl.elems > 1){ + ctrl.size = qctrl.elem_size * qctrl.elems; + ctrl.ptr = new char[ctrl.size]; + } ctrl.reserved2[0] = 0; if (!ctrl_class) ctrl_class = V4L2_CTRL_ID2CLASS(ctrl.id);
Signature · 1 line
2.5.1
Quoted 6 lines · Ricardo Ribalda Delgado
Without this patch:
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
testVIDIOC_QUERYCTRL: OK
fail: v4l2-test-controls.cpp(411):g_ctrlreturned an error (22)
That's weird.
At the moment v4l2-compliance doesn't test compound controls at all (that really should be added!). But it never should see them anyway since V4L2_CTRL_FLAG_NEXT_COMPOUND is never used, so any compound controls should be ignored.
So why does v4l2-compliance see compound controls? Is there perhaps a bug in the control framework?
Regards,
Hans
Quoted 79 lines
test VIDIOC_G/S_CTRL: FAIL
fail: v4l2-test-controls.cpp(637):g_ext_ctrlsreturned an error (28) test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 55 Private Controls: 0Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- utils/v4l2-compliance/v4l2-test-controls.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)utils/v4l2-compliance/v4l2-test-controls.cpp +18
-2@@ -377,6 +377,9 @@ int testSimpleControls(struct node *node) for (iter = node->controls.begin(); iter != node->controls.end(); ++iter) { test_query_ext_ctrl &qctrl = iter->second; + if (qctrl.elems > 1) + continue; + info("checking control '%s' (0x%08x)\n", qctrl.name, qctrl.id); ctrl.id = qctrl.id; if (qctrl.type == V4L2_CTRL_TYPE_INTEGER64 ||@@ -518,6 +521,10 @@ static int checkExtendedCtrl(struct v4l2_ext_control &ctrl, struct test_query_ex if (ctrl.id != qctrl.id) return fail("control id mismatch\n"); + + if (qctrl.elems > 1) + return 0; + switch (qctrl.type) { case V4L2_CTRL_TYPE_INTEGER: case V4L2_CTRL_TYPE_INTEGER64:@@ -620,7 +627,8 @@ int testExtendedControls(struct node *node) ctrl.id = qctrl.id; ctrl.value = qctrl.default_value; } else { - if (ret != ENOSPC && qctrl.type == V4L2_CTRL_TYPE_STRING) + if (ret != ENOSPC && + (qctrl.type == V4L2_CTRL_TYPE_STRING || qctrl.elems > 1 )) return fail("did not check against size\n"); if (ret == ENOSPC && qctrl.type == V4L2_CTRL_TYPE_STRING) { if (ctrls.error_idx != 0)@@ -629,6 +637,10 @@ int testExtendedControls(struct node *node) ctrl.size = qctrl.maximum + 1; ret = doioctl(node, VIDIOC_G_EXT_CTRLS, &ctrls); } + if (ret == ENOSPC && qctrl.elems > 1){ + ctrl.ptr = new char[ctrl.size]; + ret = doioctl(node, VIDIOC_G_EXT_CTRLS, &ctrls); + } if (ret == EIO) { warn("g_ext_ctrls returned EIO\n"); ret = 0;@@ -668,7 +680,7 @@ int testExtendedControls(struct node *node) if (checkExtendedCtrl(ctrl, qctrl)) return fail("s_ext_ctrls returned invalid control contents (%08x)\n", qctrl.id); } - if (qctrl.type == V4L2_CTRL_TYPE_STRING) + if (qctrl.type == V4L2_CTRL_TYPE_STRING || qctrl.elems > 1) delete [] ctrl.string; ctrl.string = NULL; }@@ -708,6 +720,10 @@ int testExtendedControls(struct node *node) ctrl.size = qctrl.maximum + 1; ctrl.string = new char[ctrl.size]; } + if (qctrl.elems > 1){ + ctrl.size = qctrl.elem_size * qctrl.elems; + ctrl.ptr = new char[ctrl.size]; + } ctrl.reserved2[0] = 0; if (!ctrl_class) ctrl_class = V4L2_CTRL_ID2CLASS(ctrl.id);