mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
ui/console: Use qemu_dmabuf_get_..() helpers instead
This commit updates all instances where fields within the QemuDmaBuf struct are directly accessed, replacing them with calls to these new helper functions. v6: fix typos in helper names in ui/spice-display.c v7: removed prefix, "dpy_gl_" from all helpers v8: Introduction of helpers was removed as those were already added by the previous commit v11: -- Use new qemu_dmabuf_close() instead of close(qemu_dmabuf_get_fd()). (Daniel P. Berrangé <berrange@redhat.com>) -- Use new qemu_dmabuf_dup_fd() instead of dup(qemu_dmabuf_get_fd()). (Daniel P. Berrangé <berrange@redhat.com>) Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Cc: Philippe Mathieu-Daudé <philmd@linaro.org> Cc: Daniel P. Berrangé <berrange@redhat.com> Cc: Vivek Kasireddy <vivek.kasireddy@intel.com> Signed-off-by: Dongwon Kim <dongwon.kim@intel.com> Message-Id: <20240508175403.3399895-4-dongwon.kim@intel.com>
This commit is contained in:
parent
6e6ae491da
commit
6779a3076f
12 changed files with 181 additions and 110 deletions
|
@ -262,10 +262,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)
|
|||
g->parent_obj.enable = 1;
|
||||
con = g->parent_obj.scanout[m->scanout_id].con;
|
||||
dmabuf = &g->dmabuf[m->scanout_id];
|
||||
if (dmabuf->fd >= 0) {
|
||||
close(dmabuf->fd);
|
||||
dmabuf->fd = -1;
|
||||
}
|
||||
qemu_dmabuf_close(dmabuf);
|
||||
dpy_gl_release_dmabuf(con, dmabuf);
|
||||
if (fd == -1) {
|
||||
dpy_gl_scanout_disable(con);
|
||||
|
|
|
@ -206,6 +206,7 @@ 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) {
|
||||
|
@ -216,10 +217,10 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g,
|
|||
old_primary = g->dmabuf.primary[scanout_id];
|
||||
}
|
||||
|
||||
width = qemu_dmabuf_get_width(&new_primary->buf);
|
||||
height = qemu_dmabuf_get_height(&new_primary->buf);
|
||||
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) {
|
||||
|
|
|
@ -260,8 +260,9 @@ static VFIODMABuf *vfio_display_get_dmabuf(VFIOPCIDevice *vdev,
|
|||
static void vfio_display_free_one_dmabuf(VFIODisplay *dpy, VFIODMABuf *dmabuf)
|
||||
{
|
||||
QTAILQ_REMOVE(&dpy->dmabuf.bufs, dmabuf, next);
|
||||
|
||||
qemu_dmabuf_close(&dmabuf->buf);
|
||||
dpy_gl_release_dmabuf(dpy->con, &dmabuf->buf);
|
||||
close(dmabuf->buf.fd);
|
||||
g_free(dmabuf);
|
||||
}
|
||||
|
||||
|
@ -286,6 +287,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 +298,12 @@ static void vfio_display_dmabuf_update(void *opaque)
|
|||
return;
|
||||
}
|
||||
|
||||
width = qemu_dmabuf_get_width(&primary->buf);
|
||||
height = qemu_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 +332,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue