summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMika Kahola <mika.kahola@intel.com>2018-05-23 14:47:37 +0300
committerMika Kahola <mika.kahola@intel.com>2018-05-24 10:14:09 +0300
commit4d0920216bfbfe96a95c62eb6b04190c72aedeab (patch)
tree808b074a438404561c3c4b2cdde899e6129065df /lib
parent71c7a5740913d2618f44bca252669efe8a84f4c9 (diff)
tests: Move wait_for_pageflip as library function
Two tests uses the very same wait_for_pageflip() routine. These tests are 'kms_rotation_crc' and 'kms_flip_tiling'. In order to decrease code repetition, let's move this function as part of kms function collection in igt_kms. No functional changes. Signed-off-by: Mika Kahola <mika.kahola@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_kms.c24
-rw-r--r--lib/igt_kms.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 0cee0c06..0438f641 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1458,6 +1458,30 @@ unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags)
return vbl.reply.sequence;
}
+/**
+ * kmstest_wait_for_pageflip:
+ * @fd: Opened drm file descriptor
+ *
+ * Blocks until pageflip is completed
+ *
+ */
+void kmstest_wait_for_pageflip(int fd)
+{
+ drmEventContext evctx = { .version = 2 };
+ struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
+ fd_set fds;
+ int ret;
+
+ /* Wait for pageflip completion, then consume event on fd */
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ do {
+ ret = select(fd + 1, &fds, NULL, NULL, &timeout);
+ } while (ret < 0 && errno == EINTR);
+ igt_assert_eq(ret, 1);
+ igt_assert(drmHandleEvent(fd, &evctx) == 0);
+}
+
static void get_plane(char *str, int type, struct kmstest_plane *plane)
{
int ret;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 0e75d0c9..45252388 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -222,6 +222,7 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
unsigned prot);
+void kmstest_wait_for_pageflip(int fd);
unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility);