1#ifndef _UAPI_MSM_ION_H
2#define _UAPI_MSM_ION_H
3
4#include "ion.h"
5
6enum 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
26enum 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
55enum ion_fixed_position {
56	NOT_FIXED,
57	FIXED_LOW,
58	FIXED_MIDDLE,
59	FIXED_HIGH,
60};
61
62enum 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* Deprecated! Please use the corresponding ION_FLAG_*
112*/
113#define ION_SECURE ION_FLAG_SECURE
114#define ION_FORCE_CONTIGUOUS ION_FLAG_FORCE_CONTIGUOUS
115
116/**
117 * Macro should be used with ion_heap_ids defined above.
118 */
119#define ION_HEAP(bit) (1 << (bit))
120
121#define ION_ADSP_HEAP_NAME	"adsp"
122#define ION_SYSTEM_HEAP_NAME	"system"
123#define ION_VMALLOC_HEAP_NAME	ION_SYSTEM_HEAP_NAME
124#define ION_KMALLOC_HEAP_NAME	"kmalloc"
125#define ION_AUDIO_HEAP_NAME	"audio"
126#define ION_SF_HEAP_NAME	"sf"
127#define ION_MM_HEAP_NAME	"mm"
128#define ION_CAMERA_HEAP_NAME	"camera_preview"
129#define ION_IOMMU_HEAP_NAME	"iommu"
130#define ION_MFC_HEAP_NAME	"mfc"
131#define ION_WB_HEAP_NAME	"wb"
132#define ION_MM_FIRMWARE_HEAP_NAME	"mm_fw"
133#define ION_PIL1_HEAP_NAME  "pil_1"
134#define ION_PIL2_HEAP_NAME  "pil_2"
135#define ION_QSECOM_HEAP_NAME	"qsecom"
136#define ION_SECURE_HEAP_NAME	"secure_heap"
137#define ION_SECURE_DISPLAY_HEAP_NAME "secure_display"
138
139#define ION_SET_CACHED(__cache)		(__cache | ION_FLAG_CACHED)
140#define ION_SET_UNCACHED(__cache)	(__cache & ~ION_FLAG_CACHED)
141
142#define ION_IS_CACHED(__flags)	((__flags) & ION_FLAG_CACHED)
143
144/* struct ion_flush_data - data passed to ion for flushing caches
145 *
146 * @handle:	handle with data to flush
147 * @fd:		fd to flush
148 * @vaddr:	userspace virtual address mapped with mmap
149 * @offset:	offset into the handle to flush
150 * @length:	length of handle to flush
151 *
152 * Performs cache operations on the handle. If p is the start address
153 * of the handle, p + offset through p + offset + length will have
154 * the cache operations performed
155 */
156struct ion_flush_data {
157	ion_user_handle_t handle;
158	int fd;
159	void *vaddr;
160	unsigned int offset;
161	unsigned int length;
162};
163
164
165struct ion_prefetch_data {
166	int heap_id;
167	unsigned long len;
168};
169
170#define ION_IOC_MSM_MAGIC 'M'
171
172/**
173 * DOC: ION_IOC_CLEAN_CACHES - clean the caches
174 *
175 * Clean the caches of the handle specified.
176 */
177#define ION_IOC_CLEAN_CACHES	_IOWR(ION_IOC_MSM_MAGIC, 0, \
178						struct ion_flush_data)
179/**
180 * DOC: ION_IOC_INV_CACHES - invalidate the caches
181 *
182 * Invalidate the caches of the handle specified.
183 */
184#define ION_IOC_INV_CACHES	_IOWR(ION_IOC_MSM_MAGIC, 1, \
185						struct ion_flush_data)
186/**
187 * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches
188 *
189 * Clean and invalidate the caches of the handle specified.
190 */
191#define ION_IOC_CLEAN_INV_CACHES	_IOWR(ION_IOC_MSM_MAGIC, 2, \
192						struct ion_flush_data)
193
194#define ION_IOC_PREFETCH		_IOWR(ION_IOC_MSM_MAGIC, 3, \
195						struct ion_prefetch_data)
196
197#define ION_IOC_DRAIN			_IOWR(ION_IOC_MSM_MAGIC, 4, \
198						struct ion_prefetch_data)
199
200#endif
201