drm/rockchip: add cabc support
[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 and used as default. */
23         ROCKCHIP_BO_CONTIG      = 0 << 0,
24         /* Physically Non-Continuous memory. */
25         ROCKCHIP_BO_NONCONTIG   = 1 << 0,
26         /* non-cachable mapping and used as default. */
27         ROCKCHIP_BO_NONCACHABLE = 0 << 1,
28         /* cachable mapping. */
29         ROCKCHIP_BO_CACHABLE    = 1 << 1,
30         /* write-combine mapping. */
31         ROCKCHIP_BO_WC          = 1 << 2,
32         ROCKCHIP_BO_MASK        = ROCKCHIP_BO_NONCONTIG | ROCKCHIP_BO_CACHABLE |
33                                 ROCKCHIP_BO_WC
34 };
35
36 /**
37  * User-desired buffer creation information structure.
38  *
39  * @size: user-desired memory allocation size.
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 /* acquire type definitions. */
65 enum drm_rockchip_gem_cpu_acquire_type {
66         DRM_ROCKCHIP_GEM_CPU_ACQUIRE_SHARED = 0x0,
67         DRM_ROCKCHIP_GEM_CPU_ACQUIRE_EXCLUSIVE = 0x1,
68 };
69
70 /**
71  * A structure for acquiring buffer for CPU access.
72  *
73  * @handle: a handle to gem object created.
74  * @flags: acquire flag
75  */
76 struct drm_rockchip_gem_cpu_acquire {
77         uint32_t handle;
78         uint32_t flags;
79 };
80
81 /*
82  * A structure for releasing buffer for GPU access.
83  *
84  * @handle: a handle to gem object created.
85  */
86 struct drm_rockchip_gem_cpu_release {
87         uint32_t handle;
88 };
89
90 struct drm_rockchip_rga_get_ver {
91         __u32   major;
92         __u32   minor;
93 };
94
95 struct drm_rockchip_rga_cmd {
96         __u32   offset;
97         __u32   data;
98 };
99
100 enum drm_rockchip_rga_buf_type {
101         RGA_BUF_TYPE_USERPTR = 1 << 31,
102         RGA_BUF_TYPE_GEMFD   = 1 << 30,
103         RGA_BUF_TYPE_FLUSH   = 1 << 29,
104 };
105
106 struct drm_rockchip_rga_set_cmdlist {
107         __u64           cmd;
108         __u64           cmd_buf;
109         __u32           cmd_nr;
110         __u32           cmd_buf_nr;
111         __u64           user_data;
112 };
113
114 struct drm_rockchip_rga_exec {
115         __u64           async;
116 };
117
118 enum rockchip_plane_feture {
119         ROCKCHIP_DRM_PLANE_FEATURE_SCALE,
120         ROCKCHIP_DRM_PLANE_FEATURE_ALPHA,
121         ROCKCHIP_DRM_PLANE_FEATURE_MAX,
122 };
123
124 enum rockchip_crtc_feture {
125         ROCKCHIP_DRM_CRTC_FEATURE_AFBDC,
126 };
127
128 enum rockchip_cabc_mode {
129         ROCKCHIP_DRM_CABC_MODE_DISABLE,
130         ROCKCHIP_DRM_CABC_MODE_NORMAL,
131         ROCKCHIP_DRM_CABC_MODE_LOWPOWER,
132         ROCKCHIP_DRM_CABC_MODE_USERSPACE,
133 };
134
135 #define DRM_ROCKCHIP_GEM_CREATE         0x00
136 #define DRM_ROCKCHIP_GEM_MAP_OFFSET     0x01
137 #define DRM_ROCKCHIP_GEM_CPU_ACQUIRE    0x02
138 #define DRM_ROCKCHIP_GEM_CPU_RELEASE    0x03
139
140 #define DRM_ROCKCHIP_RGA_GET_VER        0x20
141 #define DRM_ROCKCHIP_RGA_SET_CMDLIST    0x21
142 #define DRM_ROCKCHIP_RGA_EXEC           0x22
143
144 #define DRM_IOCTL_ROCKCHIP_GEM_CREATE   DRM_IOWR(DRM_COMMAND_BASE + \
145                 DRM_ROCKCHIP_GEM_CREATE, struct drm_rockchip_gem_create)
146
147 #define DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET       DRM_IOWR(DRM_COMMAND_BASE + \
148                 DRM_ROCKCHIP_GEM_MAP_OFFSET, struct drm_rockchip_gem_map_off)
149
150 #define DRM_IOCTL_ROCKCHIP_GEM_CPU_ACQUIRE      DRM_IOWR(DRM_COMMAND_BASE + \
151                 DRM_ROCKCHIP_GEM_CPU_ACQUIRE, struct drm_rockchip_gem_cpu_acquire)
152
153 #define DRM_IOCTL_ROCKCHIP_GEM_CPU_RELEASE      DRM_IOWR(DRM_COMMAND_BASE + \
154                 DRM_ROCKCHIP_GEM_CPU_RELEASE, struct drm_rockchip_gem_cpu_release)
155
156 #define DRM_IOCTL_ROCKCHIP_RGA_GET_VER          DRM_IOWR(DRM_COMMAND_BASE + \
157                 DRM_ROCKCHIP_RGA_GET_VER, struct drm_rockchip_rga_get_ver)
158
159 #define DRM_IOCTL_ROCKCHIP_RGA_SET_CMDLIST      DRM_IOWR(DRM_COMMAND_BASE + \
160                 DRM_ROCKCHIP_RGA_SET_CMDLIST, struct drm_rockchip_rga_set_cmdlist)
161
162 #define DRM_IOCTL_ROCKCHIP_RGA_EXEC             DRM_IOWR(DRM_COMMAND_BASE + \
163                 DRM_ROCKCHIP_RGA_EXEC, struct drm_rockchip_rga_exec)
164
165 #endif /* _UAPI_ROCKCHIP_DRM_H */