[PATCH i-g-t 2/8] lib/igt_kms: Remove kmstest_pipe_to_index()

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

There's only a single user for kmstest_pipe_to_index(), and that should
be the extent of it. There's no reason for other code than the i915_pipe
debugfs parsing to convert from pipe name character to the enum
pipe. And for that, the name of the function is misleading anyway.

Inline the functionality in __intel_get_pipe_from_crtc_index(), using
igt_assert_f() for invalid values instead of propagating -EINVAL which
isn't even checked by the caller.

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

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a236597ac152..b033e0276801 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1065,22 +1065,6 @@ const char *kmstest_pipe_name(enum pipe pipe)
return str + (pipe * 2);
}

-/**
- * kmstest_pipe_to_index:
- * @pipe: display pipe in string format
- *
- * Returns: Index to corresponding pipe
- */
-int kmstest_pipe_to_index(char pipe)
-{
- int r = pipe - 'A';
-
- if (r < 0 || r >= IGT_MAX_PIPES)
- return -EINVAL;
-
- return r;
-}
-
/**
* kmstest_plane_type_name:
* @plane_type: display plane type
@@ -1322,7 +1306,7 @@ void kmstest_dump_mode(drmModeModeInfo *mode)
static int __intel_get_pipe_from_crtc_index(int fd, int crtc_index)
{
char buf[2];
- int debugfs_fd, res = 0;
+ int debugfs_fd, pipe, res = 0;
char pipe_char;

debugfs_fd = igt_debugfs_pipe_dir(fd, crtc_index, O_RDONLY);
@@ -1336,7 +1320,11 @@ static int __intel_get_pipe_from_crtc_index(int fd, int crtc_index)

igt_assert_eq(sscanf(buf, "%c", &pipe_char), 1);

- return kmstest_pipe_to_index(pipe_char);
+ pipe = pipe_char - 'A';
+
+ igt_assert_f(pipe >= 0 && pipe < IGT_MAX_PIPES, "i915_pipe %c out of range\n", pipe_char);
+
+ return pipe;
}

/**
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 5bfcb53c0aaa..8d6a820856ef 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -90,7 +90,6 @@ enum pipe {
IGT_MAX_PIPES
};
const char *kmstest_pipe_name(enum pipe pipe);
-int kmstest_pipe_to_index(char pipe);
const char *kmstest_plane_type_name(int plane_type);

enum port {
--
2.47.3