All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: QEMU <qemu-devel@nongnu.org>,
	intel-gvt-dev@lists.freedesktop.org,
	Tina Zhang <tina.zhang@intel.com>
Subject: Re: [Qemu-devel] [PATCH 1/6] console: add support for dmabufs
Date: Thu, 7 Jun 2018 12:38:12 +0200	[thread overview]
Message-ID: <CAJ+F1C+cJ5q7+OMPENg44A8kE8qOj0b0MOnqXLWoHMwo41yDdA@mail.gmail.com> (raw)
In-Reply-To: <20171010135453.6704-2-kraxel@redhat.com>

Hi Gerd

On Tue, Oct 10, 2017 at 3:54 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> This patch adds support for dma-bufs to the qemu console interfaces.
> It adds a new "struct QemuDmaBuf" to represent a dmabuf with accociated
> metatdata (size, format).  It adds three functions (and
> DisplayChangeListenerOps operations) to set a dma-buf as display
> scanout, as cursor and to release a dmabuf.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/qemu/typedefs.h |  1 +
>  include/ui/console.h    | 25 +++++++++++++++++++++++++
>  ui/console.c            | 33 +++++++++++++++++++++++++++++++++
>  3 files changed, 59 insertions(+)
>
> diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
> index 980d2b330e..3dbc69b1e9 100644
> --- a/include/qemu/typedefs.h
> +++ b/include/qemu/typedefs.h
> @@ -83,6 +83,7 @@ typedef struct PropertyInfo PropertyInfo;
>  typedef struct PS2State PS2State;
>  typedef struct QEMUBH QEMUBH;
>  typedef struct QemuConsole QemuConsole;
> +typedef struct QemuDmaBuf QemuDmaBuf;
>  typedef struct QEMUFile QEMUFile;
>  typedef struct QemuOpt QemuOpt;
>  typedef struct QemuOpts QemuOpts;
> diff --git a/include/ui/console.h b/include/ui/console.h
> index 6966e4bd9d..158969f978 100644
> --- a/include/ui/console.h
> +++ b/include/ui/console.h
> @@ -5,6 +5,7 @@
>  #include "qom/object.h"
>  #include "qapi/qmp/qdict.h"
>  #include "qemu/notify.h"
> +#include "qemu/typedefs.h"
>  #include "qapi-types.h"
>  #include "qemu/error-report.h"
>  #include "qapi/error.h"
> @@ -180,6 +181,15 @@ struct QEMUGLParams {
>      int minor_ver;
>  };
>
> +struct QemuDmaBuf {
> +    int       fd;
> +    uint32_t  width;
> +    uint32_t  height;
> +    uint32_t  stride;
> +    uint32_t  fourcc;
> +    uint32_t  texture;
> +};
> +
>  typedef struct DisplayChangeListenerOps {
>      const char *dpy_name;
>
> @@ -220,6 +230,13 @@ typedef struct DisplayChangeListenerOps {
>                                     uint32_t backing_height,
>                                     uint32_t x, uint32_t y,
>                                     uint32_t w, uint32_t h);
> +    void (*dpy_gl_scanout_dmabuf)(DisplayChangeListener *dcl,
> +                                  QemuDmaBuf *dmabuf);
> +    void (*dpy_gl_cursor_dmabuf)(DisplayChangeListener *dcl,
> +                                 QemuDmaBuf *dmabuf,
> +                                 uint32_t pos_x, uint32_t pos_y);
> +    void (*dpy_gl_release_dmabuf)(DisplayChangeListener *dcl,
> +                                  QemuDmaBuf *dmabuf);
>      void (*dpy_gl_update)(DisplayChangeListener *dcl,
>                            uint32_t x, uint32_t y, uint32_t w, uint32_t h);
>
> @@ -288,6 +305,13 @@ void dpy_gl_scanout_texture(QemuConsole *con,
>                              uint32_t backing_id, bool backing_y_0_top,
>                              uint32_t backing_width, uint32_t backing_height,
>                              uint32_t x, uint32_t y, uint32_t w, uint32_t h);
> +void dpy_gl_scanout_dmabuf(QemuConsole *con,
> +                           QemuDmaBuf *dmabuf);
> +void dpy_gl_cursor_dmabuf(QemuConsole *con,
> +                          QemuDmaBuf *dmabuf,
> +                          uint32_t pos_x, uint32_t pos_y);
> +void dpy_gl_release_dmabuf(QemuConsole *con,
> +                           QemuDmaBuf *dmabuf);
>  void dpy_gl_update(QemuConsole *con,
>                     uint32_t x, uint32_t y, uint32_t w, uint32_t h);
>
> @@ -298,6 +322,7 @@ int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx);
>  QEMUGLContext dpy_gl_ctx_get_current(QemuConsole *con);
>
>  bool console_has_gl(QemuConsole *con);
> +bool console_has_gl_dmabuf(QemuConsole *con);
>
>  static inline int surface_stride(DisplaySurface *s)
>  {
> diff --git a/ui/console.c b/ui/console.c
> index b82c27960a..eca854cbd5 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -1404,6 +1404,11 @@ bool console_has_gl(QemuConsole *con)
>      return con->gl != NULL;
>  }
>
> +bool console_has_gl_dmabuf(QemuConsole *con)
> +{
> +    return con->gl != NULL && con->gl->ops->dpy_gl_scanout_dmabuf != NULL;
> +}

You added this function, but it is not being used. Somewhere it should
be used to prevent crashes of dpy_gl_scanout_dmabuf()  though. I don't
have a good idea where to atm.

> +
>  void register_displaychangelistener(DisplayChangeListener *dcl)
>  {
>      static const char nodev[] =
> @@ -1745,6 +1750,34 @@ void dpy_gl_scanout_texture(QemuConsole *con,
>                                           x, y, width, height);
>  }
>
> +void dpy_gl_scanout_dmabuf(QemuConsole *con,
> +                           QemuDmaBuf *dmabuf)
> +{
> +    assert(con->gl);
> +    con->gl->ops->dpy_gl_scanout_dmabuf(con->gl, dmabuf);
> +}
> +
> +void dpy_gl_cursor_dmabuf(QemuConsole *con,
> +                          QemuDmaBuf *dmabuf,
> +                          uint32_t pos_x, uint32_t pos_y)
> +{
> +    assert(con->gl);
> +
> +    if (con->gl->ops->dpy_gl_cursor_dmabuf) {
> +        con->gl->ops->dpy_gl_cursor_dmabuf(con->gl, dmabuf, pos_x, pos_y);
> +    }
> +}
> +
> +void dpy_gl_release_dmabuf(QemuConsole *con,
> +                          QemuDmaBuf *dmabuf)
> +{
> +    assert(con->gl);
> +
> +    if (con->gl->ops->dpy_gl_release_dmabuf) {
> +        con->gl->ops->dpy_gl_release_dmabuf(con->gl, dmabuf);
> +    }
> +}
> +
>  void dpy_gl_update(QemuConsole *con,
>                     uint32_t x, uint32_t y, uint32_t w, uint32_t h)
>  {
> --
> 2.9.3
>
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev



-- 
Marc-André Lureau

  reply	other threads:[~2018-06-07 10:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 13:54 [Qemu-devel] [PATCH 0/6] ui: start adding dma-buf support Gerd Hoffmann
2017-10-10 13:54 ` [Qemu-devel] [PATCH 1/6] console: add support for dmabufs Gerd Hoffmann
2018-06-07 10:38   ` Marc-André Lureau [this message]
2017-10-10 13:54 ` [Qemu-devel] [PATCH 2/6] opengl: move shader init from console-gl.c to shader.c Gerd Hoffmann
2017-10-10 13:54 ` [Qemu-devel] [PATCH 3/6] opengl: add flipping vertex shader Gerd Hoffmann
2017-10-10 13:54 ` [Qemu-devel] [PATCH 4/6] egl-helpers: add dmabuf import support Gerd Hoffmann
2017-10-10 13:54 ` [Qemu-devel] [PATCH 5/6] egl-helpers: add egl_texture_blit and egl_texture_blend Gerd Hoffmann
2017-10-10 13:54 ` [Qemu-devel] [PATCH 6/6] egl-headless: add dmabuf support Gerd Hoffmann

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=CAJ+F1C+cJ5q7+OMPENg44A8kE8qOj0b0MOnqXLWoHMwo41yDdA@mail.gmail.com \
    --to=marcandre.lureau@gmail.com \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tina.zhang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.