From 7602181be11e70d132ca84cbf44e43093749f9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 1 Sep 2025 10:59:23 +0200 Subject: [PATCH] utils: codegen: gen-formats.py: Fix big endian formats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First, there is a single big endian format defined in `formats.yaml`: RGB565_BE. However, while the yaml file specifies "big_endian: true", the python script looks for a key named "big-endian". Causing `RGB565{,_BE}` both to be the same. Second, the python script simply appends " | DRM_FORMAT_BIG_ENDIAN" to the fourcc of the format. However, there is no definition of that macro is available in the only user, `formats.h.in`. Fix the first one by checking for "big_endian" in the script as well, and fix the second one by defining a constant with the same value and using that. Signed-off-by: Barnabás Pőcze Fixes: 7c496f1c54dd58 ("utils: gen-formats: Support big-endian DRM formats") Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/formats.h.in | 4 +++- utils/codegen/gen-formats.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/libcamera/formats.h.in b/include/libcamera/formats.h.in index 9bbf1912..f20c60c9 100644 --- a/include/libcamera/formats.h.in +++ b/include/libcamera/formats.h.in @@ -33,10 +33,12 @@ constexpr uint64_t __mod(unsigned int vendor, unsigned int mod) (static_cast(mod) << 0); } +constexpr uint32_t kDrmFormatBigEndian = uint32_t(1) << 31; /* DRM_FORMAT_BIG_ENDIAN */ + } /* namespace */ {% for f in formats -%} -constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}), __mod({{f.mod}})); +constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}){{ ' | kDrmFormatBigEndian' if f.big_endian }}, __mod({{f.mod}})); {% endfor %} } /* namespace formats */ diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py index 1f9def58..7542d884 100755 --- a/utils/codegen/gen-formats.py +++ b/utils/codegen/gen-formats.py @@ -59,13 +59,12 @@ def generate_formats(formats, drm_fourcc): for format in formats: name, format = format.popitem() fourcc = drm_fourcc.fourcc(format['fourcc']) - if format.get('big-endian'): - fourcc += '| DRM_FORMAT_BIG_ENDIAN' data = { 'name': name, 'fourcc': fourcc, 'mod': '0, 0', + 'big_endian': format.get('big_endian'), } mod = format.get('mod')