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: fix valid_buftypes/valid_memory_type handling Author: Hans Verkuil <[email protected]> Date: Wed Jul 1 16:30:27 2026 +0200 The set of valid buffer types and valid memory streaming types depend on the current input or output. But they were only calculated for the initial input/output and the same values were used when testing other inputs/outputs. Change it so these values are obtained new whenever we change input or output. Without this e.g. v4l2-compliance vbi streaming always failed with vivid because the initial input is the webcam, which does not support VBI. Changing to input 1 (TV) caused v4l2-compliance to mark the streaming ioctls as 'Not Supported' because it was using the valid_buftypes bitmask as detected with input 0. With this change, the test-media regression script is now correctly streaming for all the vivid devices, with the exception of the metadata output devices, but that's a vivid driver bug and has to be addressed there. Signed-off-by: Hans Verkuil <[email protected]> utils/v4l2-compliance/v4l2-compliance.cpp | 21 ++++++--------- utils/v4l2-compliance/v4l2-compliance.h | 1 + utils/v4l2-compliance/v4l2-test-buffers.cpp | 42 ++++++++++++++++++++--------- utils/v4l2-compliance/v4l2-test-formats.cpp | 18 ++++++++++--- 4 files changed, 53 insertions(+), 29 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=960c9cbf9b06113337a7fc24f52722eb2c736435 diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp index 4e5c9d00deb5..cf523b9fefa0 100644 --- a/utils/v4l2-compliance/v4l2-compliance.cpp +++ b/utils/v4l2-compliance/v4l2-compliance.cpp @@ -843,6 +843,7 @@ static void streamingSetup(struct node *node) doioctl(node, VIDIOC_ENUMOUTPUT, &output); node->cur_io_caps = output.capabilities; } + setValidBufTypes(node); } static int parse_subopt(char **subs, const char * const *subopts, char **value) @@ -1561,21 +1562,15 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_ printf("\ttest USERPTR (select): %s\n", ok(testUserPtr(&node, &node_m2m_cap, frame_count, POLL_MODE_SELECT))); node.reopen(); - if (options[OptSetExpBufDevice] || - !(node.valid_memorytype & (1 << V4L2_MEMORY_DMABUF))) { - if (!(node.codec_mask & (STATEFUL_ENCODER | STATEFUL_DECODER))) { - printf("\ttest DMABUF (no poll): %s\n", - ok(testDmaBuf(&expbuf_node, &node, &node_m2m_cap, - frame_count, POLL_MODE_NONE))); - node.reopen(); - } - printf("\ttest DMABUF (select): %s\n", - ok(testDmaBuf(&expbuf_node, &node, &node_m2m_cap, frame_count, POLL_MODE_SELECT))); + if (!(node.codec_mask & (STATEFUL_ENCODER | STATEFUL_DECODER))) { + printf("\ttest DMABUF (no poll): %s\n", + ok(testDmaBuf(&expbuf_node, &node, &node_m2m_cap, + frame_count, POLL_MODE_NONE))); node.reopen(); - } else if (!options[OptSetExpBufDevice]) { - printf("\ttest DMABUF: Cannot test, specify --expbuf-device\n"); } - + printf("\ttest DMABUF (select): %s\n", + ok(testDmaBuf(&expbuf_node, &node, &node_m2m_cap, frame_count, POLL_MODE_SELECT))); + node.reopen(); printf("\n"); } diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h index 4a7af5f5bce5..b43c58171158 100644 --- a/utils/v4l2-compliance/v4l2-compliance.h +++ b/utils/v4l2-compliance/v4l2-compliance.h @@ -318,6 +318,7 @@ int check_string(const char *s, size_t len); int check_ustring(const __u8 *s, int len); int check_0(const void *p, int len); int restoreFormat(struct node *node); +void setValidBufTypes(struct node *node); void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_node, media_type type, unsigned frame_count, unsigned all_fmt_frame_count, int parent_media_fd = -1); std::string stream_from(const std::string &pixelformat, bool &use_hdr); diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp index 7e08668b7017..1d4fdf6d7337 100644 --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp @@ -647,6 +647,17 @@ int testRemoveBufs(struct node *node) return 0; } +static void setValidMemoryType(struct node *node, unsigned caps) +{ + node->valid_memorytype = 0; + if (caps & V4L2_BUF_CAP_SUPPORTS_MMAP) + node->valid_memorytype |= 1 << V4L2_MEMORY_MMAP; + if (caps & V4L2_BUF_CAP_SUPPORTS_USERPTR) + node->valid_memorytype |= 1 << V4L2_MEMORY_USERPTR; + if (caps & V4L2_BUF_CAP_SUPPORTS_DMABUF) + node->valid_memorytype |= 1 << V4L2_MEMORY_DMABUF; +} + int testReqBufs(struct node *node) { struct v4l2_create_buffers crbufs = { }; @@ -694,6 +705,7 @@ int testReqBufs(struct node *node) mmap_valid = !ret; if (mmap_valid) node->buf_caps = caps = q.g_capabilities(); + setValidMemoryType(node, caps); if (caps) { fail_on_test(mmap_valid ^ !!(caps & V4L2_BUF_CAP_SUPPORTS_MMAP)); if (caps & V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS) @@ -730,7 +742,6 @@ int testReqBufs(struct node *node) fail_on_test(q.g_type() != i); fail_on_test(q.reqbufs(node, 1)); fail_on_test(testQueryBuf(node, i, q.g_buffers())); - node->valid_memorytype |= 1 << V4L2_MEMORY_MMAP; } if (userptr_valid) { @@ -741,7 +752,6 @@ int testReqBufs(struct node *node) fail_on_test(q.g_type() != i); fail_on_test(q.reqbufs(node, 1)); fail_on_test(testQueryBuf(node, i, q.g_buffers())); - node->valid_memorytype |= 1 << V4L2_MEMORY_USERPTR; } if (dmabuf_valid) { @@ -752,7 +762,6 @@ int testReqBufs(struct node *node) fail_on_test(q.g_type() != i); fail_on_test(q.reqbufs(node, 1)); fail_on_test(testQueryBuf(node, i, q.g_buffers())); - node->valid_memorytype |= 1 << V4L2_MEMORY_DMABUF; } /* @@ -2090,6 +2099,7 @@ int testUserPtr(struct node *node, struct node *node_m2m_cap, unsigned frame_cou q.s_userptr(i, p, nullptr); } } + fail_on_test(q.reqbufs(node, 0)); stream_close(); } return 0; @@ -2189,18 +2199,8 @@ int testDmaBuf(struct node *expbuf_node, struct node *node, struct node *node_m2 if (node->is_m2m && !v4l_type_is_output(type)) continue; - if (expbuf_node->g_caps() & V4L2_CAP_VIDEO_CAPTURE_MPLANE) - expbuf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; - else if (expbuf_node->g_caps() & V4L2_CAP_VIDEO_CAPTURE) - expbuf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - else if (expbuf_node->g_caps() & V4L2_CAP_VIDEO_OUTPUT_MPLANE) - expbuf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; - else - expbuf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - cv4l_queue q(type, V4L2_MEMORY_DMABUF); cv4l_queue m2m_q(v4l_type_invert(type)); - cv4l_queue exp_q(expbuf_type, V4L2_MEMORY_MMAP); if (testSetupVbi(node, type)) continue; @@ -2213,6 +2213,22 @@ int testDmaBuf(struct node *expbuf_node, struct node *node, struct node *node_m2 return ENOTTY; } fail_on_test(!can_stream); + setValidMemoryType(node, q.g_capabilities()); + + if ((node->valid_memorytype & (1 << V4L2_MEMORY_DMABUF)) && + expbuf_node->g_fd() < 0) { + warn_once("Cannot test DMABUF, specify --expbuf-device\n"); + return ENOTTY; + } + if (expbuf_node->g_caps() & V4L2_CAP_VIDEO_CAPTURE_MPLANE) + expbuf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + else if (expbuf_node->g_caps() & V4L2_CAP_VIDEO_CAPTURE) + expbuf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + else if (expbuf_node->g_caps() & V4L2_CAP_VIDEO_OUTPUT_MPLANE) + expbuf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + else + expbuf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + cv4l_queue exp_q(expbuf_type, V4L2_MEMORY_MMAP); fail_on_test(q.reqbufs(node, 2)); fail_on_test(node->streamoff(q.g_type())); diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp index 56b6614162cf..dbe635d96c12 100644 --- a/utils/v4l2-compliance/v4l2-test-formats.cpp +++ b/utils/v4l2-compliance/v4l2-test-formats.cpp @@ -647,6 +647,20 @@ static int testFormatsType(struct node *node, int ret, unsigned type, struct v4 return 0; } +void setValidBufTypes(struct node *node) +{ + struct v4l2_clip clip; + struct v4l2_format fmt; + int type; + + node->valid_buftypes = 0; + for (type = 0; type <= V4L2_BUF_TYPE_LAST; type++) { + createInvalidFmt(fmt, clip, type); + if (!doioctl(node, VIDIOC_G_FMT, &fmt)) + node->valid_buftypes |= 1 << type; + } +} + int testGetFormats(struct node *node) { struct v4l2_clip clip; @@ -655,12 +669,10 @@ int testGetFormats(struct node *node) int type; int ret; + setValidBufTypes(node); for (type = 0; type <= V4L2_BUF_TYPE_LAST; type++) { createInvalidFmt(fmt, clip, type); ret = doioctl(node, VIDIOC_G_FMT, &fmt); - if (!ret) - node->valid_buftypes |= 1 << type; - ret = testFormatsType(node, ret, type, fmt); if (ret && ret != ENOTTY) _______________________________________________ linuxtv-commits mailing list -- [email protected] To unsubscribe send an email to [email protected]
