[PATCH i-g-t 12/17] tests/intel/kms_pipe_b_c_ivb: Use igt_crtc_t instead of enum pipe

Ville Syrjala
2026-02-11T16:35:06Z

tests/intel/kms_pipe_b_c_ivb.

This test wants to specifically use pipes B and C,
thus we are left with a few igt_crtc_for_pipe()
calls even after the conversion.

#include "scripts/iterators.cocci"

@func1@
typedef igt_crtc_t;
identifier FUNC, PIPE, CRTC;
parameter list[N] P;
@@
FUNC(P
- ,enum pipe PIPE
+ ,igt_crtc_t *CRTC
,...)
{
...
(
- igt_crtc_t *CRTC = igt_crtc_for_pipe(..., PIPE);
|
- igt_crtc_t *CRTC;
... when != PIPE = ...
- CRTC = igt_crtc_for_pipe(..., PIPE);
)
<... when != PIPE = ...
(
- igt_crtc_for_pipe(..., PIPE)
+ CRTC
|
- kmsetst_crtc_name(PIPE)
+ igt_crtc_name(CRTC)
|
- PIPE
+ CRTC->pipe
)
...>
}

@depends on func1@
identifier func1.FUNC;
expression list[func1.N] EP;
expression PIPE;
@@
FUNC(EP
- ,PIPE
+ ,igt_crtc_for_pipe(&data->display, PIPE)
,...)

@func2@
typedef igt_crtc_t;
identifier FUNC, PIPE;
parameter list[N] P;
@@
FUNC(P
- ,enum pipe PIPE
+ ,igt_crtc_t *crtc
,...)
{
<+... when != PIPE = ...
(
- igt_crtc_for_pipe(..., PIPE)
+ crtc
|
- kmsetst_crtc_name(PIPE)
+ igt_crtc_name(crtc)
|
- PIPE
+ crtc->pipe
)
...+>
}

@depends on func2@
identifier func2.FUNC;
expression list[func2.N] EP;
expression PIPE;
@@
FUNC(EP
- ,PIPE
+ ,igt_crtc_for_pipe(&data->display, PIPE)
,...)

@@
identifier FUNC;
expression DISPLAY;
@@
FUNC(...)
{
+ igt_crtc_t *crtc_b = igt_crtc_for_pipe(DISPLAY, PIPE_B);
+ igt_crtc_t *crtc_c = igt_crtc_for_pipe(DISPLAY, PIPE_C);
<+...
(
- igt_crtc_for_pipe(DISPLAY, PIPE_B)
+ crtc_b
|
- igt_crtc_for_pipe(DISPLAY, PIPE_C)
+ crtc_c
)
...+>
}

@@
identifier CRTC;
expression PIPE;
@@
igt_crtc_t *CRTC = igt_crtc_for_pipe(..., PIPE);
<+...
(
- kmstest_pipe_name(PIPE)
+ igt_crtc_name(CRTC)
|
- PIPE
+ CRTC->pipe
)
...+>

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

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

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
tests/intel/kms_pipe_b_c_ivb.c | 102 ++++++++++++++++++++++-----------
1 file changed, 68 insertions(+), 34 deletions(-)

diff --git a/tests/intel/kms_pipe_b_c_ivb.c b/tests/intel/kms_pipe_b_c_ivb.c
index 184d3b38fee7..d5c1ab3ff758 100644
--- a/tests/intel/kms_pipe_b_c_ivb.c
+++ b/tests/intel/kms_pipe_b_c_ivb.c
@@ -98,10 +98,8 @@ drmModeModeInfo mode_2_lanes = {
};

static int
-disable_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+disable_pipe(data_t *data, igt_crtc_t *crtc, igt_output_t *output)
{
- igt_display_t *display = &data->display;
- igt_crtc_t *crtc = igt_crtc_for_pipe(display, pipe);
igt_plane_t *primary;

igt_output_set_crtc(output, crtc);
@@ -111,10 +109,8 @@ disable_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
}

static int
-set_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+set_mode_on_pipe(data_t *data, igt_crtc_t *crtc, igt_output_t *output)
{
- igt_display_t *display = &data->display;
- igt_crtc_t *crtc = igt_crtc_for_pipe(display, pipe);
igt_plane_t *primary;
drmModeModeInfo *mode;
struct igt_fb fb;
@@ -137,17 +133,19 @@ set_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
}

static int
-set_big_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+set_big_mode_on_pipe(data_t *data, igt_crtc_t *crtc, igt_output_t *output)
{
igt_output_override_mode(output, &mode_3_lanes);
- return set_mode_on_pipe(data, pipe, output);
+ return set_mode_on_pipe(data, crtc,
+ output);
}

static int
-set_normal_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+set_normal_mode_on_pipe(data_t *data, igt_crtc_t *crtc, igt_output_t *output)
{
igt_output_override_mode(output, &mode_2_lanes);
- return set_mode_on_pipe(data, pipe, output);
+ return set_mode_on_pipe(data, crtc,
+ output);
}

static void
@@ -175,6 +173,8 @@ find_outputs(data_t *data, igt_output_t **output1, igt_output_t **output2)
static void
test_dpms(data_t *data)
{
+ igt_crtc_t *crtc_b = igt_crtc_for_pipe(&data->display, PIPE_B);
+ igt_crtc_t *crtc_c = igt_crtc_for_pipe(&data->display, PIPE_C);
igt_output_t *output1, *output2;
int ret;

@@ -182,22 +182,28 @@ test_dpms(data_t *data)
find_outputs(data, &output1, &output2);

igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+ igt_crtc_name(crtc_b), igt_output_name(output1));
igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+ igt_crtc_name(crtc_c), igt_output_name(output2));

- ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+ ret = set_big_mode_on_pipe(data,
+ crtc_b,
+ output1);
igt_assert_eq(ret, 0);

kmstest_set_connector_dpms(data->drm_fd, output1->config.connector, DRM_MODE_DPMS_OFF);

- ret = set_big_mode_on_pipe(data, PIPE_C, output2);
+ ret = set_big_mode_on_pipe(data,
+ crtc_c,
+ output2);
igt_assert_neq(ret, 0);
}

static void
test_lane_reduction(data_t *data)
{
+ igt_crtc_t *crtc_b = igt_crtc_for_pipe(&data->display, PIPE_B);
+ igt_crtc_t *crtc_c = igt_crtc_for_pipe(&data->display, PIPE_C);
igt_output_t *output1, *output2;
int ret;

@@ -206,23 +212,31 @@ test_lane_reduction(data_t *data)
find_outputs(data, &output1, &output2);

igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+ igt_crtc_name(crtc_b), igt_output_name(output1));
igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+ igt_crtc_name(crtc_c), igt_output_name(output2));

- ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+ ret = set_big_mode_on_pipe(data,
+ crtc_b,
+ output1);
igt_assert_eq(ret, 0);

- ret = set_normal_mode_on_pipe(data, PIPE_B, output1);
+ ret = set_normal_mode_on_pipe(data,
+ crtc_b,
+ output1);
igt_assert_eq(ret, 0);

- ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+ ret = set_normal_mode_on_pipe(data,
+ crtc_c,
+ output2);
igt_assert_eq(ret, 0);
}

static void
test_disable_pipe_B(data_t *data)
{
+ igt_crtc_t *crtc_b = igt_crtc_for_pipe(&data->display, PIPE_B);
+ igt_crtc_t *crtc_c = igt_crtc_for_pipe(&data->display, PIPE_C);
igt_output_t *output1, *output2;
int ret;

@@ -230,26 +244,35 @@ test_disable_pipe_B(data_t *data)
find_outputs(data, &output1, &output2);

igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+ igt_crtc_name(crtc_b), igt_output_name(output1));
igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+ igt_crtc_name(crtc_c), igt_output_name(output2));

- ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+ ret = set_big_mode_on_pipe(data,
+ crtc_b,
+ output1);
igt_assert_eq(ret, 0);

- ret = disable_pipe(data, PIPE_B, output1);
+ ret = disable_pipe(data, crtc_b,
+ output1);
igt_assert_eq(ret, 0);

- ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+ ret = set_normal_mode_on_pipe(data,
+ crtc_c,
+ output2);
igt_assert_eq(ret, 0);

- ret = set_normal_mode_on_pipe(data, PIPE_B, output1);
+ ret = set_normal_mode_on_pipe(data,
+ crtc_b,
+ output1);
igt_assert_eq(ret, 0);
}

static void
test_from_C_to_B_with_3_lanes(data_t *data)
{
+ igt_crtc_t *crtc_b = igt_crtc_for_pipe(&data->display, PIPE_B);
+ igt_crtc_t *crtc_c = igt_crtc_for_pipe(&data->display, PIPE_C);
igt_output_t *output1, *output2;
int ret;

@@ -257,23 +280,30 @@ test_from_C_to_B_with_3_lanes(data_t *data)
find_outputs(data, &output1, &output2);

igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+ igt_crtc_name(crtc_b), igt_output_name(output1));
igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+ igt_crtc_name(crtc_c), igt_output_name(output2));

- ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+ ret = set_normal_mode_on_pipe(data,
+ crtc_c,
+ output2);
igt_assert_eq(ret, 0);

- ret = disable_pipe(data, PIPE_C, output2);
+ ret = disable_pipe(data, crtc_c,
+ output2);
igt_assert_eq(ret, 0);

- ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+ ret = set_big_mode_on_pipe(data,
+ crtc_b,
+ output1);
igt_assert_eq(ret, 0);
}

static void
test_fail_enable_pipe_C_while_B_has_3_lanes(data_t *data)
{
+ igt_crtc_t *crtc_b = igt_crtc_for_pipe(&data->display, PIPE_B);
+ igt_crtc_t *crtc_c = igt_crtc_for_pipe(&data->display, PIPE_C);
igt_output_t *output1, *output2;
int ret;

@@ -281,14 +311,18 @@ test_fail_enable_pipe_C_while_B_has_3_lanes(data_t *data)
find_outputs(data, &output1, &output2);

igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_B), igt_output_name(output1));
+ igt_crtc_name(crtc_b), igt_output_name(output1));
igt_info("Pipe %s will use connector %s\n",
- kmstest_pipe_name(PIPE_C), igt_output_name(output2));
+ igt_crtc_name(crtc_c), igt_output_name(output2));

- ret = set_big_mode_on_pipe(data, PIPE_B, output1);
+ ret = set_big_mode_on_pipe(data,
+ crtc_b,
+ output1);
igt_assert_eq(ret, 0);

- ret = set_normal_mode_on_pipe(data, PIPE_C, output2);
+ ret = set_normal_mode_on_pipe(data,
+ crtc_c,
+ output2);
igt_assert_neq(ret, 0);
}

--
2.52.0