From 09e372cc9d7830c0f023015484d8b2caabc64cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Avi=20=D7=93?= Date: Fri, 21 Dec 2018 17:25:24 -0500 Subject: [PATCH] Fix vsync-drm --- src/vsync.c | 63 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/src/vsync.c b/src/vsync.c index fc1e612..4ea17d2 100644 --- a/src/vsync.c +++ b/src/vsync.c @@ -10,8 +10,44 @@ #include "opengl.h" #endif +#ifdef CONFIG_VSYNC_DRM +#include +#include +#include +#include +#include +#include +#endif + #include "vsync.h" +#ifdef CONFIG_VSYNC_DRM +/** + * Wait for next VSync, DRM method. + * + * Stolen from: https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/vsync.cpp + */ +static int +vsync_drm_wait(session_t *ps) { + int ret = -1; + drm_wait_vblank_t vbl; + + vbl.request.type = _DRM_VBLANK_RELATIVE, + vbl.request.sequence = 1; + + do { + ret = ioctl(ps->drm_fd, DRM_IOCTL_WAIT_VBLANK, &vbl); + vbl.request.type &= ~_DRM_VBLANK_RELATIVE; + } while (ret && errno == EINTR); + + if (ret) + log_error("VBlank ioctl did not work, unimplemented in this drmver?"); + + return ret; + +} +#endif + /** * Initialize DRM VSync. * @@ -168,33 +204,6 @@ bool (*const VSYNC_FUNCS_INIT[NUM_VSYNC])(session_t *ps) = { [VSYNC_OPENGL_MSWC ] = vsync_opengl_mswc_init, }; -#ifdef CONFIG_VSYNC_DRM -/** - * Wait for next VSync, DRM method. - * - * Stolen from: https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/vsync.cpp - */ -static int -vsync_drm_wait(session_t *ps) { - int ret = -1; - drm_wait_vblank_t vbl; - - vbl.request.type = _DRM_VBLANK_RELATIVE, - vbl.request.sequence = 1; - - do { - ret = ioctl(ps->drm_fd, DRM_IOCTL_WAIT_VBLANK, &vbl); - vbl.request.type &= ~_DRM_VBLANK_RELATIVE; - } while (ret && errno == EINTR); - - if (ret) - log_error("VBlank ioctl did not work, unimplemented in this drmver?"); - - return ret; - -} -#endif - #ifdef CONFIG_OPENGL /** * Wait for next VSync, OpenGL method.