[PATCH i-g-t v2 37/39] tests/chamelium/v3: Add test for display change detection during sleep

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


This commit introduces a new test for the Chameleon V3 display adapter to
ensure that it properly detects display changes during sleep. The test
verifies that if the display is disconnected/reconnected while the
device is in sleep mode, the new display is correctly detected upon waking
up.

This test is inspired by a similar test in the Chameleon V2 version.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 59 ++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/tests/chamelium/v3/kms_chamelium_v3_edid.c b/tests/chamelium/v3/kms_chamelium_v3_edid.c
index c03829b43aca..a73875214915 100644
--- a/tests/chamelium/v3/kms_chamelium_v3_edid.c
+++ b/tests/chamelium/v3/kms_chamelium_v3_edid.c
@@ -153,6 +153,43 @@ static void edid_resolution_list(int drm_fd, struct igt_chamelium_v3 *chamelium,
 	drmModeFreeConnector(connector);
 }
 
+static void test_suspend_resume_edid_change(int drm_fd, struct igt_chamelium_v3 *chamelium,
+					    struct chamelium_v3_port_mapping *port_mapping,
+					    enum igt_suspend_state state,
+					    enum igt_suspend_test test)
+{
+	chamelium_edid_id base_edid, alt_edid;
+	uint32_t connector_id;
+
+	chamelium_v3_reset(chamelium);
+
+	base_edid = chamelium_v3_create_edid(chamelium, igt_kms_get_base_edid());
+	igt_assert(base_edid);
+	alt_edid = chamelium_v3_create_edid(chamelium, igt_kms_get_alt_edid());
+	igt_assert(alt_edid);
+
+	chamelium_v3_apply_edid(chamelium, port_mapping->port_id, base_edid);
+	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, igt_kms_get_base_edid());
+
+	chamelium_v3_apply_edid(chamelium, port_mapping->port_id, alt_edid);
+
+	// Schedule the hpd pulse during the sleep state
+	chamelium_v3_schedule_hpd_toggle(chamelium, port_mapping->port_id,
+					 igt_get_autoresume_delay(state) * 1000 / 2,
+					 true);
+	igt_system_suspend_autoresume(state, test);
+
+	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, igt_kms_get_alt_edid());
+}
+
 igt_main
 {
 	struct igt_chamelium_v3 *chamelium;
@@ -267,6 +304,28 @@ igt_main
 		}
 	}
 
+	igt_describe("Check if hotplug during sleeping are correctly handled");
+	igt_subtest_with_dynamic("edid-edid-suspend-mem") {
+		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);
+
+				test_suspend_resume_edid_change(drm_fd, chamelium, port,
+								SUSPEND_STATE_MEM,
+								SUSPEND_TEST_NONE);
+			}
+		}
+	}
+
 	igt_fixture {
 		chamelium_v3_uninit(chamelium);
 		drm_close_driver(drm_fd);

-- 
2.44.2



More information about the igt-dev mailing list