1 /* SPDX-License-Identifier: GPL-2.0 */
3 * DMABUF Heaps helper code
5 * Copyright (C) 2011 Google, Inc.
6 * Copyright (C) 2019 Linaro Ltd.
9 #ifndef _HEAP_HELPERS_H
10 #define _HEAP_HELPERS_H
12 #include <linux/dma-heap.h>
13 #include <linux/list.h>
16 * struct heap_helper_buffer - helper buffer metadata
17 * @heap: back pointer to the heap the buffer came from
18 * @dmabuf: backing dma-buf for this buffer
19 * @size: size of the buffer
20 * @priv_virt pointer to heap specific private value
21 * @lock mutext to protect the data in this structure
22 * @vmap_cnt count of vmap references on the buffer
23 * @vaddr vmap'ed virtual address
24 * @pagecount number of pages in the buffer
25 * @pages list of page pointers
26 * @attachments list of device attachments
28 * @free heap callback to free the buffer
30 struct heap_helper_buffer
{
31 struct dma_heap
*heap
;
32 struct dma_buf
*dmabuf
;
41 struct list_head attachments
;
43 void (*free
)(struct heap_helper_buffer
*buffer
);
46 void init_heap_helper_buffer(struct heap_helper_buffer
*buffer
,
47 void (*free
)(struct heap_helper_buffer
*));
49 struct dma_buf
*heap_helper_export_dmabuf(struct heap_helper_buffer
*buffer
,
52 extern const struct dma_buf_ops heap_helper_ops
;
53 #endif /* _HEAP_HELPERS_H */