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