Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
To: igt-dev@lists.freedesktop.org, mitulkumar.ajitkumar.golani@intel.com
Subject: [igt-dev] [i-g-t 1/2] tests/kms_vrr: Add support to read Vblank event
Date: Mon, 20 Nov 2023 13:54:58 +0530	[thread overview]
Message-ID: <20231120082459.1859375-2-bhanuprakash.modem@intel.com> (raw)
In-Reply-To: <20231120082459.1859375-1-bhanuprakash.modem@intel.com>

Add a helper support to read DRM_EVENT_VBLANK event from Kernel.

Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
---
 tests/kms_vrr.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/tests/kms_vrr.c b/tests/kms_vrr.c
index f26adbccf..741a13be6 100644
--- a/tests/kms_vrr.c
+++ b/tests/kms_vrr.c
@@ -128,13 +128,31 @@ static uint64_t timespec_to_ns(struct timespec *ts)
 static uint64_t get_kernel_event_ns(data_t *data, uint32_t event)
 {
 	struct drm_event_vblank ev;
+	union drm_wait_vblank vbl;
+	uint32_t tv_sec, tv_usec;
 
 	igt_set_timeout(1, "Waiting for an event\n");
-	igt_assert_eq(read(data->drm_fd, &ev, sizeof(ev)), sizeof(ev));
-	igt_assert_eq(ev.base.type, event);
+
+	if (event == DRM_EVENT_VBLANK) {
+		memset(&vbl, 0, sizeof(vbl));
+		vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_NEXTONMISS;
+		igt_assert_eq(drmIoctl(data->drm_fd, DRM_IOCTL_WAIT_VBLANK, &vbl), 0);
+
+		tv_sec = vbl.reply.tval_sec;
+		tv_usec = vbl.reply.tval_usec;
+	} else if (event == DRM_EVENT_FLIP_COMPLETE) {
+		igt_assert_eq(read(data->drm_fd, &ev, sizeof(ev)), sizeof(ev));
+		igt_assert_eq(ev.base.type, event);
+
+		tv_sec = ev.tv_sec;
+		tv_usec = ev.tv_usec;
+	} else {
+		igt_assert_f(0, "Un recognized event.\n");
+	}
+
 	igt_reset_timeout();
 
-	return ev.tv_sec * NSECS_PER_SEC + ev.tv_usec * 1000ull;
+	return tv_sec * NSECS_PER_SEC + tv_usec * 1000ull;
 }
 
 /*
-- 
2.40.0

  reply	other threads:[~2023-11-20  8:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  8:24 [igt-dev] [i-g-t 0/2] New subtest for CMRR Bhanuprakash Modem
2023-11-20  8:24 ` Bhanuprakash Modem [this message]
2023-11-20  8:24 ` [igt-dev] [i-g-t 2/2] tests/kms_vrr: " Bhanuprakash Modem
2024-06-03  8:48   ` Golani, Mitulkumar Ajitkumar
2024-06-06 12:01   ` [i-g-t V2 " Bhanuprakash Modem
2023-11-20 14:07 ` [igt-dev] ✓ CI.xeBAT: success for " Patchwork
2024-06-03  7:12 ` ✗ Fi.CI.BUILD: failure for New subtest for CMRR (rev2) Patchwork
2024-06-06 13:04 ` ✓ CI.xeBAT: success for New subtest for CMRR (rev3) Patchwork
2024-06-06 13:05 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-06-06 18:12 ` ✗ CI.xeFULL: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231120082459.1859375-2-bhanuprakash.modem@intel.com \
    --to=bhanuprakash.modem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=mitulkumar.ajitkumar.golani@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox