[PATCH i-g-t v6 2/2] tests/chamelium/kms_chamelium_hpd: use helper function for connector lookup in DP/HDMI/VGA tests

Mohammed Bilal
2026-01-29T07:49:35Z

Introduce a unified connector_test() helper that iterates over and tests
all matching connected ports, ensuring clean skipping and consistent
connector handling across DP/HDMI/VGA tests, and avoiding unintended
execution of unrelated fixtures.

Signed-off-by: Mohammed Bilal <mohammed.bilal@intel.com>
---
tests/chamelium/kms_chamelium_hpd.c | 239 ++++++++++++----------------
1 file changed, 98 insertions(+), 141 deletions(-)

diff --git a/tests/chamelium/kms_chamelium_hpd.c b/tests/chamelium/kms_chamelium_hpd.c
index 8f13b380a..dd1735956 100644
--- a/tests/chamelium/kms_chamelium_hpd.c
+++ b/tests/chamelium/kms_chamelium_hpd.c
@@ -465,157 +465,117 @@ IGT_TEST_DESCRIPTION("Testing HPD with a Chamelium board");
int igt_main()
{
chamelium_data_t data;
- struct chamelium_port *port;
- int p;

igt_fixture() {
chamelium_init_test(&data);
}

igt_describe("DisplayPort tests");
- igt_subtest_group() {
- igt_fixture() {
- chamelium_require_connector_present(
- data.ports, DRM_MODE_CONNECTOR_DisplayPort,
- data.port_count, 1);
- }

- igt_describe(test_basic_hotplug_desc);
- connector_subtest("dp-hpd", DisplayPort)
- test_hotplug(&data, port, HPD_TOGGLE_COUNT_DP_HDMI,
- TEST_MODESET_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("dp-hpd-fast", DisplayPort) test_hotplug(
- &data, port, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("dp-hpd-enable-disable-mode", DisplayPort)
- test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
- TEST_MODESET_ON_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("dp-hpd-with-enabled-mode", DisplayPort)
- test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
- TEST_MODESET_ON);
-
- igt_describe(test_hotplug_for_each_pipe_desc);
- connector_subtest("dp-hpd-for-each-pipe", DisplayPort)
- test_hotplug_for_each_pipe(&data, port);
-
- igt_describe(test_suspend_resume_hpd_desc);
- connector_subtest("dp-hpd-after-suspend", DisplayPort)
- test_suspend_resume_hpd(&data, port, SUSPEND_STATE_MEM,
- SUSPEND_TEST_NONE);
-
- igt_describe(test_suspend_resume_hpd_desc);
- connector_subtest("dp-hpd-after-hibernate", DisplayPort)
- test_suspend_resume_hpd(&data, port, SUSPEND_STATE_DISK,
- SUSPEND_TEST_DEVICES);
-
- igt_describe(test_hpd_storm_detect_desc);
- connector_subtest("dp-hpd-storm", DisplayPort)
- test_hpd_storm_detect(&data, port,
- HPD_STORM_PULSE_INTERVAL_DP);
-
- igt_describe(test_hpd_storm_disable_desc);
- connector_subtest("dp-hpd-storm-disable", DisplayPort)
- test_hpd_storm_disable(&data, port,
- HPD_STORM_PULSE_INTERVAL_DP);
- }
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("dp-hpd", DisplayPort, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_DP_HDMI, TEST_MODESET_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("dp-hpd-fast", DisplayPort, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("dp-hpd-enable-disable-mode", DisplayPort, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("dp-hpd-with-enabled-mode", DisplayPort, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON);
+
+ igt_describe(test_hotplug_for_each_pipe_desc);
+ connector_test("dp-hpd-for-each-pipe", DisplayPort, &data,
+ test_hotplug_for_each_pipe);
+
+ igt_describe(test_suspend_resume_hpd_desc);
+ connector_test("dp-hpd-after-suspend", DisplayPort, &data, test_suspend_resume_hpd,
+ SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);
+
+ igt_describe(test_suspend_resume_hpd_desc);
+ connector_test("dp-hpd-after-hibernate", DisplayPort, &data, test_suspend_resume_hpd,
+ SUSPEND_STATE_DISK, SUSPEND_TEST_DEVICES);
+
+ igt_describe(test_hpd_storm_detect_desc);
+ connector_test("dp-hpd-storm", DisplayPort, &data, test_hpd_storm_detect,
+ HPD_STORM_PULSE_INTERVAL_DP);
+
+ igt_describe(test_hpd_storm_disable_desc);
+ connector_test("dp-hpd-storm-disable", DisplayPort, &data, test_hpd_storm_disable,
+ HPD_STORM_PULSE_INTERVAL_DP);

igt_describe("HDMI tests");
- igt_subtest_group() {
- igt_fixture() {
- chamelium_require_connector_present(
- data.ports, DRM_MODE_CONNECTOR_HDMIA,
- data.port_count, 1);
- }

- igt_describe(test_basic_hotplug_desc);
- connector_subtest("hdmi-hpd", HDMIA)
- test_hotplug(&data, port, HPD_TOGGLE_COUNT_DP_HDMI,
- TEST_MODESET_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("hdmi-hpd-fast", HDMIA) test_hotplug(
- &data, port, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("hdmi-hpd-enable-disable-mode", HDMIA)
- test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
- TEST_MODESET_ON_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("hdmi-hpd-with-enabled-mode", HDMIA)
- test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
- TEST_MODESET_ON);
-
- igt_describe(test_hotplug_for_each_pipe_desc);
- connector_subtest("hdmi-hpd-for-each-pipe", HDMIA)
- test_hotplug_for_each_pipe(&data, port);
-
- igt_describe(test_suspend_resume_hpd_desc);
- connector_subtest("hdmi-hpd-after-suspend", HDMIA)
- test_suspend_resume_hpd(&data, port, SUSPEND_STATE_MEM,
- SUSPEND_TEST_NONE);
-
- igt_describe(test_suspend_resume_hpd_desc);
- connector_subtest("hdmi-hpd-after-hibernate", HDMIA)
- test_suspend_resume_hpd(&data, port, SUSPEND_STATE_DISK,
- SUSPEND_TEST_DEVICES);
-
- igt_describe(test_hpd_storm_detect_desc);
- connector_subtest("hdmi-hpd-storm", HDMIA)
- test_hpd_storm_detect(&data, port,
- HPD_STORM_PULSE_INTERVAL_HDMI);
-
- igt_describe(test_hpd_storm_disable_desc);
- connector_subtest("hdmi-hpd-storm-disable", HDMIA)
- test_hpd_storm_disable(&data, port,
- HPD_STORM_PULSE_INTERVAL_HDMI);
- }
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("hdmi-hpd", HDMIA, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_DP_HDMI, TEST_MODESET_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("hdmi-hpd-fast", HDMIA, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("hdmi-hpd-enable-disable-mode", HDMIA, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("hdmi-hpd-with-enabled-mode", HDMIA, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON);
+
+ igt_describe(test_hotplug_for_each_pipe_desc);
+ connector_test("hdmi-hpd-for-each-pipe", HDMIA, &data, test_hotplug_for_each_pipe);
+
+ igt_describe(test_suspend_resume_hpd_desc);
+ connector_test("hdmi-hpd-after-suspend", HDMIA, &data, test_suspend_resume_hpd,
+ SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);
+
+ igt_describe(test_suspend_resume_hpd_desc);
+ connector_test("hdmi-hpd-after-hibernate", HDMIA, &data, test_suspend_resume_hpd,
+ SUSPEND_STATE_DISK, SUSPEND_TEST_DEVICES);
+
+ igt_describe(test_hpd_storm_detect_desc);
+ connector_test("hdmi-hpd-storm", HDMIA, &data, test_hpd_storm_detect,
+ HPD_STORM_PULSE_INTERVAL_HDMI);
+
+ igt_describe(test_hpd_storm_disable_desc);
+ connector_test("hdmi-hpd-storm-disable", HDMIA, &data, test_hpd_storm_disable,
+ HPD_STORM_PULSE_INTERVAL_HDMI);

igt_describe("VGA tests");
- igt_subtest_group() {
- igt_fixture() {
- chamelium_require_connector_present(
- data.ports, DRM_MODE_CONNECTOR_VGA,
- data.port_count, 1);
- }

- igt_describe(test_basic_hotplug_desc);
- connector_subtest("vga-hpd", VGA) test_hotplug(
- &data, port, HPD_TOGGLE_COUNT_VGA, TEST_MODESET_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("vga-hpd-fast", VGA) test_hotplug(
- &data, port, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("vga-hpd-enable-disable-mode", VGA)
- test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
- TEST_MODESET_ON_OFF);
-
- igt_describe(test_basic_hotplug_desc);
- connector_subtest("vga-hpd-with-enabled-mode", VGA)
- test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
- TEST_MODESET_ON);
-
- igt_describe(test_suspend_resume_hpd_desc);
- connector_subtest("vga-hpd-after-suspend", VGA)
- test_suspend_resume_hpd(&data, port, SUSPEND_STATE_MEM,
- SUSPEND_TEST_NONE);
-
- igt_describe(test_suspend_resume_hpd_desc);
- connector_subtest("vga-hpd-after-hibernate", VGA)
- test_suspend_resume_hpd(&data, port, SUSPEND_STATE_DISK,
- SUSPEND_TEST_DEVICES);
-
- igt_describe(test_hpd_without_ddc_desc);
- connector_subtest("vga-hpd-without-ddc", VGA)
- test_hpd_without_ddc(&data, port);
- }
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("vga-hpd", VGA, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_VGA, TEST_MODESET_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("vga-hpd-fast", VGA, &data, test_hotplug,
+ HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("vga-hpd-enable-disable-mode", VGA, &data,
+ test_hotplug, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON_OFF);
+
+ igt_describe(test_basic_hotplug_desc);
+ connector_test("vga-hpd-with-enabled-mode", VGA, &data,
+ test_hotplug, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON);
+
+ igt_describe(test_suspend_resume_hpd_desc);
+ connector_test("vga-hpd-after-suspend", VGA, &data,
+ test_suspend_resume_hpd, SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);
+
+ igt_describe(test_suspend_resume_hpd_desc);
+ connector_test("vga-hpd-after-hibernate", VGA, &data,
+ test_suspend_resume_hpd, SUSPEND_STATE_DISK, SUSPEND_TEST_DEVICES);
+
+ igt_describe(test_hpd_without_ddc_desc);
+ connector_test("vga-hpd-without-ddc", VGA, &data, test_hpd_without_ddc);
+
+ igt_describe(test_hotplug_for_each_pipe_desc);
+ connector_test("vga-hpd-for-each-pipe", VGA, &data, test_hotplug_for_each_pipe);

igt_describe("Tests that operate on all connectors");
igt_subtest_group() {
@@ -635,9 +595,6 @@ int igt_main()
SUSPEND_TEST_DEVICES);
}

- igt_describe(test_hotplug_for_each_pipe_desc);
- connector_subtest("vga-hpd-for-each-pipe", VGA)
- test_hotplug_for_each_pipe(&data, port);

igt_fixture() {
igt_display_fini(&data.display);
--
2.48.1