From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t 07/19] lib/kms: Introduce and use igt_first_crtc()
Date: Wed, 25 Feb 2026 14:50:56 +0200 [thread overview]
Message-ID: <20260225125108.31119-8-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 just want to pick the first CRTC they
can. Currently they just ask for the CRTC for PIPE_A
which might not even be present on the hardware.
Introduce a new igt_first_crtc() that just hands
you the first available CRTC, whatever pipe that is.
#include "scripts/iterators.cocci"
@@
expression DISPLAY;
@@
(
- igt_crtc_for_pipe(DISPLAY, PIPE_A)
+ igt_first_crtc(DISPLAY)
|
- igt_crtc_for_pipe(DISPLAY, 0)
+ igt_first_crtc(DISPLAY)
)
@@
type T;
@@
T igt_crtc_for_crtc_id(...);
+igt_crtc_t *igt_first_crtc(igt_display_t *display);
@@
iterator name for_each_crtc;
@@
igt_crtc_for_crtc_id(...) { ... }
+/*
+ * igt_first_crtc:
+ * @display: pointer to igt_display_t
+ *
+ * Returns: The first CRTC on the device
+ */
+igt_crtc_t *igt_first_crtc(igt_display_t *display)
+{
+ igt_crtc_t *crtc;
+
+ for_each_crtc(display, crtc)
+ return crtc;
+
+ return NULL;
+}
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
lib/igt_kms.c | 16 ++++++++++++++++
lib/igt_kms.h | 1 +
tests/amdgpu/amd_abm.c | 2 +-
tests/amdgpu/amd_assr.c | 2 +-
tests/amdgpu/amd_bypass.c | 2 +-
tests/amdgpu/amd_color.c | 2 +-
tests/amdgpu/amd_mall.c | 2 +-
tests/amdgpu/amd_max_bpc.c | 2 +-
tests/amdgpu/amd_mem_leak.c | 2 +-
tests/amdgpu/amd_odm.c | 2 +-
tests/amdgpu/amd_psr.c | 2 +-
tests/amdgpu/amd_replay.c | 2 +-
tests/intel/kms_dp_linktrain_fallback.c | 2 +-
tests/kms_lease.c | 6 +++---
tests/kms_rotation_crc.c | 6 +++---
tools/amd_hdmi_compliance.c | 2 +-
16 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index ee95afc49aa7..94fa0680653b 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -7965,6 +7965,22 @@ igt_crtc_t *igt_crtc_for_crtc_id(igt_display_t *display, uint32_t crtc_id)
return NULL;
}
+/*
+ * igt_first_crtc:
+ * @display: pointer to igt_display_t
+ *
+ * Returns: The first CRTC on the device
+ */
+igt_crtc_t *igt_first_crtc(igt_display_t *display)
+{
+ igt_crtc_t *crtc;
+
+ for_each_crtc (display, crtc)
+ return crtc;
+
+ return NULL;
+}
+
igt_crtc_t *igt_first_crtc_with_single_output(igt_display_t *display, igt_output_t **ret_output)
{
igt_output_t *output;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index ae488bbf4806..d6ebd40dd7be 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -585,6 +585,7 @@ static inline igt_crtc_t *igt_crtc_for_pipe(igt_display_t *display, enum pipe pi
return &display->crtcs[pipe];
}
igt_crtc_t *igt_crtc_for_crtc_id(igt_display_t *display, uint32_t crtc_id);
+igt_crtc_t *igt_first_crtc(igt_display_t *display);
typedef struct _igt_pipe_crc igt_pipe_crc_t;
igt_pipe_crc_t *igt_crtc_crc_new(igt_crtc_t *crtc, const char *source);
diff --git a/tests/amdgpu/amd_abm.c b/tests/amdgpu/amd_abm.c
index ffa73bb46865..5cd40cfb91df 100644
--- a/tests/amdgpu/amd_abm.c
+++ b/tests/amdgpu/amd_abm.c
@@ -129,7 +129,7 @@ static void test_init(data_t *data)
igt_skip("No eDP connector found\n");
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/amdgpu/amd_assr.c b/tests/amdgpu/amd_assr.c
index f02a30e8fea3..b07f3fb15a1f 100644
--- a/tests/amdgpu/amd_assr.c
+++ b/tests/amdgpu/amd_assr.c
@@ -161,7 +161,7 @@ static void present_visual_pattern(data_t *data, igt_output_t *output)
{
igt_display_t *display = &data->display;
igt_plane_t *primary;
- igt_crtc_t *crtc = igt_crtc_for_pipe(display, PIPE_A);
+ igt_crtc_t *crtc = igt_first_crtc(display);
drmModeModeInfo *mode;
igt_fb_t fb;
diff --git a/tests/amdgpu/amd_bypass.c b/tests/amdgpu/amd_bypass.c
index 6ff36ce09d3e..25136e83e6ad 100644
--- a/tests/amdgpu/amd_bypass.c
+++ b/tests/amdgpu/amd_bypass.c
@@ -63,7 +63,7 @@ static void test_init(data_t *data)
igt_display_t *display = &data->display;
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c
index dc2a10817105..cdc6f3e6abd8 100644
--- a/tests/amdgpu/amd_color.c
+++ b/tests/amdgpu/amd_color.c
@@ -178,7 +178,7 @@ static void test_init(data_t *data)
igt_display_t *display = &data->display;
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/amdgpu/amd_mall.c b/tests/amdgpu/amd_mall.c
index b83e3b864ee4..a068154656e7 100644
--- a/tests/amdgpu/amd_mall.c
+++ b/tests/amdgpu/amd_mall.c
@@ -60,7 +60,7 @@ static void test_init(data_t *data)
bool mall_en = false;
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/amdgpu/amd_max_bpc.c b/tests/amdgpu/amd_max_bpc.c
index cf4de724c12c..eb76762fa954 100644
--- a/tests/amdgpu/amd_max_bpc.c
+++ b/tests/amdgpu/amd_max_bpc.c
@@ -54,7 +54,7 @@ static void test_init(data_t *data)
igt_display_t *display = &data->display;
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/amdgpu/amd_mem_leak.c b/tests/amdgpu/amd_mem_leak.c
index 9e8e61aa7847..1e55fe785c5f 100644
--- a/tests/amdgpu/amd_mem_leak.c
+++ b/tests/amdgpu/amd_mem_leak.c
@@ -46,7 +46,7 @@ static void test_init(data_t *data)
igt_display_t *display = &data->display;
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/amdgpu/amd_odm.c b/tests/amdgpu/amd_odm.c
index ac6b839847a2..1feee8d9badb 100644
--- a/tests/amdgpu/amd_odm.c
+++ b/tests/amdgpu/amd_odm.c
@@ -47,7 +47,7 @@ static void test_init(struct data *data)
igt_display_t *display = &data->display;
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/amdgpu/amd_psr.c b/tests/amdgpu/amd_psr.c
index 548e21810fb9..b1d6d1631e26 100644
--- a/tests/amdgpu/amd_psr.c
+++ b/tests/amdgpu/amd_psr.c
@@ -170,7 +170,7 @@ static void test_init(data_t *data)
igt_display_t *display = &data->display;
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/amdgpu/amd_replay.c b/tests/amdgpu/amd_replay.c
index 010b3a97e775..5f62465d6b72 100644
--- a/tests/amdgpu/amd_replay.c
+++ b/tests/amdgpu/amd_replay.c
@@ -60,7 +60,7 @@ static void test_init(struct test_data *data)
igt_display_t *display = &data->display;
/* It doesn't matter which pipe we choose on amdpgu. */
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
diff --git a/tests/intel/kms_dp_linktrain_fallback.c b/tests/intel/kms_dp_linktrain_fallback.c
index b7e02be2d8aa..91dde2a7dcee 100644
--- a/tests/intel/kms_dp_linktrain_fallback.c
+++ b/tests/intel/kms_dp_linktrain_fallback.c
@@ -468,7 +468,7 @@ static void test_dsc_sst_fallback(data_t *data)
int output_count = 0;
igt_info("Checking DSC fallback on %s\n", igt_output_name(data->output));
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(&data->display);
igt_reset_link_params(data->drm_fd, data->output);
diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index 7531f9acf810..4e9a69da5d9d 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -872,7 +872,7 @@ static void invalid_create_leases(data_t *data)
igt_crtc_t *crtc;
int tmp_fd, ret;
- crtc = igt_crtc_for_pipe(&data->master.display, 0);
+ crtc = igt_first_crtc(&data->master.display);
/* NULL array pointer */
mcl.object_count = 1;
@@ -1070,7 +1070,7 @@ static int _create_simple_lease(int master_fd, data_t *data, int expected_ret)
struct drm_mode_create_lease mcl;
igt_crtc_t *crtc;
- crtc = igt_crtc_for_pipe(&data->master.display, 0);
+ crtc = igt_first_crtc(&data->master.display);
object_ids[0] = crtc->crtc_id;
object_ids[1] = data->master.display.outputs[0].id;
@@ -1164,7 +1164,7 @@ static void implicit_plane_lease(data_t *data)
uint32_t cursor_id;
igt_crtc_t *crtc;
- crtc = igt_crtc_for_pipe(&data->master.display, 0);
+ crtc = igt_first_crtc(&data->master.display);
cursor_id = igt_crtc_get_plane_type(crtc, DRM_PLANE_TYPE_CURSOR)->drm_plane->plane_id;
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 6240e112cb29..9b087bbaa6dc 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -1314,7 +1314,7 @@ 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_crtc_t *crtc = igt_first_crtc(&data.display);
igt_require(gen >= 9);
cleanup_crtc(&data);
@@ -1330,7 +1330,7 @@ int igt_main_args("", long_opts, help_str, opt_handler, &data)
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_crtc_t *crtc = igt_first_crtc(&data.display);
igt_require(gen >= 9);
cleanup_crtc(&data);
@@ -1346,7 +1346,7 @@ int igt_main_args("", long_opts, help_str, opt_handler, &data)
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_crtc_t *crtc = igt_first_crtc(&data.display);
igt_require(gen >= 9);
cleanup_crtc(&data);
diff --git a/tools/amd_hdmi_compliance.c b/tools/amd_hdmi_compliance.c
index 94025547f01c..e0ef78d8191d 100644
--- a/tools/amd_hdmi_compliance.c
+++ b/tools/amd_hdmi_compliance.c
@@ -383,7 +383,7 @@ static void test_init(data_t *data, int conn_id)
{
igt_display_t *display = &data->display;
- data->crtc = igt_crtc_for_pipe(&data->display, PIPE_A);
+ data->crtc = igt_first_crtc(&data->display);
igt_display_reset(display);
--
2.52.0
next prev 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 ` [PATCH i-g-t 04/19] tests/kms: " Ville Syrjala
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 ` Ville Syrjala [this message]
2026-02-25 14:00 ` [PATCH i-g-t 07/19] lib/kms: Introduce and use igt_first_crtc() 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-8-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