Search
SailfishOS Open Build Service
>
Projects
>
home:piggz
:
dontbeevil
>
libdrm
> _service:tar_git:libdrm_nexel-api-add.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File _service:tar_git:libdrm_nexel-api-add.patch of Package libdrm
diff --git a/meson.build b/meson.build index b3eb846..8d94a8b 100644 --- a/meson.build +++ b/meson.build @@ -150,6 +150,7 @@ if _etnaviv == 'true' endif with_exynos = get_option('exynos') == 'true' +with_nexell = get_option('nexell') == 'true' with_vc4 = false _vc4 = get_option('vc4') @@ -257,6 +258,7 @@ config.set10('HAVE_VISIBILITY', foreach t : [ [with_exynos, 'EXYNOS'], + [with_nexell, 'NEXELL'], [with_freedreno_kgsl, 'FREEDRENO_KGSL'], [with_intel, 'INTEL'], [with_nouveau, 'NOUVEAU'], @@ -350,6 +352,9 @@ endif if with_exynos subdir('exynos') endif +if with_nexell + subdir('nexell') +endif if with_freedreno subdir('freedreno') endif @@ -379,6 +384,7 @@ message(' AMDGPU API @0@'.format(with_amdgpu)) message(' Nouveau API @0@'.format(with_nouveau)) message(' OMAP API @0@'.format(with_omap)) message(' EXYNOS API @0@'.format(with_exynos)) +message(' NEXELL API @0@'.format(with_nexell)) message(' Freedreno API @0@ (kgsl: @1@)'.format(with_freedreno, with_freedreno_kgsl)) message(' Tegra API @0@'.format(with_tegra)) message(' VC4 API @0@'.format(with_vc4)) diff --git a/meson_options.txt b/meson_options.txt index 8af33f1..122d4d4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -75,6 +75,14 @@ option( description : '''Enable support for EXYNOS's experimental KMS API.''', ) option( + 'nexell', + type : 'combo', + value : 'false', + choices : ['true', 'false', 'auto'], + description : '''Enable support for Nexell experimental KMS API.''', +) + +option( 'freedreno', type : 'combo', value : 'auto', diff --git a/nexell/libdrm_nexell.pc.in b/nexell/libdrm_nexell.pc.in new file mode 100644 index 0000000..7e63800 --- /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/meson.build b/nexell/meson.build new file mode 100644 index 0000000..77fa59b --- /dev/null +++ b/nexell/meson.build @@ -0,0 +1,47 @@ +# Copyright © 2017-2018 Intel Corporation + +# 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. + +libdrm_nexell = shared_library( + 'drm_nexell', + [files('nexell_drm.c'), config_file], + c_args : libdrm_c_args, + include_directories : [inc_root, inc_drm], + link_with : libdrm, + dependencies : [dep_pthread_stubs], + version : '1.0.0', + install : true, +) + +install_headers('nexell_drmif.h', subdir : 'libdrm') +install_headers('nexell_drm.h', subdir : 'nexell') + +ext_libdrm_nexell = declare_dependency( + link_with : [libdrm, libdrm_nexell], + include_directories : [inc_drm, include_directories('.')], +) + +pkg.generate( + name : 'libdrm_nexell', + libraries : libdrm_nexell, + subdirs : ['.', 'libdrm', 'nexell'], + version : '0.7', + requires_private : 'libdrm', + description : 'Userspace interface to nexell kernel DRM services', +) diff --git a/nexell/nexell_drm.c b/nexell/nexell_drm.c new file mode 100644 index 0000000..bd6e6ae --- /dev/null +++ b/nexell/nexell_drm.c @@ -0,0 +1,117 @@ +/* + * 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 <unistd.h> +#include <fcntl.h> +#include <stdint.h> +#include <errno.h> +#include <stdarg.h> +#include <ctype.h> +#include <string.h> +#include <strings.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> + +#include <nexell_drm.h> + +#define DRM_IOCTL_NR(n) _IOC_NR(n) +#define DRM_IOC_VOID _IOC_NONE +#define DRM_IOC_READ _IOC_READ +#define DRM_IOC_WRITE _IOC_WRITE +#define DRM_IOC_READWRITE _IOC_READ|_IOC_WRITE +#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size) + +static int drm_ioctl(int drm_fd, unsigned long request, void *arg) +{ + int ret; + + do { + ret = ioctl(drm_fd, request, arg); + } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); + return ret; +} + +static int drm_command_write_read(int fd, unsigned long command_index, + void *data, unsigned long size) +{ + unsigned long request; + + request = DRM_IOC(DRM_IOC_READ|DRM_IOC_WRITE, DRM_IOCTL_BASE, + DRM_COMMAND_BASE + command_index, size); + if (drm_ioctl(fd, request, data)) + return -errno; + return 0; +} + +/** + * 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 = drm_command_write_read(drm_fd, DRM_NX_GEM_CREATE, &arg, + sizeof(arg)); + if (ret) { + perror("drm_command_write_read\n"); + return ret; + } + + return arg.handle; +} + +void nx_free_gem(int drm_fd, int gem) +{ + struct drm_gem_close arg = {0, }; + + arg.handle = gem; + drm_ioctl(drm_fd, DRM_IOCTL_GEM_CLOSE, &arg); +} + +/** + * return dmabuf fd + */ +int nx_gem_to_dmafd(int drm_fd, int gem_fd) +{ + int ret; + struct drm_prime_handle arg = {0, }; + + arg.handle = gem_fd; + ret = drm_ioctl(drm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg); + if (ret) { + perror("DRM_IOCTL_PRIM_HANDLE_TO_FD\n"); + return -1; + } + + return arg.fd; +} diff --git a/nexell/nexell_drm.h b/nexell/nexell_drm.h new file mode 100644 index 0000000..0751991 --- /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/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; + struct drm_gem_cma_object *obj; +}; + +/** + * 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 +/* Reserved 0x03 ~ 0x05 for nx specific gem ioctl */ +#define DRM_NX_GEM_GET 0x04 +//#define DRM_NX_VIDI_CONNECTION 0x07 + +#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_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 0000000..09a6eb0 --- /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 +