tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / ump / include / ump_uk_types.h
1 /*
2  * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
3  *
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  *
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 /**
12  * @file ump_uk_types.h
13  * Defines the types and constants used in the user-kernel interface
14  */
15
16 #ifndef __UMP_UK_TYPES_H__
17 #define __UMP_UK_TYPES_H__
18
19 #ifdef __cplusplus
20 extern "C"
21 {
22 #endif
23
24 /* Helpers for API version handling */
25 #define MAKE_VERSION_ID(x) (((x) << 16UL) | (x))
26 #define IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF))
27 #define GET_VERSION(x) (((x) >> 16UL) & 0xFFFF)
28 #define IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y))))
29
30 /**
31  * API version define.
32  * Indicates the version of the kernel API
33  * The version is a 16bit integer incremented on each API change.
34  * The 16bit integer is stored twice in a 32bit integer
35  * So for version 1 the value would be 0x00010001
36  */
37 #define UMP_IOCTL_API_VERSION MAKE_VERSION_ID(2)
38
39 typedef enum
40 {
41         _UMP_IOC_QUERY_API_VERSION = 1,
42         _UMP_IOC_ALLOCATE,
43         _UMP_IOC_RELEASE,
44         _UMP_IOC_SIZE_GET,
45         _UMP_IOC_MAP_MEM,    /* not used in Linux */
46         _UMP_IOC_UNMAP_MEM,  /* not used in Linux */
47         _UMP_IOC_MSYNC,
48 /* MALI_SEC */
49 #ifdef CONFIG_DMA_SHARED_BUFFER
50         _UMP_IOC_DMABUF_IMPORT,
51 #endif
52         _UMP_IOC_CACHE_OPERATIONS_CONTROL,
53         _UMP_IOC_SWITCH_HW_USAGE,
54         _UMP_IOC_LOCK,
55         _UMP_IOC_UNLOCK,
56         _UMP_IOC_ION_IMPORT,
57 }_ump_uk_functions;
58
59 typedef enum
60 {
61         UMP_REF_DRV_UK_CONSTRAINT_NONE = 0,
62         UMP_REF_DRV_UK_CONSTRAINT_PHYSICALLY_LINEAR = 1,
63         UMP_REF_DRV_UK_CONSTRAINT_USE_CACHE = 128,
64 } ump_uk_alloc_constraints;
65
66 typedef enum
67 {
68         _UMP_UK_MSYNC_CLEAN = 0,
69         _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE = 1,
70         _UMP_UK_MSYNC_INVALIDATE = 2,
71         _UMP_UK_MSYNC_FLUSH_L1   = 3,
72         _UMP_UK_MSYNC_READOUT_CACHE_ENABLED = 128,
73 } ump_uk_msync_op;
74
75 typedef enum
76 {
77         _UMP_UK_CACHE_OP_START = 0,
78         _UMP_UK_CACHE_OP_FINISH  = 1,
79 } ump_uk_cache_op_control;
80
81 typedef enum
82 {
83         _UMP_UK_READ = 1,
84         _UMP_UK_READ_WRITE = 3,
85 } ump_uk_lock_usage;
86
87 typedef enum
88 {
89         _UMP_UK_USED_BY_CPU = 0,
90         _UMP_UK_USED_BY_MALI = 1,
91         _UMP_UK_USED_BY_UNKNOWN_DEVICE= 100,
92 } ump_uk_user;
93
94 /**
95  * Get API version ([in,out] u32 api_version, [out] u32 compatible)
96  */
97 typedef struct _ump_uk_api_version_s
98 {
99         void *ctx;      /**< [in,out] user-kernel context (trashed on output) */
100         u32 version;    /**< Set to the user space version on entry, stores the device driver version on exit */
101         u32 compatible; /**< Non-null if the device is compatible with the client */
102 } _ump_uk_api_version_s;
103
104 /**
105  * ALLOCATE ([out] u32 secure_id, [in,out] u32 size,  [in] contraints)
106  */
107 typedef struct _ump_uk_allocate_s
108 {
109         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
110         u32 secure_id;                          /**< Return value from DD to Userdriver */
111         u32 size;                               /**< Input and output. Requested size; input. Returned size; output */
112         ump_uk_alloc_constraints constraints;   /**< Only input to Devicedriver */
113 } _ump_uk_allocate_s;
114
115 typedef struct _ump_uk_ion_import_s
116 {
117         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
118         int ion_fd;                             /**< ion_fd */
119         u32 secure_id;                          /**< Return value from DD to Userdriver */
120         u32 size;                               /**< Input and output. Requested size; input. Returned size; output */
121         ump_uk_alloc_constraints constraints;   /**< Only input to Devicedriver */
122 } _ump_uk_ion_import_s;
123
124 /* MALI_SEC */
125 #ifdef CONFIG_DMA_SHARED_BUFFER
126 struct ump_uk_dmabuf {
127         void* ctx;
128         int fd;
129         size_t size;
130         uint32_t secure_id;
131 };
132 #endif
133
134 /**
135  * SIZE_GET ([in] u32 secure_id, [out]size )
136  */
137 typedef struct _ump_uk_size_get_s
138 {
139         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
140         u32 secure_id;                          /**< Input to DD */
141         u32 size;                               /**< Returned size; output */
142 } _ump_uk_size_get_s;
143
144 /**
145  * Release ([in] u32 secure_id)
146  */
147 typedef struct _ump_uk_release_s
148 {
149         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
150         u32 secure_id;                          /**< Input to DD */
151 } _ump_uk_release_s;
152
153 typedef struct _ump_uk_map_mem_s
154 {
155         void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
156         void *mapping;                  /**< [out] Returns user-space virtual address for the mapping */
157         void *phys_addr;                /**< [in] physical address */
158         unsigned long size;             /**< [in] size */
159         u32 secure_id;                  /**< [in] secure_id to assign to mapping */
160         void * _ukk_private;            /**< Only used inside linux port between kernel frontend and common part to store vma */
161         u32 cookie;
162         u32 is_cached;            /**< [in,out] caching of CPU mappings */
163 } _ump_uk_map_mem_s;
164
165 typedef struct _ump_uk_unmap_mem_s
166 {
167         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
168         void *mapping;
169         u32 size;
170         void * _ukk_private;
171         u32 cookie;
172 } _ump_uk_unmap_mem_s;
173
174 typedef struct _ump_uk_msync_s
175 {
176         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
177         void *mapping;        /**< [in] mapping addr */
178         void *address;        /**< [in] flush start addr */
179         u32 size;             /**< [in] size to flush */
180         ump_uk_msync_op op;   /**< [in] flush operation */
181         u32 cookie;           /**< [in] cookie stored with reference to the kernel mapping internals */
182         u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
183         u32 is_cached;        /**< [out] caching of CPU mappings */
184 } _ump_uk_msync_s;
185
186 typedef struct _ump_uk_cache_operations_control_s
187 {
188         void *ctx;                   /**< [in,out] user-kernel context (trashed on output) */
189         ump_uk_cache_op_control op;  /**< [in] cache operations start/stop */
190 } _ump_uk_cache_operations_control_s;
191
192
193 typedef struct _ump_uk_switch_hw_usage_s
194 {
195         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
196         u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
197         ump_uk_user new_user;         /**< [in] cookie stored with reference to the kernel mapping internals */
198
199 } _ump_uk_switch_hw_usage_s;
200
201 typedef struct _ump_uk_lock_s
202 {
203         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
204         u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
205         ump_uk_lock_usage lock_usage;
206 } _ump_uk_lock_s;
207
208 typedef struct _ump_uk_unlock_s
209 {
210         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
211         u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
212 } _ump_uk_unlock_s;
213
214 #ifdef __cplusplus
215 }
216 #endif
217
218 #endif /* __UMP_UK_TYPES_H__ */