summaryrefslogtreecommitdiff
path: root/src/fb.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2017-12-31 11:27:15 -0800
committerVito Caputo <vcaputo@pengaru.com>2017-12-31 11:27:15 -0800
commit0b7361bb55d91b49dea75dd332294c6b75c501e7 (patch)
tree117b367d2353e5e44143faace3d1fef95fd92db4 /src/fb.c
parentda7171d994d66198682a50f05954b629eb6fb4e4 (diff)
fb: combine page flip with wait
Tidying this up a bit in preparation of ripping out all drm-specific stuff from fb.[ch]. Future commits will refactor fb.c to utilize an fb_ops_t for hooks to allocate, flip, and free pages.
Diffstat (limited to 'src/fb.c')
-rw-r--r--src/fb.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/fb.c b/src/fb.c
index 88095e2..03978a4 100644
--- a/src/fb.c
+++ b/src/fb.c
@@ -86,15 +86,19 @@ typedef struct fb_t {
#endif
-/* Synchronize with the page flip by waiting for its event. */
-static inline void fb_drm_flip_wait(fb_t *fb)
+/* Synchronously page flip to page */
+static int fb_flip_page_sync(fb_t *fb, _fb_page_t *page)
{
drmEventContext drm_ev_ctx = {
.version = DRM_EVENT_CONTEXT_VERSION,
.vblank_handler = NULL,
.page_flip_handler = NULL
};
- drmHandleEvent(fb->drm_fd, &drm_ev_ctx);
+
+ if (drmModePageFlip(fb->drm_fd, fb->drm_crtc_id, page->drm_fb_id, DRM_MODE_PAGE_FLIP_EVENT, NULL) < 0)
+ return -1;
+
+ return drmHandleEvent(fb->drm_fd, &drm_ev_ctx);
}
@@ -121,9 +125,8 @@ static void * fb_flipper_thread(void *_fb)
pthread_mutex_unlock(&fb->ready_mutex);
/* submit the next active page for page flip on vsync, and wait for it. */
- pexit_if(drmModePageFlip(fb->drm_fd, fb->drm_crtc_id, next_active_page->drm_fb_id, DRM_MODE_PAGE_FLIP_EVENT, NULL) < 0,
+ pexit_if(fb_flip_page_sync(fb, next_active_page) < 0,
"unable to flip page");
- fb_drm_flip_wait(fb);
/* now that we're displaying a new page, make the previously active one inactive so rendering can reuse it */
pthread_mutex_lock(&fb->inactive_mutex);
© All Rights Reserved