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 typedef struct QemuDmaBuf { 14 int fd; 15 uint32_t width; 16 uint32_t height; 17 uint32_t stride; 18 uint32_t fourcc; 19 uint64_t modifier; 20 uint32_t texture; 21 uint32_t x; 22 uint32_t y; 23 uint32_t backing_width; 24 uint32_t backing_height; 25 bool y0_top; 26 void *sync; 27 int fence_fd; 28 bool allow_fences; 29 bool draw_submitted; 30 } QemuDmaBuf; 31 32 QemuDmaBuf *qemu_dmabuf_new(uint32_t width, uint32_t height, 33 uint32_t stride, uint32_t x, 34 uint32_t y, uint32_t backing_width, 35 uint32_t backing_height, uint32_t fourcc, 36 uint64_t modifier, int dmabuf_fd, 37 bool allow_fences, bool y0_top); 38 void qemu_dmabuf_free(QemuDmaBuf *dmabuf); 39 40 G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuDmaBuf, qemu_dmabuf_free); 41 42 int qemu_dmabuf_get_fd(QemuDmaBuf *dmabuf); 43 int qemu_dmabuf_dup_fd(QemuDmaBuf *dmabuf); 44 void qemu_dmabuf_close(QemuDmaBuf *dmabuf); 45 uint32_t qemu_dmabuf_get_width(QemuDmaBuf *dmabuf); 46 uint32_t qemu_dmabuf_get_height(QemuDmaBuf *dmabuf); 47 uint32_t qemu_dmabuf_get_stride(QemuDmaBuf *dmabuf); 48 uint32_t qemu_dmabuf_get_fourcc(QemuDmaBuf *dmabuf); 49 uint64_t qemu_dmabuf_get_modifier(QemuDmaBuf *dmabuf); 50 uint32_t qemu_dmabuf_get_texture(QemuDmaBuf *dmabuf); 51 uint32_t qemu_dmabuf_get_x(QemuDmaBuf *dmabuf); 52 uint32_t qemu_dmabuf_get_y(QemuDmaBuf *dmabuf); 53 uint32_t qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf); 54 uint32_t qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf); 55 bool qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf); 56 void *qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf); 57 int32_t qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf); 58 bool qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf); 59 bool qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf); 60 void qemu_dmabuf_set_texture(QemuDmaBuf *dmabuf, uint32_t texture); 61 void qemu_dmabuf_set_fence_fd(QemuDmaBuf *dmabuf, int32_t fence_fd); 62 void qemu_dmabuf_set_sync(QemuDmaBuf *dmabuf, void *sync); 63 void qemu_dmabuf_set_draw_submitted(QemuDmaBuf *dmabuf, bool draw_submitted); 64 void qemu_dmabuf_set_fd(QemuDmaBuf *dmabuf, int32_t fd); 65 66 #endif 67