[PATCH i-g-t v2 31/39] tests/chamelium/v3: Implement basic EDID handling test

Louis Chauvet louis.chauvet at bootlin.com
Tue Jul 9 15:34:47 UTC 2024


This commit introduces a new Chamelium v3 test to validate the proper
handling of EDID data. The test uploads a custom EDID to the Chamelium and
then confirms that the EDID data can be accurately read back from the
kernel.

This test is adapted from the v2 version.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 95 ++++++++++++++++++++++++++++++
 tests/meson.build                          |  1 +
 2 files changed, 96 insertions(+)

diff --git a/tests/chamelium/v3/kms_chamelium_v3_edid.c b/tests/chamelium/v3/kms_chamelium_v3_edid.c
new file mode 100644
index 000000000000..b8d750ad771d
--- /dev/null
+++ b/tests/chamelium/v3/kms_chamelium_v3_edid.c
@@ -0,0 +1,95 @@
+// SPDX-License-Identifier: MIT
+
+#include <igt.h>
+#include "chamelium/v3/igt_chamelium.h"
+
+static void collect_and_compare_edid(int drm_fd,
+				     const struct chamelium_v3_port_mapping *port_mapping,
+				     const struct edid *edid)
+{
+	drmModePropertyBlobPtr edid_blob = NULL;
+	uint64_t edid_blob_id;
+
+	uint32_t connector_id = chamelium_v3_port_mapping_get_connector_id(port_mapping, drm_fd);
+
+	/* Force refresh of properties */
+	drmModeFreeConnector(drmModeGetConnector(drm_fd, connector_id));
+	igt_assert(kmstest_get_property(drm_fd, connector_id,
+					DRM_MODE_OBJECT_CONNECTOR, "EDID", NULL,
+					&edid_blob_id, NULL));
+	igt_assert(edid_blob_id);
+	edid_blob = drmModeGetPropertyBlob(drm_fd, edid_blob_id);
+	igt_assert(edid_blob);
+	igt_assert(memcmp(edid, edid_blob->data, edid_get_size(edid)) == 0);
+
+	drmModeFreePropertyBlob(edid_blob);
+}
+
+static void upload_and_read_edid(int drm_fd, struct igt_chamelium_v3 *chamelium,
+				 const struct chamelium_v3_port_mapping *port_mapping,
+				 const struct edid *edid)
+{
+	uint32_t connector_id;
+
+	int edid_id;
+
+	chamelium_v3_reset(chamelium);
+	edid_id = chamelium_v3_create_edid(chamelium, edid);
+	chamelium_v3_apply_edid(chamelium, port_mapping->port_id, edid_id);
+	chamelium_v3_plug(chamelium, port_mapping->port_id);
+
+	connector_id = chamelium_v3_port_mapping_get_connector_id(port_mapping, drm_fd);
+	igt_assert(igt_wait_for_connector_status(drm_fd, connector_id, 10.0,
+						 DRM_MODE_CONNECTED));
+
+	collect_and_compare_edid(drm_fd, port_mapping, edid);
+}
+
+static void igt_custom_edid_type_read(int drm_fd, struct igt_chamelium_v3 *chamelium,
+				      struct chamelium_v3_port_mapping *port_mapping,
+				      enum igt_custom_edid_type edid)
+{
+	upload_and_read_edid(drm_fd, chamelium, port_mapping, igt_kms_get_custom_edid(edid));
+}
+
+igt_main
+{
+	struct igt_chamelium_v3 *chamelium;
+	int drm_fd;
+
+	igt_fixture {
+		chamelium = chamelium_v3_init_from_config();
+		igt_assert(chamelium);
+		drm_fd = drm_open_driver(DRIVER_ANY);
+		igt_assert(drm_fd);
+		chamelium_v3_fill_port_mapping(chamelium, drm_fd);
+	}
+
+	igt_describe("Read basic EDID from the chamelium.");
+	igt_subtest_with_dynamic("edid-read-basic") {
+		struct chamelium_v3_port_mapping *port, *tmp;
+
+		igt_list_for_each_entry_safe(port, tmp, chamelium_v3_get_port_mapping(chamelium),
+					     link) {
+			igt_dynamic_f("port-%d", port->port_id) {
+				char *name;
+
+				igt_require(!chamelium_v3_is_mst(chamelium, port->port_id));
+
+				name = chamelium_v3_get_port_name(chamelium, port->port_id);
+				igt_info("Testing port %s (%s)\n", port->connector_name, name);
+				free(name);
+
+				igt_custom_edid_type_read(drm_fd, chamelium, port,
+							  IGT_CUSTOM_EDID_BASE);
+				igt_custom_edid_type_read(drm_fd, chamelium, port,
+							  IGT_CUSTOM_EDID_ALT);
+			}
+		}
+	}
+
+	igt_fixture {
+		chamelium_v3_uninit(chamelium);
+		drm_close_driver(drm_fd);
+	}
+}
diff --git a/tests/meson.build b/tests/meson.build
index e36ae9b18ffc..ebaf1cb9ebb2 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -326,6 +326,7 @@ chamelium_v2_progs = [
 
 chamelium_v3_progs = [
 	'kms_chamelium_v3_basic',
+	'kms_chamelium_v3_edid',
 ]
 
 test_deps = [ igt_deps ]

-- 
2.44.2



More information about the igt-dev mailing list