[PATCH i-g-t 3/3] tests/kms: Use for_each_crtc_with_valid_output()

Ville Syrjala
2026-04-13T20:01:06Z

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

A few tests are doing nested for_each_crtc() and
for_each_valid_output_on_crtc() loops. This is basically
the same as for_each_crtc_with_valid_output(), so just
use that instead. This drops the indentation by two levels,
which is nice.

Note that the original code had the crtc as the outer loop
and output as the inner loop, whereas for_each_crtc_with_valid_output()
does it the other way around. I don't think the difference
should matter here.

And while at it, rename the 'crtc' variable to 'crtc1'
to match the naming of the corresponding output variables.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
tests/kms_display_modes.c | 61 +++++++++++++++---------------------
tests/kms_plane_multiple.c | 63 +++++++++++++++-----------------------
2 files changed, 49 insertions(+), 75 deletions(-)

diff --git a/tests/kms_display_modes.c b/tests/kms_display_modes.c
index 76e73152a2ab..d8aae4256122 100644
--- a/tests/kms_display_modes.c
+++ b/tests/kms_display_modes.c
@@ -178,49 +178,36 @@ static void run_extendedmode_basic(data_t *data, igt_crtc_t *crtc1,
}

static void run_extendedmode_test(data_t *data) {
- igt_crtc_t *crtc2;
- igt_crtc_t *crtc;
bool sim_flag = igt_run_in_simulation();
+ igt_crtc_t *crtc1, *crtc2;
igt_output_t *output1, *output2;
igt_display_t *display = &data->display;

igt_display_reset(display);

- for_each_crtc(display, crtc) {
- for_each_valid_output_on_crtc(display,
- crtc,
- output1) {
-
- for_each_crtc(display, crtc2) {
- if (crtc == crtc2)
- continue;
-
- for_each_valid_output_on_crtc(display, crtc2, output2) {
- if (output1 == output2)
- continue;
-
- igt_display_reset(display);
-
- igt_output_set_crtc(output1,
- crtc);
- igt_output_set_crtc(output2,
- crtc2);
-
- if (!intel_pipe_output_combo_valid(display))
- continue;
-
- igt_dynamic_f("pipe-%s-%s-pipe-%s-%s",
- igt_crtc_name(crtc),
- igt_output_name(output1),
- igt_crtc_name(crtc2),
- igt_output_name(output2))
- run_extendedmode_basic(data,
- crtc,
- output1,
- crtc2,
- output2);
- }
- }
+ for_each_crtc_with_valid_output(display, crtc1, output1) {
+ for_each_crtc_with_valid_output(display, crtc2, output2) {
+ if (crtc1 == crtc2)
+ continue;
+
+ if (output1 == output2)
+ continue;
+
+ igt_display_reset(display);
+
+ igt_output_set_crtc(output1, crtc1);
+ igt_output_set_crtc(output2, crtc2);
+
+ if (!intel_pipe_output_combo_valid(display))
+ continue;
+
+ igt_dynamic_f("pipe-%s-%s-pipe-%s-%s",
+ igt_crtc_name(crtc1), igt_output_name(output1),
+ igt_crtc_name(crtc2), igt_output_name(output2))
+ run_extendedmode_basic(data,
+ crtc1, output1,
+ crtc2, output2);
+
/*
* In simulation env, only run the test once with a
* single valid pipe/output pair instead of all combos.
diff --git a/tests/kms_plane_multiple.c b/tests/kms_plane_multiple.c
index 55cee260d01f..0d338eeb5acb 100644
--- a/tests/kms_plane_multiple.c
+++ b/tests/kms_plane_multiple.c
@@ -524,8 +524,7 @@ static void test_plane_position_2_display(data_t *data, igt_crtc_t *crtc1,

static void run_2_display_test(data_t *data, uint64_t modifier, const char *name)
{
- igt_crtc_t *crtc2;
- igt_crtc_t *crtc;
+ igt_crtc_t *crtc1, *crtc2;
igt_output_t *output1, *output2;
igt_display_t *display = &data->display;

@@ -534,42 +533,30 @@ static void run_2_display_test(data_t *data, uint64_t modifier, const char *name

igt_display_reset(display);

- for_each_crtc(display, crtc) {
- for_each_valid_output_on_crtc(display,
- crtc,
- output1) {
- for_each_crtc(display, crtc2) {
- if (crtc == crtc2)
- continue;
-
- for_each_valid_output_on_crtc(display, crtc2, output2) {
- if (output1 == output2)
- continue;
-
- igt_display_reset(display);
-
- igt_output_set_crtc(output1,
- crtc);
- igt_output_set_crtc(output2,
- crtc2);
-
- if (!intel_pipe_output_combo_valid(display))
- continue;
-
- igt_dynamic_f("pipe-%s-%s-pipe-%s-%s",
- igt_crtc_name(crtc),
- output1->name,
- igt_crtc_name(crtc2),
- output2->name)
- test_plane_position_2_display(data,
- crtc,
- crtc2,
- output1, output2,
- modifier);
-
- test_fini_2_display(data);
- }
- }
+ for_each_crtc_with_valid_output(display, crtc1, output1) {
+ for_each_crtc_with_valid_output(display, crtc2, output2) {
+ if (crtc1 == crtc2)
+ continue;
+
+ if (output1 == output2)
+ continue;
+
+ igt_display_reset(display);
+
+ igt_output_set_crtc(output1, crtc1);
+ igt_output_set_crtc(output2, crtc2);
+
+ if (!intel_pipe_output_combo_valid(display))
+ continue;
+
+ igt_dynamic_f("pipe-%s-%s-pipe-%s-%s",
+ igt_crtc_name(crtc1), output1->name,
+ igt_crtc_name(crtc2), output2->name)
+ test_plane_position_2_display(data,
+ crtc1, crtc2,
+ output1, output2,
+ modifier);
+ test_fini_2_display(data);
}
}
}
--
2.52.0