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 03/17] lib/kms: Replace igt_get_single_output_for_pipe() with igt_get_single_output_for_crtc()
Date: Fri, 27 Feb 2026 10:06:39 +0200	[thread overview]
Message-ID: <20260227080653.30389-4-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20260227080653.30389-1-ville.syrjala@linux.intel.com>

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

Replace the pipe based igt_get_single_output_for_pipe() with
the crtc based igt_get_single_output_for_crtc()

 #include "scripts/iterators.cocci"

@@
expression DISPLAY, PIPE;
@@
- igt_get_single_output_for_pipe(DISPLAY, PIPE)
+ igt_get_single_output_for_crtc(igt_crtc_for_pipe(DISPLAY, PIPE))

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

@@
type T;
@@
T igt_get_single_output_for_pipe(...);
+igt_output_t *igt_get_single_output_for_crtc(igt_crtc_t *crtc);

@@
@@
igt_get_single_output_for_pipe(...)
{ ... }
+/**
+ * igt_get_single_output_for_crtc:
+ * @crtc: The CRTC for which an #igt_output_t must be returned.
+ *
+ * Get a compatible output for a CRTC.
+ *
+ * Returns: A compatible output for a given CRTC, or NULL.
+ */
+igt_output_t *igt_get_single_output_for_crtc(igt_crtc_t *crtc)
+{
+       igt_display_t *display = crtc->display;
+       igt_output_t *chosen_outputs[igt_display_n_crtcs(display)];
+
+       __igt_pipe_populate_outputs(display, chosen_outputs);
+
+       return chosen_outputs[crtc->pipe];
+}

@@
@@
- igt_get_single_output_for_pipe(...) { ... }

@@
@@
- igt_require_pipe(...) { ... }

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_kms.c                           | 26 ++++++++-----------------
 lib/igt_kms.h                           |  2 +-
 tests/amdgpu/amd_abm.c                  |  3 +--
 tests/amdgpu/amd_bypass.c               |  3 +--
 tests/amdgpu/amd_color.c                |  3 +--
 tests/amdgpu/amd_multidisplay_modeset.c |  2 +-
 tests/amdgpu/amd_psr.c                  |  3 +--
 tests/amdgpu/amd_replay.c               |  3 +--
 tests/intel/gem_eio.c                   |  2 +-
 tests/nouveau_crc.c                     |  3 +--
 10 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 11ed109d74fb..5c2e101f08be 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2814,13 +2814,6 @@ void igt_display_reset(igt_display_t *display)
 static void igt_fill_plane_format_mod(igt_display_t *display, igt_plane_t *plane);
 static void igt_fill_display_format_mod(igt_display_t *display);
 
-static void igt_require_pipe(igt_display_t *display, enum pipe pipe)
-{
-	igt_skip_on_f(pipe >= igt_display_n_crtcs(display) || !igt_crtc_for_pipe(display, pipe)->valid,
-			"Pipe %s does not exist\n",
-			kmstest_pipe_name(pipe));
-}
-
 static bool igt_crtc_has_valid_output(igt_crtc_t *crtc)
 {
 	igt_display_t *display = crtc->display;
@@ -2949,7 +2942,7 @@ void igt_display_reset_outputs(igt_display_t *display)
 		if (!igt_crtc_has_valid_output(crtc))
 			continue;
 
-		output = igt_get_single_output_for_pipe(display, crtc->pipe);
+		output = igt_get_single_output_for_crtc(crtc);
 
 		if (crtc->num_primary_planes > 1) {
 			igt_plane_t *old_primary = &crtc->planes[0];
@@ -3655,24 +3648,21 @@ igt_output_t **__igt_pipe_populate_outputs(igt_display_t *display, igt_output_t
 }
 
 /**
- * igt_get_single_output_for_pipe:
- * @display: a pointer to an #igt_display_t structure
- * @pipe: The pipe for which an #igt_output_t must be returned.
+ * igt_get_single_output_for_crtc:
+ * @crtc: The CRTC for which an #igt_output_t must be returned.
  *
- * Get a compatible output for a pipe.
+ * Get a compatible output for a CRTC.
  *
- * Returns: A compatible output for a given pipe, or NULL.
+ * Returns: A compatible output for a given CRTC, or NULL.
  */
-igt_output_t *igt_get_single_output_for_pipe(igt_display_t *display, enum pipe pipe)
+igt_output_t *igt_get_single_output_for_crtc(igt_crtc_t *crtc)
 {
+	igt_display_t *display = crtc->display;
 	igt_output_t *chosen_outputs[igt_display_n_crtcs(display)];
 
-	igt_assert(pipe != PIPE_NONE);
-	igt_require_pipe(display, pipe);
-
 	__igt_pipe_populate_outputs(display, chosen_outputs);
 
-	return chosen_outputs[pipe];
+	return chosen_outputs[crtc->pipe];
 }
 
 static igt_output_t *igt_crtc_get_output(igt_crtc_t *crtc)
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index c79c8664e9a9..08573316eea6 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -616,7 +616,7 @@ int igt_crtc_count_plane_type(igt_crtc_t *crtc, int plane_type);
 igt_plane_t *igt_crtc_get_plane_type_index(igt_crtc_t *crtc, int plane_type,
 					   int index);
 bool output_is_internal_panel(igt_output_t *output);
-igt_output_t *igt_get_single_output_for_pipe(igt_display_t *display, enum pipe pipe);
+igt_output_t *igt_get_single_output_for_crtc(igt_crtc_t *crtc);
 
 void igt_crtc_request_out_fence(igt_crtc_t *crtc);
 
diff --git a/tests/amdgpu/amd_abm.c b/tests/amdgpu/amd_abm.c
index bd700b90f361..1752a7e5c48d 100644
--- a/tests/amdgpu/amd_abm.c
+++ b/tests/amdgpu/amd_abm.c
@@ -133,8 +133,7 @@ static void test_init(data_t *data)
 
 	igt_display_reset(display);
 
-	data->output = igt_get_single_output_for_pipe(display,
-						      data->crtc->pipe);
+	data->output = igt_get_single_output_for_crtc(data->crtc);
 	igt_require(data->output);
 	igt_info("output %s\n", data->output->name);
 
diff --git a/tests/amdgpu/amd_bypass.c b/tests/amdgpu/amd_bypass.c
index 25136e83e6ad..9d5f3dd71c89 100644
--- a/tests/amdgpu/amd_bypass.c
+++ b/tests/amdgpu/amd_bypass.c
@@ -67,8 +67,7 @@ static void test_init(data_t *data)
 
 	igt_display_reset(display);
 
-	data->output = igt_get_single_output_for_pipe(display,
-						      data->crtc->pipe);
+	data->output = igt_get_single_output_for_crtc(data->crtc);
 	igt_assert(data->output);
 
 	if (data->output->config.connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c
index cdc6f3e6abd8..68f541d64d63 100644
--- a/tests/amdgpu/amd_color.c
+++ b/tests/amdgpu/amd_color.c
@@ -182,8 +182,7 @@ static void test_init(data_t *data)
 
 	igt_display_reset(display);
 
-	data->output = igt_get_single_output_for_pipe(display,
-						      data->crtc->pipe);
+	data->output = igt_get_single_output_for_crtc(data->crtc);
 	igt_require(data->output);
 
 	data->mode = igt_output_get_mode(data->output);
diff --git a/tests/amdgpu/amd_multidisplay_modeset.c b/tests/amdgpu/amd_multidisplay_modeset.c
index a2853e73225a..40d1e5d7f42b 100644
--- a/tests/amdgpu/amd_multidisplay_modeset.c
+++ b/tests/amdgpu/amd_multidisplay_modeset.c
@@ -159,7 +159,7 @@ static void test_init(struct data_t *data)
 		 * This will let displays connected to MST hub be
 		 * tested
 		 */
-		output = igt_get_single_output_for_pipe(display, crtc->pipe);
+		output = igt_get_single_output_for_crtc(crtc);
 		data->primary[crtc->pipe] = igt_crtc_get_plane_type(crtc,
 							   DRM_PLANE_TYPE_PRIMARY);
 		data->output[crtc->pipe] = output;
diff --git a/tests/amdgpu/amd_psr.c b/tests/amdgpu/amd_psr.c
index b1d6d1631e26..85247d0e20da 100644
--- a/tests/amdgpu/amd_psr.c
+++ b/tests/amdgpu/amd_psr.c
@@ -174,8 +174,7 @@ static void test_init(data_t *data)
 
 	igt_display_reset(display);
 
-	data->output = igt_get_single_output_for_pipe(display,
-						      data->crtc->pipe);
+	data->output = igt_get_single_output_for_crtc(data->crtc);
 	igt_require(data->output);
 	igt_info("output %s\n", data->output->name);
 
diff --git a/tests/amdgpu/amd_replay.c b/tests/amdgpu/amd_replay.c
index 5f62465d6b72..775bed190adf 100644
--- a/tests/amdgpu/amd_replay.c
+++ b/tests/amdgpu/amd_replay.c
@@ -64,8 +64,7 @@ static void test_init(struct test_data *data)
 
 	igt_display_reset(display);
 
-	data->output = igt_get_single_output_for_pipe(display,
-						      data->crtc->pipe);
+	data->output = igt_get_single_output_for_crtc(data->crtc);
 	igt_require(data->output);
 	igt_info("output %s\n", data->output->name);
 
diff --git a/tests/intel/gem_eio.c b/tests/intel/gem_eio.c
index 361fd24744c4..546fff14bd5b 100644
--- a/tests/intel/gem_eio.c
+++ b/tests/intel/gem_eio.c
@@ -1041,7 +1041,7 @@ static void display_helper(igt_display_t *dpy, int *done)
 		if (!crtc || !crtc->valid)
 			continue;
 
-		output = igt_get_single_output_for_pipe(dpy, crtc->pipe);
+		output = igt_get_single_output_for_crtc(crtc);
 		if (!output)
 			continue;
 
diff --git a/tests/nouveau_crc.c b/tests/nouveau_crc.c
index 98394674e463..eeb544acad76 100644
--- a/tests/nouveau_crc.c
+++ b/tests/nouveau_crc.c
@@ -350,8 +350,7 @@ int igt_main()
 				igt_display_commit(&data.display);
 			}
 
-			data.output = igt_get_single_output_for_pipe(&data.display,
-								     data.crtc->pipe);
+			data.output = igt_get_single_output_for_crtc(data.crtc);
 			data.mode = igt_output_get_mode(data.output);
 
 			/* None of these tests need to perform modesets, just page flips. So running
-- 
2.52.0


  parent reply	other threads:[~2026-02-27  8:07 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27  8:06 [PATCH i-g-t 00/17] lib/kms: Finish the igt_crtc_t API refactoring Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 01/17] lib/kms: Replace igt_pipe_has_valid_output() with igt_crtc_has_valid_output() Ville Syrjala
2026-02-27 10:42   ` Jani Nikula
2026-02-27  8:06 ` [PATCH i-g-t 02/17] lib/kms: Replace igt_display_require_output_on_pipe() with igt_display_require_output_on_crtc() Ville Syrjala
2026-02-27 10:50   ` Jani Nikula
2026-02-27  8:06 ` Ville Syrjala [this message]
2026-02-27 10:22   ` [PATCH i-g-t 03/17] lib/kms: Replace igt_get_single_output_for_pipe() with igt_get_single_output_for_crtc() Jani Nikula
2026-02-27  8:06 ` [PATCH i-g-t 04/17] lib/kms: Make the igt_*_bpc_*() interfaces more abstract Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 05/17] tests/kms: Use igt_crtc_name() Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 06/17] tests/kms: Clean up crtc->pipe comparions Ville Syrjala
2026-02-27 10:51   ` Jani Nikula
2026-02-27  8:06 ` [PATCH i-g-t 07/17] tests/vmwgfx/vmw_prime: Replace igt_pipe_crc_new() with igt_crtc_crc_new() Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 08/17] lib/kms: Prefer "crtc" over "pipe" in function names Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 09/17] tests/kms_color*: " Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 10/17] tests/kms: " Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 11/17] tests/kms_tiled_display: Remove mention of PIPE_NONE Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 12/17] tests/kms: Remove hand rolled get_vblank() stuff Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 13/17] lib/kms: Fix kmstest_get_vblank() docs Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 14/17] tests/kms: Pass crtc_index to kmstest_get_vbl_flag() Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 15/17] tests/kms: Pass crtc_index to kmstest_get_vblank() Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 16/17] lib/kms: Introduce igt_crtc_get_vbl_flag() Ville Syrjala
2026-02-27  8:06 ` [PATCH i-g-t 17/17] lib/kms: Introduce igt_crtc_get_vblank() Ville Syrjala
2026-02-27 10:55 ` [PATCH i-g-t 00/17] lib/kms: Finish the igt_crtc_t API refactoring Jani Nikula
2026-02-27 14:14 ` ✗ i915.CI.BAT: failure for " Patchwork
2026-02-27 14:24 ` ✓ Xe.CI.BAT: success " Patchwork
2026-02-27 23:28 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-04  5:58 ` ✓ Xe.CI.BAT: success for lib/kms: Finish the igt_crtc_t API refactoring (rev2) Patchwork
2026-03-04  6:19 ` ✓ i915.CI.BAT: " Patchwork
2026-03-05  5:01 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-05  8:15 ` ✗ 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=20260227080653.30389-4-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