public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t 04/19] tests/kms: Consolidate igt_crtc_for_pipe() calls
Date: Wed, 25 Feb 2026 14:50:53 +0200	[thread overview]
Message-ID: <20260225125108.31119-5-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20260225125108.31119-1-ville.syrjala@linux.intel.com>

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

Several tests have igt_crtc_for_pipe() calls sprinkled all over
the place. Consolidate them better, and assign each to local
variable, to better see what's actually going on.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/amdgpu/amd_mode_switch.c          |  5 +++--
 tests/amdgpu/amd_multidisplay_modeset.c |  7 +++++--
 tests/amdgpu/amd_odm.c                  |  4 +---
 tests/intel/gem_eio.c                   | 11 ++++++----
 tests/intel/gem_exec_reloc.c            |  9 ++++++---
 tests/intel/kms_cdclk.c                 | 11 +++++-----
 tests/intel/kms_pipe_stress.c           | 27 ++++++++++++++-----------
 tests/kms_bw.c                          |  5 +++--
 tests/kms_rotation_crc.c                | 15 ++++++++------
 9 files changed, 54 insertions(+), 40 deletions(-)

diff --git a/tests/amdgpu/amd_mode_switch.c b/tests/amdgpu/amd_mode_switch.c
index 98e1fc06ce08..4da07c412996 100644
--- a/tests/amdgpu/amd_mode_switch.c
+++ b/tests/amdgpu/amd_mode_switch.c
@@ -96,6 +96,8 @@ static void run_mode_switch_first_last(data_t *data, int num_pipes)
 	/* First supported mode */
 
 	for (j = 0; j < num_pipes; j++) {
+		igt_crtc_t *crtc = igt_crtc_for_pipe(display, j);
+
 		output = data->output[j];
 		if (!igt_output_is_connected(output))
 			continue;
@@ -113,8 +115,7 @@ static void run_mode_switch_first_last(data_t *data, int num_pipes)
 					    DRM_FORMAT_MOD_NONE, 1.f, 0.f,
 					    0.f, buffer1[j]);
 		}
-		igt_output_set_crtc(output,
-				    igt_crtc_for_pipe(display, j));
+		igt_output_set_crtc(output, crtc);
 		force_output_mode(data, output, kmode);
 		igt_plane_set_fb(data->primary[j], buffer1[j]);
 		drmModeFreeConnector(conn);
diff --git a/tests/amdgpu/amd_multidisplay_modeset.c b/tests/amdgpu/amd_multidisplay_modeset.c
index 5eb61b54a43d..a2853e73225a 100644
--- a/tests/amdgpu/amd_multidisplay_modeset.c
+++ b/tests/amdgpu/amd_multidisplay_modeset.c
@@ -279,6 +279,8 @@ static void multiple_display_test(struct data_t *data, enum sub_test test_mode)
 			igt_info("\n\nnmode loop:%d -----\n", i);
 		j = 0;
 		for_each_connected_output(display, output) {
+			igt_crtc_t *crtc;
+
 			if (test_mode == DISPLAY_ENABLE_DISABLE) {
 				/* only enable display mapping to
 				 * bitmap_disps with value 1
@@ -323,12 +325,13 @@ static void multiple_display_test(struct data_t *data, enum sub_test test_mode)
 				igt_output_override_mode(output, kmode);
 			}
 
+			crtc = igt_crtc_for_pipe(display, j);
+
 			igt_create_pattern_fb(data->fd, kmode->hdisplay,
 					kmode->vdisplay, DRM_FORMAT_XRGB8888,
 					0, (buf + j));
 
-			igt_output_set_crtc(output,
-					    igt_crtc_for_pipe(display, j));
+			igt_output_set_crtc(output, crtc);
 			igt_plane_set_fb(data->primary[j], (buf + j));
 			j++;
 		}
diff --git a/tests/amdgpu/amd_odm.c b/tests/amdgpu/amd_odm.c
index 85873880e7a5..ac6b839847a2 100644
--- a/tests/amdgpu/amd_odm.c
+++ b/tests/amdgpu/amd_odm.c
@@ -110,7 +110,6 @@ static void run_test_odmc(struct data *data, enum odmc_mode m, const drmModeMode
 	struct igt_fb buffer;
 	char buf[256];
 	int ret, seg, fd;
-	int i = 0;
 
 	test_init(data);
 
@@ -121,8 +120,7 @@ static void run_test_odmc(struct data *data, enum odmc_mode m, const drmModeMode
 			    DRM_FORMAT_MOD_LINEAR, 1.f, 0.f, 0.f,
 			    &buffer);
 
-	igt_output_set_crtc(data->output,
-			    igt_crtc_for_pipe(display, i));
+	igt_output_set_crtc(data->output, data->crtc);
 
 	igt_plane_set_fb(data->primary, &buffer);
 
diff --git a/tests/intel/gem_eio.c b/tests/intel/gem_eio.c
index 09ea3bf6b8cd..361fd24744c4 100644
--- a/tests/intel/gem_eio.c
+++ b/tests/intel/gem_eio.c
@@ -1032,17 +1032,20 @@ static void display_helper(igt_display_t *dpy, int *done)
 		drmModeModeInfoPtr mode;
 		igt_plane_t *primary;
 		igt_output_t *output;
+		igt_crtc_t *crtc;
 		int pipe;
 
 		pipe = rand() % igt_display_n_crtcs(dpy);
-		if (!igt_crtc_for_pipe(dpy, pipe)->valid)
+
+		crtc = igt_crtc_for_pipe(dpy, pipe);
+		if (!crtc || !crtc->valid)
 			continue;
-		output = igt_get_single_output_for_pipe(dpy, pipe);
+
+		output = igt_get_single_output_for_pipe(dpy, crtc->pipe);
 		if (!output)
 			continue;
 
-		igt_output_set_crtc(output,
-				    igt_crtc_for_pipe(dpy, pipe));
+		igt_output_set_crtc(output, crtc);
 		mode = igt_output_get_mode(output);
 
 		if (fb.width != mode->hdisplay || fb.height != mode->vdisplay) {
diff --git a/tests/intel/gem_exec_reloc.c b/tests/intel/gem_exec_reloc.c
index c2c5765a543f..53d8a1e9aa7e 100644
--- a/tests/intel/gem_exec_reloc.c
+++ b/tests/intel/gem_exec_reloc.c
@@ -1510,15 +1510,18 @@ static void scanout(int i915,
 		.rsvd1 = ctx->id,
 	};
 	igt_output_t *output;
+	igt_crtc_t *crtc;
 	struct igt_fb fb;
 	uint64_t *map;
 
 	igt_display_reset(dpy);
 
-	output = igt_get_single_output_for_pipe(dpy, PIPE_A);
+	crtc = igt_crtc_for_pipe(dpy, PIPE_A);
+
+	output = igt_get_single_output_for_pipe(dpy, crtc->pipe);
 	igt_require(output);
-	igt_output_set_crtc(output,
-			    igt_crtc_for_pipe(dpy, PIPE_A));
+
+	igt_output_set_crtc(output, crtc);
 
 	/*
 	 * Find where the scanout is in our GTT; on !full-ppgtt this will be
diff --git a/tests/intel/kms_cdclk.c b/tests/intel/kms_cdclk.c
index 9f2b81985361..73cb962c0fe9 100644
--- a/tests/intel/kms_cdclk.c
+++ b/tests/intel/kms_cdclk.c
@@ -239,12 +239,10 @@ static void set_mode(data_t *data, int count, drmModeModeInfo *mode,
 		     igt_output_t **valid_outputs, struct igt_fb fb)
 {
 	igt_display_t *display = &data->display;
-	igt_crtc_t *crtc;
-	igt_plane_t *plane;
 
 	for (int i = 0; i < count; i++) {
-		crtc = igt_crtc_for_pipe(display, i);
-		plane = igt_crtc_get_plane_type(crtc, DRM_PLANE_TYPE_PRIMARY);
+		igt_crtc_t *crtc = igt_crtc_for_pipe(display, i);
+		igt_plane_t *plane = igt_crtc_get_plane_type(crtc, DRM_PLANE_TYPE_PRIMARY);
 
 		igt_output_override_mode(valid_outputs[i], &mode[i]);
 
@@ -289,14 +287,15 @@ static void test_mode_transition_on_all_outputs(data_t *data)
 		      "Number of valid outputs (%d) must be greater than or equal to 2\n", count);
 
 	for (int i = 0; i < count; i++) {
+		igt_crtc_t *crtc = igt_crtc_for_pipe(display, i);
+
 		mode = igt_output_get_mode(valid_outputs[i]);
 		igt_assert(mode);
 
 		width = max(width, mode->hdisplay);
 		height = max(height, mode->vdisplay);
 
-		igt_output_set_crtc(valid_outputs[i],
-				    igt_crtc_for_pipe(display, i));
+		igt_output_set_crtc(valid_outputs[i], crtc);
 		igt_output_override_mode(valid_outputs[i], &mode_highres[i]);
 	}
 
diff --git a/tests/intel/kms_pipe_stress.c b/tests/intel/kms_pipe_stress.c
index 7b7a65ff5630..72f8a7be23cc 100644
--- a/tests/intel/kms_pipe_stress.c
+++ b/tests/intel/kms_pipe_stress.c
@@ -594,25 +594,25 @@ static void stress_pipes(struct data *data, struct timespec *start,
 	igt_crc_t crc, crc2;
 
 	for_each_connected_output(&data->display, output) {
+		igt_crtc_t *crtc;
 
 		if (!data->highest_mode[pipe])
 			continue;
 
-		igt_assert_f(igt_crtc_for_pipe(display, pipe)->n_planes < MAX_PLANES,
+		crtc = igt_crtc_for_pipe(display, pipe);
+
+		igt_assert_f(crtc->n_planes < MAX_PLANES,
 			     "Currently we don't support more than %d planes!",
 			     MAX_PLANES);
 
-		ret = pipe_stress(data, output,
-				  igt_crtc_for_pipe(display, pipe),
+		ret = pipe_stress(data, output, crtc,
 				  data->highest_mode[pipe]);
 		if (ret)
 			break;
 
 		igt_pipe_crc_start(data->pipe_crc[pipe]);
 		igt_pipe_crc_get_current(data->display.drm_fd, data->pipe_crc[pipe], &crc);
-		get_vblank(data->display.drm_fd,
-			   igt_crtc_for_pipe(display, pipe),
-			   DRM_VBLANK_NEXTONMISS);
+		get_vblank(data->display.drm_fd, crtc, DRM_VBLANK_NEXTONMISS);
 		igt_pipe_crc_get_current(data->display.drm_fd, data->pipe_crc[pipe], &crc2);
 		igt_pipe_crc_stop(data->pipe_crc[pipe]);
 		igt_assert_crc_equal(&crc, &crc2);
@@ -755,14 +755,16 @@ static void destroy_framebuffers(struct data *data)
 	int i, j;
 
 	for (i = 0; i < IGT_MAX_PIPES; i++) {
+		igt_crtc_t *crtc;
 
 		if (!data->highest_mode[i])
 			continue;
 
+		crtc = igt_crtc_for_pipe(display, i);
+
 		for (j = 0; j < MAX_PLANES; j++) {
 			if (data->fb[i * MAX_PLANES + j].fb_id) {
-				igt_plane_set_fb(&igt_crtc_for_pipe(display, i)->planes[j],
-						 NULL);
+				igt_plane_set_fb(&crtc->planes[j], NULL);
 				igt_remove_fb(data->display.drm_fd, &data->fb[i * MAX_PLANES + j]);
 				data->fb[i * MAX_PLANES + j].fb_id = 0;
 			}
@@ -808,6 +810,7 @@ static void prepare_test(struct data *data)
 
 	for (i = 0; i < IGT_MAX_PIPES; i++) {
 		drmModeConnector *connector = (drmModeConnector *)data->connectors[i];
+		igt_crtc_t *crtc;
 
 		if (!connector)
 			continue;
@@ -818,17 +821,17 @@ static void prepare_test(struct data *data)
 		}
 		igt_assert(data->highest_mode[i]);
 
+		crtc = igt_crtc_for_pipe(display, i);
+
 		if (data->highest_mode[i]) {
 			igt_info("Using mode: \n");
 			kmstest_dump_mode(data->highest_mode[i]);
-			data->pipe_crc[i] = igt_crtc_crc_new(igt_crtc_for_pipe(display, i),
-							     IGT_PIPE_CRC_SOURCE_AUTO);
+			data->pipe_crc[i] = igt_crtc_crc_new(crtc, IGT_PIPE_CRC_SOURCE_AUTO);
 		} else
 			data->pipe_crc[i] = NULL;
 
 		if (data->num_planes[i] == -1)
-			data->num_planes[i] = igt_crtc_for_pipe(display,
-								i)->n_planes;
+			data->num_planes[i] = crtc->n_planes;
 
 		igt_info("Max number of planes is %d for pipe %d\n",
 			 data->num_planes[i], i);
diff --git a/tests/kms_bw.c b/tests/kms_bw.c
index 778900d8c9f1..690e28958b38 100644
--- a/tests/kms_bw.c
+++ b/tests/kms_bw.c
@@ -210,6 +210,8 @@ static void run_test_linear_tiling(data_t *data, int pipe, const drmModeModeInfo
 
 	/* create buffers */
 	for (i = 0; i <= pipe; i++) {
+		crtc = igt_crtc_for_pipe(display, i);
+
 		output = physical ? data->connected_output[i] : data->output[i];
 		if (!output) {
 			continue;
@@ -222,8 +224,7 @@ static void run_test_linear_tiling(data_t *data, int pipe, const drmModeModeInfo
 				    DRM_FORMAT_MOD_LINEAR, 1.f, 0.f, 0.f,
 				    &buffer[i]);
 
-		igt_output_set_crtc(output,
-				    igt_crtc_for_pipe(display, i));
+		igt_output_set_crtc(output, crtc);
 
 		igt_plane_set_fb(data->primary[i], &buffer[i]);
 		igt_info("Assigning pipe %s to output %s with mode %s\n",
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index cd0873b3bf8d..6240e112cb29 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -1314,6 +1314,8 @@ int igt_main_args("", long_opts, help_str, opt_handler, &data)
 
 	igt_describe("Rotation test on both planes by making them fully visible");
 	igt_subtest_f("multiplane-rotation") {
+		igt_crtc_t *crtc = igt_crtc_for_pipe(&data.display, PIPE_A);
+
 		igt_require(gen >= 9);
 		cleanup_crtc(&data);
 		data.planepos[0].origo = p_top | p_left;
@@ -1322,13 +1324,14 @@ int igt_main_args("", long_opts, help_str, opt_handler, &data)
 		data.planepos[1].origo = p_top | p_right;
 		data.planepos[1].x = -.4f;
 		data.planepos[1].y = .1f;
-		test_multi_plane_rotation(&data,
-					  igt_crtc_for_pipe(&data.display, PIPE_A));
+		test_multi_plane_rotation(&data, crtc);
 	}
 
 	igt_describe("Rotation test on both planes by cropping left/top corner of primary plane and"
 			"right/top corner of sprite plane");
 	igt_subtest_f("multiplane-rotation-cropping-top") {
+		igt_crtc_t *crtc = igt_crtc_for_pipe(&data.display, PIPE_A);
+
 		igt_require(gen >= 9);
 		cleanup_crtc(&data);
 		data.planepos[0].origo = p_top | p_left;
@@ -1337,13 +1340,14 @@ int igt_main_args("", long_opts, help_str, opt_handler, &data)
 		data.planepos[1].origo = p_top | p_right;
 		data.planepos[1].x = -.15f;
 		data.planepos[1].y = -.15f;
-		test_multi_plane_rotation(&data,
-					  igt_crtc_for_pipe(&data.display, PIPE_A));
+		test_multi_plane_rotation(&data, crtc);
 	}
 
 	igt_describe("Rotation test on both planes by cropping left/bottom corner of primary plane"
 			"and right/bottom corner of sprite plane");
 	igt_subtest_f("multiplane-rotation-cropping-bottom") {
+		igt_crtc_t *crtc = igt_crtc_for_pipe(&data.display, PIPE_A);
+
 		igt_require(gen >= 9);
 		cleanup_crtc(&data);
 		data.planepos[0].origo = p_bottom | p_left;
@@ -1352,8 +1356,7 @@ int igt_main_args("", long_opts, help_str, opt_handler, &data)
 		data.planepos[1].origo = p_bottom | p_right;
 		data.planepos[1].x = -.15f;
 		data.planepos[1].y = -.20f;
-		test_multi_plane_rotation(&data,
-					  igt_crtc_for_pipe(&data.display, PIPE_A));
+		test_multi_plane_rotation(&data, crtc);
 	}
 
 	/*
-- 
2.52.0


  parent reply	other threads:[~2026-02-25 12:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 12:50 [PATCH i-g-t 00/19] lib/kms: Clean up more of igt_kms API Ville Syrjala
2026-02-25 12:50 ` [PATCH i-g-t 01/19] tests/kms_plane_multiple: Clean up n_planes stuff Ville Syrjala
2026-02-25 12:50 ` [PATCH i-g-t 02/19] tests/kms_async_flips: Remove redundant data.crtc_id Ville Syrjala
2026-02-25 13:58   ` Jani Nikula
2026-02-25 12:50 ` [PATCH i-g-t 03/19] tests/kms_lease: Consolidate igt_crtc_for_pipe() calls Ville Syrjala
2026-02-25 12:50 ` Ville Syrjala [this message]
2026-02-25 12:50 ` [PATCH i-g-t 05/19] lib/kms: Introduce igt_first_crtc_with_single_output() Ville Syrjala
2026-02-25 13:59   ` Jani Nikula
2026-02-25 12:50 ` [PATCH i-g-t 06/19] tests/kms: Use igt_first_crtc_with_single_output() Ville Syrjala
2026-02-25 12:50 ` [PATCH i-g-t 07/19] lib/kms: Introduce and use igt_first_crtc() Ville Syrjala
2026-02-25 14:00   ` Jani Nikula
2026-02-25 12:50 ` [PATCH i-g-t 08/19] tests/kms: Stop using igt_require_pipe() Ville Syrjala
2026-02-25 12:50 ` [PATCH i-g-t 09/19] lib/kms: Replace get_num_scalers() with igt_crtc_num_scalers() Ville Syrjala
2026-02-25 12:50 ` [PATCH i-g-t 10/19] lib/kms: Pass igt_crtc_t* to igt_max_bpc_constraint() Ville Syrjala
2026-02-25 12:51 ` [PATCH i-g-t 11/19] lib/kms: Introduce for_each_plane_on_crtc() Ville Syrjala
2026-02-25 12:51 ` [PATCH i-g-t 12/19] tests/kms: Use for_each_plane_on_crtc() Ville Syrjala
2026-02-25 13:53   ` Jani Nikula
2026-02-25 12:51 ` [PATCH i-g-t 13/19] lib/kms: Nuke for_each_plane_on_pipe() Ville Syrjala
2026-02-25 12:51 ` [PATCH i-g-t 14/19] tests/kms: Switch to for_each_valid_output_on_crtc_local() Ville Syrjala
2026-02-25 12:51 ` [PATCH i-g-t 15/19] tests/kms: Replace igt_pipe_connector_valid() with igt_crtc_connector_valid() Ville Syrjala
2026-02-25 12:51 ` [PATCH i-g-t 16/19] lib/kms: Intreoduce for_each_valid_output_on_crtc() Ville Syrjala
2026-02-25 12:51 ` [PATCH i-g-t 17/19] tests/intel/kms_frontbuffer_tracking: Use for_each_valid_output_on_crtc() Ville Syrjala
2026-02-25 12:51 ` [PATCH i-g-t 18/19] tests/kms: " Ville Syrjala
2026-02-25 12:51 ` [PATCH i-g-t 19/19] lib/kms: Nuke for_each_valid_output_on_pipe() Ville Syrjala
2026-02-25 14:06   ` Jani Nikula
2026-02-25 14:07 ` [PATCH i-g-t 00/19] lib/kms: Clean up more of igt_kms API Jani Nikula
2026-02-25 23:34 ` ✗ Xe.CI.BAT: failure for " Patchwork
2026-02-26  0:05 ` ✓ i915.CI.BAT: success " Patchwork
2026-02-26  1:57 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-02-26 22:06 ` ✓ Xe.CI.BAT: success for lib/kms: Clean up more of igt_kms API (rev2) Patchwork
2026-02-26 22:09 ` ✓ i915.CI.BAT: " Patchwork
2026-02-27  2:55 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-02-27  4:24 ` ✗ i915.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260225125108.31119-5-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox