From patchwork Tue Nov 17 16:11:48 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: 28955 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 9D01FBDE17 for ; Tue, 17 Nov 2026 16:12:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D856F6A8A8; Tue, 17 Nov 2026 17:11:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TlLaJdEg"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D0DCE6A895 for ; Tue, 17 Nov 2026 17:11:53 +0100 (CET) Received: from pb-laptop.local (185.221.140.49.nat.pool.zt.hu [185.221.140.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3437520E4 for ; Tue, 17 Nov 2026 17:09:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1794931766; bh=7WJXxef332HVQayZSXBvBhKJ5+TTSO9PwRyybtGsZgk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TlLaJdEgs7/P9C+sAeEOULdMjgF56y4T+LrMpT++RTdRz3CWIumyy9LOiNBnHEfrZ hZDUYD6lrzF7m/m9gHnvycy/1k+Wq9l3C5p38oQo7lqvL4RnFlSidOOTOTFSq/Hrmu txxKiNZF+XdddqUuZv1wavZf6uaArWpZKLqB5ZQY= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 2/3] utils: codegen: gen-formats: Support multiple fourcc headers Date: Tue, 17 Nov 2026 17:11:48 +0100 Message-ID: <20261117161149.1423792-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261117161149.1423792-1-barnabas.pocze@ideasonboard.com> References: <20261117161149.1423792-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 --- 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']