xref: /qemu/include/ui/dmabuf.h (revision 3e1210e8b0d86a2190e51632985c3da3e5721336)
1 /*
2  * SPDX-License-Identifier: GPL-2.0-or-later
3  *
4  * QemuDmaBuf struct and helpers used for accessing its data
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  */
9 
10 #ifndef DMABUF_H
11 #define DMABUF_H
12 
13 #define DMABUF_MAX_PLANES 4
14 
15 typedef struct QemuDmaBuf QemuDmaBuf;
16 
17 QemuDmaBuf *qemu_dmabuf_new(uint32_t width, uint32_t height,
18                             const uint32_t *offset, const uint32_t *stride,
19                             uint32_t x, uint32_t y,
20                             uint32_t backing_width, uint32_t backing_height,
21                             uint32_t fourcc, uint64_t modifier,
22                             const int32_t *dmabuf_fd, uint32_t num_planes,
23                             bool allow_fences, bool y0_top);
24 void qemu_dmabuf_free(QemuDmaBuf *dmabuf);
25 
26 G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuDmaBuf, qemu_dmabuf_free);
27 
28 const int *qemu_dmabuf_get_fds(QemuDmaBuf *dmabuf, int *nfds);
29 void qemu_dmabuf_dup_fds(QemuDmaBuf *dmabuf, int *fds, int nfds);
30 void qemu_dmabuf_close(QemuDmaBuf *dmabuf);
31 uint32_t qemu_dmabuf_get_width(QemuDmaBuf *dmabuf);
32 uint32_t qemu_dmabuf_get_height(QemuDmaBuf *dmabuf);
33 const uint32_t *qemu_dmabuf_get_offsets(QemuDmaBuf *dmabuf, int *noffsets);
34 const uint32_t *qemu_dmabuf_get_strides(QemuDmaBuf *dmabuf, int *nstrides);
35 uint32_t qemu_dmabuf_get_num_planes(QemuDmaBuf *dmabuf);
36 uint32_t qemu_dmabuf_get_fourcc(QemuDmaBuf *dmabuf);
37 uint64_t qemu_dmabuf_get_modifier(QemuDmaBuf *dmabuf);
38 uint32_t qemu_dmabuf_get_texture(QemuDmaBuf *dmabuf);
39 uint32_t qemu_dmabuf_get_x(QemuDmaBuf *dmabuf);
40 uint32_t qemu_dmabuf_get_y(QemuDmaBuf *dmabuf);
41 uint32_t qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf);
42 uint32_t qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf);
43 bool qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf);
44 void *qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf);
45 int32_t qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf);
46 bool qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf);
47 bool qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf);
48 void qemu_dmabuf_set_texture(QemuDmaBuf *dmabuf, uint32_t texture);
49 void qemu_dmabuf_set_fence_fd(QemuDmaBuf *dmabuf, int32_t fence_fd);
50 void qemu_dmabuf_set_sync(QemuDmaBuf *dmabuf, void *sync);
51 void qemu_dmabuf_set_draw_submitted(QemuDmaBuf *dmabuf, bool draw_submitted);
52 
53 #endif
54