From: Javier Martinez Canillas <javierm@redhat.com>
To: Jocelyn Falempe <jfalempe@redhat.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
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>,
Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev
Subject: Re: [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests
Date: Tue, 20 Aug 2024 16:27:46 +0200 [thread overview]
Message-ID: <87a5h79sm5.fsf@minerva.mail-host-address-is-not-set> (raw)
In-Reply-To: <ddd41844-1d3e-4755-9013-9ae4e751c501@redhat.com>
Jocelyn Falempe <jfalempe@redhat.com> writes:
> On 20/08/2024 14:48, Thomas Zimmermann wrote:
>> Hi
>>
>> Am 20.08.24 um 11:07 schrieb Jocelyn Falempe:
>>> 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
>>
>> As these defines are only used here, would it be beneficial to put the
>> __BIG_ENDIAN branch directly around the switch statement?
>
> That was my first version, but I found it difficult to read, when I mix
> #ifdef in a switch case.
>
>
> or maybe something like the following would be better ?
>
>
> switch (drm_fourcc) {
> #ifdef _BIG_ENDIAN
> case DRM_FORMAT_XRGB8888:
> format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
> break;
> case DRM_FORMAT_ARGB8888:
> format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
> break;
> #else
> case DRM_FORMAT_XRGB8888:
> format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
> break;
> case DRM_FORMAT_ARGB8888:
> format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
> break;
> #endif
IMO your current patch is easier to read than having the ifdefery
in the switch statement.
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
next prev parent reply other threads:[~2024-08-20 14:27 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 ` [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests Jocelyn Falempe
2024-08-20 12:48 ` Thomas Zimmermann
2024-08-20 12:55 ` Jocelyn Falempe
2024-08-20 13:25 ` Thomas Zimmermann
2024-08-20 14:27 ` Javier Martinez Canillas [this message]
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=87a5h79sm5.fsf@minerva.mail-host-address-is-not-set \
--to=javierm@redhat.com \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=jfalempe@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;
as well as URLs for NNTP newsgroup(s).