spapr: Don't allow multiple active vCPUs at CAS
[qemu/ar7.git] / contrib / vhost-user-gpu / vugbm.h
blob07e698fcd74ba48cbdb800d966840d7b436ade07
1 /*
2 * Virtio vhost-user GPU Device
4 * GBM helpers
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 */
10 #ifndef VHOST_USER_GPU_VUGBM_H
11 #define VHOST_USER_GPU_VUGBM_H
13 #include "qemu/osdep.h"
15 #ifdef CONFIG_MEMFD
16 #include <sys/mman.h>
17 #include <sys/ioctl.h>
18 #endif
20 #ifdef CONFIG_GBM
21 #include <gbm.h>
22 #endif
24 struct vugbm_buffer;
26 struct vugbm_device {
27 bool inited;
28 int fd;
29 #ifdef CONFIG_GBM
30 struct gbm_device *dev;
31 #endif
33 bool (*alloc_bo)(struct vugbm_buffer *buf);
34 void (*free_bo)(struct vugbm_buffer *buf);
35 bool (*get_fd)(struct vugbm_buffer *buf, int *fd);
36 bool (*map_bo)(struct vugbm_buffer *buf);
37 void (*unmap_bo)(struct vugbm_buffer *buf);
38 void (*device_destroy)(struct vugbm_device *dev);
41 struct vugbm_buffer {
42 struct vugbm_device *dev;
44 #ifdef CONFIG_MEMFD
45 int memfd;
46 #endif
47 #ifdef CONFIG_GBM
48 struct gbm_bo *bo;
49 void *mmap_data;
50 #endif
52 uint8_t *mmap;
53 uint32_t width;
54 uint32_t height;
55 uint32_t stride;
56 uint32_t format;
59 bool vugbm_device_init(struct vugbm_device *dev, int fd);
60 void vugbm_device_destroy(struct vugbm_device *dev);
62 bool vugbm_buffer_create(struct vugbm_buffer *buffer, struct vugbm_device *dev,
63 uint32_t width, uint32_t height);
64 bool vugbm_buffer_can_get_dmabuf_fd(struct vugbm_buffer *buffer);
65 bool vugbm_buffer_get_dmabuf_fd(struct vugbm_buffer *buffer, int *fd);
66 void vugbm_buffer_destroy(struct vugbm_buffer *buffer);
68 #endif