From: Pekka Paalanen <ppaalanen@gmail.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH RFC libdrm 2/2] util: Fix 32 bpp patterns on big-endian
Date: Tue, 8 Mar 2022 11:29:56 +0200 [thread overview]
Message-ID: <20220308112956.73598e53@eldfell> (raw)
In-Reply-To: <1be5820fe86d6940aab8acd52a522d39a35995c3.1646684158.git.geert@linux-m68k.org>
[-- Attachment #1: Type: text/plain, Size: 1653 bytes --]
On Mon, 7 Mar 2022 21:53:42 +0100
Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> DRM formats are defined to be little-endian, unless the
> DRM_FORMAT_BIG_ENDIAN flag is set. Hence writes of multi-byte pixel
> values need to take endianness into account.
>
> Introduce a cpu_to_le32() helper to convert 32-bit values from
> CPU-endian to little-endian, and use them in the various pattern fill
> functions for 32-bit formats.
Hi Geert,
FWIW, this explanation matches my understanding, so it sounds correct
to me. That's all I can say. I guess that means
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
?
Thanks,
pq
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Works now with Linux' drm_fb_xrgb8888_to_rgb332_line(), which uses
> le32_to_cpu() to read pixel values from memory.
>
> ---
> tests/util/pattern.c | 30 +++++++++++++++++++++---------
> 1 file changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/tests/util/pattern.c b/tests/util/pattern.c
> index 42d75d700700dc3d..48677ea6d25b2676 100644
> --- a/tests/util/pattern.c
> +++ b/tests/util/pattern.c
> @@ -61,6 +61,18 @@ struct color_yuv {
> .u = MAKE_YUV_601_U(r, g, b), \
> .v = MAKE_YUV_601_V(r, g, b) }
>
> +#if defined(__BIG_ENDIAN__) || defined(__sparc__) || defined(__mc68000__) || defined(__MIPSEB__)
> +static inline uint32_t cpu_to_le32(uint32_t x)
> +{
> + return ((x & 0x000000ffU) << 24) |
> + ((x & 0x0000ff00U) << 8) |
> + ((x & 0x00ff0000U) >> 8) |
> + ((x & 0xff000000U) >> 24);
> +}
> +#else
> +#define cpu_to_le32(x) (x)
> +#endif
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2022-03-08 9:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 20:53 [PATCH RFC libdrm 0/2] Big-endian fixes Geert Uytterhoeven
2022-03-07 20:53 ` [PATCH RFC libdrm 1/2] intel: Improve checks for big-endian Geert Uytterhoeven
2022-03-08 12:48 ` Robin Murphy
2022-03-07 20:53 ` [PATCH RFC libdrm 2/2] util: Fix 32 bpp patterns on big-endian Geert Uytterhoeven
2022-03-08 9:29 ` Pekka Paalanen [this message]
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=20220308112956.73598e53@eldfell \
--to=ppaalanen@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert@linux-m68k.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 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.