diff options
author | Inki Dae | 2012-05-04 05:13:14 -0500 |
---|---|---|
committer | Rob Clark | 2012-05-12 10:04:54 -0500 |
commit | e07b650662ea0529d99741691c47856ef1034c9c (patch) | |
tree | 0f465d978c9316abcc223e3c51c042c7103ea16d /exynos | |
parent | 86451a12ca52e88a9600ed55f56b8cacd1ac0d6d (diff) | |
download | external-libgbm-e07b650662ea0529d99741691c47856ef1034c9c.tar.gz external-libgbm-e07b650662ea0529d99741691c47856ef1034c9c.tar.xz external-libgbm-e07b650662ea0529d99741691c47856ef1034c9c.zip |
libdrm: add exynos drm support
this patch adds libdrm_exynos helper layer that inclues some intefaces
for exynos specific gem and virtual display driver and also adds exynos
module name to modtest and vbltest.
Changelog v2:
- fixed exynos broken ioctl.
the pointer of uint64_t *edid should be removed.
- removed unnecessary definitions.
- added drm prime interfaces.
this feature is used to share a buffer between drivers or memory managers
and for this, please, refer to below links:
http://www.mjmwired.net/kernel/Documentation/dma-buf-sharing.txt
http://lwn.net/Articles/488664/
this patch is based on a link below:
git://anongit.freedesktop.org/mesa/drm
commit id: d72a44c7c4f5eea9c1e5bb0c36cb9e0224b9ca22
Reviewed-by: Rob Clark <rob@ti.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Rob Clark <rob@ti.com>
Diffstat (limited to 'exynos')
-rw-r--r-- | exynos/Makefile.am | 22 | ||||
-rw-r--r-- | exynos/exynos_drm.c | 396 | ||||
-rw-r--r-- | exynos/exynos_drm.h | 146 | ||||
-rw-r--r-- | exynos/exynos_drmif.h | 88 | ||||
-rw-r--r-- | exynos/libdrm_exynos.pc.in | 11 |
5 files changed, 663 insertions, 0 deletions
diff --git a/exynos/Makefile.am b/exynos/Makefile.am new file mode 100644 index 00000000..e782d34d --- /dev/null +++ b/exynos/Makefile.am | |||
@@ -0,0 +1,22 @@ | |||
1 | AM_CFLAGS = \ | ||
2 | $(WARN_CFLAGS) \ | ||
3 | -I$(top_srcdir) \ | ||
4 | -I$(top_srcdir)/exynos \ | ||
5 | $(PTHREADSTUBS_CFLAGS) \ | ||
6 | -I$(top_srcdir)/include/drm | ||
7 | |||
8 | libdrm_exynos_la_LTLIBRARIES = libdrm_exynos.la | ||
9 | libdrm_exynos_ladir = $(libdir) | ||
10 | libdrm_exynos_la_LDFLAGS = -version-number 1:0:0 -no-undefined | ||
11 | libdrm_exynos_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ | ||
12 | |||
13 | libdrm_exynos_la_SOURCES = exynos_drm.c | ||
14 | |||
15 | libdrm_exynoscommonincludedir = ${includedir}/exynos | ||
16 | libdrm_exynoscommoninclude_HEADERS = exynos_drm.h | ||
17 | |||
18 | libdrm_exynosincludedir = ${includedir}/libdrm | ||
19 | libdrm_exynosinclude_HEADERS = exynos_drmif.h | ||
20 | |||
21 | pkgconfigdir = @pkgconfigdir@ | ||
22 | pkgconfig_DATA = libdrm_exynos.pc | ||
diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c new file mode 100644 index 00000000..4db755e7 --- /dev/null +++ b/exynos/exynos_drm.c | |||
@@ -0,0 +1,396 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Samsung Electronics Co., Ltd. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice (including the next | ||
12 | * paragraph) shall be included in all copies or substantial portions of the | ||
13 | * Software. | ||
14 | * | ||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
21 | * SOFTWARE. | ||
22 | * | ||
23 | * Authors: | ||
24 | * Inki Dae <inki.dae@samsung.com> | ||
25 | */ | ||
26 | |||
27 | #ifdef HAVE_CONFIG_H | ||
28 | #include "config.h" | ||
29 | #endif | ||
30 | |||
31 | #include <stdlib.h> | ||
32 | #include <stdio.h> | ||
33 | #include <string.h> | ||
34 | #include <errno.h> | ||
35 | |||
36 | #include <sys/mman.h> | ||
37 | #include <linux/stddef.h> | ||
38 | |||
39 | #include <xf86drm.h> | ||
40 | |||
41 | #include "exynos_drm.h" | ||
42 | #include "exynos_drmif.h" | ||
43 | |||
44 | /* | ||
45 | * Create exynos drm device object. | ||
46 | * | ||
47 | * @fd: file descriptor to exynos drm driver opened. | ||
48 | * | ||
49 | * if true, return the device object else NULL. | ||
50 | */ | ||
51 | struct exynos_device * exynos_device_create(int fd) | ||
52 | { | ||
53 | struct exynos_device *dev; | ||
54 | |||
55 | dev = calloc(sizeof(*dev), 1); | ||
56 | if (!dev) { | ||
57 | fprintf(stderr, "failed to create device[%s].\n", | ||
58 | strerror(errno)); | ||
59 | return NULL; | ||
60 | } | ||
61 | |||
62 | dev->fd = fd; | ||
63 | |||
64 | return dev; | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * Destroy exynos drm device object | ||
69 | * | ||
70 | * @dev: exynos drm device object. | ||
71 | */ | ||
72 | void exynos_device_destroy(struct exynos_device *dev) | ||
73 | { | ||
74 | free(dev); | ||
75 | } | ||
76 | |||
77 | /* | ||
78 | * Create a exynos buffer object to exynos drm device. | ||
79 | * | ||
80 | * @dev: exynos drm device object. | ||
81 | * @size: user-desired size. | ||
82 | * flags: user-desired memory type. | ||
83 | * user can set one or more types among several types to memory | ||
84 | * allocation and cache attribute types. and as default, | ||
85 | * EXYNOS_BO_NONCONTIG and EXYNOS-BO_NONCACHABLE types would | ||
86 | * be used. | ||
87 | * | ||
88 | * if true, return a exynos buffer object else NULL. | ||
89 | */ | ||
90 | struct exynos_bo * exynos_bo_create(struct exynos_device *dev, | ||
91 | size_t size, uint32_t flags) | ||
92 | { | ||
93 | struct exynos_bo *bo; | ||
94 | struct drm_exynos_gem_create req = { | ||
95 | .size = size, | ||
96 | .flags = flags, | ||
97 | }; | ||
98 | |||
99 | if (size == 0) { | ||
100 | fprintf(stderr, "invalid size.\n"); | ||
101 | goto fail; | ||
102 | } | ||
103 | |||
104 | bo = calloc(sizeof(*bo), 1); | ||
105 | if (!bo) { | ||
106 | fprintf(stderr, "failed to create bo[%s].\n", | ||
107 | strerror(errno)); | ||
108 | goto err_free_bo; | ||
109 | } | ||
110 | |||
111 | bo->dev = dev; | ||
112 | |||
113 | if (drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_CREATE, &req)){ | ||
114 | fprintf(stderr, "failed to create gem object[%s].\n", | ||
115 | strerror(errno)); | ||
116 | goto err_free_bo; | ||
117 | } | ||
118 | |||
119 | bo->handle = req.handle; | ||
120 | bo->size = size; | ||
121 | bo->flags = flags; | ||
122 | |||
123 | return bo; | ||
124 | |||
125 | err_free_bo: | ||
126 | free(bo); | ||
127 | fail: | ||
128 | return NULL; | ||
129 | } | ||
130 | |||
131 | /* | ||
132 | * Get information to gem region allocated. | ||
133 | * | ||
134 | * @dev: exynos drm device object. | ||
135 | * @handle: gem handle to request gem info. | ||
136 | * @size: size to gem object and returned by kernel side. | ||
137 | * @flags: gem flags to gem object and returned by kernel side. | ||
138 | * | ||
139 | * with this function call, you can get flags and size to gem handle | ||
140 | * through bo object. | ||
141 | * | ||
142 | * if true, return 0 else negative. | ||
143 | */ | ||
144 | int exynos_bo_get_info(struct exynos_device *dev, uint32_t handle, | ||
145 | size_t *size, uint32_t *flags) | ||
146 | { | ||
147 | int ret; | ||
148 | struct drm_exynos_gem_info req = { | ||
149 | .handle = handle, | ||
150 | }; | ||
151 | |||
152 | ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_GET, &req); | ||
153 | if (ret < 0) { | ||
154 | fprintf(stderr, "failed to get gem object information[%s].\n", | ||
155 | strerror(errno)); | ||
156 | return ret; | ||
157 | } | ||
158 | |||
159 | *size = req.size; | ||
160 | *flags = req.flags; | ||
161 | |||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * Destroy a exynos buffer object. | ||
167 | * | ||
168 | * @bo: a exynos buffer object to be destroyed. | ||
169 | */ | ||
170 | void exynos_bo_destroy(struct exynos_bo *bo) | ||
171 | { | ||
172 | if (!bo) | ||
173 | return; | ||
174 | |||
175 | if (bo->vaddr) | ||
176 | munmap(bo->vaddr, bo->size); | ||
177 | |||
178 | if (bo->handle) { | ||
179 | struct drm_gem_close req = { | ||
180 | .handle = bo->handle, | ||
181 | }; | ||
182 | |||
183 | drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req); | ||
184 | } | ||
185 | |||
186 | free(bo); | ||
187 | } | ||
188 | |||
189 | |||
190 | /* | ||
191 | * Get a exynos buffer object from a gem global object name. | ||
192 | * | ||
193 | * @dev: a exynos device object. | ||
194 | * @name: a gem global object name exported by another process. | ||
195 | * | ||
196 | * this interface is used to get a exynos buffer object from a gem | ||
197 | * global object name sent by another process for buffer sharing. | ||
198 | * | ||
199 | * if true, return a exynos buffer object else NULL. | ||
200 | * | ||
201 | */ | ||
202 | struct exynos_bo * exynos_bo_from_name(struct exynos_device *dev, uint32_t name) | ||
203 | { | ||
204 | struct exynos_bo *bo; | ||
205 | struct drm_gem_open req = { | ||
206 | .name = name, | ||
207 | }; | ||
208 | |||
209 | bo = calloc(sizeof(*bo), 1); | ||
210 | if (!bo) { | ||
211 | fprintf(stderr, "failed to allocate bo[%s].\n", | ||
212 | strerror(errno)); | ||
213 | return NULL; | ||
214 | } | ||
215 | |||
216 | if (drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req)) { | ||
217 | fprintf(stderr, "failed to open gem object[%s].\n", | ||
218 | strerror(errno)); | ||
219 | goto err_free_bo; | ||
220 | } | ||
221 | |||
222 | bo->dev = dev; | ||
223 | bo->name = name; | ||
224 | bo->handle = req.handle; | ||
225 | |||
226 | return bo; | ||
227 | |||
228 | err_free_bo: | ||
229 | free(bo); | ||
230 | return NULL; | ||
231 | } | ||
232 | |||
233 | /* | ||
234 | * Get a gem global object name from a gem object handle. | ||
235 | * | ||
236 | * @bo: a exynos buffer object including gem handle. | ||
237 | * @name: a gem global object name to be got by kernel driver. | ||
238 | * | ||
239 | * this interface is used to get a gem global object name from a gem object | ||
240 | * handle to a buffer that wants to share it with another process. | ||
241 | * | ||
242 | * if true, return 0 else negative. | ||
243 | */ | ||
244 | int exynos_bo_get_name(struct exynos_bo *bo, uint32_t *name) | ||
245 | { | ||
246 | if (!bo->name) { | ||
247 | struct drm_gem_flink req = { | ||
248 | .handle = bo->handle, | ||
249 | }; | ||
250 | int ret; | ||
251 | |||
252 | ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_FLINK, &req); | ||
253 | if (ret) { | ||
254 | fprintf(stderr, "failed to get gem global name[%s].\n", | ||
255 | strerror(errno)); | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | bo->name = req.name; | ||
260 | } | ||
261 | |||
262 | *name = bo->name; | ||
263 | |||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | uint32_t exynos_bo_handle(struct exynos_bo *bo) | ||
268 | { | ||
269 | return bo->handle; | ||
270 | } | ||
271 | |||
272 | /* | ||
273 | * Mmap a buffer to user space. | ||
274 | * | ||
275 | * @bo: a exynos buffer object including a gem object handle to be mmapped | ||
276 | * to user space. | ||
277 | * | ||
278 | * if true, user pointer mmaped else NULL. | ||
279 | */ | ||
280 | void *exynos_bo_map(struct exynos_bo *bo) | ||
281 | { | ||
282 | if (!bo->vaddr) { | ||
283 | struct exynos_device *dev = bo->dev; | ||
284 | struct drm_exynos_gem_mmap req = { | ||
285 | .handle = bo->handle, | ||
286 | .size = bo->size, | ||
287 | }; | ||
288 | int ret; | ||
289 | |||
290 | ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_MMAP, &req); | ||
291 | if (ret) { | ||
292 | fprintf(stderr, "failed to mmap[%s].\n", | ||
293 | strerror(errno)); | ||
294 | return NULL; | ||
295 | } | ||
296 | |||
297 | bo->vaddr = req.mapped; | ||
298 | } | ||
299 | |||
300 | return bo->vaddr; | ||
301 | } | ||
302 | |||
303 | /* | ||
304 | * Export gem object to dmabuf as file descriptor. | ||
305 | * | ||
306 | * @dev: a exynos device object. | ||
307 | * @handle: gem handle to be exported into dmabuf as file descriptor. | ||
308 | * @fd: file descriptor to dmabuf exported from gem handle and | ||
309 | * returned by kernel side. | ||
310 | * | ||
311 | * if true, return 0 else negative. | ||
312 | */ | ||
313 | int exynos_prime_handle_to_fd(struct exynos_device *dev, uint32_t handle, | ||
314 | int *fd) | ||
315 | { | ||
316 | int ret; | ||
317 | struct drm_prime_handle req = { | ||
318 | .handle = handle, | ||
319 | }; | ||
320 | |||
321 | ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req); | ||
322 | if (ret) { | ||
323 | fprintf(stderr, "failed to mmap[%s].\n", | ||
324 | strerror(errno)); | ||
325 | return ret; | ||
326 | } | ||
327 | |||
328 | *fd = req.fd; | ||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | /* | ||
333 | * Import file descriptor into gem handle. | ||
334 | * | ||
335 | * @dev: a exynos device object. | ||
336 | * @fd: file descriptor exported into dmabuf. | ||
337 | * @handle: gem handle to gem object imported from file descriptor | ||
338 | * and returned by kernel side. | ||
339 | * | ||
340 | * if true, return 0 else negative. | ||
341 | */ | ||
342 | int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd, | ||
343 | uint32_t *handle) | ||
344 | { | ||
345 | int ret; | ||
346 | struct drm_prime_handle req = { | ||
347 | .fd = fd, | ||
348 | }; | ||
349 | |||
350 | ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &req); | ||
351 | if (ret) { | ||
352 | fprintf(stderr, "failed to mmap[%s].\n", | ||
353 | strerror(errno)); | ||
354 | return ret; | ||
355 | } | ||
356 | |||
357 | *handle = req.handle; | ||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | |||
362 | |||
363 | /* | ||
364 | * Request Wireless Display connection or disconnection. | ||
365 | * | ||
366 | * @dev: a exynos device object. | ||
367 | * @connect: indicate whether connectoin or disconnection request. | ||
368 | * @ext: indicate whether edid data includes extentions data or not. | ||
369 | * @edid: a pointer to edid data from Wireless Display device. | ||
370 | * | ||
371 | * this interface is used to request Virtual Display driver connection or | ||
372 | * disconnection. for this, user should get a edid data from the Wireless | ||
373 | * Display device and then send that data to kernel driver with connection | ||
374 | * request | ||
375 | * | ||
376 | * if true, return 0 else negative. | ||
377 | */ | ||
378 | int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect, | ||
379 | uint32_t ext, void *edid) | ||
380 | { | ||
381 | struct drm_exynos_vidi_connection req = { | ||
382 | .connection = connect, | ||
383 | .extensions = ext, | ||
384 | .edid = edid, | ||
385 | }; | ||
386 | int ret; | ||
387 | |||
388 | ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_VIDI_CONNECTION, &req); | ||
389 | if (ret) { | ||
390 | fprintf(stderr, "failed to request vidi connection[%s].\n", | ||
391 | strerror(errno)); | ||
392 | return ret; | ||
393 | } | ||
394 | |||
395 | return 0; | ||
396 | } | ||
diff --git a/exynos/exynos_drm.h b/exynos/exynos_drm.h new file mode 100644 index 00000000..dc2eef36 --- /dev/null +++ b/exynos/exynos_drm.h | |||
@@ -0,0 +1,146 @@ | |||
1 | /* exynos_drm.h | ||
2 | * | ||
3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. | ||
4 | * Authors: | ||
5 | * Inki Dae <inki.dae@samsung.com> | ||
6 | * Joonyoung Shim <jy0922.shim@samsung.com> | ||
7 | * Seung-Woo Kim <sw0312.kim@samsung.com> | ||
8 | * | ||
9 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
10 | * copy of this software and associated documentation files (the "Software"), | ||
11 | * to deal in the Software without restriction, including without limitation | ||
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
13 | * and/or sell copies of the Software, and to permit persons to whom the | ||
14 | * Software is furnished to do so, subject to the following conditions: | ||
15 | * | ||
16 | * The above copyright notice and this permission notice (including the next | ||
17 | * paragraph) shall be included in all copies or substantial portions of the | ||
18 | * Software. | ||
19 | * | ||
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
23 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
24 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
25 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
26 | * OTHER DEALINGS IN THE SOFTWARE. | ||
27 | */ | ||
28 | |||
29 | #ifndef _EXYNOS_DRM_H_ | ||
30 | #define _EXYNOS_DRM_H_ | ||
31 | |||
32 | #include "drm.h" | ||
33 | |||
34 | /** | ||
35 | * User-desired buffer creation information structure. | ||
36 | * | ||
37 | * @size: user-desired memory allocation size. | ||
38 | * - this size value would be page-aligned internally. | ||
39 | * @flags: user request for setting memory type or cache attributes. | ||
40 | * @handle: returned a handle to created gem object. | ||
41 | * - this handle will be set by gem module of kernel side. | ||
42 | */ | ||
43 | struct drm_exynos_gem_create { | ||
44 | uint64_t size; | ||
45 | unsigned int flags; | ||
46 | unsigned int handle; | ||
47 | }; | ||
48 | |||
49 | /** | ||
50 | * A structure for getting buffer offset. | ||
51 | * | ||
52 | * @handle: a pointer to gem object created. | ||
53 | * @pad: just padding to be 64-bit aligned. | ||
54 | * @offset: relatived offset value of the memory region allocated. | ||
55 | * - this value should be set by user. | ||
56 | */ | ||
57 | struct drm_exynos_gem_map_off { | ||
58 | unsigned int handle; | ||
59 | unsigned int pad; | ||
60 | uint64_t offset; | ||
61 | }; | ||
62 | |||
63 | /** | ||
64 | * A structure for mapping buffer. | ||
65 | * | ||
66 | * @handle: a handle to gem object created. | ||
67 | * @size: memory size to be mapped. | ||
68 | * @mapped: having user virtual address mmaped. | ||
69 | * - this variable would be filled by exynos gem module | ||
70 | * of kernel side with user virtual address which is allocated | ||
71 | * by do_mmap(). | ||
72 | */ | ||
73 | struct drm_exynos_gem_mmap { | ||
74 | unsigned int handle; | ||
75 | unsigned int size; | ||
76 | uint64_t mapped; | ||
77 | }; | ||
78 | |||
79 | /** | ||
80 | * A structure to gem information. | ||
81 | * | ||
82 | * @handle: a handle to gem object created. | ||
83 | * @flags: flag value including memory type and cache attribute and | ||
84 | * this value would be set by driver. | ||
85 | * @size: size to memory region allocated by gem and this size would | ||
86 | * be set by driver. | ||
87 | */ | ||
88 | struct drm_exynos_gem_info { | ||
89 | unsigned int handle; | ||
90 | unsigned int flags; | ||
91 | uint64_t size; | ||
92 | }; | ||
93 | |||
94 | /** | ||
95 | * A structure for user connection request of virtual display. | ||
96 | * | ||
97 | * @connection: indicate whether doing connetion or not by user. | ||
98 | * @extensions: if this value is 1 then the vidi driver would need additional | ||
99 | * 128bytes edid data. | ||
100 | * @edid: the edid data pointer from user side. | ||
101 | */ | ||
102 | struct drm_exynos_vidi_connection { | ||
103 | unsigned int connection; | ||
104 | unsigned int extensions; | ||
105 | uint64_t edid; | ||
106 | }; | ||
107 | |||
108 | /* memory type definitions. */ | ||
109 | enum e_drm_exynos_gem_mem_type { | ||
110 | /* Physically Continuous memory and used as default. */ | ||
111 | EXYNOS_BO_CONTIG = 0 << 0, | ||
112 | /* Physically Non-Continuous memory. */ | ||
113 | EXYNOS_BO_NONCONTIG = 1 << 0, | ||
114 | /* non-cachable mapping and used as default. */ | ||
115 | EXYNOS_BO_NONCACHABLE = 0 << 1, | ||
116 | /* cachable mapping. */ | ||
117 | EXYNOS_BO_CACHABLE = 1 << 1, | ||
118 | /* write-combine mapping. */ | ||
119 | EXYNOS_BO_WC = 1 << 2, | ||
120 | EXYNOS_BO_MASK = EXYNOS_BO_NONCONTIG | EXYNOS_BO_CACHABLE | | ||
121 | EXYNOS_BO_WC | ||
122 | }; | ||
123 | |||
124 | #define DRM_EXYNOS_GEM_CREATE 0x00 | ||
125 | #define DRM_EXYNOS_GEM_MAP_OFFSET 0x01 | ||
126 | #define DRM_EXYNOS_GEM_MMAP 0x02 | ||
127 | /* Reserved 0x04 ~ 0x05 for exynos specific gem ioctl */ | ||
128 | #define DRM_EXYNOS_GEM_GET 0x04 | ||
129 | #define DRM_EXYNOS_VIDI_CONNECTION 0x07 | ||
130 | |||
131 | #define DRM_IOCTL_EXYNOS_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ | ||
132 | DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create) | ||
133 | |||
134 | #define DRM_IOCTL_EXYNOS_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \ | ||
135 | DRM_EXYNOS_GEM_MAP_OFFSET, struct drm_exynos_gem_map_off) | ||
136 | |||
137 | #define DRM_IOCTL_EXYNOS_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + \ | ||
138 | DRM_EXYNOS_GEM_MMAP, struct drm_exynos_gem_mmap) | ||
139 | |||
140 | #define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ | ||
141 | DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info) | ||
142 | |||
143 | #define DRM_IOCTL_EXYNOS_VIDI_CONNECTION DRM_IOWR(DRM_COMMAND_BASE + \ | ||
144 | DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection) | ||
145 | |||
146 | #endif | ||
diff --git a/exynos/exynos_drmif.h b/exynos/exynos_drmif.h new file mode 100644 index 00000000..92f613ea --- /dev/null +++ b/exynos/exynos_drmif.h | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Samsung Electronics Co., Ltd. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice (including the next | ||
12 | * paragraph) shall be included in all copies or substantial portions of the | ||
13 | * Software. | ||
14 | * | ||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
21 | * SOFTWARE. | ||
22 | * | ||
23 | * Authors: | ||
24 | * Inki Dae <inki.dae@samsung.com> | ||
25 | */ | ||
26 | |||
27 | #ifndef EXYNOS_DRMIF_H_ | ||
28 | #define EXYNOS_DRMIF_H_ | ||
29 | |||
30 | #include <xf86drm.h> | ||
31 | #include <stdint.h> | ||
32 | #include "exynos_drm.h" | ||
33 | |||
34 | struct exynos_device { | ||
35 | int fd; | ||
36 | }; | ||
37 | |||
38 | /* | ||
39 | * Exynos Buffer Object structure. | ||
40 | * | ||
41 | * @dev: exynos device object allocated. | ||
42 | * @handle: a gem handle to gem object created. | ||
43 | * @flags: indicate memory allocation and cache attribute types. | ||
44 | * @fd: file descriptor exported into dmabuf. | ||
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 exynos_bo { | ||
50 | struct exynos_device *dev; | ||
51 | uint32_t handle; | ||
52 | uint32_t flags; | ||
53 | int fd; | ||
54 | size_t size; | ||
55 | void *vaddr; | ||
56 | uint32_t name; | ||
57 | }; | ||
58 | |||
59 | /* | ||
60 | * device related functions: | ||
61 | */ | ||
62 | struct exynos_device * exynos_device_create(int fd); | ||
63 | void exynos_device_destroy(struct exynos_device *dev); | ||
64 | |||
65 | /* | ||
66 | * buffer-object related functions: | ||
67 | */ | ||
68 | struct exynos_bo * exynos_bo_create(struct exynos_device *dev, | ||
69 | size_t size, uint32_t flags); | ||
70 | int exynos_bo_get_info(struct exynos_device *dev, uint32_t handle, | ||
71 | size_t *size, uint32_t *flags); | ||
72 | void exynos_bo_destroy(struct exynos_bo *bo); | ||
73 | struct exynos_bo * exynos_bo_from_name(struct exynos_device *dev, uint32_t name); | ||
74 | int exynos_bo_get_name(struct exynos_bo *bo, uint32_t *name); | ||
75 | uint32_t exynos_bo_handle(struct exynos_bo *bo); | ||
76 | void * exynos_bo_map(struct exynos_bo *bo); | ||
77 | int exynos_prime_handle_to_fd(struct exynos_device *dev, uint32_t handle, | ||
78 | int *fd); | ||
79 | int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd, | ||
80 | uint32_t *handle); | ||
81 | |||
82 | /* | ||
83 | * Virtual Display related functions: | ||
84 | */ | ||
85 | int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect, | ||
86 | uint32_t ext, void *edid); | ||
87 | |||
88 | #endif /* EXYNOS_DRMIF_H_ */ | ||
diff --git a/exynos/libdrm_exynos.pc.in b/exynos/libdrm_exynos.pc.in new file mode 100644 index 00000000..5ce91186 --- /dev/null +++ b/exynos/libdrm_exynos.pc.in | |||
@@ -0,0 +1,11 @@ | |||
1 | prefix=@prefix@ | ||
2 | exec_prefix=@exec_prefix@ | ||
3 | libdir=@libdir@ | ||
4 | includedir=@includedir@ | ||
5 | |||
6 | Name: libdrm_exynos | ||
7 | Description: Userspace interface to exynos kernel DRM services | ||
8 | Version: 0.6 | ||
9 | Libs: -L${libdir} -ldrm_exynos | ||
10 | Cflags: -I${includedir} -I${includedir}/libdrm -I${includedir}/exynos | ||
11 | Requires.private: libdrm | ||