1 #ifndef _MSM_ION_H 2 #define _MSM_ION_H 3 4 #include "ion.h" 5 6 #define ION_BIT(nr) (1UL << (nr)) 7 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, 11 ION_HEAP_TYPE_SYSTEM_SECURE, 12 ION_HEAP_TYPE_HYP_CMA, 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, 31 ION_SECURE_HEAP_ID = 9, 32 ION_SECURE_DISPLAY_HEAP_ID = 10, 33 ION_CP_MFC_HEAP_ID = 12, 34 ION_SPSS_HEAP_ID = 13, /* Secure Processor ION heap */ 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 ION_GOOGLE_HEAP_ID = 30, 48 49 ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ 50 }; 51 52 /* 53 * The IOMMU heap is deprecated! Here are some aliases for backwards 54 * compatibility: 55 */ 56 #define ION_IOMMU_HEAP_ID ION_SYSTEM_HEAP_ID 57 #define ION_HEAP_TYPE_IOMMU ION_HEAP_TYPE_SYSTEM 58 59 #define ION_SPSS_HEAP_ID ION_SPSS_HEAP_ID 60 61 enum ion_fixed_position { 62 NOT_FIXED, 63 FIXED_LOW, 64 FIXED_MIDDLE, 65 FIXED_HIGH, 66 }; 67 68 enum cp_mem_usage { 69 VIDEO_BITSTREAM = 0x1, 70 VIDEO_PIXEL = 0x2, 71 VIDEO_NONPIXEL = 0x3, 72 DISPLAY_SECURE_CP_USAGE = 0x4, 73 CAMERA_SECURE_CP_USAGE = 0x5, 74 MAX_USAGE = 0x6, 75 UNKNOWN = 0x7FFFFFFF, 76 }; 77 78 /** 79 * Flags to be used when allocating from the secure heap for 80 * content protection 81 */ 82 #define ION_FLAG_CP_TOUCH ION_BIT(17) 83 #define ION_FLAG_CP_BITSTREAM ION_BIT(18) 84 #define ION_FLAG_CP_PIXEL ION_BIT(19) 85 #define ION_FLAG_CP_NON_PIXEL ION_BIT(20) 86 #define ION_FLAG_CP_CAMERA ION_BIT(21) 87 #define ION_FLAG_CP_HLOS ION_BIT(22) 88 #define ION_FLAG_CP_HLOS_FREE ION_BIT(23) 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) 92 93 94 /** 95 * Flag to allow non continguous allocation of memory from secure 96 * heap 97 */ 98 #define ION_FLAG_ALLOW_NON_CONTIG ION_BIT(24) 99 100 /** 101 * Flag to use when allocating to indicate that a heap is secure. 102 */ 103 #define ION_FLAG_SECURE ION_BIT(ION_HEAP_ID_RESERVED) 104 105 /** 106 * Flag for clients to force contiguous memort allocation 107 * 108 * Use of this flag is carefully monitored! 109 */ 110 #define ION_FLAG_FORCE_CONTIGUOUS ION_BIT(30) 111 112 /* 113 * Used in conjunction with heap which pool memory to force an allocation 114 * to come from the page allocator directly instead of from the pool allocation 115 */ 116 #define ION_FLAG_POOL_FORCE_ALLOC ION_BIT(16) 117 118 /** 119 * Deprecated! Please use the corresponding ION_FLAG_* 120 */ 121 #define ION_SECURE ION_FLAG_SECURE 122 #define ION_FORCE_CONTIGUOUS ION_FLAG_FORCE_CONTIGUOUS 123 124 /** 125 * Macro should be used with ion_heap_ids defined above. 126 */ 127 #define ION_HEAP(bit) ION_BIT(bit) 128 129 #define ION_ADSP_HEAP_NAME "adsp" 130 #define ION_SYSTEM_HEAP_NAME "system" 131 #define ION_VMALLOC_HEAP_NAME ION_SYSTEM_HEAP_NAME 132 #define ION_KMALLOC_HEAP_NAME "kmalloc" 133 #define ION_AUDIO_HEAP_NAME "audio" 134 #define ION_SF_HEAP_NAME "sf" 135 #define ION_MM_HEAP_NAME "mm" 136 #define ION_CAMERA_HEAP_NAME "camera_preview" 137 #define ION_IOMMU_HEAP_NAME "iommu" 138 #define ION_MFC_HEAP_NAME "mfc" 139 #define ION_SPSS_HEAP_NAME "spss" 140 #define ION_WB_HEAP_NAME "wb" 141 #define ION_MM_FIRMWARE_HEAP_NAME "mm_fw" 142 #define ION_GOOGLE_HEAP_NAME "easel_mem" 143 #define ION_PIL1_HEAP_NAME "pil_1" 144 #define ION_PIL2_HEAP_NAME "pil_2" 145 #define ION_QSECOM_HEAP_NAME "qsecom" 146 #define ION_SECURE_HEAP_NAME "secure_heap" 147 #define ION_SECURE_DISPLAY_HEAP_NAME "secure_display" 148 149 #define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED) 150 #define ION_SET_UNCACHED(__cache) (__cache & ~ION_FLAG_CACHED) 151 152 #define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED) 153 154 /* struct ion_flush_data - data passed to ion for flushing caches 155 * 156 * @handle: handle with data to flush 157 * @fd: fd to flush 158 * @vaddr: userspace virtual address mapped with mmap 159 * @offset: offset into the handle to flush 160 * @length: length of handle to flush 161 * 162 * Performs cache operations on the handle. If p is the start address 163 * of the handle, p + offset through p + offset + length will have 164 * the cache operations performed 165 */ 166 struct ion_flush_data { 167 ion_user_handle_t handle; 168 int fd; 169 void *vaddr; 170 unsigned int offset; 171 unsigned int length; 172 }; 173 174 struct ion_prefetch_regions { 175 unsigned int vmid; 176 size_t *sizes; 177 unsigned int nr_sizes; 178 }; 179 180 struct ion_prefetch_data { 181 int heap_id; 182 unsigned long len; 183 struct ion_prefetch_regions *regions; 184 unsigned int nr_regions; 185 }; 186 187 #define ION_IOC_MSM_MAGIC 'M' 188 189 /** 190 * DOC: ION_IOC_CLEAN_CACHES - clean the caches 191 * 192 * Clean the caches of the handle specified. 193 */ 194 #define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \ 195 struct ion_flush_data) 196 /** 197 * DOC: ION_IOC_INV_CACHES - invalidate the caches 198 * 199 * Invalidate the caches of the handle specified. 200 */ 201 #define ION_IOC_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 1, \ 202 struct ion_flush_data) 203 /** 204 * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches 205 * 206 * Clean and invalidate the caches of the handle specified. 207 */ 208 #define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \ 209 struct ion_flush_data) 210 211 #define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ 212 struct ion_prefetch_data) 213 214 #define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ 215 struct ion_prefetch_data) 216 217 #endif 218