[PATCH i-g-t 6/8] lib/igt_kms: Always return CRTC index from kmstest_get_pipe_from_crtc_id()

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

All users of kmstest_get_pipe_from_crtc_id() actually need the CRTC
index, not the hardware pipe. Stop doing the CRTC index to hardware pipe
special case mapping on Intel devices. Rename the function
kmstest_get_crtc_index_from_id().

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
lib/igt_kms.c | 12 +++++-------
lib/igt_kms.h | 2 +-
tests/intel/kms_fbcon_fbt.c | 6 +++---
tests/kms_async_flips.c | 10 +++++-----
4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 16fae622fd11..6508400fd686 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1328,16 +1328,14 @@ int __intel_get_pipe_from_crtc_index(int fd, int crtc_index)
}

/**
- * kmstest_get_pipe_from_crtc_id:
+ * kmstest_get_crtc_index_from_id:
* @fd: DRM fd
* @crtc_id: DRM CRTC id
*
- * Returns: The crtc index for the given DRM CRTC ID @crtc_id. The crtc index
- * is the equivalent of the pipe id. This value maps directly to an enum pipe
- * value used in other helper functions. Returns 0 if the index could not be
- * determined.
+ * Returns: The crtc index for the given DRM CRTC ID @crtc_id. Returns 0 if the
+ * index could not be determined.
*/
-int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id)
+int kmstest_get_crtc_index_from_id(int fd, int crtc_id)
{
drmModeRes *res;
drmModeCrtc *drm_crtc;
@@ -1359,7 +1357,7 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id)

drmModeFreeResources(res);

- return is_intel_device(fd) ? __intel_get_pipe_from_crtc_index(fd, i) : i;
+ return i;
}

/**
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index bd6125989945..432c67d11780 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -148,7 +148,7 @@ void kmstest_dump_mode(drmModeModeInfo *mode);
#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);
+int kmstest_get_crtc_index_from_id(int fd, int crtc_id);
void kmstest_set_vt_graphics_mode(void);
void kmstest_restore_vt_mode(void);
void kmstest_set_vt_text_mode(void);
diff --git a/tests/intel/kms_fbcon_fbt.c b/tests/intel/kms_fbcon_fbt.c
index 1b9e535ebffc..36de84f9852f 100644
--- a/tests/intel/kms_fbcon_fbt.c
+++ b/tests/intel/kms_fbcon_fbt.c
@@ -146,10 +146,10 @@ static bool fbc_check_cursor_blinking(struct drm_info *drm)
igt_pipe_crc_t *pipe_crc;
igt_crc_t crc[2];
bool ret;
- int i, pipe;
+ int i, crtc_index;

- pipe = kmstest_get_pipe_from_crtc_id(drm->fd, drm->crtc_id);
- pipe_crc = igt_pipe_crc_new(drm->fd, pipe, IGT_PIPE_CRC_SOURCE_AUTO);
+ crtc_index = kmstest_get_crtc_index_from_id(drm->fd, drm->crtc_id);
+ pipe_crc = igt_pipe_crc_new(drm->fd, crtc_index, IGT_PIPE_CRC_SOURCE_AUTO);

igt_pipe_crc_start(pipe_crc);
igt_pipe_crc_drain(pipe_crc);
diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index c8586a5f947c..993ad37530b0 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c
@@ -555,9 +555,9 @@ static void test_async_flip(data_t *data)

static void wait_for_vblank(data_t *data, unsigned long *vbl_time, unsigned int *seq)
{
- int pipe = kmstest_get_pipe_from_crtc_id(data->drm_fd, data->crtc_id);
+ int crtc_index = kmstest_get_crtc_index_from_id(data->drm_fd, data->crtc_id);
drmVBlank wait_vbl = {
- .request.type = DRM_VBLANK_RELATIVE | kmstest_get_vbl_flag(pipe),
+ .request.type = DRM_VBLANK_RELATIVE | kmstest_get_vbl_flag(crtc_index),
.request.sequence = 1,
};

@@ -728,10 +728,10 @@ static void test_invalid(data_t *data)

static void queue_vblank(data_t *data)
{
- int pipe = kmstest_get_pipe_from_crtc_id(data->drm_fd, data->crtc_id);
+ int crtc_index = kmstest_get_crtc_index_from_id(data->drm_fd, data->crtc_id);
drmVBlank wait_vbl = {
.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT |
- kmstest_get_vbl_flag(pipe),
+ kmstest_get_vbl_flag(crtc_index),
.request.sequence = 1,
.request.signal = (long)data,
};
@@ -850,7 +850,7 @@ static void test_crc(data_t *data)
&data->output->config.connector->connector_id, 1, mode);
igt_assert_eq(ret, 0);

- data->pipe_crc = igt_crtc_crc_new(igt_crtc_for_pipe(&data->display, kmstest_get_pipe_from_crtc_id(data->drm_fd, data->crtc_id)),
+ data->pipe_crc = igt_crtc_crc_new(igt_crtc_for_pipe(&data->display, kmstest_get_crtc_index_from_id(data->drm_fd, data->crtc_id)),
IGT_PIPE_CRC_SOURCE_AUTO);

igt_pipe_crc_start(data->pipe_crc);
--
2.47.3