Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/linux/ion.h |
| 3 | * |
| 4 | * Copyright (C) 2011 Google, Inc. |
Olav Haugan | 0a85251 | 2012-01-09 10:20:55 -0800 | [diff] [blame] | 5 | * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 6 | * |
| 7 | * This software is licensed under the terms of the GNU General Public |
| 8 | * License version 2, as published by the Free Software Foundation, and |
| 9 | * may be copied, distributed, and modified under those terms. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #ifndef _LINUX_ION_H |
| 19 | #define _LINUX_ION_H |
| 20 | |
Laura Abbott | abcb6f7 | 2011-10-04 16:26:49 -0700 | [diff] [blame] | 21 | #include <linux/ioctl.h> |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 22 | #include <linux/types.h> |
| 23 | |
Laura Abbott | abcb6f7 | 2011-10-04 16:26:49 -0700 | [diff] [blame] | 24 | |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 25 | struct ion_handle; |
| 26 | /** |
| 27 | * enum ion_heap_types - list of all possible types of heaps |
Iliyan Malchev | f2230156 | 2011-07-06 16:53:21 -0700 | [diff] [blame] | 28 | * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc |
| 29 | * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc |
| 30 | * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 31 | * carveout heap, allocations are physically |
| 32 | * contiguous |
Olav Haugan | 0a85251 | 2012-01-09 10:20:55 -0800 | [diff] [blame] | 33 | * @ION_HEAP_TYPE_IOMMU: IOMMU memory |
| 34 | * @ION_HEAP_TYPE_CP: memory allocated from a prereserved |
| 35 | * carveout heap, allocations are physically |
| 36 | * contiguous. Used for content protection. |
| 37 | * @ION_HEAP_END: helper for iterating over heaps |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 38 | */ |
| 39 | enum ion_heap_type { |
| 40 | ION_HEAP_TYPE_SYSTEM, |
| 41 | ION_HEAP_TYPE_SYSTEM_CONTIG, |
| 42 | ION_HEAP_TYPE_CARVEOUT, |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 43 | ION_HEAP_TYPE_IOMMU, |
Olav Haugan | 0a85251 | 2012-01-09 10:20:55 -0800 | [diff] [blame] | 44 | ION_HEAP_TYPE_CP, |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 45 | ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always |
| 46 | are at the end of this enum */ |
Rebecca Schultz Zavin | e6ee124 | 2011-06-30 12:19:55 -0700 | [diff] [blame] | 47 | ION_NUM_HEAPS, |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
Iliyan Malchev | f2230156 | 2011-07-06 16:53:21 -0700 | [diff] [blame] | 50 | #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM) |
| 51 | #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG) |
| 52 | #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) |
Olav Haugan | 0a85251 | 2012-01-09 10:20:55 -0800 | [diff] [blame] | 53 | #define ION_HEAP_CP_MASK (1 << ION_HEAP_TYPE_CP) |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 54 | |
Laura Abbott | a2e9363 | 2011-08-19 13:36:32 -0700 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * These are the only ids that should be used for Ion heap ids. |
| 58 | * The ids listed are the order in which allocation will be attempted |
| 59 | * if specified. Don't swap the order of heap ids unless you know what |
| 60 | * you are doing! |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 61 | * Id's are spaced by purpose to allow new Id's to be inserted in-between (for |
| 62 | * possible fallbacks) |
Laura Abbott | a2e9363 | 2011-08-19 13:36:32 -0700 | [diff] [blame] | 63 | */ |
| 64 | |
| 65 | enum ion_heap_ids { |
Olav Haugan | 42ebe71 | 2012-01-10 16:30:58 -0800 | [diff] [blame] | 66 | INVALID_HEAP_ID = -1, |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 67 | ION_CP_MM_HEAP_ID = 8, |
| 68 | ION_CP_MFC_HEAP_ID = 12, |
| 69 | ION_CP_WB_HEAP_ID = 16, /* 8660 only */ |
| 70 | ION_CAMERA_HEAP_ID = 20, /* 8660 only */ |
| 71 | ION_SF_HEAP_ID = 24, |
Olav Haugan | 9e123f9 | 2012-02-15 15:41:48 -0800 | [diff] [blame] | 72 | ION_IOMMU_HEAP_ID = 25, |
Olav Haugan | 80854eb | 2012-01-12 12:00:23 -0800 | [diff] [blame] | 73 | ION_QSECOM_HEAP_ID = 27, |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 74 | ION_AUDIO_HEAP_ID = 28, |
| 75 | |
Olav Haugan | 42ebe71 | 2012-01-10 16:30:58 -0800 | [diff] [blame] | 76 | ION_MM_FIRMWARE_HEAP_ID = 29, |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 77 | ION_SYSTEM_HEAP_ID = 30, |
| 78 | |
| 79 | ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_SECURE flag */ |
Laura Abbott | a2e9363 | 2011-08-19 13:36:32 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Larry Bassel | 2d8b42d | 2012-03-12 10:41:26 -0700 | [diff] [blame] | 82 | enum ion_fixed_position { |
| 83 | NOT_FIXED, |
| 84 | FIXED_LOW, |
| 85 | FIXED_MIDDLE, |
| 86 | FIXED_HIGH, |
| 87 | }; |
| 88 | |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 89 | /** |
| 90 | * Flag to use when allocating to indicate that a heap is secure. |
| 91 | */ |
| 92 | #define ION_SECURE (1 << ION_HEAP_ID_RESERVED) |
| 93 | |
| 94 | /** |
| 95 | * Macro should be used with ion_heap_ids defined above. |
| 96 | */ |
| 97 | #define ION_HEAP(bit) (1 << (bit)) |
| 98 | |
Laura Abbott | a2e9363 | 2011-08-19 13:36:32 -0700 | [diff] [blame] | 99 | #define ION_VMALLOC_HEAP_NAME "vmalloc" |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 100 | #define ION_AUDIO_HEAP_NAME "audio" |
| 101 | #define ION_SF_HEAP_NAME "sf" |
| 102 | #define ION_MM_HEAP_NAME "mm" |
| 103 | #define ION_CAMERA_HEAP_NAME "camera_preview" |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 104 | #define ION_IOMMU_HEAP_NAME "iommu" |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 105 | #define ION_MFC_HEAP_NAME "mfc" |
| 106 | #define ION_WB_HEAP_NAME "wb" |
Olav Haugan | 42ebe71 | 2012-01-10 16:30:58 -0800 | [diff] [blame] | 107 | #define ION_MM_FIRMWARE_HEAP_NAME "mm_fw" |
Olav Haugan | 80854eb | 2012-01-12 12:00:23 -0800 | [diff] [blame] | 108 | #define ION_QSECOM_HEAP_NAME "qsecom" |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 109 | #define ION_FMEM_HEAP_NAME "fmem" |
Laura Abbott | a2e9363 | 2011-08-19 13:36:32 -0700 | [diff] [blame] | 110 | |
Laura Abbott | 894fd58 | 2011-08-19 13:33:56 -0700 | [diff] [blame] | 111 | #define CACHED 1 |
| 112 | #define UNCACHED 0 |
| 113 | |
| 114 | #define ION_CACHE_SHIFT 0 |
| 115 | |
| 116 | #define ION_SET_CACHE(__cache) ((__cache) << ION_CACHE_SHIFT) |
| 117 | |
Laura Abbott | 3541203 | 2011-09-29 09:50:06 -0700 | [diff] [blame] | 118 | #define ION_IS_CACHED(__flags) ((__flags) & (1 << ION_CACHE_SHIFT)) |
| 119 | |
Olav Haugan | b367659 | 2012-03-02 15:02:25 -0800 | [diff] [blame] | 120 | /* |
| 121 | * This flag allows clients when mapping into the IOMMU to specify to |
| 122 | * defer un-mapping from the IOMMU until the buffer memory is freed. |
| 123 | */ |
| 124 | #define ION_IOMMU_UNMAP_DELAYED 1 |
| 125 | |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 126 | #ifdef __KERNEL__ |
Laura Abbott | 6557696 | 2011-10-31 12:13:25 -0700 | [diff] [blame] | 127 | #include <linux/err.h> |
Laura Abbott | cffdff5 | 2011-09-23 10:40:19 -0700 | [diff] [blame] | 128 | #include <mach/ion.h> |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 129 | struct ion_device; |
| 130 | struct ion_heap; |
| 131 | struct ion_mapper; |
| 132 | struct ion_client; |
| 133 | struct ion_buffer; |
| 134 | |
| 135 | /* This should be removed some day when phys_addr_t's are fully |
| 136 | plumbed in the kernel, and all instances of ion_phys_addr_t should |
| 137 | be converted to phys_addr_t. For the time being many kernel interfaces |
| 138 | do not accept phys_addr_t's that would have to */ |
| 139 | #define ion_phys_addr_t unsigned long |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 140 | #define ion_virt_addr_t unsigned long |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 141 | |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 142 | /** |
| 143 | * struct ion_platform_heap - defines a heap in the given platform |
| 144 | * @type: type of the heap from ion_heap_type enum |
Olav Haugan | ee0f780 | 2011-12-19 13:28:57 -0800 | [diff] [blame] | 145 | * @id: unique identifier for heap. When allocating (lower numbers |
Olav Haugan | b5be799 | 2011-11-18 14:29:02 -0800 | [diff] [blame] | 146 | * will be allocated from first) |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 147 | * @name: used for debug purposes |
| 148 | * @base: base address of heap in physical memory if applicable |
| 149 | * @size: size of the heap in bytes if applicable |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 150 | * @memory_type:Memory type used for the heap |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 151 | * @has_outer_cache: set to 1 if outer cache is used, 0 otherwise. |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 152 | * @extra_data: Extra data specific to each heap type |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 153 | */ |
| 154 | struct ion_platform_heap { |
| 155 | enum ion_heap_type type; |
Rebecca Schultz Zavin | e6ee124 | 2011-06-30 12:19:55 -0700 | [diff] [blame] | 156 | unsigned int id; |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 157 | const char *name; |
| 158 | ion_phys_addr_t base; |
| 159 | size_t size; |
Laura Abbott | a2e9363 | 2011-08-19 13:36:32 -0700 | [diff] [blame] | 160 | enum ion_memory_types memory_type; |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 161 | unsigned int has_outer_cache; |
Olav Haugan | 0703dbf | 2011-12-19 17:53:38 -0800 | [diff] [blame] | 162 | void *extra_data; |
| 163 | }; |
| 164 | |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 165 | /** |
| 166 | * struct ion_cp_heap_pdata - defines a content protection heap in the given |
| 167 | * platform |
| 168 | * @permission_type: Memory ID used to identify the memory to TZ |
| 169 | * @align: Alignment requirement for the memory |
| 170 | * @secure_base: Base address for securing the heap. |
| 171 | * Note: This might be different from actual base address |
| 172 | * of this heap in the case of a shared heap. |
| 173 | * @secure_size: Memory size for securing the heap. |
| 174 | * Note: This might be different from actual size |
| 175 | * of this heap in the case of a shared heap. |
| 176 | * @reusable Flag indicating whether this heap is reusable of not. |
| 177 | * (see FMEM) |
Olav Haugan | f6dc774 | 2012-02-15 09:11:55 -0800 | [diff] [blame] | 178 | * @mem_is_fmem Flag indicating whether this memory is coming from fmem |
| 179 | * or not. |
Larry Bassel | 2d8b42d | 2012-03-12 10:41:26 -0700 | [diff] [blame] | 180 | * @fixed_position If nonzero, position in the fixed area. |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 181 | * @virt_addr: Virtual address used when using fmem. |
Olav Haugan | 8726caf | 2012-05-10 15:11:35 -0700 | [diff] [blame] | 182 | * @iommu_map_all: Indicates whether we should map whole heap into IOMMU. |
| 183 | * @iommu_2x_map_domain: Indicates the domain to use for overmapping. |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 184 | * @request_region: function to be called when the number of allocations |
| 185 | * goes from 0 -> 1 |
| 186 | * @release_region: function to be called when the number of allocations |
| 187 | * goes from 1 -> 0 |
| 188 | * @setup_region: function to be called upon ion registration |
| 189 | * |
| 190 | */ |
Olav Haugan | 0703dbf | 2011-12-19 17:53:38 -0800 | [diff] [blame] | 191 | struct ion_cp_heap_pdata { |
Olav Haugan | 0a85251 | 2012-01-09 10:20:55 -0800 | [diff] [blame] | 192 | enum ion_permission_type permission_type; |
Olav Haugan | 42ebe71 | 2012-01-10 16:30:58 -0800 | [diff] [blame] | 193 | unsigned int align; |
| 194 | ion_phys_addr_t secure_base; /* Base addr used when heap is shared */ |
| 195 | size_t secure_size; /* Size used for securing heap when heap is shared*/ |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 196 | int reusable; |
Olav Haugan | f6dc774 | 2012-02-15 09:11:55 -0800 | [diff] [blame] | 197 | int mem_is_fmem; |
Larry Bassel | 2d8b42d | 2012-03-12 10:41:26 -0700 | [diff] [blame] | 198 | enum ion_fixed_position fixed_position; |
Olav Haugan | 8726caf | 2012-05-10 15:11:35 -0700 | [diff] [blame] | 199 | int iommu_map_all; |
| 200 | int iommu_2x_map_domain; |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 201 | ion_virt_addr_t *virt_addr; |
Olav Haugan | ee0f780 | 2011-12-19 13:28:57 -0800 | [diff] [blame] | 202 | int (*request_region)(void *); |
| 203 | int (*release_region)(void *); |
Alex Bird | 8a3ede3 | 2011-11-07 12:33:42 -0800 | [diff] [blame] | 204 | void *(*setup_region)(void); |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 205 | }; |
| 206 | |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 207 | /** |
| 208 | * struct ion_co_heap_pdata - defines a carveout heap in the given platform |
| 209 | * @adjacent_mem_id: Id of heap that this heap must be adjacent to. |
| 210 | * @align: Alignment requirement for the memory |
Olav Haugan | f6dc774 | 2012-02-15 09:11:55 -0800 | [diff] [blame] | 211 | * @mem_is_fmem Flag indicating whether this memory is coming from fmem |
| 212 | * or not. |
Larry Bassel | 2d8b42d | 2012-03-12 10:41:26 -0700 | [diff] [blame] | 213 | * @fixed_position If nonzero, position in the fixed area. |
Laura Abbott | caafeea | 2011-12-13 11:43:10 -0800 | [diff] [blame] | 214 | * @request_region: function to be called when the number of allocations |
| 215 | * goes from 0 -> 1 |
| 216 | * @release_region: function to be called when the number of allocations |
| 217 | * goes from 1 -> 0 |
| 218 | * @setup_region: function to be called upon ion registration |
| 219 | * |
| 220 | */ |
Olav Haugan | 0703dbf | 2011-12-19 17:53:38 -0800 | [diff] [blame] | 221 | struct ion_co_heap_pdata { |
Olav Haugan | 42ebe71 | 2012-01-10 16:30:58 -0800 | [diff] [blame] | 222 | int adjacent_mem_id; |
| 223 | unsigned int align; |
Olav Haugan | f6dc774 | 2012-02-15 09:11:55 -0800 | [diff] [blame] | 224 | int mem_is_fmem; |
Larry Bassel | 2d8b42d | 2012-03-12 10:41:26 -0700 | [diff] [blame] | 225 | enum ion_fixed_position fixed_position; |
Olav Haugan | 0703dbf | 2011-12-19 17:53:38 -0800 | [diff] [blame] | 226 | int (*request_region)(void *); |
| 227 | int (*release_region)(void *); |
| 228 | void *(*setup_region)(void); |
| 229 | }; |
| 230 | |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 231 | /** |
| 232 | * struct ion_platform_data - array of platform heaps passed from board file |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 233 | * @has_outer_cache: set to 1 if outer cache is used, 0 otherwise. |
Alex Bird | 27ca661 | 2011-11-01 14:40:06 -0700 | [diff] [blame] | 234 | * @nr: number of structures in the array |
| 235 | * @request_region: function to be called when the number of allocations goes |
| 236 | * from 0 -> 1 |
| 237 | * @release_region: function to be called when the number of allocations goes |
| 238 | * from 1 -> 0 |
| 239 | * @setup_region: function to be called upon ion registration |
| 240 | * @heaps: array of platform_heap structions |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 241 | * |
| 242 | * Provided by the board file in the form of platform data to a platform device. |
| 243 | */ |
| 244 | struct ion_platform_data { |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 245 | unsigned int has_outer_cache; |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 246 | int nr; |
Olav Haugan | ee0f780 | 2011-12-19 13:28:57 -0800 | [diff] [blame] | 247 | int (*request_region)(void *); |
| 248 | int (*release_region)(void *); |
Alex Bird | 27ca661 | 2011-11-01 14:40:06 -0700 | [diff] [blame] | 249 | void *(*setup_region)(void); |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 250 | struct ion_platform_heap heaps[]; |
| 251 | }; |
| 252 | |
Jordan Crouse | 8cd4832 | 2011-10-12 17:05:19 -0600 | [diff] [blame] | 253 | #ifdef CONFIG_ION |
| 254 | |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 255 | /** |
| 256 | * ion_client_create() - allocate a client and returns it |
| 257 | * @dev: the global ion device |
| 258 | * @heap_mask: mask of heaps this client can allocate from |
| 259 | * @name: used for debugging |
| 260 | */ |
| 261 | struct ion_client *ion_client_create(struct ion_device *dev, |
| 262 | unsigned int heap_mask, const char *name); |
| 263 | |
| 264 | /** |
Laura Abbott | 302911d | 2011-08-15 17:12:57 -0700 | [diff] [blame] | 265 | * msm_ion_client_create - allocate a client using the ion_device specified in |
| 266 | * drivers/gpu/ion/msm/msm_ion.c |
| 267 | * |
| 268 | * heap_mask and name are the same as ion_client_create, return values |
| 269 | * are the same as ion_client_create. |
| 270 | */ |
| 271 | |
| 272 | struct ion_client *msm_ion_client_create(unsigned int heap_mask, |
| 273 | const char *name); |
| 274 | |
| 275 | /** |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 276 | * ion_client_destroy() - free's a client and all it's handles |
| 277 | * @client: the client |
| 278 | * |
| 279 | * Free the provided client and all it's resources including |
| 280 | * any handles it is holding. |
| 281 | */ |
| 282 | void ion_client_destroy(struct ion_client *client); |
| 283 | |
| 284 | /** |
| 285 | * ion_alloc - allocate ion memory |
| 286 | * @client: the client |
| 287 | * @len: size of the allocation |
| 288 | * @align: requested allocation alignment, lots of hardware blocks have |
| 289 | * alignment requirements of some kind |
Rebecca Schultz Zavin | e6ee124 | 2011-06-30 12:19:55 -0700 | [diff] [blame] | 290 | * @flags: mask of heaps to allocate from, if multiple bits are set |
| 291 | * heaps will be tried in order from lowest to highest order bit |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 292 | * |
| 293 | * Allocate memory in one of the heaps provided in heap mask and return |
| 294 | * an opaque handle to it. |
| 295 | */ |
| 296 | struct ion_handle *ion_alloc(struct ion_client *client, size_t len, |
| 297 | size_t align, unsigned int flags); |
| 298 | |
| 299 | /** |
| 300 | * ion_free - free a handle |
| 301 | * @client: the client |
| 302 | * @handle: the handle to free |
| 303 | * |
| 304 | * Free the provided handle. |
| 305 | */ |
| 306 | void ion_free(struct ion_client *client, struct ion_handle *handle); |
| 307 | |
| 308 | /** |
| 309 | * ion_phys - returns the physical address and len of a handle |
| 310 | * @client: the client |
| 311 | * @handle: the handle |
| 312 | * @addr: a pointer to put the address in |
| 313 | * @len: a pointer to put the length in |
| 314 | * |
| 315 | * This function queries the heap for a particular handle to get the |
| 316 | * handle's physical address. It't output is only correct if |
| 317 | * a heap returns physically contiguous memory -- in other cases |
| 318 | * this api should not be implemented -- ion_map_dma should be used |
| 319 | * instead. Returns -EINVAL if the handle is invalid. This has |
| 320 | * no implications on the reference counting of the handle -- |
| 321 | * the returned value may not be valid if the caller is not |
| 322 | * holding a reference. |
| 323 | */ |
| 324 | int ion_phys(struct ion_client *client, struct ion_handle *handle, |
| 325 | ion_phys_addr_t *addr, size_t *len); |
| 326 | |
| 327 | /** |
| 328 | * ion_map_kernel - create mapping for the given handle |
| 329 | * @client: the client |
| 330 | * @handle: handle to map |
Laura Abbott | 894fd58 | 2011-08-19 13:33:56 -0700 | [diff] [blame] | 331 | * @flags: flags for this mapping |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 332 | * |
| 333 | * Map the given handle into the kernel and return a kernel address that |
Laura Abbott | 894fd58 | 2011-08-19 13:33:56 -0700 | [diff] [blame] | 334 | * can be used to access this address. If no flags are specified, this |
| 335 | * will return a non-secure uncached mapping. |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 336 | */ |
Laura Abbott | 894fd58 | 2011-08-19 13:33:56 -0700 | [diff] [blame] | 337 | void *ion_map_kernel(struct ion_client *client, struct ion_handle *handle, |
| 338 | unsigned long flags); |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 339 | |
| 340 | /** |
| 341 | * ion_unmap_kernel() - destroy a kernel mapping for a handle |
| 342 | * @client: the client |
| 343 | * @handle: handle to unmap |
| 344 | */ |
| 345 | void ion_unmap_kernel(struct ion_client *client, struct ion_handle *handle); |
| 346 | |
| 347 | /** |
| 348 | * ion_map_dma - create a dma mapping for a given handle |
| 349 | * @client: the client |
| 350 | * @handle: handle to map |
| 351 | * |
| 352 | * Return an sglist describing the given handle |
| 353 | */ |
| 354 | struct scatterlist *ion_map_dma(struct ion_client *client, |
Laura Abbott | 894fd58 | 2011-08-19 13:33:56 -0700 | [diff] [blame] | 355 | struct ion_handle *handle, |
| 356 | unsigned long flags); |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 357 | |
| 358 | /** |
| 359 | * ion_unmap_dma() - destroy a dma mapping for a handle |
| 360 | * @client: the client |
| 361 | * @handle: handle to unmap |
| 362 | */ |
| 363 | void ion_unmap_dma(struct ion_client *client, struct ion_handle *handle); |
| 364 | |
| 365 | /** |
| 366 | * ion_share() - given a handle, obtain a buffer to pass to other clients |
| 367 | * @client: the client |
| 368 | * @handle: the handle to share |
| 369 | * |
Iliyan Malchev | 3fe2436 | 2011-08-09 14:42:08 -0700 | [diff] [blame] | 370 | * Given a handle, return a buffer, which exists in a global name |
| 371 | * space, and can be passed to other clients. Should be passed into ion_import |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 372 | * to obtain a new handle for this buffer. |
Iliyan Malchev | 3fe2436 | 2011-08-09 14:42:08 -0700 | [diff] [blame] | 373 | * |
| 374 | * NOTE: This function does do not an extra reference. The burden is on the |
| 375 | * caller to make sure the buffer doesn't go away while it's being passed to |
| 376 | * another client. That is, ion_free should not be called on this handle until |
| 377 | * the buffer has been imported into the other client. |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 378 | */ |
| 379 | struct ion_buffer *ion_share(struct ion_client *client, |
| 380 | struct ion_handle *handle); |
| 381 | |
| 382 | /** |
| 383 | * ion_import() - given an buffer in another client, import it |
| 384 | * @client: this blocks client |
| 385 | * @buffer: the buffer to import (as obtained from ion_share) |
| 386 | * |
| 387 | * Given a buffer, add it to the client and return the handle to use to refer |
| 388 | * to it further. This is called to share a handle from one kernel client to |
| 389 | * another. |
| 390 | */ |
| 391 | struct ion_handle *ion_import(struct ion_client *client, |
| 392 | struct ion_buffer *buffer); |
| 393 | |
| 394 | /** |
| 395 | * ion_import_fd() - given an fd obtained via ION_IOC_SHARE ioctl, import it |
| 396 | * @client: this blocks client |
| 397 | * @fd: the fd |
| 398 | * |
| 399 | * A helper function for drivers that will be recieving ion buffers shared |
| 400 | * with them from userspace. These buffers are represented by a file |
| 401 | * descriptor obtained as the return from the ION_IOC_SHARE ioctl. |
| 402 | * This function coverts that fd into the underlying buffer, and returns |
| 403 | * the handle to use to refer to it further. |
| 404 | */ |
| 405 | struct ion_handle *ion_import_fd(struct ion_client *client, int fd); |
Laura Abbott | 273dd8e | 2011-10-12 14:26:33 -0700 | [diff] [blame] | 406 | |
Laura Abbott | 273dd8e | 2011-10-12 14:26:33 -0700 | [diff] [blame] | 407 | /** |
| 408 | * ion_handle_get_flags - get the flags for a given handle |
| 409 | * |
| 410 | * @client - client who allocated the handle |
| 411 | * @handle - handle to get the flags |
| 412 | * @flags - pointer to store the flags |
| 413 | * |
| 414 | * Gets the current flags for a handle. These flags indicate various options |
| 415 | * of the buffer (caching, security, etc.) |
| 416 | */ |
| 417 | int ion_handle_get_flags(struct ion_client *client, struct ion_handle *handle, |
| 418 | unsigned long *flags); |
| 419 | |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 420 | |
| 421 | /** |
| 422 | * ion_map_iommu - map the given handle into an iommu |
| 423 | * |
| 424 | * @client - client who allocated the handle |
| 425 | * @handle - handle to map |
| 426 | * @domain_num - domain number to map to |
| 427 | * @partition_num - partition number to allocate iova from |
| 428 | * @align - alignment for the iova |
| 429 | * @iova_length - length of iova to map. If the iova length is |
| 430 | * greater than the handle length, the remaining |
| 431 | * address space will be mapped to a dummy buffer. |
| 432 | * @iova - pointer to store the iova address |
| 433 | * @buffer_size - pointer to store the size of the buffer |
| 434 | * @flags - flags for options to map |
Olav Haugan | b367659 | 2012-03-02 15:02:25 -0800 | [diff] [blame] | 435 | * @iommu_flags - flags specific to the iommu. |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 436 | * |
| 437 | * Maps the handle into the iova space specified via domain number. Iova |
| 438 | * will be allocated from the partition specified via partition_num. |
| 439 | * Returns 0 on success, negative value on error. |
| 440 | */ |
| 441 | int ion_map_iommu(struct ion_client *client, struct ion_handle *handle, |
| 442 | int domain_num, int partition_num, unsigned long align, |
| 443 | unsigned long iova_length, unsigned long *iova, |
| 444 | unsigned long *buffer_size, |
Olav Haugan | b367659 | 2012-03-02 15:02:25 -0800 | [diff] [blame] | 445 | unsigned long flags, unsigned long iommu_flags); |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 446 | |
| 447 | |
| 448 | /** |
| 449 | * ion_handle_get_size - get the allocated size of a given handle |
| 450 | * |
| 451 | * @client - client who allocated the handle |
| 452 | * @handle - handle to get the size |
| 453 | * @size - pointer to store the size |
| 454 | * |
| 455 | * gives the allocated size of a handle. returns 0 on success, negative |
| 456 | * value on error |
| 457 | * |
| 458 | * NOTE: This is intended to be used only to get a size to pass to map_iommu. |
| 459 | * You should *NOT* rely on this for any other usage. |
| 460 | */ |
| 461 | |
| 462 | int ion_handle_get_size(struct ion_client *client, struct ion_handle *handle, |
| 463 | unsigned long *size); |
| 464 | |
| 465 | /** |
| 466 | * ion_unmap_iommu - unmap the handle from an iommu |
| 467 | * |
| 468 | * @client - client who allocated the handle |
| 469 | * @handle - handle to unmap |
| 470 | * @domain_num - domain to unmap from |
| 471 | * @partition_num - partition to unmap from |
| 472 | * |
| 473 | * Decrement the reference count on the iommu mapping. If the count is |
| 474 | * 0, the mapping will be removed from the iommu. |
| 475 | */ |
| 476 | void ion_unmap_iommu(struct ion_client *client, struct ion_handle *handle, |
| 477 | int domain_num, int partition_num); |
| 478 | |
| 479 | |
Olav Haugan | 0a85251 | 2012-01-09 10:20:55 -0800 | [diff] [blame] | 480 | /** |
| 481 | * ion_secure_heap - secure a heap |
| 482 | * |
| 483 | * @client - a client that has allocated from the heap heap_id |
| 484 | * @heap_id - heap id to secure. |
| 485 | * |
| 486 | * Secure a heap |
| 487 | * Returns 0 on success |
| 488 | */ |
| 489 | int ion_secure_heap(struct ion_device *dev, int heap_id); |
| 490 | |
| 491 | /** |
| 492 | * ion_unsecure_heap - un-secure a heap |
| 493 | * |
| 494 | * @client - a client that has allocated from the heap heap_id |
| 495 | * @heap_id - heap id to un-secure. |
| 496 | * |
| 497 | * Un-secure a heap |
| 498 | * Returns 0 on success |
| 499 | */ |
| 500 | int ion_unsecure_heap(struct ion_device *dev, int heap_id); |
| 501 | |
| 502 | /** |
| 503 | * msm_ion_secure_heap - secure a heap. Wrapper around ion_secure_heap. |
| 504 | * |
| 505 | * @heap_id - heap id to secure. |
| 506 | * |
| 507 | * Secure a heap |
| 508 | * Returns 0 on success |
| 509 | */ |
| 510 | int msm_ion_secure_heap(int heap_id); |
| 511 | |
| 512 | /** |
| 513 | * msm_ion_unsecure_heap - unsecure a heap. Wrapper around ion_unsecure_heap. |
| 514 | * |
| 515 | * @heap_id - heap id to secure. |
| 516 | * |
| 517 | * Un-secure a heap |
| 518 | * Returns 0 on success |
| 519 | */ |
| 520 | int msm_ion_unsecure_heap(int heap_id); |
| 521 | |
Olav Haugan | 41f8579 | 2012-02-08 15:28:05 -0800 | [diff] [blame] | 522 | /** |
| 523 | * msm_ion_do_cache_op - do cache operations. |
| 524 | * |
| 525 | * @client - pointer to ION client. |
| 526 | * @handle - pointer to buffer handle. |
| 527 | * @vaddr - virtual address to operate on. |
| 528 | * @len - Length of data to do cache operation on. |
| 529 | * @cmd - Cache operation to perform: |
| 530 | * ION_IOC_CLEAN_CACHES |
| 531 | * ION_IOC_INV_CACHES |
| 532 | * ION_IOC_CLEAN_INV_CACHES |
| 533 | * |
| 534 | * Returns 0 on success |
| 535 | */ |
| 536 | int msm_ion_do_cache_op(struct ion_client *client, struct ion_handle *handle, |
| 537 | void *vaddr, unsigned long len, unsigned int cmd); |
| 538 | |
Jordan Crouse | 8cd4832 | 2011-10-12 17:05:19 -0600 | [diff] [blame] | 539 | #else |
| 540 | static inline struct ion_client *ion_client_create(struct ion_device *dev, |
| 541 | unsigned int heap_mask, const char *name) |
| 542 | { |
| 543 | return ERR_PTR(-ENODEV); |
| 544 | } |
Laura Abbott | 273dd8e | 2011-10-12 14:26:33 -0700 | [diff] [blame] | 545 | |
Jordan Crouse | 8cd4832 | 2011-10-12 17:05:19 -0600 | [diff] [blame] | 546 | static inline struct ion_client *msm_ion_client_create(unsigned int heap_mask, |
| 547 | const char *name) |
| 548 | { |
| 549 | return ERR_PTR(-ENODEV); |
| 550 | } |
| 551 | |
| 552 | static inline void ion_client_destroy(struct ion_client *client) { } |
| 553 | |
| 554 | static inline struct ion_handle *ion_alloc(struct ion_client *client, |
| 555 | size_t len, size_t align, unsigned int flags) |
| 556 | { |
| 557 | return ERR_PTR(-ENODEV); |
| 558 | } |
| 559 | |
| 560 | static inline void ion_free(struct ion_client *client, |
| 561 | struct ion_handle *handle) { } |
| 562 | |
| 563 | |
| 564 | static inline int ion_phys(struct ion_client *client, |
| 565 | struct ion_handle *handle, ion_phys_addr_t *addr, size_t *len) |
| 566 | { |
| 567 | return -ENODEV; |
| 568 | } |
| 569 | |
| 570 | static inline void *ion_map_kernel(struct ion_client *client, |
| 571 | struct ion_handle *handle, unsigned long flags) |
| 572 | { |
| 573 | return ERR_PTR(-ENODEV); |
| 574 | } |
| 575 | |
| 576 | static inline void ion_unmap_kernel(struct ion_client *client, |
| 577 | struct ion_handle *handle) { } |
| 578 | |
| 579 | static inline struct scatterlist *ion_map_dma(struct ion_client *client, |
| 580 | struct ion_handle *handle, unsigned long flags) |
| 581 | { |
| 582 | return ERR_PTR(-ENODEV); |
| 583 | } |
| 584 | |
| 585 | static inline void ion_unmap_dma(struct ion_client *client, |
| 586 | struct ion_handle *handle) { } |
| 587 | |
| 588 | static inline struct ion_buffer *ion_share(struct ion_client *client, |
| 589 | struct ion_handle *handle) |
| 590 | { |
| 591 | return ERR_PTR(-ENODEV); |
| 592 | } |
| 593 | |
| 594 | static inline struct ion_handle *ion_import(struct ion_client *client, |
| 595 | struct ion_buffer *buffer) |
| 596 | { |
| 597 | return ERR_PTR(-ENODEV); |
| 598 | } |
| 599 | |
| 600 | static inline struct ion_handle *ion_import_fd(struct ion_client *client, |
| 601 | int fd) |
| 602 | { |
| 603 | return ERR_PTR(-ENODEV); |
| 604 | } |
| 605 | |
| 606 | static inline int ion_handle_get_flags(struct ion_client *client, |
| 607 | struct ion_handle *handle, unsigned long *flags) |
| 608 | { |
| 609 | return -ENODEV; |
| 610 | } |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 611 | |
| 612 | static inline int ion_map_iommu(struct ion_client *client, |
| 613 | struct ion_handle *handle, int domain_num, |
| 614 | int partition_num, unsigned long align, |
| 615 | unsigned long iova_length, unsigned long *iova, |
Olav Haugan | 9a27d4c | 2012-02-23 09:35:16 -0800 | [diff] [blame] | 616 | unsigned long *buffer_size, |
Olav Haugan | b367659 | 2012-03-02 15:02:25 -0800 | [diff] [blame] | 617 | unsigned long flags, |
| 618 | unsigned long iommu_flags) |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 619 | { |
| 620 | return -ENODEV; |
| 621 | } |
| 622 | |
| 623 | static inline void ion_unmap_iommu(struct ion_client *client, |
| 624 | struct ion_handle *handle, int domain_num, |
| 625 | int partition_num) |
| 626 | { |
| 627 | return; |
| 628 | } |
| 629 | |
Olav Haugan | 0a85251 | 2012-01-09 10:20:55 -0800 | [diff] [blame] | 630 | static inline int ion_secure_heap(struct ion_device *dev, int heap_id) |
| 631 | { |
| 632 | return -ENODEV; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 633 | |
Olav Haugan | 0a85251 | 2012-01-09 10:20:55 -0800 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | static inline int ion_unsecure_heap(struct ion_device *dev, int heap_id) |
| 637 | { |
| 638 | return -ENODEV; |
| 639 | } |
| 640 | |
| 641 | static inline int msm_ion_secure_heap(int heap_id) |
| 642 | { |
| 643 | return -ENODEV; |
| 644 | |
| 645 | } |
| 646 | |
| 647 | static inline int msm_ion_unsecure_heap(int heap_id) |
| 648 | { |
| 649 | return -ENODEV; |
| 650 | } |
Olav Haugan | 41f8579 | 2012-02-08 15:28:05 -0800 | [diff] [blame] | 651 | |
| 652 | static inline int msm_ion_do_cache_op(struct ion_client *client, |
| 653 | struct ion_handle *handle, void *vaddr, |
| 654 | unsigned long len, unsigned int cmd) |
| 655 | { |
| 656 | return -ENODEV; |
| 657 | } |
| 658 | |
Jordan Crouse | 8cd4832 | 2011-10-12 17:05:19 -0600 | [diff] [blame] | 659 | #endif /* CONFIG_ION */ |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 660 | #endif /* __KERNEL__ */ |
| 661 | |
| 662 | /** |
| 663 | * DOC: Ion Userspace API |
| 664 | * |
| 665 | * create a client by opening /dev/ion |
| 666 | * most operations handled via following ioctls |
| 667 | * |
| 668 | */ |
| 669 | |
| 670 | /** |
| 671 | * struct ion_allocation_data - metadata passed from userspace for allocations |
| 672 | * @len: size of the allocation |
| 673 | * @align: required alignment of the allocation |
| 674 | * @flags: flags passed to heap |
| 675 | * @handle: pointer that will be populated with a cookie to use to refer |
| 676 | * to this allocation |
| 677 | * |
| 678 | * Provided by userspace as an argument to the ioctl |
| 679 | */ |
| 680 | struct ion_allocation_data { |
| 681 | size_t len; |
| 682 | size_t align; |
| 683 | unsigned int flags; |
| 684 | struct ion_handle *handle; |
| 685 | }; |
| 686 | |
| 687 | /** |
| 688 | * struct ion_fd_data - metadata passed to/from userspace for a handle/fd pair |
| 689 | * @handle: a handle |
| 690 | * @fd: a file descriptor representing that handle |
| 691 | * |
| 692 | * For ION_IOC_SHARE or ION_IOC_MAP userspace populates the handle field with |
| 693 | * the handle returned from ion alloc, and the kernel returns the file |
| 694 | * descriptor to share or map in the fd field. For ION_IOC_IMPORT, userspace |
| 695 | * provides the file descriptor and the kernel returns the handle. |
| 696 | */ |
| 697 | struct ion_fd_data { |
| 698 | struct ion_handle *handle; |
| 699 | int fd; |
| 700 | }; |
| 701 | |
| 702 | /** |
| 703 | * struct ion_handle_data - a handle passed to/from the kernel |
| 704 | * @handle: a handle |
| 705 | */ |
| 706 | struct ion_handle_data { |
| 707 | struct ion_handle *handle; |
| 708 | }; |
| 709 | |
Rebecca Schultz Zavin | e6ee124 | 2011-06-30 12:19:55 -0700 | [diff] [blame] | 710 | /** |
| 711 | * struct ion_custom_data - metadata passed to/from userspace for a custom ioctl |
| 712 | * @cmd: the custom ioctl function to call |
| 713 | * @arg: additional data to pass to the custom ioctl, typically a user |
| 714 | * pointer to a predefined structure |
| 715 | * |
| 716 | * This works just like the regular cmd and arg fields of an ioctl. |
| 717 | */ |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 718 | struct ion_custom_data { |
| 719 | unsigned int cmd; |
| 720 | unsigned long arg; |
| 721 | }; |
| 722 | |
Laura Abbott | abcb6f7 | 2011-10-04 16:26:49 -0700 | [diff] [blame] | 723 | |
| 724 | /* struct ion_flush_data - data passed to ion for flushing caches |
| 725 | * |
| 726 | * @handle: handle with data to flush |
Laura Abbott | e80ea01 | 2011-11-18 18:36:47 -0800 | [diff] [blame] | 727 | * @fd: fd to flush |
Laura Abbott | abcb6f7 | 2011-10-04 16:26:49 -0700 | [diff] [blame] | 728 | * @vaddr: userspace virtual address mapped with mmap |
| 729 | * @offset: offset into the handle to flush |
| 730 | * @length: length of handle to flush |
| 731 | * |
| 732 | * Performs cache operations on the handle. If p is the start address |
| 733 | * of the handle, p + offset through p + offset + length will have |
| 734 | * the cache operations performed |
| 735 | */ |
| 736 | struct ion_flush_data { |
| 737 | struct ion_handle *handle; |
Laura Abbott | e80ea01 | 2011-11-18 18:36:47 -0800 | [diff] [blame] | 738 | int fd; |
Laura Abbott | abcb6f7 | 2011-10-04 16:26:49 -0700 | [diff] [blame] | 739 | void *vaddr; |
| 740 | unsigned int offset; |
| 741 | unsigned int length; |
| 742 | }; |
Laura Abbott | 273dd8e | 2011-10-12 14:26:33 -0700 | [diff] [blame] | 743 | |
| 744 | /* struct ion_flag_data - information about flags for this buffer |
| 745 | * |
| 746 | * @handle: handle to get flags from |
| 747 | * @flags: flags of this handle |
| 748 | * |
| 749 | * Takes handle as an input and outputs the flags from the handle |
| 750 | * in the flag field. |
| 751 | */ |
| 752 | struct ion_flag_data { |
| 753 | struct ion_handle *handle; |
| 754 | unsigned long flags; |
| 755 | }; |
| 756 | |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 757 | #define ION_IOC_MAGIC 'I' |
| 758 | |
| 759 | /** |
| 760 | * DOC: ION_IOC_ALLOC - allocate memory |
| 761 | * |
| 762 | * Takes an ion_allocation_data struct and returns it with the handle field |
| 763 | * populated with the opaque handle for the allocation. |
| 764 | */ |
| 765 | #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ |
| 766 | struct ion_allocation_data) |
| 767 | |
| 768 | /** |
| 769 | * DOC: ION_IOC_FREE - free memory |
| 770 | * |
| 771 | * Takes an ion_handle_data struct and frees the handle. |
| 772 | */ |
| 773 | #define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data) |
| 774 | |
| 775 | /** |
| 776 | * DOC: ION_IOC_MAP - get a file descriptor to mmap |
| 777 | * |
| 778 | * Takes an ion_fd_data struct with the handle field populated with a valid |
| 779 | * opaque handle. Returns the struct with the fd field set to a file |
| 780 | * descriptor open in the current address space. This file descriptor |
| 781 | * can then be used as an argument to mmap. |
| 782 | */ |
| 783 | #define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data) |
| 784 | |
| 785 | /** |
| 786 | * DOC: ION_IOC_SHARE - creates a file descriptor to use to share an allocation |
| 787 | * |
| 788 | * Takes an ion_fd_data struct with the handle field populated with a valid |
| 789 | * opaque handle. Returns the struct with the fd field set to a file |
| 790 | * descriptor open in the current address space. This file descriptor |
| 791 | * can then be passed to another process. The corresponding opaque handle can |
| 792 | * be retrieved via ION_IOC_IMPORT. |
| 793 | */ |
| 794 | #define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data) |
| 795 | |
| 796 | /** |
| 797 | * DOC: ION_IOC_IMPORT - imports a shared file descriptor |
| 798 | * |
| 799 | * Takes an ion_fd_data struct with the fd field populated with a valid file |
| 800 | * descriptor obtained from ION_IOC_SHARE and returns the struct with the handle |
| 801 | * filed set to the corresponding opaque handle. |
| 802 | */ |
| 803 | #define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, int) |
| 804 | |
| 805 | /** |
| 806 | * DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl |
| 807 | * |
| 808 | * Takes the argument of the architecture specific ioctl to call and |
| 809 | * passes appropriate userdata for that ioctl |
| 810 | */ |
| 811 | #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data) |
| 812 | |
Laura Abbott | abcb6f7 | 2011-10-04 16:26:49 -0700 | [diff] [blame] | 813 | |
| 814 | /** |
| 815 | * DOC: ION_IOC_CLEAN_CACHES - clean the caches |
| 816 | * |
| 817 | * Clean the caches of the handle specified. |
| 818 | */ |
| 819 | #define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MAGIC, 7, \ |
| 820 | struct ion_flush_data) |
| 821 | /** |
| 822 | * DOC: ION_MSM_IOC_INV_CACHES - invalidate the caches |
| 823 | * |
| 824 | * Invalidate the caches of the handle specified. |
| 825 | */ |
| 826 | #define ION_IOC_INV_CACHES _IOWR(ION_IOC_MAGIC, 8, \ |
| 827 | struct ion_flush_data) |
| 828 | /** |
| 829 | * DOC: ION_MSM_IOC_CLEAN_CACHES - clean and invalidate the caches |
| 830 | * |
| 831 | * Clean and invalidate the caches of the handle specified. |
| 832 | */ |
| 833 | #define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MAGIC, 9, \ |
| 834 | struct ion_flush_data) |
Laura Abbott | 273dd8e | 2011-10-12 14:26:33 -0700 | [diff] [blame] | 835 | |
| 836 | /** |
| 837 | * DOC: ION_IOC_GET_FLAGS - get the flags of the handle |
| 838 | * |
| 839 | * Gets the flags of the current handle which indicate cachability, |
| 840 | * secure state etc. |
| 841 | */ |
| 842 | #define ION_IOC_GET_FLAGS _IOWR(ION_IOC_MAGIC, 10, \ |
| 843 | struct ion_flag_data) |
Rebecca Schultz Zavin | c80005a | 2011-06-29 19:44:29 -0700 | [diff] [blame] | 844 | #endif /* _LINUX_ION_H */ |