Skip to contentSkip to conversation

v4l-utils: add support for V4L2_CAP_EDID

PATCH New Hans Verkuil 1 participant 4 messages Aug 29, 2024 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

v2 cover v4l-utils: add support for V4L2_CAP_EDID

This series adds support for V4L2_CAP_EDID to v4l2-ctl and v4l2-compliance.

This is for this series:

https://patchwork.linuxtv.org/project/linux-media/list/?series=13364

Changes since v1:

- Check in v4l2-compliance that CAP_EDID isn't mixed with other video caps (and vice versa) as suggested by Ricardo.

Regards,

Hans

Hans Verkuil (3):
videodev2.h: add CAP_EDID (DO NOT COMMIT)
utils/common: add V4L2_CAP_EDID support
v4l2-compliance: add support for V4L2_CAP_EDID

 include/linux/videodev2.h                     |  1 +
 utils/common/v4l2-info.cpp                    |  2 ++
 utils/v4l2-compliance/v4l2-compliance.cpp     | 23 ++++++++++++++++---
 utils/v4l2-compliance/v4l2-test-io-config.cpp |  4 +++-
 4 files changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/3 videodev2.h: add CAP_EDID (DO NOT COMMIT)

Add capability flag to indicate that the device is an EDID-only device.

---
 include/linux/videodev2.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/videodev2.h +1 -0
index f18a40d4..dab68c8d 100644
@@ -475,6 +475,7 @@ struct v4l2_capability {
 #define V4L2_CAP_META_CAPTURE		0x00800000  /* Is a metadata capture device */
 
 #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
+#define V4L2_CAP_EDID			0x02000000  /* Is an EDID-only device */
 #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
 #define V4L2_CAP_META_OUTPUT		0x08000000  /* Is a metadata output device */
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/3 utils/common: add V4L2_CAP_EDID support

In reply to Hans Verkuil

Understand V4L2_CAP_EDID and log it.

---
 utils/common/v4l2-info.cpp | 2 ++
 1 file changed, 2 insertions(+)
utils/common/v4l2-info.cpp +2 -0
index aaf7b0b5..7dd7e708 100644
@@ -91,6 +91,8 @@ static std::string cap2s(unsigned cap)
 		s += "\t\tI/O MC\n";
 	if (cap & V4L2_CAP_READWRITE)
 		s += "\t\tRead/Write\n";
+	if (cap & V4L2_CAP_EDID)
+		s += "\t\tEDID Only\n";
 	if (cap & V4L2_CAP_STREAMING)
 		s += "\t\tStreaming\n";
 	if (cap & V4L2_CAP_EXT_PIX_FORMAT)
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/3 v4l2-compliance: add support for V4L2_CAP_EDID

In reply to Hans Verkuil

Add tests for devices that only support G/S_EDID and ENUM/G/S_INPUT or OUTPUT.

---
 utils/v4l2-compliance/v4l2-compliance.cpp     | 23 ++++++++++++++++---
 utils/v4l2-compliance/v4l2-test-io-config.cpp |  4 +++-
 2 files changed, 23 insertions(+), 4 deletions(-)
utils/v4l2-compliance/v4l2-compliance.cpp +20 -3
index 144f9618..542ba213 100644
@@ -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,13 @@ 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));
+	if (node->is_video) {
+		fail_on_test(!(dcaps & (video_caps | edid_caps)));
+		if (dcaps & edid_caps)
+			fail_on_test(dcaps & video_caps);
+		else if (dcaps & video_caps)
+			fail_on_test(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 +1042,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 +1416,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);
utils/v4l2-compliance/v4l2-test-io-config.cpp +3 -1
index dcab40b8..48eabe04 100644
@@ -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);
Signature · 1 line
2.43.0