[RFC,v1,2/3] utils: codegen: gen-formats: Support multiple fourcc headers
diff mbox series

Message ID 20261117161149.1423792-3-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • include: linux: Split local changes
Related show

Commit Message

Barnabás Pőcze Nov. 17, 2026, 4:11 p.m. UTC
When the upstream and libcamera fourcc codes are split, the code generation
needs to take both into account. So add support for that.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 utils/codegen/gen-formats.py | 41 ++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

Patch
diff mbox series

diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py
index 740790e8f1..a889063ff5 100755
--- a/utils/codegen/gen-formats.py
+++ b/utils/codegen/gen-formats.py
@@ -19,29 +19,30 @@  class DRMFourCC(object):
     mod_vendor_regex = re.compile(r"#define DRM_FORMAT_MOD_VENDOR_([A-Z0-9_]+)[ \t]+([0-9a-fA-Fx]+)")
     mod_regex = re.compile(r"#define ([A-Za-z0-9_]+)[ \t]+fourcc_mod_code\(([A-Z0-9_]+), ([0-9a-fA-Fx]+)\)")
 
-    def __init__(self, file):
+    def __init__(self, files):
         self.formats = {}
         self.vendors = {}
         self.mods = {}
 
-        for line in file:
-            match = DRMFourCC.format_regex.match(line)
-            if match:
-                format, fourcc = match.groups()
-                self.formats[format] = fourcc
-                continue
-
-            match = DRMFourCC.mod_vendor_regex.match(line)
-            if match:
-                vendor, value = match.groups()
-                self.vendors[vendor] = int(value, 0)
-                continue
-
-            match = DRMFourCC.mod_regex.match(line)
-            if match:
-                mod, vendor, value = match.groups()
-                self.mods[mod] = (vendor, int(value, 0))
-                continue
+        for file in files:
+            for line in file:
+                match = DRMFourCC.format_regex.match(line)
+                if match:
+                    format, fourcc = match.groups()
+                    self.formats[format] = fourcc
+                    continue
+
+                match = DRMFourCC.mod_vendor_regex.match(line)
+                if match:
+                    vendor, value = match.groups()
+                    self.vendors[vendor] = int(value, 0)
+                    continue
+
+                match = DRMFourCC.mod_regex.match(line)
+                if match:
+                    mod, vendor, value = match.groups()
+                    self.mods[mod] = (vendor, int(value, 0))
+                    continue
 
     def fourcc(self, name):
         return self.formats[name]
@@ -86,7 +87,7 @@  def main(argv):
     parser.add_argument('template', type=argparse.FileType('r', encoding='utf-8'),
                         help='Template file name.')
     parser.add_argument('drm_fourcc', type=argparse.FileType('r', encoding='utf-8'),
-                        help='Path to drm_fourcc.h.')
+                        help='Path to drm_fourcc.h.', nargs='+')
     args = parser.parse_args(argv[1:])
 
     formats = yaml.safe_load(args.input)['formats']