From patchwork Thu Nov 26 09:11:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 29089 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 75F1CC3304 for ; Thu, 26 Nov 2026 09:11:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC5DB6AA19; Thu, 26 Nov 2026 10:11:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IekhBqxs"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8510A6AA06 for ; Thu, 26 Nov 2026 10:11:07 +0100 (CET) Received: from pb-laptop.local (185.182.215.119.nat.pool.zt.hu [185.182.215.119]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3FC1BC25 for ; Thu, 26 Nov 2026 10:08:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1795684113; bh=7WJXxef332HVQayZSXBvBhKJ5+TTSO9PwRyybtGsZgk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IekhBqxsXj8OlhLqAomOAyeuWEvG/ZW/nXEIEH1VDiy/XjmC4kRtN203QtdpacsJX O/Fnu8OydHW+WFiOQ9+1pFODCNF/L60hls1sF65V9a8zdCW+wlWb+/YMXZJAQKHgh9 HZVDUpoM42OUIhZMR1hutSAMxHcWrtmZSLSROb+k= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v2 2/3] utils: codegen: gen-formats: Support multiple fourcc headers Date: Thu, 26 Nov 2026 10:11:02 +0100 Message-ID: <20261126091103.1843573-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261126091103.1843573-1-barnabas.pocze@ideasonboard.com> References: <20261126091103.1843573-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Kieran Bingham --- utils/codegen/gen-formats.py | 41 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) 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']