Commit e458191f authored by Jens Kuske's avatar Jens Kuske
Browse files

Update ION headers to support AArch64

These headers are from 3.10, but are compatible with 3.4 too.
parent 85cbc027
......@@ -31,7 +31,7 @@ struct ion_mem
{
struct cedrus_mem pub;
struct ion_handle *handle;
ion_user_handle_t handle;
int fd;
};
......@@ -42,22 +42,22 @@ struct ion_allocator
int fd;
};
static struct ion_handle *ion_alloc(int ion_fd, size_t size)
static ion_user_handle_t ion_alloc(int ion_fd, size_t size)
{
struct ion_allocation_data allocation_data = {
.len = size,
.align = 4096,
.heap_id_mask = ION_HEAP_TYPE_DMA,
.heap_id_mask = ION_HEAP_TYPE_DMA_MASK,
.flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC,
};
if (ioctl(ion_fd, ION_IOC_ALLOC, &allocation_data))
return NULL;
return 0;
return allocation_data.handle;
}
static int ion_map(int ion_fd, struct ion_handle *ion_handle)
static int ion_map(int ion_fd, ion_user_handle_t ion_handle)
{
struct ion_fd_data fd_data = {
.handle = ion_handle,
......@@ -69,7 +69,7 @@ static int ion_map(int ion_fd, struct ion_handle *ion_handle)
return fd_data.fd;
}
static uint32_t ion_get_phys_addr(int ion_fd, struct ion_handle *ion_handle)
static uint32_t ion_get_phys_addr(int ion_fd, ion_user_handle_t ion_handle)
{
sunxi_phys_data phys_data = {
.handle = ion_handle,
......@@ -104,7 +104,7 @@ static int ion_flush_cache(int ion_fd, void *addr, size_t size)
return 1;
}
static int ion_free(int ion_fd, struct ion_handle *ion_handle)
static int ion_free(int ion_fd, ion_user_handle_t ion_handle)
{
struct ion_handle_data handle_data = {
.handle = ion_handle,
......
/*
* include/linux/ion.h
* drivers/staging/android/uapi/ion.h
*
* Copyright (C) 2011 Google, Inc.
*
......@@ -14,13 +14,14 @@
*
*/
#ifndef _LINUX_ION_H
#define _LINUX_ION_H
#ifndef _UAPI_LINUX_ION_H
#define _UAPI_LINUX_ION_H
#include <stdlib.h>
#include <linux/ioctl.h>
#include <linux/types.h>
struct ion_handle;
typedef int ion_user_handle_t;
/**
* enum ion_heap_types - list of all possible types of heaps
* @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc
......@@ -63,188 +64,6 @@ enum ion_heap_type {
at mmap time, if this is set
caches must be managed manually */
#ifdef __KERNEL__
struct ion_device;
struct ion_heap;
struct ion_mapper;
struct ion_client;
struct ion_buffer;
/* This should be removed some day when phys_addr_t's are fully
plumbed in the kernel, and all instances of ion_phys_addr_t should
be converted to phys_addr_t. For the time being many kernel interfaces
do not accept phys_addr_t's that would have to */
#define ion_phys_addr_t unsigned long
/**
* struct ion_platform_heap - defines a heap in the given platform
* @type: type of the heap from ion_heap_type enum
* @id: unique identifier for heap. When allocating higher numbers
* will be allocated from first. At allocation these are passed
* as a bit mask and therefore can not exceed ION_NUM_HEAP_IDS.
* @name: used for debug purposes
* @base: base address of heap in physical memory if applicable
* @size: size of the heap in bytes if applicable
* @align: required alignment in physical memory if applicable
* @priv: private info passed from the board file
*
* Provided by the board file.
*/
struct ion_platform_heap {
enum ion_heap_type type;
unsigned int id;
const char *name;
ion_phys_addr_t base;
size_t size;
ion_phys_addr_t align;
void *priv;
};
/**
* struct ion_platform_data - array of platform heaps passed from board file
* @nr: number of structures in the array
* @heaps: array of platform_heap structions
*
* Provided by the board file in the form of platform data to a platform device.
*/
struct ion_platform_data {
int nr;
struct ion_platform_heap heaps[];
};
/**
* ion_reserve() - reserve memory for ion heaps if applicable
* @data: platform data specifying starting physical address and
* size
*
* Calls memblock reserve to set aside memory for heaps that are
* located at specific memory addresses or of specfic sizes not
* managed by the kernel
*/
void ion_reserve(struct ion_platform_data *data);
/**
* ion_client_create() - allocate a client and returns it
* @dev: the global ion device
* @heap_type_mask: mask of heaps this client can allocate from
* @name: used for debugging
*/
struct ion_client *ion_client_create(struct ion_device *dev,
const char *name);
/**
* ion_client_destroy() - free's a client and all it's handles
* @client: the client
*
* Free the provided client and all it's resources including
* any handles it is holding.
*/
void ion_client_destroy(struct ion_client *client);
/**
* ion_alloc - allocate ion memory
* @client: the client
* @len: size of the allocation
* @align: requested allocation alignment, lots of hardware blocks
* have alignment requirements of some kind
* @heap_id_mask: mask of heaps to allocate from, if multiple bits are set
* heaps will be tried in order from highest to lowest
* id
* @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 heap_id_mask,
unsigned int flags);
/**
* ion_free - free a handle
* @client: the client
* @handle: the handle to free
*
* Free the provided handle.
*/
void ion_free(struct ion_client *client, struct ion_handle *handle);
/**
* ion_phys - returns the physical address and len of a handle
* @client: the client
* @handle: the handle
* @addr: a pointer to put the address in
* @len: a pointer to put the length in
*
* This function queries the heap for a particular handle to get the
* handle's physical address. It't output is only correct if
* a heap returns physically contiguous memory -- in other cases
* this api should not be implemented -- ion_sg_table should be used
* instead. Returns -EINVAL if the handle is invalid. This has
* no implications on the reference counting of the handle --
* the returned value may not be valid if the caller is not
* holding a reference.
*/
int ion_phys(struct ion_client *client, struct ion_handle *handle,
ion_phys_addr_t *addr, size_t *len);
/**
* ion_map_dma - return an sg_table describing a handle
* @client: the client
* @handle: the handle
*
* This function returns the sg_table describing
* a particular ion handle.
*/
struct sg_table *ion_sg_table(struct ion_client *client,
struct ion_handle *handle);
/**
* ion_map_kernel - create mapping for the given handle
* @client: the client
* @handle: handle to map
*
* Map the given handle into the kernel and return a kernel address that
* can be used to access this address.
*/
void *ion_map_kernel(struct ion_client *client, struct ion_handle *handle);
/**
* ion_unmap_kernel() - destroy a kernel mapping for a handle
* @client: the client
* @handle: handle to unmap
*/
void ion_unmap_kernel(struct ion_client *client, struct ion_handle *handle);
/**
* ion_share_dma_buf() - share buffer as dma-buf
* @client: the client
* @handle: the handle
*/
struct dma_buf *ion_share_dma_buf(struct ion_client *client,
struct ion_handle *handle);
/**
* ion_share_dma_buf_fd() - given an ion client, create a dma-buf fd
* @client: the client
* @handle: the handle
*/
int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle);
/**
* ion_import_dma_buf() - given an dma-buf fd from the ion exporter get handle
* @client: the client
* @fd: the dma-buf fd
*
* Given an dma-buf fd that was allocated through ion via ion_share_dma_buf,
* import that fd and return a handle representing it. If a dma-buf from
* another exporter is passed in this function will return ERR_PTR(-EINVAL)
*/
struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd);
#endif /* __KERNEL__ */
/**
* DOC: Ion Userspace API
*
......@@ -269,7 +88,7 @@ struct ion_allocation_data {
size_t align;
unsigned int heap_id_mask;
unsigned int flags;
struct ion_handle *handle;
ion_user_handle_t handle;
};
/**
......@@ -283,7 +102,7 @@ struct ion_allocation_data {
* provides the file descriptor and the kernel returns the handle.
*/
struct ion_fd_data {
struct ion_handle *handle;
ion_user_handle_t handle;
int fd;
};
......@@ -292,7 +111,7 @@ struct ion_fd_data {
* @handle: a handle
*/
struct ion_handle_data {
struct ion_handle *handle;
ion_user_handle_t handle;
};
/**
......@@ -374,4 +193,4 @@ struct ion_custom_data {
*/
#define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
#endif /* _LINUX_ION_H */
#endif /* _UAPI_LINUX_ION_H */
......@@ -17,92 +17,21 @@
#ifndef __ION_SUNXI_H
#define __ION_SUNXI_H
#define ION_HEAP_TYPE_SUNXI_START (ION_HEAP_TYPE_CUSTOM + 1)
#define ION_HEAP_TYPE_SECURE (ION_HEAP_TYPE_SUNXI_START)
typedef struct {
long start;
long end;
}sunxi_cache_range;
typedef struct {
void *handle;
unsigned long phys_addr;
unsigned long size;
}sunxi_phys_data;
#define DMA_BUF_MAXCNT 8
typedef struct {
unsigned int src_va;
unsigned int src_pa;
unsigned int dst_va;
unsigned int dst_pa;
ion_user_handle_t handle;
unsigned int phys_addr;
unsigned int size;
}dma_buf_item;
typedef struct {
int multi_dma;
unsigned int cnt;
dma_buf_item item[DMA_BUF_MAXCNT];
}dma_buf_group;
}sunxi_phys_data;
#define ION_IOC_SUNXI_FLUSH_RANGE 5
#define ION_IOC_SUNXI_FLUSH_ALL 6
#define ION_IOC_SUNXI_PHYS_ADDR 7
#define ION_IOC_SUNXI_DMA_COPY 8
#define ION_IOC_SUNXI_DUMP 9
#ifdef __KERNEL__
int flush_clean_user_range(long start, long end);
int flush_user_range(long start, long end);
void flush_dcache_all(void);
/**
* sunxi_buf_alloc - alloc phys contigous memory in SUNXI platform.
* @size: size in bytes to allocate.
* @paddr: store the start phys address allocated.
*
* return the start virtual address, or 0 if failed.
*/
void *sunxi_buf_alloc(unsigned int size, unsigned int *paddr);
/**
* sunxi_buf_free - free buffer allocated by sunxi_buf_alloc.
* @vaddr: the kernel virt addr of the area.
* @paddr: the start phys addr of the area.
* @size: size in bytes of the area.
*/
void sunxi_buf_free(void *vaddr, unsigned int paddr, unsigned int size);
/**
* sunxi_alloc_phys - alloc phys contigous memory in SUNXI platform.
* @size: size in bytes to allocate.
*
* return the start phys addr, or 0 if failed.
*/
u32 sunxi_alloc_phys(size_t size);
/**
* sunxi_free_phys - free phys contigous memory allocted by sunxi_alloc_phys.
* @paddr: the start phys addr of the area.
* @size: size in bytes of the area.
*/
void sunxi_free_phys(u32 paddr, size_t size);
/**
* sunxi_map_kernel - map phys contigous memory to kernel virtual space.
* @paddr: the start phys addr of the area.
* @size: size in bytes of the area.
*
* return the start virt addr which is in vmalloc space, or NULL if failed.
*/
void *sunxi_map_kernel(unsigned int paddr, unsigned int size);
/**
* sunxi_unmap_kernel - unmap phys contigous memory from kernel space.
* @vaddr: the kernel virt addr of the area.
* @paddr: the start phys addr of the area.
* @size: size in bytes of the area.
*/
void sunxi_unmap_kernel(void *vaddr, unsigned int paddr, unsigned int size);
#endif /* __KERNEL__ */
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment