RE: [PATCH i-g-t v6 2/3] lib/igt_kms: Add helper to return vblank timestamp and sequence
flat view
From: Golani, Mitulkumar Ajitkumar <hidden>
Date: 2026-09-09 16:22:58
quoted hunk ↗ jump to hunk
-----Original Message----- From: Naladala, Ramanaidu <redacted> Sent: 07 September 2026 23:19 To: igt-dev@lists.freedesktop.org Cc: Golani, Mitulkumar Ajitkumar <redacted>; Borah, Chaitanya Kumar [off-list ref]; B S, Karthik [off-list ref]; Naladala, Ramanaidu [off-list ref] Subject: [PATCH i-g-t v6 2/3] lib/igt_kms: Add helper to return vblank timestamp and sequence Add a utility that waits for the next vertical blanking interval on a specified CRTC and returns the timestamp and sequence number reported by the kernel for that event. Several tests need access not only to vblank synchronization but also to the exact timing information associated with the completed vblank. Having a common helper avoids repeating the same wait and timestamp extraction. v1: Address below review comments: - Extend __igt_vblank_wait() to return timestamp and sequence. (Jani) - Adjust vblank helper prototype ordering. (Chaitanya) Assisted-by: GitHub Copilot:Claude Opus 4.6 Signed-off-by: Naladala Ramanaidu <redacted> Reviewed-by: Chaitanya Kumar Borah <redacted> --- lib/igt_kms.c | 37 +++++++++++++++++++++++++++++++++---- lib/igt_kms.h | 1 + 2 files changed, 34 insertions(+), 4 deletions(-)diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 2d78e3bee..6784210f9 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c@@ -5850,10 +5850,12 @@ void igt_output_set_writeback_fb(igt_output_t*output, struct igt_fb *fb) (ptrdiff_t)&output-quoted
writeback_out_fence_fd);} -static int __igt_vblank_wait(int drm_fd, int crtc_index, int count) +static int __igt_vblank_wait(int drm_fd, int crtc_index, int count, + uint64_t *ts_ns, unsigned int *seq) { drmVBlank wait_vbl; uint32_t pipe_id_flag; + int ret; memset(&wait_vbl, 0, sizeof(wait_vbl)); pipe_id_flag = kmstest_get_vbl_flag(crtc_index); @@ -5861,7 +5863,17 @@ static int __igt_vblank_wait(int drm_fd, int crtc_index, int count) wait_vbl.request.type = DRM_VBLANK_RELATIVE | pipe_id_flag; wait_vbl.request.sequence = count; - return drmWaitVBlank(drm_fd, &wait_vbl); + ret = drmWaitVBlank(drm_fd, &wait_vbl); + if (ret) + return ret; + + if (ts_ns) + *ts_ns = wait_vbl.reply.tval_sec * NSEC_PER_SEC + + wait_vbl.reply.tval_usec * NSEC_PER_USEC; + if (seq) + *seq = wait_vbl.reply.sequence; + + return 0; } /**@@ -5874,7 +5886,23 @@ static int __igt_vblank_wait(int drm_fd, intcrtc_index, int count) */ void igt_wait_for_vblank_count(igt_crtc_t *crtc, int count) { - igt_assert(__igt_vblank_wait(crtc->display->drm_fd, crtc->crtc_index, count) == 0); + igt_assert(__igt_vblank_wait(crtc->display->drm_fd, crtc->crtc_index, + count, NULL, NULL) == 0); +} + +/** + * igt_wait_for_vblank_ts_seq: + * @crtc: the CRTC + * @ts_ns: returns the vblank timestamp in nanoseconds, may be NULL + * @seq: returns the vblank sequence number, may be NULL + * + * Waits for the next vertical blank interval on @crtc and hands back +the + * timestamp and the sequence number reported by the kernel for that event. + */ +void igt_wait_for_vblank_ts_seq(igt_crtc_t *crtc, uint64_t *ts_ns, +unsigned int *seq) { + igt_assert(__igt_vblank_wait(crtc->display->drm_fd, crtc->crtc_index, + 1, ts_ns, seq) == 0); } /**@@ -5888,7 +5916,8 @@ void igt_wait_for_vblank_count(igt_crtc_t *crtc, intcount) */ void igt_wait_for_vblank(igt_crtc_t *crtc) { - igt_assert(__igt_vblank_wait(crtc->display->drm_fd, crtc->crtc_index, 1) == 0); + igt_assert(__igt_vblank_wait(crtc->display->drm_fd, crtc->crtc_index, + 1, NULL, NULL) == 0); } /**diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 27f8877a9..c5fc44f5b 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h@@ -654,6 +654,7 @@ const char *igt_plane_rotation_name(igt_rotation_trotation); void igt_wait_for_vblank(igt_crtc_t *crtc); void igt_wait_for_vblank_count(igt_crtc_t *crtc, int count); +void igt_wait_for_vblank_ts_seq(igt_crtc_t *crtc, uint64_t *ts_ns, +unsigned int *seq);
Changes LGTM Reviewed-by: Mitul Golani<redacted>
/** * igt_output_is_connected: -- 2.43.0