[PATCH i-g-t v5 1/3] lib/igt_kms: Add helper to get encoder index
Jessica Zhang
quic_jesszhan at quicinc.com
Thu Oct 17 01:22:59 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 bb35d4b82c5a9e2ad3d2e66afdc8b5a71f5d9f11..0641ae3e2104515dd392febb7381f4766112911c 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3296,6 +3296,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 2b26d2bbfff1e36e5b7ce2bc920dc499feebf7b2..728b44f5134d054d7323c673ba08ffb99cb0f2c2 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -309,6 +309,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 bc7b8fabb1964b242d1603f78b0435d13669cf75..c504d5a567abcff8a1bce720becc447c88e57db9 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