summaryrefslogtreecommitdiffstats
path: root/src/egl/main/egldriver.c
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2010-05-13 16:06:29 -0400
committerKristian Høgsberg <[email protected]>2010-05-13 16:14:07 -0400
commit681fd73f1e95d43425b946a250b241bfdb0ce1c8 (patch)
treef0cfdd275af6b83be85c8eedbfd4bc04cac28c9f /src/egl/main/egldriver.c
parent7413d9ae9ff3e21f517aea97d7a1a211867bdc68 (diff)
egl: Allow a prioritized list of default drivers
When there is no user driver or any matching display drivers we fall back to the default driver. This patch lets us have a list of default drivers instead of just one. The drivers are loaded in turn and we attempt to initialize the display. If it fails we unload the driver and move on to the next one. Compared to the display driver mechanism, this avoids loading a number of drivers and then only using one. Also, we call Initialize to see if the driver will work instead of relying on Probe. To know for sure that a driver will work, Probe really have to do a full Initialize, so we will just use Initialize directly.
Diffstat (limited to 'src/egl/main/egldriver.c')
-rw-r--r--src/egl/main/egldriver.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 2913ce2ece9..566554d51dc 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -36,7 +36,9 @@
/* XXX Need to decide how to do dynamic name lookup on Windows */
-static const char DefaultDriverName[] = "TBD";
+static const char DefaultDriverNames[] = {
+ "TBD",
+};
typedef HMODULE lib_handle;
@@ -63,7 +65,10 @@ library_suffix(void)
#elif defined(_EGL_PLATFORM_POSIX)
-static const char DefaultDriverName[] = "egl_glx";
+static const char *DefaultDriverNames[] = {
+ "egl_dri2",
+ "egl_glx"
+};
typedef void * lib_handle;
@@ -488,17 +493,6 @@ _eglPreloadDisplayDrivers(void)
/**
- * Preload the default driver.
- */
-static EGLBoolean
-_eglPreloadDefaultDriver(void)
-{
- return (_eglPreloadForEach(_eglGetSearchPath(),
- _eglLoaderFile, (void *) DefaultDriverName) > 0);
-}
-
-
-/**
* Preload drivers.
*
* This function loads the driver modules and creates the corresponding
@@ -519,15 +513,13 @@ _eglPreloadDrivers(void)
}
loaded = (_eglPreloadUserDriver() ||
- _eglPreloadDisplayDrivers() ||
- _eglPreloadDefaultDriver());
+ _eglPreloadDisplayDrivers());
_eglUnlockMutex(_eglGlobal.Mutex);
return loaded;
}
-
/**
* Unload preloaded drivers.
*/
@@ -558,6 +550,30 @@ _eglUnloadDrivers(void)
_eglGlobal.NumDrivers = 0;
}
+_EGLDriver *
+_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+ _EGLDriver *drv = NULL;
+ int i;
+
+ _eglLockMutex(_eglGlobal.Mutex);
+
+ for (i = 0; i < ARRAY_SIZE(DefaultDriverNames); i++) {
+ _eglPreloadForEach(_eglGetSearchPath(),
+ _eglLoaderFile, (void *) DefaultDriverNames[i]);
+ if (_eglGlobal.NumDrivers == 0)
+ continue;
+ drv = _eglGlobal.Drivers[0];
+ if (drv->API.Initialize(drv, dpy, major, minor))
+ break;
+ _eglUnloadDrivers();
+ }
+
+ _eglUnlockMutex(_eglGlobal.Mutex);
+
+ return drv;
+}
+
/**
* Plug all the available fallback routines into the given driver's