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