summaryrefslogtreecommitdiff
path: root/src/egl/main/egldisplay.c
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-06-17 23:45:41 +0800
committerChia-I Wu <olv@lunarg.com>2010-06-29 17:16:19 +0800
commitea05299ce54ea0463626277907cab8e849884740 (patch)
tree427d55a566a49372dfe259bcdd6de3dabad900ad /src/egl/main/egldisplay.c
parentf66a4e20c19d55005854bbee312947ec16e287e3 (diff)
st/egl: One driver per hardware.
Merge multiple egl_<platform>_<pipe>.so into a single egl_gallium_<pipe>.so. The environment variable EGL_PLATFORM is now used to modify the return value of _eglGetNativePlatform.
Diffstat (limited to 'src/egl/main/egldisplay.c')
-rw-r--r--src/egl/main/egldisplay.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index d666bdabe0..9980356c4a 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -15,6 +15,62 @@
/**
+ * Return the native platform by parsing EGL_PLATFORM.
+ */
+static _EGLPlatformType
+_eglGetNativePlatformFromEnv(void)
+{
+ /* map --with-egl-platforms names to platform types */
+ static const struct {
+ _EGLPlatformType platform;
+ const char *name;
+ } egl_platforms[_EGL_NUM_PLATFORMS] = {
+ { _EGL_PLATFORM_WINDOWS, "gdi" },
+ { _EGL_PLATFORM_X11, "x11" },
+ { _EGL_PLATFORM_DRM, "kms" },
+ { _EGL_PLATFORM_FBDEV, "fbdev" }
+ };
+ _EGLPlatformType plat = _EGL_INVALID_PLATFORM;
+ const char *plat_name;
+ EGLint i;
+
+ plat_name = getenv("EGL_PLATFORM");
+ /* try deprecated env variable */
+ if (!plat_name || !plat_name[0])
+ plat_name = getenv("EGL_DISPLAY");
+ if (!plat_name || !plat_name[0])
+ return _EGL_INVALID_PLATFORM;
+
+ for (i = 0; i < _EGL_NUM_PLATFORMS; i++) {
+ if (strcmp(egl_platforms[i].name, plat_name) == 0) {
+ plat = egl_platforms[i].platform;
+ break;
+ }
+ }
+
+ return plat;
+}
+
+
+/**
+ * Return the native platform. It is the platform of the EGL native types.
+ */
+_EGLPlatformType
+_eglGetNativePlatform(void)
+{
+ static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
+
+ if (native_platform == _EGL_INVALID_PLATFORM) {
+ native_platform = _eglGetNativePlatformFromEnv();
+ if (native_platform == _EGL_INVALID_PLATFORM)
+ native_platform = _EGL_NATIVE_PLATFORM;
+ }
+
+ return native_platform;
+}
+
+
+/**
* Finish display management.
*/
void