kms_flip: Hook up primary events for page-flips

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-08-29 16:43:18 +01:00
parent 1f2b3e99f9
commit 865b7821e3

View File

@ -132,6 +132,7 @@ struct test_output {
struct event_state flip_state; struct event_state flip_state;
struct event_state vblank_state; struct event_state vblank_state;
unsigned int pending_events; 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; int n, ret = 0;
for (n = 0; n < o->count; n++) { o->flip_count = 0;
ret = drmModePageFlip(drm_fd, o->_crtc[n], fb_id, event ? DRM_MODE_PAGE_FLIP_EVENT : 0,
event ? o : NULL); for (n = 0; ret == 0 && n < o->count; n++)
if (ret == 0 && event) ret = drmModePageFlip(drm_fd, o->_crtc[n], fb_id,
set_flag(&o->pending_events, EVENT_FLIP); 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; 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, static void page_flip_handler(int fd, unsigned int frame, unsigned int sec,
unsigned int usec, void *data) 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); if (++o->flip_count == o->count)
event_handler(&o->flip_state, frame, sec, usec); 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) 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_ZERO(&fds);
FD_SET(drm_fd, &fds); FD_SET(drm_fd, &fds);
do { do {
ret = select(drm_fd + 1, &fds, NULL, NULL, &timeout); do {
} while (ret < 0 && errno == EINTR); ret = select(drm_fd + 1, &fds, NULL, NULL, &timeout);
} while (ret < 0 && errno == EINTR);
if (ret <= 0) { if (ret <= 0) {
fprintf(stderr, "select timed out or error (ret %d)\n", fprintf(stderr, "select timed out or error (ret %d)\n",
ret); ret);
igt_fail(1); igt_fail(1);
} else if (FD_ISSET(0, &fds)) { } else if (FD_ISSET(0, &fds)) {
fprintf(stderr, "no fds active, breaking\n"); fprintf(stderr, "no fds active, breaking\n");
igt_fail(2); 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; event_mask ^= o->pending_events;
igt_assert(event_mask); igt_assert(event_mask);