diff mbox series

[3/3] v4l2-compliance: add support for V4L2_CAP_EDID

Message ID f4142c49c8bee0c4e7bc9af652fd1913e47fd9ae.1724067944.git.hverkuil-cisco@xs4all.nl (mailing list archive)
State New
Headers show
Series v4l-utils: add support for V4L2_CAP_EDID | expand

Commit Message

Hans Verkuil Aug. 19, 2024, 11:45 a.m. UTC
Add tests for devices that only support G/S_EDID and
ENUM/G/S_INPUT or OUTPUT.

Co-developed-by: Erling Ljunggren <hljunggr@cisco.com>
Signed-off-by: Erling Ljunggren <hljunggr@cisco.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 utils/v4l2-compliance/v4l2-compliance.cpp     | 17 ++++++++++++++---
 utils/v4l2-compliance/v4l2-test-io-config.cpp |  4 +++-
 2 files changed, 17 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 144f9618..c2832401 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -645,6 +645,7 @@  static int testCap(struct node *node)
 		V4L2_CAP_VIDEO_M2M_MPLANE;
 	const __u32 splane_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT |
 		V4L2_CAP_VIDEO_M2M;
+	const __u32 edid_caps = V4L2_CAP_EDID;
 
 	memset(&vcap, 0xff, sizeof(vcap));
 	fail_on_test(doioctl(node, VIDIOC_QUERYCAP, &vcap));
@@ -663,6 +664,7 @@  static int testCap(struct node *node)
 	    memcmp(vcap.bus_info, "platform:", 9) &&
 	    memcmp(vcap.bus_info, "rmi4:", 5) &&
 	    memcmp(vcap.bus_info, "libcamera:", 10) &&
+	    memcmp(vcap.bus_info, "serio:", 6) &&
 	    memcmp(vcap.bus_info, "gadget.", 7))
 		return fail("missing bus_info prefix ('%s')\n", vcap.bus_info);
 	if (!node->media_bus_info.empty() &&
@@ -685,7 +687,7 @@  static int testCap(struct node *node)
 	// for a modern driver for both caps and dcaps
 	fail_on_test(!(caps & V4L2_CAP_EXT_PIX_FORMAT));
 	//fail_on_test(!(dcaps & V4L2_CAP_EXT_PIX_FORMAT));
-	fail_on_test(node->is_video && !(dcaps & video_caps));
+	fail_on_test(node->is_video && !(dcaps & video_caps || dcaps & edid_caps));
 	fail_on_test(node->is_radio && !(dcaps & radio_caps));
 	// V4L2_CAP_AUDIO is invalid for radio and sdr
 	fail_on_test(node->is_radio && (dcaps & V4L2_CAP_AUDIO));
@@ -1034,6 +1036,14 @@  void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
 			 V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_SLICED_VBI_OUTPUT |
 			 V4L2_CAP_META_OUTPUT))
 		node.has_outputs = true;
+	if (node.g_caps() & V4L2_CAP_EDID) {
+		int tmp;
+
+		if (!ioctl(node.g_fd(), VIDIOC_G_INPUT, &tmp))
+			node.has_inputs = true;
+		else if (!ioctl(node.g_fd(), VIDIOC_G_OUTPUT, &tmp))
+			node.has_outputs = true;
+	}
 	if (node.g_caps() & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE |
 			 V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE |
 			 V4L2_CAP_VIDEO_M2M | V4L2_CAP_SLICED_VBI_CAPTURE |
@@ -1400,20 +1410,21 @@  void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
 		node.valid_buftypes = 0;
 		node.valid_memorytype = 0;
 		node.buf_caps = 0;
+		node.cur_io_caps = 0;
 		for (auto &buftype_pixfmt : node.buftype_pixfmts)
 			buftype_pixfmt.clear();
 
 		if (max_io) {
 			sprintf(suffix, " (%s %u)",
 				node.can_capture ? "Input" : "Output", io);
-			if (node.can_capture) {
+			if (node.has_inputs) {
 				struct v4l2_input descr;
 
 				doioctl(&node, VIDIOC_S_INPUT, &io);
 				descr.index = io;
 				doioctl(&node, VIDIOC_ENUMINPUT, &descr);
 				node.cur_io_caps = descr.capabilities;
-			} else {
+			} else if (node.has_outputs) {
 				struct v4l2_output descr;
 
 				doioctl(&node, VIDIOC_S_OUTPUT, &io);
diff --git a/utils/v4l2-compliance/v4l2-test-io-config.cpp b/utils/v4l2-compliance/v4l2-test-io-config.cpp
index dcab40b8..48eabe04 100644
--- a/utils/v4l2-compliance/v4l2-test-io-config.cpp
+++ b/utils/v4l2-compliance/v4l2-test-io-config.cpp
@@ -513,8 +513,10 @@  static int checkEdid(struct node *node, unsigned pad, bool is_input)
 		fail_on_test(doioctl(node, VIDIOC_S_EDID, &edid) != ENOTTY);
 		return ENOTTY;
 	}
+	if (!is_input && ret == ENODATA)
+		return 0;
 	has_edid = ret == 0;
-	fail_on_test(ret && ret != EINVAL);
+	fail_on_test_val(ret && ret != EINVAL, ret);
 	fail_on_test(!ret && check_0(edid.reserved, sizeof(edid.reserved)));
 	fail_on_test(edid.start_block);
 	fail_on_test(edid.blocks > 256);