summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2012-07-13 11:15:25 +0200
committerMichel Dänzer <michel@daenzer.net>2012-07-13 11:15:25 +0200
commit6ef1ad6a46348d3aecd8d1f5e94431ca2298853c (patch)
treeec19a154ec7a0b5d8393d6b8556eb600b04a21be
parentef8a404391036d8aa814dbda2407c789b8a64b92 (diff)
Deal more gracefully with DRI2 being unavailable at build or run time.
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
-rw-r--r--src/radeon_dri2.c12
-rw-r--r--src/radeon_dri2.h43
-rw-r--r--src/radeon_glamor.c3
-rw-r--r--src/radeon_kms.c5
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) {