xref: /openbsd-src/sys/dev/pci/drm/include/linux/dma-buf.h (revision 99fd087599a8791921855f21bd7e36130f39aadc)
1 /*	$OpenBSD: dma-buf.h,v 1.1 2019/04/14 10:14:53 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/reservation.h>
24 
25 struct dma_buf_ops;
26 
27 struct dma_buf {
28 	const struct dma_buf_ops *ops;
29 	void *priv;
30 	size_t size;
31 	struct file *file;
32 };
33 
34 struct dma_buf_attachment;
35 
36 void	get_dma_buf(struct dma_buf *);
37 struct dma_buf *dma_buf_get(int);
38 void	dma_buf_put(struct dma_buf *);
39 int	dma_buf_fd(struct dma_buf *, int);
40 
41 struct dma_buf_ops {
42 	void (*release)(struct dma_buf *);
43 };
44 
45 struct dma_buf_export_info {
46 	const struct dma_buf_ops *ops;
47 	size_t size;
48 	int flags;
49 	void *priv;
50 	struct reservation_object *resv;
51 };
52 
53 #define DEFINE_DMA_BUF_EXPORT_INFO(x)  struct dma_buf_export_info x
54 
55 struct dma_buf *dma_buf_export(const struct dma_buf_export_info *);
56 
57 #define dma_buf_attach(x, y) NULL
58 #define dma_buf_detach(x, y) panic("dma_buf_detach")
59 
60 #endif
61