qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 02/11] ui/pixman: add qemu_drm_format_to_pixman()
Date: Tue, 13 Mar 2018 14:17:54 -0600	[thread overview]
Message-ID: <20180313201754.2327.44722.stgit@gimli.home> (raw)
In-Reply-To: <20180313201415.2327.62402.stgit@gimli.home>

From: Gerd Hoffmann <kraxel@redhat.com>

Map drm fourcc codes to pixman formats.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed by: Kirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 include/ui/qemu-pixman.h |    5 +++++
 ui/qemu-pixman.c         |   22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index 4a67e01232d7..b7c82d17fc5f 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -33,6 +33,8 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_r8g8b8a8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_x8b8g8r8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_a8b8g8r8
+# define PIXMAN_LE_r8g8b8     PIXMAN_b8g8r8
+# define PIXMAN_LE_a8r8g8b8   PIXMAN_b8g8r8a8
 # define PIXMAN_LE_x8r8g8b8   PIXMAN_b8g8r8x8
 #else
 # define PIXMAN_BE_r8g8b8     PIXMAN_b8g8r8
@@ -44,6 +46,8 @@
 # define PIXMAN_BE_r8g8b8a8   PIXMAN_a8b8g8r8
 # define PIXMAN_BE_x8b8g8r8   PIXMAN_r8g8b8x8
 # define PIXMAN_BE_a8b8g8r8   PIXMAN_r8g8b8a8
+# define PIXMAN_LE_r8g8b8     PIXMAN_r8g8b8
+# define PIXMAN_LE_a8r8g8b8   PIXMAN_a8r8g8b8
 # define PIXMAN_LE_x8r8g8b8   PIXMAN_x8r8g8b8
 #endif
 
@@ -51,6 +55,7 @@
 
 PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format);
 pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian);
+pixman_format_code_t qemu_drm_format_to_pixman(uint32_t drm_format);
 int qemu_pixman_get_type(int rshift, int gshift, int bshift);
 pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf);
 bool qemu_pixman_check_format(DisplayChangeListener *dcl,
diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
index 6e591ab82131..3e52abd92d0a 100644
--- a/ui/qemu-pixman.c
+++ b/ui/qemu-pixman.c
@@ -6,6 +6,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "ui/console.h"
+#include "standard-headers/drm/drm_fourcc.h"
 
 PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format)
 {
@@ -88,6 +89,27 @@ pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian)
     return 0;
 }
 
+/* Note: drm is little endian, pixman is native endian */
+pixman_format_code_t qemu_drm_format_to_pixman(uint32_t drm_format)
+{
+    static const struct {
+        uint32_t drm_format;
+        pixman_format_code_t pixman;
+    } map[] = {
+        { DRM_FORMAT_RGB888,   PIXMAN_LE_r8g8b8   },
+        { DRM_FORMAT_ARGB8888, PIXMAN_LE_a8r8g8b8 },
+        { DRM_FORMAT_XRGB8888, PIXMAN_LE_x8r8g8b8 }
+    };
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(map); i++) {
+        if (drm_format == map[i].drm_format) {
+            return map[i].pixman;
+        }
+    }
+    return 0;
+}
+
 int qemu_pixman_get_type(int rshift, int gshift, int bshift)
 {
     int type = PIXMAN_TYPE_OTHER;

  parent reply	other threads:[~2018-03-13 20:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 20:17 [Qemu-devel] [PULL 00/11] vfio updates for QEMU-2.12 soft freeze Alex Williamson
2018-03-13 20:17 ` [Qemu-devel] [PULL 01/11] standard-headers: add drm/drm_fourcc.h Alex Williamson
2018-03-13 20:17 ` Alex Williamson [this message]
2018-03-13 20:18 ` [Qemu-devel] [PULL 03/11] console: minimal hotplug suport Alex Williamson
2018-03-13 20:18 ` [Qemu-devel] [PULL 04/11] secondary-vga: properly close QemuConsole on unplug Alex Williamson
2018-03-13 20:18 ` [Qemu-devel] [PULL 05/11] vfio/common: cleanup in vfio_region_finalize Alex Williamson
2018-03-13 20:18 ` [Qemu-devel] [PULL 06/11] vfio/display: core & wireup Alex Williamson
2018-03-13 20:18 ` [Qemu-devel] [PULL 07/11] vfio/display: adding region support Alex Williamson
2018-03-13 20:18 ` [Qemu-devel] [PULL 08/11] vfio/display: adding dmabuf support Alex Williamson
2018-03-13 20:18 ` [Qemu-devel] [PULL 09/11] vfio/pci: Relax DMA map errors for MMIO regions Alex Williamson
2018-03-13 20:19 ` [Qemu-devel] [PULL 10/11] vfio-pci: Allow mmap of MSIX BAR Alex Williamson
2018-03-13 20:19 ` [Qemu-devel] [PULL 11/11] ppc/spapr, vfio: Turn off MSIX emulation for VFIO devices Alex Williamson
2018-03-16 11:03 ` [Qemu-devel] [PULL 00/11] vfio updates for QEMU-2.12 soft freeze Peter Maydell

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=20180313201754.2327.44722.stgit@gimli.home \
    --to=alex.williamson@redhat.com \
    --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).