summaryrefslogtreecommitdiffstats
path: root/src/gbm
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-11-15 13:54:49 -0800
committerEric Anholt <[email protected]>2018-11-16 17:49:17 -0800
commitd971a4230d54069c996bca78b6ed6a6a23377821 (patch)
tree2d9c29c0c0df5405a0bad5b2c7860bcc614069a2 /src/gbm
parentcc198157382a988590b0288d287281139c5f73e6 (diff)
loader: Factor out the common driver opening logic from each loader.
I copied the code from egl_dri2.c, but the functionality was equivalent between all the loaders other than their particular environment variables. v2: Drop the logging function equivalent to loader_default_logger() (requested by Eric, Emil). Move the SCons workaround across. Drop the now-unused driGetDriverExtensions() declaration that was lost in a rebase. Reviewed-by: Eric Engestrom <[email protected]> (v1) Reviewed-by: Emil Velikov <[email protected]> (v1)
Diffstat (limited to 'src/gbm')
-rw-r--r--src/gbm/Makefile.am1
-rw-r--r--src/gbm/backends/dri/gbm_dri.c84
-rw-r--r--src/gbm/meson.build1
3 files changed, 12 insertions, 74 deletions
diff --git a/src/gbm/Makefile.am b/src/gbm/Makefile.am
index 5097212cda0..bb246ecebf5 100644
--- a/src/gbm/Makefile.am
+++ b/src/gbm/Makefile.am
@@ -42,7 +42,6 @@ libgbm_la_SOURCES += \
$(gbm_dri_FILES)
AM_CFLAGS += \
- -DDEFAULT_DRIVER_DIR='"$(DRI_DRIVER_SEARCH_DIR)"' \
$(LIBDRM_CFLAGS) \
$(PTHREADSTUBS_CFLAGS)
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index f32c0cd9885..aeb13962cdc 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -304,28 +304,6 @@ dri_bind_extensions(struct gbm_dri_device *dri,
static const __DRIextension **
dri_open_driver(struct gbm_dri_device *dri)
{
- const __DRIextension **extensions = NULL;
- char path[PATH_MAX], *search_paths, *p, *next, *end;
- char *get_extensions_name;
-
- search_paths = NULL;
- /* don't allow setuid apps to use LIBGL_DRIVERS_PATH or GBM_DRIVERS_PATH */
- if (geteuid() == getuid()) {
- /* Read GBM_DRIVERS_PATH first for compatibility, but LIBGL_DRIVERS_PATH
- * is recommended over GBM_DRIVERS_PATH.
- */
- search_paths = getenv("GBM_DRIVERS_PATH");
-
- /* Read LIBGL_DRIVERS_PATH if GBM_DRIVERS_PATH was not set.
- * LIBGL_DRIVERS_PATH is recommended over GBM_DRIVERS_PATH.
- */
- if (search_paths == NULL) {
- search_paths = getenv("LIBGL_DRIVERS_PATH");
- }
- }
- if (search_paths == NULL)
- search_paths = DEFAULT_DRIVER_DIR;
-
/* Temporarily work around dri driver libs that need symbols in libglapi
* but don't automatically link it in.
*/
@@ -334,56 +312,18 @@ dri_open_driver(struct gbm_dri_device *dri)
*/
dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL);
- dri->driver = NULL;
- end = search_paths + strlen(search_paths);
- for (p = search_paths; p < end && dri->driver == NULL; p = next + 1) {
- int len;
- next = strchr(p, ':');
- if (next == NULL)
- next = end;
-
- len = next - p;
-#if GLX_USE_TLS
- snprintf(path, sizeof path,
- "%.*s/tls/%s_dri.so", len, p, dri->driver_name);
- dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
-#endif
- if (dri->driver == NULL) {
- snprintf(path, sizeof path,
- "%.*s/%s_dri.so", len, p, dri->driver_name);
- dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
- }
- /* not need continue to loop all paths once the driver is found */
- if (dri->driver != NULL)
- break;
- }
-
- if (dri->driver == NULL) {
- fprintf(stderr, "gbm: failed to open any driver (search paths %s)\n",
- search_paths);
- fprintf(stderr, "gbm: Last dlopen error: %s\n", dlerror());
- return NULL;
- }
-
- get_extensions_name = loader_get_extensions_name(dri->driver_name);
- if (get_extensions_name) {
- const __DRIextension **(*get_extensions)(void);
-
- get_extensions = dlsym(dri->driver, get_extensions_name);
- free(get_extensions_name);
-
- if (get_extensions)
- extensions = get_extensions();
- }
-
- if (!extensions)
- extensions = dlsym(dri->driver, __DRI_DRIVER_EXTENSIONS);
- if (extensions == NULL) {
- fprintf(stderr, "gbm: driver exports no extensions (%s)", dlerror());
- dlclose(dri->driver);
- }
-
- return extensions;
+ static const char *search_path_vars[] = {
+ /* Read GBM_DRIVERS_PATH first for compatibility, but LIBGL_DRIVERS_PATH
+ * is recommended over GBM_DRIVERS_PATH.
+ */
+ "GBM_DRIVERS_PATH"
+ /* Read LIBGL_DRIVERS_PATH if GBM_DRIVERS_PATH was not set.
+ * LIBGL_DRIVERS_PATH is recommended over GBM_DRIVERS_PATH.
+ */
+ "LIBGL_DRIVERS_PATH",
+ NULL
+ };
+ return loader_open_driver(dri->driver_name, &dri->driver, search_path_vars);
}
static int
diff --git a/src/gbm/meson.build b/src/gbm/meson.build
index 719f9c1a9b8..007f50a9ae3 100644
--- a/src/gbm/meson.build
+++ b/src/gbm/meson.build
@@ -37,7 +37,6 @@ incs_gbm = [
if with_dri2
files_gbm += files('backends/dri/gbm_dri.c', 'backends/dri/gbm_driint.h')
deps_gbm += dep_libdrm # TODO: pthread-stubs
- args_gbm += '-DDEFAULT_DRIVER_DIR="@0@"'.format(dri_search_path)
endif
if with_platform_wayland
deps_gbm += dep_wayland_server