utils: codegen: gen-formats.py: Fix big endian formats

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 <barnabas.pocze@ideasonboard.com>
Fixes: 7c496f1c54 ("utils: gen-formats: Support big-endian DRM formats")
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze
2025-09-01 10:59:23 +02:00
parent 479a9031f5
commit 7602181be1
2 changed files with 4 additions and 3 deletions

View File

@@ -33,10 +33,12 @@ constexpr uint64_t __mod(unsigned int vendor, unsigned int mod)
(static_cast<uint64_t>(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 */

View File

@@ -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')