From 1943b8e544a985e08cd4fbe2ae79320fed2f2548 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 9 Aug 2010 11:29:03 +0100 Subject: [PATCH] glx: Depend on libdrm DRM is available on more platforms than Linux (e.g. kFreeBSD), but Clutter currently FTBFS there because of not being an alternative to the __linux__ code (where it should be HAVE_DRM). Instead of copying the DRM data structures, we should use libdrm when falling back to directly requesting to wait for the vblank. http://bugzilla.clutter-project.org/show_bug.cgi?id=2225 Based on a patch by: Emilio Pozuelo Monfort Signed-off-by: Emmanuele Bassi --- clutter/glx/clutter-stage-glx.c | 43 +++++++++------------------------ configure.ac | 8 ++++++ 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/clutter/glx/clutter-stage-glx.c b/clutter/glx/clutter-stage-glx.c index 42e488e90..06010da58 100644 --- a/clutter/glx/clutter-stage-glx.c +++ b/clutter/glx/clutter-stage-glx.c @@ -53,32 +53,9 @@ #include #include -#ifdef __linux__ -#define DRM_VBLANK_RELATIVE 0x1; - -struct drm_wait_vblank_request { - int type; - unsigned int sequence; - unsigned long signal; -}; - -struct drm_wait_vblank_reply { - int type; - unsigned int sequence; - long tval_sec; - long tval_usec; -}; - -typedef union drm_wait_vblank { - struct drm_wait_vblank_request request; - struct drm_wait_vblank_reply reply; -} drm_wait_vblank_t; - -#define DRM_IOCTL_BASE 'd' -#define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type) -#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, drm_wait_vblank_t) - -#endif /* __linux__ */ +#ifdef HAVE_DRM +#include +#endif static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface); @@ -462,7 +439,7 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface) /* the rest is inherited from ClutterStageX11 */ } -#ifdef __linux__ +#ifdef HAVE_DRM static int drm_wait_vblank(int fd, drm_wait_vblank_t *vbl) { @@ -471,14 +448,14 @@ drm_wait_vblank(int fd, drm_wait_vblank_t *vbl) do { ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl); - vbl->request.type &= ~DRM_VBLANK_RELATIVE; + vbl->request.type &= ~_DRM_VBLANK_RELATIVE; rc = errno; } while (ret && rc == EINTR); return rc; } -#endif /* __linux__ */ +#endif /* HAVE_DRM */ static void wait_for_vblank (ClutterBackendGLX *backend_glx) @@ -496,18 +473,20 @@ wait_for_vblank (ClutterBackendGLX *backend_glx) (retraceCount + 1) % 2, &retraceCount); } -#ifdef __linux__ else { +#ifdef HAVE_DRM drm_wait_vblank_t blank; CLUTTER_NOTE (BACKEND, "Waiting for vblank (drm)"); - blank.request.type = DRM_VBLANK_RELATIVE; + blank.request.type = _DRM_VBLANK_RELATIVE; blank.request.sequence = 1; blank.request.signal = 0; drm_wait_vblank (backend_glx->dri_fd, &blank); +#else + CLUTTER_NOTE (BACKEND, "No vblank mechanism found"); +#endif /* HAVE_DRM */ } -#endif } void diff --git a/configure.ac b/configure.ac index 4a124b62d..0e7a92996 100644 --- a/configure.ac +++ b/configure.ac @@ -180,6 +180,14 @@ AS_CASE([$CLUTTER_FLAVOUR], # if a pkg-config file isn't found just add -lGL # and hope for the best. [FLAVOUR_LIBS="$FLAVOUR_LIBS -lGL"]) + + # We might fall back to DRM for sync-to-vblank on GLX + PKG_CHECK_EXISTS([libdrm], + [ + AC_DEFINE([HAVE_DRM], [1], [Have libdrm support]) + BACKEND_PC_FILES="$BACKEND_PC_FILES libdrm" + ], + []) ], [opengl-egl-xlib],