1 #ifndef _UAPI_MSM_ION_H 2 #define _UAPI_MSM_ION_H 3 4 #include "ion.h" 5 6 enum msm_ion_heap_types { 7 ION_HEAP_TYPE_MSM_START = ION_HEAP_TYPE_CUSTOM + 1, 8 ION_HEAP_TYPE_DMA = ION_HEAP_TYPE_MSM_START, 9 ION_HEAP_TYPE_SECURE_DMA, 10 ION_HEAP_TYPE_REMOVED, 11 /* 12 * if you add a heap type here you should also add it to 13 * heap_types_info[] in msm_ion.c 14 */ 15 }; 16 17 /** 18 * These are the only ids that should be used for Ion heap ids. 19 * The ids listed are the order in which allocation will be attempted 20 * if specified. Don't swap the order of heap ids unless you know what 21 * you are doing! 22 * Id's are spaced by purpose to allow new Id's to be inserted in-between (for 23 * possible fallbacks) 24 */ 25 26 enum ion_heap_ids { 27 INVALID_HEAP_ID = -1, 28 ION_CP_MM_HEAP_ID = 8, 29 ION_CP_MFC_HEAP_ID = 12, 30 ION_CP_WB_HEAP_ID = 16, /* 8660 only */ 31 ION_CAMERA_HEAP_ID = 20, /* 8660 only */ 32 ION_SYSTEM_CONTIG_HEAP_ID = 21, 33 ION_ADSP_HEAP_ID = 22, 34 ION_PIL1_HEAP_ID = 23, /* Currently used for other PIL images */ 35 ION_SF_HEAP_ID = 24, 36 ION_SYSTEM_HEAP_ID = 25, 37 ION_PIL2_HEAP_ID = 26, /* Currently used for modem firmware images */ 38 ION_QSECOM_HEAP_ID = 27, 39 ION_AUDIO_HEAP_ID = 28, 40 41 ION_MM_FIRMWARE_HEAP_ID = 29, 42 43 ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ 44 }; 45 46 /* 47 * The IOMMU heap is deprecated! Here are some aliases for backwards 48 * compatibility: 49 */ 50 #define ION_IOMMU_HEAP_ID ION_SYSTEM_HEAP_ID 51 #define ION_HEAP_TYPE_IOMMU ION_HEAP_TYPE_SYSTEM 52 53 enum ion_fixed_position { 54 NOT_FIXED, 55 FIXED_LOW, 56 FIXED_MIDDLE, 57 FIXED_HIGH, 58 }; 59 60 enum cp_mem_usage { 61 VIDEO_BITSTREAM = 0x1, 62 VIDEO_PIXEL = 0x2, 63 VIDEO_NONPIXEL = 0x3, 64 DISPLAY_SECURE_CP_USAGE = 0x4, 65 CAMERA_SECURE_CP_USAGE = 0x5, 66 MAX_USAGE = 0x6, 67 UNKNOWN = 0x7FFFFFFF, 68 }; 69 70 #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) 71 72 /** 73 * Flag to use when allocating to indicate that a heap is secure. 74 */ 75 #define ION_FLAG_SECURE (1 << ION_HEAP_ID_RESERVED) 76 77 /** 78 * Flag for clients to force contiguous memort allocation 79 * 80 * Use of this flag is carefully monitored! 81 */ 82 #define ION_FLAG_FORCE_CONTIGUOUS (1 << 30) 83 84 /* 85 * Used in conjunction with heap which pool memory to force an allocation 86 * to come from the page allocator directly instead of from the pool allocation 87 */ 88 #define ION_FLAG_POOL_FORCE_ALLOC (1 << 16) 89 90 /** 91 * Deprecated! Please use the corresponding ION_FLAG_* 92 */ 93 #define ION_SECURE ION_FLAG_SECURE 94 #define ION_FORCE_CONTIGUOUS ION_FLAG_FORCE_CONTIGUOUS 95 96 /** 97 * Macro should be used with ion_heap_ids defined above. 98 */ 99 #define ION_HEAP(bit) (1 << (bit)) 100 101 #define ION_ADSP_HEAP_NAME "adsp" 102 #define ION_SYSTEM_HEAP_NAME "system" 103 #define ION_VMALLOC_HEAP_NAME ION_SYSTEM_HEAP_NAME 104 #define ION_KMALLOC_HEAP_NAME "kmalloc" 105 #define ION_AUDIO_HEAP_NAME "audio" 106 #define ION_SF_HEAP_NAME "sf" 107 #define ION_MM_HEAP_NAME "mm" 108 #define ION_CAMERA_HEAP_NAME "camera_preview" 109 #define ION_IOMMU_HEAP_NAME "iommu" 110 #define ION_MFC_HEAP_NAME "mfc" 111 #define ION_WB_HEAP_NAME "wb" 112 #define ION_MM_FIRMWARE_HEAP_NAME "mm_fw" 113 #define ION_PIL1_HEAP_NAME "pil_1" 114 #define ION_PIL2_HEAP_NAME "pil_2" 115 #define ION_QSECOM_HEAP_NAME "qsecom" 116 117 #define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED) 118 #define ION_SET_UNCACHED(__cache) (__cache & ~ION_FLAG_CACHED) 119 120 #define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED) 121 122 /* struct ion_flush_data - data passed to ion for flushing caches 123 * 124 * @handle: handle with data to flush 125 * @fd: fd to flush 126 * @vaddr: userspace virtual address mapped with mmap 127 * @offset: offset into the handle to flush 128 * @length: length of handle to flush 129 * 130 * Performs cache operations on the handle. If p is the start address 131 * of the handle, p + offset through p + offset + length will have 132 * the cache operations performed 133 */ 134 struct ion_flush_data { 135 ion_user_handle_t handle; 136 int fd; 137 void *vaddr; 138 unsigned int offset; 139 unsigned int length; 140 }; 141 142 143 struct ion_prefetch_data { 144 int heap_id; 145 unsigned long len; 146 }; 147 148 #define ION_IOC_MSM_MAGIC 'M' 149 150 /** 151 * DOC: ION_IOC_CLEAN_CACHES - clean the caches 152 * 153 * Clean the caches of the handle specified. 154 */ 155 #define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \ 156 struct ion_flush_data) 157 /** 158 * DOC: ION_IOC_INV_CACHES - invalidate the caches 159 * 160 * Invalidate the caches of the handle specified. 161 */ 162 #define ION_IOC_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 1, \ 163 struct ion_flush_data) 164 /** 165 * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches 166 * 167 * Clean and invalidate the caches of the handle specified. 168 */ 169 #define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \ 170 struct ion_flush_data) 171 172 #define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ 173 struct ion_prefetch_data) 174 175 #define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ 176 struct ion_prefetch_data) 177 178 #endif 179