RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / img_types.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Global types for use by IMG APIs
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Defines type aliases for use by IMG APIs.
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43
44 #ifndef __IMG_TYPES_H__
45 #define __IMG_TYPES_H__
46 #if defined (__cplusplus)
47 extern "C" {
48 #endif
49
50 /* To use C99 types and definitions, there are two special cases we need to
51  * cater for:
52  *
53  * - Visual Studio: in VS2010 or later, some standard headers are available,
54  *   and MSVC has its own built-in sized types. We can define the C99 types
55  *   in terms of these.
56  *
57  * - Linux kernel code: C99 sized types are defined in <linux/types.h>, but
58  *   some other features (like macros for constants or printf format
59  *   strings) are missing, so we need to fill in the gaps ourselves.
60  *
61  * For other cases (userspace code under Linux, Android or Neutrino, or
62  * firmware code), we can include the standard headers.
63  */
64 #if defined(_MSC_VER)
65         #include "msvc_types.h"
66 #elif defined(LINUX) && defined(__KERNEL__)
67         #include <linux/types.h>
68         #include "kernel_types.h"
69 #elif defined(LINUX) || defined(__METAG) || defined(__QNXNTO__) || defined(INTEGRITY_OS)
70         #include <stddef.h>                     /* NULL */
71         #include <inttypes.h>           /* intX_t/uintX_t, format specifiers */
72         #include <limits.h>                     /* INT_MIN, etc */
73 #elif defined(__mips)
74         #include <stddef.h>                     /* NULL */
75         #include <inttypes.h>           /* intX_t/uintX_t, format specifiers */
76 #else
77         #error C99 support not set up for this build
78 #endif
79
80 typedef unsigned int    IMG_UINT,       *IMG_PUINT;
81 typedef int                             IMG_INT,        *IMG_PINT;
82
83 typedef uint8_t                 IMG_UINT8,      *IMG_PUINT8;
84 typedef uint8_t                 IMG_BYTE,       *IMG_PBYTE;
85 typedef int8_t                  IMG_INT8,       *IMG_PINT8;
86 typedef char                    IMG_CHAR,       *IMG_PCHAR;
87
88 typedef uint16_t                IMG_UINT16,     *IMG_PUINT16;
89 typedef int16_t                 IMG_INT16,      *IMG_PINT16;
90 typedef uint32_t                IMG_UINT32,     *IMG_PUINT32;
91 typedef int32_t                 IMG_INT32,      *IMG_PINT32;
92
93 typedef uint64_t                IMG_UINT64,     *IMG_PUINT64;
94 typedef int64_t                 IMG_INT64,      *IMG_PINT64;
95 #define IMG_INT64_C(c)  INT64_C(c)
96 #define IMG_UINT64_C(c) UINT64_C(c)
97 #define IMG_UINT64_FMTSPEC PRIu64
98 #define IMG_UINT64_FMTSPECX PRIX64
99 #define IMG_UINT64_FMTSPECx PRIx64
100 #define IMG_UINT64_FMTSPECo PRIo64
101 #define IMG_INT64_FMTSPECd PRId64
102
103 #define IMG_UINT16_MAX  UINT16_MAX
104 #define IMG_UINT32_MAX  UINT32_MAX
105 #define IMG_UINT64_MAX  UINT64_MAX
106
107 #define IMG_INT16_MAX   INT16_MAX
108 #define IMG_INT32_MAX   INT32_MAX
109 #define IMG_INT64_MAX   INT64_MAX
110
111 /* Linux kernel mode does not use floating point */
112 typedef float                   IMG_FLOAT,      *IMG_PFLOAT;
113 typedef double                  IMG_DOUBLE, *IMG_PDOUBLE;
114
115 typedef union _IMG_UINT32_FLOAT_
116 {
117         IMG_UINT32 ui32;
118         IMG_FLOAT f;
119 } IMG_UINT32_FLOAT;
120
121 typedef int                             IMG_SECURE_TYPE;
122
123 typedef enum tag_img_bool
124 {
125         IMG_FALSE               = 0,
126         IMG_TRUE                = 1,
127         IMG_FORCE_ALIGN = 0x7FFFFFFF
128 } IMG_BOOL, *IMG_PBOOL;
129
130 #if defined(UNDER_WDDM) || defined(WINDOWS_WDF)
131 typedef void            IMG_VOID, *IMG_PVOID;
132
133 typedef uintptr_t               IMG_UINTPTR_T;
134 typedef size_t                  IMG_SIZE_T;
135
136 #define IMG_SIZE_T_MAX  SIZE_MAX
137 #define IMG_NULL                NULL
138
139 typedef IMG_CHAR const* IMG_PCCHAR;
140 #endif
141
142 #if defined(_MSC_VER)
143 #define IMG_SIZE_FMTSPEC  "%Iu"
144 #define IMG_SIZE_FMTSPECX "%Ix"
145 #else
146 #define IMG_SIZE_FMTSPEC  "%zu"
147 #define IMG_SIZE_FMTSPECX "%zx"
148 #endif
149
150 #if defined(LINUX) && defined(__KERNEL__)
151 /* prints the function name when used with printk */
152 #define IMG_PFN_FMTSPEC "%pf"
153 #else
154 #define IMG_PFN_FMTSPEC "%p"
155 #endif
156
157 typedef void           *IMG_HANDLE;
158
159 /* services/stream ID */
160 typedef IMG_UINT64      IMG_SID;
161
162 /* Process IDs */
163 typedef IMG_UINT32      IMG_PID;
164
165 /* OS connection type */
166 typedef int             IMG_OS_CONNECTION;
167
168
169 /*
170  * Address types.
171  * All types used to refer to a block of memory are wrapped in structures
172  * to enforce some degree of type safety, i.e. a IMG_DEV_VIRTADDR cannot
173  * be assigned to a variable of type IMG_DEV_PHYADDR because they are not the
174  * same thing.
175  *
176  * There is an assumption that the system contains at most one non-cpu mmu,
177  * and a memory block is only mapped by the MMU once.
178  *
179  * Different devices could have offset views of the physical address space.
180  * 
181  */
182
183
184 /*
185  *
186  * +------------+    +------------+      +------------+        +------------+
187  * |    CPU     |    |    DEV     |      |    DEV     |        |    DEV     |
188  * +------------+    +------------+      +------------+        +------------+
189  *       |                 |                   |                     |
190  *       | void *          |IMG_DEV_VIRTADDR   |IMG_DEV_VIRTADDR     |
191  *       |                 \-------------------/                     |
192  *       |                          |                                |
193  * +------------+             +------------+                         |
194  * |    MMU     |             |    MMU     |                         |
195  * +------------+             +------------+                         |
196  *       |                          |                                |
197  *       |                          |                                |
198  *       |                          |                                |
199  *   +--------+                +---------+                      +--------+
200  *   | Offset |                | (Offset)|                      | Offset |
201  *   +--------+                +---------+                      +--------+
202  *       |                          |                IMG_DEV_PHYADDR |
203  *       |                          |                                |
204  *       |                          | IMG_DEV_PHYADDR                |
205  * +---------------------------------------------------------------------+
206  * |                         System Address bus                          |
207  * +---------------------------------------------------------------------+
208  *
209  */
210
211 #define IMG_DEV_VIRTADDR_FMTSPEC "0x%010" IMG_UINT64_FMTSPECX
212 #define IMG_DEVMEM_SIZE_FMTSPEC "0x%010" IMG_UINT64_FMTSPECX
213 #define IMG_DEVMEM_ALIGN_FMTSPEC "0x%010" IMG_UINT64_FMTSPECX
214 #define IMG_DEVMEM_OFFSET_FMTSPEC "0x%010" IMG_UINT64_FMTSPECX
215
216 /* cpu physical address */
217 typedef struct _IMG_CPU_PHYADDR
218 {
219 #if defined(UNDER_WDDM) || defined(WINDOWS_WDF)
220         uintptr_t uiAddr;
221 #define IMG_CAST_TO_CPUPHYADDR_UINT(var)                (uintptr_t)(var)
222 #elif defined(LINUX) && defined(__KERNEL__)
223         phys_addr_t uiAddr;
224 #define IMG_CAST_TO_CPUPHYADDR_UINT(var)                (phys_addr_t)(var)
225 #else
226         IMG_UINT64 uiAddr;
227 #define IMG_CAST_TO_CPUPHYADDR_UINT(var)                (IMG_UINT64)(var)
228 #endif
229 } IMG_CPU_PHYADDR;
230
231 /* device physical address */
232 typedef struct _IMG_DEV_PHYADDR
233 {
234         IMG_UINT64 uiAddr;
235 } IMG_DEV_PHYADDR;
236
237 /* system physical address */
238 typedef struct _IMG_SYS_PHYADDR
239 {
240 #if defined(UNDER_WDDM) || defined(WINDOWS_WDF)
241         uintptr_t uiAddr;
242 #else
243         IMG_UINT64 uiAddr;
244 #endif
245 } IMG_SYS_PHYADDR;
246
247 /* 32-bit device virtual address (e.g. MSVDX) */
248 typedef struct _IMG_DEV_VIRTADDR32
249 {
250         IMG_UINT32 uiAddr;
251 #define IMG_CAST_TO_DEVVADDR_UINT32(var) (IMG_UINT32)(var)
252 } IMG_DEV_VIRTADDR32;
253
254 /*
255         rectangle structure
256 */
257 typedef struct _IMG_RECT_
258 {
259         IMG_INT32       x0;
260         IMG_INT32       y0;
261         IMG_INT32       x1;
262         IMG_INT32       y1;
263 }IMG_RECT, *PIMG_RECT;
264
265 typedef struct _IMG_RECT_16_
266 {
267         IMG_INT16       x0;
268         IMG_INT16       y0;
269         IMG_INT16       x1;
270         IMG_INT16       y1;
271 }IMG_RECT_16, *PIMG_RECT_16;
272
273 typedef struct _IMG_RECT_32_
274 {
275         IMG_FLOAT       x0;
276         IMG_FLOAT       y0;
277         IMG_FLOAT       x1;
278         IMG_FLOAT       y1;
279 } IMG_RECT_F32, *PIMG_RECT_F32;
280
281 /*
282  * box structure
283  */
284 typedef struct _IMG_BOX_
285 {
286         IMG_INT32       x0;
287         IMG_INT32       y0;
288         IMG_INT32       z0;
289         IMG_INT32       x1;
290         IMG_INT32       y1;
291         IMG_INT32       z1;
292 } IMG_BOX, *PIMG_BOX;
293
294 #if defined (__cplusplus)
295 }
296 #endif
297
298 #include "img_defs.h"
299
300 #endif  /* __IMG_TYPES_H__ */
301 /******************************************************************************
302  End of file (img_types.h)
303 ******************************************************************************/
304