[PATCH i-g-t 17/21] tests/chamelium: Use igt_crtc_t instead of enum pipe

Ville Syrjala
2026-02-20T14:03:12Z

Convert the remaining chamelium tests to use igt_crtc_t
instead of enum pipe. Here we specifically deal with changing
the return type of chamelium_get_pipe_for_output().

The mess inside test_hotplug() proved difficult for cocci,
so there is some special sauce for that in the semantic
patch.

#include "scripts/iterators.cocci"

@ret_pipe@
typedef igt_output_t;
typedef igt_crtc_t;
identifier FUNC;
igt_crtc_t *CRTC;
parameter list[N] P;
@@
- enum pipe
+ igt_crtc_t *
FUNC(P)
{
<...
- return CRTC->pipe;
+ return CRTC;
...>
}

@depends on ret_pipe@
identifier ret_pipe.FUNC;
@@
- enum pipe
+ igt_crtc_t *
FUNC(...);

@depends on ret_pipe@
identifier ret_pipe.FUNC;
@@
FUNC(...)
+ ->pipe

@depends on ret_pipe@
identifier ret_pipe.FUNC, PIPE;
expression list[ret_pipe.N] EP;
@@
{ ...
enum pipe PIPE;
+ igt_crtc_t *crtc;
<+... when != PIPE = ...
- PIPE = FUNC(EP)->pipe;
+ crtc = FUNC(EP);
+ PIPE = crtc->pipe;
...+>
}

@depends on ret_pipe@
identifier ret_pipe.FUNC;
expression list[ret_pipe.N] EP;
@@
- igt_crtc_for_pipe(..., FUNC(EP)->pipe)
+ FUNC(EP)

@@
identifier PIPE;
igt_crtc_t *CRTC;
@@
{...
if (...) {
...
- PIPE = CRTC->pipe;
...
}
<+... when != PIPE = ...
- PIPE
+ CRTC->pipe
...+>
}

@@
identifier PIPE;
igt_crtc_t *CRTC;
@@
{...
- PIPE = CRTC->pipe;
<+... when != PIPE = ...
- PIPE
+ CRTC->pipe
...+>
}

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

@@
identifier PIPE;
@@
{...
- enum pipe PIPE;
... when != PIPE
}

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

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
tests/chamelium/kms_chamelium_edid.c | 13 +++++++------
tests/chamelium/kms_chamelium_helper.c | 10 +++++-----
tests/chamelium/kms_chamelium_helper.h | 2 +-
tests/chamelium/kms_chamelium_hpd.c | 8 ++++----
4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/tests/chamelium/kms_chamelium_edid.c b/tests/chamelium/kms_chamelium_edid.c
index f5647dde0d9d..e014ba3aa873 100644
--- a/tests/chamelium/kms_chamelium_edid.c
+++ b/tests/chamelium/kms_chamelium_edid.c
@@ -287,7 +287,7 @@ static void edid_stress_resolution(chamelium_data_t *data,
drmModeModeInfo mode;
struct igt_fb fb = { 0 };
igt_output_t *output;
- enum pipe pipe;
+ igt_crtc_t *crtc;
bool is_video_stable;
int screen_res_w, screen_res_h;

@@ -311,9 +311,9 @@ static void edid_stress_resolution(chamelium_data_t *data,
mode = chamelium_get_mode_for_port(chamelium, port);
chamelium_create_fb_for_mode(data, &fb, &mode);
output = chamelium_get_output_for_port(data, port);
- pipe = chamelium_get_pipe_for_output(&data->display, output);
+ crtc = chamelium_get_pipe_for_output(&data->display, output);
igt_output_set_crtc(output,
- igt_crtc_for_pipe(output->display, pipe));
+ crtc);
chamelium_enable_output(data, port, output, &mode, &fb);

/* Capture the screen resolution and verify. */
@@ -350,7 +350,7 @@ static void edid_resolution_list(chamelium_data_t *data,
int count_modes;
int i;
igt_output_t *output;
- enum pipe pipe;
+ igt_crtc_t *crtc;

chamelium_unplug(chamelium, port);
chamelium_set_edid(data, port, IGT_CUSTOM_EDID_FULL);
@@ -366,8 +366,9 @@ static void edid_resolution_list(chamelium_data_t *data,
count_modes = connector->count_modes;

output = chamelium_get_output_for_port(data, port);
- pipe = chamelium_get_pipe_for_output(&data->display, output);
- igt_output_set_crtc(output, igt_crtc_for_pipe(output->display, pipe));
+ crtc = chamelium_get_pipe_for_output(&data->display, output);
+ igt_output_set_crtc(output,
+ crtc);

for (i = 0; i < count_modes; ++i)
igt_debug("#%d %s %uHz\n", i, modes[i].name, modes[i].vrefresh);
diff --git a/tests/chamelium/kms_chamelium_helper.c b/tests/chamelium/kms_chamelium_helper.c
index c15a3096c5fe..ea30ff42d9a9 100644
--- a/tests/chamelium/kms_chamelium_helper.c
+++ b/tests/chamelium/kms_chamelium_helper.c
@@ -133,7 +133,7 @@ igt_output_t *chamelium_prepare_output(chamelium_data_t *data,
{
igt_display_t *display = &data->display;
igt_output_t *output;
- enum pipe pipe;
+ igt_crtc_t *crtc;

/* The chamelium's default EDID has a lot of resolutions, way more then
* we need to test. Additionally the default EDID doesn't support HDMI
@@ -152,8 +152,8 @@ igt_output_t *chamelium_prepare_output(chamelium_data_t *data,
/* Refresh pipe to update connected status */
igt_output_set_crtc(output, NULL);

- pipe = chamelium_get_pipe_for_output(display, output);
- igt_output_set_crtc(output, igt_crtc_for_pipe(display, pipe));
+ crtc = chamelium_get_pipe_for_output(display, output);
+ igt_output_set_crtc(output, crtc);

return output;
}
@@ -201,7 +201,7 @@ void chamelium_enable_output(chamelium_data_t *data,
}

/* Return pipe attached to @outpu.t */
-enum pipe chamelium_get_pipe_for_output(igt_display_t *display,
+igt_crtc_t * chamelium_get_pipe_for_output(igt_display_t *display,
igt_output_t *output)
{
igt_crtc_t *crtc;
@@ -216,7 +216,7 @@ enum pipe chamelium_get_pipe_for_output(igt_display_t *display,
}

igt_output_set_crtc(output, NULL);
- return crtc->pipe;
+ return crtc;
}

igt_assert_f(false, "No pipe found for output %s\n",
diff --git a/tests/chamelium/kms_chamelium_helper.h b/tests/chamelium/kms_chamelium_helper.h
index 7941ca9d3139..6060796661c4 100644
--- a/tests/chamelium/kms_chamelium_helper.h
+++ b/tests/chamelium/kms_chamelium_helper.h
@@ -97,7 +97,7 @@ igt_output_t *chamelium_prepare_output(chamelium_data_t *data,
void chamelium_enable_output(chamelium_data_t *data,
struct chamelium_port *port, igt_output_t *output,
drmModeModeInfo *mode, struct igt_fb *fb);
-enum pipe chamelium_get_pipe_for_output(igt_display_t *display,
+igt_crtc_t * chamelium_get_pipe_for_output(igt_display_t *display,
igt_output_t *output);

int chamelium_get_pattern_fb(chamelium_data_t *data, size_t width,
diff --git a/tests/chamelium/kms_chamelium_hpd.c b/tests/chamelium/kms_chamelium_hpd.c
index 29028ce6f7da..bd8731c0216b 100644
--- a/tests/chamelium/kms_chamelium_hpd.c
+++ b/tests/chamelium/kms_chamelium_hpd.c
@@ -230,7 +230,7 @@ static void test_hotplug(chamelium_data_t *data, struct chamelium_port *port,
int toggle_count, enum test_modeset_mode modeset_mode)
{
int i;
- enum pipe pipe;
+ igt_crtc_t *crtc;
struct igt_fb fb = { 0 };
drmModeModeInfo mode;
struct udev_monitor *mon = igt_watch_uevents();
@@ -259,15 +259,15 @@ static void test_hotplug(chamelium_data_t *data, struct chamelium_port *port,
* connected */
output = chamelium_get_output_for_port(data,
port);
- pipe = chamelium_get_pipe_for_output(
- &data->display, output);
+ crtc = chamelium_get_pipe_for_output(&data->display,
+ output);
mode = chamelium_get_mode_for_port(
data->chamelium, port);
chamelium_create_fb_for_mode(data, &fb, &mode);
}

igt_output_set_crtc(output,
- igt_crtc_for_pipe(output->display, pipe));
+ crtc);
chamelium_enable_output(data, port, output, &mode, &fb);
}

--
2.52.0