aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2014-01-29 15:23:11 +0000
committerChris Michael <cp.michael@samsung.com>2014-01-29 15:27:24 +0000
commit826d6a30f48649934dd9aaff69b65c9160974883 (patch)
treefd5b95e47595d0161569bc468c242584876efc1d
parentCheck return values of drm commands and fail nicely. (diff)
downloadefl-826d6a30f48649934dd9aaff69b65c9160974883.tar.gz
Add start of buffer abstraction code
Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/modules/evas/engines/drm/evas_buffer_manager.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/modules/evas/engines/drm/evas_buffer_manager.c b/src/modules/evas/engines/drm/evas_buffer_manager.c
new file mode 100644
index 0000000000..4b355df2cd
--- /dev/null
+++ b/src/modules/evas/engines/drm/evas_buffer_manager.c
@@ -0,0 +1,88 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "evas_engine.h"
+#include <dlfcn.h>
+
+static int _init_count = 0;
+
+/* the actual Manager device returned from init of the library */
+static void *bufmgr;
+
+/* the actual library we successfully dlopen'd */
+static void *libbufmgr;
+
+/* pointers to library functions that we need */
+void *(*libbufmgr_init)(int fd);
+void (*libbufmgr_shutdown)(void *mgr);
+
+//void *(*libbufmgr_buffer_create)(void *mgr);
+
+int
+evas_buffer_manager_init(void)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ if (++_init_count != 1) return _init_count;
+
+ /* try to dlopen various buffer managers until we find one that works
+ * (libgbm, libtbm, etc)
+ *
+ * NB: as I am testing this on desktop and do not have libtbm, I am
+ * just going to code for that. Feel free to hack in libtbm support */
+ libbufmgr = dlopen("libgbm.so", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libbufmgr)
+ libbufmgr = dlopen("libgbm.so.1", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libbufmgr)
+ libbufmgr = dlopen("libgbm.so.1.0.0", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libbufmgr) return --_init_count;
+
+ /* with the library found, symlink the functions we need */
+ libbufmgr_init = dlsym(libbufmgr, "gbm_create_device");
+ libbufmgr_shutdown = dlsym(libbufmgr, "gbm_device_destroy");
+
+ return _init_count;
+}
+
+int
+evas_buffer_manager_shutdown(void)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ if (--_init_count != 0) return _init_count;
+
+ /* call function to shutdown the manager */
+ evas_buffer_manager_close();
+}
+
+Eina_Bool
+evas_buffer_manager_open(int fd)
+{
+ Eina_Bool ret = EINA_FALSE;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ if (bufmgr) return EINA_TRUE;
+
+ /* call any init functions required by the dlsym'd buffer manager */
+ if (libbufmgr_init)
+ {
+ if ((bufmgr = libbufmgr_init(fd)))
+ ret = EINA_TRUE;
+ }
+
+ return ret;
+}
+
+void
+evas_buffer_manager_close(void)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+ /* call any shutdown functions required by the dlsym'd buffer manager */
+ if (libbufmgr_shutdown)
+ libbufmgr_shutdown(bufmgr);
+
+ bufmgr = NULL;
+}