1 /* 2 * Copyright (C) 2022 Intel Corporation. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 * Vistual Display for VMs 7 * 8 */ 9 #ifndef _VDISPLAY_H_ 10 #define _VDISPLAY_H_ 11 12 #include <sys/queue.h> 13 #include <pixman.h> 14 #include "dm.h" 15 16 typedef void (*bh_task_func)(void *data); 17 18 /* bh task is still pending */ 19 #define ACRN_BH_PENDING (1 << 0) 20 /* bh task is done */ 21 #define ACRN_BH_DONE (1 << 1) 22 /* free vdpy_display_bh after executing bh_cb */ 23 #define ACRN_BH_FREE (1 << 2) 24 25 struct vdpy_display_bh { 26 TAILQ_ENTRY(vdpy_display_bh) link; 27 bh_task_func task_cb; 28 void *data; 29 uint32_t bh_flag; 30 }; 31 32 struct edid_info { 33 char *vendor; 34 char *name; 35 char *sn; 36 uint32_t prefx; 37 uint32_t prefy; 38 uint32_t maxx; 39 uint32_t maxy; 40 uint32_t refresh_rate; 41 }; 42 43 struct display_info { 44 /* geometry */ 45 int xoff; 46 int yoff; 47 uint32_t width; 48 uint32_t height; 49 }; 50 51 enum surface_type { 52 SURFACE_PIXMAN = 1, 53 SURFACE_DMABUF, 54 }; 55 56 struct surface { 57 enum surface_type surf_type; 58 /* use pixman_format as the intermediate-format */ 59 pixman_format_code_t surf_format; 60 uint32_t x; 61 uint32_t y; 62 uint32_t width; 63 uint32_t height; 64 uint32_t bpp; 65 uint32_t stride; 66 void *pixel; 67 struct { 68 int dmabuf_fd; 69 uint32_t surf_fourcc; 70 uint32_t dmabuf_offset; 71 } dma_info; 72 }; 73 74 struct cursor { 75 enum surface_type surf_type; 76 /* use pixman_format as the intermediate-format */ 77 pixman_format_code_t surf_format; 78 uint32_t x; 79 uint32_t y; 80 uint32_t hot_x; 81 uint32_t hot_y; 82 uint32_t width; 83 uint32_t height; 84 void *data; 85 }; 86 87 int vdpy_parse_cmd_option(const char *opts); 88 int gfx_ui_init(); 89 int vdpy_init(int *num_vscreens); 90 void vdpy_get_display_info(int handle, int scanout_id, struct display_info *info); 91 void vdpy_surface_set(int handle, int scanout_id, struct surface *surf); 92 void vdpy_surface_update(int handle, int scanout_id, struct surface *surf); 93 bool vdpy_submit_bh(int handle, struct vdpy_display_bh *bh); 94 void vdpy_get_edid(int handle, int scanout_id, uint8_t *edid, size_t size); 95 void vdpy_cursor_define(int handle, int scanout_id, struct cursor *cur); 96 void vdpy_cursor_move(int handle, int scanout_id, uint32_t x, uint32_t y); 97 int vdpy_deinit(int handle); 98 void gfx_ui_deinit(); 99 100 #endif /* _VDISPLAY_H_ */ 101