ui: add an optional get_flags callback to GraphicHwOps

Those flags can be used to express different requirements for the
display or other needs.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210204105232.834642-12-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-02-04 14:52:23 +04:00 committed by Gerd Hoffmann
parent ff64d44fb8
commit a7dfbe289e
4 changed files with 42 additions and 0 deletions

View File

@ -114,7 +114,25 @@ virtio_gpu_gl_block(void *opaque, bool block)
}
}
static int
virtio_gpu_get_flags(void *opaque)
{
VirtIOGPUBase *g = opaque;
int flags = GRAPHIC_FLAGS_NONE;
if (virtio_gpu_virgl_enabled(g->conf)) {
flags |= GRAPHIC_FLAGS_GL;
}
if (virtio_gpu_dmabuf_enabled(g->conf)) {
flags |= GRAPHIC_FLAGS_DMABUF;
}
return flags;
}
static const GraphicHwOps virtio_gpu_ops = {
.get_flags = virtio_gpu_get_flags,
.invalidate = virtio_gpu_invalidate_display,
.gfx_update = virtio_gpu_update_display,
.text_update = virtio_gpu_text_update,

View File

@ -68,7 +68,16 @@ static void virtio_vga_base_gl_block(void *opaque, bool block)
}
}
static int virtio_vga_base_get_flags(void *opaque)
{
VirtIOVGABase *vvga = opaque;
VirtIOGPUBase *g = vvga->vgpu;
return g->hw_ops->get_flags(g);
}
static const GraphicHwOps virtio_vga_base_ops = {
.get_flags = virtio_vga_base_get_flags,
.invalidate = virtio_vga_base_invalidate_display,
.gfx_update = virtio_vga_base_update_display,
.text_update = virtio_vga_base_text_update,

View File

@ -335,7 +335,13 @@ static void vfio_display_dmabuf_update(void *opaque)
}
}
static int vfio_display_get_flags(void *opaque)
{
return GRAPHIC_FLAGS_GL | GRAPHIC_FLAGS_DMABUF;
}
static const GraphicHwOps vfio_display_dmabuf_ops = {
.get_flags = vfio_display_get_flags,
.gfx_update = vfio_display_dmabuf_update,
.ui_info = vfio_display_edid_ui_info,
};

View File

@ -368,7 +368,16 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
*dest = ch;
}
enum {
GRAPHIC_FLAGS_NONE = 0,
/* require a console/display with GL callbacks */
GRAPHIC_FLAGS_GL = 1 << 0,
/* require a console/display with DMABUF import */
GRAPHIC_FLAGS_DMABUF = 1 << 1,
};
typedef struct GraphicHwOps {
int (*get_flags)(void *opaque); /* optional, default 0 */
void (*invalidate)(void *opaque);
void (*gfx_update)(void *opaque);
bool gfx_update_async; /* if true, calls graphic_hw_update_done() */