xref: /openbsd-src/sys/dev/pci/drm/include/linux/dma-buf.h (revision 4e1ee0786f11cc571bd0be17d38e46f635c719fc)
1 /*	$OpenBSD: dma-buf.h,v 1.3 2021/07/07 02:38:36 jsg Exp $	*/
2 /*
3  * Copyright (c) 2018 Mark Kettenis
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _LINUX_DMA_BUF_H
19 #define _LINUX_DMA_BUF_H
20 
21 #include <sys/types.h>
22 #include <sys/systm.h>
23 #include <linux/dma-resv.h>
24 #include <linux/list.h>
25 
26 struct dma_buf_ops;
27 
28 struct dma_buf {
29 	const struct dma_buf_ops *ops;
30 	void *priv;
31 	size_t size;
32 	struct file *file;
33 	struct list_head attachments;
34 	struct dma_resv *resv;
35 };
36 
37 struct dma_buf_attachment {
38 	void *importer_priv;
39 };
40 
41 struct dma_buf_attach_ops {
42 	void (*move_notify)(struct dma_buf_attachment *);
43 	bool allow_peer2peer;
44 };
45 
46 void	get_dma_buf(struct dma_buf *);
47 struct dma_buf *dma_buf_get(int);
48 void	dma_buf_put(struct dma_buf *);
49 int	dma_buf_fd(struct dma_buf *, int);
50 
51 struct dma_buf_ops {
52 	void (*release)(struct dma_buf *);
53 };
54 
55 struct dma_buf_export_info {
56 	const struct dma_buf_ops *ops;
57 	size_t size;
58 	int flags;
59 	void *priv;
60 	struct dma_resv *resv;
61 };
62 
63 #define DEFINE_DMA_BUF_EXPORT_INFO(x)  struct dma_buf_export_info x
64 
65 struct dma_buf *dma_buf_export(const struct dma_buf_export_info *);
66 
67 #define dma_buf_attach(x, y) NULL
68 #define dma_buf_detach(x, y) panic("dma_buf_detach")
69 
70 #endif
71