Home | History | Annotate | Download | only in linux
      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_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 
     25 enum 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 
     52 enum ion_fixed_position {
     53 	NOT_FIXED,
     54 	FIXED_LOW,
     55 	FIXED_MIDDLE,
     56 	FIXED_HIGH,
     57 };
     58 
     59 enum 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 use when allocating to indicate that a heap is secure.
     71  */
     72 #define ION_FLAG_SECURE (1 << ION_HEAP_ID_RESERVED)
     73 
     74 /**
     75  * Flag for clients to force contiguous memort allocation
     76  *
     77  * Use of this flag is carefully monitored!
     78  */
     79 #define ION_FLAG_FORCE_CONTIGUOUS (1 << 30)
     80 
     81 /*
     82  * Used in conjunction with heap which pool memory to force an allocation
     83  * to come from the page allocator directly instead of from the pool allocation
     84  */
     85 #define ION_FLAG_POOL_FORCE_ALLOC (1 << 16)
     86 
     87 /**
     88 * Deprecated! Please use the corresponding ION_FLAG_*
     89 */
     90 #define ION_SECURE ION_FLAG_SECURE
     91 #define ION_FORCE_CONTIGUOUS ION_FLAG_FORCE_CONTIGUOUS
     92 
     93 /**
     94  * Macro should be used with ion_heap_ids defined above.
     95  */
     96 #define ION_HEAP(bit) (1 << (bit))
     97 
     98 #define ION_ADSP_HEAP_NAME	"adsp"
     99 #define ION_SYSTEM_HEAP_NAME	"system"
    100 #define ION_VMALLOC_HEAP_NAME	ION_SYSTEM_HEAP_NAME
    101 #define ION_KMALLOC_HEAP_NAME	"kmalloc"
    102 #define ION_AUDIO_HEAP_NAME	"audio"
    103 #define ION_SF_HEAP_NAME	"sf"
    104 #define ION_MM_HEAP_NAME	"mm"
    105 #define ION_CAMERA_HEAP_NAME	"camera_preview"
    106 #define ION_IOMMU_HEAP_NAME	"iommu"
    107 #define ION_MFC_HEAP_NAME	"mfc"
    108 #define ION_WB_HEAP_NAME	"wb"
    109 #define ION_MM_FIRMWARE_HEAP_NAME	"mm_fw"
    110 #define ION_PIL1_HEAP_NAME  "pil_1"
    111 #define ION_PIL2_HEAP_NAME  "pil_2"
    112 #define ION_QSECOM_HEAP_NAME	"qsecom"
    113 
    114 #define ION_SET_CACHED(__cache)		(__cache | ION_FLAG_CACHED)
    115 #define ION_SET_UNCACHED(__cache)	(__cache & ~ION_FLAG_CACHED)
    116 
    117 #define ION_IS_CACHED(__flags)	((__flags) & ION_FLAG_CACHED)
    118 
    119 /* struct ion_flush_data - data passed to ion for flushing caches
    120  *
    121  * @handle:	handle with data to flush
    122  * @fd:		fd to flush
    123  * @vaddr:	userspace virtual address mapped with mmap
    124  * @offset:	offset into the handle to flush
    125  * @length:	length of handle to flush
    126  *
    127  * Performs cache operations on the handle. If p is the start address
    128  * of the handle, p + offset through p + offset + length will have
    129  * the cache operations performed
    130  */
    131 struct ion_flush_data {
    132 	ion_user_handle_t handle;
    133 	int fd;
    134 	void *vaddr;
    135 	unsigned int offset;
    136 	unsigned int length;
    137 };
    138 
    139 
    140 struct ion_prefetch_data {
    141 	int heap_id;
    142 	unsigned long len;
    143 };
    144 
    145 #define ION_IOC_MSM_MAGIC 'M'
    146 
    147 /**
    148  * DOC: ION_IOC_CLEAN_CACHES - clean the caches
    149  *
    150  * Clean the caches of the handle specified.
    151  */
    152 #define ION_IOC_CLEAN_CACHES	_IOWR(ION_IOC_MSM_MAGIC, 0, \
    153 						struct ion_flush_data)
    154 /**
    155  * DOC: ION_IOC_INV_CACHES - invalidate the caches
    156  *
    157  * Invalidate the caches of the handle specified.
    158  */
    159 #define ION_IOC_INV_CACHES	_IOWR(ION_IOC_MSM_MAGIC, 1, \
    160 						struct ion_flush_data)
    161 /**
    162  * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches
    163  *
    164  * Clean and invalidate the caches of the handle specified.
    165  */
    166 #define ION_IOC_CLEAN_INV_CACHES	_IOWR(ION_IOC_MSM_MAGIC, 2, \
    167 						struct ion_flush_data)
    168 
    169 #define ION_IOC_PREFETCH		_IOWR(ION_IOC_MSM_MAGIC, 3, \
    170 						struct ion_prefetch_data)
    171 
    172 #define ION_IOC_DRAIN			_IOWR(ION_IOC_MSM_MAGIC, 4, \
    173 						struct ion_prefetch_data)
    174 
    175 #endif
    176