From patchwork Mon Jun 29 08:36:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 27074 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 B02C0C3264 for ; Mon, 29 Jun 2026 09:42:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0996765F13; Mon, 29 Jun 2026 11:42:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="VPd9/qTJ"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4510565F10 for ; Mon, 29 Jun 2026 11:42:25 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-490d6730461so2806885e9.3 for ; Mon, 29 Jun 2026 02:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1782726145; x=1783330945; 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=VPd9/qTJOZXgDBbUr2DHpIVmHimpmE4AiNGHi1R7ri4Psbe0RVYbAmja1ThvlEuCeW FNfCBD6+G8FeWfQHdkCZBf89Vs4b3ESgeQsexBMXEZSkIG6HuEQqmDP03oBlbjpe8xXJ tIrgEpiIU7hz6PjvuETImnd+CBc18k1kknLEMCigkY7kdZ1QOvvo2qUo/+gZTGcv+aQL P2vb1EFivoBLyxpBK45wRiBNEmDIoXepWS+cW4Z1Hc9znMQSn5F6MBvfWZSC2qaP5Byc 9+zyGIvfwzb6np2RxqZR01/1+8xe4awKYMY1ZGvaQ5QvS5IV22JHqaCuknear7UCzDpt XJbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782726145; x=1783330945; 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=mafuyTjKe8Ejc7zn/Ysz8mrC404byhTsPg+xtmMj4qoa9eHeMhlEASm9xxA3o7Z04U QgAqfDCv10kxYS1BD4EigTWVLWX6pHLVFoYj443yvb5wkYga1Z1/TUBzK8qCcVtBcvGf xkmERBOeOfP1C1XYF74oNH9H6i2TfVS8BCPXdL4JCLYF/2TQ0n+xVVBxUNaw6EDdycp6 XJTW1Ja7KEQZjw1mYFZXIUv6pDuTtec8uci3RvVgxHHDCpGdsBDsw96qBfjDCtvNgCKq ngYYZsdxZRl1DjTOu49bb3ln2RpV4G/xkgb35m0ljnIunh2XJq65av65o4vVnjlyfZUG G2fg== X-Gm-Message-State: AOJu0YxFVOw1ZUG0XvZ6oXHq6K9O/YyErpG4FgAx9bbh4XtEDYcMiOim BCZEy1m0gMZ4Vu9l8Ury5sex1Od5evhmmdt5K2TnqKneR4YFNaQrIfWoGzGHTAfhMMVLfc1sp0f XBXkLIXI= X-Gm-Gg: AfdE7cnEE9ld6/1Xtce8uRaguUwN6JTqw3W/ntx9NXUmES2uM6lnGvpc1LAasIXq80c wmPdDBhu3Sh7bl8KiNTQSkgREHIXl7HU0OEY2cRnuTsIjRJMn9oSVhk6L8q/eSdfewguqk5Wk5R AaRd9NXkDk8FPPpK3sy2cF4P8pufiNEhl4ATaw7JV6WOJjjnXRNxEv8LhjWQYPPXKhxMPV/jnHi DqQEeqBY7NJM7qfwBK9Xj4qOhYwZOxvKXNJvdvE5W6XpTU9oRUX4xWuYE0yUGmjCFtpgEEZVSpj 0N1mPLACWcMDaW3hKjypJiLuaOr8GmmP+1K3N2pBqawruGKJr/r/xO0o94QscCC0BOjiuZHOvyO iWMaNGfyfsve9YkDZoKOWm1DCCxjgb9GLfsz5YgDbLo1GmZR7uOpWg6VhZ3Rew+ofcC4pL8s7Fj T5CXocoE1aVTyPE7NGbVMLGuAoregExPmA/+u1YeZ6b7DImjdghvR0HV0tujr1tsKUUNzNTgWgu A/taRYEwLtcJMrXbHaxMvrKbzC9bfgouDXhqOVBNIcTq9iDtJEQxAC/Xe0pnXqN7M80gZ8frUJr TSX4THhUg+tfhKutEClR X-Received: by 2002:a05:600d:117:b0:490:b4d4:5c16 with SMTP id 5b1f17b1804b1-4926689f7a8mr85414975e9.8.1782726144693; Mon, 29 Jun 2026 02:42:24 -0700 (PDT) Received: from naush-dell.pitowers.org ([2a00:1098:3142:1f:496e:3dec:bc78:809f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268f700c0sm345499125e9.0.2026.06.29.02.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 02:42:24 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v2 1/3] utils: codegen: gen-formats: Resolve Broadcom SAND modifiers Date: Mon, 29 Jun 2026 09:36:40 +0100 Message-ID: <20260629094216.747340-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260629094216.747340-1-naush@raspberrypi.com> References: <20260629094216.747340-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]