xref: /openbsd/sys/dev/pci/drm/include/linux/dma-buf.h (revision 771fbea0)
1 /*	$OpenBSD: dma-buf.h,v 1.2 2020/06/08 04:48:14 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 };
44 
45 void	get_dma_buf(struct dma_buf *);
46 struct dma_buf *dma_buf_get(int);
47 void	dma_buf_put(struct dma_buf *);
48 int	dma_buf_fd(struct dma_buf *, int);
49 
50 struct dma_buf_ops {
51 	void (*release)(struct dma_buf *);
52 };
53 
54 struct dma_buf_export_info {
55 	const struct dma_buf_ops *ops;
56 	size_t size;
57 	int flags;
58 	void *priv;
59 	struct dma_resv *resv;
60 };
61 
62 #define DEFINE_DMA_BUF_EXPORT_INFO(x)  struct dma_buf_export_info x
63 
64 struct dma_buf *dma_buf_export(const struct dma_buf_export_info *);
65 
66 #define dma_buf_attach(x, y) NULL
67 #define dma_buf_detach(x, y) panic("dma_buf_detach")
68 
69 #endif
70