diff --git a/include/libcamera/formats.h.in b/include/libcamera/formats.h.in
index 5ff9c3bf4..c821ffbb1 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<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 */
diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py
index 872f3fe34..01adf5e1f 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') == True,
         }
 
         mod = format.get('mod')
