From patchwork Fri Jun 26 11:54:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 27057 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 58BD0C3301 for ; Fri, 26 Jun 2026 12:00:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 524BA658FA; Fri, 26 Jun 2026 14:00:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="PZaBmfJ4"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 24C75658F2 for ; Fri, 26 Jun 2026 14:00:48 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-49254e68922so230735e9.0 for ; Fri, 26 Jun 2026 05:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1782475248; x=1783080048; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YJ2j2YFI2gtwpHQ6GxpM81KxZWVYfpTifYHhAI9CDqg=; b=PZaBmfJ4KMhYMMTqAeCjb5eOmRu/pbhiUJX0Xj1E8DmulYspeb0IkkOj+HUdNT/dEo 2tZOY1HC/r6sNctxRttxg4Y/qp/2kiBw2B7Ok7u//VxqNoQ9eEFeTwFR0Z5W187upMEs DBJC6gmuUq66lEdmo+h0/x2tiQqqDXdy4PXMjsE/q316rzfR+JzxDtfB02FnMI9LaO/O Y6qpYV6rniEvavAbsFvC52O0Mwsxa3ckWuIjQDdn1WV1NUcqQKmmH3yugEoOCxNbLk4Q McVpPPTvcXC1gbIvFrP4nM2qJkHEXtNlHLMr5AH41RRGMhvejd+7VHPMKk5R10/8TDTj st2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782475248; x=1783080048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=YJ2j2YFI2gtwpHQ6GxpM81KxZWVYfpTifYHhAI9CDqg=; b=H72l54l46WykvSRu85dN5I5NyMyyvAARp0wKN0I248yVdOz76FdbbZUmg+d1xlxxf7 ub0mDF1fZyAuspfoR2IbCaD+AGwdxTN14F6B8VHoYVDY/N6MwS1a15slmrbNJNdUEYvg 46VueLtzCcsLsxZ2CgJX/9F8m03eBFrCGfgXapxsizxRs+dVgACtH793aRZezlKKSRxg +FrrP5mux4q9nNDBF443UGEvQqfTBvRmHZJjSEbe/OIdKVqr3KbFJiyPVKNChjUnSGWw EyqUWeZ42AutMH4/iCkXcxNsDLrO9AIf0hDsOjl/sRxWo8bPeqVV04HAfFQqtCWCFop3 jXag== X-Gm-Message-State: AOJu0YxuIiDyFHFefkbkRc0v/fWyuPXAhMZelHBAkvnWCOw5yi44cHCf NVVRbidYUOKEwV1cnTbAjLW+FsLjP5c/dcAC3jEyJ1hxvV5KtdO2hUAFLztqtB6yp0iTnVm/wOb VpP74khw= X-Gm-Gg: AfdE7clau2W7ZzlpnCZOXoMwPaqebuXFqF3uoBBiu0MNXFAem6vsNrngDiwj/VUMs/2 qvyIYvUm1bF1DZfEDF+zYCcNoihUuzi5su2+z1Gl6CmqJQQJWCUdM5kPypfMccBCr4T2MoZ2gFY dzMlqOrZdoz/DnK1GWH0Go+LqqzmFFzBbB0EyxbAVJeAXL8VSivd8dLZvG6LF4NNjIZLq1E0DCX k3wtWWsZN7zok/EsLzz0kMwX9vkMnTsGeyLHxL78R3SRDrDD1jjfDv9XBBSWLAXYFhMlcLO5ylO wLNfRTSCj8yWZCo3naYC897ZRrv74eWDTE2qKe0YdJtnj8FIgGmlWpFgD6UJLM+TMATbk2broKa EIidEvwZzAZTW2ECibjqEGwLHO6ErI044NWNW3INgKLW+6A2dF1nRvo6XDH88QaT5c42M3BC8QG IBxMVWq1Bn38IAarmPFlr2H/UWMdKDPMXq3lyjdQZVOeiYi1Gk+6ShsGdlRk4cUTjN/KnmDqOxu gJivMa9XCgsafvHEy0iD/vyEL8y/fuMo2NKtNnFyjbO53Pzh4zOgXxziHmd9W/42Fr3g+RxRJUX PITk3MY0TN57hl3FFV3SLgHkxR8+cIQ= X-Received: by 2002:a05:600c:83c4:b0:492:6f90:d92a with SMTP id 5b1f17b1804b1-4926f90d94bmr5510385e9.4.1782475247549; Fri, 26 Jun 2026 05:00:47 -0700 (PDT) Received: from naush-dell.pitowers.org ([2a00:1098:3142:1f:9337:c770:257e:d321]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4926c02088dsm39163015e9.0.2026.06.26.05.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 05:00:47 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH 1/3] utils: codegen: gen-formats: Resolve Broadcom SAND modifiers Date: Fri, 26 Jun 2026 12:54:01 +0100 Message-ID: <20260626120041.627376-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260626120041.627376-1-naush@raspberrypi.com> References: <20260626120041.627376-1-naush@raspberrypi.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" The Broadcom SAND (coloumn mode) modifiers are defined through the fourcc_mod_broadcom_code() column-height helper rather than a plain fourcc_mod_code(), so the generator script cannot not resolve them. Collapse line continuations and match the helper form so formats may reference the DRM_FORMAT_MOD_BROADCOM_SAND* modifiers. Signed-off-by: Naushir Patuck --- utils/codegen/gen-formats.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py index 740790e8f1a6..add04558f65f 100755 --- a/utils/codegen/gen-formats.py +++ b/utils/codegen/gen-formats.py @@ -18,13 +18,22 @@ class DRMFourCC(object): format_regex = re.compile(r"#define (DRM_FORMAT_[A-Z0-9_]+)[ \t]+fourcc_code\(('.', '.', '.', '.')\)") 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]+)\)") + # Broadcom SAND modifiers are defined indirectly via a _COL_HEIGHT(v) helper + # that wraps fourcc_mod_broadcom_code(, v) (which injects the BROADCOM + # vendor). Match that helper, strip _COL_HEIGHT to recover the convenience + # macro name, and use as the value - valid as the convenience macro is + # the height-0 case, which contributes nothing to it. + mod_brcm_regex = re.compile(r"#define (DRM_FORMAT_MOD_BROADCOM_SAND[0-9]+)_COL_HEIGHT\(v\)" + r"[ \t]+fourcc_mod_broadcom_code\(([0-9]+), v\)") def __init__(self, file): self.formats = {} self.vendors = {} self.mods = {} - for line in file: + # Collapse line continuations so multi-line macros match on one line. + lines = re.sub(r'\\[ \t]*\n', ' ', file.read()).splitlines() + for line in lines: match = DRMFourCC.format_regex.match(line) if match: format, fourcc = match.groups() @@ -43,6 +52,12 @@ class DRMFourCC(object): self.mods[mod] = (vendor, int(value, 0)) continue + match = DRMFourCC.mod_brcm_regex.match(line) + if match: + mod, code = match.groups() + self.mods[mod] = ('BROADCOM', int(code)) + continue + def fourcc(self, name): return self.formats[name]