aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhnaradla <hanumantha.naradla@linaro.org>2014-07-09 17:22:26 +0530
committerhnaradla <hanumantha.naradla@linaro.org>2014-07-09 17:22:26 +0530
commita33cb3d4edc29b0b2306af553cc362b0365d5469 (patch)
tree2baf274db710543e26f29dbac0395458ffd413a9
parentcd8b9a06d8019752b0784fdb7037a8a518a132b1 (diff)
downloadvpb-a33cb3d4edc29b0b2306af553cc362b0365d5469.tar.gz
vidctest: Adopt ion functions signature changes.
- modetest app is modified as per ion signature changes for branch freedreno/ifc6410-v2.0-drm-next.
-rwxr-xr-xmodetest/buffers.c4
-rwxr-xr-xmodetest/ion.h312
2 files changed, 29 insertions, 287 deletions
diff --git a/modetest/buffers.c b/modetest/buffers.c
index 25dc847..7482afb 100755
--- a/modetest/buffers.c
+++ b/modetest/buffers.c
@@ -1028,9 +1028,9 @@ ion_allocate_buffer(unsigned int width, unsigned int height)
size = ALIGN(pitch * height, 0x1000);
alloc_data.len = size;
- alloc_data.flags = ION_HEAP(ION_IOMMU_HEAP_ID);
+ alloc_data.flags = ION_HEAP_TYPE_DMA_MASK;
alloc_data.align = 0x1000; // 2048;
- //alloc_data.heap_mask = 0x2000000;
+ alloc_data.heap_mask = 0x2000000;
rc = ioctl(ion_devicefd, ION_IOC_ALLOC, &alloc_data);
if (rc || !alloc_data.handle) {
diff --git a/modetest/ion.h b/modetest/ion.h
index 2519270..c32da12 100755
--- a/modetest/ion.h
+++ b/modetest/ion.h
@@ -2,7 +2,7 @@
* include/linux/ion.h
*
* Copyright (C) 2011 Google, Inc.
- * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -33,14 +33,14 @@ struct ion_handle;
* @ION_HEAP_TYPE_CP: memory allocated from a prereserved
* carveout heap, allocations are physically
* contiguous. Used for content protection.
+ * @ION_HEAP_TYPE_DMA: memory allocated via DMA API
* @ION_HEAP_END: helper for iterating over heaps
*/
enum ion_heap_type {
ION_HEAP_TYPE_SYSTEM,
ION_HEAP_TYPE_SYSTEM_CONTIG,
ION_HEAP_TYPE_CARVEOUT,
- ION_HEAP_TYPE_IOMMU,
- ION_HEAP_TYPE_CP,
+ ION_HEAP_TYPE_DMA,
ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always
are at the end of this enum */
ION_NUM_HEAPS,
@@ -49,86 +49,16 @@ enum ion_heap_type {
#define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM)
#define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
-#define ION_HEAP_CP_MASK (1 << ION_HEAP_TYPE_CP)
-
-
-/**
- * These are the only ids that should be used for Ion heap ids.
- * The ids listed are the order in which allocation will be attempted
- * if specified. Don't swap the order of heap ids unless you know what
- * you are doing!
- * Id's are spaced by purpose to allow new Id's to be inserted in-between (for
- * possible fallbacks)
- */
-
-enum ion_heap_ids {
- INVALID_HEAP_ID = -1,
- ION_CP_MM_HEAP_ID = 8,
- ION_CP_MFC_HEAP_ID = 12,
- ION_CP_WB_HEAP_ID = 16, /* 8660 only */
- ION_CAMERA_HEAP_ID = 20, /* 8660 only */
- ION_SF_HEAP_ID = 24,
- ION_IOMMU_HEAP_ID = 25,
- ION_QSECOM_HEAP_ID = 27,
- ION_AUDIO_HEAP_ID = 28,
-
- ION_MM_FIRMWARE_HEAP_ID = 29,
- ION_SYSTEM_HEAP_ID = 30,
-
- ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_SECURE flag */
-};
-
-enum ion_fixed_position {
- NOT_FIXED,
- FIXED_LOW,
- FIXED_MIDDLE,
- FIXED_HIGH,
-};
-
-enum cp_mem_usage {
- VIDEO_BITSTREAM = 0x1,
- VIDEO_PIXEL = 0x2,
- VIDEO_NONPIXEL = 0x3,
- MAX_USAGE = 0x4,
- UNKNOWN = 0x7FFFFFFF,
-};
-
-/**
- * Flag to use when allocating to indicate that a heap is secure.
- */
-#define ION_SECURE (1 << ION_HEAP_ID_RESERVED)
+#define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA)
/**
- * Macro should be used with ion_heap_ids defined above.
- */
-#define ION_HEAP(bit) (1 << (bit))
-
-#define ION_VMALLOC_HEAP_NAME "vmalloc"
-#define ION_AUDIO_HEAP_NAME "audio"
-#define ION_SF_HEAP_NAME "sf"
-#define ION_MM_HEAP_NAME "mm"
-#define ION_CAMERA_HEAP_NAME "camera_preview"
-#define ION_IOMMU_HEAP_NAME "iommu"
-#define ION_MFC_HEAP_NAME "mfc"
-#define ION_WB_HEAP_NAME "wb"
-#define ION_MM_FIRMWARE_HEAP_NAME "mm_fw"
-#define ION_QSECOM_HEAP_NAME "qsecom"
-#define ION_FMEM_HEAP_NAME "fmem"
-
-#define CACHED 1
-#define UNCACHED 0
-
-#define ION_CACHE_SHIFT 0
-
-#define ION_SET_CACHE(__cache) ((__cache) << ION_CACHE_SHIFT)
-
-#define ION_IS_CACHED(__flags) ((__flags) & (1 << ION_CACHE_SHIFT))
-
-/*
- * This flag allows clients when mapping into the IOMMU to specify to
- * defer un-mapping from the IOMMU until the buffer memory is freed.
+ * heap flags - the lower 16 bits are used by core ion, the upper 16
+ * bits are reserved for use by the heaps themselves.
*/
-#define ION_IOMMU_UNMAP_DELAYED 1
+#define ION_FLAG_CACHED 1 /* mappings of this buffer should be
+ cached, ion will do cache
+ maintenance when the buffer is
+ mapped for dma */
#ifdef __KERNEL__
#include <linux/err.h>
@@ -157,6 +87,7 @@ struct ion_buffer;
* @memory_type:Memory type used for the heap
* @has_outer_cache: set to 1 if outer cache is used, 0 otherwise.
* @extra_data: Extra data specific to each heap type
+ * @priv: heap private data
*/
struct ion_platform_heap {
enum ion_heap_type type;
@@ -167,72 +98,7 @@ struct ion_platform_heap {
enum ion_memory_types memory_type;
unsigned int has_outer_cache;
void *extra_data;
-};
-
-/**
- * struct ion_cp_heap_pdata - defines a content protection heap in the given
- * platform
- * @permission_type: Memory ID used to identify the memory to TZ
- * @align: Alignment requirement for the memory
- * @secure_base: Base address for securing the heap.
- * Note: This might be different from actual base address
- * of this heap in the case of a shared heap.
- * @secure_size: Memory size for securing the heap.
- * Note: This might be different from actual size
- * of this heap in the case of a shared heap.
- * @reusable Flag indicating whether this heap is reusable of not.
- * (see FMEM)
- * @mem_is_fmem Flag indicating whether this memory is coming from fmem
- * or not.
- * @fixed_position If nonzero, position in the fixed area.
- * @virt_addr: Virtual address used when using fmem.
- * @iommu_map_all: Indicates whether we should map whole heap into IOMMU.
- * @iommu_2x_map_domain: Indicates the domain to use for overmapping.
- * @request_region: function to be called when the number of allocations
- * goes from 0 -> 1
- * @release_region: function to be called when the number of allocations
- * goes from 1 -> 0
- * @setup_region: function to be called upon ion registration
- *
- */
-struct ion_cp_heap_pdata {
- enum ion_permission_type permission_type;
- unsigned int align;
- ion_phys_addr_t secure_base; /* Base addr used when heap is shared */
- size_t secure_size; /* Size used for securing heap when heap is shared*/
- int reusable;
- int mem_is_fmem;
- enum ion_fixed_position fixed_position;
- int iommu_map_all;
- int iommu_2x_map_domain;
- ion_virt_addr_t *virt_addr;
- int (*request_region)(void *);
- int (*release_region)(void *);
- void *(*setup_region)(void);
-};
-
-/**
- * struct ion_co_heap_pdata - defines a carveout heap in the given platform
- * @adjacent_mem_id: Id of heap that this heap must be adjacent to.
- * @align: Alignment requirement for the memory
- * @mem_is_fmem Flag indicating whether this memory is coming from fmem
- * or not.
- * @fixed_position If nonzero, position in the fixed area.
- * @request_region: function to be called when the number of allocations
- * goes from 0 -> 1
- * @release_region: function to be called when the number of allocations
- * goes from 1 -> 0
- * @setup_region: function to be called upon ion registration
- *
- */
-struct ion_co_heap_pdata {
- int adjacent_mem_id;
- unsigned int align;
- int mem_is_fmem;
- enum ion_fixed_position fixed_position;
- int (*request_region)(void *);
- int (*release_region)(void *);
- void *(*setup_region)(void);
+ void *priv;
};
/**
@@ -254,7 +120,7 @@ struct ion_platform_data {
int (*request_region)(void *);
int (*release_region)(void *);
void *(*setup_region)(void);
- struct ion_platform_heap heaps[];
+ struct ion_platform_heap *heaps;
};
#ifdef CONFIG_ION
@@ -305,14 +171,18 @@ void ion_client_destroy(struct ion_client *client);
* @len: size of the allocation
* @align: requested allocation alignment, lots of hardware blocks have
* alignment requirements of some kind
- * @flags: mask of heaps to allocate from, if multiple bits are set
+ * @heap_mask: mask of heaps to allocate from, if multiple bits are set
* heaps will be tried in order from lowest to highest order bit
+ * @flags: heap flags, the low 16 bits are consumed by ion, the high 16
+ * bits are passed on to the respective heap and can be heap
+ * custom
*
* Allocate memory in one of the heaps provided in heap mask and return
* an opaque handle to it.
*/
struct ion_handle *ion_alloc(struct ion_client *client, size_t len,
- size_t align, unsigned int flags);
+ size_t align, unsigned int heap_mask,
+ unsigned int flags);
/**
* ion_free - free a handle
@@ -363,8 +233,7 @@ struct sg_table *ion_sg_table(struct ion_client *client,
* can be used to access this address. If no flags are specified, this
* will return a non-secure uncached mapping.
*/
-void *ion_map_kernel(struct ion_client *client, struct ion_handle *handle,
- unsigned long flags);
+void *ion_map_kernel(struct ion_client *client, struct ion_handle *handle);
/**
* ion_unmap_kernel() - destroy a kernel mapping for a handle
@@ -493,50 +362,6 @@ int ion_unsecure_heap(struct ion_device *dev, int heap_id, int version,
void *data);
/**
- * msm_ion_secure_heap - secure a heap. Wrapper around ion_secure_heap.
- *
- * @heap_id - heap id to secure.
- *
- * Secure a heap
- * Returns 0 on success
- */
-int msm_ion_secure_heap(int heap_id);
-
-/**
- * msm_ion_unsecure_heap - unsecure a heap. Wrapper around ion_unsecure_heap.
- *
- * @heap_id - heap id to secure.
- *
- * Un-secure a heap
- * Returns 0 on success
- */
-int msm_ion_unsecure_heap(int heap_id);
-
-/**
- * msm_ion_secure_heap_2_0 - secure a heap using 2.0 APIs
- * Wrapper around ion_secure_heap.
- *
- * @heap_id - heap id to secure.
- * @usage - usage hint to TZ
- *
- * Secure a heap
- * Returns 0 on success
- */
-int msm_ion_secure_heap_2_0(int heap_id, enum cp_mem_usage usage);
-
-/**
- * msm_ion_unsecure_heap - unsecure a heap secured with 3.0 APIs.
- * Wrapper around ion_unsecure_heap.
- *
- * @heap_id - heap id to secure.
- * @usage - usage hint to TZ
- *
- * Un-secure a heap
- * Returns 0 on success
- */
-int msm_ion_unsecure_heap_2_0(int heap_id, enum cp_mem_usage usage);
-
-/**
* msm_ion_do_cache_op - do cache operations.
*
* @client - pointer to ION client.
@@ -574,7 +399,9 @@ static inline struct ion_client *msm_ion_client_create(unsigned int heap_mask,
static inline void ion_client_destroy(struct ion_client *client) { }
static inline struct ion_handle *ion_alloc(struct ion_client *client,
- size_t len, size_t align, unsigned int flags)
+ size_t len, size_t align,
+ unsigned int heap_mask,
+ unsigned int flags)
{
return ERR_PTR(-ENODEV);
}
@@ -596,7 +423,7 @@ static inline struct sg_table *ion_sg_table(struct ion_client *client,
}
static inline void *ion_map_kernel(struct ion_client *client,
- struct ion_handle *handle, unsigned long flags)
+ struct ion_handle *handle)
{
return ERR_PTR(-ENODEV);
}
@@ -651,28 +478,6 @@ static inline int ion_unsecure_heap(struct ion_device *dev, int heap_id,
return -ENODEV;
}
-static inline int msm_ion_secure_heap(int heap_id)
-{
- return -ENODEV;
-
-}
-
-static inline int msm_ion_unsecure_heap(int heap_id)
-{
- return -ENODEV;
-}
-
-static inline int msm_ion_secure_heap_2_0(int heap_id, enum cp_mem_usage usage)
-{
- return -ENODEV;
-}
-
-static inline int msm_ion_unsecure_heap_2_0(int heap_id,
- enum cp_mem_usage usage)
-{
- return -ENODEV;
-}
-
static inline int msm_ion_do_cache_op(struct ion_client *client,
struct ion_handle *handle, void *vaddr,
unsigned long len, unsigned int cmd)
@@ -695,6 +500,7 @@ static inline int msm_ion_do_cache_op(struct ion_client *client,
* struct ion_allocation_data - metadata passed from userspace for allocations
* @len: size of the allocation
* @align: required alignment of the allocation
+ * @heap_mask: mask of heaps to allocate from
* @flags: flags passed to heap
* @handle: pointer that will be populated with a cookie to use to refer
* to this allocation
@@ -704,6 +510,7 @@ static inline int msm_ion_do_cache_op(struct ion_client *client,
struct ion_allocation_data {
size_t len;
size_t align;
+ unsigned int heap_mask;
unsigned int flags;
struct ion_handle *handle;
};
@@ -743,41 +550,6 @@ struct ion_custom_data {
unsigned int cmd;
unsigned long arg;
};
-
-
-/* struct ion_flush_data - data passed to ion for flushing caches
- *
- * @handle: handle with data to flush
- * @fd: fd to flush
- * @vaddr: userspace virtual address mapped with mmap
- * @offset: offset into the handle to flush
- * @length: length of handle to flush
- *
- * Performs cache operations on the handle. If p is the start address
- * of the handle, p + offset through p + offset + length will have
- * the cache operations performed
- */
-struct ion_flush_data {
- struct ion_handle *handle;
- int fd;
- void *vaddr;
- unsigned int offset;
- unsigned int length;
-};
-
-/* struct ion_flag_data - information about flags for this buffer
- *
- * @handle: handle to get flags from
- * @flags: flags of this handle
- *
- * Takes handle as an input and outputs the flags from the handle
- * in the flag field.
- */
-struct ion_flag_data {
- struct ion_handle *handle;
- unsigned long flags;
-};
-
#define ION_IOC_MAGIC 'I'
/**
@@ -824,7 +596,7 @@ struct ion_flag_data {
* descriptor obtained from ION_IOC_SHARE and returns the struct with the handle
* filed set to the corresponding opaque handle.
*/
-#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, int)
+#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
/**
* DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl
@@ -835,34 +607,4 @@ struct ion_flag_data {
#define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
-/**
- * DOC: ION_IOC_CLEAN_CACHES - clean the caches
- *
- * Clean the caches of the handle specified.
- */
-#define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MAGIC, 7, \
- struct ion_flush_data)
-/**
- * DOC: ION_MSM_IOC_INV_CACHES - invalidate the caches
- *
- * Invalidate the caches of the handle specified.
- */
-#define ION_IOC_INV_CACHES _IOWR(ION_IOC_MAGIC, 8, \
- struct ion_flush_data)
-/**
- * DOC: ION_MSM_IOC_CLEAN_CACHES - clean and invalidate the caches
- *
- * Clean and invalidate the caches of the handle specified.
- */
-#define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MAGIC, 9, \
- struct ion_flush_data)
-
-/**
- * DOC: ION_IOC_GET_FLAGS - get the flags of the handle
- *
- * Gets the flags of the current handle which indicate cachability,
- * secure state etc.
- */
-#define ION_IOC_GET_FLAGS _IOWR(ION_IOC_MAGIC, 10, \
- struct ion_flag_data)
#endif /* _LINUX_ION_H */