Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 1 | /* |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 2 | * drivers/staging/android/uapi/ion.h |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 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 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 17 | #ifndef _UAPI_LINUX_ION_H |
| 18 | #define _UAPI_LINUX_ION_H |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 19 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 20 | #include <linux/ioctl.h> |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 21 | #include <linux/types.h> |
| 22 | |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 23 | /** |
| 24 | * enum ion_heap_types - list of all possible types of heaps |
| 25 | * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc |
| 26 | * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc |
| 27 | * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved |
Christopher Ferris | 3147524 | 2014-09-02 17:43:51 -0700 | [diff] [blame] | 28 | * carveout heap, allocations are physically |
| 29 | * contiguous |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 30 | * @ION_HEAP_TYPE_DMA: memory allocated via DMA API |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 31 | * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask |
Christopher Ferris | 3147524 | 2014-09-02 17:43:51 -0700 | [diff] [blame] | 32 | * is used to identify the heaps, so only 32 |
| 33 | * total heap types are supported |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 34 | */ |
| 35 | enum ion_heap_type { |
| 36 | ION_HEAP_TYPE_SYSTEM, |
| 37 | ION_HEAP_TYPE_SYSTEM_CONTIG, |
| 38 | ION_HEAP_TYPE_CARVEOUT, |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 39 | ION_HEAP_TYPE_CHUNK, |
| 40 | ION_HEAP_TYPE_DMA, |
Christopher Ferris | 12e1f28 | 2016-02-04 12:35:07 -0800 | [diff] [blame] | 41 | ION_HEAP_TYPE_CUSTOM, /* |
| 42 | * must be last so device specific heaps always |
| 43 | * are at the end of this enum |
| 44 | */ |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 45 | }; |
| 46 | |
Christopher Ferris | 3147524 | 2014-09-02 17:43:51 -0700 | [diff] [blame] | 47 | #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 48 | |
| 49 | /** |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 50 | * allocation flags - the lower 16 bits are used by core ion, the upper 16 |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 51 | * bits are reserved for use by the heaps themselves. |
| 52 | */ |
Christopher Ferris | 3318540 | 2017-01-13 13:28:52 -0800 | [diff] [blame] | 53 | |
| 54 | /* |
| 55 | * mappings of this buffer should be cached, ion will do cache maintenance |
| 56 | * when the buffer is mapped for dma |
| 57 | */ |
| 58 | #define ION_FLAG_CACHED 1 |
| 59 | |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 60 | /** |
| 61 | * DOC: Ion Userspace API |
| 62 | * |
| 63 | * create a client by opening /dev/ion |
| 64 | * most operations handled via following ioctls |
| 65 | * |
| 66 | */ |
| 67 | |
| 68 | /** |
| 69 | * struct ion_allocation_data - metadata passed from userspace for allocations |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 70 | * @len: size of the allocation |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 71 | * @heap_id_mask: mask of heap ids to allocate from |
| 72 | * @flags: flags passed to heap |
Christopher Ferris | 3147524 | 2014-09-02 17:43:51 -0700 | [diff] [blame] | 73 | * @handle: pointer that will be populated with a cookie to use to |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 74 | * refer to this allocation |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 75 | * |
| 76 | * Provided by userspace as an argument to the ioctl |
| 77 | */ |
| 78 | struct ion_allocation_data { |
Christopher Ferris | 0543f74 | 2017-07-26 13:09:46 -0700 | [diff] [blame] | 79 | __u64 len; |
| 80 | __u32 heap_id_mask; |
| 81 | __u32 flags; |
| 82 | __u32 fd; |
| 83 | __u32 unused; |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
Christopher Ferris | 3318540 | 2017-01-13 13:28:52 -0800 | [diff] [blame] | 86 | #define MAX_HEAP_NAME 32 |
| 87 | |
| 88 | /** |
| 89 | * struct ion_heap_data - data about a heap |
| 90 | * @name - first 32 characters of the heap name |
| 91 | * @type - heap type |
| 92 | * @heap_id - heap id for the heap |
| 93 | */ |
| 94 | struct ion_heap_data { |
| 95 | char name[MAX_HEAP_NAME]; |
| 96 | __u32 type; |
| 97 | __u32 heap_id; |
| 98 | __u32 reserved0; |
| 99 | __u32 reserved1; |
| 100 | __u32 reserved2; |
| 101 | }; |
| 102 | |
| 103 | /** |
| 104 | * struct ion_heap_query - collection of data about all heaps |
| 105 | * @cnt - total number of heaps to be copied |
| 106 | * @heaps - buffer to copy heap data |
| 107 | */ |
| 108 | struct ion_heap_query { |
| 109 | __u32 cnt; /* Total number of heaps to be copied */ |
| 110 | __u32 reserved0; /* align to 64bits */ |
| 111 | __u64 heaps; /* buffer to be populated */ |
| 112 | __u32 reserved1; |
| 113 | __u32 reserved2; |
| 114 | }; |
| 115 | |
Christopher Ferris | 6ea19f6 | 2013-11-20 19:48:48 -0800 | [diff] [blame] | 116 | #define ION_IOC_MAGIC 'I' |
| 117 | |
| 118 | /** |
| 119 | * DOC: ION_IOC_ALLOC - allocate memory |
| 120 | * |
| 121 | * Takes an ion_allocation_data struct and returns it with the handle field |
| 122 | * populated with the opaque handle for the allocation. |
| 123 | */ |
| 124 | #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ |
| 125 | struct ion_allocation_data) |
| 126 | |
| 127 | /** |
Christopher Ferris | 3318540 | 2017-01-13 13:28:52 -0800 | [diff] [blame] | 128 | * DOC: ION_IOC_HEAP_QUERY - information about available heaps |
| 129 | * |
| 130 | * Takes an ion_heap_query structure and populates information about |
| 131 | * available Ion heaps. |
| 132 | */ |
| 133 | #define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \ |
| 134 | struct ion_heap_query) |
| 135 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 136 | #endif /* _UAPI_LINUX_ION_H */ |