diff options
author | jino.cho <jino.cho@samsung.com> | 2016-08-25 18:42:35 +0900 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2019-04-25 17:58:35 +0900 |
commit | 9bf00bbae21c4e9da4fcaba6fdd20f468ef8e597 (patch) | |
tree | 938806af64d4300fe918f2cf10302f1061f6703c | |
parent | 8a0fcc247fa36c164700ac68e66cdc27310316d8 (diff) | |
download | libdrm-9bf00bbae21c4e9da4fcaba6fdd20f468ef8e597.tar.gz libdrm-9bf00bbae21c4e9da4fcaba6fdd20f468ef8e597.tar.bz2 libdrm-9bf00bbae21c4e9da4fcaba6fdd20f468ef8e597.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 | 16 | ||||
-rw-r--r-- | nexell/Makefile.am | 22 | ||||
-rw-r--r-- | nexell/libdrm_nexell.pc.in | 11 | ||||
-rw-r--r-- | nexell/nexell_drm.c | 78 | ||||
-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, 254 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 5bea2131..a7e08d84 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) \ data \ tests \ $(MAN_SUBDIR) diff --git a/configure.ac b/configure.ac index f75369af..d2a02792 100644 --- a/configure.ac +++ b/configure.ac @@ -156,6 +156,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)]), @@ -462,6 +467,13 @@ else AC_DEFINE(HAVE_VIGS, 0) fi +AM_CONDITIONAL(HAVE_NEXELL, [test "x$NEXELL" = xyes]) +if test "x$NEXELL" = xyes; then + AC_DEFINE(HAVE_NEXELL, 1, [Have NEXELL support]) +else + AC_DEFINE(HAVE_NEXELL, 0) +fi + AM_CONDITIONAL(HAVE_INSTALL_TESTS, [test "x$INSTALL_TESTS" = xyes]) AC_ARG_ENABLE([cairo-tests], @@ -576,6 +588,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 @@ -612,4 +626,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..8a8201e2 --- /dev/null +++ b/nexell/nexell_drm.c @@ -0,0 +1,78 @@ +/* + * 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. + * + */ + +#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 fdebc1b7..5fbf2f2a 100644 --- a/packaging/libdrm.spec +++ b/packaging/libdrm.spec @@ -70,6 +70,7 @@ cp %{SOURCE1001} . --disable-nouveau \ --disable-freedreno \ --enable-exynos-experimental-api \ + --enable-nexell \ --enable-install-test-programs \ --disable-cairo-tests @@ -96,6 +97,7 @@ cp %{SOURCE1001} . %{_libdir}/libdrm.so.* %{_libdir}/libdrm_exynos.so.* %{_libdir}/libdrm_vigs.so.* +%{_libdir}/libdrm_nexell.so.* %files tools %manifest %{name}.manifest @@ -124,6 +126,8 @@ cp %{SOURCE1001} . %{_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 @@ -131,6 +135,7 @@ cp %{SOURCE1001} . %endif %{_libdir}/libkms.so %{_libdir}/libdrm_exynos.so +%{_libdir}/libdrm_nexell.so %{_libdir}/libdrm_vigs.so %{_libdir}/pkgconfig/* |