1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * DMABUF Heaps Allocation Infrastructure
4  *
5  * Copyright (C) 2011 Google, Inc.
6  * Copyright (C) 2019 Linaro Ltd.
7  */
8 
9 #ifndef _DMA_HEAPS_H
10 #define _DMA_HEAPS_H
11 
12 #include <linux/types.h>
13 
14 struct dma_heap;
15 
16 /**
17  * struct dma_heap_ops - ops to operate on a given heap
18  * @allocate:	allocate dmabuf and return struct dma_buf ptr
19  *
20  * allocate returns dmabuf on success, ERR_PTR(-errno) on error.
21  */
22 struct dma_heap_ops {
23 	struct dma_buf *(*allocate)(struct dma_heap *heap,
24 				    unsigned long len,
25 				    u32 fd_flags,
26 				    u64 heap_flags);
27 };
28 
29 /**
30  * struct dma_heap_export_info - information needed to export a new dmabuf heap
31  * @name:	used for debugging/device-node name
32  * @ops:	ops struct for this heap
33  * @priv:	heap exporter private data
34  *
35  * Information needed to export a new dmabuf heap.
36  */
37 struct dma_heap_export_info {
38 	const char *name;
39 	const struct dma_heap_ops *ops;
40 	void *priv;
41 };
42 
43 void *dma_heap_get_drvdata(struct dma_heap *heap);
44 
45 const char *dma_heap_get_name(struct dma_heap *heap);
46 
47 struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info);
48 
49 #endif /* _DMA_HEAPS_H */
50