From: Jocelyn Falempe <jfalempe@redhat.com>
To: David Airlie <airlied@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Gurchetan Singh <gurchetansingh@chromium.org>,
Chia-I Wu <olvaffe@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev
Cc: Jocelyn Falempe <jfalempe@redhat.com>,
Javier Martinez Canillas <javierm@redhat.com>
Subject: [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests
Date: Tue, 20 Aug 2024 11:07:41 +0200 [thread overview]
Message-ID: <20240820090908.151042-2-jfalempe@redhat.com> (raw)
In-Reply-To: <20240820090908.151042-1-jfalempe@redhat.com>
The colors are inverted when testing a s390x VM on a s390x host.
Changing the conversion from DRM_FORMAT -> VIRTIO_GPU_FORMAT on big
endian guests fixes the colors. But it may break big-endian guest on
little-endian host. In this case, the fix should be in qemu, because
the host endianess is not known in the guest VM.
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
---
drivers/gpu/drm/virtio/virtgpu_plane.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 860b5757ec3fc..0ec6ecc96eb13 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -37,16 +37,24 @@ static const uint32_t virtio_gpu_cursor_formats[] = {
DRM_FORMAT_ARGB8888,
};
+#ifdef __BIG_ENDIAN
+#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM
+#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM
+#else
+#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM
+#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM
+#endif
+
uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
{
uint32_t format;
switch (drm_fourcc) {
case DRM_FORMAT_XRGB8888:
- format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
+ format = VIRTIO_GPU_HOST_XRGB8888;
break;
case DRM_FORMAT_ARGB8888:
- format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
+ format = VIRTIO_GPU_HOST_ARGB8888;
break;
default:
/*
--
2.46.0
next prev parent reply other threads:[~2024-08-20 9:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 9:07 [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Jocelyn Falempe
2024-08-20 9:07 ` Jocelyn Falempe [this message]
2024-08-20 12:48 ` [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests Thomas Zimmermann
2024-08-20 12:55 ` Jocelyn Falempe
2024-08-20 13:25 ` Thomas Zimmermann
2024-08-20 14:27 ` Javier Martinez Canillas
2024-08-21 10:46 ` Gerd Hoffmann
2024-08-21 11:12 ` [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Gerd Hoffmann
2024-08-22 14:46 ` Jocelyn Falempe
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=20240820090908.151042-2-jfalempe@redhat.com \
--to=jfalempe@redhat.com \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=javierm@redhat.com \
--cc=kraxel@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=olvaffe@gmail.com \
--cc=tzimmermann@suse.de \
--cc=virtualization@lists.linux.dev \
/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