[PATCH i-g-t v1 1/2] tests/kms_vrr: Add function to return vblank timestamp

Naladala Ramanaidu ramanaidu.naladala at intel.com
Thu Jan 30 23:52:45 UTC 2025


This is useful for subtests that require precise vblank
timestamps.

Signed-off-by: Naladala Ramanaidu <ramanaidu.naladala at intel.com>
---
 tests/kms_vrr.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/kms_vrr.c b/tests/kms_vrr.c
index e7d2ff1db..fac7cb4f7 100644
--- a/tests/kms_vrr.c
+++ b/tests/kms_vrr.c
@@ -172,6 +172,27 @@ static uint64_t get_kernel_event_ns(data_t *data, uint32_t event)
 	return ev.tv_sec * NSECS_PER_SEC + ev.tv_usec * 1000ull;
 }
 
+/*
+ * Wait for an vblank event and return its timestamp in microseconds.
+ *
+ * This blocks untill the event is received.
+ */
+static uint64_t wait_for_vblank(data_t *data, int pipe)
+{
+	uint32_t pipe_id_flag;
+	drmVBlank vbl;
+
+	memset(&vbl, 0, sizeof(vbl));
+
+	pipe_id_flag = kmstest_get_vbl_flag(pipe);
+
+	vbl.request.type = DRM_VBLANK_RELATIVE | pipe_id_flag;
+	vbl.request.sequence = 1;
+	do_ioctl(data->drm_fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
+
+	return (vbl.reply.tval_sec * 1000000 + vbl.reply.tval_usec);
+}
+
 /*
  * Returns the current CLOCK_MONOTONIC time in nanoseconds.
  * The regular IGT helpers can't be used since they default to
-- 
2.25.1



More information about the igt-dev mailing list