From: Dongwon Kim <dongwon....@intel.com> Signed-off-by: Dongwon Kim <dongwon....@intel.com> Message-Id: <20240320034229.3347130-1-dongwon....@intel.com> [PMD: Split patch in 3, part 1/3] Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> --- include/ui/console.h | 2 ++ hw/display/virtio-gpu-udmabuf.c | 8 +++++--- hw/vfio/display.c | 9 ++++++--- ui/console.c | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h index a4a49ffc64..a7f6cef26d 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -358,6 +358,8 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, bool have_hot, uint32_t hot_x, uint32_t hot_y); void dpy_gl_cursor_position(QemuConsole *con, uint32_t pos_x, uint32_t pos_y); +uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf); void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); void dpy_gl_update(QemuConsole *con, diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c index d51184d658..d680e871c1 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -206,20 +206,22 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, { struct virtio_gpu_scanout *scanout = &g->parent_obj.scanout[scanout_id]; VGPUDMABuf *new_primary, *old_primary = NULL; + uint32_t width, height; new_primary = virtio_gpu_create_dmabuf(g, scanout_id, res, fb, r); if (!new_primary) { return -EINVAL; } + width = dpy_gl_dmabuf_get_width(&new_primary->buf); + height = dpy_gl_dmabuf_get_height(&new_primary->buf); + if (g->dmabuf.primary[scanout_id]) { old_primary = g->dmabuf.primary[scanout_id]; } g->dmabuf.primary[scanout_id] = new_primary; - qemu_console_resize(scanout->con, - new_primary->buf.width, - new_primary->buf.height); + qemu_console_resize(scanout->con, width, height); dpy_gl_scanout_dmabuf(scanout->con, &new_primary->buf); if (old_primary) { diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 1aa440c663..c962e5f88f 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -286,6 +286,7 @@ static void vfio_display_dmabuf_update(void *opaque) VFIOPCIDevice *vdev = opaque; VFIODisplay *dpy = vdev->dpy; VFIODMABuf *primary, *cursor; + uint32_t width, height; bool free_bufs = false, new_cursor = false; primary = vfio_display_get_dmabuf(vdev, DRM_PLANE_TYPE_PRIMARY); @@ -296,10 +297,12 @@ static void vfio_display_dmabuf_update(void *opaque) return; } + width = dpy_gl_dmabuf_get_width(&primary->buf); + height = dpy_gl_dmabuf_get_height(&primary->buf); + if (dpy->dmabuf.primary != primary) { dpy->dmabuf.primary = primary; - qemu_console_resize(dpy->con, - primary->buf.width, primary->buf.height); + qemu_console_resize(dpy->con, width, height); dpy_gl_scanout_dmabuf(dpy->con, &primary->buf); free_bufs = true; } @@ -328,7 +331,7 @@ static void vfio_display_dmabuf_update(void *opaque) cursor->pos_updates = 0; } - dpy_gl_update(dpy->con, 0, 0, primary->buf.width, primary->buf.height); + dpy_gl_update(dpy->con, 0, 0, width, height); if (free_bufs) { vfio_display_free_dmabufs(vdev); diff --git a/ui/console.c b/ui/console.c index 832055675c..edabad64c0 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1190,6 +1190,24 @@ void dpy_gl_cursor_position(QemuConsole *con, } } +uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf) +{ + if (dmabuf) { + return dmabuf->width; + } + + return 0; +} + +uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf) +{ + if (dmabuf) { + return dmabuf->height; + } + + return 0; +} + void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf) { -- 2.41.0