summaryrefslogtreecommitdiff
path: root/src/static_libs/libdrm
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-06-02 07:06:26 -0500
committerDerek Foreman <derekf@osg.samsung.com>2016-06-03 11:05:28 -0500
commit821aada3c442af82339b01df036fa13aa086491a (patch)
treec8a8be7ef1e1842db4112f56b0a608f1fbe5833b /src/static_libs/libdrm
parent0f07f67b127ae2c1810b7955f049ff53584a53fc (diff)
wayland_shm: Add exynos allocator for dmabuf
Allows clients on exynos hardware to allocate GEM buffer objects to back DMAbuf buffers.
Diffstat (limited to 'src/static_libs/libdrm')
-rw-r--r--src/static_libs/libdrm/exynos_drm.h172
-rw-r--r--src/static_libs/libdrm/exynos_drmif.h112
2 files changed, 284 insertions, 0 deletions
diff --git a/src/static_libs/libdrm/exynos_drm.h b/src/static_libs/libdrm/exynos_drm.h
new file mode 100644
index 0000000000..c3af0ac5f6
--- /dev/null
+++ b/src/static_libs/libdrm/exynos_drm.h
@@ -0,0 +1,172 @@
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 */
43struct drm_exynos_gem_create {
44 uint64_t size;
45 unsigned int flags;
46 unsigned int handle;
47};
48
49/**
50 * A structure to gem information.
51 *
52 * @handle: a handle to gem object created.
53 * @flags: flag value including memory type and cache attribute and
54 * this value would be set by driver.
55 * @size: size to memory region allocated by gem and this size would
56 * be set by driver.
57 */
58struct drm_exynos_gem_info {
59 unsigned int handle;
60 unsigned int flags;
61 uint64_t size;
62};
63
64/**
65 * A structure for user connection request of virtual display.
66 *
67 * @connection: indicate whether doing connetion or not by user.
68 * @extensions: if this value is 1 then the vidi driver would need additional
69 * 128bytes edid data.
70 * @edid: the edid data pointer from user side.
71 */
72struct drm_exynos_vidi_connection {
73 unsigned int connection;
74 unsigned int extensions;
75 uint64_t edid;
76};
77
78/* memory type definitions. */
79enum e_drm_exynos_gem_mem_type {
80 /* Physically Continuous memory and used as default. */
81 EXYNOS_BO_CONTIG = 0 << 0,
82 /* Physically Non-Continuous memory. */
83 EXYNOS_BO_NONCONTIG = 1 << 0,
84 /* non-cachable mapping and used as default. */
85 EXYNOS_BO_NONCACHABLE = 0 << 1,
86 /* cachable mapping. */
87 EXYNOS_BO_CACHABLE = 1 << 1,
88 /* write-combine mapping. */
89 EXYNOS_BO_WC = 1 << 2,
90 EXYNOS_BO_MASK = EXYNOS_BO_NONCONTIG | EXYNOS_BO_CACHABLE |
91 EXYNOS_BO_WC
92};
93
94struct drm_exynos_g2d_get_ver {
95 __u32 major;
96 __u32 minor;
97};
98
99struct drm_exynos_g2d_cmd {
100 __u32 offset;
101 __u32 data;
102};
103
104enum drm_exynos_g2d_buf_type {
105 G2D_BUF_USERPTR = 1 << 31,
106};
107
108enum drm_exynos_g2d_event_type {
109 G2D_EVENT_NOT,
110 G2D_EVENT_NONSTOP,
111 G2D_EVENT_STOP, /* not yet */
112};
113
114struct drm_exynos_g2d_userptr {
115 unsigned long userptr;
116 unsigned long size;
117};
118
119struct drm_exynos_g2d_set_cmdlist {
120 __u64 cmd;
121 __u64 cmd_buf;
122 __u32 cmd_nr;
123 __u32 cmd_buf_nr;
124
125 /* for g2d event */
126 __u64 event_type;
127 __u64 user_data;
128};
129
130struct drm_exynos_g2d_exec {
131 __u64 async;
132};
133
134#define DRM_EXYNOS_GEM_CREATE 0x00
135/* Reserved 0x04 ~ 0x05 for exynos specific gem ioctl */
136#define DRM_EXYNOS_GEM_GET 0x04
137#define DRM_EXYNOS_VIDI_CONNECTION 0x07
138
139/* G2D */
140#define DRM_EXYNOS_G2D_GET_VER 0x20
141#define DRM_EXYNOS_G2D_SET_CMDLIST 0x21
142#define DRM_EXYNOS_G2D_EXEC 0x22
143
144#define DRM_IOCTL_EXYNOS_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \
145 DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
146
147#define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \
148 DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info)
149
150#define DRM_IOCTL_EXYNOS_VIDI_CONNECTION DRM_IOWR(DRM_COMMAND_BASE + \
151 DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection)
152
153#define DRM_IOCTL_EXYNOS_G2D_GET_VER DRM_IOWR(DRM_COMMAND_BASE + \
154 DRM_EXYNOS_G2D_GET_VER, struct drm_exynos_g2d_get_ver)
155#define DRM_IOCTL_EXYNOS_G2D_SET_CMDLIST DRM_IOWR(DRM_COMMAND_BASE + \
156 DRM_EXYNOS_G2D_SET_CMDLIST, struct drm_exynos_g2d_set_cmdlist)
157#define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + \
158 DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
159
160/* EXYNOS specific events */
161#define DRM_EXYNOS_G2D_EVENT 0x80000000
162
163struct drm_exynos_g2d_event {
164 struct drm_event base;
165 __u64 user_data;
166 __u32 tv_sec;
167 __u32 tv_usec;
168 __u32 cmdlist_no;
169 __u32 reserved;
170};
171
172#endif
diff --git a/src/static_libs/libdrm/exynos_drmif.h b/src/static_libs/libdrm/exynos_drmif.h
new file mode 100644
index 0000000000..626e39985a
--- /dev/null
+++ b/src/static_libs/libdrm/exynos_drmif.h
@@ -0,0 +1,112 @@
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
34struct 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 * @size: size to the buffer created.
45 * @vaddr: user space address to a gem buffer mmaped.
46 * @name: a gem global handle from flink request.
47 */
48struct exynos_bo {
49 struct exynos_device *dev;
50 uint32_t handle;
51 uint32_t flags;
52 size_t size;
53 void *vaddr;
54 uint32_t name;
55};
56
57#define EXYNOS_EVENT_CONTEXT_VERSION 1
58
59/*
60 * Exynos Event Context structure.
61 *
62 * @base: base context (for core events).
63 * @version: version info similar to the one in 'drmEventContext'.
64 * @g2d_event_handler: handler for G2D events.
65 */
66struct exynos_event_context {
67 drmEventContext base;
68
69 int version;
70
71 void (*g2d_event_handler)(int fd, unsigned int cmdlist_no,
72 unsigned int tv_sec, unsigned int tv_usec,
73 void *user_data);
74};
75
76/*
77 * device related functions:
78 */
79struct exynos_device * exynos_device_create(int fd);
80void exynos_device_destroy(struct exynos_device *dev);
81
82/*
83 * buffer-object related functions:
84 */
85struct exynos_bo * exynos_bo_create(struct exynos_device *dev,
86 size_t size, uint32_t flags);
87int exynos_bo_get_info(struct exynos_device *dev, uint32_t handle,
88 size_t *size, uint32_t *flags);
89void exynos_bo_destroy(struct exynos_bo *bo);
90struct exynos_bo * exynos_bo_from_name(struct exynos_device *dev, uint32_t name);
91int exynos_bo_get_name(struct exynos_bo *bo, uint32_t *name);
92uint32_t exynos_bo_handle(struct exynos_bo *bo);
93void * exynos_bo_map(struct exynos_bo *bo);
94int exynos_prime_handle_to_fd(struct exynos_device *dev, uint32_t handle,
95 int *fd);
96int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd,
97 uint32_t *handle);
98
99/*
100 * Virtual Display related functions:
101 */
102int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect,
103 uint32_t ext, void *edid);
104
105/*
106 * event handling related functions:
107 */
108int exynos_handle_event(struct exynos_device *dev,
109 struct exynos_event_context *ctx);
110
111
112#endif /* EXYNOS_DRMIF_H_ */