[PATCH i-g-t v1 1/2] lib/igt_kms: Add helper to measure vblank sequence difference
Naladala Ramanaidu
ramanaidu.naladala at intel.com
Mon Aug 18 21:44:30 UTC 2025
Add a new helper to calculate the number of vblank intervals
between two consecutive events. This enhancement enables more
precise timing and synchronization measurements in simulation
environments.
Signed-off-by: Naladala Ramanaidu <ramanaidu.naladala at intel.com>
---
lib/igt_kms.c | 21 +++++++++++++++++++++
lib/igt_kms.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7191bf92e..1dfe70637 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2355,6 +2355,27 @@ static inline uint32_t pipe_select(int pipe)
return 0;
}
+/**
+ * get_vblank_seq_diff:
+ * @fd: Opened drm file descriptor
+ * @pipe: Display pipe
+ *
+ * Measures the difference in vblank sequence numbers between
+ * two consecutive vblank events.
+ *
+ * Returns the number of vblank sequence numbers are elapsed.
+ */
+unsigned int get_vblank_seq_diff(int fd, enum pipe pipe)
+{
+ uint32_t vblank_start, vblank_end;
+
+ vblank_start = kmstest_get_vblank(fd, pipe, 0);
+ igt_wait_for_vblank(fd, pipe);
+ vblank_end = kmstest_get_vblank(fd, pipe, 0);
+
+ return vblank_end - vblank_start;
+}
+
/**
* kmstest_get_vblank:
* @fd: Opened drm file descriptor
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index f140ad91a..01d1b8061 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -314,6 +314,7 @@ void kmstest_dumb_destroy(int fd, uint32_t handle);
void kmstest_wait_for_pageflip(int fd);
void kmstest_wait_for_pageflip_timeout(int fd, uint64_t timeout_us);
unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
+unsigned int get_vblank_seq_diff(int fd, enum pipe pipe);
bool kms_has_vblank(int fd);
--
2.43.0
More information about the igt-dev
mailing list