@@ -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,
@@ -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;
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(+)