Skip to contentSkip to conversation

v4l2-compliance: check errors returned by CREATE_BUFS

PATCH In review Deborah Brouwer 2 participants 2 messages Oct 5, 2023 – Oct 11, 2023 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 v4l2-compliance: check errors returned by CREATE_BUFS

If VIDIOC_CREATE_BUFS is not supported by a driver, it should return ENOTTY on all queues; so add a test to fail if ENOTTY is returned on only one queue.

If VIDIOC_CREATE_BUFS is supported, asymmetrically, on only one queue and not another, then the driver should return EOPNOTSUPP for only that queue. Fail if the driver returns EOPNOTSUPP on both queues.

---
Changes since v1:
- add the ENOTTY test
- use a count instead of bool to keep track of error codes

On the wave5 driver, v4l2-compliance -d0 -v shows:
<snip>
Buffer ioctls:
info: test buftype Video Capture Multiplanar
info: VIDIOC_CREATE_BUFS not supported for Video Capture Multiplanar
info: test buftype Video Output Multiplanar
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
info: could not test the Request API, no suitable control found
test Requests: OK (Not Supported)

Total for wave5-dec device /dev/video0: 45, Succeeded: 45, Failed: 0, Warnings: 0

 utils/v4l2-compliance/v4l2-test-buffers.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
utils/v4l2-compliance/v4l2-test-buffers.cpp +15 -0
index 6d592c9b..632da7f8 100644
@@ -540,6 +540,9 @@ int testReqBufs(struct node *node)
 	bool dmabuf_valid;
 	int ret;
 	unsigned i, m;
+	int crbufs_ok_cnt = 0;
+	int crbufs_enotty_cnt = 0;
+	int crbufs_eopnotsupp_cnt = 0;
 
 	node->reopen();
 
@@ -690,9 +693,21 @@ int testReqBufs(struct node *node)
 
 			ret = q.create_bufs(node, 0);
 			if (ret == ENOTTY) {
+				/* VIDIOC_CREATE_BUFS is not supported at all. */
+				crbufs_enotty_cnt++;
+				fail_on_test(crbufs_enotty_cnt && (crbufs_eopnotsupp_cnt + crbufs_ok_cnt));
 				warn("VIDIOC_CREATE_BUFS not supported\n");
 				break;
 			}
+			if (ret == EOPNOTSUPP) {
+				/* VIDIOC_CREATE_BUFS is supported on one queue but not the other. */
+				fail_on_test(crbufs_eopnotsupp_cnt && !crbufs_ok_cnt);
+				crbufs_eopnotsupp_cnt++;
+				info("VIDIOC_CREATE_BUFS not supported for %s\n",
+				     buftype2s(q.g_type()).c_str());
+				break;
+			}
+			crbufs_ok_cnt++;
 
 			memset(&crbufs, 0xff, sizeof(crbufs));
 			node->g_fmt(crbufs.format, i);
Signature · 1 line
2.40.1
#1 lore raw
Quoted 46 lines · Deborah Brouwer

If VIDIOC_CREATE_BUFS is not supported by a driver, it should return ENOTTY on all queues; so add a test to fail if ENOTTY is returned on only one queue.

If VIDIOC_CREATE_BUFS is supported, asymmetrically, on only one queue and not another, then the driver should return EOPNOTSUPP for only that queue. Fail if the driver returns EOPNOTSUPP on both queues.

---
Changes since v1:
- add the ENOTTY test
- use a count instead of bool to keep track of error codes

On the wave5 driver, v4l2-compliance -d0 -v shows:
<snip>
Buffer ioctls:
info: test buftype Video Capture Multiplanar
info: VIDIOC_CREATE_BUFS not supported for Video Capture Multiplanar
info: test buftype Video Output Multiplanar
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
info: could not test the Request API, no suitable control found
test Requests: OK (Not Supported)

Total for wave5-dec device /dev/video0: 45, Succeeded: 45, Failed: 0, Warnings: 0

 utils/v4l2-compliance/v4l2-test-buffers.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
utils/v4l2-compliance/v4l2-test-buffers.cpp +3 -0
index 6d592c9b..632da7f8 100644
@@ -540,6 +540,9 @@ int testReqBufs(struct node *node)
 	bool dmabuf_valid;
 	int ret;
 	unsigned i, m;
+	int crbufs_ok_cnt = 0;
+	int crbufs_enotty_cnt = 0;
+	int crbufs_eopnotsupp_cnt = 0;
 
 	node->reopen();
 

utils/v4l2-compliance/v4l2-test-buffers.cpp int testReqBufs(struct node *node) · line 697

Quoted 5 lines
utils/v4l2-compliance/v4l2-test-buffers.cpp +2 -0
@@ -690,9 +693,21 @@ int testReqBufs(struct node *node)
 
 			ret = q.create_bufs(node, 0);
 			if (ret == ENOTTY) {
+				/* VIDIOC_CREATE_BUFS is not supported at all. */
+				crbufs_enotty_cnt++;

Just count here...

utils/v4l2-compliance/v4l2-test-buffers.cpp int testReqBufs(struct node *node) · line 698

Quoted 1 line
utils/v4l2-compliance/v4l2-test-buffers.cpp +1 -0
+				fail_on_test(crbufs_enotty_cnt && (crbufs_eopnotsupp_cnt + crbufs_ok_cnt));

...and move the fail_on_test to after the loop, when all the counter values are final.

utils/v4l2-compliance/v4l2-test-buffers.cpp int testReqBufs(struct node *node) · line 704

Quoted 6 lines
utils/v4l2-compliance/v4l2-test-buffers.cpp +3 -0
 				warn("VIDIOC_CREATE_BUFS not supported\n");
 				break;
 			}
+			if (ret == EOPNOTSUPP) {
+				/* VIDIOC_CREATE_BUFS is supported on one queue but not the other. */
+				fail_on_test(crbufs_eopnotsupp_cnt && !crbufs_ok_cnt);

Also move to after the loop is done.

utils/v4l2-compliance/v4l2-test-buffers.cpp int testReqBufs(struct node *node) · line 713

Quoted 9 lines
utils/v4l2-compliance/v4l2-test-buffers.cpp +6 -0
+				crbufs_eopnotsupp_cnt++;
+				info("VIDIOC_CREATE_BUFS not supported for %s\n",
+				     buftype2s(q.g_type()).c_str());
+				break;
+			}
+			crbufs_ok_cnt++;
 
 			memset(&crbufs, 0xff, sizeof(crbufs));
 			node->g_fmt(crbufs.format, i);

Regards,

Hans