summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChangyeon Lee <cyeon.lee@samsung.com>2022-06-22 17:54:07 +0900
committerChangyeon Lee <cyeon.lee@samsung.com>2022-06-22 19:29:04 +0900
commit62e5aa585dca2143efa94d457406841ac1de5861 (patch)
tree4ef1a40975fdfa68e7c3c5c8abd05d59429cf924
parent2bf954f4782a45ea6929941661f4b9dc31e4c97e (diff)
downloadlibtbm-vigs-accepted/tizen_8.0_unified.tar.gz
libtbm-vigs-accepted/tizen_8.0_unified.tar.bz2
libtbm-vigs-accepted/tizen_8.0_unified.zip
Change-Id: I0bcf6aac6cba8160f4a1c83ada9852765c8a8b12
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac21
-rw-r--r--libtbm-vigs.pc.in10
-rw-r--r--packaging/hal-backend-tbm-vigs.manifest (renamed from packaging/libhal-backend-tbm-vigs.manifest)0
-rw-r--r--packaging/hal-backend-tbm-vigs.spec64
-rw-r--r--packaging/libtbm-vigs.manifest5
-rw-r--r--packaging/libtbm-vigs.spec123
-rw-r--r--src/Makefile.am15
-rw-r--r--src/libhal-backend-tbm-vigs/Makefile.am15
-rw-r--r--src/libhal-backend-tbm-vigs/tbm_vigs.h39
-rw-r--r--src/libhal_backend_tbm_vigs.h (renamed from src/libhal-backend-tbm-vigs/libhal_backend_tbm_vigs.h)0
-rw-r--r--src/libtbm-vigs/Makefile.am14
-rwxr-xr-xsrc/libtbm-vigs/tbm_bufmgr_vigs.c1099
-rw-r--r--src/libtbm-vigs/tbm_vigs.h39
-rw-r--r--src/tbm_backend_log.c (renamed from src/libhal-backend-tbm-vigs/tbm_backend_log.c)0
-rw-r--r--src/tbm_backend_log.h (renamed from src/libhal-backend-tbm-vigs/tbm_backend_log.h)0
-rw-r--r--src/tbm_backend_vigs.c (renamed from src/libhal-backend-tbm-vigs/tbm_backend_vigs.c)0
17 files changed, 81 insertions, 1365 deletions
diff --git a/Makefile.am b/Makefile.am
index 02d3393..a8144e4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
SUBDIRS = src
pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libtbm-vigs.pc hal-backend-tbm-vigs.pc
+pkgconfig_DATA = hal-backend-tbm-vigs.pc
diff --git a/configure.ac b/configure.ac
index 18cb477..1108725 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AC_PREREQ(2.60)
-AC_INIT(libtbm-vigs, 1.0.0)
+AC_INIT(hal-backend-tbm-vigs, 1.0.0)
AC_USE_SYSTEM_EXTENSIONS
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
@@ -38,20 +38,10 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
PKG_CHECK_MODULES(LIBDRM, libdrm)
PKG_CHECK_MODULES(LIBDRM_VIGS, libdrm_vigs)
-PKG_CHECK_MODULES(LIBTBM, libtbm)
PKG_CHECK_MODULES(HAL_API_COMMON, hal-api-common)
PKG_CHECK_MODULES(HAL_API_TBM, hal-api-tbm)
PKG_CHECK_MODULES(DLOG, dlog)
-LIBTBM_VIGS_CFLAGS="$LIBDRM_CFLAGS $LIBDRM_VIGS_CFLAGS $LIBTBM_CFLAGS "
-LIBTBM_VIGS_LIBS="$LIBDRM_LIBS $LIBDRM_VIGS_LIBS $LIBTBM_LIBS "
-AC_SUBST(LIBTBM_VIGS_CFLAGS)
-AC_SUBST(LIBTBM_VIGS_LIBS)
-
-#bufmgr_dir=${libdir#*/}
-bufmgr_dir=${libdir}/bufmgr/
-AC_SUBST(bufmgr_dir)
-
# set the data dir for the tdm config
DEFAULT_HAL_LIBDIR="/hal/lib"
AC_ARG_WITH(hal-libdir, AS_HELP_STRING([--with-hal-libdir=PATH], [hal backend library path]),
@@ -60,7 +50,6 @@ AC_ARG_WITH(hal-libdir, AS_HELP_STRING([--with-hal-libdir=PATH], [hal backend li
AC_DEFINE_UNQUOTED(HAL_LIBDIR, "${HAL_LIBDIR}", [Directory for hal backend library path])
AC_SUBST(HAL_LIBDIR)
-# for libhal-backend-tbm-exynos-tgm
LIBHAL_BACKEND_TBM_VIGS_CFLAGS="$HAL_API_COMMON_CFLAGS $HAL_API_TBM_CFLAGS $LIBDRM_CFLAGS $LIBDRM_VIGS_CFLAGS $CAPI_CFLAGS $DLOG_CFLAGS "
LIBHAL_BACKEND_TBM_VIGS_LIBS="$HAL_API_COMMON_LIBS $HAL_API_TBM_LIBS $LIBDRM_LIBS $LIBDRM_VIGS_LIBS $CAPI_LIBS $DLOG_LIBS "
@@ -69,19 +58,13 @@ AC_SUBST(LIBHAL_BACKEND_TBM_VIGS_LIBS)
AC_OUTPUT([
Makefile
- src/libtbm-vigs/Makefile
- src/libhal-backend-tbm-vigs/Makefile
src/Makefile
- libtbm-vigs.pc
hal-backend-tbm-vigs.pc])
echo ""
echo "CFLAGS : $CFLAGS"
echo "LDFLAGS : $LDFLAGS"
-echo "LIBTBM_VIGS_CFLAGS : $LIBTBM_VIGS_CFLAGS"
-echo "LIBTBM_VIGS_LIBS : $LIBTBM_VIGS_LIBS"
-echo "bufmgr_dir : $bufmgr_dir"
echo "LIBHAL_BACKEND_TBM_VIGS_CFLAGS : $LIBHAL_BACKEND_TBM_VIGS_CFLAGS"
echo "LIBHAL_BACKEND_TBM_VIGS_LIBS : $LIBHAL_BACKEND_TBM_VIGS_LIBS"
-echo "hal-libdir : $HAL_LIBDIR"
+echo "HAL_LIBDIR : $HAL_LIBDIR"
echo ""
diff --git a/libtbm-vigs.pc.in b/libtbm-vigs.pc.in
deleted file mode 100644
index 98b2e8a..0000000
--- a/libtbm-vigs.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libtbm-vigs
-Description: the library for Tizen Buffer Manager vigs backend
-Version: @PACKAGE_VERSION@
-Libs: -L${libdir}/bufmgr -ltbm_vigs
-Cflags: -I${includedir} -I${includedir}/tbm-vigs
diff --git a/packaging/libhal-backend-tbm-vigs.manifest b/packaging/hal-backend-tbm-vigs.manifest
index 017d22d..017d22d 100644
--- a/packaging/libhal-backend-tbm-vigs.manifest
+++ b/packaging/hal-backend-tbm-vigs.manifest
diff --git a/packaging/hal-backend-tbm-vigs.spec b/packaging/hal-backend-tbm-vigs.spec
new file mode 100644
index 0000000..29dcd2e
--- /dev/null
+++ b/packaging/hal-backend-tbm-vigs.spec
@@ -0,0 +1,64 @@
+Name: hal-backend-tbm-vigs
+Version: 3.0.5
+Release: 1
+License: MIT
+Summary: hal tbm backend module for vigs
+Group: System/Libraries
+Source0: %{name}-%{version}.tar.gz
+Source1001: %{name}.manifest
+
+BuildRequires: pkgconfig(libdrm)
+BuildRequires: pkgconfig(hal-api-common)
+BuildRequires: pkgconfig(hal-api-tbm)
+BuildRequires: pkgconfig(dlog)
+
+%description
+description: hal tbm backend module for vigs
+
+%package devel
+Summary: hal-backend-tbm library for vigs
+Group: System/Libraries
+Requires: hal-backend-tbm-vigs
+
+%description devel
+description: hal tbm backend library headers for vigs
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+autoreconf -vfi
+./configure --prefix=%{_prefix} --libdir=%{_libdir} \
+ --with-hal-libdir=%{_hal_libdir} \
+ CFLAGS="${CFLAGS} -Wall -Werror" LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed"
+
+make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+# make rule and license files
+mkdir -p %{buildroot}%{_hal_licensedir}/libhal-backend-tbm-vigs
+cp -af COPYING %{buildroot}%{_hal_licensedir}/libhal-backend-tbm-vigs
+
+%post
+if [ -f %{_hal_libdir}/libhal-backend-tbm.so ]; then
+ rm -rf %{_hal_libdir}/libhal-backend-tbm.so
+fi
+ln -s libhal-backend-tbm-vigs.so %{_hal_libdir}/libhal-backend-tbm.so
+
+%postun -n hal-backend-tbm-vigs -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%{_hal_licensedir}/libhal-backend-tbm-vigs/COPYING
+%{_hal_libdir}/libhal-backend-*.so*
+
+%files devel
+%defattr(-,root,root,-)
+%dir %{_includedir}
+%{_includedir}/tbm-vigs/libhal_backend_tbm_vigs.h
+%{_hal_libdir}/libhal-backend-tbm*.so
+%{_libdir}/pkgconfig/hal-backend-tbm-vigs.pc
diff --git a/packaging/libtbm-vigs.manifest b/packaging/libtbm-vigs.manifest
deleted file mode 100644
index 017d22d..0000000
--- a/packaging/libtbm-vigs.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
diff --git a/packaging/libtbm-vigs.spec b/packaging/libtbm-vigs.spec
deleted file mode 100644
index 385ab2c..0000000
--- a/packaging/libtbm-vigs.spec
+++ /dev/null
@@ -1,123 +0,0 @@
-Name: libtbm-vigs
-Version: 3.0.5
-Release: 1
-License: MIT
-Summary: Tizen Buffer Manager - vigs backend
-Group: System/Libraries
-Source0: %{name}-%{version}.tar.gz
-Source1001: libtbm-vigs.manifest
-Source1002: libhal-backend-tbm-vigs.manifest
-
-BuildRequires: pkgconfig(libdrm)
-BuildRequires: pkgconfig(libtbm)
-
-Requires: libtbm
-Requires: libdrm
-BuildRequires: pkgconfig(hal-api-common)
-BuildRequires: pkgconfig(hal-api-tbm)
-BuildRequires: pkgconfig(dlog)
-
-%description
-description: ${summary}
-
-%package devel
-Summary: Tizen Buffer Manager Library Backend for vigs
-Group: Development/Libraries
-
-%description devel
-TBM vigs backend. Developement Files.
-
-%package -n hal-backend-tbm-vigs
-Summary: hal-backend-tbm module for vigs
-Group: System/Libraries
-Requires: hal-api-tbm
-Requires: hal-api-common
-
-%description -n hal-backend-tbm-vigs
-descriptionion: hal tbm backend module for vigs
-
-%package -n hal-backend-tbm-vigs-devel
-Summary: hal-backend-tbm library for vigs
-Group: System/Libraries
-Requires: hal-backend-tbm-vigs
-
-%description -n hal-backend-tbm-vigs-devel
-descriptionion: hal tbm backend library headers for vigs
-
-
-%prep
-%setup -q
-cp %{SOURCE1001} .
-cp %{SOURCE1002} .
-
-%build
-autoreconf -vfi
-./configure --prefix=%{_prefix} --libdir=%{_libdir} \
- --with-hal-libdir=%{_hal_libdir} \
- CFLAGS="${CFLAGS} -Wall -Werror" LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed"
-
-make %{?_smp_mflags}
-
-%install
-rm -rf %{buildroot}
-%make_install
-
-# make rule and license files
-mkdir -p %{buildroot}%{_hal_licensedir}/libhal-backend-tbm-vigs
-cp -af COPYING %{buildroot}%{_hal_licensedir}/libhal-backend-tbm-vigs
-
-%post
-if [ -f %{_libdir}/bufmgr/libtbm_default.so ]; then
- rm -rf %{_libdir}/bufmgr/libtbm_default.so
-fi
-ln -s libtbm_vigs.so %{_libdir}/bufmgr/libtbm_default.so
-
-if [ -f %{_libdir}/libtbm_vigs.so ]; then
- rm -rf %{_libdir}/libtbm_vigs.so
-fi
-ln -s bufmgr/libtbm_vigs.so %{_libdir}/libtbm_vigs.so
-
-if [ -f %{_libdir}/libtbm_vigs.so.0 ]; then
- rm -rf %{_libdir}/libtbm_vigs.so.0
-fi
-ln -s %{_libdir}/bufmgr/libtbm_vigs.so.0 %{_libdir}/libtbm_vigs.so.0
-
-if [ -f %{_libdir}/libtbm_vigs.so.0.0.0 ]; then
- rm -rf %{_libdir}/libtbm_vigs.so.0.0.0
-fi
-ln -s %{_libdir}/bufmgr/libtbm_vigs.so.0.0.0 %{_libdir}/libtbm_vigs.so.0.0.0
-
-%postun -p /sbin/ldconfig
-
-%post -n hal-backend-tbm-vigs
-if [ -f %{_hal_libdir}/libhal-backend-tbm.so ]; then
- rm -rf %{_hal_libdir}/libhal-backend-tbm.so
-fi
-ln -s libhal-backend-tbm-vigs.so %{_hal_libdir}/libhal-backend-tbm.so
-
-%postun -n hal-backend-tbm-vigs -p /sbin/ldconfig
-
-%files
-%manifest %{name}.manifest
-%defattr(-,root,root,-)
-%license COPYING
-%{_libdir}/bufmgr/libtbm_*.so*
-
-%files devel
-%defattr(-,root,root,-)
-%dir %{_includedir}
-%{_includedir}/tbm-vigs/tbm_vigs.h
-%{_libdir}/bufmgr/libtbm_*.so
-%{_libdir}/pkgconfig/libtbm-vigs.pc
-
-%files -n hal-backend-tbm-vigs
-%manifest libhal-backend-tbm-vigs.manifest
-%{_hal_licensedir}/libhal-backend-tbm-vigs/COPYING
-%{_hal_libdir}/libhal-backend-*.so*
-
-%files -n hal-backend-tbm-vigs-devel
-%defattr(-,root,root,-)
-%dir %{_includedir}
-%{_includedir}/tbm-vigs/libhal_backend_tbm_vigs.h
-%{_hal_libdir}/libhal-backend-tbm*.so
-%{_libdir}/pkgconfig/hal-backend-tbm-vigs.pc
diff --git a/src/Makefile.am b/src/Makefile.am
index 7244c42..097fc7d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,2 +1,15 @@
-SUBDIRS = libtbm-vigs libhal-backend-tbm-vigs
+AM_CFLAGS = \
+ @LIBHAL_BACKEND_TBM_VIGS_CFLAGS@ \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src
+libhal_backend_tbm_vigs_la_LTLIBRARIES = libhal-backend-tbm-vigs.la
+libhal_backend_tbm_vigs_ladir = @HAL_LIBDIR@
+libhal_backend_tbm_vigs_la_LIBADD = @LIBHAL_BACKEND_TBM_VIGS_LIBS@
+
+libhal_backend_tbm_vigs_la_SOURCES = \
+ tbm_backend_log.c \
+ tbm_backend_vigs.c
+
+libhal_backend_tbm_vigs_includedir=$(includedir)/tbm-vigs
+libhal_backend_tbm_vigs_include_HEADERS = libhal_backend_tbm_vigs.h
diff --git a/src/libhal-backend-tbm-vigs/Makefile.am b/src/libhal-backend-tbm-vigs/Makefile.am
deleted file mode 100644
index c857ce1..0000000
--- a/src/libhal-backend-tbm-vigs/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-AM_CFLAGS = \
- @LIBHAL_BACKEND_TBM_VIGS_CFLAGS@ \
- -I$(top_srcdir) \
- -I$(top_srcdir)/src/libhal-backend-tbm-vigs
-
-libhal_backend_tbm_vigs_la_LTLIBRARIES = libhal-backend-tbm-vigs.la
-libhal_backend_tbm_vigs_ladir = @HAL_LIBDIR@
-libhal_backend_tbm_vigs_la_LIBADD = @LIBHAL_BACKEND_TBM_VIGS_LIBS@
-
-libhal_backend_tbm_vigs_la_SOURCES = \
- tbm_backend_log.c \
- tbm_backend_vigs.c
-
-libhal_backend_tbm_vigs_includedir=$(includedir)/tbm-vigs
-libhal_backend_tbm_vigs_include_HEADERS = libhal_backend_tbm_vigs.h
diff --git a/src/libhal-backend-tbm-vigs/tbm_vigs.h b/src/libhal-backend-tbm-vigs/tbm_vigs.h
deleted file mode 100644
index eefeacb..0000000
--- a/src/libhal-backend-tbm-vigs/tbm_vigs.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * libtbm-vigs header
- *
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact :
- * SooChan Lim <sc1.lim@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#ifndef _TBM_VIGS_LOG_H_
-#define _TBM_VIGS_LOG_H_
-
-#include "vigs.h"
-
-struct vigs_drm_device *tbm_vigs_get_drm_dev(void);
-
-#endif
diff --git a/src/libhal-backend-tbm-vigs/libhal_backend_tbm_vigs.h b/src/libhal_backend_tbm_vigs.h
index 9d65686..9d65686 100644
--- a/src/libhal-backend-tbm-vigs/libhal_backend_tbm_vigs.h
+++ b/src/libhal_backend_tbm_vigs.h
diff --git a/src/libtbm-vigs/Makefile.am b/src/libtbm-vigs/Makefile.am
deleted file mode 100644
index 7db9357..0000000
--- a/src/libtbm-vigs/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
-AM_CFLAGS = \
- @LIBTBM_VIGS_CFLAGS@ \
- -I$(top_srcdir) \
- -I$(top_srcdir)/src
-
-libtbm_vigs_la_LTLIBRARIES = libtbm_vigs.la
-libtbm_vigs_ladir = /${bufmgr_dir}
-libtbm_vigs_la_LIBADD = @LIBTBM_VIGS_LIBS@
-
-libtbm_vigs_la_SOURCES = \
- tbm_bufmgr_vigs.c
-
-libtbm_vigs_includedir=$(includedir)/tbm-vigs
-libtbm_vigs_include_HEADERS = tbm_vigs.h
diff --git a/src/libtbm-vigs/tbm_bufmgr_vigs.c b/src/libtbm-vigs/tbm_bufmgr_vigs.c
deleted file mode 100755
index 3dc7244..0000000
--- a/src/libtbm-vigs/tbm_bufmgr_vigs.c
+++ /dev/null
@@ -1,1099 +0,0 @@
-/*
- * buffer manager for libtbm-vigs
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact :
- * Stanislav Vorobiov <s.vorobiov@samsung.com>
- * Jinhyung Jo <jinhyung.jo@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "vigs.h"
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <xf86drm.h>
-#include <tbm_backend.h>
-#include <tbm_drm_helper.h>
-#include <tbm_log.h>
-
-#define STRERR_BUFSIZE 128
-
-#define VIGS_DRM_NAME "vigs"
-
-/* global singleton drm_dev. this is shared with yagl. */
-struct vigs_drm_device *g_drm_dev = NULL;
-
-static uint32_t tbm_bufmgr_vigs_color_format_list[] = {
- TBM_FORMAT_RGB888,
- TBM_FORMAT_ARGB8888,
- TBM_FORMAT_RGBA8888,
- TBM_FORMAT_XRGB8888,
- TBM_FORMAT_XBGR8888,
- TBM_FORMAT_NV21,
- TBM_FORMAT_NV61,
- TBM_FORMAT_YUV420,
-};
-
-typedef struct _tbm_bufmgr_vigs *tbm_bufmgr_vigs;
-typedef struct _tbm_bo_vigs *tbm_bo_vigs;
-
-/* tbm buffor object for vigs */
-struct _tbm_bo_vigs {
- struct vigs_drm_surface *sfc;
-
- tbm_bufmgr_vigs bufmgr_vigs;
-};
-
-/* tbm bufmgr private for vigs */
-struct _tbm_bufmgr_vigs {
- struct vigs_drm_device *drm_dev;
- void *hash_bos;
-
- tbm_backend_bufmgr_func *bufmgr_func;
- tbm_backend_bo_func *bo_func;
-
- tbm_bufmgr bufmgr;
-};
-
-static int _tbm_vigs_open_drm(void)
-{
- int fd = -1;
-
- fd = drmOpen(VIGS_DRM_NAME, NULL);
- if (fd < 0) {
- TBM_ERR("open vigs drm device failed");
- return -1;
- }
-
- return fd;
-}
-
-static unsigned int
-_get_name(int fd, unsigned int gem)
-{
- struct drm_gem_flink arg = {0,};
-
- arg.handle = gem;
- if (drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &arg)) {
- TBM_ERR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem);
- return 0;
- }
-
- return (unsigned int)arg.name;
-}
-
-static tbm_bo_handle get_tbm_bo_handle(struct vigs_drm_surface *sfc, int device)
-{
- tbm_bo_handle bo_handle;
- int ret;
- struct vigs_drm_gem *gem = &sfc->gem;
- char buf[STRERR_BUFSIZE];
-
- memset(&bo_handle, 0, sizeof(bo_handle));
-
- switch (device) {
- case TBM_DEVICE_DEFAULT:
- case TBM_DEVICE_2D:
- bo_handle.u32 = gem->handle;
- break;
- case TBM_DEVICE_CPU:
- ret = vigs_drm_gem_map(gem, 1);
-
- if (ret == 0)
- bo_handle.ptr = gem->vaddr;
- else
- TBM_ERR("vigs_drm_gem_map failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
-
- break;
- case TBM_DEVICE_3D:
- bo_handle.ptr = (void *)sfc;
- break;
- case TBM_DEVICE_MM:
- TBM_ERR("TBM_DEVICE_MM not supported");
- break;
- default:
- TBM_ERR("%d not supported", device);
- break;
- }
-
- return bo_handle;
-}
-
-static tbm_bufmgr_capability
-tbm_vigs_bufmgr_get_capabilities(tbm_backend_bufmgr_data *bufmgr_data, tbm_error_e *error)
-{
- tbm_bufmgr_capability capabilities = TBM_BUFMGR_CAPABILITY_NONE;
-
- capabilities = TBM_BUFMGR_CAPABILITY_SHARE_KEY|TBM_BUFMGR_CAPABILITY_SHARE_FD;
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return capabilities;
-}
-
-static tbm_error_e
-tbm_vigs_bufmgr_bind_native_display(tbm_backend_bufmgr_data *bufmgr_data, tbm_native_display *native_display)
-{
- tbm_bufmgr_vigs bufmgr_vigs = (tbm_bufmgr_vigs)bufmgr_data;
- struct vigs_drm_device *drm_dev;
- char *device_name;
- int ret = 0;
-
- if (bufmgr_vigs == NULL || bufmgr_vigs->drm_dev == NULL) {
- TBM_ERR("bufmgr_data is null\n");
- return TBM_ERROR_INVALID_PARAMETER;
- }
-
- drm_dev = bufmgr_vigs->drm_dev;
-
- device_name = drmGetDeviceNameFromFd(drm_dev->fd);
- if (!device_name) {
- TBM_ERR("drmGetDeviceNameFromFd failed");
- return TBM_ERROR_INVALID_OPERATION;
- }
-
- ret = tbm_drm_helper_wl_auth_server_init(native_display, drm_dev->fd, device_name, 0);
- if (!ret) {
- TBM_ERR("tbm_drm_helper_wl_auth_server_init failed");
- free(device_name);
- return TBM_ERROR_INVALID_OPERATION;
- }
-
- free(device_name);
-
- return TBM_ERROR_NONE;
-}
-
-static tbm_error_e
-tbm_vigs_bufmgr_get_supported_formats(tbm_backend_bufmgr_data *bufmgr_data,
- uint32_t **formats, uint32_t *num)
-{
- tbm_bufmgr_vigs bufmgr_vigs = (tbm_bufmgr_vigs)bufmgr_data;
- uint32_t *color_formats;
-
- if (!bufmgr_vigs)
- return TBM_ERROR_INVALID_PARAMETER;
-
- color_formats = (uint32_t *) calloc(1, sizeof(tbm_bufmgr_vigs_color_format_list));
- if (!color_formats)
- return TBM_ERROR_OUT_OF_MEMORY;
-
- memcpy(color_formats, tbm_bufmgr_vigs_color_format_list, sizeof(tbm_bufmgr_vigs_color_format_list));
-
- *formats = color_formats;
- *num = sizeof(tbm_bufmgr_vigs_color_format_list) / sizeof(tbm_bufmgr_vigs_color_format_list[0]);
-
- return TBM_ERROR_NONE;
-}
-
-static tbm_error_e
-tbm_vigs_bufmgr_get_plane_data(tbm_backend_bufmgr_data *bufmgr_data,
- tbm_format format, int plane_idx, int width,
- int height, uint32_t * size, uint32_t * offset,
- uint32_t * pitch, int *bo_idx)
-{
- tbm_bufmgr_vigs bufmgr_vigs = (tbm_bufmgr_vigs)bufmgr_data;
-
- *size = 0;
- *offset = 0;
- *pitch = 0;
- *bo_idx = 0;
-
- if (!bufmgr_vigs)
- return TBM_ERROR_INVALID_PARAMETER;
-
- switch (format) {
- case TBM_FORMAT_RGB888:
- *size = width * height * 3;
- *offset = 0;
- *pitch = width * 3;
- *bo_idx = 0;
- return TBM_ERROR_NONE;
- case TBM_FORMAT_XRGB8888:
- case TBM_FORMAT_XBGR8888:
- case TBM_FORMAT_ARGB8888:
- case TBM_FORMAT_RGBA8888:
- *size = width * height * 4;
- *offset = 0;
- *pitch = width * 4;
- *bo_idx = 0;
- return TBM_ERROR_NONE;
- case TBM_FORMAT_NV21:
- if (plane_idx == 0) {
- *size = width * height;
- *offset = 0;
- *pitch = width;
- *bo_idx = 0;
- } else if (plane_idx == 1) {
- *size = width * (height >> 1);
- *offset = width * height;
- *pitch = width;
- *bo_idx = 0;
- } else {
- return TBM_ERROR_INVALID_PARAMETER;
- }
- return TBM_ERROR_NONE;
- case TBM_FORMAT_NV61:
- if (plane_idx == 0) {
- *size = width * height;
- *offset = 0;
- *pitch = width;
- *bo_idx = 0;
- } else if (plane_idx == 1) {
- *size = width * height;
- *offset = width * height;
- *pitch = width;
- *bo_idx = 0;
- } else {
- return TBM_ERROR_INVALID_PARAMETER;
- }
- return TBM_ERROR_NONE;
- case TBM_FORMAT_YUV420:
- if (plane_idx == 0) {
- *size = width * height;
- *offset = 0;
- *pitch = width;
- *bo_idx = 0;
- } else if (plane_idx == 1) {
- *size = (width * height) >> 2;
- *offset = width * height;
- *pitch = width >> 1;
- *bo_idx = 0;
- } else if (plane_idx == 2) {
- *size = (width * height) >> 2;
- *offset = (width * height) + (width * height >> 2);
- *pitch = width >> 1;
- *bo_idx = 0;
- } else {
- return TBM_ERROR_INVALID_PARAMETER;
- }
- return TBM_ERROR_NONE;
- default:
- return TBM_ERROR_INVALID_PARAMETER;
- }
-}
-
-static tbm_backend_bo_data *
-tbm_vigs_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, unsigned int size,
- tbm_bo_memory_type flags, tbm_error_e *error)
-{
- tbm_bufmgr_vigs bufmgr_vigs = (tbm_bufmgr_vigs)bufmgr_data;
- tbm_bo_vigs bo_vigs;
- struct vigs_drm_device *drm_dev;
- struct vigs_drm_surface *sfc;
- uint32_t width = 2048, height;
- int ret;
- char buf[STRERR_BUFSIZE];
-
- if (bufmgr_vigs == NULL || bufmgr_vigs->drm_dev == NULL) {
- TBM_ERR("bufmgr_data is null\n");
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- drm_dev = bufmgr_vigs->drm_dev;
-
- height = ((uint32_t) size + (width * 4) - 1) / (width * 4);
-
- ret = vigs_drm_surface_create(drm_dev, width, height, width * 4, vigs_drm_surface_bgra8888, 0, &sfc);
- if (ret != 0) {
- TBM_ERR("vigs_drm_suface_create failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- bo_vigs = calloc(1, sizeof(struct _tbm_bo_vigs));
- if (!bo_vigs) {
- TBM_ERR("fail to allocate the bo_vigs private\n");
- vigs_drm_gem_unref(&sfc->gem);
- if (error)
- *error = TBM_ERROR_OUT_OF_MEMORY;
- return NULL;
- }
- bo_vigs->bufmgr_vigs = bufmgr_vigs;
- bo_vigs->sfc = sfc;
-
- ret = vigs_drm_gem_get_name(&sfc->gem);
- if (ret != 0) {
- TBM_ERR("vigs_drm_gem_get_name failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- vigs_drm_gem_unref(&sfc->gem);
- free(bo_vigs);
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return 0;
- }
-
- if (drmHashInsert(bufmgr_vigs->hash_bos, bo_vigs->sfc->gem.name, (void *)bo_vigs) < 0)
- TBM_ERR("Cannot insert bo_vigs to Hash(%d)\n", bo_vigs->sfc->gem.name);
-
- TBM_DBG("size = %d, flags = 0x%X", size, flags);
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return (tbm_backend_bo_data *)bo_vigs;
-}
-
-static tbm_backend_bo_data *
-tbm_bufmgr_vigs_alloc_bo_with_format(tbm_backend_bufmgr_data *bufmgr_data, int format, int bo_idx,
- int width, int height, tbm_bo_memory_type flags, tbm_error_e *error)
-{
- tbm_bufmgr_vigs bufmgr_vigs = (tbm_bufmgr_vigs)bufmgr_data;
- tbm_bo_vigs bo_vigs;
- struct vigs_drm_device *drm_dev;
- struct vigs_drm_surface *sfc;
- int ret;
- char buf[STRERR_BUFSIZE];
-
- if (bufmgr_vigs == NULL || bufmgr_vigs->drm_dev == NULL) {
- TBM_ERR("bufmgr_data is null\n");
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- if (bo_idx != 0) {
- TBM_ERR("Not supported bo idx");
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- drm_dev = bufmgr_vigs->drm_dev;
-
- switch (format) {
- case TBM_FORMAT_RGB888:
- ret = vigs_drm_surface_create(drm_dev, width, height, width * 3, vigs_drm_surface_bgra8888, 0, &sfc);
- break;
- case TBM_FORMAT_XRGB8888:
- case TBM_FORMAT_XBGR8888:
- ret = vigs_drm_surface_create(drm_dev, width, height, width * 4, vigs_drm_surface_bgra8888, 0, &sfc);
- break;
- case TBM_FORMAT_ARGB8888:
- case TBM_FORMAT_RGBA8888:
- ret = vigs_drm_surface_create(drm_dev, width, height, width * 4, vigs_drm_surface_bgra8888, 0, &sfc);
- break;
- case TBM_FORMAT_NV21:
- ret = vigs_drm_surface_create(drm_dev, width, height * 3 >> 1, width, vigs_drm_surface_bgra8888, 0, &sfc);
- break;
- case TBM_FORMAT_NV61:
- ret = vigs_drm_surface_create(drm_dev, width, height * 2, width, vigs_drm_surface_bgra8888, 0, &sfc);
- break;
- case TBM_FORMAT_YUV420:
- ret = vigs_drm_surface_create(drm_dev, width >> 2, height * 3 >> 1, width, vigs_drm_surface_bgra8888, 0, &sfc);
- break;
- default:
- TBM_ERR("Not supported format");
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- if (ret != 0) {
- TBM_ERR("vigs_drm_suface_create failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- bo_vigs = calloc(1, sizeof(struct _tbm_bo_vigs));
- if (!bo_vigs) {
- TBM_ERR("fail to allocate the bo_vigs private\n");
- vigs_drm_gem_unref(&sfc->gem);
- if (error)
- *error = TBM_ERROR_OUT_OF_MEMORY;
- return NULL;
- }
- bo_vigs->bufmgr_vigs = bufmgr_vigs;
- bo_vigs->sfc = sfc;
-
- ret = vigs_drm_gem_get_name(&sfc->gem);
- if (ret != 0) {
- TBM_ERR("vigs_drm_gem_get_name failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- vigs_drm_gem_unref(&sfc->gem);
- free(bo_vigs);
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return 0;
- }
-
- if (drmHashInsert(bufmgr_vigs->hash_bos, bo_vigs->sfc->gem.name, (void *)bo_vigs) < 0)
- TBM_ERR("Cannot insert bo_vigs to Hash(%d)\n", bo_vigs->sfc->gem.name);
-
- TBM_DBG("width = %d, height = %d, format = %x, flags = 0x%X bo_idx = %d",
- width, height, format, flags, bo_idx);
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return (tbm_backend_bo_data *)bo_vigs;
-}
-
-static tbm_backend_bo_data *
-tbm_vigs_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_error_e *error)
-{
- tbm_bufmgr_vigs bufmgr_vigs = (tbm_bufmgr_vigs)bufmgr_data;
- tbm_bo_vigs bo_vigs;
- struct vigs_drm_device *drm_dev;
- struct vigs_drm_surface *sfc;
- int ret;
- char buf[STRERR_BUFSIZE];
- struct drm_prime_handle arg = {0, };
- unsigned int gem;
- unsigned int name;
-
- if (bufmgr_vigs == NULL || bufmgr_vigs->drm_dev == NULL) {
- TBM_ERR("bufmgr_data is null\n");
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- drm_dev = bufmgr_vigs->drm_dev;
-
- arg.fd = key;
- if (drmIoctl(bufmgr_vigs->drm_dev->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) {
- TBM_ERR("Cannot get gem handle from fd:%d (%s)\n",
- arg.fd, strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return NULL;
- }
- gem = arg.handle;
-
- name = _get_name(bufmgr_vigs->drm_dev->fd, gem);
- if (!name) {
- TBM_ERR("Cannot get name from gem:%d, fd:%d (%s)\n",
- gem, key, strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return NULL;
- }
-
- ret = drmHashLookup(bufmgr_vigs->hash_bos, name, (void **)&bo_vigs);
- if (ret == 0) {
- if (gem == bo_vigs->sfc->gem.handle) {
- if (error)
- *error = TBM_ERROR_NONE;
- return (tbm_backend_bo_data *)bo_vigs;
- }
- }
-
- ret = vigs_drm_prime_import_fd(drm_dev, key, &sfc);
- if (ret != 0) {
- TBM_ERR("vigs_drm_prime_import_fd failed for key %d: %s",
- key, strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return NULL;
- }
-
- bo_vigs = calloc(1, sizeof(struct _tbm_bo_vigs));
- if (!bo_vigs) {
- TBM_ERR("fail to allocate the bo_vigs private\n");
- vigs_drm_gem_unref(&sfc->gem);
- if (error)
- *error = TBM_ERROR_OUT_OF_MEMORY;
- return NULL;
- }
- bo_vigs->bufmgr_vigs = bufmgr_vigs;
- bo_vigs->sfc = sfc;
-
- ret = vigs_drm_gem_get_name(&sfc->gem);
- if (ret != 0) {
- TBM_ERR("vigs_drm_gem_get_name failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- vigs_drm_gem_unref(&sfc->gem);
- free(bo_vigs);
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return 0;
- }
-
- if (drmHashInsert(bufmgr_vigs->hash_bos, bo_vigs->sfc->gem.name, (void *)bo_vigs) < 0)
- TBM_ERR("Cannot insert bo_vigs to Hash(%d)\n", bo_vigs->sfc->gem.name);
-
- TBM_DBG("bo_vigs = %p, key = %u handle = %u", bo_vigs, key, sfc->gem.handle);
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return (tbm_backend_bo_data *)bo_vigs;
-}
-
-static tbm_backend_bo_data *
-tbm_vigs_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tbm_error_e *error)
-{
- tbm_bufmgr_vigs bufmgr_vigs = (tbm_bufmgr_vigs)bufmgr_data;
- tbm_bo_vigs bo_vigs;
- struct vigs_drm_device *drm_dev;
- int ret;
- struct vigs_drm_surface *sfc;
- char buf[STRERR_BUFSIZE];
-
- if (bufmgr_vigs == NULL || bufmgr_vigs->drm_dev == NULL) {
- TBM_ERR("bufmgr_data is null\n");
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- drm_dev = bufmgr_vigs->drm_dev;
-
- ret = drmHashLookup(bufmgr_vigs->hash_bos, key, (void **)&bo_vigs);
- if (ret == 0) {
- if (error)
- *error = TBM_ERROR_NONE;
- return (tbm_backend_bo_data *)bo_vigs;
- }
-
- ret = vigs_drm_surface_open(drm_dev, key, &sfc);
- if (ret != 0) {
- TBM_ERR("vigs_drm_surface_open failed for key %u: %s",
- key, strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return NULL;
- }
-
- bo_vigs = calloc(1, sizeof(struct _tbm_bo_vigs));
- if (!bo_vigs) {
- TBM_ERR("fail to allocate the bo_vigs private\n");
- vigs_drm_gem_unref(&sfc->gem);
- if (error)
- *error = TBM_ERROR_OUT_OF_MEMORY;
- return NULL;
- }
- bo_vigs->bufmgr_vigs = bufmgr_vigs;
- bo_vigs->sfc = sfc;
-
- ret = vigs_drm_gem_get_name(&sfc->gem);
- if (ret != 0) {
- TBM_ERR("vigs_drm_gem_get_name failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- vigs_drm_gem_unref(&sfc->gem);
- free(bo_vigs);
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return 0;
- }
-
- if (drmHashInsert(bufmgr_vigs->hash_bos, bo_vigs->sfc->gem.name, (void *)bo_vigs) < 0)
- TBM_ERR("Cannot insert bo_vigs to Hash(%d)\n", bo_vigs->sfc->gem.name);
-
- TBM_DBG("bo_vigs = %p, key = %u handle = %u", bo_vigs, key, sfc->gem.handle);
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return (tbm_backend_bo_data *)bo_vigs;
-}
-
-static void
-tbm_vigs_bo_free(tbm_backend_bo_data *bo_data)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
- tbm_bo_vigs temp;
- struct vigs_drm_surface *sfc;
- tbm_bufmgr_vigs bufmgr_vigs;
- int ret;
-
- if (!bo_data)
- return;
-
- bufmgr_vigs = bo_vigs->bufmgr_vigs;
- if (!bufmgr_vigs)
- return;
-
- TBM_DBG("bo_vigs = %p", bo_vigs);
-
- sfc = bo_vigs->sfc;
-
- /* delete bo from hash */
- ret = drmHashLookup(bufmgr_vigs->hash_bos, sfc->gem.name,
- (void **)&temp);
- if (ret == 0)
- drmHashDelete(bufmgr_vigs->hash_bos, sfc->gem.name);
- else
- TBM_ERR("Cannot find bo_vigs to Hash(%d), ret=%d\n", sfc->gem.name, ret);
-
- vigs_drm_gem_unref(&sfc->gem);
-
- free(bo_vigs);
-}
-
-static int
-tbm_vigs_bo_get_size(tbm_backend_bo_data *bo_data, tbm_error_e *error)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
- struct vigs_drm_surface *sfc;
-
- if (!bo_vigs || !bo_vigs->sfc) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return 0;
- }
-
- TBM_DBG("bo_vigs = %p", bo_vigs);
-
- sfc = bo_vigs->sfc;
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return sfc->gem.size;
-}
-
-static tbm_bo_memory_type
-tbm_vigs_bo_get_memory_type(tbm_backend_bo_data *bo_data, tbm_error_e *error)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
-
- if (!bo_vigs || !bo_vigs->sfc) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return TBM_BO_DEFAULT;
- }
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return TBM_BO_DEFAULT;
-}
-
-static tbm_bo_handle
-tbm_vigs_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device, tbm_error_e *error)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
- struct vigs_drm_surface *sfc;
- tbm_bo_handle handle;
-
- if (!bo_vigs || !bo_vigs->sfc) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return (tbm_bo_handle) NULL;
- }
-
- sfc = bo_vigs->sfc;
-
- TBM_DBG("bo_vigs = %p, device = %d", bo_vigs, device);
-
- handle = get_tbm_bo_handle(sfc, device);
- if (!handle.ptr) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return handle;
- }
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return handle;
-}
-
-static tbm_bo_handle
-tbm_vigs_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device,
- tbm_bo_access_option opt, tbm_error_e *error)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
- struct vigs_drm_surface *sfc;
- tbm_bo_handle handle;
- uint32_t saf = 0;
-
- if (!bo_vigs || !bo_vigs->sfc) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return (tbm_bo_handle) NULL;
- }
-
- sfc = bo_vigs->sfc;
-
- TBM_DBG("bo_vigs = %p, device = %d, opt = %d", bo_vigs, device, opt);
-
- handle = get_tbm_bo_handle(sfc, device);
- if (!handle.ptr) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return handle;
- }
-
- if ((opt & TBM_OPTION_READ) != 0)
- saf |= VIGS_DRM_SAF_READ;
-
- if ((opt & TBM_OPTION_WRITE) != 0)
- saf |= VIGS_DRM_SAF_WRITE;
-
- vigs_drm_surface_start_access(sfc, saf);
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return handle;
-}
-
-static tbm_error_e
-tbm_vigs_bo_unmap(tbm_backend_bo_data *bo_data)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
- struct vigs_drm_surface *sfc;
-
- if (!bo_vigs || !bo_vigs->sfc)
- return TBM_ERROR_INVALID_PARAMETER;
-
- sfc = bo_vigs->sfc;
-
- TBM_DBG("bo_vigs = %p", bo_vigs);
-
- vigs_drm_surface_end_access(sfc, 1);
-
- return TBM_ERROR_NONE;
-}
-
-static tbm_error_e
-tbm_vigs_bo_lock(tbm_backend_bo_data *bo_data, tbm_bo_device_type device,
- tbm_bo_access_option opt)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
-
- if (!bo_vigs || !bo_vigs->sfc)
- return TBM_ERROR_INVALID_PARAMETER;
-
- TBM_DBG("bo_vigs = %p", bo_vigs);
-
- return TBM_ERROR_NONE;
-}
-
-static tbm_error_e
-tbm_vigs_bo_unlock(tbm_backend_bo_data *bo_data)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
-
- if (!bo_vigs || !bo_vigs->sfc)
- return TBM_ERROR_INVALID_PARAMETER;
-
- TBM_DBG("bo_vigs = %p", bo_data);
-
- return TBM_ERROR_NONE;
-}
-
-tbm_fd
-tbm_vigs_bo_export_fd(tbm_backend_bo_data *bo_data, tbm_error_e *error)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
- tbm_bufmgr_vigs bufmgr_vigs;
- struct vigs_drm_surface *sfc;
- struct vigs_drm_device *drm_dev;
- int ret, fd = 0;
- char buf[STRERR_BUFSIZE];
-
- if (!bo_vigs || !bo_vigs->sfc) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return -1;
- }
-
- bufmgr_vigs = bo_vigs->bufmgr_vigs;
- if (!bufmgr_vigs || !bufmgr_vigs->drm_dev) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return -1;
- }
-
- drm_dev = bufmgr_vigs->drm_dev;
- sfc = bo_vigs->sfc;
-
- ret = vigs_drm_prime_export_fd(drm_dev, sfc, &fd);
- if (ret != 0) {
- TBM_ERR("vigs_drm_prime_export_fd failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return -1;
- }
-
- TBM_DBG(" bo_vigs:%p, gem:%d(%d)\n", bo_vigs, sfc->gem);
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return (tbm_fd)fd;
-}
-
-static tbm_key
-tbm_vigs_bo_export_key(tbm_backend_bo_data *bo_data, tbm_error_e *error)
-{
- tbm_bo_vigs bo_vigs = (tbm_bo_vigs)bo_data;
- struct vigs_drm_surface *sfc;
- int ret;
- char buf[STRERR_BUFSIZE];
-
- if (!bo_vigs || !bo_vigs->sfc) {
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return 0;
- }
-
- sfc = bo_vigs->sfc;
-
- ret = vigs_drm_gem_get_name(&sfc->gem);
- if (ret != 0) {
- TBM_ERR("vigs_drm_gem_get_name failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- return 0;
- }
-
- TBM_DBG(" bo_vigs:%p, gem:%d(%d)\n", bo_vigs, sfc->gem);
-
- if (error)
- *error = TBM_ERROR_NONE;
-
- return (tbm_key)sfc->gem.name;
-}
-
-static void
-tbm_vigs_deinit(tbm_backend_bufmgr_data *bufmgr_data)
-{
- tbm_bufmgr_vigs bufmgr_vigs = (tbm_bufmgr_vigs)bufmgr_data;
- struct vigs_drm_device *drm_dev;
- tbm_error_e error;
- tbm_bufmgr bufmgr;
- unsigned long key;
- void *value;
-
- TBM_DBG("enter");
-
- if (!bufmgr_vigs)
- return;
-
- drm_dev = bufmgr_vigs->drm_dev;
- if (!drm_dev)
- return;
-
- bufmgr = bufmgr_vigs->bufmgr;
- if (!bufmgr)
- return;
-
- if (bufmgr_vigs->hash_bos) {
- while (drmHashFirst(bufmgr_vigs->hash_bos, &key, &value) > 0) {
- free(value);
- drmHashDelete(bufmgr_vigs->hash_bos, key);
- }
-
- drmHashDestroy(bufmgr_vigs->hash_bos);
- bufmgr_vigs->hash_bos = NULL;
- }
-
- if (tbm_backend_bufmgr_query_display_server(bufmgr, &error)) {
- tbm_drm_helper_wl_auth_server_deinit();
- tbm_drm_helper_unset_tbm_master_fd();
- }
-
- close(drm_dev->fd);
-
- vigs_drm_device_destroy(drm_dev);
-
- g_drm_dev = NULL;
-}
-
-static tbm_backend_bufmgr_data *
-tbm_vigs_init(tbm_bufmgr bufmgr, tbm_error_e *error)
-{
- tbm_bufmgr_vigs bufmgr_vigs = NULL;
- tbm_backend_bufmgr_func *bufmgr_func = NULL;
- tbm_backend_bo_func *bo_func = NULL;
- int ret = 0;
- struct vigs_drm_device *drm_dev = NULL;
- int drm_fd = -1;
- tbm_error_e err;
- char buf[STRERR_BUFSIZE];
- int set_master = 0;
-
- TBM_DBG("enter");
-
- if (!bufmgr) {
- TBM_ERR("bufmgr is null.\n");
- if (error)
- *error = TBM_ERROR_INVALID_PARAMETER;
- return NULL;
- }
-
- bufmgr_vigs = calloc(1, sizeof(struct _tbm_bufmgr_vigs));
- if (!bufmgr_vigs) {
- TBM_ERR("fail to alloc bufmgr_vigs!\n");
- if (error)
- *error = TBM_ERROR_OUT_OF_MEMORY;
- return NULL;
- }
-
- /* check the master_fd which already had opened */
- drm_fd = tbm_drm_helper_get_master_fd();
- if (drm_fd < 0) {
- drm_fd = _tbm_vigs_open_drm();
- if (drm_fd < 0) {
- TBM_ERR("fail to open drm!\n");
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- goto fail_open_drm;
- }
-
- if (drmIsMaster(drm_fd)) {
- tbm_drm_helper_set_tbm_master_fd(drm_fd);
- set_master = 1;
- TBM_INFO("This is Master FD(%d) from open_drm.", drm_fd);
- } else {
- /* close the fd and get the authenticated fd from the master fd */
- close(drm_fd);
- drm_fd = -1;
-
- /* get the authenticated drm fd from the master fd */
- if (!tbm_drm_helper_get_auth_info(&(drm_fd), NULL, NULL)) {
- TBM_ERR("fail to get auth drm info!\n");
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- goto fail_get_auth_info;
- }
- TBM_INFO("This is Authenticated FD(%d)", drm_fd);
- }
- } else {
- TBM_INFO("This is Master FD from tbm_drm_helper_get_master_fd(%d)", drm_fd);
- }
- tbm_drm_helper_set_fd(drm_fd);
-
- ret = vigs_drm_device_create(drm_fd, &drm_dev);
- if (ret != 0) {
- TBM_ERR("vigs_drm_device_create failed: %s", strerror_r(errno, buf, STRERR_BUFSIZE));
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- goto fail_create_vigs_drm_device;
- }
- bufmgr_vigs->drm_dev = drm_dev;
- g_drm_dev = drm_dev;
-
- bufmgr_vigs->hash_bos = drmHashCreate();
-
- /* alloc and register bufmgr_funcs */
- bufmgr_func = tbm_backend_bufmgr_alloc_bufmgr_func(bufmgr, &err);
- if (!bufmgr_func) {
- TBM_ERR("fail to alloc bufmgr_func! err(%d)\n", err);
- if (error)
- *error = TBM_ERROR_OUT_OF_MEMORY;
- goto fail_alloc_bufmgr_func;
- }
-
- bufmgr_func->bufmgr_get_capabilities = tbm_vigs_bufmgr_get_capabilities;
- bufmgr_func->bufmgr_bind_native_display = tbm_vigs_bufmgr_bind_native_display;
- bufmgr_func->bufmgr_get_supported_formats = tbm_vigs_bufmgr_get_supported_formats;
- bufmgr_func->bufmgr_get_plane_data = tbm_vigs_bufmgr_get_plane_data;
- bufmgr_func->bufmgr_alloc_bo = tbm_vigs_bufmgr_alloc_bo;
- bufmgr_func->bufmgr_alloc_bo_with_format = tbm_bufmgr_vigs_alloc_bo_with_format;
- bufmgr_func->bufmgr_import_fd = tbm_vigs_bufmgr_import_fd;
- bufmgr_func->bufmgr_import_key = tbm_vigs_bufmgr_import_key;
-
- err = tbm_backend_bufmgr_register_bufmgr_func(bufmgr, bufmgr_func);
- if (err != TBM_ERROR_NONE) {
- TBM_ERR("fail to register bufmgr_func! err(%d)\n", err);
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- goto fail_register_bufmgr_func;
- }
- bufmgr_vigs->bufmgr_func = bufmgr_func;
-
- /* alloc and register bo_funcs */
- bo_func = tbm_backend_bufmgr_alloc_bo_func(bufmgr, &err);
- if (!bo_func) {
- TBM_ERR("fail to alloc bo_func! err(%d)\n", err);
- if (error)
- *error = TBM_ERROR_OUT_OF_MEMORY;
- goto fail_alloc_bo_func;
- }
-
- bo_func->bo_free = tbm_vigs_bo_free;
- bo_func->bo_get_size = tbm_vigs_bo_get_size;
- bo_func->bo_get_memory_types = tbm_vigs_bo_get_memory_type;
- bo_func->bo_get_handle = tbm_vigs_bo_get_handle;
- bo_func->bo_map = tbm_vigs_bo_map;
- bo_func->bo_unmap = tbm_vigs_bo_unmap;
- bo_func->bo_lock = tbm_vigs_bo_lock;
- bo_func->bo_unlock = tbm_vigs_bo_unlock;
- bo_func->bo_export_fd = tbm_vigs_bo_export_fd;
- bo_func->bo_export_key = tbm_vigs_bo_export_key;
-
- err = tbm_backend_bufmgr_register_bo_func(bufmgr, bo_func);
- if (err != TBM_ERROR_NONE) {
- TBM_ERR("fail to register bo_func! err(%d)\n", err);
- if (error)
- *error = TBM_ERROR_INVALID_OPERATION;
- goto fail_register_bo_func;
- }
- bufmgr_vigs->bo_func = bo_func;
-
- TBM_INFO("initialized");
-
- return (tbm_backend_bufmgr_data *)bufmgr_vigs;
-
-fail_register_bo_func:
- tbm_backend_bufmgr_free_bo_func(bufmgr, bo_func);
-fail_alloc_bo_func:
-fail_register_bufmgr_func:
- tbm_backend_bufmgr_free_bufmgr_func(bufmgr, bufmgr_func);
-fail_alloc_bufmgr_func:
- drmHashDestroy(bufmgr_vigs->hash_bos);
- vigs_drm_device_destroy(drm_dev);
-fail_create_vigs_drm_device:
- if (set_master)
- tbm_drm_helper_unset_tbm_master_fd();
- if (drm_fd >= 0)
- close(drm_fd);
-fail_get_auth_info:
-fail_open_drm:
- if (bufmgr_vigs)
- free(bufmgr_vigs);
- g_drm_dev = NULL;
- return NULL;
-}
-
-tbm_backend_module tbm_backend_module_data = {
- "vigs",
- "Samsung",
- TBM_BACKEND_ABI_VERSION_3_0,
- tbm_vigs_init,
- tbm_vigs_deinit
-};
-
-struct vigs_drm_device *
-tbm_vigs_get_drm_dev(void)
-{
- return g_drm_dev;
-}
diff --git a/src/libtbm-vigs/tbm_vigs.h b/src/libtbm-vigs/tbm_vigs.h
deleted file mode 100644
index eefeacb..0000000
--- a/src/libtbm-vigs/tbm_vigs.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * libtbm-vigs header
- *
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact :
- * SooChan Lim <sc1.lim@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#ifndef _TBM_VIGS_LOG_H_
-#define _TBM_VIGS_LOG_H_
-
-#include "vigs.h"
-
-struct vigs_drm_device *tbm_vigs_get_drm_dev(void);
-
-#endif
diff --git a/src/libhal-backend-tbm-vigs/tbm_backend_log.c b/src/tbm_backend_log.c
index 6516221..6516221 100644
--- a/src/libhal-backend-tbm-vigs/tbm_backend_log.c
+++ b/src/tbm_backend_log.c
diff --git a/src/libhal-backend-tbm-vigs/tbm_backend_log.h b/src/tbm_backend_log.h
index f530f8b..f530f8b 100644
--- a/src/libhal-backend-tbm-vigs/tbm_backend_log.h
+++ b/src/tbm_backend_log.h
diff --git a/src/libhal-backend-tbm-vigs/tbm_backend_vigs.c b/src/tbm_backend_vigs.c
index 6fa2d98..6fa2d98 100644
--- a/src/libhal-backend-tbm-vigs/tbm_backend_vigs.c
+++ b/src/tbm_backend_vigs.c