[PATCH i-g-t v3 2/3] lib/igt_kms: Add helper to get encoder index
Jessica Zhang
quic_jesszhan at quicinc.com
Thu Sep 19 17:26:51 UTC 2024
From: Esha Bharadwaj <quic_ebharadw at quicinc.com>
Move the get_encoder_idx() helper within the kms_setmode test to
lib/igt_kms
Signed-off-by: Esha Bharadwaj <quic_ebharadw at quicinc.com>
Signed-off-by: Jessica Zhang <quic_jesszhan at quicinc.com>
---
lib/igt_kms.c | 15 +++++++++++++++
lib/igt_kms.h | 1 +
tests/kms_setmode.c | 14 ++------------
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b40470c02..f5fab7f73 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3271,6 +3271,21 @@ void igt_display_fini(igt_display_t *display)
display->planes = NULL;
}
+/**
+ * kmstest_get_encoder_idx:
+ * @resources: libdrm resources pointer
+ * @encoder: libdrm encoder pointer
+ *
+ * Get encoder index from encoder_id
+ */
+int kmstest_get_encoder_idx(drmModeRes *resources, drmModeEncoder *encoder)
+{
+ for (int i = 0; i < resources->count_encoders; i++)
+ if (resources->encoders[i] == encoder->encoder_id)
+ return i;
+ igt_assert(0);
+}
+
static void igt_display_refresh(igt_display_t *display)
{
igt_output_t *output;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 25ba50916..72fe3b3b1 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -295,6 +295,7 @@ void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
void kmstest_dumb_destroy(int fd, uint32_t handle);
void kmstest_wait_for_pageflip(int fd);
unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
+int kmstest_get_encoder_idx(drmModeRes *resources, drmModeEncoder *encoder);
bool kms_has_vblank(int fd);
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index bc7b8fabb..c504d5a56 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -268,16 +268,6 @@ found:
*mode_ret = *mode;
}
-static int get_encoder_idx(drmModeRes *resources, drmModeEncoder *encoder)
-{
- int i;
-
- for (i = 0; i < resources->count_encoders; i++)
- if (resources->encoders[i] == encoder->encoder_id)
- return i;
- igt_assert(0);
-}
-
static void get_crtc_config_str(struct crtc_config *crtc, char *buf,
size_t buf_size)
{
@@ -370,7 +360,7 @@ static void setup_crtcs(const struct test_config *tconf,
config_valid &= !!(encoder->possible_crtcs &
(1 << crtc->crtc_idx));
- encoder_mask |= 1 << get_encoder_idx(resources,
+ encoder_mask |= 1 << kmstest_get_encoder_idx(resources,
encoder);
config_valid &= !(encoder_mask &
~encoder->possible_clones);
@@ -396,7 +386,7 @@ static void setup_crtcs(const struct test_config *tconf,
idx = cconf[i].crtc_idx;
encoder = drmModeGetEncoder(drm_fd, connector->encoders[idx]);
- encoder_usage_count[get_encoder_idx(resources, encoder)]++;
+ encoder_usage_count[kmstest_get_encoder_idx(resources, encoder)]++;
drmModeFreeEncoder(encoder);
}
for (i = 0; i < resources->count_encoders; i++)
--
2.34.1
More information about the igt-dev
mailing list