diff options
author | jino.cho <jino.cho@samsung.com> | 2016-08-25 18:42:35 +0900 |
---|---|---|
committer | Joonyoung Shim <jy0922.shim@samsung.com> | 2017-02-15 13:37:34 +0900 |
commit | 59167be0ede1070bc39ae1a534e13a2aa366e050 (patch) | |
tree | ac0db54e7d4af6df50955777f7fc8dde654e41f9 | |
parent | 8e5d29c79e2a40152ba383a5b32dc246bbd25402 (diff) | |
download | libdrm-59167be0ede1070bc39ae1a534e13a2aa366e050.tar.gz libdrm-59167be0ede1070bc39ae1a534e13a2aa366e050.tar.bz2 libdrm-59167be0ede1070bc39ae1a534e13a2aa366e050.zip |
libdrm : add nexell api
This patch imports the nexell api of the libdrm
Change-Id: If8009fc30f46edcf4fdcc04679523e590e165003
Signed-off-by: jino.cho <jino.cho@samsung.com>
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | nexell/Makefile.am | 22 | ||||
-rw-r--r-- | nexell/libdrm_nexell.pc.in | 11 | ||||
-rw-r--r-- | nexell/nexell_drm.c | 82 | ||||
-rw-r--r-- | nexell/nexell_drm.h | 74 | ||||
-rw-r--r-- | nexell/nexell_drmif.h | 43 | ||||
-rw-r--r-- | packaging/libdrm.spec | 5 |
8 files changed, 256 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 4161ad95..93b4bb86 100644 --- a/Makefile.am +++ b/Makefile.am @@ -94,6 +94,10 @@ if HAVE_VIGS VIGS_SUBDIR = vigs endif +if HAVE_NEXELL +NEXELL_SUBDIR = nexell +endif + if BUILD_MANPAGES if HAVE_MANPAGES_STYLESHEET MAN_SUBDIR = man @@ -114,6 +118,7 @@ SUBDIRS = \ $(VC4_SUBDIR) \ $(ETNAVIV_SUBDIR) \ $(VIGS_SUBDIR) \ + $(NEXELL_SUBDIR) \ tests \ $(MAN_SUBDIR) diff --git a/configure.ac b/configure.ac index 35977f0f..c5c5f569 100644 --- a/configure.ac +++ b/configure.ac @@ -138,6 +138,11 @@ AC_ARG_ENABLE(vigs, [Enable support for VIGS's API (default: enabled)]), [VIGS=$enableval], [VIGS=yes]) +AC_ARG_ENABLE(nexell, + AS_HELP_STRING([--enable-nexell], + [Enable support for nexell (default: disabled)]), + [NEXELL=$enableval], [NEXELL=no]) + AC_ARG_ENABLE(install-test-programs, AS_HELP_STRING([--enable-install-test-programs], [Install test programs (default: no)]), @@ -432,6 +437,11 @@ if test "x$VIGS" = xyes; then AC_DEFINE(HAVE_VIGS, 1, [Have VIGS support]) fi +AM_CONDITIONAL(HAVE_NEXELL, [test "x$NEXELL" = xyes]) +if test "x$NEXELL" = xyes; then + AC_DEFINE(HAVE_NEXELL, 1, [Have NEXELL support]) +fi + AM_CONDITIONAL(HAVE_INSTALL_TESTS, [test "x$INSTALL_TESTS" = xyes]) if test "x$INSTALL_TESTS" = xyes; then AC_DEFINE(HAVE_INSTALL_TESTS, 1, [Install test programs]) @@ -540,6 +550,8 @@ AC_CONFIG_FILES([ etnaviv/libdrm_etnaviv.pc vigs/Makefile vigs/libdrm_vigs.pc + nexell/Makefile + nexell/libdrm_nexell.pc tests/Makefile tests/modeprint/Makefile tests/modetest/Makefile @@ -577,4 +589,6 @@ echo " Tegra API $TEGRA" echo " VC4 API $VC4" echo " Etnaviv API $ETNAVIV" echo " VIGS API $VIGS" +echo " NEXELL API $NEXELL" + echo "" diff --git a/nexell/Makefile.am b/nexell/Makefile.am new file mode 100644 index 00000000..617d1385 --- /dev/null +++ b/nexell/Makefile.am @@ -0,0 +1,22 @@ +AM_CFLAGS = \ + $(WARN_CFLAGS) \ + $(VISIBILITY_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/nexell \ + -I$(top_srcdir)/include/drm + +libdrm_nexell_la_LTLIBRARIES = libdrm_nexell.la +libdrm_nexell_ladir = $(libdir) +libdrm_nexell_la_LDFLAGS = -version-number 1:0:0 -no-undefined +libdrm_nexell_la_LIBADD = ../libdrm.la + +libdrm_nexell_la_SOURCES = \ + nexell_drm.c + +libdrm_nexellcommonincludedir = ${includedir}/nexell +libdrm_nexellcommoninclude_HEADERS = nexell_drm.h +libdrm_nexellincludedir = ${includedir}/libdrm +libdrm_nexellinclude_HEADERS = nexell_drmif.h + +pkgconfigdir = @pkgconfigdir@ +pkgconfig_DATA = libdrm_nexell.pc diff --git a/nexell/libdrm_nexell.pc.in b/nexell/libdrm_nexell.pc.in new file mode 100644 index 00000000..7e638005 --- /dev/null +++ b/nexell/libdrm_nexell.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libdrm_nexell +Description: Userspace interface to nexell kernel DRM services +Version: 0.7 +Libs: -L${libdir} -ldrm_nexell +Cflags: -I${includedir} -I${includedir}/libdrm -I${includedir}/nexell +Requires.private: libdrm diff --git a/nexell/nexell_drm.c b/nexell/nexell_drm.c new file mode 100644 index 00000000..8d5bfd7a --- /dev/null +++ b/nexell/nexell_drm.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2016 Nexell Co., Ltd. + * Author: hyejung, kwon <cjscld15@nexell.co.kr> + * + * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <stdint.h> + +#include <xf86drm.h> + +#include "nexell_drm.h" +#include "nexell_drmif.h" + +/** + * return gem_fd + */ +int nx_alloc_gem(int drm_fd, int size, int flags) +{ + struct nx_drm_gem_create arg = { 0, }; + int ret; + + arg.size = size; + arg.flags = flags; + + ret = drmCommandWriteRead(drm_fd, DRM_NX_GEM_CREATE, &arg, + sizeof(arg)); + if (ret) { + perror("drmCommandWriteRead\n"); + return ret; + } + + return arg.handle; +} + +void nx_free_gem(int drm_fd, int gem) +{ + struct drm_gem_close arg = {0, }; + + arg.handle = gem; + drmIoctl(drm_fd, DRM_IOCTL_GEM_CLOSE, &arg); +} + +/** + * return dmabuf fd + */ +int nx_gem_to_dmafd(int drm_fd, int gem_fd) +{ + int ret, fd; + + ret = drmPrimeHandleToFD(drm_fd, gem_fd, 0, &fd); + if (ret) + return ret; + + return fd; +} diff --git a/nexell/nexell_drm.h b/nexell/nexell_drm.h new file mode 100644 index 00000000..f5ca7544 --- /dev/null +++ b/nexell/nexell_drm.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2016 Nexell Co., Ltd. + * Author: hyejung, kwon <cjscld15@nexell.co.kr> + * + * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + */ + +#ifndef _UAPI_NX_DRM_H_ +#define _UAPI_NX_DRM_H_ + +#include "drm.h" + +/** + * User-desired buffer creation information structure. + * + * @size: user-desired memory allocation size. + * - this size value would be page-aligned internally. + * @flags: user request for setting memory type or cache attributes. + * @handle: returned a handle to created gem object. + * - this handle will be set by gem module of kernel side. + */ +struct nx_drm_gem_create { + uint64_t size; + unsigned int flags; + unsigned int handle; +}; + +/** + * A structure to gem information. + * + * @handle: a handle to gem object created. + * @flags: flag value including memory type and cache attribute and + * this value would be set by driver. + * @size: size to memory region allocated by gem and this size would + * be set by driver. + */ +struct nx_drm_gem_info { + unsigned int handle; + unsigned int flags; + uint64_t size; +}; + +#define DRM_NX_GEM_CREATE 0x00 +#define DRM_NX_GEM_GET 0x04 +#define DRM_NX_GEM_SYNC 0x05 + +#define DRM_IOCTL_NX_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_NX_GEM_CREATE, struct nx_drm_gem_create) + +#define DRM_IOCTL_NX_GEM_SYNC DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_NX_GEM_SYNC, struct nx_drm_gem_create) + +#define DRM_IOCTL_NX_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_NX_GEM_GET, struct nx_drm_gem_info) +#endif diff --git a/nexell/nexell_drmif.h b/nexell/nexell_drmif.h new file mode 100644 index 00000000..09a6eb0c --- /dev/null +++ b/nexell/nexell_drmif.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2016 Nexell Co., Ltd. + * Author: hyejung, kwon <cjscld15@nexell.co.kr> + * + * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + */ + +#ifndef _NEXELL_DRMIF_H +#define _NEXELL_DRMIF_H + +#ifdef __cplusplus +extern "C" { +#endif + +int nx_alloc_gem(int drm_fd, int size, int flags); +int nx_gem_to_dmafd(int drm_fd, int gem_fd); +void nx_free_gem(int drm_fd, int gem); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/packaging/libdrm.spec b/packaging/libdrm.spec index 8a4de9f0..2dc62055 100644 --- a/packaging/libdrm.spec +++ b/packaging/libdrm.spec @@ -72,6 +72,7 @@ cp %{SOURCE1001} . --disable-radeon \ --disable-nouveau \ --enable-exynos-experimental-api \ + --enable-nexell \ --enable-install-test-programs \ --disable-cairo-tests @@ -105,6 +106,7 @@ rm -f %{buildroot}%{_bindir}/kmstest %{_libdir}/libdrm.so.* %{_libdir}/libdrm_exynos.so.* %{_libdir}/libdrm_vigs.so.* +%{_libdir}/libdrm_nexell.so.* %files tools %manifest %{name}.manifest @@ -128,6 +130,8 @@ rm -f %{buildroot}%{_bindir}/kmstest %{_includedir}/libkms/*.h %dir %{_includedir}/exynos %{_includedir}/exynos/*.h +%dir %{_includedir}/nexell +%{_includedir}/nexell/*.h %{_includedir}/*.h %{_libdir}/libdrm.so %ifarch i586 i686 %ix86 x86_64 @@ -135,6 +139,7 @@ rm -f %{buildroot}%{_bindir}/kmstest %endif %{_libdir}/libkms.so %{_libdir}/libdrm_exynos.so +%{_libdir}/libdrm_nexell.so %{_libdir}/libdrm_vigs.so %{_libdir}/pkgconfig/* |