util: fix 32 bpp patterns on big-endian
authorGeert Uytterhoeven <geert@linux-m68k.org>
Thu, 3 Mar 2022 16:58:08 +0000 (17:58 +0100)
committerDmitry Baryshkov <dbaryshkov@gmail.com>
Tue, 31 Oct 2023 13:24:32 +0000 (13:24 +0000)
commit8cb6d837ccd140da54ab021e3860b7ef32c63e72
treeda64652263eeba907071751218644b43d0374c56
parent5dba8d73df173c422e39eba93ea88f18e87a2d4b
util: fix 32 bpp patterns on big-endian

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 swap32() helper to byteswap 32-bit values, and a
cpu_to_le32() helper to convert 32-bit values from CPU-endian to
little-endian, and use the latter in the various pattern fill functions
for 32-bit formats.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
  - Add Reviewed-by,

v4:
  - Use new HAVE_BIG_ENDIAN symbol,

v3:
  - Increase indentation after definition of cpu_to_le32(),

v2:
  - Add Acked-by,
  - Add swap32() intermediate helper,
  - Add __ARM_BIG_ENDIAN and __s390__.
tests/util/pattern.c