[PATCH i-g-t 16/17] lib/kms: Introduce igt_crtc_get_vbl_flag()
From: Ville Syrjala <hidden>
Date: 2026-02-27 08:08:04
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
From: Ville Syrjälä <redacted>
Provide a crtc based wrapper (igt_crtc_get_vbl_flag())
for kmstest_get_vbl_flag(), and make use of it where
appropriate.
#include "scripts/iterators.cocci"
@@
igt_crtc_t *CRTC;
@@
- kmstest_get_vbl_flag(CRTC->crtc_index)
+ igt_crtc_get_vbl_flag(CRTC)
@@
typedef uint32_t;
@@
kmstest_get_vbl_flag(...) { ... }
+/**
+ * igt_crtc_get_vbl_flag:
+ * @crtc: CRTC
+ *
+ * Convert a CRTC into flag representation
+ * expected by DRM_IOCTL_WAIT_VBLANK.
+ *
+ * See #igt_wait_for_vblank_count for details.
+ */
+uint32_t igt_crtc_get_vbl_flag(igt_crtc_t *crtc)
+{
+ return kmstest_get_vbl_flag(crtc->crtc_index);
+}
@@
type T;
@@
T igt_first_crtc_with_single_output(...);
+
+ uint32_t igt_crtc_get_vbl_flag(igt_crtc_t *crtc);
Signed-off-by: Ville Syrjälä <redacted>
---
lib/igt_kms.c | 14 ++++++++++++++
lib/igt_kms.h | 2 ++
tests/intel/perf_pmu.c | 2 +-
tests/kms_async_flips.c | 8 ++++----
tests/kms_vblank.c | 14 +++++++-------
5 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b3c44d9748d2..c3fe6198d302 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c@@ -6095,6 +6095,20 @@ uint32_t kmstest_get_vbl_flag(int crtc_index) return flag; } +/** + * igt_crtc_get_vbl_flag: + * @crtc: CRTC + * + * Convert a CRTC into flag representation + * expected by DRM_IOCTL_WAIT_VBLANK. + * + * See #igt_wait_for_vblank_count for details. + */ +uint32_t igt_crtc_get_vbl_flag(igt_crtc_t *crtc) +{ + return kmstest_get_vbl_flag(crtc->crtc_index); +} + static inline const uint32_t * formats_ptr(const struct drm_format_modifier_blob *blob) {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index b38f62f354fc..3e88d49fdaba 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h@@ -586,6 +586,8 @@ igt_crtc_t *igt_crtc_for_crtc_id(igt_display_t *display, uint32_t crtc_id); igt_crtc_t *igt_first_crtc(igt_display_t *display); igt_crtc_t *igt_first_crtc_with_single_output(igt_display_t *display, igt_output_t **ret_output); +uint32_t igt_crtc_get_vbl_flag(igt_crtc_t *crtc); + typedef struct _igt_pipe_crc igt_pipe_crc_t; igt_pipe_crc_t *igt_crtc_crc_new(igt_crtc_t *crtc, const char *source); igt_pipe_crc_t *igt_crtc_crc_new_nonblock(igt_crtc_t *crtc, const char *source);
diff --git a/tests/intel/perf_pmu.c b/tests/intel/perf_pmu.c
index 744d619f7f4c..661ead32dc29 100644
--- a/tests/intel/perf_pmu.c
+++ b/tests/intel/perf_pmu.c@@ -1202,7 +1202,7 @@ event_wait(int gem_fd, const intel_ctx_t *ctx, igt_fork_helper(&waiter) { const uint32_t pipe_id_flag = - kmstest_get_vbl_flag(data.crtc->crtc_index); + igt_crtc_get_vbl_flag(data.crtc); for (;;) { union drm_wait_vblank vbl = { };
diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index 53990917c9e4..03d1931fb2bb 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c@@ -553,7 +553,7 @@ static void test_async_flip(data_t *data) static void wait_for_vblank(data_t *data, unsigned long *vbl_time, unsigned int *seq) { drmVBlank wait_vbl = { - .request.type = DRM_VBLANK_RELATIVE | kmstest_get_vbl_flag(data->crtc->crtc_index), + .request.type = DRM_VBLANK_RELATIVE | igt_crtc_get_vbl_flag(data->crtc), .request.sequence = 1, };
@@ -726,9 +726,9 @@ static void queue_vblank(data_t *data) { drmVBlank wait_vbl = { .request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT | - kmstest_get_vbl_flag(data->crtc->crtc_index), - .request.sequence = 1, - .request.signal = (long)data, + igt_crtc_get_vbl_flag(data->crtc), + .request.sequence = 1, + .request.signal = (long)data, }; do_ioctl(data->drm_fd, DRM_IOCTL_WAIT_VBLANK, &wait_vbl);
diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index fd1da2738ac1..e79b2535c599 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c@@ -192,7 +192,7 @@ static void run_test(data_t *data, void (*testfunc)(data_t *, int, int)) memset(&vbl, 0, sizeof(vbl)); vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT; - vbl.request.type |= kmstest_get_vbl_flag(data->crtc->crtc_index); + vbl.request.type |= igt_crtc_get_vbl_flag(data->crtc); vbl.request.sequence = 120 + 12; igt_assert_eq(wait_vblank(fd, &vbl), 0); }
@@ -245,7 +245,7 @@ static void crtc_id_subtest(data_t *data, int fd) igt_display_t *display = &data->display; igt_output_t *output = data->output; struct drm_event_vblank buf; - const uint32_t pipe_id_flag = kmstest_get_vbl_flag(data->crtc->crtc_index); + const uint32_t pipe_id_flag = igt_crtc_get_vbl_flag(data->crtc); unsigned crtc_id, expected_crtc_id; uint64_t val; union drm_wait_vblank vbl;
@@ -290,7 +290,7 @@ static void crtc_id_subtest(data_t *data, int fd) static void accuracy(data_t *data, int fd, int nchildren) { - const uint32_t pipe_id_flag = kmstest_get_vbl_flag(data->crtc->crtc_index); + const uint32_t pipe_id_flag = igt_crtc_get_vbl_flag(data->crtc); union drm_wait_vblank vbl; unsigned long target; int total = 120 / nchildren;
@@ -329,7 +329,7 @@ static void accuracy(data_t *data, int fd, int nchildren) static void vblank_query(data_t *data, int fd, int nchildren) { - const uint32_t pipe_id_flag = kmstest_get_vbl_flag(data->crtc->crtc_index); + const uint32_t pipe_id_flag = igt_crtc_get_vbl_flag(data->crtc); union drm_wait_vblank vbl; struct timespec start, end; unsigned long sq, count = 0;
@@ -358,7 +358,7 @@ static void vblank_query(data_t *data, int fd, int nchildren) static void vblank_wait(data_t *data, int fd, int nchildren) { - const uint32_t pipe_id_flag = kmstest_get_vbl_flag(data->crtc->crtc_index); + const uint32_t pipe_id_flag = igt_crtc_get_vbl_flag(data->crtc); union drm_wait_vblank vbl; struct timespec start, end; unsigned long sq, count = 0;
@@ -392,7 +392,7 @@ static int get_vblank(int fd, igt_crtc_t *crtc, unsigned flags) union drm_wait_vblank vbl; memset(&vbl, 0, sizeof(vbl)); - vbl.request.type = DRM_VBLANK_RELATIVE | kmstest_get_vbl_flag(crtc->crtc_index) | flags; + vbl.request.type = DRM_VBLANK_RELATIVE | igt_crtc_get_vbl_flag(crtc) | flags; do_or_die(igt_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl)); return vbl.reply.sequence;
@@ -435,7 +435,7 @@ static void vblank_ts_cont(data_t *data, int fd, int nchildren) /* Attempting to do a vblank while disabled should return -EINVAL */ memset(&vbl, 0, sizeof(vbl)); vbl.request.type = _DRM_VBLANK_RELATIVE; - vbl.request.type |= kmstest_get_vbl_flag(data->crtc->crtc_index); + vbl.request.type |= igt_crtc_get_vbl_flag(data->crtc); igt_assert_eq(wait_vblank(fd, &vbl), -EINVAL); }
--
2.52.0