util: fix 16 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)
commit1b8d0e5ccd6db08185c4c178db40535b69e2505f
tree7eedaa32be5b48e09efd9194c18553818c561540
parent8cb6d837ccd140da54ab021e3860b7ef32c63e72
util: fix 16 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 swap16() helper to byteswap 16-bit values, and a
cpu_to_le16() helper to convert 16-bit values from CPU-endian to
little-endian, and use the latter in the various pattern fill functions
for 16-bit formats.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
  - Add Reviewed-by,

v4:
  - No changes,

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

v2:
  - New.
tests/util/pattern.c