aboutsummaryrefslogtreecommitdiff
path: root/drivers/cenalloc/cenalloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cenalloc/cenalloc.h')
-rw-r--r--drivers/cenalloc/cenalloc.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/drivers/cenalloc/cenalloc.h b/drivers/cenalloc/cenalloc.h
new file mode 100644
index 000000000000..91e07b246f1c
--- /dev/null
+++ b/drivers/cenalloc/cenalloc.h
@@ -0,0 +1,99 @@
+/*
+ * Header file for allocator helper framework for constraints-aware
+ * dma-buf backing storage allocation.
+ *
+ * Copyright(C) 2014 Linaro Limited. All rights reserved.
+ * Author: Sumit Semwal <sumit.semwal@linaro.org>
+ *
+ * Structure for management of device, buffers etc heavily derived from
+ * Android's ION framework.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CENALLOC_H_
+#define CENALLOC_H_
+
+#include <linux/types.h>
+#include <linux/dma-buf.h>
+
+struct cenalloc_device;
+
+/**
+ * cenalloc_get_device:
+ * gets a reference to cenalloc_device; this should be used in the
+ * call to cenalloc_buffer_create.
+ *
+ * TODO: might need to have a better way of getting this device.
+ */
+const struct cenalloc_device *cenalloc_get_device(void);
+
+/**
+ * cenalloc_buffer_create:
+ * creates a cenalloc_buffer, associates a dma_buf buffer with it,
+ * and returns the dma_buf; other importers can then use references
+ * to this dma_buf and attach themselves to it.
+ *
+ * Note: Since this is delayed-allocation model, no actual allocation
+ * will happen at this call.
+ *
+ * @dev: cenalloc_device to create the buffer from
+ * @len: size of the buffer
+ * @align: alignment info, if any
+ * @flags: flags for the buffer, if any
+ *
+ */
+struct dma_buf *cenalloc_buffer_create(struct cenalloc_device *dev,
+ unsigned long len,
+ unsigned long align,
+ unsigned long flags);
+
+/**
+ * cenalloc_buffer_free:
+ * calls dma_buf_put(), which in turn may call allocator->free()
+ * if this was the last reference held.
+ * For dma-bufs created with cenalloc_buffer_create, this should be
+ * called instead of dma_buf_put() directly.
+ *
+ * @dma_buf: the dma_buf to free.
+ */
+void cenalloc_buffer_free(struct dma_buf *dmabuf);
+
+/**
+ * cenalloc_phys:
+ * returns the phys address and len associated with this buffer - this
+ * will get refined as the ION 'abuse' of phys_addr_t is corrected.
+ * This is valid only for buffers that are allocated from physically
+ * contiguous memory; its output is invalid otherwise. For such cases,
+ * cenalloc_sg_table() should be used instead.
+ * Will return -EINVAL if the buffer is invalid.
+ *
+ * @dmabuf: buffer for which phys address is needed
+ * @phys: pointer to the phys address
+ * @len: pointer to teh length of the buffer
+ *
+ */
+int cenalloc_phys(struct dma_buf *dmabuf,
+ phys_addr_t *addr, size_t *len);
+
+/**
+ * cenalloc_sg_table:
+ * returns the sg_table associated with the dma_buf.
+ * Will return -EINVAL in case of error.
+ *
+ * @dmabuf: handle to buffer who's sg_table is to be returned.
+ *
+ */
+struct sg_table *cenalloc_sg_table(struct dma_buf *dmabuf);
+
+#endif /* CENALLOC_H_ */