[PATCH i-g-t 5/8] tests/kms_setmode: use __intel_get_pipe_from_crtc_index() directly

Jani Nikula
2026-01-27T11:56:38Z

tests/kms_setmode is the only user of kmstest_get_pipe_from_crtc_id()
that actually needs the pipe instead of CRTC index. And it needs it only
for logging and test naming.

As a temporary measure, use __intel_get_pipe_from_crtc_index() directly
to allow cleaning up kmstest_get_pipe_from_crtc_id().

tests/kms_setmode should probably use igt_display_require() to handle
all of the resource management, but the conversion is not
straightforward, and igt_display_require() might not be flexible enough
at this point.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
lib/igt_kms.c | 2 +-
lib/igt_kms.h | 1 +
tests/kms_setmode.c | 6 ++++--
3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b033e0276801..16fae622fd11 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1303,7 +1303,7 @@ void kmstest_dump_mode(drmModeModeInfo *mode)
* The hardware pipe may be different from the CRTC index. Figure out the CRTC
* index to pipe mapping from the debugfs.
*/
-static int __intel_get_pipe_from_crtc_index(int fd, int crtc_index)
+int __intel_get_pipe_from_crtc_index(int fd, int crtc_index)
{
char buf[2];
int debugfs_fd, pipe, res = 0;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8d6a820856ef..bd6125989945 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -147,6 +147,7 @@ void kmstest_dump_mode(drmModeModeInfo *mode);
#define HDISPLAY_6K_PER_PIPE 6144
#define HDISPLAY_5K_PER_PIPE 5120

+int __intel_get_pipe_from_crtc_index(int fd, int crtc_index);
int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id);
void kmstest_set_vt_graphics_mode(void);
void kmstest_restore_vt_mode(void);
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index a7f7a5606bb3..9c0649e17bd0 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -350,8 +350,10 @@ static void setup_crtcs(const struct test_config *tconf,

crtc->crtc_idx = cconf[i].crtc_idx;
crtc->crtc_id = resources->crtcs[crtc->crtc_idx];
- crtc->pipe_id = kmstest_get_pipe_from_crtc_id(drm_fd,
- crtc->crtc_id);
+
+ /* FIXME: avoid __intel_get_pipe_from_crtc_index() */
+ crtc->pipe_id = is_intel_device(drm_fd) ?
+ __intel_get_pipe_from_crtc_index(drm_fd, crtc->crtc_idx) : crtc->crtc_idx;

crtc->connector_count = 1;
for (j = i + 1; j < connector_count; j++)
--
2.47.3