libdrm : add nexell api accepted/tizen/unified/20201209.124856 submit/tizen/20201208.090512
authorjino.cho <jino.cho@samsung.com>
Thu, 25 Aug 2016 09:42:35 +0000 (18:42 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Tue, 8 Dec 2020 08:41:51 +0000 (17:41 +0900)
This patch imports the nexell api of the libdrm

Change-Id: If8009fc30f46edcf4fdcc04679523e590e165003
Signed-off-by: jino.cho <jino.cho@samsung.com>
nexell: Add meson build system

Change-Id: I58d2e2b7a2605f087bf78e340ba156b8b8399da7
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
packaging: enable nexell and add lib

Change-Id: I22b2e6324bf6b07f289bb7b33054b6f80dbee945
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
nexell: add explicit cast for gem size

The nexell gem alloc api has int parameter, so it should be casted
to uint64_t for kernel gem alloc interface.

Change-Id: Icc98b42645fd8ec234b99193304b5f91bcdd3389
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
tests: add nexell drm to default test modules

Add nexell drm to test modules for the artik devices.

Change-Id: I5f15f6bf28064ebc6ad178ba40ada0c6e666ad49
Signed-off-by: SooChan Lim <sc1.lim@samsung.com>
nexell: add gem buffer type

Add gem buffer type to sync with kernel header.

libtbm nexell backend refers to gem buffer type for cache control.
So this patch adds the buffer type to identify if cache operation
is required or not.

Change-Id: I7760a54496a1a9e7c2f17f0a77e640e346d9b455
Signed-off-by: Inki Dae <inki.dae@samsung.com>
nexell: fix to check return of drmIoctl()

Fix to check return value of drmIoctl().

Change-Id: I456184820278ee38ff1a7e5bba283acb8c2ea99f
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
nexell: fix signed/unsinged cast

The commit 4f6c18f11c68 ("nexell: add explicit cast for gem size")
introduced signed 32bit value into unsigned 64bit value and it can
cause wrong value conversion. Fix to cast signed 32bit value into
unsigned 32bit value first and then cast into unsigned 64bit value.

Change-Id: I9550b74987ddd981e905f3b5085d4abaede01c65
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
nexell: add drm_public macro for nexell drm api

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
meson.build
meson_options.txt
nexell/libdrm_nexell.pc.in [new file with mode: 0644]
nexell/meson.build [new file with mode: 0644]
nexell/nexell-symbols.txt [new file with mode: 0644]
nexell/nexell_drm.c [new file with mode: 0644]
nexell/nexell_drm.h [new file with mode: 0644]
nexell/nexell_drmif.h [new file with mode: 0644]
packaging/libdrm.spec
tests/util/kms.c

index f1ebec7..a7c7eb3 100644 (file)
@@ -157,6 +157,8 @@ with_exynos = get_option('exynos') == 'true'
 
 with_vigs = get_option('vigs') == 'true'
 
+with_nexell = get_option('nexell') == 'true'
+
 with_vc4 = false
 _vc4 = get_option('vc4')
 if _vc4 != 'false'
@@ -283,6 +285,7 @@ config.set10('HAVE_VISIBILITY',
 foreach t : [
              [with_exynos, 'EXYNOS'],
              [with_vigs, 'VIGS'],
+             [with_nexell, 'NEXELL'],
              [with_freedreno_kgsl, 'FREEDRENO_KGSL'],
              [with_intel, 'INTEL'],
              [with_nouveau, 'NOUVEAU'],
@@ -386,6 +389,9 @@ endif
 if with_vigs
   subdir('vigs')
 endif
+if with_nexell
+  subdir('nexell')
+endif
 if with_freedreno
   subdir('freedreno')
 endif
@@ -416,6 +422,7 @@ message('  Nouveau API    @0@'.format(with_nouveau))
 message('  OMAP API       @0@'.format(with_omap))
 message('  EXYNOS API     @0@'.format(with_exynos))
 message('  VIGS API       @0@'.format(with_vigs))
+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))
index e82e094..7b13fd4 100644 (file)
@@ -82,6 +82,13 @@ option(
   description : '''Enable support for VIGS's experimental KMS API.''',
 )
 option(
+  'nexell',
+  type : 'combo',
+  value : 'false',
+  choices : ['true', 'false', 'auto'],
+  description : '''Enable support for NEXELL's 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 (file)
index 0000000..7e63800
--- /dev/null
@@ -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 (file)
index 0000000..b284074
--- /dev/null
@@ -0,0 +1,57 @@
+# 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',
+)
+
+test(
+  'nexell-symbols-check',
+  symbols_check,
+  args : [
+    '--lib', libdrm_nexell,
+    '--symbols-file', files('nexell-symbols.txt'),
+    '--nm', prog_nm.path(),
+  ],
+)
diff --git a/nexell/nexell-symbols.txt b/nexell/nexell-symbols.txt
new file mode 100644 (file)
index 0000000..ad8b474
--- /dev/null
@@ -0,0 +1,3 @@
+nx_alloc_gem
+nx_gem_to_dmafd
+nx_free_gem
diff --git a/nexell/nexell_drm.c b/nexell/nexell_drm.c
new file mode 100644 (file)
index 0000000..9dac99d
--- /dev/null
@@ -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.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdint.h>
+
+#include <xf86drm.h>
+
+#include "libdrm_macros.h"
+#include "nexell_drm.h"
+#include "nexell_drmif.h"
+
+/**
+ * return gem_fd
+ */
+drm_public int nx_alloc_gem(int drm_fd, int size, int flags)
+{
+       struct nx_drm_gem_create arg = { 0, };
+       int ret;
+
+       arg.size = (uint64_t)(unsigned int)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;
+}
+
+drm_public void nx_free_gem(int drm_fd, int gem)
+{
+       struct drm_gem_close arg = {0, };
+       int ret;
+
+       arg.handle = gem;
+       ret = drmIoctl(drm_fd, DRM_IOCTL_GEM_CLOSE, &arg);
+       if (ret)
+               perror("DRM_IOCTL_GEM_CLOSE failed\n");
+}
+
+/**
+ * return dmabuf fd
+ */
+drm_public 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 (file)
index 0000000..998f6fe
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * 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;
+};
+
+/*
+ * nexell gem memory type
+ */
+enum nx_gem_type {
+       /*
+        * DMA continuous memory
+        * user   : non-cacheable
+        * kernel : non-cacheable
+        */
+       NEXELL_BO_DMA,
+
+       /*
+        * DMA continuous memory, allocate from DMA,
+        * user   : cacheable
+        * kernel : non-cacheable
+        */
+       NEXELL_BO_DMA_CACHEABLE,
+
+       /*
+        * System continuous memory, allocate from system
+        * user   : non-cacheable
+        * kernel : non-cacheable
+        */
+       NEXELL_BO_SYSTEM,
+
+       /*
+        * System continuous memory, allocate from system
+        * user   : cacheable
+        * kernel : cacheable
+        */
+       NEXELL_BO_SYSTEM_CACHEABLE,
+
+       /*
+        * System non-continuous memory, allocate from system
+        * user   : non-cacheable
+        * kernel : non-cacheable
+        */
+       NEXELL_BO_SYSTEM_NONCONTIG,
+
+       /*
+        * System non-continuous memory, allocate from system
+        * user   : cacheable
+        * kernel : cacheable
+        */
+       NEXELL_BO_SYSTEM_NONCONTIG_CACHEABLE,
+
+       NEXELL_BO_MAX,
+};
+
+#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 (file)
index 0000000..09a6eb0
--- /dev/null
@@ -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
+
index 76a778d..0ec3a09 100644 (file)
@@ -76,6 +76,7 @@ meson setup --prefix /usr --libdir %{_libdir} \
 %endif
        -Dexynos=true \
        -Dvigs=true \
+       -Dnexell=true \
        -Dinstall-test-programs=true \
        -Dcairo-tests=false \
        -Db_pie=true \
@@ -105,6 +106,7 @@ ninja -C builddir install
 %{_libdir}/libdrm.so.*
 %{_libdir}/libdrm_exynos.so.*
 %{_libdir}/libdrm_vigs.so.*
+%{_libdir}/libdrm_nexell.so.*
 
 %files tools
 %manifest %{name}.manifest
@@ -131,6 +133,8 @@ ninja -C builddir install
 %{_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
@@ -138,6 +142,7 @@ ninja -C builddir install
 %endif
 %{_libdir}/libkms.so
 %{_libdir}/libdrm_exynos.so
+%{_libdir}/libdrm_nexell.so
 %{_libdir}/libdrm_vigs.so
 %{_libdir}/pkgconfig/*
 
index 08b48fe..b67ec23 100644 (file)
@@ -149,6 +149,7 @@ static const char * const modules[] = {
        "armada-drm",
        "komeda",
        "imx-dcss",
+       "nexell",
 };
 
 int util_open(const char *device, const char *module)