Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * DMABUF Heaps Allocation Infrastructure
0004  *
0005  * Copyright (C) 2011 Google, Inc.
0006  * Copyright (C) 2019 Linaro Ltd.
0007  */
0008 
0009 #ifndef _DMA_HEAPS_H
0010 #define _DMA_HEAPS_H
0011 
0012 #include <linux/cdev.h>
0013 #include <linux/types.h>
0014 
0015 struct dma_heap;
0016 
0017 /**
0018  * struct dma_heap_ops - ops to operate on a given heap
0019  * @allocate:       allocate dmabuf and return struct dma_buf ptr
0020  *
0021  * allocate returns dmabuf on success, ERR_PTR(-errno) on error.
0022  */
0023 struct dma_heap_ops {
0024     struct dma_buf *(*allocate)(struct dma_heap *heap,
0025                     unsigned long len,
0026                     unsigned long fd_flags,
0027                     unsigned long heap_flags);
0028 };
0029 
0030 /**
0031  * struct dma_heap_export_info - information needed to export a new dmabuf heap
0032  * @name:   used for debugging/device-node name
0033  * @ops:    ops struct for this heap
0034  * @priv:   heap exporter private data
0035  *
0036  * Information needed to export a new dmabuf heap.
0037  */
0038 struct dma_heap_export_info {
0039     const char *name;
0040     const struct dma_heap_ops *ops;
0041     void *priv;
0042 };
0043 
0044 /**
0045  * dma_heap_get_drvdata() - get per-heap driver data
0046  * @heap: DMA-Heap to retrieve private data for
0047  *
0048  * Returns:
0049  * The per-heap data for the heap.
0050  */
0051 void *dma_heap_get_drvdata(struct dma_heap *heap);
0052 
0053 /**
0054  * dma_heap_get_name() - get heap name
0055  * @heap: DMA-Heap to retrieve private data for
0056  *
0057  * Returns:
0058  * The char* for the heap name.
0059  */
0060 const char *dma_heap_get_name(struct dma_heap *heap);
0061 
0062 /**
0063  * dma_heap_add - adds a heap to dmabuf heaps
0064  * @exp_info:       information needed to register this heap
0065  */
0066 struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info);
0067 
0068 #endif /* _DMA_HEAPS_H */