ipptest: add fimc and rotator test applications
[platform/upstream/libdrm.git] / exynos / exynos_drm.h
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  * @pad: just padding to be 64-bit aligned.
68  * @size: memory size to be mapped.
69  * @mapped: having user virtual address mmaped.
70  *      - this variable would be filled by exynos gem module
71  *      of kernel side with user virtual address which is allocated
72  *      by do_mmap().
73  */
74 struct drm_exynos_gem_mmap {
75         unsigned int handle;
76         unsigned int pad;
77         uint64_t size;
78         uint64_t mapped;
79 };
80
81 /**
82  * A structure to gem information.
83  *
84  * @handle: a handle to gem object created.
85  * @flags: flag value including memory type and cache attribute and
86  *      this value would be set by driver.
87  * @size: size to memory region allocated by gem and this size would
88  *      be set by driver.
89  */
90 struct drm_exynos_gem_info {
91         unsigned int handle;
92         unsigned int flags;
93         uint64_t size;
94 };
95
96 /**
97  * A structure for user connection request of virtual display.
98  *
99  * @connection: indicate whether doing connetion or not by user.
100  * @extensions: if this value is 1 then the vidi driver would need additional
101  *      128bytes edid data.
102  * @edid: the edid data pointer from user side.
103  */
104 struct drm_exynos_vidi_connection {
105         unsigned int connection;
106         unsigned int extensions;
107         uint64_t edid;
108 };
109
110 /* memory type definitions. */
111 enum e_drm_exynos_gem_mem_type {
112         /* Physically Continuous memory and used as default. */
113         EXYNOS_BO_CONTIG        = 0 << 0,
114         /* Physically Non-Continuous memory. */
115         EXYNOS_BO_NONCONTIG     = 1 << 0,
116         /* non-cachable mapping and used as default. */
117         EXYNOS_BO_NONCACHABLE   = 0 << 1,
118         /* cachable mapping. */
119         EXYNOS_BO_CACHABLE      = 1 << 1,
120         /* write-combine mapping. */
121         EXYNOS_BO_WC            = 1 << 2,
122         EXYNOS_BO_MASK          = EXYNOS_BO_NONCONTIG | EXYNOS_BO_CACHABLE |
123                                         EXYNOS_BO_WC
124 };
125
126 struct drm_exynos_g2d_get_ver {
127         __u32   major;
128         __u32   minor;
129 };
130
131 struct drm_exynos_g2d_cmd {
132         __u32   offset;
133         __u32   data;
134 };
135
136 enum drm_exynos_g2d_buf_type {
137         G2D_BUF_USERPTR = 1 << 31,
138 };
139
140 enum drm_exynos_g2d_event_type {
141         G2D_EVENT_NOT,
142         G2D_EVENT_NONSTOP,
143         G2D_EVENT_STOP,         /* not yet */
144 };
145
146 struct drm_exynos_g2d_userptr {
147         unsigned long userptr;
148         unsigned long size;
149 };
150
151 struct drm_exynos_g2d_set_cmdlist {
152         __u64                                   cmd;
153         __u64                                   cmd_buf;
154         __u32                                   cmd_nr;
155         __u32                                   cmd_buf_nr;
156
157         /* for g2d event */
158         __u64                                   event_type;
159         __u64                                   user_data;
160 };
161
162 struct drm_exynos_g2d_exec {
163         __u64                                   async;
164 };
165
166 /* definition of operations types */
167 enum drm_exynos_ops_id {
168         EXYNOS_DRM_OPS_SRC,
169         EXYNOS_DRM_OPS_DST,
170         EXYNOS_DRM_OPS_MAX,
171 };
172
173 /* definition of size */
174 struct drm_exynos_sz {
175         __u32   hsize;
176         __u32   vsize;
177 };
178
179 /* definition of position */
180 struct drm_exynos_pos {
181         __u32   x;
182         __u32   y;
183         __u32   w;
184         __u32   h;
185 };
186
187 /* definition of flip */
188 enum drm_exynos_flip {
189         EXYNOS_DRM_FLIP_NONE = (0 << 0),
190         EXYNOS_DRM_FLIP_VERTICAL = (1 << 0),
191         EXYNOS_DRM_FLIP_HORIZONTAL = (1 << 1),
192         EXYNOS_DRM_FLIP_BOTH = EXYNOS_DRM_FLIP_VERTICAL |
193                         EXYNOS_DRM_FLIP_HORIZONTAL,
194 };
195
196 /* definition of rotation degree */
197 enum drm_exynos_degree {
198         EXYNOS_DRM_DEGREE_0,
199         EXYNOS_DRM_DEGREE_90,
200         EXYNOS_DRM_DEGREE_180,
201         EXYNOS_DRM_DEGREE_270,
202 };
203
204 /* definition of planar */
205 enum drm_exynos_planer {
206         EXYNOS_DRM_PLANAR_Y,
207         EXYNOS_DRM_PLANAR_CB,
208         EXYNOS_DRM_PLANAR_CR,
209         EXYNOS_DRM_PLANAR_MAX,
210 };
211
212 /**
213  * A structure for ipp supported property list.
214  *
215  * @version: version of this structure.
216  * @ipp_id: id of ipp driver.
217  * @count: count of ipp driver.
218  * @writeback: flag of writeback supporting.
219  * @flip: flag of flip supporting.
220  * @degree: flag of degree information.
221  * @csc: flag of csc supporting.
222  * @crop: flag of crop supporting.
223  * @scale: flag of scale supporting.
224  * @refresh_min: min hz of refresh.
225  * @refresh_max: max hz of refresh.
226  * @crop_min: crop min resolution.
227  * @crop_max: crop max resolution.
228  * @scale_min: scale min resolution.
229  * @scale_max: scale max resolution.
230  */
231 struct drm_exynos_ipp_prop_list {
232         __u32   version;
233         __u32   ipp_id;
234         __u32   count;
235         __u32   writeback;
236         __u32   flip;
237         __u32   degree;
238         __u32   csc;
239         __u32   crop;
240         __u32   scale;
241         __u32   refresh_min;
242         __u32   refresh_max;
243         __u32   reserved;
244         struct drm_exynos_sz    crop_min;
245         struct drm_exynos_sz    crop_max;
246         struct drm_exynos_sz    scale_min;
247         struct drm_exynos_sz    scale_max;
248 };
249
250 /**
251  * A structure for ipp config.
252  *
253  * @ops_id: property of operation directions.
254  * @flip: property of mirror, flip.
255  * @degree: property of rotation degree.
256  * @fmt: property of image format.
257  * @sz: property of image size.
258  * @pos: property of image position(src-cropped,dst-scaler).
259  */
260 struct drm_exynos_ipp_config {
261         enum drm_exynos_ops_id ops_id;
262         enum drm_exynos_flip    flip;
263         enum drm_exynos_degree  degree;
264         __u32   fmt;
265         struct drm_exynos_sz    sz;
266         struct drm_exynos_pos   pos;
267 };
268
269 /* definition of command */
270 enum drm_exynos_ipp_cmd {
271         IPP_CMD_NONE,
272         IPP_CMD_M2M,
273         IPP_CMD_WB,
274         IPP_CMD_OUTPUT,
275         IPP_CMD_MAX,
276 };
277
278 /**
279  * A structure for ipp property.
280  *
281  * @config: source, destination config.
282  * @cmd: definition of command.
283  * @ipp_id: id of ipp driver.
284  * @prop_id: id of property.
285  * @refresh_rate: refresh rate.
286  */
287 struct drm_exynos_ipp_property {
288         struct drm_exynos_ipp_config config[EXYNOS_DRM_OPS_MAX];
289         enum drm_exynos_ipp_cmd cmd;
290         __u32   ipp_id;
291         __u32   prop_id;
292         __u32   refresh_rate;
293 };
294
295 /* definition of buffer */
296 enum drm_exynos_ipp_buf_type {
297         IPP_BUF_ENQUEUE,
298         IPP_BUF_DEQUEUE,
299 };
300
301 /**
302  * A structure for ipp buffer operations.
303  *
304  * @ops_id: operation directions.
305  * @buf_type: definition of buffer.
306  * @prop_id: id of property.
307  * @buf_id: id of buffer.
308  * @handle: Y, Cb, Cr each planar handle.
309  * @user_data: user data.
310  */
311 struct drm_exynos_ipp_queue_buf {
312         enum drm_exynos_ops_id  ops_id;
313         enum drm_exynos_ipp_buf_type    buf_type;
314         __u32   prop_id;
315         __u32   buf_id;
316         __u32   handle[EXYNOS_DRM_PLANAR_MAX];
317         __u32   reserved;
318         __u64   user_data;
319 };
320
321 /* definition of control */
322 enum drm_exynos_ipp_ctrl {
323         IPP_CTRL_PLAY,
324         IPP_CTRL_STOP,
325         IPP_CTRL_PAUSE,
326         IPP_CTRL_RESUME,
327         IPP_CTRL_MAX,
328 };
329
330 /**
331  * A structure for ipp start/stop operations.
332  *
333  * @prop_id: id of property.
334  * @ctrl: definition of control.
335  */
336 struct drm_exynos_ipp_cmd_ctrl {
337         __u32   prop_id;
338         enum drm_exynos_ipp_ctrl        ctrl;
339 };
340
341 #define DRM_EXYNOS_GEM_CREATE           0x00
342 #define DRM_EXYNOS_GEM_MAP_OFFSET       0x01
343 #define DRM_EXYNOS_GEM_MMAP             0x02
344 /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
345 #define DRM_EXYNOS_GEM_GET              0x04
346 #define DRM_EXYNOS_VIDI_CONNECTION      0x07
347
348 /* G2D */
349 #define DRM_EXYNOS_G2D_GET_VER          0x20
350 #define DRM_EXYNOS_G2D_SET_CMDLIST      0x21
351 #define DRM_EXYNOS_G2D_EXEC             0x22
352
353 /* IPP - Image Post Processing */
354 #define DRM_EXYNOS_IPP_GET_PROPERTY     0x30
355 #define DRM_EXYNOS_IPP_SET_PROPERTY     0x31
356 #define DRM_EXYNOS_IPP_QUEUE_BUF        0x32
357 #define DRM_EXYNOS_IPP_CMD_CTRL 0x33
358
359 #define DRM_IOCTL_EXYNOS_GEM_CREATE             DRM_IOWR(DRM_COMMAND_BASE + \
360                 DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
361
362 #define DRM_IOCTL_EXYNOS_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \
363                 DRM_EXYNOS_GEM_MAP_OFFSET, struct drm_exynos_gem_map_off)
364
365 #define DRM_IOCTL_EXYNOS_GEM_MMAP       DRM_IOWR(DRM_COMMAND_BASE + \
366                 DRM_EXYNOS_GEM_MMAP, struct drm_exynos_gem_mmap)
367
368 #define DRM_IOCTL_EXYNOS_GEM_GET        DRM_IOWR(DRM_COMMAND_BASE + \
369                 DRM_EXYNOS_GEM_GET,     struct drm_exynos_gem_info)
370
371 #define DRM_IOCTL_EXYNOS_VIDI_CONNECTION        DRM_IOWR(DRM_COMMAND_BASE + \
372                 DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection)
373
374 #define DRM_IOCTL_EXYNOS_G2D_GET_VER            DRM_IOWR(DRM_COMMAND_BASE + \
375                 DRM_EXYNOS_G2D_GET_VER, struct drm_exynos_g2d_get_ver)
376 #define DRM_IOCTL_EXYNOS_G2D_SET_CMDLIST        DRM_IOWR(DRM_COMMAND_BASE + \
377                 DRM_EXYNOS_G2D_SET_CMDLIST, struct drm_exynos_g2d_set_cmdlist)
378 #define DRM_IOCTL_EXYNOS_G2D_EXEC               DRM_IOWR(DRM_COMMAND_BASE + \
379                 DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
380
381 #define DRM_IOCTL_EXYNOS_IPP_GET_PROPERTY       DRM_IOWR(DRM_COMMAND_BASE + \
382                 DRM_EXYNOS_IPP_GET_PROPERTY, struct drm_exynos_ipp_prop_list)
383 #define DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY       DRM_IOWR(DRM_COMMAND_BASE + \
384                 DRM_EXYNOS_IPP_SET_PROPERTY, struct drm_exynos_ipp_property)
385 #define DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF  DRM_IOWR(DRM_COMMAND_BASE + \
386                 DRM_EXYNOS_IPP_QUEUE_BUF, struct drm_exynos_ipp_queue_buf)
387 #define DRM_IOCTL_EXYNOS_IPP_CMD_CTRL           DRM_IOWR(DRM_COMMAND_BASE + \
388                 DRM_EXYNOS_IPP_CMD_CTRL, struct drm_exynos_ipp_cmd_ctrl)
389
390 /* EXYNOS specific events */
391 #define DRM_EXYNOS_G2D_EVENT            0x80000000
392 #define DRM_EXYNOS_IPP_EVENT            0x80000001
393
394 struct drm_exynos_g2d_event {
395         struct drm_event        base;
396         __u64                   user_data;
397         __u32                   tv_sec;
398         __u32                   tv_usec;
399         __u32                   cmdlist_no;
400         __u32                   reserved;
401 };
402
403 struct drm_exynos_ipp_event {
404         struct drm_event        base;
405         __u64                   user_data;
406         __u32                   tv_sec;
407         __u32                   tv_usec;
408         __u32                   prop_id;
409         __u32                   reserved;
410         __u32                   buf_id[EXYNOS_DRM_OPS_MAX];
411 };
412
413 #endif