[PATCH i-g-t v2 21/23] tests/kms: Use igt_crtc_t instead of enum pipe, part 2

Ville Syrjala
2026-02-21T03:21:29Z

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

Convert several kms tests to use igt_crtc_t instead
of enum pipe. These specific tests already track crtcs
alongside pipes (both in arrays) in their data structure.
Remove the redundant pipe information and just rely on the
crtcs.

#include "scripts/iterators.cocci"

@@
igt_display_t DISPLAY;
expression _PIPE;
@@
- &DISPLAY.crtcs[_PIPE]
+ igt_crtc_for_pipe(&DISPLAY, _PIPE)

@@
igt_display_t *DISPLAY;
expression _PIPE;
@@
- &DISPLAY->crtcs[_PIPE]
+ igt_crtc_for_pipe(DISPLAY, _PIPE)

@find_data@
typedef igt_crtc_t;
typedef igt_display_t;
identifier DISPLAY, PIPE, CRTC;
type T;
@@
(
T {
...
igt_display_t DISPLAY;
...
igt_crtc_t *CRTC[...];
...
- enum pipe PIPE[...];
...
};
|
T {
...
- enum pipe PIPE[...];
...
igt_display_t DISPLAY;
...
igt_crtc_t *CRTC[...];
...
};
)

@depends on find_data@
identifier find_data.PIPE;
identifier find_data.CRTC;
identifier find_data.DISPLAY;
find_data.T S;
find_data.T *P;
expression _PIPE, I;
@@
(
- S.PIPE[I] = _PIPE;
+ S.CRTC[I] = igt_crtc_for_pipe(&S.DISPLAY, _PIPE);
|
- P->PIPE[I] = _PIPE;
+ P->CRTC[I] = igt_crtc_for_pipe(&P->DISPLAY, _PIPE);
)

@depends on find_data@
identifier find_data.PIPE;
identifier find_data.CRTC;
identifier find_data.DISPLAY;
find_data.T S;
find_data.T *P;
expression E;
@@
(
- S.PIPE[I] = E
+ S.CRTC[I] = igt_crtc_for_pipe(&S.DISPLAY, E)
|
- P->PIPE[I] = E
+ P->CRTC[I] = igt_crtc_for_pipe(&P->DISPLAY, E)
|
- igt_crtc_for_pipe(..., S.PIPE[I])
+ S.CRTC[I]
|
- igt_crtc_for_pipe(..., P->PIPE[I])
+ P->CRTC[I]
|
- kmstest_pipe_name(S.PIPE[I])
+ igt_crtc_name(S.CRTC[I])
|
- kmstest_pipe_name(P->PIPE[I])
+ igt_crtc_name(P->CRTC[I])
)

@depends on find_data@
identifier find_data.PIPE;
identifier find_data.CRTC;
find_data.T S;
find_data.T *P;
expression I;
@@
(
- S.PIPE[I]
+ S.CRTC[I]->pipe
|
- P->PIPE[I]
+ P->CRTC[I]->pipe
)

@@
igt_crtc_t *CRTC;
@@
- igt_crtc_for_pipe(..., CRTC->pipe)
+ CRTC

@depends on find_data@
identifier find_data.CRTC;
find_data.T S;
find_data.T *P;
expression I, E;
@@
(
S.CRTC[I] = E;
...
- S.CRTC[I] = E;
|
P->CRTC[I] = E;
...
- P->CRTC[I] = E;
)

@depends on find_data@
identifier find_data.CRTC;
find_data.T S;
find_data.T *P;
igt_crtc_t *C;
@@
(
S.CRTC[C->pipe] = ...;
|
P->CRTC[C->pipe] = ...;
|
- S.CRTC[C->pipe]
+ C
|
- P->CRTC[C->pipe]
+ C
)

@@
typedef igt_display_t;
identifier DISPLAY;
@@
- igt_display_t *DISPLAY = ...;
... when != DISPLAY

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
tests/amdgpu/amd_dp_dsc.c | 12 +++++-------
tests/amdgpu/amd_hotplug.c | 4 +---
tests/amdgpu/amd_plane.c | 14 ++++++--------
tests/amdgpu/amd_subvp.c | 4 +---
tests/kms_bw.c | 2 --
5 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/tests/amdgpu/amd_dp_dsc.c b/tests/amdgpu/amd_dp_dsc.c
index d02d66def18a..4403f9205d83 100644
--- a/tests/amdgpu/amd_dp_dsc.c
+++ b/tests/amdgpu/amd_dp_dsc.c
@@ -39,7 +39,6 @@ typedef struct data {
igt_crtc_t *crtc[MAX_PIPES];
igt_pipe_crc_t *pipe_crc[MAX_PIPES];
drmModeModeInfo mode[MAX_PIPES];
- enum pipe pipe_id[MAX_PIPES];
int fd;
} data_t;

@@ -65,7 +64,6 @@ static void test_init(data_t *data)
int i, n;

for_each_crtc(display, crtc) {
- data->pipe_id[crtc->pipe] = crtc->pipe;
data->crtc[crtc->pipe] = crtc;
data->primary[crtc->pipe] = igt_crtc_get_plane_type(crtc,
DRM_PLANE_TYPE_PRIMARY);
@@ -135,7 +133,7 @@ static void test_dsc_enable(data_t *data)
0,
&ref_fb);
igt_output_set_crtc(output,
- igt_crtc_for_pipe(display, data->pipe_id[crtc->pipe]));
+ crtc);
igt_plane_set_fb(data->primary[crtc->pipe], &ref_fb);
igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, 0);

@@ -283,7 +281,7 @@ static void test_dsc_slice_dimensions_change(data_t *data)
0,
&ref_fb);
igt_output_set_crtc(output,
- igt_crtc_for_pipe(display, data->pipe_id[crtc->pipe]));
+ crtc);
igt_plane_set_fb(data->primary[crtc->pipe], &ref_fb);
igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, 0);

@@ -379,7 +377,7 @@ static void test_dsc_link_settings(data_t *data)
0,
&ref_fb[crtc->pipe]);
igt_output_set_crtc(output,
- igt_crtc_for_pipe(display, data->pipe_id[crtc->pipe]));
+ crtc);
igt_plane_set_fb(data->primary[crtc->pipe],
&ref_fb[crtc->pipe]);
}
@@ -506,7 +504,7 @@ static void test_dsc_bpc(data_t *data)
0,
&ref_fb[crtc->pipe]);
igt_output_set_crtc(output,
- igt_crtc_for_pipe(display, data->pipe_id[crtc->pipe]));
+ crtc);
igt_plane_set_fb(data->primary[crtc->pipe],
&ref_fb[crtc->pipe]);
}
@@ -529,7 +527,7 @@ static void test_dsc_bpc(data_t *data)
/* Check current bpc */
igt_info("Verifying display %s has correct bpc\n", output->name);
igt_assert_output_bpc_equal(data->fd,
- data->pipe_id[crtc->pipe],
+ crtc->pipe,
output->name,
bpc_vals[bpc]);

diff --git a/tests/amdgpu/amd_hotplug.c b/tests/amdgpu/amd_hotplug.c
index eff4ec42de00..15092cc9fdec 100644
--- a/tests/amdgpu/amd_hotplug.c
+++ b/tests/amdgpu/amd_hotplug.c
@@ -42,7 +42,6 @@ typedef struct data {
igt_crtc_t *crtc[MAX_PIPES];
igt_pipe_crc_t *pipe_crc[MAX_PIPES];
drmModeModeInfo mode[MAX_PIPES];
- enum pipe pipe_id[MAX_PIPES];
int w[MAX_PIPES];
int h[MAX_PIPES];
int fd;
@@ -55,7 +54,6 @@ static void test_init(data_t *data)
igt_crtc_t *crtc;

for_each_crtc(display, crtc) {
- data->pipe_id[crtc->pipe] = crtc->pipe;
data->crtc[crtc->pipe] = crtc;
data->primary[crtc->pipe] = igt_crtc_get_plane_type(crtc,
DRM_PLANE_TYPE_PRIMARY);
@@ -165,7 +163,7 @@ static void test_hotplug_basic(data_t *data, bool suspend)
DRM_FORMAT_XRGB8888, 0,
&ref_fb[crtc->pipe]);
igt_output_set_crtc(output,
- igt_crtc_for_pipe(display, data->pipe_id[crtc->pipe]));
+ crtc);
igt_plane_set_fb(data->primary[crtc->pipe],
&ref_fb[crtc->pipe]);
}
diff --git a/tests/amdgpu/amd_plane.c b/tests/amdgpu/amd_plane.c
index 296deb898e1d..6831fc43e4a6 100644
--- a/tests/amdgpu/amd_plane.c
+++ b/tests/amdgpu/amd_plane.c
@@ -47,7 +47,6 @@ typedef struct data {
igt_crtc_t *crtc[MAX_PIPES];
igt_pipe_crc_t *pipe_crc[MAX_PIPES];
drmModeModeInfo mode[MAX_PIPES];
- enum pipe pipe_id[MAX_PIPES];
int w[MAX_PIPES];
int h[MAX_PIPES];
int fd;
@@ -156,7 +155,6 @@ static void test_init(data_t *data)
igt_crtc_t *crtc;

for_each_crtc(display, crtc) {
- data->pipe_id[crtc->pipe] = crtc->pipe;
data->crtc[crtc->pipe] = crtc;
data->primary[crtc->pipe] = igt_crtc_get_plane_type(crtc,
DRM_PLANE_TYPE_PRIMARY);
@@ -570,7 +568,7 @@ static void test_multi_mpo_invalid(data_t *data)
igt_skip_on(!data->overlay2[0]);

igt_output_set_crtc(data->output[0],
- igt_crtc_for_pipe(display, data->pipe_id[0]));
+ data->crtc[0]);

igt_create_color_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, 1.0, 1.0, 1.0, &fb[0].test_primary);
igt_create_fb(data->fd, w, h, DRM_FORMAT_NV12, 0, &fb[0].test_overlay);
@@ -647,7 +645,7 @@ static void test_display_mpo(data_t *data, enum test test, uint32_t format, int
}

igt_output_set_crtc(data->output[n],
- igt_crtc_for_pipe(display, data->pipe_id[n]));
+ data->crtc[n]);

igt_create_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, &fb[n].ref_primary);
igt_create_color_fb(data->fd, w, h, DRM_FORMAT_XRGB8888, 0, 1.0, 1.0, 1.0, &fb[n].ref_primary);
@@ -735,7 +733,7 @@ static void test_mpo_4k(data_t *data)
0.00, 0.00, 0.00, 0.00);

igt_output_set_crtc(data->output[0],
- igt_crtc_for_pipe(display, data->pipe_id[0]));
+ data->crtc[0]);
igt_plane_set_fb(data->primary[0], &r_fb);
igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);

@@ -801,9 +799,9 @@ static void test_mpo_swizzle_toggle_multihead(data_t *data)

/* Initial modeset */
igt_output_set_crtc(data->output[0],
- igt_crtc_for_pipe(display, data->pipe_id[0]));
+ data->crtc[0]);
igt_output_set_crtc(data->output[1],
- igt_crtc_for_pipe(display, data->pipe_id[1]));
+ data->crtc[1]);
force_output_mode(data, data->output[0], &test_mode_1);
force_output_mode(data, data->output[1], &test_mode_2);

@@ -872,7 +870,7 @@ static void test_mpo_swizzle_toggle(data_t *data)

/* Initial modeset */
igt_output_set_crtc(data->output[0],
- igt_crtc_for_pipe(display, data->pipe_id[0]));
+ data->crtc[0]);
force_output_mode(data, data->output[0], &test_mode_1);

igt_plane_set_fb(data->primary[0], &fb_1920_xb24_linear);
diff --git a/tests/amdgpu/amd_subvp.c b/tests/amdgpu/amd_subvp.c
index 6249490a4e5e..37879d167e08 100644
--- a/tests/amdgpu/amd_subvp.c
+++ b/tests/amdgpu/amd_subvp.c
@@ -19,7 +19,6 @@ struct data {
igt_crtc_t *crtc[IGT_MAX_PIPES];
igt_pipe_crc_t *pipe_crc[IGT_MAX_PIPES];
drmModeModeInfo mode[IGT_MAX_PIPES];
- enum pipe pipe_id[IGT_MAX_PIPES];
int fd;
};

@@ -65,7 +64,6 @@ static void test_init(struct data *data)
bool subvp_en = false;

for_each_crtc(display, crtc) {
- data->pipe_id[crtc->pipe] = crtc->pipe;
data->crtc[crtc->pipe] = crtc;
data->primary[crtc->pipe] = igt_crtc_get_plane_type(crtc,
DRM_PLANE_TYPE_PRIMARY);
@@ -141,7 +139,7 @@ static void test_subvp(struct data *data)
&rfb);

igt_output_set_crtc(output,
- igt_crtc_for_pipe(display, data->pipe_id[crtc->pipe]));
+ crtc);
igt_plane_set_fb(data->primary[crtc->pipe], &rfb);
igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, 0);
}
diff --git a/tests/kms_bw.c b/tests/kms_bw.c
index 11f055b23464..778900d8c9f1 100644
--- a/tests/kms_bw.c
+++ b/tests/kms_bw.c
@@ -70,7 +70,6 @@ typedef struct data {
igt_crtc_t *crtc[IGT_MAX_PIPES];
igt_pipe_crc_t *pipe_crc[IGT_MAX_PIPES];
drmModeModeInfo mode[IGT_MAX_PIPES];
- enum pipe pipe_id[IGT_MAX_PIPES];
int w[IGT_MAX_PIPES];
int h[IGT_MAX_PIPES];
int fd;
@@ -126,7 +125,6 @@ static void test_init(data_t *data, bool physical)
data->connected_outputs = 0;

for_each_crtc(display, crtc) {
- data->pipe_id[crtc->pipe] = crtc->pipe;
data->crtc[crtc->pipe] = crtc;
data->primary[crtc->pipe] = igt_crtc_get_plane_type(crtc,
DRM_PLANE_TYPE_PRIMARY);
--
2.52.0