diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-29 16:43:18 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-29 17:41:01 +0100 |
commit | 865b7821e37dbca4cc0c2ff6f91236c09e91b26b (patch) | |
tree | d138db77630465e72dbc46419b4cce72f36bf736 | |
parent | 1f2b3e99f9349dbc34750d506312b6eb353c14a4 (diff) |
kms_flip: Hook up primary events for page-flips
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | tests/kms_flip.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 6eb13d55..965b44c2 100644 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -132,6 +132,7 @@ struct test_output { struct event_state flip_state; struct event_state vblank_state; unsigned int pending_events; + int flip_count; }; @@ -301,12 +302,15 @@ static int do_page_flip(struct test_output *o, int fb_id, bool event) { int n, ret = 0; - for (n = 0; n < o->count; n++) { - ret = drmModePageFlip(drm_fd, o->_crtc[n], fb_id, event ? DRM_MODE_PAGE_FLIP_EVENT : 0, - event ? o : NULL); - if (ret == 0 && event) - set_flag(&o->pending_events, EVENT_FLIP); - } + o->flip_count = 0; + + for (n = 0; ret == 0 && n < o->count; n++) + ret = drmModePageFlip(drm_fd, o->_crtc[n], fb_id, + event ? DRM_MODE_PAGE_FLIP_EVENT : 0, + event ? (void *)((unsigned long)o | (n==0)) : NULL); + + if (ret == 0 && event) + set_flag(&o->pending_events, EVENT_FLIP); return ret; } @@ -401,10 +405,13 @@ static void event_handler(struct event_state *es, unsigned int frame, static void page_flip_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) { - struct test_output *o = data; + int primary = (unsigned long)data & 1; + struct test_output *o = (void *)((unsigned long)data & ~ 1); - clear_flag(&o->pending_events, EVENT_FLIP); - event_handler(&o->flip_state, frame, sec, usec); + if (++o->flip_count == o->count) + clear_flag(&o->pending_events, EVENT_FLIP); + if (primary) + event_handler(&o->flip_state, frame, sec, usec); } static double frame_time(struct test_output *o) @@ -1063,19 +1070,21 @@ static unsigned int wait_for_events(struct test_output *o) FD_ZERO(&fds); FD_SET(drm_fd, &fds); do { - ret = select(drm_fd + 1, &fds, NULL, NULL, &timeout); - } while (ret < 0 && errno == EINTR); + do { + ret = select(drm_fd + 1, &fds, NULL, NULL, &timeout); + } while (ret < 0 && errno == EINTR); - if (ret <= 0) { - fprintf(stderr, "select timed out or error (ret %d)\n", + if (ret <= 0) { + fprintf(stderr, "select timed out or error (ret %d)\n", ret); - igt_fail(1); - } else if (FD_ISSET(0, &fds)) { - fprintf(stderr, "no fds active, breaking\n"); - igt_fail(2); - } + igt_fail(1); + } else if (FD_ISSET(0, &fds)) { + fprintf(stderr, "no fds active, breaking\n"); + igt_fail(2); + } - do_or_die(drmHandleEvent(drm_fd, &evctx)); + do_or_die(drmHandleEvent(drm_fd, &evctx)); + } while (o->pending_events); event_mask ^= o->pending_events; igt_assert(event_mask); |