Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ion: move userspace api into uapi/ion.h

Split the userspace api out of drivers/staging/android/ion/ion.h
into drivers/staging/android/uapi/ion.h

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Colin Cross and committed by
Greg Kroah-Hartman
c3a2fe03 9e57e108

+198 -176
+1 -1
drivers/staging/android/ion/compat_ion.c
··· 21 21 #include "ion.h" 22 22 #include "compat_ion.h" 23 23 24 - /* See drivers/staging/android/ion/ion.h for the definition of these structs */ 24 + /* See drivers/staging/android/uapi/ion.h for the definition of these structs */ 25 25 struct compat_ion_allocation_data { 26 26 compat_size_t len; 27 27 compat_size_t align;
+1 -175
drivers/staging/android/ion/ion.h
··· 19 19 20 20 #include <linux/types.h> 21 21 22 - typedef int ion_user_handle_t; 22 + #include "../uapi/ion.h" 23 23 24 - /** 25 - * enum ion_heap_types - list of all possible types of heaps 26 - * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc 27 - * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc 28 - * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved 29 - * carveout heap, allocations are physically 30 - * contiguous 31 - * @ION_HEAP_TYPE_DMA: memory allocated via DMA API 32 - * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask 33 - * is used to identify the heaps, so only 32 34 - * total heap types are supported 35 - */ 36 - enum ion_heap_type { 37 - ION_HEAP_TYPE_SYSTEM, 38 - ION_HEAP_TYPE_SYSTEM_CONTIG, 39 - ION_HEAP_TYPE_CARVEOUT, 40 - ION_HEAP_TYPE_CHUNK, 41 - ION_HEAP_TYPE_DMA, 42 - ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always 43 - are at the end of this enum */ 44 - ION_NUM_HEAPS, 45 - }; 46 - 47 - #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM) 48 - #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG) 49 - #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) 50 - #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) 51 - 52 - #define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8 53 - 54 - /** 55 - * allocation flags - the lower 16 bits are used by core ion, the upper 16 56 - * bits are reserved for use by the heaps themselves. 57 - */ 58 - #define ION_FLAG_CACHED 1 /* mappings of this buffer should be 59 - cached, ion will do cache 60 - maintenance when the buffer is 61 - mapped for dma */ 62 - #define ION_FLAG_CACHED_NEEDS_SYNC 2 /* mappings of this buffer will created 63 - at mmap time, if this is set 64 - caches must be managed manually */ 65 - 66 - #ifdef __KERNEL__ 67 24 struct ion_handle; 68 25 struct ion_device; 69 26 struct ion_heap; ··· 200 243 * another exporter is passed in this function will return ERR_PTR(-EINVAL) 201 244 */ 202 245 struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd); 203 - 204 - #endif /* __KERNEL__ */ 205 - 206 - /** 207 - * DOC: Ion Userspace API 208 - * 209 - * create a client by opening /dev/ion 210 - * most operations handled via following ioctls 211 - * 212 - */ 213 - 214 - /** 215 - * struct ion_allocation_data - metadata passed from userspace for allocations 216 - * @len: size of the allocation 217 - * @align: required alignment of the allocation 218 - * @heap_id_mask: mask of heap ids to allocate from 219 - * @flags: flags passed to heap 220 - * @handle: pointer that will be populated with a cookie to use to 221 - * refer to this allocation 222 - * 223 - * Provided by userspace as an argument to the ioctl 224 - */ 225 - struct ion_allocation_data { 226 - size_t len; 227 - size_t align; 228 - unsigned int heap_id_mask; 229 - unsigned int flags; 230 - ion_user_handle_t handle; 231 - }; 232 - 233 - /** 234 - * struct ion_fd_data - metadata passed to/from userspace for a handle/fd pair 235 - * @handle: a handle 236 - * @fd: a file descriptor representing that handle 237 - * 238 - * For ION_IOC_SHARE or ION_IOC_MAP userspace populates the handle field with 239 - * the handle returned from ion alloc, and the kernel returns the file 240 - * descriptor to share or map in the fd field. For ION_IOC_IMPORT, userspace 241 - * provides the file descriptor and the kernel returns the handle. 242 - */ 243 - struct ion_fd_data { 244 - ion_user_handle_t handle; 245 - int fd; 246 - }; 247 - 248 - /** 249 - * struct ion_handle_data - a handle passed to/from the kernel 250 - * @handle: a handle 251 - */ 252 - struct ion_handle_data { 253 - ion_user_handle_t handle; 254 - }; 255 - 256 - /** 257 - * struct ion_custom_data - metadata passed to/from userspace for a custom ioctl 258 - * @cmd: the custom ioctl function to call 259 - * @arg: additional data to pass to the custom ioctl, typically a user 260 - * pointer to a predefined structure 261 - * 262 - * This works just like the regular cmd and arg fields of an ioctl. 263 - */ 264 - struct ion_custom_data { 265 - unsigned int cmd; 266 - unsigned long arg; 267 - }; 268 - 269 - #define ION_IOC_MAGIC 'I' 270 - 271 - /** 272 - * DOC: ION_IOC_ALLOC - allocate memory 273 - * 274 - * Takes an ion_allocation_data struct and returns it with the handle field 275 - * populated with the opaque handle for the allocation. 276 - */ 277 - #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ 278 - struct ion_allocation_data) 279 - 280 - /** 281 - * DOC: ION_IOC_FREE - free memory 282 - * 283 - * Takes an ion_handle_data struct and frees the handle. 284 - */ 285 - #define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data) 286 - 287 - /** 288 - * DOC: ION_IOC_MAP - get a file descriptor to mmap 289 - * 290 - * Takes an ion_fd_data struct with the handle field populated with a valid 291 - * opaque handle. Returns the struct with the fd field set to a file 292 - * descriptor open in the current address space. This file descriptor 293 - * can then be used as an argument to mmap. 294 - */ 295 - #define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data) 296 - 297 - /** 298 - * DOC: ION_IOC_SHARE - creates a file descriptor to use to share an allocation 299 - * 300 - * Takes an ion_fd_data struct with the handle field populated with a valid 301 - * opaque handle. Returns the struct with the fd field set to a file 302 - * descriptor open in the current address space. This file descriptor 303 - * can then be passed to another process. The corresponding opaque handle can 304 - * be retrieved via ION_IOC_IMPORT. 305 - */ 306 - #define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data) 307 - 308 - /** 309 - * DOC: ION_IOC_IMPORT - imports a shared file descriptor 310 - * 311 - * Takes an ion_fd_data struct with the fd field populated with a valid file 312 - * descriptor obtained from ION_IOC_SHARE and returns the struct with the handle 313 - * filed set to the corresponding opaque handle. 314 - */ 315 - #define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data) 316 - 317 - /** 318 - * DOC: ION_IOC_SYNC - syncs a shared file descriptors to memory 319 - * 320 - * Deprecated in favor of using the dma_buf api's correctly (syncing 321 - * will happend automatically when the buffer is mapped to a device). 322 - * If necessary should be used after touching a cached buffer from the cpu, 323 - * this will make the buffer in memory coherent. 324 - */ 325 - #define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data) 326 - 327 - /** 328 - * DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl 329 - * 330 - * Takes the argument of the architecture specific ioctl to call and 331 - * passes appropriate userdata for that ioctl 332 - */ 333 - #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data) 334 246 335 247 #endif /* _LINUX_ION_H */
+196
drivers/staging/android/uapi/ion.h
··· 1 + /* 2 + * drivers/staging/android/uapi/ion.h 3 + * 4 + * Copyright (C) 2011 Google, Inc. 5 + * 6 + * This software is licensed under the terms of the GNU General Public 7 + * License version 2, as published by the Free Software Foundation, and 8 + * may be copied, distributed, and modified under those terms. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + */ 16 + 17 + #ifndef _UAPI_LINUX_ION_H 18 + #define _UAPI_LINUX_ION_H 19 + 20 + #include <linux/ioctl.h> 21 + #include <linux/types.h> 22 + 23 + typedef int ion_user_handle_t; 24 + 25 + /** 26 + * enum ion_heap_types - list of all possible types of heaps 27 + * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc 28 + * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc 29 + * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved 30 + * carveout heap, allocations are physically 31 + * contiguous 32 + * @ION_HEAP_TYPE_DMA: memory allocated via DMA API 33 + * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask 34 + * is used to identify the heaps, so only 32 35 + * total heap types are supported 36 + */ 37 + enum ion_heap_type { 38 + ION_HEAP_TYPE_SYSTEM, 39 + ION_HEAP_TYPE_SYSTEM_CONTIG, 40 + ION_HEAP_TYPE_CARVEOUT, 41 + ION_HEAP_TYPE_CHUNK, 42 + ION_HEAP_TYPE_DMA, 43 + ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always 44 + are at the end of this enum */ 45 + ION_NUM_HEAPS = 16, 46 + }; 47 + 48 + #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM) 49 + #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG) 50 + #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) 51 + #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) 52 + 53 + #define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8 54 + 55 + /** 56 + * allocation flags - the lower 16 bits are used by core ion, the upper 16 57 + * bits are reserved for use by the heaps themselves. 58 + */ 59 + #define ION_FLAG_CACHED 1 /* mappings of this buffer should be 60 + cached, ion will do cache 61 + maintenance when the buffer is 62 + mapped for dma */ 63 + #define ION_FLAG_CACHED_NEEDS_SYNC 2 /* mappings of this buffer will created 64 + at mmap time, if this is set 65 + caches must be managed manually */ 66 + 67 + /** 68 + * DOC: Ion Userspace API 69 + * 70 + * create a client by opening /dev/ion 71 + * most operations handled via following ioctls 72 + * 73 + */ 74 + 75 + /** 76 + * struct ion_allocation_data - metadata passed from userspace for allocations 77 + * @len: size of the allocation 78 + * @align: required alignment of the allocation 79 + * @heap_id_mask: mask of heap ids to allocate from 80 + * @flags: flags passed to heap 81 + * @handle: pointer that will be populated with a cookie to use to 82 + * refer to this allocation 83 + * 84 + * Provided by userspace as an argument to the ioctl 85 + */ 86 + struct ion_allocation_data { 87 + size_t len; 88 + size_t align; 89 + unsigned int heap_id_mask; 90 + unsigned int flags; 91 + ion_user_handle_t handle; 92 + }; 93 + 94 + /** 95 + * struct ion_fd_data - metadata passed to/from userspace for a handle/fd pair 96 + * @handle: a handle 97 + * @fd: a file descriptor representing that handle 98 + * 99 + * For ION_IOC_SHARE or ION_IOC_MAP userspace populates the handle field with 100 + * the handle returned from ion alloc, and the kernel returns the file 101 + * descriptor to share or map in the fd field. For ION_IOC_IMPORT, userspace 102 + * provides the file descriptor and the kernel returns the handle. 103 + */ 104 + struct ion_fd_data { 105 + ion_user_handle_t handle; 106 + int fd; 107 + }; 108 + 109 + /** 110 + * struct ion_handle_data - a handle passed to/from the kernel 111 + * @handle: a handle 112 + */ 113 + struct ion_handle_data { 114 + ion_user_handle_t handle; 115 + }; 116 + 117 + /** 118 + * struct ion_custom_data - metadata passed to/from userspace for a custom ioctl 119 + * @cmd: the custom ioctl function to call 120 + * @arg: additional data to pass to the custom ioctl, typically a user 121 + * pointer to a predefined structure 122 + * 123 + * This works just like the regular cmd and arg fields of an ioctl. 124 + */ 125 + struct ion_custom_data { 126 + unsigned int cmd; 127 + unsigned long arg; 128 + }; 129 + 130 + #define ION_IOC_MAGIC 'I' 131 + 132 + /** 133 + * DOC: ION_IOC_ALLOC - allocate memory 134 + * 135 + * Takes an ion_allocation_data struct and returns it with the handle field 136 + * populated with the opaque handle for the allocation. 137 + */ 138 + #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ 139 + struct ion_allocation_data) 140 + 141 + /** 142 + * DOC: ION_IOC_FREE - free memory 143 + * 144 + * Takes an ion_handle_data struct and frees the handle. 145 + */ 146 + #define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data) 147 + 148 + /** 149 + * DOC: ION_IOC_MAP - get a file descriptor to mmap 150 + * 151 + * Takes an ion_fd_data struct with the handle field populated with a valid 152 + * opaque handle. Returns the struct with the fd field set to a file 153 + * descriptor open in the current address space. This file descriptor 154 + * can then be used as an argument to mmap. 155 + */ 156 + #define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data) 157 + 158 + /** 159 + * DOC: ION_IOC_SHARE - creates a file descriptor to use to share an allocation 160 + * 161 + * Takes an ion_fd_data struct with the handle field populated with a valid 162 + * opaque handle. Returns the struct with the fd field set to a file 163 + * descriptor open in the current address space. This file descriptor 164 + * can then be passed to another process. The corresponding opaque handle can 165 + * be retrieved via ION_IOC_IMPORT. 166 + */ 167 + #define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data) 168 + 169 + /** 170 + * DOC: ION_IOC_IMPORT - imports a shared file descriptor 171 + * 172 + * Takes an ion_fd_data struct with the fd field populated with a valid file 173 + * descriptor obtained from ION_IOC_SHARE and returns the struct with the handle 174 + * filed set to the corresponding opaque handle. 175 + */ 176 + #define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data) 177 + 178 + /** 179 + * DOC: ION_IOC_SYNC - syncs a shared file descriptors to memory 180 + * 181 + * Deprecated in favor of using the dma_buf api's correctly (syncing 182 + * will happend automatically when the buffer is mapped to a device). 183 + * If necessary should be used after touching a cached buffer from the cpu, 184 + * this will make the buffer in memory coherent. 185 + */ 186 + #define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data) 187 + 188 + /** 189 + * DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl 190 + * 191 + * Takes the argument of the architecture specific ioctl to call and 192 + * passes appropriate userdata for that ioctl 193 + */ 194 + #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data) 195 + 196 + #endif /* _UAPI_LINUX_ION_H */