qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/5] Ui 20190607 patches
@ 2019-06-07 13:18 Gerd Hoffmann
  2019-06-07 13:18 ` [Qemu-devel] [PULL 1/5] ui/curses: Fix build with -m32 Gerd Hoffmann
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-06-07 13:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Gerd Hoffmann

The following changes since commit 0d74f3b4277a7ecb0ccb80c865797d11f8e466f5:

  Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging (2019-06-06 14:09:14 +0100)

are available in the Git repository at:

  git://git.kraxel.org/qemu tags/ui-20190607-pull-request

for you to fetch changes up to 15ee0d9bc10b3de677ff6cd78b6dc9d5a7d40603:

  egl-helpers: add modifier support to egl_dmabuf_import_texture() (2019-06-07 11:52:35 +0200)

----------------------------------------------------------------
curses: 32bit build fix.
egl: dmabuf modifier support.

----------------------------------------------------------------

Gerd Hoffmann (4):
  console: add dmabuf modifier field.
  vfio/display: set dmabuf modifier field
  egl-helpers: add modifier support to egl_get_fd_for_texture().
  egl-helpers: add modifier support to egl_dmabuf_import_texture()

Max Reitz (1):
  ui/curses: Fix build with -m32

 include/ui/console.h     |  1 +
 include/ui/egl-helpers.h |  3 ++-
 hw/vfio/display.c        |  1 +
 ui/curses.c              |  8 ++++----
 ui/egl-helpers.c         | 39 ++++++++++++++++++++++++++++-----------
 ui/spice-display.c       |  7 ++++---
 6 files changed, 40 insertions(+), 19 deletions(-)

-- 
2.18.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 1/5] ui/curses: Fix build with -m32
  2019-06-07 13:18 [Qemu-devel] [PULL 0/5] Ui 20190607 patches Gerd Hoffmann
@ 2019-06-07 13:18 ` Gerd Hoffmann
  2019-06-07 13:18 ` [Qemu-devel] [PULL 2/5] console: add dmabuf modifier field Gerd Hoffmann
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-06-07 13:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Gerd Hoffmann, Max Reitz

From: Max Reitz <mreitz@redhat.com>

wchar_t may resolve to be an unsigned long on 32-bit architectures.
Using the %x conversion specifier will then give a compiler warning:

ui/curses.c: In function ‘get_ucs’:
ui/curses.c:492:49: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘long int’} [-Werror=format=]
  492 |         fprintf(stderr, "Could not convert 0x%04x "
      |                                              ~~~^
      |                                                 |
      |                                                 unsigned int
      |                                              %04lx
  493 |                         "from wchar_t to a multibyte character: %s\n",
  494 |                         wch, strerror(errno));
      |                         ~~~
      |                         |
      |                         wchar_t {aka long int}
ui/curses.c:504:49: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘long int’} [-Werror=format=]
  504 |         fprintf(stderr, "Could not convert 0x%04x "
      |                                              ~~~^
      |                                                 |
      |                                                 unsigned int
      |                                              %04lx
  505 |                         "from a multibyte character to UCS-2 : %s\n",
  506 |                         wch, strerror(errno));
      |                         ~~~
      |                         |
      |                         wchar_t {aka long int}

Fix this by casting the wchar_t value to an unsigned long and using %lx
as the conversion specifier.

Fixes: b7b664a4fe9a955338f2e11a0f7433b29c8cbad0
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-id: 20190527142540.23255-1-mreitz@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/curses.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ui/curses.c b/ui/curses.c
index 1f3fcabb004b..e9319eb8ae19 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -489,9 +489,9 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
     memset(&ps, 0, sizeof(ps));
     ret = wcrtomb(mbch, wch, &ps);
     if (ret == -1) {
-        fprintf(stderr, "Could not convert 0x%04x "
+        fprintf(stderr, "Could not convert 0x%04lx "
                         "from wchar_t to a multibyte character: %s\n",
-                        wch, strerror(errno));
+                        (unsigned long)wch, strerror(errno));
         return 0xFFFD;
     }
 
@@ -501,9 +501,9 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
     such = sizeof(uch);
 
     if (iconv(conv, &pmbch, &smbch, &puch, &such) == (size_t) -1) {
-        fprintf(stderr, "Could not convert 0x%04x "
+        fprintf(stderr, "Could not convert 0x%04lx "
                         "from a multibyte character to UCS-2 : %s\n",
-                        wch, strerror(errno));
+                        (unsigned long)wch, strerror(errno));
         return 0xFFFD;
     }
 
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 2/5] console: add dmabuf modifier field.
  2019-06-07 13:18 [Qemu-devel] [PULL 0/5] Ui 20190607 patches Gerd Hoffmann
  2019-06-07 13:18 ` [Qemu-devel] [PULL 1/5] ui/curses: Fix build with -m32 Gerd Hoffmann
@ 2019-06-07 13:18 ` Gerd Hoffmann
  2019-06-07 13:18 ` [Qemu-devel] [PULL 3/5] vfio/display: set " Gerd Hoffmann
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-06-07 13:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Gerd Hoffmann

dmabufs can have a format modifier (DRM_FORMAT_MOD_*) which is used for
tiled layouts for example.  Add a field to QemuDmaBuf so we can carry
around that information.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 20190529072144.26737-2-kraxel@redhat.com
---
 include/ui/console.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index fef900db76a5..f9816968487c 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -175,6 +175,7 @@ typedef struct QemuDmaBuf {
     uint32_t  height;
     uint32_t  stride;
     uint32_t  fourcc;
+    uint64_t  modifier;
     uint32_t  texture;
     bool      y0_top;
 } QemuDmaBuf;
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 3/5] vfio/display: set dmabuf modifier field
  2019-06-07 13:18 [Qemu-devel] [PULL 0/5] Ui 20190607 patches Gerd Hoffmann
  2019-06-07 13:18 ` [Qemu-devel] [PULL 1/5] ui/curses: Fix build with -m32 Gerd Hoffmann
  2019-06-07 13:18 ` [Qemu-devel] [PULL 2/5] console: add dmabuf modifier field Gerd Hoffmann
@ 2019-06-07 13:18 ` Gerd Hoffmann
  2019-06-07 13:19 ` [Qemu-devel] [PULL 4/5] egl-helpers: add modifier support to egl_get_fd_for_texture() Gerd Hoffmann
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-06-07 13:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Gerd Hoffmann

Fill the new QemuDmaBuf->modifier field properly from plane info.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Message-id: 20190529072144.26737-3-kraxel@redhat.com
---
 hw/vfio/display.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/vfio/display.c b/hw/vfio/display.c
index 2c2d3e5b71d6..a5a608c5b226 100644
--- a/hw/vfio/display.c
+++ b/hw/vfio/display.c
@@ -248,6 +248,7 @@ static VFIODMABuf *vfio_display_get_dmabuf(VFIOPCIDevice *vdev,
     dmabuf->buf.height = plane.height;
     dmabuf->buf.stride = plane.stride;
     dmabuf->buf.fourcc = plane.drm_format;
+    dmabuf->buf.modifier = plane.drm_format_mod;
     dmabuf->buf.fd     = fd;
     if (plane_type == DRM_PLANE_TYPE_CURSOR) {
         vfio_display_update_cursor(dmabuf, &plane);
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 4/5] egl-helpers: add modifier support to egl_get_fd_for_texture().
  2019-06-07 13:18 [Qemu-devel] [PULL 0/5] Ui 20190607 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2019-06-07 13:18 ` [Qemu-devel] [PULL 3/5] vfio/display: set " Gerd Hoffmann
@ 2019-06-07 13:19 ` Gerd Hoffmann
  2019-06-07 13:19 ` [Qemu-devel] [PULL 5/5] egl-helpers: add modifier support to egl_dmabuf_import_texture() Gerd Hoffmann
  2019-06-07 14:23 ` [Qemu-devel] [PULL 0/5] Ui 20190607 patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-06-07 13:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Gerd Hoffmann

Add modifier parameter to egl_get_fd_for_texture(), to return the used
modifier on dmabuf exports.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20190529072144.26737-4-kraxel@redhat.com
---
 include/ui/egl-helpers.h | 3 ++-
 ui/egl-helpers.c         | 5 +++--
 ui/spice-display.c       | 7 ++++---
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
index b976cb872821..d71412779913 100644
--- a/include/ui/egl-helpers.h
+++ b/include/ui/egl-helpers.h
@@ -36,7 +36,8 @@ extern struct gbm_device *qemu_egl_rn_gbm_dev;
 extern EGLContext qemu_egl_rn_ctx;
 
 int egl_rendernode_init(const char *rendernode, DisplayGLMode mode);
-int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc);
+int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc,
+                           EGLuint64KHR *modifier);
 
 void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf);
 void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index e90eef8c9c3a..0c9716067cfb 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -200,7 +200,8 @@ err:
     return -1;
 }
 
-int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc)
+int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc,
+                           EGLuint64KHR *modifier)
 {
     EGLImageKHR image;
     EGLint num_planes, fd;
@@ -214,7 +215,7 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc)
     }
 
     eglExportDMABUFImageQueryMESA(qemu_egl_display, image, fourcc,
-                                  &num_planes, NULL);
+                                  &num_planes, modifier);
     if (num_planes != 1) {
         eglDestroyImageKHR(qemu_egl_display, image);
         return -1;
diff --git a/ui/spice-display.c b/ui/spice-display.c
index a5e26479a866..104df2302575 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -888,7 +888,8 @@ static void spice_gl_switch(DisplayChangeListener *dcl,
     if (ssd->ds) {
         surface_gl_create_texture(ssd->gls, ssd->ds);
         fd = egl_get_fd_for_texture(ssd->ds->texture,
-                                    &stride, &fourcc);
+                                    &stride, &fourcc,
+                                    NULL);
         if (fd < 0) {
             surface_gl_destroy_texture(ssd->gls, ssd->ds);
             return;
@@ -945,7 +946,7 @@ static void qemu_spice_gl_scanout_texture(DisplayChangeListener *dcl,
     int fd = -1;
 
     assert(tex_id);
-    fd = egl_get_fd_for_texture(tex_id, &stride, &fourcc);
+    fd = egl_get_fd_for_texture(tex_id, &stride, &fourcc, NULL);
     if (fd < 0) {
         fprintf(stderr, "%s: failed to get fd for texture\n", __func__);
         return;
@@ -1063,7 +1064,7 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl,
                 egl_fb_setup_new_tex(&ssd->blit_fb,
                                      dmabuf->width, dmabuf->height);
                 fd = egl_get_fd_for_texture(ssd->blit_fb.texture,
-                                            &stride, &fourcc);
+                                            &stride, &fourcc, NULL);
                 spice_qxl_gl_scanout(&ssd->qxl, fd,
                                      dmabuf->width, dmabuf->height,
                                      stride, fourcc, false);
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 5/5] egl-helpers: add modifier support to egl_dmabuf_import_texture()
  2019-06-07 13:18 [Qemu-devel] [PULL 0/5] Ui 20190607 patches Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2019-06-07 13:19 ` [Qemu-devel] [PULL 4/5] egl-helpers: add modifier support to egl_get_fd_for_texture() Gerd Hoffmann
@ 2019-06-07 13:19 ` Gerd Hoffmann
  2019-06-07 14:23 ` [Qemu-devel] [PULL 0/5] Ui 20190607 patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-06-07 13:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Gerd Hoffmann

Check and use QemuDmaBuf->modifier in egl_dmabuf_import_texture()
for dmabuf imports.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20190529072144.26737-5-kraxel@redhat.com
---
 ui/egl-helpers.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 0c9716067cfb..edc53f6d3464 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -229,20 +229,36 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc,
 void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf)
 {
     EGLImageKHR image = EGL_NO_IMAGE_KHR;
-    EGLint attrs[] = {
-        EGL_DMA_BUF_PLANE0_FD_EXT,      dmabuf->fd,
-        EGL_DMA_BUF_PLANE0_PITCH_EXT,   dmabuf->stride,
-        EGL_DMA_BUF_PLANE0_OFFSET_EXT,  0,
-        EGL_WIDTH,                      dmabuf->width,
-        EGL_HEIGHT,                     dmabuf->height,
-        EGL_LINUX_DRM_FOURCC_EXT,       dmabuf->fourcc,
-        EGL_NONE, /* end of list */
-    };
+    EGLint attrs[64];
+    int i = 0;
 
     if (dmabuf->texture != 0) {
         return;
     }
 
+    attrs[i++] = EGL_WIDTH;
+    attrs[i++] = dmabuf->width;
+    attrs[i++] = EGL_HEIGHT;
+    attrs[i++] = dmabuf->height;
+    attrs[i++] = EGL_LINUX_DRM_FOURCC_EXT;
+    attrs[i++] = dmabuf->fourcc;
+
+    attrs[i++] = EGL_DMA_BUF_PLANE0_FD_EXT;
+    attrs[i++] = dmabuf->fd;
+    attrs[i++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
+    attrs[i++] = dmabuf->stride;
+    attrs[i++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
+    attrs[i++] = 0;
+#ifdef EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT
+    if (dmabuf->modifier) {
+        attrs[i++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
+        attrs[i++] = (dmabuf->modifier >>  0) & 0xffffffff;
+        attrs[i++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
+        attrs[i++] = (dmabuf->modifier >> 32) & 0xffffffff;
+    }
+#endif
+    attrs[i++] = EGL_NONE;
+
     image = eglCreateImageKHR(qemu_egl_display,
                               EGL_NO_CONTEXT,
                               EGL_LINUX_DMA_BUF_EXT,
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PULL 0/5] Ui 20190607 patches
  2019-06-07 13:18 [Qemu-devel] [PULL 0/5] Ui 20190607 patches Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2019-06-07 13:19 ` [Qemu-devel] [PULL 5/5] egl-helpers: add modifier support to egl_dmabuf_import_texture() Gerd Hoffmann
@ 2019-06-07 14:23 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2019-06-07 14:23 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Alex Williamson, QEMU Developers

On Fri, 7 Jun 2019 at 14:21, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> The following changes since commit 0d74f3b4277a7ecb0ccb80c865797d11f8e466f5:
>
>   Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging (2019-06-06 14:09:14 +0100)
>
> are available in the Git repository at:
>
>   git://git.kraxel.org/qemu tags/ui-20190607-pull-request
>
> for you to fetch changes up to 15ee0d9bc10b3de677ff6cd78b6dc9d5a7d40603:
>
>   egl-helpers: add modifier support to egl_dmabuf_import_texture() (2019-06-07 11:52:35 +0200)
>
> ----------------------------------------------------------------
> curses: 32bit build fix.
> egl: dmabuf modifier support.
>
> ----------------------------------------------------------------
>
> Gerd Hoffmann (4):
>   console: add dmabuf modifier field.
>   vfio/display: set dmabuf modifier field
>   egl-helpers: add modifier support to egl_get_fd_for_texture().
>   egl-helpers: add modifier support to egl_dmabuf_import_texture()
>
> Max Reitz (1):
>   ui/curses: Fix build with -m32


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-06-07 15:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-07 13:18 [Qemu-devel] [PULL 0/5] Ui 20190607 patches Gerd Hoffmann
2019-06-07 13:18 ` [Qemu-devel] [PULL 1/5] ui/curses: Fix build with -m32 Gerd Hoffmann
2019-06-07 13:18 ` [Qemu-devel] [PULL 2/5] console: add dmabuf modifier field Gerd Hoffmann
2019-06-07 13:18 ` [Qemu-devel] [PULL 3/5] vfio/display: set " Gerd Hoffmann
2019-06-07 13:19 ` [Qemu-devel] [PULL 4/5] egl-helpers: add modifier support to egl_get_fd_for_texture() Gerd Hoffmann
2019-06-07 13:19 ` [Qemu-devel] [PULL 5/5] egl-helpers: add modifier support to egl_dmabuf_import_texture() Gerd Hoffmann
2019-06-07 14:23 ` [Qemu-devel] [PULL 0/5] Ui 20190607 patches Peter Maydell

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).