All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
	Tina Zhang <tina.zhang@intel.com>,
	intel-gvt-dev@lists.freedesktop.org,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [RfC PATCH 3/6] ui/pixman: add qemu_drm_format_to_pixman()
Date: Tue, 10 Oct 2017 16:03:31 +0200	[thread overview]
Message-ID: <20171010140334.8231-4-kraxel@redhat.com> (raw)
In-Reply-To: <20171010140334.8231-1-kraxel@redhat.com>

Map drm fourcc codes to pixman formats.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/qemu-pixman.h |  1 +
 ui/qemu-pixman.c         | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index 4a67e01232..75661db080 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -51,6 +51,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 6e591ab821..2c389ad323 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,25 @@ 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_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;
-- 
2.9.3

  parent reply	other threads:[~2017-10-10 14:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 14:03 [Qemu-devel] [RfC PATCH 0/6] vfio: add display support Gerd Hoffmann
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 1/6] headers: update linux-headers/linux/vfio.h (intel-gvt kernel patches, v15) Gerd Hoffmann
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 2/6] headers: add drm/drm_fourcc.h to standard-headers Gerd Hoffmann
2017-10-10 14:03 ` Gerd Hoffmann [this message]
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 4/6] vfio/display: core & wireup Gerd Hoffmann
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 5/6] vfio/display: adding region support Gerd Hoffmann
2017-10-10 20:27   ` Alex Williamson
2017-10-11 10:47     ` Gerd Hoffmann
2017-10-11 16:55       ` Alex Williamson
2017-11-10 10:48         ` Gerd Hoffmann
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 6/6] vfio/display: add dmabuf support (v15) Gerd Hoffmann
2017-10-10 20:27   ` Alex Williamson
2017-10-11  7:01     ` Gerd Hoffmann
2017-10-10 14:20 ` [Qemu-devel] [RfC PATCH 0/6] vfio: add display support no-reply
2017-10-10 14:23 ` no-reply

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=20171010140334.8231-4-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --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.