diff options
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | rockchip/Makefile.am | 20 | ||||
-rw-r--r-- | rockchip/libdrm_rockchip.pc.in | 11 | ||||
-rw-r--r-- | rockchip/rockchip_drm.c | 274 | ||||
-rw-r--r-- | rockchip/rockchip_drm.h | 73 | ||||
-rw-r--r-- | rockchip/rockchip_drmif.h | 77 |
7 files changed, 473 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 3cb516c8..c4cd3f6e 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -57,7 +57,11 @@ if HAVE_TEGRA | |||
57 | TEGRA_SUBDIR = tegra | 57 | TEGRA_SUBDIR = tegra |
58 | endif | 58 | endif |
59 | 59 | ||
60 | SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) $(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR) $(FREEDRENO_SUBDIR) $(TEGRA_SUBDIR) tests man | 60 | if HAVE_ROCKCHIP |
61 | ROCKCHIP_SUBDIR = rockchip | ||
62 | endif | ||
63 | |||
64 | SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) $(RADEON_SUBDIR) $(OMAP_SUBDIR) $(EXYNOS_SUBDIR) $(FREEDRENO_SUBDIR) $(TEGRA_SUBDIR) $(ROCKCHIP_SUBDIR) tests man | ||
61 | 65 | ||
62 | libdrm_la_LTLIBRARIES = libdrm.la | 66 | libdrm_la_LTLIBRARIES = libdrm.la |
63 | libdrm_ladir = $(libdir) | 67 | libdrm_ladir = $(libdir) |
diff --git a/configure.ac b/configure.ac index c0ab4302..774df8ec 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -108,6 +108,11 @@ AC_ARG_ENABLE(tegra-experimental-api, | |||
108 | [Enable support for Tegra's experimental API (default: disabled)]), | 108 | [Enable support for Tegra's experimental API (default: disabled)]), |
109 | [TEGRA=$enableval], [TEGRA=no]) | 109 | [TEGRA=$enableval], [TEGRA=no]) |
110 | 110 | ||
111 | AC_ARG_ENABLE(rockchip-experimental-api, | ||
112 | AS_HELP_STRING([--enable-rockchip-experimental-api], | ||
113 | [Enable support for rockchip's experimental API (default: disabled)]), | ||
114 | [ROCKCHIP=$enableval], [ROCKCHIP=no]) | ||
115 | |||
111 | AC_ARG_ENABLE(install-test-programs, | 116 | AC_ARG_ENABLE(install-test-programs, |
112 | AS_HELP_STRING([--enable-install-test-programs], | 117 | AS_HELP_STRING([--enable-install-test-programs], |
113 | [Install test programs (default: no)]), | 118 | [Install test programs (default: no)]), |
@@ -324,6 +329,11 @@ if test "x$TEGRA" = xyes; then | |||
324 | AC_DEFINE(HAVE_TEGRA, 1, [Have Tegra support]) | 329 | AC_DEFINE(HAVE_TEGRA, 1, [Have Tegra support]) |
325 | fi | 330 | fi |
326 | 331 | ||
332 | AM_CONDITIONAL(HAVE_ROCKCHIP, [test "x$ROCKCHIP" = xyes]) | ||
333 | if test "x$ROCKCHIP" = xyes; then | ||
334 | AC_DEFINE(HAVE_ROCKCHIP, 1, [Have ROCKCHIP support]) | ||
335 | fi | ||
336 | |||
327 | AM_CONDITIONAL(HAVE_INSTALL_TESTS, [test "x$INSTALL_TESTS" = xyes]) | 337 | AM_CONDITIONAL(HAVE_INSTALL_TESTS, [test "x$INSTALL_TESTS" = xyes]) |
328 | if test "x$INSTALL_TESTS" = xyes; then | 338 | if test "x$INSTALL_TESTS" = xyes; then |
329 | AC_DEFINE(HAVE_INSTALL_TESTS, 1, [Install test programs]) | 339 | AC_DEFINE(HAVE_INSTALL_TESTS, 1, [Install test programs]) |
@@ -425,6 +435,8 @@ AC_CONFIG_FILES([ | |||
425 | freedreno/libdrm_freedreno.pc | 435 | freedreno/libdrm_freedreno.pc |
426 | tegra/Makefile | 436 | tegra/Makefile |
427 | tegra/libdrm_tegra.pc | 437 | tegra/libdrm_tegra.pc |
438 | rockchip/Makefile | ||
439 | rockchip/libdrm_rockchip.pc | ||
428 | tests/Makefile | 440 | tests/Makefile |
429 | tests/modeprint/Makefile | 441 | tests/modeprint/Makefile |
430 | tests/modetest/Makefile | 442 | tests/modetest/Makefile |
@@ -450,4 +462,5 @@ echo " OMAP API $OMAP" | |||
450 | echo " EXYNOS API $EXYNOS" | 462 | echo " EXYNOS API $EXYNOS" |
451 | echo " Freedreno API $FREEDRENO (kgsl: $FREEDRENO_KGSL)" | 463 | echo " Freedreno API $FREEDRENO (kgsl: $FREEDRENO_KGSL)" |
452 | echo " Tegra API $TEGRA" | 464 | echo " Tegra API $TEGRA" |
465 | echo " Rockchip API $ROCKCHIP" | ||
453 | echo "" | 466 | echo "" |
diff --git a/rockchip/Makefile.am b/rockchip/Makefile.am new file mode 100644 index 00000000..2ebb82f1 --- /dev/null +++ b/rockchip/Makefile.am | |||
@@ -0,0 +1,20 @@ | |||
1 | AM_CFLAGS = \ | ||
2 | $(WARN_CFLAGS) \ | ||
3 | -I$(top_srcdir) \ | ||
4 | -I$(top_srcdir)/rockchip \ | ||
5 | $(PTHREADSTUBS_CFLAGS) \ | ||
6 | -I$(top_srcdir)/include/drm | ||
7 | |||
8 | libdrm_rockchip_la_LTLIBRARIES = libdrm_rockchip.la | ||
9 | libdrm_rockchip_ladir = $(libdir) | ||
10 | libdrm_rockchip_la_LDFLAGS = -version-number 1:0:0 -no-undefined | ||
11 | libdrm_rockchip_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ | ||
12 | |||
13 | libdrm_rockchip_la_SOURCES = \ | ||
14 | rockchip_drm.c | ||
15 | |||
16 | libdrm_rockchipincludedir = ${includedir}/libdrm | ||
17 | libdrm_rockchipinclude_HEADERS = rockchip_drmif.h rockchip_drm.h | ||
18 | |||
19 | pkgconfigdir = @pkgconfigdir@ | ||
20 | pkgconfig_DATA = libdrm_rockchip.pc | ||
diff --git a/rockchip/libdrm_rockchip.pc.in b/rockchip/libdrm_rockchip.pc.in new file mode 100644 index 00000000..13f22ac7 --- /dev/null +++ b/rockchip/libdrm_rockchip.pc.in | |||
@@ -0,0 +1,11 @@ | |||
1 | prefix=@prefix@ | ||
2 | exec_prefix=@exec_prefix@ | ||
3 | libdir=@libdir@ | ||
4 | includedir=@includedir@ | ||
5 | |||
6 | Name: libdrm_rockchip | ||
7 | Description: Userspace interface to rockchip kernel DRM services | ||
8 | Version: 0.1 | ||
9 | Libs: -L${libdir} -ldrm_rockchip | ||
10 | Cflags: -I${includedir} -I${includedir}/libdrm | ||
11 | Requires.private: libdrm | ||
diff --git a/rockchip/rockchip_drm.c b/rockchip/rockchip_drm.c new file mode 100644 index 00000000..d56a68b4 --- /dev/null +++ b/rockchip/rockchip_drm.c | |||
@@ -0,0 +1,274 @@ | |||
1 | /* | ||
2 | * Copyright (C) ROCKCHIP, Inc. | ||
3 | * Author:yzq<yzq@rock-chips.com> | ||
4 | * | ||
5 | * based on exynos_drm.c | ||
6 | * | ||
7 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
8 | * copy of this software and associated documentation files (the "Software"), | ||
9 | * to deal in the Software without restriction, including without limitation | ||
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
11 | * and/or sell copies of the Software, and to permit persons to whom the | ||
12 | * Software is furnished to do so, subject to the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice (including the next | ||
15 | * paragraph) shall be included in all copies or substantial portions of the | ||
16 | * Software. | ||
17 | * | ||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
24 | * SOFTWARE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #ifdef HAVE_CONFIG_H | ||
29 | #include "config.h" | ||
30 | #endif | ||
31 | |||
32 | #include <stdlib.h> | ||
33 | #include <stdio.h> | ||
34 | #include <string.h> | ||
35 | #include <errno.h> | ||
36 | |||
37 | #include <sys/mman.h> | ||
38 | #include <linux/stddef.h> | ||
39 | |||
40 | #include <xf86drm.h> | ||
41 | |||
42 | #include "rockchip_drm.h" | ||
43 | #include "rockchip_drmif.h" | ||
44 | |||
45 | /* | ||
46 | * Create rockchip drm device object. | ||
47 | * | ||
48 | * @fd: file descriptor to rockchip drm driver opened. | ||
49 | * | ||
50 | * if true, return the device object else NULL. | ||
51 | */ | ||
52 | struct rockchip_device *rockchip_device_create(int fd) | ||
53 | { | ||
54 | struct rockchip_device *dev; | ||
55 | |||
56 | dev = calloc(1, sizeof(*dev)); | ||
57 | if (!dev) { | ||
58 | fprintf(stderr, "failed to create device[%s].\n", | ||
59 | strerror(errno)); | ||
60 | return NULL; | ||
61 | } | ||
62 | |||
63 | dev->fd = fd; | ||
64 | |||
65 | return dev; | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * Destroy rockchip drm device object | ||
70 | * | ||
71 | * @dev: rockchip drm device object. | ||
72 | */ | ||
73 | void rockchip_device_destroy(struct rockchip_device *dev) | ||
74 | { | ||
75 | free(dev); | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * Create a rockchip buffer object to rockchip drm device. | ||
80 | * | ||
81 | * @dev: rockchip drm device object. | ||
82 | * @size: user-desired size. | ||
83 | * flags: user-desired memory type. | ||
84 | * user can set one or more types among several types to memory | ||
85 | * allocation and cache attribute types. and as default, | ||
86 | * ROCKCHIP_BO_NONCONTIG and ROCKCHIP-BO_NONCACHABLE types would | ||
87 | * be used. | ||
88 | * | ||
89 | * if true, return a rockchip buffer object else NULL. | ||
90 | */ | ||
91 | struct rockchip_bo *rockchip_bo_create(struct rockchip_device *dev, | ||
92 | size_t size, uint32_t flags) | ||
93 | { | ||
94 | struct rockchip_bo *bo; | ||
95 | struct drm_rockchip_gem_create req = { | ||
96 | .size = size, | ||
97 | .flags = flags, | ||
98 | }; | ||
99 | |||
100 | if (size == 0) { | ||
101 | fprintf(stderr, "invalid size.\n"); | ||
102 | return NULL; | ||
103 | } | ||
104 | |||
105 | bo = calloc(1, sizeof(*bo)); | ||
106 | if (!bo) { | ||
107 | fprintf(stderr, "failed to create bo[%s].\n", | ||
108 | strerror(errno)); | ||
109 | goto fail; | ||
110 | } | ||
111 | |||
112 | bo->dev = dev; | ||
113 | |||
114 | if (drmIoctl(dev->fd, DRM_IOCTL_ROCKCHIP_GEM_CREATE, &req)){ | ||
115 | fprintf(stderr, "failed to create gem object[%s].\n", | ||
116 | strerror(errno)); | ||
117 | goto err_free_bo; | ||
118 | } | ||
119 | |||
120 | bo->handle = req.handle; | ||
121 | bo->size = size; | ||
122 | bo->flags = flags; | ||
123 | |||
124 | return bo; | ||
125 | |||
126 | err_free_bo: | ||
127 | free(bo); | ||
128 | fail: | ||
129 | return NULL; | ||
130 | } | ||
131 | |||
132 | /* | ||
133 | * Destroy a rockchip buffer object. | ||
134 | * | ||
135 | * @bo: a rockchip buffer object to be destroyed. | ||
136 | */ | ||
137 | void rockchip_bo_destroy(struct rockchip_bo *bo) | ||
138 | { | ||
139 | if (!bo) | ||
140 | return; | ||
141 | |||
142 | if (bo->vaddr) | ||
143 | munmap(bo->vaddr, bo->size); | ||
144 | |||
145 | if (bo->handle) { | ||
146 | struct drm_gem_close req = { | ||
147 | .handle = bo->handle, | ||
148 | }; | ||
149 | |||
150 | drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req); | ||
151 | } | ||
152 | |||
153 | free(bo); | ||
154 | } | ||
155 | |||
156 | |||
157 | /* | ||
158 | * Get a rockchip buffer object from a gem global object name. | ||
159 | * | ||
160 | * @dev: a rockchip device object. | ||
161 | * @name: a gem global object name exported by another process. | ||
162 | * | ||
163 | * this interface is used to get a rockchip buffer object from a gem | ||
164 | * global object name sent by another process for buffer sharing. | ||
165 | * | ||
166 | * if true, return a rockchip buffer object else NULL. | ||
167 | * | ||
168 | */ | ||
169 | struct rockchip_bo *rockchip_bo_from_name(struct rockchip_device *dev, | ||
170 | uint32_t name) | ||
171 | { | ||
172 | struct rockchip_bo *bo; | ||
173 | struct drm_gem_open req = { | ||
174 | .name = name, | ||
175 | }; | ||
176 | |||
177 | bo = calloc(1, sizeof(*bo)); | ||
178 | if (!bo) { | ||
179 | fprintf(stderr, "failed to allocate bo[%s].\n", | ||
180 | strerror(errno)); | ||
181 | return NULL; | ||
182 | } | ||
183 | |||
184 | if (drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req)) { | ||
185 | fprintf(stderr, "failed to open gem object[%s].\n", | ||
186 | strerror(errno)); | ||
187 | goto err_free_bo; | ||
188 | } | ||
189 | |||
190 | bo->dev = dev; | ||
191 | bo->name = name; | ||
192 | bo->handle = req.handle; | ||
193 | |||
194 | return bo; | ||
195 | |||
196 | err_free_bo: | ||
197 | free(bo); | ||
198 | return NULL; | ||
199 | } | ||
200 | |||
201 | /* | ||
202 | * Get a gem global object name from a gem object handle. | ||
203 | * | ||
204 | * @bo: a rockchip buffer object including gem handle. | ||
205 | * @name: a gem global object name to be got by kernel driver. | ||
206 | * | ||
207 | * this interface is used to get a gem global object name from a gem object | ||
208 | * handle to a buffer that wants to share it with another process. | ||
209 | * | ||
210 | * if true, return 0 else negative. | ||
211 | */ | ||
212 | int rockchip_bo_get_name(struct rockchip_bo *bo, uint32_t *name) | ||
213 | { | ||
214 | if (!bo->name) { | ||
215 | struct drm_gem_flink req = { | ||
216 | .handle = bo->handle, | ||
217 | }; | ||
218 | int ret; | ||
219 | |||
220 | ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_FLINK, &req); | ||
221 | if (ret) { | ||
222 | fprintf(stderr, "failed to get gem global name[%s].\n", | ||
223 | strerror(errno)); | ||
224 | return ret; | ||
225 | } | ||
226 | |||
227 | bo->name = req.name; | ||
228 | } | ||
229 | |||
230 | *name = bo->name; | ||
231 | |||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | uint32_t rockchip_bo_handle(struct rockchip_bo *bo) | ||
236 | { | ||
237 | return bo->handle; | ||
238 | } | ||
239 | |||
240 | /* | ||
241 | * Mmap a buffer to user space. | ||
242 | * | ||
243 | * @bo: a rockchip buffer object including a gem object handle to be mmapped | ||
244 | * to user space. | ||
245 | * | ||
246 | * if true, user pointer mmaped else NULL. | ||
247 | */ | ||
248 | void *rockchip_bo_map(struct rockchip_bo *bo) | ||
249 | { | ||
250 | if (!bo->vaddr) { | ||
251 | struct rockchip_device *dev = bo->dev; | ||
252 | struct drm_rockchip_gem_map_off req = { | ||
253 | .handle = bo->handle, | ||
254 | }; | ||
255 | int ret; | ||
256 | |||
257 | ret = drmIoctl(dev->fd, DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET, &req); | ||
258 | if (ret) { | ||
259 | fprintf(stderr, "failed to ioctl gem map offset[%s].\n", | ||
260 | strerror(errno)); | ||
261 | return NULL; | ||
262 | } | ||
263 | |||
264 | bo->vaddr = mmap(0, bo->size, PROT_READ | PROT_WRITE, | ||
265 | MAP_SHARED, dev->fd, req.offset); | ||
266 | if (bo->vaddr == MAP_FAILED) { | ||
267 | fprintf(stderr, "failed to mmap buffer[%s].\n", | ||
268 | strerror(errno)); | ||
269 | return NULL; | ||
270 | } | ||
271 | } | ||
272 | |||
273 | return bo->vaddr; | ||
274 | } | ||
diff --git a/rockchip/rockchip_drm.h b/rockchip/rockchip_drm.h new file mode 100644 index 00000000..13977d59 --- /dev/null +++ b/rockchip/rockchip_drm.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd | ||
3 | * Authors: | ||
4 | * Mark Yao <yzq@rock-chips.com> | ||
5 | * | ||
6 | * based on exynos_drm.h | ||
7 | * | ||
8 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
9 | * copy of this software and associated documentation files (the "Software"), | ||
10 | * to deal in the Software without restriction, including without limitation | ||
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
12 | * and/or sell copies of the Software, and to permit persons to whom the | ||
13 | * Software is furnished to do so, subject to the following conditions: | ||
14 | * | ||
15 | * The above copyright notice and this permission notice (including the next | ||
16 | * paragraph) shall be included in all copies or substantial portions of the | ||
17 | * Software. | ||
18 | * | ||
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
22 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
25 | * SOFTWARE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | #ifndef _ROCKCHIP_DRM_H_ | ||
30 | #define _ROCKCHIP_DRM_H_ | ||
31 | |||
32 | #include <stdint.h> | ||
33 | #include "drm.h" | ||
34 | |||
35 | /** | ||
36 | * User-desired buffer creation information structure. | ||
37 | * | ||
38 | * @size: user-desired memory allocation size. | ||
39 | * - this size value would be page-aligned internally. | ||
40 | * @flags: user request for setting memory type or cache attributes. | ||
41 | * @handle: returned a handle to created gem object. | ||
42 | * - this handle will be set by gem module of kernel side. | ||
43 | */ | ||
44 | struct drm_rockchip_gem_create { | ||
45 | uint64_t size; | ||
46 | uint32_t flags; | ||
47 | uint32_t handle; | ||
48 | }; | ||
49 | |||
50 | /** | ||
51 | * A structure for getting buffer offset. | ||
52 | * | ||
53 | * @handle: a pointer to gem object created. | ||
54 | * @pad: just padding to be 64-bit aligned. | ||
55 | * @offset: relatived offset value of the memory region allocated. | ||
56 | * - this value should be set by user. | ||
57 | */ | ||
58 | struct drm_rockchip_gem_map_off { | ||
59 | uint32_t handle; | ||
60 | uint32_t pad; | ||
61 | uint64_t offset; | ||
62 | }; | ||
63 | |||
64 | #define DRM_ROCKCHIP_GEM_CREATE 0x00 | ||
65 | #define DRM_ROCKCHIP_GEM_MAP_OFFSET 0x01 | ||
66 | |||
67 | #define DRM_IOCTL_ROCKCHIP_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ | ||
68 | DRM_ROCKCHIP_GEM_CREATE, struct drm_rockchip_gem_create) | ||
69 | |||
70 | #define DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \ | ||
71 | DRM_ROCKCHIP_GEM_MAP_OFFSET, struct drm_rockchip_gem_map_off) | ||
72 | |||
73 | #endif | ||
diff --git a/rockchip/rockchip_drmif.h b/rockchip/rockchip_drmif.h new file mode 100644 index 00000000..bcc55539 --- /dev/null +++ b/rockchip/rockchip_drmif.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * Copyright (C) ROCKCHIP, Inc. | ||
3 | * Author:yzq<yzq@rock-chips.com> | ||
4 | * | ||
5 | * based on exynos_drmif.h | ||
6 | * | ||
7 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
8 | * copy of this software and associated documentation files (the "Software"), | ||
9 | * to deal in the Software without restriction, including without limitation | ||
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
11 | * and/or sell copies of the Software, and to permit persons to whom the | ||
12 | * Software is furnished to do so, subject to the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice (including the next | ||
15 | * paragraph) shall be included in all copies or substantial portions of the | ||
16 | * Software. | ||
17 | * | ||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
24 | * SOFTWARE. | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #ifndef ROCKCHIP_DRMIF_H_ | ||
29 | #define ROCKCHIP_DRMIF_H_ | ||
30 | |||
31 | #include <xf86drm.h> | ||
32 | #include <stdint.h> | ||
33 | #include "rockchip_drm.h" | ||
34 | |||
35 | struct rockchip_device { | ||
36 | int fd; | ||
37 | }; | ||
38 | |||
39 | /* | ||
40 | * Rockchip Buffer Object structure. | ||
41 | * | ||
42 | * @dev: rockchip device object allocated. | ||
43 | * @handle: a gem handle to gem object created. | ||
44 | * @flags: indicate memory allocation and cache attribute types. | ||
45 | * @size: size to the buffer created. | ||
46 | * @vaddr: user space address to a gem buffer mmaped. | ||
47 | * @name: a gem global handle from flink request. | ||
48 | */ | ||
49 | struct rockchip_bo { | ||
50 | struct rockchip_device *dev; | ||
51 | uint32_t handle; | ||
52 | uint32_t flags; | ||
53 | size_t size; | ||
54 | void *vaddr; | ||
55 | uint32_t name; | ||
56 | }; | ||
57 | |||
58 | /* | ||
59 | * device related functions: | ||
60 | */ | ||
61 | struct rockchip_device *rockchip_device_create(int fd); | ||
62 | void rockchip_device_destroy(struct rockchip_device *dev); | ||
63 | |||
64 | /* | ||
65 | * buffer-object related functions: | ||
66 | */ | ||
67 | struct rockchip_bo *rockchip_bo_create(struct rockchip_device *dev, | ||
68 | size_t size, uint32_t flags); | ||
69 | int rockchip_bo_get_info(struct rockchip_device *dev, uint32_t handle, | ||
70 | size_t *size, uint32_t *flags); | ||
71 | void rockchip_bo_destroy(struct rockchip_bo *bo); | ||
72 | struct rockchip_bo *rockchip_bo_from_name(struct rockchip_device *dev, | ||
73 | uint32_t name); | ||
74 | int rockchip_bo_get_name(struct rockchip_bo *bo, uint32_t *name); | ||
75 | uint32_t rockchip_bo_handle(struct rockchip_bo *bo); | ||
76 | void *rockchip_bo_map(struct rockchip_bo *bo); | ||
77 | #endif /* ROCKCHIP_DRMIF_H_ */ | ||