Initial release 82/160382/4
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 16 Nov 2017 02:11:30 +0000 (11:11 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 16 Nov 2017 05:46:09 +0000 (14:46 +0900)
[Version] 0.0.1
[Profile] Common
[Issue Type] Initial release
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20171107.4]

Change-Id: I73ea0a4070b2b0abe90e8ce4be7e033f2d5ef0ea
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
16 files changed:
AUTHORS [new file with mode: 0644]
LICENSE.APLv2 [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
NOTICE [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
libmm-display-interface.manifest [new file with mode: 0644]
libmm-display.manifest [new file with mode: 0644]
mm-display-interface.pc.in [new file with mode: 0644]
packaging/libmm-display.spec [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/include/mm_display.h [new file with mode: 0644]
src/include/mm_display_interface.h [new file with mode: 0644]
src/include/mm_display_interface_private.h [new file with mode: 0644]
src/mm_display.c [new file with mode: 0644]
src/mm_display_interface.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..5660903
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Jeongmo Yang <jm80.yang at samsung dot com>
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..bbe9d02
--- /dev/null
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..0d10595
--- /dev/null
@@ -0,0 +1,8 @@
+ACLOCAL_AMFLAGS='-I m4'
+
+SUBDIRS = src
+
+pcfiles = mm-display-interface.pc
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(pcfiles)
+EXTRA_DIST = $(pcfiles)
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..0e0f016
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..d5ce106
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+libtoolize --copy --force
+aclocal -I m4
+autoheader
+autoconf
+automake -a -c
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..f4da5be
--- /dev/null
@@ -0,0 +1,107 @@
+AC_PREREQ(2.52)
+
+AC_INIT([libmm-display], [0.8.0])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+AC_CONFIG_HEADERS([config.h:config.hin])
+AC_CONFIG_MACRO_DIR([m4])
+
+# Checks for programs.
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_C_CONST
+dnl AC_FUNC_MALLOC
+AC_FUNC_MMAP
+AC_FUNC_REALLOC
+AC_FUNC_SELECT_ARGTYPES
+AC_FUNC_STAT
+AC_FUNC_VPRINTF
+AC_HEADER_STDBOOL
+AC_HEADER_STDC
+AC_HEADER_TIME
+AC_PROG_GCC_TRADITIONAL
+AC_PROG_LIBTOOL
+
+# Checks for libraries.
+PKG_CHECK_MODULES(GLIB, glib-2.0)
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
+PKG_CHECK_MODULES(GMODULE, gmodule-2.0)
+AC_SUBST(GMODULE_CFLAGS)
+AC_SUBST(GMODULE_LIBS)
+
+PKG_CHECK_MODULES(MM_COMMON, mm-common)
+AC_SUBST(MM_COMMON_CFLAGS)
+AC_SUBST(MM_COMMON_LIBS)
+
+PKG_CHECK_MODULES(TBM, libtbm)
+AC_SUBST(TBM_CFLAGS)
+AC_SUBST(TBM_LIBS)
+
+PKG_CHECK_MODULES(MEDIA_TOOL, capi-media-tool)
+AC_SUBST(MEDIA_TOOL_CFLAGS)
+AC_SUBST(MEDIA_TOOL_LIBS)
+
+PKG_CHECK_MODULES(DLOG, dlog)
+AC_SUBST(DLOG_CFLAGS)
+AC_SUBST(DLOG_LIBS)
+
+PKG_CHECK_MODULES(EVAS, evas)
+AC_SUBST(EVAS_CFLAGS)
+AC_SUBST(EVAS_LIBS)
+
+PKG_CHECK_MODULES(ELEMENTARY, elementary)
+AC_SUBST(ELEMENTARY_CFLAGS)
+AC_SUBST(ELEMENTARY_LIBS)
+
+PKG_CHECK_MODULES(ECORE_EVAS, ecore-evas)
+AC_SUBST(ECORE_EVAS_CFLAGS)
+AC_SUBST(ECORE_EVAS_LIBS)
+
+PKG_CHECK_MODULES(ECORE_WAYLAND, ecore-wayland)
+AC_SUBST(ECORE_WAYLAND_CFLAGS)
+AC_SUBST(ECORE_WAYLAND_LIBS)
+
+PKG_CHECK_MODULES(TIZEN_EXTENSION_CLIENT, tizen-extension-client)
+AC_SUBST(TIZEN_EXTENSION_CLIENT_CFLAGS)
+AC_SUBST(TIZEN_EXTENSION_CLIENT_LIBS)
+
+AC_ARG_ENABLE(evas-renderer, AC_HELP_STRING([--enable-evas-renderer], [enable evas renderer]),
+[
+  case "${enableval}" in
+    yes) TIZEN_FEATURE_EVAS_RENDERER=yes ;;
+    no)  TIZEN_FEATURE_EVAS_RENDERER=no ;;
+    *) AC_MSG_ERROR(bad value ${enableval} for --enable-evas-renderer) ;;
+  esac
+],[TIZEN_FEATURE_EVAS_RENDERER=no])
+if test "x$TIZEN_FEATURE_EVAS_RENDERER" = "xyes"; then
+PKG_CHECK_MODULES(EVAS_RENDERER, mm-evas-renderer)
+AC_SUBST(EVAS_RENDERER_CFLAGS)
+AC_SUBST(EVAS_RENDERER_LIBS)
+fi
+AM_CONDITIONAL([TIZEN_FEATURE_EVAS_RENDERER], [test "x$TIZEN_FEATURE_EVAS_RENDERER" = "xyes"])
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([fcntl.h memory.h stdlib.h string.h sys/time.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_ALLOCA
+AC_FUNC_FORK
+AC_FUNC_MALLOC
+AC_FUNC_MEMCMP
+AC_FUNC_SELECT_ARGTYPES
+AC_TYPE_SIGNAL
+AC_CHECK_FUNCS([memset select])
+AC_CONFIG_FILES([
+Makefile
+src/Makefile
+mm-display-interface.pc
+])
+AC_OUTPUT
diff --git a/libmm-display-interface.manifest b/libmm-display-interface.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/libmm-display.manifest b/libmm-display.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/mm-display-interface.pc.in b/mm-display-interface.pc.in
new file mode 100644 (file)
index 0000000..9078e5c
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: mm-display-interface
+Description: Multimedia Framework Display Library
+Requires: mm-common capi-media-tool
+Version: $VERSION
+Libs: -L${libdir} -lmmfdisplay_interface
+Cflags: -I${includedir}/ -I${includedir}/mmf
diff --git a/packaging/libmm-display.spec b/packaging/libmm-display.spec
new file mode 100644 (file)
index 0000000..9310856
--- /dev/null
@@ -0,0 +1,87 @@
+Name:       libmm-display
+Summary:    Multimedia framework display library
+Version:    0.0.1
+Release:    0
+Group:      Multimedia/Libraries
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gmodule-2.0)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(mm-common)
+BuildRequires:  pkgconfig(libtbm)
+BuildRequires:  pkgconfig(capi-media-tool)
+BuildRequires:  pkgconfig(evas)
+BuildRequires:  pkgconfig(elementary)
+BuildRequires:  pkgconfig(ecore-evas)
+BuildRequires:  pkgconfig(ecore-wayland)
+BuildRequires:  pkgconfig(tizen-extension-client)
+%if "%{tizen_profile_name}" != "tv"
+BuildRequires:  pkgconfig(mm-evas-renderer)
+%endif
+
+%description
+Multimedia framework display library.
+
+
+%package interface
+Summary:    Multimedia framework display interface library
+Group:      Multimedia/Libraries
+Version:    %{version}
+
+%description interface
+Multimedia framework display interface library.
+
+
+%package interface-devel
+Summary:    Multimedia framework display interface library for development
+Group:      libdevel
+Version:    %{version}
+Requires:   %{name}-interface = %{version}-%{release}
+
+%description interface-devel
+Multimedia framework display library for develpment.
+
+
+%prep
+%setup -q
+
+
+%build
+export CFLAGS+=" -D_LARGEFILE64_SOURCE -DMM_DISPLAY_LIBDIR=\\\"%{_libdir}\\\""
+./autogen.sh
+%configure \
+%if "%{tizen_profile_name}" != "tv"
+       --enable-evas-renderer \
+%endif
+       --disable-static
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+
+%post
+/sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest libmm-display.manifest
+%license LICENSE.APLv2
+%defattr(-,root,root,-)
+%{_libdir}/libmmfdisplay.so*
+
+%files interface
+%manifest libmm-display-interface.manifest
+%license LICENSE.APLv2
+%defattr(-,root,root,-)
+%{_libdir}/libmmfdisplay_interface.so.*
+
+%files interface-devel
+%defattr(-,root,root,-)
+%{_includedir}/mmf/mm_display_interface.h
+%{_libdir}/pkgconfig/mm-display-interface.pc
+%{_libdir}/libmmfdisplay_interface.so
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..fc40995
--- /dev/null
@@ -0,0 +1,79 @@
+ACLOCAL_AMFLAGS='-I m4'
+
+lib_LTLIBRARIES = libmmfdisplay.la libmmfdisplay_interface.la
+
+###################
+## libmmfdisplay ##
+###################
+
+includelibmmfdisplaydir = $(includedir)/mmf
+
+noinst_HEADERS = include/mm_display.h \
+       include/mm_display_interface_private.h
+
+libmmfdisplay_la_SOURCES = mm_display.c
+
+libmmfdisplay_la_CFLAGS = -I$(srcdir)/include \
+       $(GLIB_CFLAGS) \
+       $(MM_COMMON_CFLAGS) \
+       $(MEDIA_TOOL_CFLAGS) \
+       $(TBM_CFLAGS) \
+       $(EVAS_CFLAGS) \
+       $(ELEMENTARY_CFLAGS) \
+       $(ECORE_EVAS_CFLAGS) \
+       $(ECORE_WAYLAND_CFLAGS) \
+       $(TIZEN_EXTENSION_CLIENT_CFLAGS) \
+       $(DLOG_CFLAGS)
+
+libmmfdisplay_la_LIBADD = \
+       $(GLIB_LIBS) \
+       $(MM_COMMON_LIBS) \
+       $(MEDIA_TOOL_LIBS) \
+       $(TBM_LIBS) \
+       $(EVAS_LIBS) \
+       $(ELEMENTARY_LIBS) \
+       $(ECORE_EVAS_LIBS) \
+       $(ECORE_WAYLAND_LIBS) \
+       $(TIZEN_EXTENSION_CLIENT_LIBS) \
+       $(DLOG_LIBS)
+
+if TIZEN_FEATURE_EVAS_RENDERER
+libmmfdisplay_la_CFLAGS += $(EVAS_RENDERER_CFLAGS) -DTIZEN_FEATURE_EVAS_RENDERER
+libmmfdisplay_la_LIBADD += $(EVAS_RENDERER_LIBS)
+endif
+
+libmmfdisplay_la_CFLAGS += -D_FILE_OFFSET_BITS=64
+libmmfdisplay_la_CFLAGS += -fdata-sections -ffunction-sections -Wl,--gc-sections
+libmmfdisplay_la_LDFLAGS = -Wl,--gc-sections
+
+
+
+#############################
+## libmmfdisplay_interface ##
+#############################
+
+includelibmmfdisplay_interfacedir = $(includedir)/mmf
+
+includelibmmfdisplay_interface_HEADERS = include/mm_display_interface.h
+
+libmmfdisplay_interface_la_SOURCES = mm_display_interface.c
+
+libmmfdisplay_interface_la_CFLAGS = -I$(srcdir)/include \
+       $(GMODULE_CFLAGS) \
+       $(MM_COMMON_CFLAGS) \
+       $(MEDIA_TOOL_CFLAGS) \
+       $(DLOG_CFLAGS)
+
+libmmfdisplay_interface_la_LIBADD = \
+       $(GMODULE_LIBS) \
+       $(MEDIA_TOOL_LIBS) \
+       $(DLOG_LIBS)
+
+if TIZEN_FEATURE_EVAS_RENDERER
+libmmfdisplay_interface_la_CFLAGS += -DTIZEN_FEATURE_EVAS_RENDERER
+endif
+
+libmmfdisplay_interface_la_CFLAGS += -D_FILE_OFFSET_BITS=64
+libmmfdisplay_interface_la_CFLAGS += -fdata-sections -ffunction-sections -Wl,--gc-sections
+libmmfdisplay_interface_la_LDFLAGS = -Wl,--gc-sections
+
diff --git a/src/include/mm_display.h b/src/include/mm_display.h
new file mode 100644 (file)
index 0000000..f783cbd
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MM_DISPLAY_H__
+#define __MM_DISPLAY_H__
+
+#include "mm_display_interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct mm_display {
+       mm_display_type_e type;
+
+       /* wayland */
+       mm_display_wayland_info_s wl_info;              /* wayland related information */
+
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       /* evas renderer */
+       MMHandleType evas_renderer;                     /* evas renderer handle */
+       GMutex evas_mutex;
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+} mm_display_t;
+typedef void *mm_display_h;
+
+int mm_display_init(mm_display_h *handle);
+int mm_display_deinit(mm_display_h handle);
+int mm_display_set_display(mm_display_h handle, mm_display_type_e type, void *display, mm_display_wayland_info_s *wl_info);
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+int mm_display_evas_set_rotation(mm_display_h handle, int rotation);
+int mm_display_evas_get_rotation(mm_display_h handle, int *rotation);
+int mm_display_evas_set_visible(mm_display_h handle, bool visible);
+int mm_display_evas_get_visible(mm_display_h handle, bool *visible);
+int mm_display_evas_set_flip(mm_display_h handle, int flip);
+int mm_display_evas_get_flip(mm_display_h handle, int *flip);
+int mm_display_evas_set_mode(mm_display_h handle, int mode);
+int mm_display_evas_get_mode(mm_display_h handle, int *mode);
+int mm_display_evas_set_roi_area(mm_display_h handle, int x, int y, int w, int h);
+int mm_display_evas_get_roi_area(mm_display_h handle, int *x, int *y, int *w, int *h);
+int mm_display_evas_set_rendered_cb(mm_display_h handle, mm_display_evas_rendered_cb rendered_cb, void *user_data);
+int mm_display_evas_render(mm_display_h handle, media_packet_h packet);
+int mm_display_evas_flush(mm_display_h handle, bool keep_screen);
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MM_DISPLAY_H__ */
diff --git a/src/include/mm_display_interface.h b/src/include/mm_display_interface.h
new file mode 100644 (file)
index 0000000..867401a
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MM_DISPLAY_INTERFACE_H__
+#define __MM_DISPLAY_INTERFACE_H__
+
+#include <mm_types.h>
+#include <media_packet.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *mm_display_interface_h;
+
+typedef enum {
+       MM_DISPLAY_TYPE_INVALID = -1,
+       MM_DISPLAY_TYPE_OVERLAY = 0,
+       MM_DISPLAY_TYPE_EVAS
+} mm_display_type_e;
+
+typedef struct {
+       int parent_id;
+       MMRectType window;
+} mm_display_wayland_info_s;
+
+typedef void (*mm_display_evas_rendered_cb)(media_packet_h packet, void *user_data);
+
+int mm_display_interface_init(mm_display_interface_h *handle);
+int mm_display_interface_deinit(mm_display_interface_h handle);
+int mm_display_interface_set_display(mm_display_interface_h handle, mm_display_type_e type, void *display, mm_display_wayland_info_s *wl_info);
+int mm_display_interface_evas_set_rotation(mm_display_interface_h handle, int rotation);
+int mm_display_interface_evas_get_rotation(mm_display_interface_h handle, int *rotation);
+int mm_display_interface_evas_set_visible(mm_display_interface_h handle, bool visible);
+int mm_display_interface_evas_get_visible(mm_display_interface_h handle, bool *visible);
+int mm_display_interface_evas_set_flip(mm_display_interface_h handle, int flip);
+int mm_display_interface_evas_get_flip(mm_display_interface_h handle, int *flip);
+int mm_display_interface_evas_set_mode(mm_display_interface_h handle, int mode);
+int mm_display_interface_evas_get_mode(mm_display_interface_h handle, int *mode);
+int mm_display_interface_evas_set_roi_area(mm_display_interface_h handle, int x, int y, int w, int h);
+int mm_display_interface_evas_get_roi_area(mm_display_interface_h handle, int *x, int *y, int *w, int *h);
+int mm_display_interface_evas_set_rendered_cb(mm_display_interface_h handle, mm_display_evas_rendered_cb rendered_cb, void *user_data);
+int mm_display_interface_evas_render(mm_display_interface_h handle, media_packet_h packet);
+int mm_display_interface_evas_flush(mm_display_interface_h handle, bool keep_screen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MM_DISPLAY_INTERFACE_H__ */
diff --git a/src/include/mm_display_interface_private.h b/src/include/mm_display_interface_private.h
new file mode 100644 (file)
index 0000000..d32c633
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MM_DISPLAY_INTERFACE_PRIVATE_H__
+#define __MM_DISPLAY_INTERFACE_PRIVATE_H__
+
+#include <glib.h>
+#include <gmodule.h>
+#include "mm_display_interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MM_DISPLAY_LIBRARY_PATH MM_DISPLAY_LIBDIR"/libmmfdisplay.so"
+
+typedef struct mm_display_interface {
+       GModule *module;
+       void *dp_handle;
+
+       int (*init)(void **);
+       int (*deinit)(void *);
+       int (*set_display)(void *, int, void *, mm_display_wayland_info_s *);
+       int (*evas_set_rotation)(void *, int);
+       int (*evas_get_rotation)(void *, int *);
+       int (*evas_set_visible)(void *, bool);
+       int (*evas_get_visible)(void *, bool *);
+       int (*evas_set_flip)(void *, int);
+       int (*evas_get_flip)(void *, int *);
+       int (*evas_set_mode)(void *, int);
+       int (*evas_get_mode)(void *, int *);
+       int (*evas_set_roi_area)(void *, int, int, int, int);
+       int (*evas_get_roi_area)(void *, int *, int *, int *, int *);
+       int (*evas_set_rendered_cb)(void *, mm_display_evas_rendered_cb, void *);
+       int (*evas_render)(void *, media_packet_h);
+       int (*evas_flush)(void *, bool);
+} mm_display_interface_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MM_DISPLAY_INTERFACE_PRIVATE_H__ */
diff --git a/src/mm_display.c b/src/mm_display.c
new file mode 100644 (file)
index 0000000..06046af
--- /dev/null
@@ -0,0 +1,611 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include <dlog.h>
+#include <mm_error.h>
+#include <mm_types.h>
+#include <Evas.h>
+#include <Elementary.h>
+#include <Ecore_Evas.h>
+#include <Ecore_Wayland.h>
+#include <tizen-extension-client-protocol.h>
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+#include <mm_evas_renderer.h>
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+
+#include "mm_display.h"
+
+#define DECLARE_CHECK_DISPLAY_HANDLE(handle) \
+       mm_display_t *dp_handle = (mm_display_t *)handle; \
+       if (!dp_handle) { \
+               LOGE("NULL handle"); \
+               return MM_ERROR_INVALID_HANDLE; \
+       }
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MM_DISPLAY"
+
+
+
+
+/*
+ * wayland parent id related functiosn
+ */
+static void __global(void *data, struct wl_registry *registry,
+       uint32_t name, const char *interface, uint32_t version)
+{
+       struct tizen_surface **tz_surface = NULL;
+
+       if (!data) {
+               LOGE("NULL data");
+               return;
+       }
+
+       tz_surface = (struct tizen_surface **)data;
+
+       if (!interface) {
+               LOGW("NULL interface");
+               return;
+       }
+
+       /*LOGI("interface %s", interface);*/
+
+       if (strcmp(interface, "tizen_surface") == 0) {
+               LOGD("binding tizen surface for wayland");
+
+               *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
+               if (*tz_surface == NULL)
+                       LOGE("failed to bind");
+
+               LOGD("done");
+       }
+
+       return;
+}
+
+static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
+{
+       LOGD("enter");
+       return;
+}
+
+static const struct wl_registry_listener _mm_display_wl_registry_listener = {
+       __global,
+       __global_remove
+};
+
+void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
+{
+       if (!data) {
+               LOGE("NULL data");
+               return;
+       }
+
+       *((unsigned int *)data) = id;
+
+       LOGD("[CLIENT] got parent_id [%u] from server", id);
+
+       return;
+}
+
+static const struct tizen_resource_listener _mm_display_tz_resource_listener = {
+       __parent_id_getter
+};
+
+
+int _mm_display_get_wl_info(Evas_Object *obj, mm_display_wayland_info_s *wl_info)
+{
+       int ret = MM_ERROR_NONE;
+       int rotation = 0;
+       int tmp = 0;
+       Ecore_Wl_Window *window = NULL;
+       struct wl_display *display = NULL;
+       struct wl_display *display_wrapper = NULL;
+       struct wl_surface *surface = NULL;
+       struct wl_registry *registry = NULL;
+       struct wl_event_queue *queue = NULL;
+       struct tizen_surface *tz_surface = NULL;
+       struct tizen_resource *tz_resource = NULL;
+
+       if (!obj || !wl_info) {
+               LOGE("NULL parameter %p %p", obj, wl_info);
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       window = elm_win_wl_window_get(obj);
+       if (!window) {
+               LOGE("failed to get wayland window");
+               ret = MM_ERROR_UNKNOWN;
+               goto _DONE;
+       }
+
+       ecore_wl_window_video_has(window, EINA_TRUE);
+
+       surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
+       if (!surface) {
+               LOGE("failed to get wayland surface");
+               ret = MM_ERROR_UNKNOWN;
+               goto _DONE;
+       }
+
+       display = (struct wl_display *)ecore_wl_display_get();
+       if (!display) {
+               LOGE("failed to get wayland display");
+               ret = MM_ERROR_UNKNOWN;
+               goto _DONE;
+       }
+
+       display_wrapper = wl_proxy_create_wrapper(display);
+       if (!display_wrapper) {
+               LOGE("failed to create wl display wrapper");
+               ret = MM_ERROR_UNKNOWN;
+               goto _DONE;
+       }
+
+       queue = wl_display_create_queue(display);
+       if (!queue) {
+               LOGE("failed to create wl display queue");
+               ret = MM_ERROR_UNKNOWN;
+               goto _DONE;
+       }
+
+       wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
+
+       registry = wl_display_get_registry(display_wrapper);
+       if (!registry) {
+               LOGE("failed to get wayland registry");
+               ret = MM_ERROR_UNKNOWN;
+               goto _DONE;
+       }
+
+       wl_registry_add_listener(registry, &_mm_display_wl_registry_listener, &tz_surface);
+
+       wl_display_dispatch_queue(display, queue);
+       wl_display_roundtrip_queue(display, queue);
+
+       if (!tz_surface) {
+               LOGE("failed to get tizen surface");
+               ret = MM_ERROR_UNKNOWN;
+               goto _DONE;
+       }
+
+       /* Get parent_id which is unique in a entire systemw. */
+       tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
+       if (!tz_resource) {
+               LOGE("failed to get tizen resurce");
+               ret = MM_ERROR_UNKNOWN;
+               goto _DONE;
+       }
+
+       wl_info->parent_id = 0;
+
+       tizen_resource_add_listener(tz_resource, &_mm_display_tz_resource_listener, &wl_info->parent_id);
+
+       wl_display_roundtrip_queue(display, queue);
+
+       if (wl_info->parent_id > 0) {
+               Ecore_Evas *ecore_evas = NULL;
+               ret = MM_ERROR_NONE;
+
+               evas_object_geometry_get(obj, &wl_info->window.x, &wl_info->window.y,
+                       &wl_info->window.width, &wl_info->window.height);
+
+               ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
+               if (ecore_evas) {
+                       rotation = ecore_evas_rotation_get(ecore_evas);
+                       if (rotation == 90 || rotation == 270) {
+                               LOGD("swap width and height %d, %d", wl_info->window.width, wl_info->window.height);
+
+                               tmp = wl_info->window.width;
+                               wl_info->window.width = wl_info->window.height;
+                               wl_info->window.height = tmp;
+                       }
+               } else {
+                       LOGW("failed to get ecore_evas.. skip rotation check");
+               }
+
+               LOGD("eo: %p, rot: %d, id : %u, window: %d,%d,%dx%d",
+                       obj, rotation, wl_info->parent_id,
+                       wl_info->window.x, wl_info->window.y,
+                       wl_info->window.width, wl_info->window.height);
+       } else {
+               ret = MM_ERROR_UNKNOWN;
+               LOGE("failed to get parent id");
+       }
+
+_DONE:
+       if (tz_surface) {
+               tizen_surface_destroy(tz_surface);
+               tz_surface = NULL;
+       }
+
+       if (tz_resource) {
+               tizen_resource_destroy(tz_resource);
+               tz_resource = NULL;
+       }
+
+       if (registry) {
+               wl_registry_destroy(registry);
+               registry = NULL;
+       }
+
+       if (queue) {
+               wl_event_queue_destroy(queue);
+               queue = NULL;
+       }
+
+       if (display_wrapper) {
+               wl_proxy_wrapper_destroy(display_wrapper);
+               display_wrapper = NULL;
+       }
+
+       return ret;
+}
+
+
+int mm_display_init(mm_display_h *handle)
+{
+       mm_display_t *new_handle = NULL;
+
+       if (!handle) {
+               LOGE("NULL handle");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       new_handle = (mm_display_t *)calloc(1, sizeof(mm_display_t));
+       if (!new_handle) {
+               LOGE("handle allocation failed");
+               return MM_ERROR_OUT_OF_MEMORY;
+       }
+
+       new_handle->type = MM_DISPLAY_TYPE_INVALID;
+
+       *handle = (mm_display_h)new_handle;
+
+       LOGD("display handle %p", new_handle);
+
+       return MM_ERROR_NONE;
+}
+
+
+int mm_display_deinit(mm_display_h handle)
+{
+       mm_display_t *dp_handle = (mm_display_t *)handle;
+
+       if (!dp_handle) {
+               LOGE("NULL handle");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       if (dp_handle->evas_renderer) {
+               LOGD("destroy evas renderer %p", dp_handle->evas_renderer);
+               mm_evas_renderer_destroy(&dp_handle->evas_renderer);
+               g_mutex_clear(&dp_handle->evas_mutex);
+       }
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+
+       free(dp_handle);
+       dp_handle = NULL;
+
+       LOGD("done");
+
+       return MM_ERROR_NONE;
+}
+
+
+int mm_display_set_display(mm_display_h handle, mm_display_type_e type, void *display, mm_display_wayland_info_s *wl_info)
+{
+       int ret = MM_ERROR_NONE;
+       const char *object_type = NULL;
+       Evas_Object *obj = NULL;
+       mm_display_t *dp_handle = NULL;
+
+       if (!handle || !display ||
+               type < MM_DISPLAY_TYPE_OVERLAY ||
+               type > MM_DISPLAY_TYPE_EVAS) {
+               LOGE("invalid param %p %p %d", handle, display, type);
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       dp_handle = (mm_display_t *)handle;
+
+       LOGD("enter - type %d", type);
+
+       dp_handle->type = type;
+
+       obj = (Evas_Object *)display;
+       object_type = evas_object_type_get(obj);
+       if (!object_type) {
+               LOGE("failed to get evas object type from %p", obj);
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       if (type == MM_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
+               /* get wayland parent id */
+               ret = _mm_display_get_wl_info(obj, &dp_handle->wl_info);
+               if (ret == MM_ERROR_NONE && wl_info)
+                       memcpy(wl_info, &dp_handle->wl_info, sizeof(mm_display_wayland_info_s));
+               else
+                       LOGE("failed to get wayland info. ret 0x%x, %p", ret, wl_info);
+       } else if (type == MM_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
+               /* evas object surface */
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+               MMHandleType new_evas_renderer = NULL;
+
+               /* create evas renderer */
+               ret = mm_evas_renderer_create(&new_evas_renderer, obj);
+               if (ret != MM_ERROR_NONE) {
+                       LOGE("failed to creat evas renderer 0x%x", ret);
+                       ret = MM_ERROR_UNKNOWN;
+               } else {
+                       /* release previous resources */
+                       if (dp_handle->evas_renderer) {
+                               LOGW("release previous evas renderer %p", dp_handle->evas_renderer);
+                               mm_evas_renderer_destroy(dp_handle->evas_renderer);
+                               dp_handle->evas_renderer = NULL;
+                       } else {
+                               /* init mutex for first time */
+                               g_mutex_init(&dp_handle->evas_mutex);
+                       }
+
+                       dp_handle->evas_renderer = new_evas_renderer;
+
+                       LOGD("new evas renderer %p", new_evas_renderer);
+               }
+#else /* TIZEN_FEATURE_EVAS_RENDERER */
+               LOGE("EVAS surface is not supported");
+               ret = MM_ERROR_NOT_SUPPORT_API;
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+       } else {
+               LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
+               ret = MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       return ret;
+}
+
+
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+int mm_display_evas_set_rotation(mm_display_h handle, int rotation)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       g_mutex_lock(&dp_handle->evas_mutex);
+
+       ret = mm_evas_renderer_set_rotation(dp_handle->evas_renderer, rotation);
+
+       LOGD("set rotation %d, ret 0x%x", rotation, ret);
+
+       g_mutex_unlock(&dp_handle->evas_mutex);
+
+       return ret;
+}
+
+
+int mm_display_evas_get_rotation(mm_display_h handle, int *rotation)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       if (!rotation) {
+               LOGE("NULL param");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       ret = mm_evas_renderer_get_rotation(dp_handle->evas_renderer, rotation);
+
+       LOGD("get rotation %d, ret 0x%x", *rotation, ret);
+
+       return ret;
+}
+
+
+int mm_display_evas_set_visible(mm_display_h handle, bool visible)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       g_mutex_lock(&dp_handle->evas_mutex);
+
+       ret = mm_evas_renderer_set_visible(dp_handle->evas_renderer, visible);
+
+       LOGD("set visible %d, ret 0x%x", visible, ret);
+
+       g_mutex_unlock(&dp_handle->evas_mutex);
+
+       return ret;
+}
+
+
+int mm_display_evas_get_visible(mm_display_h handle, bool *visible)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       if (!visible) {
+               LOGE("NULL param");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       ret = mm_evas_renderer_get_visible(dp_handle->evas_renderer, visible);
+
+       LOGD("get visible %d, ret 0x%x", *visible, ret);
+
+       return ret;
+}
+
+
+int mm_display_evas_set_flip(mm_display_h handle, int flip)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       g_mutex_lock(&dp_handle->evas_mutex);
+
+       ret = mm_evas_renderer_set_flip(dp_handle->evas_renderer, flip);
+
+       LOGD("set flip %d, ret 0x%x", flip, ret);
+
+       g_mutex_unlock(&dp_handle->evas_mutex);
+
+       return ret;
+}
+
+
+int mm_display_evas_get_flip(mm_display_h handle, int *flip)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       if (!flip) {
+               LOGE("NULL param");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       ret = mm_evas_renderer_get_flip(dp_handle->evas_renderer, flip);
+
+       LOGD("get flip %d, ret 0x%x", *flip, ret);
+
+       return ret;
+}
+
+
+int mm_display_evas_set_mode(mm_display_h handle, int mode)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       g_mutex_lock(&dp_handle->evas_mutex);
+
+       ret = mm_evas_renderer_set_geometry(dp_handle->evas_renderer, mode);
+
+       LOGD("set mode %d, ret 0x%x", mode, ret);
+
+       g_mutex_unlock(&dp_handle->evas_mutex);
+
+       return ret;
+}
+
+
+int mm_display_evas_get_mode(mm_display_h handle, int *mode)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       if (!mode) {
+               LOGE("NULL param");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       ret = mm_evas_renderer_get_geometry(dp_handle->evas_renderer, mode);
+
+       LOGD("get mode %d, ret 0x%x", *mode, ret);
+
+       return ret;
+}
+
+
+int mm_display_evas_set_roi_area(mm_display_h handle, int x, int y, int w, int h)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       g_mutex_lock(&dp_handle->evas_mutex);
+
+       ret = mm_evas_renderer_set_roi_area(dp_handle->evas_renderer, x, y, w, h);
+
+       LOGD("set roi %d,%d,%dx%d, ret 0x%x", x, y, w, h, ret);
+
+       g_mutex_unlock(&dp_handle->evas_mutex);
+
+       return ret;
+}
+
+
+int mm_display_evas_get_roi_area(mm_display_h handle, int *x, int *y, int *w, int *h)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       if (!x || !y || !w || !h) {
+               LOGE("NULL param %p %p %p %p", x, y, w, h);
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       ret = mm_evas_renderer_get_roi_area(dp_handle->evas_renderer, x, y, w, h);
+
+       LOGD("get roi %d,%d,%dx%d, ret 0x%x", *x, *y, *w, *h, ret);
+
+       return ret;
+}
+
+
+int mm_display_evas_set_rendered_cb(mm_display_h handle, mm_display_evas_rendered_cb rendered_cb, void *user_data)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       g_mutex_lock(&dp_handle->evas_mutex);
+
+       ret = mm_evas_renderer_set_packet_rendered_callback(dp_handle->evas_renderer,
+               (mm_evas_renderer_media_packet_rendered_cb)rendered_cb, user_data);
+
+       LOGD("set rendered cb %p, ret 0x%x", rendered_cb, ret);
+
+       g_mutex_unlock(&dp_handle->evas_mutex);
+
+       return ret;
+}
+
+
+int mm_display_evas_render(mm_display_h handle, media_packet_h packet)
+{
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       g_mutex_lock(&dp_handle->evas_mutex);
+
+       mm_evas_renderer_write(packet, dp_handle->evas_renderer);
+
+       LOGD("evas render packet %p", packet);
+
+       g_mutex_unlock(&dp_handle->evas_mutex);
+
+       return MM_ERROR_NONE;
+}
+
+
+int mm_display_evas_flush(mm_display_h handle, bool keep_screen)
+{
+       int ret = MM_ERROR_NONE;
+       DECLARE_CHECK_DISPLAY_HANDLE(handle);
+
+       g_mutex_lock(&dp_handle->evas_mutex);
+
+       ret = mm_evas_renderer_retrieve_all_packets(dp_handle->evas_renderer, keep_screen);
+
+       LOGD("evas flush ret 0x%x, keep screen %d", ret, keep_screen);
+
+       g_mutex_unlock(&dp_handle->evas_mutex);
+
+       return ret;
+}
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
diff --git a/src/mm_display_interface.c b/src/mm_display_interface.c
new file mode 100644 (file)
index 0000000..818fa0a
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <dlog.h>
+#include <mm_error.h>
+
+#include "mm_display_interface_private.h"
+
+#define DECLARE_CHECK_INTERFACE_HANDLE(handle) \
+       mm_display_interface_t *interface = (mm_display_interface_t *)handle; \
+       if (!interface) { \
+               LOGE("NULL handle"); \
+               return MM_ERROR_INVALID_HANDLE; \
+       }
+
+#define CHECK_EVAS_FUNCTION_POINTER(func_ptr) \
+       if (!func_ptr) { \
+               LOGE("NULL function pointer, NOT SUPPORTED API"); \
+               return MM_ERROR_NOT_SUPPORT_API; \
+       }
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MM_DISPLAY_INTF"
+
+
+int mm_display_interface_init(mm_display_interface_h *handle)
+{
+       int ret = MM_ERROR_NONE;
+       gboolean sym_ret = FALSE;
+       GModule *module = NULL;
+       mm_display_interface_t *new_interface = NULL;
+
+       if (!handle) {
+               LOGE("NULL param");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       /* check mm-display library */
+       if (access(MM_DISPLAY_LIBRARY_PATH, F_OK) != 0) {
+               LOGE("no library : %d", errno);
+               return MM_ERROR_NOT_SUPPORT_API;
+       }
+
+       /* open mm-display library */
+       module = g_module_open(MM_DISPLAY_LIBRARY_PATH, G_MODULE_BIND_LAZY);
+       if (!module) {
+               LOGE("failed to open module");
+               return MM_ERROR_UNKNOWN;
+       }
+
+       /* allocate new handle */
+       new_interface = (mm_display_interface_t *)calloc(1, sizeof(mm_display_interface_t));
+       if (!new_interface) {
+               LOGE("interface allocation failed");
+               ret = MM_ERROR_OUT_OF_MEMORY;
+               goto _INIT_FAILED;
+       }
+
+       /* find symbols */
+       sym_ret = g_module_symbol(module, "mm_display_init", (gpointer *)&new_interface->init);
+       sym_ret &= g_module_symbol(module, "mm_display_deinit", (gpointer *)&new_interface->deinit);
+       sym_ret &= g_module_symbol(module, "mm_display_set_display", (gpointer *)&new_interface->set_display);
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       sym_ret &= g_module_symbol(module, "mm_display_evas_set_rotation", (gpointer *)&new_interface->evas_set_rotation);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_get_rotation", (gpointer *)&new_interface->evas_get_rotation);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_set_visible", (gpointer *)&new_interface->evas_set_visible);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_get_visible", (gpointer *)&new_interface->evas_get_visible);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_set_flip", (gpointer *)&new_interface->evas_set_flip);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_get_flip", (gpointer *)&new_interface->evas_get_flip);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_set_mode", (gpointer *)&new_interface->evas_set_mode);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_get_mode", (gpointer *)&new_interface->evas_get_mode);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_set_roi_area", (gpointer *)&new_interface->evas_set_roi_area);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_get_roi_area", (gpointer *)&new_interface->evas_get_roi_area);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_set_rendered_cb", (gpointer *)&new_interface->evas_set_rendered_cb);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_render", (gpointer *)&new_interface->evas_render);
+       sym_ret &= g_module_symbol(module, "mm_display_evas_flush", (gpointer *)&new_interface->evas_flush);
+       LOGD("find evas symbol done");
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+
+       if (sym_ret == FALSE || !new_interface->init) {
+               LOGE("symbol failed %d %p", sym_ret, new_interface->init);
+               ret = MM_ERROR_UNKNOWN;
+               goto _INIT_FAILED;
+       }
+
+       ret = new_interface->init(&new_interface->dp_handle);
+       if (ret != MM_ERROR_NONE) {
+               LOGE("init display handle failed 0x%x", ret);
+               goto _INIT_FAILED;
+       }
+
+       new_interface->module = module;
+       *handle = (mm_display_interface_h)new_interface;
+
+       LOGD("new interface handle %p", new_interface);
+
+       return MM_ERROR_NONE;
+
+_INIT_FAILED:
+       /* release allocated resources */
+       if (module) {
+               g_module_close(module);
+               module = NULL;
+       }
+       if (new_interface) {
+               if (new_interface->dp_handle && new_interface->deinit)
+                       new_interface->deinit(new_interface->dp_handle);
+
+               free(new_interface);
+               new_interface = NULL;
+       }
+
+       return ret;
+}
+
+
+int mm_display_interface_deinit(mm_display_interface_h handle)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+
+       LOGW("enter  - handle %p", interface);
+
+       if (interface->deinit) {
+               interface->deinit(interface->dp_handle);
+               interface->dp_handle = NULL;
+       } else {
+               LOGE("NULL deinit function");
+       }
+
+       if (interface->module) {
+               LOGW("close module %p", interface->module);
+               if (!g_module_close(interface->module)) {
+                       LOGE("close module failed");
+                       return MM_ERROR_UNKNOWN;
+               }
+       }
+
+       free(interface);
+       interface = NULL;
+
+       LOGW("leave");
+
+       return MM_ERROR_NONE;
+}
+
+
+int mm_display_interface_set_display(mm_display_interface_h handle, mm_display_type_e type, void *display, mm_display_wayland_info_s *wl_info)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+
+       if (!interface->set_display) {
+               LOGE("NULL function pointer");
+               return MM_ERROR_UNKNOWN;
+       }
+
+       return interface->set_display(interface->dp_handle, type, display, wl_info);
+
+       return MM_ERROR_NONE;
+}
+
+
+int mm_display_interface_evas_set_rotation(mm_display_interface_h handle, int rotation)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_set_rotation);
+
+       return interface->evas_set_rotation(interface->dp_handle, rotation);
+}
+
+
+int mm_display_interface_evas_get_rotation(mm_display_interface_h handle, int *rotation)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_get_rotation);
+
+       return interface->evas_get_rotation(interface->dp_handle, rotation);
+}
+
+
+int mm_display_interface_evas_set_visible(mm_display_interface_h handle, bool visible)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_set_visible);
+
+       return interface->evas_set_visible(interface->dp_handle, visible);
+}
+
+
+int mm_display_interface_evas_get_visible(mm_display_interface_h handle, bool *visible)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_get_visible);
+
+       return interface->evas_get_visible(interface->dp_handle, visible);
+}
+
+
+int mm_display_interface_evas_set_flip(mm_display_interface_h handle, int flip)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_set_flip);
+
+       return interface->evas_set_flip(interface->dp_handle, flip);
+}
+
+
+int mm_display_interface_evas_get_flip(mm_display_interface_h handle, int *flip)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_get_flip);
+
+       return interface->evas_get_flip(interface->dp_handle, flip);
+}
+
+
+int mm_display_interface_evas_set_mode(mm_display_interface_h handle, int mode)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_set_mode);
+
+       return interface->evas_set_mode(interface->dp_handle, mode);
+}
+
+
+int mm_display_interface_evas_get_mode(mm_display_interface_h handle, int *mode)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_get_mode);
+
+       return interface->evas_get_mode(interface->dp_handle, mode);
+}
+
+
+int mm_display_interface_evas_set_roi_area(mm_display_interface_h handle, int x, int y, int w, int h)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_set_roi_area);
+
+       return interface->evas_set_roi_area(interface->dp_handle, x, y, w, h);
+}
+
+
+int mm_display_interface_evas_get_roi_area(mm_display_interface_h handle, int *x, int *y, int *w, int *h)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_get_roi_area);
+
+       return interface->evas_get_roi_area(interface->dp_handle, x, y, w, h);
+}
+
+
+int mm_display_interface_evas_render(mm_display_interface_h handle, media_packet_h packet)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_render);
+
+       return interface->evas_render(interface->dp_handle, packet);
+}
+
+
+int mm_display_interface_evas_flush(mm_display_interface_h handle, bool keep_screen)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_flush);
+
+       return interface->evas_flush(interface->dp_handle, keep_screen);
+}
+
+
+int mm_display_interface_evas_set_rendered_cb(mm_display_interface_h handle, mm_display_evas_rendered_cb rendered_cb, void *user_data)
+{
+       DECLARE_CHECK_INTERFACE_HANDLE(handle);
+       CHECK_EVAS_FUNCTION_POINTER(interface->evas_set_rendered_cb);
+
+       return interface->evas_set_rendered_cb(interface->dp_handle, rendered_cb, user_data);
+}