diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/radeon_dri2.c | 12 | ||||
-rw-r--r-- | src/radeon_dri2.h | 43 | ||||
-rw-r--r-- | src/radeon_glamor.c | 3 | ||||
-rw-r--r-- | src/radeon_kms.c | 5 |
4 files changed, 61 insertions, 2 deletions
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index e16d5517..92241c7a 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -29,13 +29,16 @@ #include "config.h" #endif +#include "radeon.h" +#include "radeon_dri2.h" + +#ifdef DRI2 + #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> -#include "radeon.h" -#include "radeon_dri2.h" #include "radeon_version.h" #if HAVE_LIST_H @@ -1398,6 +1401,9 @@ radeon_dri2_screen_init(ScreenPtr pScreen) Bool scheduling_works = TRUE; #endif + if (!info->dri2.available) + return FALSE; + info->dri2.device_name = drmGetDeviceNameFromFd(info->dri2.drm_fd); if ( (info->ChipFamily >= CHIP_FAMILY_TAHITI) ) { @@ -1502,3 +1508,5 @@ void radeon_dri2_close_screen(ScreenPtr pScreen) drmFree(info->dri2.device_name); } +#endif /* DRI2 */ + diff --git a/src/radeon_dri2.h b/src/radeon_dri2.h index 0dd2a33c..aaad0ca9 100644 --- a/src/radeon_dri2.h +++ b/src/radeon_dri2.h @@ -27,13 +27,18 @@ #ifndef RADEON_DRI2_H #define RADEON_DRI2_H +#include <xorg-server.h> + struct radeon_dri2 { drmVersionPtr pKernelDRMVersion; int drm_fd; + Bool available; Bool enabled; char *device_name; }; +#ifdef DRI2 + #include "dri2.h" Bool radeon_dri2_screen_init(ScreenPtr pScreen); void radeon_dri2_close_screen(ScreenPtr pScreen); @@ -46,4 +51,42 @@ void radeon_dri2_frame_event_handler(unsigned int frame, unsigned int tv_sec, void radeon_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec, unsigned int tv_usec, void *event_data); +#else + +static inline Bool radeon_dri2_screen_init(ScreenPtr pScreen) { return FALSE; } +static inline void radeon_dri2_close_screen(ScreenPtr pScreen) {} + +static inline void +radeon_dri2_dummy_event_handler(unsigned int frame, unsigned int tv_sec, + unsigned int tv_usec, void *event_data, + const char *name) +{ + static Bool warned; + + if (!warned) { + ErrorF("%s called but DRI2 disabled at build time\n", name); + warned = TRUE; + } + + free(event_data); +} + +static inline void +radeon_dri2_frame_event_handler(unsigned int frame, unsigned int tv_sec, + unsigned int tv_usec, void *event_data) +{ + radeon_dri2_dummy_event_handler(frame, tv_sec, tv_usec, event_data, + __func__); +} + +static inline void +radeon_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec, + unsigned int tv_usec, void *event_data) +{ + radeon_dri2_dummy_event_handler(frame, tv_sec, tv_usec, event_data, + __func__); +} + #endif + +#endif /* RADEON_DRI2_H */ diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index 714dde9e..12dfd38c 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -83,6 +83,9 @@ radeon_glamor_pre_init(ScrnInfoPtr scrn) CARD32 version; const char *s; + if (!info->dri2.available) + return FALSE; + s = xf86GetOptValString(info->Options, OPTION_ACCELMETHOD); if (s == NULL) return FALSE; diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 5cc362f9..a4f46d79 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -425,6 +425,10 @@ shadowfb: return TRUE; } +#ifdef DRI2 + info->dri2.available = !!xf86LoadSubModule(pScrn, "dri2"); +#endif + if (radeon_glamor_pre_init(pScrn)) return TRUE; @@ -740,6 +744,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags) goto fail; } + info->dri2.available = FALSE; info->dri2.enabled = FALSE; info->dri2.pKernelDRMVersion = drmGetVersion(info->dri2.drm_fd); if (info->dri2.pKernelDRMVersion == NULL) { |