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