From: dongwon.kim@intel.com
To: qemu-devel@nongnu.org
Cc: philmd@linaro.org, marcandre.lureau@redhat.com
Subject: [PATCH 3/3] ui/console: add methods for allocating, intializing and accessing QemuDmaBuf
Date: Wed, 20 Mar 2024 13:50:18 -0700 [thread overview]
Message-ID: <20240320205018.3351984-4-dongwon.kim@intel.com> (raw)
In-Reply-To: <20240320205018.3351984-1-dongwon.kim@intel.com>
From: Dongwon Kim <dongwon.kim@intel.com>
This commit introduces new methods within ui/console to handle the allocation,
initialization, and field retrieval of QemuDmaBuf. By isolating these
operations within ui/console, it enhances safety and encapsulation of
the struct.
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
include/ui/console.h | 10 ++++++++
ui/console.c | 55 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/include/ui/console.h b/include/ui/console.h
index 0bc7a00ac0..70903f1b0d 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -279,6 +279,7 @@ typedef struct DisplayChangeListenerOps {
/* optional */
void (*dpy_gl_cursor_position)(DisplayChangeListener *dcl,
uint32_t pos_x, uint32_t pos_y);
+
/* optional */
void (*dpy_gl_release_dmabuf)(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf);
@@ -358,6 +359,15 @@ 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);
+QemuDmaBuf *dpy_gl_create_dmabuf(uint32_t width, uint32_t height,
+ uint32_t stride, uint32_t x,
+ uint32_t y, uint32_t backing_width,
+ uint32_t backing_height, uint32_t fourcc,
+ uint32_t modifier, uint32_t dmabuf_fd,
+ bool allow_fences);
+uint32_t dpy_gl_dmabuf_get_width(QemuDmaBuf *dmabuf);
+uint32_t dpy_gl_dmabuf_get_height(QemuDmaBuf *dmabuf);
+int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf);
void dpy_gl_release_dmabuf(QemuConsole *con,
QemuDmaBuf *dmabuf);
void dpy_gl_update(QemuConsole *con,
diff --git a/ui/console.c b/ui/console.c
index 43226c5c14..bac24756f0 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1132,6 +1132,60 @@ void dpy_gl_cursor_position(QemuConsole *con,
}
}
+QemuDmaBuf *dpy_gl_create_dmabuf(uint32_t width, uint32_t height,
+ uint32_t stride, uint32_t x,
+ uint32_t y, uint32_t backing_width,
+ uint32_t backing_height, uint32_t fourcc,
+ uint32_t modifier, uint32_t dmabuf_fd,
+ bool allow_fences)
+{
+ QemuDmaBuf *dmabuf;
+
+ dmabuf = g_new0(QemuDmaBuf, 1);
+
+ dmabuf->width = width;
+ dmabuf->height = height;
+ dmabuf->stride = stride;
+ dmabuf->x = x;
+ dmabuf->y = y;
+ dmabuf->backing_width = backing_width;
+ dmabuf->backing_height = backing_height;
+ dmabuf->fourcc = fourcc;
+ dmabuf->modifier = modifier;
+ dmabuf->fd = dmabuf_fd;
+ dmabuf->allow_fences = allow_fences;
+ dmabuf->fence_fd = -1;
+
+ return dmabuf;
+}
+
+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;
+}
+
+int32_t dpy_gl_dmabuf_get_fd(QemuDmaBuf *dmabuf)
+{
+ if (dmabuf) {
+ return dmabuf->fd;
+ }
+
+ return -1;
+}
+
void dpy_gl_release_dmabuf(QemuConsole *con,
QemuDmaBuf *dmabuf)
{
@@ -1145,6 +1199,7 @@ void dpy_gl_release_dmabuf(QemuConsole *con,
if (dcl->ops->dpy_gl_release_dmabuf) {
dcl->ops->dpy_gl_release_dmabuf(dcl, dmabuf);
}
+ g_free(dmabuf);
}
}
--
2.34.1
next prev parent reply other threads:[~2024-03-20 20:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 20:50 [PATCH 0/3] ui/console: initialize QemuDmaBuf in ui/console dongwon.kim
2024-03-20 20:50 ` [PATCH 1/3] hw/virtio: initialize QemuDmaBuf using the function from ui/console dongwon.kim
2024-03-20 20:50 ` [PATCH 2/3] hw/vfio: intialize " dongwon.kim
2024-03-20 20:50 ` dongwon.kim [this message]
2024-03-21 9:58 ` [PATCH 3/3] ui/console: add methods for allocating, intializing and accessing QemuDmaBuf Philippe Mathieu-Daudé
2024-03-21 6:57 ` [PATCH 0/3] ui/console: initialize QemuDmaBuf in ui/console Philippe Mathieu-Daudé
2024-03-21 7:01 ` Kim, Dongwon
2024-03-21 7:04 ` Philippe Mathieu-Daudé
2024-03-21 9:41 ` Philippe Mathieu-Daudé
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=20240320205018.3351984-4-dongwon.kim@intel.com \
--to=dongwon.kim@intel.com \
--cc=marcandre.lureau@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).