drm/rockchip: gem: add get phys ioctl
[firefly-linux-kernel-4.4.55.git] / include / uapi / drm / rockchip_drm.h
1 /*
2  *
3  * Copyright (c) Fuzhou Rockchip Electronics Co.Ltd
4  * Authors:
5  *       Mark Yao <yzq@rock-chips.com>
6  *
7  * base on exynos_drm.h
8  *
9  * This program is free software; you can redistribute  it and/or modify it
10  * under  the terms of  the GNU General  Public License as published by the
11  * Free Software Foundation;  either version 2 of the  License, or (at your
12  * option) any later version.
13  */
14
15 #ifndef _UAPI_ROCKCHIP_DRM_H
16 #define _UAPI_ROCKCHIP_DRM_H
17
18 #include <drm/drm.h>
19
20 /* memory type definitions. */
21 enum drm_rockchip_gem_mem_type {
22         /* Physically Continuous memory. */
23         ROCKCHIP_BO_CONTIG      = 1 << 0,
24         /* cachable mapping. */
25         ROCKCHIP_BO_CACHABLE    = 1 << 1,
26         /* write-combine mapping. */
27         ROCKCHIP_BO_WC          = 1 << 2,
28         ROCKCHIP_BO_MASK        = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE |
29                                 ROCKCHIP_BO_WC
30 };
31
32 /**
33  * User-desired buffer creation information structure.
34  *
35  * @size: user-desired memory allocation size.
36  * @flags: user request for setting memory type or cache attributes.
37  * @handle: returned a handle to created gem object.
38  *     - this handle will be set by gem module of kernel side.
39  */
40 struct drm_rockchip_gem_create {
41         uint64_t size;
42         uint32_t flags;
43         uint32_t handle;
44 };
45
46 struct drm_rockchip_gem_phys {
47         uint32_t handle;
48         uint32_t phy_addr;
49 };
50
51 /**
52  * A structure for getting buffer offset.
53  *
54  * @handle: a pointer to gem object created.
55  * @pad: just padding to be 64-bit aligned.
56  * @offset: relatived offset value of the memory region allocated.
57  *     - this value should be set by user.
58  */
59 struct drm_rockchip_gem_map_off {
60         uint32_t handle;
61         uint32_t pad;
62         uint64_t offset;
63 };
64
65 /* acquire type definitions. */
66 enum drm_rockchip_gem_cpu_acquire_type {
67         DRM_ROCKCHIP_GEM_CPU_ACQUIRE_SHARED = 0x0,
68         DRM_ROCKCHIP_GEM_CPU_ACQUIRE_EXCLUSIVE = 0x1,
69 };
70
71 /**
72  * A structure for acquiring buffer for CPU access.
73  *
74  * @handle: a handle to gem object created.
75  * @flags: acquire flag
76  */
77 struct drm_rockchip_gem_cpu_acquire {
78         uint32_t handle;
79         uint32_t flags;
80 };
81
82 /*
83  * A structure for releasing buffer for GPU access.
84  *
85  * @handle: a handle to gem object created.
86  */
87 struct drm_rockchip_gem_cpu_release {
88         uint32_t handle;
89 };
90
91 struct drm_rockchip_rga_get_ver {
92         __u32   major;
93         __u32   minor;
94 };
95
96 struct drm_rockchip_rga_cmd {
97         __u32   offset;
98         __u32   data;
99 };
100
101 enum drm_rockchip_rga_buf_type {
102         RGA_BUF_TYPE_USERPTR = 1 << 31,
103         RGA_BUF_TYPE_GEMFD   = 1 << 30,
104         RGA_BUF_TYPE_FLUSH   = 1 << 29,
105 };
106
107 struct drm_rockchip_rga_set_cmdlist {
108         __u64           cmd;
109         __u64           cmd_buf;
110         __u32           cmd_nr;
111         __u32           cmd_buf_nr;
112         __u64           user_data;
113 };
114
115 struct drm_rockchip_rga_exec {
116         __u64           async;
117 };
118
119 enum rockchip_plane_feture {
120         ROCKCHIP_DRM_PLANE_FEATURE_SCALE,
121         ROCKCHIP_DRM_PLANE_FEATURE_ALPHA,
122         ROCKCHIP_DRM_PLANE_FEATURE_MAX,
123 };
124
125 enum rockchip_crtc_feture {
126         ROCKCHIP_DRM_CRTC_FEATURE_AFBDC,
127 };
128
129 enum rockchip_cabc_mode {
130         ROCKCHIP_DRM_CABC_MODE_DISABLE,
131         ROCKCHIP_DRM_CABC_MODE_NORMAL,
132         ROCKCHIP_DRM_CABC_MODE_LOWPOWER,
133         ROCKCHIP_DRM_CABC_MODE_USERSPACE,
134 };
135
136 #define DRM_ROCKCHIP_GEM_CREATE         0x00
137 #define DRM_ROCKCHIP_GEM_MAP_OFFSET     0x01
138 #define DRM_ROCKCHIP_GEM_CPU_ACQUIRE    0x02
139 #define DRM_ROCKCHIP_GEM_CPU_RELEASE    0x03
140 #define DRM_ROCKCHIP_GEM_GET_PHYS       0x04
141
142 #define DRM_ROCKCHIP_RGA_GET_VER        0x20
143 #define DRM_ROCKCHIP_RGA_SET_CMDLIST    0x21
144 #define DRM_ROCKCHIP_RGA_EXEC           0x22
145
146 #define DRM_IOCTL_ROCKCHIP_GEM_CREATE   DRM_IOWR(DRM_COMMAND_BASE + \
147                 DRM_ROCKCHIP_GEM_CREATE, struct drm_rockchip_gem_create)
148
149 #define DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET       DRM_IOWR(DRM_COMMAND_BASE + \
150                 DRM_ROCKCHIP_GEM_MAP_OFFSET, struct drm_rockchip_gem_map_off)
151
152 #define DRM_IOCTL_ROCKCHIP_GEM_CPU_ACQUIRE      DRM_IOWR(DRM_COMMAND_BASE + \
153                 DRM_ROCKCHIP_GEM_CPU_ACQUIRE, struct drm_rockchip_gem_cpu_acquire)
154
155 #define DRM_IOCTL_ROCKCHIP_GEM_CPU_RELEASE      DRM_IOWR(DRM_COMMAND_BASE + \
156                 DRM_ROCKCHIP_GEM_CPU_RELEASE, struct drm_rockchip_gem_cpu_release)
157
158 #define DRM_IOCTL_ROCKCHIP_GEM_GET_PHYS         DRM_IOWR(DRM_COMMAND_BASE + \
159                 DRM_ROCKCHIP_GEM_GET_PHYS, struct drm_rockchip_gem_phys)
160
161 #define DRM_IOCTL_ROCKCHIP_RGA_GET_VER          DRM_IOWR(DRM_COMMAND_BASE + \
162                 DRM_ROCKCHIP_RGA_GET_VER, struct drm_rockchip_rga_get_ver)
163
164 #define DRM_IOCTL_ROCKCHIP_RGA_SET_CMDLIST      DRM_IOWR(DRM_COMMAND_BASE + \
165                 DRM_ROCKCHIP_RGA_SET_CMDLIST, struct drm_rockchip_rga_set_cmdlist)
166
167 #define DRM_IOCTL_ROCKCHIP_RGA_EXEC             DRM_IOWR(DRM_COMMAND_BASE + \
168                 DRM_ROCKCHIP_RGA_EXEC, struct drm_rockchip_rga_exec)
169
170 #endif /* _UAPI_ROCKCHIP_DRM_H */