summaryrefslogtreecommitdiff
path: root/tests/kms_vblank.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2015-04-06 10:37:41 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2015-04-06 10:44:46 +0100
commita6c3b32622d3d1cd2f3cb67255cd006b99d3fabb (patch)
tree5651ca953a79e687aa29d6f46100715604bc0952 /tests/kms_vblank.c
parent43a1f64e7222e9b5a8d7cb2b887002a8b539452e (diff)
igt/kms_vblank: Simple accuracy test
Queue 60 event to arrive at the same vblank from different points in time and make sure it just works. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/kms_vblank.c')
-rw-r--r--tests/kms_vblank.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index 03db6fd5..69461771 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c
@@ -67,6 +67,40 @@ static bool crtc0_active(int fd)
return drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl) == 0;
}
+static void accuracy(int fd)
+{
+ union drm_wait_vblank vbl;
+ unsigned long target;
+ int n;
+
+ memset(&vbl, 0, sizeof(vbl));
+
+ vbl.request.type = DRM_VBLANK_RELATIVE;
+ vbl.request.sequence = 1;
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
+
+ target = vbl.reply.sequence + 60;
+ for (n = 0; n < 60; n++) {
+ vbl.request.type = DRM_VBLANK_RELATIVE;
+ vbl.request.sequence = 1;
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
+
+ vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
+ vbl.request.sequence = target;
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
+ }
+ vbl.request.type = DRM_VBLANK_RELATIVE;
+ vbl.request.sequence = 0;
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
+ igt_assert_eq(vbl.reply.sequence, target);
+
+ for (n = 0; n < 60; n++) {
+ struct drm_event_vblank ev;
+ igt_assert_eq(read(fd, &ev, sizeof(ev)), sizeof(ev));
+ igt_assert_eq(ev.sequence, target);
+ }
+}
+
static void vblank_query(int fd, bool busy)
{
union drm_wait_vblank vbl;
@@ -79,12 +113,12 @@ static void vblank_query(int fd, bool busy)
if (busy) {
vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT;
vbl.request.sequence = 72;
- do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl));
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
}
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.sequence = 0;
- do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl));
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
sq = vbl.reply.sequence;
@@ -92,7 +126,7 @@ static void vblank_query(int fd, bool busy)
do {
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.sequence = 0;
- do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl));
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
count++;
} while ((vbl.reply.sequence - sq) <= 60);
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -116,12 +150,12 @@ static void vblank_wait(int fd, bool busy)
if (busy) {
vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT;
vbl.request.sequence = 72;
- do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl));
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
}
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.sequence = 0;
- do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl));
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
sq = vbl.reply.sequence;
@@ -129,7 +163,7 @@ static void vblank_wait(int fd, bool busy)
do {
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.sequence = 1;
- do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl));
+ do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
count++;
} while ((vbl.reply.sequence - sq) <= 60);
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -154,6 +188,9 @@ igt_main
igt_require(crtc0_active(fd));
}
+ igt_subtest("accuracy")
+ accuracy(fd);
+
igt_subtest("query-idle")
vblank_query(fd, false);