From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Dongwon Kim <dongwon.kim@intel.com>, qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Vivek Kasireddy" <vivek.kasireddy@intel.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v3 1/3] ui/console: Introduce dpy_gl_dmabuf_get_height/width() helpers
Date: Thu, 21 Mar 2024 11:06:33 +0100 [thread overview]
Message-ID: <20240321100635.64950-2-philmd@linaro.org> (raw)
In-Reply-To: <20240321100635.64950-1-philmd@linaro.org>
From: Dongwon Kim <dongwon.kim@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Message-Id: <20240320034229.3347130-1-dongwon.kim@intel.com>
[PMD: Split patch in 3, part 1/3]
Signed-off-by: Philippe Mathieu-Daudé <philmd@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
next prev parent reply other threads:[~2024-03-21 10:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 10:06 [PATCH v3 0/3] ui/console: initialize QemuDmaBuf in ui/console Philippe Mathieu-Daudé
2024-03-21 10:06 ` Philippe Mathieu-Daudé [this message]
2024-03-21 10:06 ` [PATCH v3 2/3] ui/console: Introduce dpy_gl_dmabuf_get_fd() helper Philippe Mathieu-Daudé
2024-03-21 10:06 ` [INCOMPLETE PATCH v3 3/3] ui/console: Introduce dpy_gl_create_dmabuf() helper Philippe Mathieu-Daudé
2024-03-21 23:46 ` Kim, Dongwon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240321100635.64950-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=dongwon.kim@intel.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vivek.kasireddy@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).