Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 1 | #ifndef _UAPI_MSM_ION_H |
| 2 | #define _UAPI_MSM_ION_H |
| 3 | |
| 4 | #include "ion.h" |
| 5 | |
Liam Mark | d9a5085 | 2016-09-22 11:30:51 -0700 | [diff] [blame] | 6 | #define ION_BIT(nr) (1UL << (nr)) |
| 7 | |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 8 | enum msm_ion_heap_types { |
| 9 | ION_HEAP_TYPE_MSM_START = ION_HEAP_TYPE_CUSTOM + 1, |
| 10 | ION_HEAP_TYPE_SECURE_DMA = ION_HEAP_TYPE_MSM_START, |
Patrick Daly | c1005d8 | 2016-09-22 17:43:26 -0700 | [diff] [blame] | 11 | ION_HEAP_TYPE_SYSTEM_SECURE, |
Laura Abbott | 29defcc | 2014-08-01 16:13:40 -0700 | [diff] [blame] | 12 | ION_HEAP_TYPE_HYP_CMA, |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 13 | /* |
| 14 | * if you add a heap type here you should also add it to |
| 15 | * heap_types_info[] in msm_ion.c |
| 16 | */ |
| 17 | }; |
| 18 | |
| 19 | /** |
| 20 | * These are the only ids that should be used for Ion heap ids. |
| 21 | * The ids listed are the order in which allocation will be attempted |
| 22 | * if specified. Don't swap the order of heap ids unless you know what |
| 23 | * you are doing! |
| 24 | * Id's are spaced by purpose to allow new Id's to be inserted in-between (for |
| 25 | * possible fallbacks) |
| 26 | */ |
| 27 | |
| 28 | enum ion_heap_ids { |
| 29 | INVALID_HEAP_ID = -1, |
| 30 | ION_CP_MM_HEAP_ID = 8, |
Patrick Daly | c1005d8 | 2016-09-22 17:43:26 -0700 | [diff] [blame] | 31 | ION_SECURE_HEAP_ID = 9, |
Laura Abbott | 29defcc | 2014-08-01 16:13:40 -0700 | [diff] [blame] | 32 | ION_SECURE_DISPLAY_HEAP_ID = 10, |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 33 | ION_CP_MFC_HEAP_ID = 12, |
Laura Abbott | 29defcc | 2014-08-01 16:13:40 -0700 | [diff] [blame] | 34 | ION_SPSS_HEAP_ID = 13, /* Secure Processor ION heap */ |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 35 | ION_CP_WB_HEAP_ID = 16, /* 8660 only */ |
| 36 | ION_CAMERA_HEAP_ID = 20, /* 8660 only */ |
| 37 | ION_SYSTEM_CONTIG_HEAP_ID = 21, |
| 38 | ION_ADSP_HEAP_ID = 22, |
| 39 | ION_PIL1_HEAP_ID = 23, /* Currently used for other PIL images */ |
| 40 | ION_SF_HEAP_ID = 24, |
| 41 | ION_SYSTEM_HEAP_ID = 25, |
| 42 | ION_PIL2_HEAP_ID = 26, /* Currently used for modem firmware images */ |
| 43 | ION_QSECOM_HEAP_ID = 27, |
| 44 | ION_AUDIO_HEAP_ID = 28, |
| 45 | |
| 46 | ION_MM_FIRMWARE_HEAP_ID = 29, |
| 47 | |
| 48 | ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ |
| 49 | }; |
| 50 | |
| 51 | /* |
| 52 | * The IOMMU heap is deprecated! Here are some aliases for backwards |
| 53 | * compatibility: |
| 54 | */ |
| 55 | #define ION_IOMMU_HEAP_ID ION_SYSTEM_HEAP_ID |
| 56 | #define ION_HEAP_TYPE_IOMMU ION_HEAP_TYPE_SYSTEM |
| 57 | |
Laura Abbott | 29defcc | 2014-08-01 16:13:40 -0700 | [diff] [blame] | 58 | #define ION_SPSS_HEAP_ID ION_SPSS_HEAP_ID |
| 59 | |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 60 | enum ion_fixed_position { |
| 61 | NOT_FIXED, |
| 62 | FIXED_LOW, |
| 63 | FIXED_MIDDLE, |
| 64 | FIXED_HIGH, |
| 65 | }; |
| 66 | |
| 67 | enum cp_mem_usage { |
| 68 | VIDEO_BITSTREAM = 0x1, |
| 69 | VIDEO_PIXEL = 0x2, |
| 70 | VIDEO_NONPIXEL = 0x3, |
| 71 | DISPLAY_SECURE_CP_USAGE = 0x4, |
| 72 | CAMERA_SECURE_CP_USAGE = 0x5, |
| 73 | MAX_USAGE = 0x6, |
| 74 | UNKNOWN = 0x7FFFFFFF, |
| 75 | }; |
| 76 | |
| 77 | /** |
Patrick Daly | c1005d8 | 2016-09-22 17:43:26 -0700 | [diff] [blame] | 78 | * Flags to be used when allocating from the secure heap for |
| 79 | * content protection |
| 80 | */ |
Liam Mark | d9a5085 | 2016-09-22 11:30:51 -0700 | [diff] [blame] | 81 | #define ION_FLAG_CP_TOUCH ION_BIT(17) |
| 82 | #define ION_FLAG_CP_BITSTREAM ION_BIT(18) |
| 83 | #define ION_FLAG_CP_PIXEL ION_BIT(19) |
| 84 | #define ION_FLAG_CP_NON_PIXEL ION_BIT(20) |
| 85 | #define ION_FLAG_CP_CAMERA ION_BIT(21) |
| 86 | #define ION_FLAG_CP_HLOS ION_BIT(22) |
Sudarshan Rajagopalan | c934228 | 2017-05-18 00:11:06 -0700 | [diff] [blame] | 87 | #define ION_FLAG_CP_SPSS_SP ION_BIT(23) |
Sudarshan Rajagopalan | 8e20679 | 2017-06-28 17:45:57 -0700 | [diff] [blame] | 88 | #define ION_FLAG_CP_SPSS_SP_SHARED ION_BIT(24) |
Liam Mark | d9a5085 | 2016-09-22 11:30:51 -0700 | [diff] [blame] | 89 | #define ION_FLAG_CP_SEC_DISPLAY ION_BIT(25) |
| 90 | #define ION_FLAG_CP_APP ION_BIT(26) |
| 91 | #define ION_FLAG_CP_CAMERA_PREVIEW ION_BIT(27) |
Sudarshan Rajagopalan | e08afb6 | 2017-07-13 11:19:46 -0700 | [diff] [blame] | 92 | #define ION_FLAG_CP_SPSS_HLOS_SHARED ION_BIT(30) |
Liam Mark | d9a5085 | 2016-09-22 11:30:51 -0700 | [diff] [blame] | 93 | |
Patrick Daly | c1005d8 | 2016-09-22 17:43:26 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 96 | * Flag to use when allocating to indicate that a heap is secure. |
| 97 | * Do NOT use BIT macro since it is defined in #ifdef __KERNEL__ |
| 98 | */ |
Liam Mark | d9a5085 | 2016-09-22 11:30:51 -0700 | [diff] [blame] | 99 | #define ION_FLAG_SECURE ION_BIT(ION_HEAP_ID_RESERVED) |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 100 | |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 101 | /* |
| 102 | * Used in conjunction with heap which pool memory to force an allocation |
| 103 | * to come from the page allocator directly instead of from the pool allocation |
| 104 | */ |
Liam Mark | d9a5085 | 2016-09-22 11:30:51 -0700 | [diff] [blame] | 105 | #define ION_FLAG_POOL_FORCE_ALLOC ION_BIT(16) |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Deprecated! Please use the corresponding ION_FLAG_* |
| 109 | */ |
| 110 | #define ION_SECURE ION_FLAG_SECURE |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Macro should be used with ion_heap_ids defined above. |
| 114 | */ |
Liam Mark | d9a5085 | 2016-09-22 11:30:51 -0700 | [diff] [blame] | 115 | #define ION_HEAP(bit) ION_BIT(bit) |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 116 | |
| 117 | #define ION_ADSP_HEAP_NAME "adsp" |
| 118 | #define ION_SYSTEM_HEAP_NAME "system" |
| 119 | #define ION_VMALLOC_HEAP_NAME ION_SYSTEM_HEAP_NAME |
| 120 | #define ION_KMALLOC_HEAP_NAME "kmalloc" |
| 121 | #define ION_AUDIO_HEAP_NAME "audio" |
| 122 | #define ION_SF_HEAP_NAME "sf" |
| 123 | #define ION_MM_HEAP_NAME "mm" |
| 124 | #define ION_CAMERA_HEAP_NAME "camera_preview" |
| 125 | #define ION_IOMMU_HEAP_NAME "iommu" |
| 126 | #define ION_MFC_HEAP_NAME "mfc" |
Laura Abbott | 29defcc | 2014-08-01 16:13:40 -0700 | [diff] [blame] | 127 | #define ION_SPSS_HEAP_NAME "spss" |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 128 | #define ION_WB_HEAP_NAME "wb" |
| 129 | #define ION_MM_FIRMWARE_HEAP_NAME "mm_fw" |
| 130 | #define ION_PIL1_HEAP_NAME "pil_1" |
| 131 | #define ION_PIL2_HEAP_NAME "pil_2" |
| 132 | #define ION_QSECOM_HEAP_NAME "qsecom" |
Patrick Daly | c1005d8 | 2016-09-22 17:43:26 -0700 | [diff] [blame] | 133 | #define ION_SECURE_HEAP_NAME "secure_heap" |
Laura Abbott | 29defcc | 2014-08-01 16:13:40 -0700 | [diff] [blame] | 134 | #define ION_SECURE_DISPLAY_HEAP_NAME "secure_display" |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 135 | |
| 136 | #define ION_SET_CACHED(__cache) ((__cache) | ION_FLAG_CACHED) |
| 137 | #define ION_SET_UNCACHED(__cache) ((__cache) & ~ION_FLAG_CACHED) |
| 138 | |
| 139 | #define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED) |
| 140 | |
| 141 | /* struct ion_flush_data - data passed to ion for flushing caches |
| 142 | * |
| 143 | * @handle: handle with data to flush |
| 144 | * @fd: fd to flush |
| 145 | * @vaddr: userspace virtual address mapped with mmap |
| 146 | * @offset: offset into the handle to flush |
| 147 | * @length: length of handle to flush |
| 148 | * |
| 149 | * Performs cache operations on the handle. If p is the start address |
| 150 | * of the handle, p + offset through p + offset + length will have |
| 151 | * the cache operations performed |
| 152 | */ |
| 153 | struct ion_flush_data { |
| 154 | ion_user_handle_t handle; |
| 155 | int fd; |
| 156 | void *vaddr; |
| 157 | unsigned int offset; |
| 158 | unsigned int length; |
| 159 | }; |
| 160 | |
Laura Abbott | 29defcc | 2014-08-01 16:13:40 -0700 | [diff] [blame] | 161 | struct ion_prefetch_regions { |
| 162 | unsigned int vmid; |
| 163 | size_t __user *sizes; |
| 164 | unsigned int nr_sizes; |
| 165 | }; |
| 166 | |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 167 | struct ion_prefetch_data { |
| 168 | int heap_id; |
| 169 | unsigned long len; |
Laura Abbott | 29defcc | 2014-08-01 16:13:40 -0700 | [diff] [blame] | 170 | struct ion_prefetch_regions __user *regions; |
| 171 | unsigned int nr_regions; |
Patrick Daly | eeeb940 | 2016-11-01 20:54:41 -0700 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | #define ION_IOC_MSM_MAGIC 'M' |
| 175 | |
| 176 | /** |
| 177 | * DOC: ION_IOC_CLEAN_CACHES - clean the caches |
| 178 | * |
| 179 | * Clean the caches of the handle specified. |
| 180 | */ |
| 181 | #define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \ |
| 182 | struct ion_flush_data) |
| 183 | /** |
| 184 | * DOC: ION_IOC_INV_CACHES - invalidate the caches |
| 185 | * |
| 186 | * Invalidate the caches of the handle specified. |
| 187 | */ |
| 188 | #define ION_IOC_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 1, \ |
| 189 | struct ion_flush_data) |
| 190 | /** |
| 191 | * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches |
| 192 | * |
| 193 | * Clean and invalidate the caches of the handle specified. |
| 194 | */ |
| 195 | #define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \ |
| 196 | struct ion_flush_data) |
| 197 | |
| 198 | #define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ |
| 199 | struct ion_prefetch_data) |
| 200 | |
| 201 | #define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ |
| 202 | struct ion_prefetch_data) |
| 203 | |
| 204 | #endif |