| Laura Abbott | 89b8de2 | 2017-06-30 11:08:19 +0530 | [diff] [blame] | 1 | /* | 
|  | 2 | * Adapted from 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_NEW_H | 
|  | 18 | #define _UAPI_LINUX_ION_NEW_H | 
|  | 19 |  | 
|  | 20 | #include <linux/ioctl.h> | 
|  | 21 | #include <linux/types.h> | 
|  | 22 |  | 
|  | 23 | #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) | 
|  | 24 |  | 
|  | 25 | /** | 
|  | 26 | * DOC: Ion Userspace API | 
|  | 27 | * | 
|  | 28 | * create a client by opening /dev/ion | 
|  | 29 | * most operations handled via following ioctls | 
|  | 30 | * | 
|  | 31 | */ | 
|  | 32 |  | 
|  | 33 | /** | 
|  | 34 | * struct ion_new_allocation_data - metadata passed from userspace for allocations | 
|  | 35 | * @len:		size of the allocation | 
|  | 36 | * @heap_id_mask:	mask of heap ids to allocate from | 
|  | 37 | * @flags:		flags passed to heap | 
|  | 38 | * @handle:		pointer that will be populated with a cookie to use to | 
|  | 39 | *			refer to this allocation | 
|  | 40 | * | 
|  | 41 | * Provided by userspace as an argument to the ioctl - added _new to denote | 
|  | 42 | * this belongs to the new ION interface. | 
|  | 43 | */ | 
|  | 44 | struct ion_new_allocation_data { | 
|  | 45 | __u64 len; | 
|  | 46 | __u32 heap_id_mask; | 
|  | 47 | __u32 flags; | 
|  | 48 | __u32 fd; | 
|  | 49 | __u32 unused; | 
|  | 50 | }; | 
|  | 51 |  | 
|  | 52 | #define MAX_HEAP_NAME 32 | 
|  | 53 |  | 
|  | 54 | /** | 
|  | 55 | * struct ion_heap_data - data about a heap | 
|  | 56 | * @name - first 32 characters of the heap name | 
|  | 57 | * @type - heap type | 
|  | 58 | * @heap_id - heap id for the heap | 
|  | 59 | */ | 
|  | 60 | struct ion_heap_data { | 
|  | 61 | char name[MAX_HEAP_NAME]; | 
|  | 62 | __u32 type; | 
|  | 63 | __u32 heap_id; | 
|  | 64 | __u32 reserved0; | 
|  | 65 | __u32 reserved1; | 
|  | 66 | __u32 reserved2; | 
|  | 67 | }; | 
|  | 68 |  | 
|  | 69 | /** | 
|  | 70 | * struct ion_heap_query - collection of data about all heaps | 
|  | 71 | * @cnt - total number of heaps to be copied | 
|  | 72 | * @heaps - buffer to copy heap data | 
|  | 73 | */ | 
|  | 74 | struct ion_heap_query { | 
|  | 75 | __u32 cnt;       /* Total number of heaps to be copied */ | 
|  | 76 | __u32 reserved0; /* align to 64bits */ | 
|  | 77 | __u64 heaps;     /* buffer to be populated */ | 
|  | 78 | __u32 reserved1; | 
|  | 79 | __u32 reserved2; | 
|  | 80 | }; | 
|  | 81 |  | 
|  | 82 | #define ION_IOC_MAGIC 'I' | 
|  | 83 |  | 
|  | 84 | /** | 
|  | 85 | * DOC: ION_IOC_NEW_ALLOC - allocate memory | 
|  | 86 | * | 
|  | 87 | * Takes an ion_allocation_data struct and returns it with the handle field | 
|  | 88 | * populated with the opaque handle for the allocation. | 
|  | 89 | * TODO: This IOCTL will clash by design; however, only one of | 
|  | 90 | *  ION_IOC_ALLOC or ION_IOC_NEW_ALLOC paths will be exercised, | 
|  | 91 | *  so this should not conflict. | 
|  | 92 | */ | 
|  | 93 | #define ION_IOC_NEW_ALLOC _IOWR(ION_IOC_MAGIC, 0, struct ion_new_allocation_data) | 
|  | 94 |  | 
|  | 95 | /** | 
|  | 96 | * DOC: ION_IOC_FREE - free memory | 
|  | 97 | * | 
|  | 98 | * Takes an ion_handle_data struct and frees the handle. | 
|  | 99 | * | 
|  | 100 | * #define ION_IOC_FREE		_IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data) | 
|  | 101 | * This will come from the older kernels, so don't redefine here | 
|  | 102 | */ | 
|  | 103 |  | 
|  | 104 | /** | 
|  | 105 | * DOC: ION_IOC_SHARE - creates a file descriptor to use to share an allocation | 
|  | 106 | * | 
|  | 107 | * Takes an ion_fd_data struct with the handle field populated with a valid | 
|  | 108 | * opaque handle.  Returns the struct with the fd field set to a file | 
|  | 109 | * descriptor open in the current address space.  This file descriptor | 
|  | 110 | * can then be passed to another process.  The corresponding opaque handle can | 
|  | 111 | * be retrieved via ION_IOC_IMPORT. | 
|  | 112 | * | 
|  | 113 | * #define ION_IOC_SHARE		_IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data) | 
|  | 114 | * This will come from the older kernels, so don't redefine here | 
|  | 115 | */ | 
|  | 116 |  | 
|  | 117 | /** | 
|  | 118 | * DOC: ION_IOC_HEAP_QUERY - information about available heaps | 
|  | 119 | * | 
|  | 120 | * Takes an ion_heap_query structure and populates information about | 
|  | 121 | * available Ion heaps. | 
|  | 122 | */ | 
|  | 123 | #define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, struct ion_heap_query) | 
|  | 124 |  | 
|  | 125 | #endif /* _UAPI_LINUX_ION_NEW_H */ |