ecore-drm2: Add start of Ecore_Drm2 library
authorChris Michael <cpmichael@osg.samsung.com>
Mon, 2 May 2016 14:21:00 +0000 (10:21 -0400)
committerChris Michael <cpmichael@osg.samsung.com>
Fri, 27 May 2016 15:57:53 +0000 (11:57 -0400)
This new library is going to replace the existing Ecore_Drm. This will
refactor a lot of the code, bring improvements over the existing API,
and provide additional support for missing features.

@feature

Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
Makefile.am
configure.ac
m4/efl.m4
pc/.gitignore
pc/ecore-drm2.pc.in [new file with mode: 0644]
src/Makefile.am
src/Makefile_Ecore_Drm2.am [new file with mode: 0644]
src/Makefile_Ecore_Evas.am
src/lib/ecore_drm2/Ecore_Drm2.h [new file with mode: 0644]
src/lib/ecore_drm2/ecore_drm2.c [new file with mode: 0644]
src/lib/ecore_drm2/ecore_drm2_private.h [new file with mode: 0644]

index 564f332..1efae6e 100644 (file)
@@ -290,6 +290,10 @@ if HAVE_ELPUT
 pkgconfig_DATA += pc/elput.pc
 endif
 
+if HAVE_ECORE_DRM2
+pkgconfig_DATA += pc/ecore-drm2.pc
+endif
+
 # Cmake configs:
 efl_cmakeconfigdir = $(libdir)/cmake/Efl/
 efl_cmakeconfig_DATA = \
index cae4e39..0912ac2 100644 (file)
@@ -2085,19 +2085,32 @@ if test "x${have_cocoa}" = "xyes"; then
 fi
 AC_SUBST(cocoa_coreservices_ldflags)
 
+AC_ARG_ENABLE([elput],
+   [AS_HELP_STRING([--enable-elput],[enable elput library. @<:@default=disabled@:>@])],
+   [
+    if test "x${enableval}" = "xyes" ; then
+       want_elput="yes"
+    else
+       want_elput="no"
+    fi
+   ],
+   [want_elput="no"])
+
 # Drm
 AC_ARG_ENABLE([drm],
    [AS_HELP_STRING([--enable-drm],[enable drm engine. @<:@default=disabled@:>@])],
    [
     if test "x${enableval}" = "xyes" ; then
-       want_drm="yes"
+      if test "x${want_elput}" != "xyes" ; then
+        AC_MSG_ERROR([elput is required to build drm support])
+      fi
+      want_drm="yes"
     else
        want_drm="no"
     fi
    ],
    [want_drm="no"])
 
-
 AC_ARG_ENABLE([gl-drm],
    [AC_HELP_STRING([--enable-gl-drm],
        [enable gl drm engine. @<:@default=disabled@:>@])],
@@ -2296,17 +2309,6 @@ AC_ARG_ENABLE([ecore-buffer],
    ],
    [want_ecore_buffer="no"])
 
-AC_ARG_ENABLE([elput],
-   [AS_HELP_STRING([--enable-elput],[enable elput library. @<:@default=disabled@:>@])],
-   [
-    if test "x${enableval}" = "xyes" ; then
-       want_elput="yes"
-    else
-       want_elput="no"
-    fi
-   ],
-   [want_elput="no"])
-
 # Image Loaders
 
 ARG_ENABLE_EVAS_IMAGE_LOADER(BMP, static)
@@ -3633,7 +3635,52 @@ EFL_EVAL_PKGS([ELPUT])
 ### Checks for library functions
 
 EFL_LIB_END_OPTIONAL([Elput])
-#### End of Ecore_Drm
+#### End of Elput
+
+#### Ecore_Drm2
+have_libinput_new="no"
+EFL_LIB_START_OPTIONAL([Ecore_Drm2], [test "${want_drm}" = "yes"])
+
+### Additional options to configure
+SUID_CFLAGS=-fPIE
+SUID_LDFLAGS=-pie
+AC_SUBST([SUID_CFLAGS])
+AC_SUBST([SUID_LDFLAGS])
+
+### Default values
+
+### Checks for programs
+
+### Checks for libraries
+EFL_INTERNAL_DEPEND_PKG([ECORE_DRM2], [eo])
+EFL_INTERNAL_DEPEND_PKG([ECORE_DRM2], [efl])
+EFL_INTERNAL_DEPEND_PKG([ECORE_DRM2], [eina])
+EFL_INTERNAL_DEPEND_PKG([ECORE_DRM2], [ecore])
+EFL_INTERNAL_DEPEND_PKG([ECORE_DRM2], [elput])
+EFL_INTERNAL_DEPEND_PKG([ECORE_DRM2], [eeze])
+
+EFL_DEPEND_PKG([ECORE_DRM2], [DRM], [libdrm >= 2.4 gbm])
+
+EFL_ADD_LIBS([ECORE_DRM2], [-lm])
+
+AC_CHECK_LIB(drm, drmModeAtomicCommit, AC_DEFINE(HAVE_ATOMIC_DRM, [], [Atomic modeset supported]))
+
+EFL_EVAL_PKGS([ECORE_DRM2])
+
+### Checks for header files
+
+### Checks for types
+
+### Checks for structures
+
+### Checks for compiler characteristics
+
+### Checks for linker characteristics
+
+### Checks for library functions
+
+EFL_LIB_END_OPTIONAL([Ecore_Drm2])
+#### End of Ecore_Drm2
 
 
 #### Ecore_Audio
@@ -5260,7 +5307,7 @@ EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ELEMENTARY], [${have_ps3}], [ecore_psl1ght])
 EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ELEMENTARY], [${want_sdl}], [ecore_sdl])
 EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ELEMENTARY], [${want_ecore_evas_gl_cocoa}], [ecore_cocoa])
 EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ELEMENTARY], [${build_ecore_evas_win32}], [ecore_win32])
-EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ELEMENTARY], [${want_drm}], [ecore_drm])
+EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ELEMENTARY], [${want_drm}], [ecore_drm2])
 EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ELEMENTARY], [${build_ecore_evas_wayland}], [ecore_wl2])
 
 dnl Special case deps for ecore_drm
@@ -5605,6 +5652,7 @@ pc/elua.pc
 pc/elementary.pc
 pc/elementary-cxx.pc
 pc/elput.pc
+pc/ecore-drm2.pc
 dbus-services/org.enlightenment.Ethumb.service
 systemd-services/ethumb.service
 $po_makefile_in
index c9e15f3..f1694c5 100644 (file)
--- a/m4/efl.m4
+++ b/m4/efl.m4
@@ -174,6 +174,9 @@ case "m4_defn([DOWNOTHER])" in
    ecore_win32)
       depname="ecore-win32"
       ;;
+   ecore_drm2)
+      depname="ecore-drm2"
+      ;;
 esac
 requirements_pc_[]m4_defn([DOWNEFL])="${depname} >= ${PACKAGE_VERSION} ${requirements_pc_[][]m4_defn([DOWNEFL])}"
 requirements_cflags_[]m4_defn([DOWNEFL])="-I\$(top_srcdir)/src/lib/${libdirname} -I\$(top_builddir)/src/lib/${libdirname} ${requirements_cflags_[][]m4_defn([DOWNEFL])}"
index f66395b..893e937 100644 (file)
@@ -74,3 +74,4 @@
 /efl-js.pc
 /elementary-cxx.pc
 /elput.pc
+/ecore-drm2.pc
diff --git a/pc/ecore-drm2.pc.in b/pc/ecore-drm2.pc.in
new file mode 100644 (file)
index 0000000..4530eac
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ecore-drm2
+Description: E core library, DRM module
+Requires.private: @requirements_pc_ecore_drm2@
+Version: @VERSION@
+Libs: -L${libdir} -lecore_drm2
+Libs.private: @requirements_libs_ecore_drm2@
+Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/ecore-drm2-@VMAJ@
index af019a7..523f411 100644 (file)
@@ -54,7 +54,9 @@ include Makefile_Ecore_IMF.am
 include Makefile_Ecore_IMF_Evas.am
 include Makefile_Eldbus.am
 include Makefile_Eeze.am
+include Makefile_Elput.am
 include Makefile_Ecore_Drm.am
+include Makefile_Ecore_Drm2.am
 include Makefile_Ecore_Evas.am
 include Makefile_Ecore_Audio.am
 include Makefile_Ecore_Avahi.am
@@ -69,7 +71,6 @@ include Makefile_Ethumb.am
 include Makefile_Ethumb_Client.am
 include Makefile_Elocation.am
 include Makefile_Elementary.am
-include Makefile_Elput.am
 
 include Makefile_Cxx.am
 include Makefile_Eolian_Cxx.am
diff --git a/src/Makefile_Ecore_Drm2.am b/src/Makefile_Ecore_Drm2.am
new file mode 100644 (file)
index 0000000..2818b0e
--- /dev/null
@@ -0,0 +1,25 @@
+if HAVE_ECORE_DRM2
+
+### Library
+
+lib_LTLIBRARIES += lib/ecore_drm2/libecore_drm2.la
+
+installed_ecoredrm2mainheadersdir = $(includedir)/ecore-drm2-@VMAJ@
+dist_installed_ecoredrm2mainheaders_DATA = \
+  lib/ecore_drm2/Ecore_Drm2.h
+
+lib_ecore_drm2_libecore_drm2_la_SOURCES = \
+lib/ecore_drm2/ecore_drm2.c \
+lib/ecore_drm2/ecore_drm2_private.h
+
+lib_ecore_drm2_libecore_drm2_la_CPPFLAGS = \
+  -I$(top_builddir)/src/lib/efl \
+  @ECORE_DRM2_CFLAGS@ @EFL_CFLAGS@ \
+  -DPACKAGE_LIB_DIR=\"$(libdir)\" \
+  -DMODULE_ARCH=\"$(MODULE_ARCH)\"
+
+lib_ecore_drm2_libecore_drm2_la_LIBADD = @ECORE_DRM2_LIBS@
+lib_ecore_drm2_libecore_drm2_la_DEPENDENCIES = @ECORE_DRM2_INTERNAL_LIBS@
+lib_ecore_drm2_libecore_drm2_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
+
+endif
index 12efc0b..25af963 100644 (file)
@@ -271,11 +271,13 @@ modules_ecore_evas_engines_drm_module_la_CPPFLAGS = -I$(top_builddir)/src/lib/ef
 @ECORE_EVAS_CFLAGS@ \
 @ECORE_DRM_CFLAGS@ \
 -I$(top_srcdir)/src/modules/evas/engines/drm \
--I$(top_srcdir)/src/modules/evas/engines/gl_drm \
-@ecore_evas_engines_gl_drm_cflags@
-modules_ecore_evas_engines_drm_module_la_LIBADD = @USE_ECORE_EVAS_LIBS@ \
-@ecore_evas_engines_gl_drm_libs@
-modules_ecore_evas_engines_drm_module_la_DEPENDENCIES = @USE_ECORE_EVAS_INTERNAL_LIBS@
+-I$(top_srcdir)/src/modules/evas/engines/gl_drm
+modules_ecore_evas_engines_drm_module_la_LIBADD = \
+@USE_ECORE_EVAS_LIBS@ \
+@USE_ECORE_DRM2_LIBS@
+modules_ecore_evas_engines_drm_module_la_DEPENDENCIES = \
+@USE_ECORE_EVAS_INTERNAL_LIBS@ \
+@USE_ECORE_DRM2_INTERNAL_LIBS@
 modules_ecore_evas_engines_drm_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
 modules_ecore_evas_engines_drm_module_la_LIBTOOLFLAGS = --tag=disable-static
 endif
diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
new file mode 100644 (file)
index 0000000..b2bbd15
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef _ECORE_DRM2_H
+# define _ECORE_DRM2_H
+
+# include <Ecore.h>
+# include <Elput.h>
+
+# ifdef EAPI
+#  undef EAPI
+# endif
+
+# ifdef _MSC_VER
+#  ifdef BUILDING_DLL
+#   define EAPI __declspec(dllexport)
+#  else // ifdef BUILDING_DLL
+#   define EAPI __declspec(dllimport)
+#  endif // ifdef BUILDING_DLL
+# else // ifdef _MSC_VER
+#  ifdef __GNUC__
+#   if __GNUC__ >= 4
+#    define EAPI __attribute__ ((visibility("default")))
+#   else // if __GNUC__ >= 4
+#    define EAPI
+#   endif // if __GNUC__ >= 4
+#  else // ifdef __GNUC__
+#   define EAPI
+#  endif // ifdef __GNUC__
+# endif // ifdef _MSC_VER
+
+# ifdef EFL_BETA_API_SUPPORT
+
+/**
+ * @file
+ * @brief Ecore functions for dealing with drm, virtual terminals
+ *
+ * @defgroup Ecore_Drm2_Group Ecore_Drm2 - Drm Integration
+ * @ingroup Ecore
+ *
+ * Ecore_Drm2 provides a wrapper and functions for using libdrm
+ *
+ * @li @ref Ecore_Drm2_Init_Group
+ * @li @ref Ecore_Drm2_Device_Group
+ */
+
+/**
+ * @defgroup Ecore_Drm2_Init_Group Drm library Init and Shutdown functions
+ *
+ * Functions that start and shutdown the Ecore_Drm2 library
+ */
+
+/**
+ * Initialize the Ecore_Drm2 library
+ *
+ * @return  The number of times the library has been initialized without
+ *          being shut down. 0 is returned if an error occurs.
+ *
+ * @ingroup Ecore_Drm2_Init_Group
+ * @since 1.18
+ */
+EAPI int ecore_drm2_init(void);
+
+/**
+ * Shutdown the Ecore_Drm2 library
+ *
+ * @return  The number of times the library has been initialized without
+ *          being shutdown. 0 is returned if an error occurs.
+ *
+ * @ingroup Ecore_Drm2_Init_Group
+ * @since 1.18
+ */
+EAPI int ecore_drm2_shutdown(void);
+
+# endif
+
+#endif
diff --git a/src/lib/ecore_drm2/ecore_drm2.c b/src/lib/ecore_drm2/ecore_drm2.c
new file mode 100644 (file)
index 0000000..32b6781
--- /dev/null
@@ -0,0 +1,74 @@
+#include "ecore_drm2_private.h"
+
+static int _ecore_drm2_init_count = 0;
+
+int _ecore_drm2_log_dom = -1;
+
+EAPI int
+ecore_drm2_init(void)
+{
+   if (++_ecore_drm2_init_count != 1) return _ecore_drm2_init_count;
+
+   if (!eina_init()) goto eina_err;
+
+   if (!ecore_init())
+     {
+        EINA_LOG_ERR("Could not initialize Ecore library");
+        goto ecore_err;
+     }
+
+   if (!eeze_init())
+     {
+        EINA_LOG_ERR("Could not initialize Eeze library");
+        goto eeze_err;
+     }
+
+   if (!elput_init())
+     {
+        EINA_LOG_ERR("Could not initialize Elput library");
+        goto elput_err;
+     }
+
+   _ecore_drm2_log_dom =
+     eina_log_domain_register("ecore_drm2", ECORE_DRM2_DEFAULT_LOG_COLOR);
+   if (!_ecore_drm2_log_dom)
+     {
+        EINA_LOG_ERR("Could not create logging domain for Ecore_Drm2");
+        goto log_err;
+     }
+
+   return _ecore_drm2_init_count;
+
+log_err:
+   elput_shutdown();
+elput_err:
+   eeze_shutdown();
+eeze_err:
+   ecore_shutdown();
+ecore_err:
+   eina_shutdown();
+eina_err:
+   return --_ecore_drm2_init_count;
+}
+
+EAPI int
+ecore_drm2_shutdown(void)
+{
+   if (_ecore_drm2_init_count < 1)
+     {
+        ERR("Ecore_Drm2 shutdown called without init");
+        return 0;
+     }
+
+   if (--_ecore_drm2_init_count != 0) return _ecore_drm2_init_count;
+
+   eina_log_domain_unregister(_ecore_drm2_log_dom);
+   _ecore_drm2_log_dom = -1;
+
+   elput_shutdown();
+   eeze_shutdown();
+   ecore_shutdown();
+   eina_shutdown();
+
+   return _ecore_drm2_init_count;
+}
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
new file mode 100644 (file)
index 0000000..6177e8e
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef _ECORE_DRM2_PRIVATE_H
+# define _ECORE_DRM2_PRIVATE_H
+
+# ifdef HAVE_CONFIG_H
+#  include "config.h"
+# endif
+
+# include "Ecore.h"
+# include "ecore_private.h"
+# include "Eeze.h"
+# include "Elput.h"
+# include <Ecore_Drm2.h>
+
+# include <unistd.h>
+# include <strings.h>
+# include <sys/mman.h>
+# include <fcntl.h>
+# include <ctype.h>
+
+# include <sys/ioctl.h>
+# include <xf86drm.h>
+# include <xf86drmMode.h>
+# include <drm_mode.h>
+# include <drm_fourcc.h>
+
+extern int _ecore_drm2_log_dom;
+
+# ifdef ECORE_DRM2_DEFAULT_LOG_COLOR
+#  undef ECORE_DRM2_DEFAULT_LOG_COLOR
+# endif
+# define ECORE_DRM2_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
+
+# ifdef ERR
+#  undef ERR
+# endif
+# define ERR(...) EINA_LOG_DOM_ERR(_ecore_drm2_log_dom, __VA_ARGS__)
+
+# ifdef DBG
+#  undef DBG
+# endif
+# define DBG(...) EINA_LOG_DOM_DBG(_ecore_drm2_log_dom, __VA_ARGS__)
+
+# ifdef INF
+#  undef INF
+# endif
+# define INF(...) EINA_LOG_DOM_INFO(_ecore_drm2_log_dom, __VA_ARGS__)
+
+# ifdef WRN
+#  undef WRN
+# endif
+# define WRN(...) EINA_LOG_DOM_WARN(_ecore_drm2_log_dom, __VA_ARGS__)
+
+# ifdef CRIT
+#  undef CRIT
+# endif
+# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm2_log_dom, __VA_ARGS__)
+
+#endif