diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-05-05 18:25:19 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-05-16 10:46:52 +0200 |
commit | 8633ac0279f9272f81aa99524aa078ca14e3da1e (patch) | |
tree | 1f1e0053a0c5a4372dbfc5ff01ec8e8869e13f60 | |
parent | cf40dc16fc449e7611d88cac18286261c50a683d (diff) |
wip
24 files changed, 396 insertions, 89 deletions
diff --git a/configs/default b/configs/default index 0582a0210a..d401bf6258 100644 --- a/configs/default +++ b/configs/default @@ -61,7 +61,7 @@ GLESv2_LIB = GLESv2 VG_LIB = OpenVG GLAPI_LIB = glapi WAYLAND_EGL_LIB = wayland-egl - +GBM_LIB = gbm # Library names (actual file names) GL_LIB_NAME = lib$(GL_LIB).so @@ -157,6 +157,9 @@ DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR) # EGL driver install directory EGL_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/egl +# gbm backend install directory +GBM_BACKEND_INSTALL_DIR = $(INSTALL_LIB_DIR)/gbm + # Xorg driver install directory (for xorg state-tracker) XORG_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/xorg/modules/drivers diff --git a/src/egl/drivers/dri2/Makefile b/src/egl/drivers/dri2/Makefile index 90888f2ee7..39b720a54e 100644 --- a/src/egl/drivers/dri2/Makefile +++ b/src/egl/drivers/dri2/Makefile @@ -13,6 +13,7 @@ EGL_INCLUDES = \ -I$(TOP)/src/egl/main \ -I$(TOP)/src/mapi \ -I$(TOP)/src/ \ + -I$(TOP)/src/gbm/main \ -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \ $(LIBUDEV_CFLAGS) \ $(LIBDRM_CFLAGS) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 6c9a832fdd..a29de1a60f 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -44,7 +44,7 @@ #include <GL/gl.h> #include <GL/internal/dri_interface.h> -#include <gbm/dri_internal.h> +#include <gbm/backends/dri/dri_internal.h> #include "eglconfig.h" #include "eglcontext.h" diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile index 7ced8d3c50..549b7aeba2 100644 --- a/src/gallium/state_trackers/egl/Makefile +++ b/src/gallium/state_trackers/egl/Makefile @@ -33,7 +33,7 @@ wayland_INCLUDES = \ wayland_SOURCES = $(wildcard wayland/*.c) wayland_OBJECTS = $(wayland_SOURCES:.c=.o) -drm_INCLUDES = -I$(TOP)/src/gallium/winsys $(shell pkg-config --cflags-only-I libdrm) -I$(TOP)/src/ +drm_INCLUDES = -I$(TOP)/src/gallium/winsys $(shell pkg-config --cflags-only-I libdrm) -I$(TOP)/src/ -I$(TOP)/src/gbm/main drm_SOURCES = $(wildcard drm/*.c) drm_OBJECTS = $(drm_SOURCES:.c=.o) diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c index 2773611c29..d386140336 100644 --- a/src/gallium/state_trackers/egl/drm/native_drm.c +++ b/src/gallium/state_trackers/egl/drm/native_drm.c @@ -33,7 +33,7 @@ #include "native_drm.h" -#include "gbm/gallium_drm_internal.h" +#include "gbm/backends/gallium_drm/gallium_drm_internal.h" #ifdef HAVE_LIBUDEV #include <libudev.h> diff --git a/src/gbm/Makefile b/src/gbm/Makefile index 0e8764a105..19543ec3be 100644 --- a/src/gbm/Makefile +++ b/src/gbm/Makefile @@ -1,84 +1,31 @@ -# src/egl/Makefile +# src/gbm/Makefile TOP = ../.. include $(TOP)/configs/current -PIPE_PREFIX := pipe_ +SUBDIRS = backends main -INCLUDE_DIRS = -I$(TOP)/include \ - -I$(TOP)/src/gallium/auxiliary \ - -I$(TOP)/src/gallium/include -HEADERS = \ - common.h \ - internal.h \ - gbm.h +default: subdirs -SOURCES = \ - api.c \ - common.c \ - dri.c \ - gallium_drm.c -OBJECTS = $(SOURCES:.c=.o) +subdirs: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1 ; \ + fi \ + done -# use dl*() to load drivers -LOCAL_CFLAGS = -D_OS_UNIX=1 $(LIBDRM_CFLAGS) $(LIBUDEV_CFLAGS) $(DLOPEN_CFLAGS) -LOCAL_LIBS = \ - $(TOP)/src/gallium/drivers/identity/libidentity.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/rbug/librbug.a \ - $(GALLIUM_AUXILIARIES) - -GBM_LIB_DEPS += $(LIBDRM_LIB) $(LIBUDEV_LIBS) $(DLOPEN_LIBS) - -LOCAL_CFLAGS += \ - -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \ - -D_EGL_GALLIUM_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" \ - -DPIPE_PREFIX=\"$(PIPE_PREFIX)\" - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ - - -default: depend library - - -library: $(TOP)/$(LIB_DIR)/libgbm.so - -$(TOP)/$(LIB_DIR)/libgbm.so: $(OBJECTS) $(LOCAL_LIBS) - $(MKLIB) -o gbm -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major 1 -minor 0 \ - -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ - -L$(TOP)/$(LIB_DIR) $(GBM_LIB_DEPS) \ - $(OBJECTS) $(LOCAL_LIBS) - -install-headers: - $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/ - $(INSTALL) -m 644 $(TOP)/src/gbm/gbm.h \ - $(DESTDIR)$(INSTALL_INC_DIR) - - -PKG_CONFIG_DIR = $(INSTALL_LIB_DIR)/pkgconfig - - -install: default install-headers - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(MINSTALL) $(TOP)/$(LIB_DIR)/libgbm.so* \ - $(DESTDIR)$(INSTALL_LIB_DIR) +install: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) install) || exit 1 ; \ + fi \ + done clean: - -rm -f *.o - -rm -f depend depend.bak - - -depend: $(SOURCES) $(HEADERS) - @ echo "running $(MKDEP)" - @ rm -f depend - @ touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ - $(SOURCES) $(HEADERS) > /dev/null 2>/dev/null - - --include depend -# DO NOT DELETE + -@for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) clean) ; \ + fi \ + done diff --git a/src/gbm/backends/Makefile b/src/gbm/backends/Makefile new file mode 100644 index 0000000000..994bbba878 --- /dev/null +++ b/src/gbm/backends/Makefile @@ -0,0 +1,32 @@ +# src/gbm/backends/Makefile + +TOP = ../../.. +include $(TOP)/configs/current + +# SUBDIRS = $(EGL_DRIVERS_DIRS) +SUBDIRS = dri gallium_drm + + +default: subdirs + + +subdirs: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir ; $(MAKE)) || exit 1 ; \ + fi \ + done + +install: + @ for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir ; $(MAKE) install) || exit 1 ; \ + fi \ + done + +clean: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir ; $(MAKE) clean) ; \ + fi \ + done diff --git a/src/gbm/backends/Makefile.template b/src/gbm/backends/Makefile.template new file mode 100644 index 0000000000..9df2ed930d --- /dev/null +++ b/src/gbm/backends/Makefile.template @@ -0,0 +1,66 @@ +# src/gbm/backends/Makefile.template +# +# Backends should define +# +# GBM_BUILTIN, the driver is built-in or external +# GBM_BACKEND, the driver name +# GBM_SOURCES, the driver sources +# GBM_INCLUDES, the include pathes +# GBM_CFLAGS, additional CFLAGS +# GBM_LIBS, additional LIBS +# +# before including this template. +# + + +GBM_BACKEND_PATH = $(TOP)/$(LIB_DIR)/gbm/$(GBM_BACKEND).so +GBM_OBJECTS = $(GBM_SOURCES:.c=.o) + +# built-in or external +ifeq ($(GBM_BUILTIN),true) +GBM_TARGET = lib$(GBM_BACKEND).a +GBM_INSTALL = +else +GBM_TARGET = $(GBM_BACKEND_PATH) +GBM_INSTALL = install-so +endif + +default: depend $(GBM_TARGET) + +$(GBM_BACKEND_PATH): $(GBM_BACKEND).so + @$(INSTALL) -d $(TOP)/$(LIB_DIR)/gbm + $(INSTALL) $< $(TOP)/$(LIB_DIR)/gbm + +$(GBM_BACKEND).so: $(GBM_OBJECTS) Makefile $(TOP)/src/gbm/backends/Makefile.template + @$(MKLIB) -o $(GBM_BACKEND).so -noprefix \ + -linker '$(CC)' -ldflags '-L$(TOP)/$(LIB_DIR) $(LDFLAGS)' \ + $(MKLIB_OPTIONS) \ + $(GBM_OBJECTS) $(GBM_LIBS) -l$(GBM_LIB) + +lib$(GBM_BACKEND).a: $(GBM_OBJECTS) Makefile $(TOP)/src/gbm/backends/Makefile.template + @$(MKLIB) -o $(GBM_BACKEND) -static $(GBM_OBJECTS) + +.c.o: + $(CC) -c $(GBM_INCLUDES) $(CFLAGS) $(GBM_CFLAGS) $< -o $@ + +install-so: $(GBM_BACKEND_PATH) + $(INSTALL) -d $(DESTDIR)$(GBM_BACKEND_INSTALL_DIR) + $(MINSTALL) $(GBM_BACKEND_PATH) $(DESTDIR)$(GBM_BACKEND_INSTALL_DIR) + +install: $(GBM_INSTALL) + +clean: + rm -f $(GBM_BACKEND).so + rm -f lib$(GBM_BACKEND).a + rm -f $(GBM_OBJECTS) + rm -f depend depend.bak + +depend: $(GBM_SOURCES) + @ echo "running $(MKDEP)" + @ rm -f depend + @ touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(GBM_INCLUDES) $(GBM_SOURCES) \ + >/dev/null 2>/dev/null + +sinclude depend +# DO NOT DELETE diff --git a/src/gbm/backends/dri/Makefile b/src/gbm/backends/dri/Makefile new file mode 100644 index 0000000000..e47b39b01e --- /dev/null +++ b/src/gbm/backends/dri/Makefile @@ -0,0 +1,28 @@ +# src/gbm/backends/dri/Makefile + +TOP = ../../../.. +include $(TOP)/configs/current + +GBM_BACKEND = gbm_dri +GBM_SOURCES = gbm_dri.c u_drm_screen.c + +GBM_INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/src/gbm/main \ + -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \ + $(LIBUDEV_CFLAGS) \ + $(LIBDRM_CFLAGS) + +# Includes for u_drm_screen.c +GBM_INCLUDES += \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/gallium/include + +GBM_LIBS = $(LIBUDEV_LIBS) $(LIBDRM_LIB) + +GBM_CFLAGS = +GBM_BUILTIN = +#GBM_CFLAGS = -D_GBM_MAIN=_eglBuiltInDriverDRI2 +#GBM_BUILTIN = true + +include ../Makefile.template diff --git a/src/gbm/dri_internal.h b/src/gbm/backends/dri/dri_internal.h index a065a3c416..a065a3c416 100644 --- a/src/gbm/dri_internal.h +++ b/src/gbm/backends/dri/dri_internal.h diff --git a/src/gbm/dri.c b/src/gbm/backends/dri/gbm_dri.c index a8c588a6ea..a2dd28c013 100644 --- a/src/gbm/dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -326,7 +326,7 @@ dri_destroy(struct gbm_device *gbm) free(dri); } -struct gbm_device * +static struct gbm_device * dri_device_create(int fd) { struct gbm_dri_device *dri; @@ -351,3 +351,28 @@ dri_device_create(int fd) return &dri->base.base; } + +static int +dri_probe(int fd) +{ + char *name; + int ret = 0; + + name = util_drm_fd_get_screen_name(fd); + if (name == NULL) { + ret = -1; + } else { + free(name); + ret = 0; + } + + return ret; +} + + +GBM_EXPORT struct gbm_backend gbm_backend = { + .class_name = "drm", + .backend_name = "dri", + .probe = dri_probe, + .create_device = dri_device_create, +}; diff --git a/src/gbm/backends/dri/u_drm_screen.c b/src/gbm/backends/dri/u_drm_screen.c new file mode 120000 index 0000000000..9e5413df97 --- /dev/null +++ b/src/gbm/backends/dri/u_drm_screen.c @@ -0,0 +1 @@ +../../../gallium/auxiliary/util/u_drm_screen.c
\ No newline at end of file diff --git a/src/gbm/backends/gallium_drm/Makefile b/src/gbm/backends/gallium_drm/Makefile new file mode 100644 index 0000000000..0459635f08 --- /dev/null +++ b/src/gbm/backends/gallium_drm/Makefile @@ -0,0 +1,33 @@ +# src/gbm/backends/gallium_drm/Makefile + +TOP = ../../../.. +include $(TOP)/configs/current + +PIPE_PREFIX := pipe_ + +GBM_BACKEND = gbm_gallium_drm +GBM_SOURCES = gbm_gallium_drm.c + +GBM_INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/src/gbm/main \ + $(LIBUDEV_CFLAGS) \ + $(LIBDRM_CFLAGS) + +GBM_INCLUDES += \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/gallium/include + +GBM_LIBS = $(LIBUDEV_LIBS) $(LIBDRM_LIB) \ + $(TOP)/src/gallium/drivers/identity/libidentity.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ + $(GALLIUM_AUXILIARIES) + + +GBM_CFLAGS = -D_EGL_GALLIUM_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" -DPIPE_PREFIX=\"$(PIPE_PREFIX)\" +GBM_BUILTIN = +#GBM_CFLAGS = -D_GBM_MAIN=_eglBuiltInDriverDRI2 +#GBM_BUILTIN = true + +include ../Makefile.template diff --git a/src/gbm/gallium_drm_internal.h b/src/gbm/backends/gallium_drm/gallium_drm_internal.h index 7f9bc081ae..7f9bc081ae 100644 --- a/src/gbm/gallium_drm_internal.h +++ b/src/gbm/backends/gallium_drm/gallium_drm_internal.h diff --git a/src/gbm/gallium_drm.c b/src/gbm/backends/gallium_drm/gbm_gallium_drm.c index 19bc6a9a14..6b3fb1e4a9 100644 --- a/src/gbm/gallium_drm.c +++ b/src/gbm/backends/gallium_drm/gbm_gallium_drm.c @@ -141,15 +141,6 @@ create_drm_screen(const char *name, int fd) pmod->drmdd->create_screen(fd) : NULL; } - - - - - - - - - static int gallium_screen_create(struct gbm_gallium_drm_device *gdrm) { @@ -329,13 +320,14 @@ gbm_gallium_drm_destroy(struct gbm_device *gbm) FREE(gdrm); } -struct gbm_device * +static struct gbm_device * gbm_gallium_drm_device_create(int fd) { struct gbm_gallium_drm_device *dri; int ret; dri = calloc(1, sizeof *dri); + printf("create g3d\n"); dri->base.base.fd = fd; dri->base.base.bo_create = gbm_gallium_drm_bo_create; @@ -355,3 +347,28 @@ gbm_gallium_drm_device_create(int fd) return &dri->base.base; } + +static int +gallium_drm_probe(int fd) +{ + char *name; + int ret = 0; + + name = util_drm_fd_get_screen_name(fd); + if (name == NULL) { + ret = -1; + } else { + free(name); + ret = 0; + } + + return ret; +} + + +GBM_EXPORT struct gbm_backend gbm_backend = { + .class_name = "drm", + .backend_name = "gallium", + .probe = gallium_drm_probe, + .create_device = gbm_gallium_drm_device_create, +}; diff --git a/src/gbm/main/Makefile b/src/gbm/main/Makefile new file mode 100644 index 0000000000..08877ef2b5 --- /dev/null +++ b/src/gbm/main/Makefile @@ -0,0 +1,71 @@ +# src/gbm/main/Makefile + +TOP = ../../.. +include $(TOP)/configs/current + +INCLUDE_DIRS = -I$(TOP)/include + +HEADERS = \ + common.h \ + module.h \ + internal.h \ + gbm.h + +SOURCES = \ + api.c \ + module.c \ + common.c + +OBJECTS = $(SOURCES:.c=.o) + +# use dl*() to load drivers +LOCAL_CFLAGS = -D_OS_UNIX=1 $(LIBUDEV_CFLAGS) $(DLOPEN_CFLAGS) -DMODULEDIR='"$(GBM_BACKEND_INSTALL_DIR)"' +LOCAL_LIBS = + +GBM_LIB_DEPS += $(LIBUDEV_LIBS) $(DLOPEN_LIBS) + +.c.o: + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ + + +default: depend library + + +library: $(TOP)/$(LIB_DIR)/libgbm.so + +$(TOP)/$(LIB_DIR)/libgbm.so: $(OBJECTS) $(LOCAL_LIBS) + $(MKLIB) -o gbm -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -major 1 -minor 0 \ + -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ + -L$(TOP)/$(LIB_DIR) $(GBM_LIB_DEPS) \ + $(OBJECTS) $(LOCAL_LIBS) + +install-headers: + $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/ + $(INSTALL) -m 644 $(TOP)/src/gbm/main/gbm.h \ + $(DESTDIR)$(INSTALL_INC_DIR) + + +PKG_CONFIG_DIR = $(INSTALL_LIB_DIR)/pkgconfig + + +install: default install-headers + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libgbm.so* \ + $(DESTDIR)$(INSTALL_LIB_DIR) + +clean: + -rm -f *.o + -rm -f depend depend.bak + + +depend: $(SOURCES) $(HEADERS) + @ echo "running $(MKDEP)" + @ rm -f depend + @ touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ + $(SOURCES) $(HEADERS) > /dev/null 2>/dev/null + + +-include depend +# DO NOT DELETE diff --git a/src/gbm/api.c b/src/gbm/main/api.c index f8aaf7b2a6..24e8c5615c 100644 --- a/src/gbm/api.c +++ b/src/gbm/main/api.c @@ -3,6 +3,7 @@ #include "gbm.h" #include "internal.h" +#include "module.h" GBM_EXPORT int gbm_device_get_fd(struct gbm_device *gbm) @@ -28,8 +29,10 @@ gbm_device_create(int fd) { struct gbm_device *gbm; - gbm = dri_device_create(fd); + //gbm = dri_device_create(fd); //gbm = gbm_gallium_drm_device_create(fd); + struct gbm_backend *backend = find_backend(fd); + gbm = backend->create_device(fd); if (gbm == NULL) return NULL; diff --git a/src/gbm/common.c b/src/gbm/main/common.c index 9c5aac94fd..9c5aac94fd 100644 --- a/src/gbm/common.c +++ b/src/gbm/main/common.c diff --git a/src/gbm/common.h b/src/gbm/main/common.h index ee33e972bb..ee33e972bb 100644 --- a/src/gbm/common.h +++ b/src/gbm/main/common.h diff --git a/src/gbm/common_drm.h b/src/gbm/main/common_drm.h index 44985c42aa..44985c42aa 100644 --- a/src/gbm/common_drm.h +++ b/src/gbm/main/common_drm.h diff --git a/src/gbm/gbm.h b/src/gbm/main/gbm.h index 9200ca5ae5..9200ca5ae5 100644 --- a/src/gbm/gbm.h +++ b/src/gbm/main/gbm.h diff --git a/src/gbm/internal.h b/src/gbm/main/internal.h index 0ceef265e8..6f0d4f1f16 100644 --- a/src/gbm/internal.h +++ b/src/gbm/main/internal.h @@ -44,10 +44,20 @@ struct gbm_bo { union gbm_bo_handle handle; }; + +struct gbm_backend { + const char *class_name; + const char *backend_name; + int (*probe)(int fd); + struct gbm_device *(*create_device)(int fd); +}; + +#if 0 struct gbm_device * dri_device_create(int fd); struct gbm_device * gbm_gallium_drm_device_create(int fd); +#endif #endif diff --git a/src/gbm/main/module.c b/src/gbm/main/module.c new file mode 100644 index 0000000000..0a7b37adb1 --- /dev/null +++ b/src/gbm/main/module.c @@ -0,0 +1,61 @@ +#include <stdio.h> +#include <stddef.h> +#include <stdlib.h> +#include <limits.h> +#include <dlfcn.h> + +#include "module.h" + +static void * +load_module(const char *name, const char *entrypoint) +{ + char path[PATH_MAX]; + void *module, *init; + + if (name[0] != '/') + snprintf(path, sizeof path, MODULEDIR "/%s", name); + else + snprintf(path, sizeof path, "%s", name); + + module = dlopen(path, RTLD_LAZY); + if (!module) { + fprintf(stderr, + "failed to load module: %s\n", dlerror()); + return NULL; + } + + init = dlsym(module, entrypoint); + if (!init) + return NULL; + + return init; +} + +static const char *backends[] = { + "gbm_dri.so", + "gbm_gallium_drm.so", +}; + +#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) + +struct gbm_backend * +find_backend(int fd) +{ + struct gbm_backend *backend = NULL; + int i; + const char *b; + + b = getenv("GBM_BACKEND"); + if (b) + backend = load_module(b, "gbm_backend"); + + for (i = 0; i < ARRAY_SIZE(backends) && backend == NULL; ++i) { + backend = load_module(backends[i], "gbm_backend"); + if (backend && backend->probe(fd) == 0) + break; + else + backend = NULL; + } + + return backend; +} diff --git a/src/gbm/main/module.h b/src/gbm/main/module.h new file mode 100644 index 0000000000..591062a93d --- /dev/null +++ b/src/gbm/main/module.h @@ -0,0 +1,9 @@ +#ifndef MODULE_H_ +#define MODULE_H_ + +#include "internal.h" + +struct gbm_backend * +find_backend(int fd); + +#endif |