From d24ff64079c5c58da459d6b8177a180357f75f75 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Tue, 24 Sep 2013 17:03:33 +0200 Subject: bgi: wait before flipping Signed-off-by: Michael Olbrich --- src/bgi.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/bgi.c b/src/bgi.c index bfabfa5..78f1dfd 100644 --- a/src/bgi.c +++ b/src/bgi.c @@ -20,6 +20,7 @@ static struct kms_fb *fb3d; static int crtc3d; +static int can_wait; int do_wait_vblank; static struct fb_fix_screeninfo fix = { @@ -106,6 +107,11 @@ static int wait_vblank(void) struct timeval timeout = { .tv_sec = 0, .tv_usec = 200000 }; fd_set fds; + if (!can_wait) + return 0; + + can_wait = 0; + FD_ZERO(&fds); FD_SET(drmfd, &fds); ret = select(drmfd + 1, &fds, NULL, NULL, &timeout); @@ -159,18 +165,20 @@ static void do_pageflip(unsigned int offset) return; } + if (do_wait_vblank) + wait_vblank(); + flip.fb_id = fb_id; flip.crtc_id = crtc3d; - flip.flags = DRM_MODE_PAGE_FLIP_EVENT; + flip.flags = can_wait ? 0 : DRM_MODE_PAGE_FLIP_EVENT; flip.reserved = 0; ret = ioctl(drmfd, DRM_IOCTL_MODE_PAGE_FLIP, &flip); if (ret) { pr_err("page flip failed: %s\n", strerror(errno)); + return; } - - if (do_wait_vblank) - wait_vblank(); + can_wait = 1; } static void fbdev_ioctl(fuse_req_t req, int cmd, void *arg, @@ -246,6 +254,7 @@ int bgi_init(struct kms_fb *fb, int crtc) fb3d = fb; crtc3d = crtc; + can_wait = 0; fix.smem_start = fb->phys; fix.smem_len = fb->pitch * fb->yres * 3; -- cgit v1.2.3