From patchwork Mon Jul 7 08:55:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23750 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 5F330C3237 for ; Mon, 7 Jul 2025 08:55:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 071E668E83; Mon, 7 Jul 2025 10:55:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AdPi1oVF"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F12168E83 for ; Mon, 7 Jul 2025 10:55:38 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 3BDFC190D; Mon, 7 Jul 2025 10:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878511; bh=oLjBvEwsCQYBU2LjyJQ+CLtdwcnLI/y+qAkom7x9HdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AdPi1oVFIwxc/lAepRhXGCj4ociuLKfO6+S2Kvor49Riy5hqAJelRa/PDs7xDVuJA xXyGYgrZk/W2NhfXukbsM5gRKFv4d6Kz0J1teXOG17zbMLZzdsSxYMLAb6gCJkbF1P nqGPgkkRztt7d4VbzJs38vFP4WRCobjKx6Wkb5cg= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Paul Elder , Isaac Scott Subject: [PATCH v3 1/9] utils: gen-debug-controls: Remove line number from control description Date: Mon, 7 Jul 2025 10:55:04 +0200 Message-ID: <20250707085520.39777-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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" The line numbers change so often that including them in the description creates too much noise in control_ids_debug.yaml. Output the path only. Signed-off-by: Stefan Klug Acked-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Isaac Scott --- Changes in v3: - Collected tags Changes in v2: - Collected tag --- utils/gen-debug-controls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/gen-debug-controls.py b/utils/gen-debug-controls.py index 272597f4874f..53c8fa70d76d 100755 --- a/utils/gen-debug-controls.py +++ b/utils/gen-debug-controls.py @@ -107,7 +107,7 @@ def main(argv): p = m.file.relative_to(root_dir) desc = {'type': m.type, 'direction': 'out', - 'description': f'Debug control {m.name} found in {p}:{m.line}'} + 'description': f'Debug control {m.name} found in {p}'} if m.size is not None: desc['size'] = m.size From patchwork Mon Jul 7 08:55:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23751 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 DE191C3237 for ; Mon, 7 Jul 2025 08:55:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7327B68E8C; Mon, 7 Jul 2025 10:55:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DydhLHMc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F47968E7F for ; Mon, 7 Jul 2025 10:55:40 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id A7A80190D; Mon, 7 Jul 2025 10:55:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878513; bh=mpWY2PdpGfqPwI38J+x1H4tmUL82j0GDHtT12cc7mXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DydhLHMctrE6MueYevdYSyr+aLVrGcMUCYUvtan9h/djh7FB7z33QAgKCJpVeQKLc Ayg/84rXR1x/jyNKSfnCT1IrwgUOGSz4Pat+B2JcYXs7CHJThAT72RULJ0YO+iu420 QYHXKFYbyTkpQ01vRNqLHcwjrJNZxK3qAHacT6fM= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Paul Elder , Isaac Scott Subject: [PATCH v3 2/9] utils: gen-debug-controls: Fix handling of controls that appear multiple times Date: Mon, 7 Jul 2025 10:55:05 +0200 Message-ID: <20250707085520.39777-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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" Allow usage of the same debug control in multiple places as long as all instances are of the same type and size. Signed-off-by: Stefan Klug Acked-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Isaac Scott --- Changes in v3: - Collected tags Changes in v2: - Collected tag --- utils/gen-debug-controls.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils/gen-debug-controls.py b/utils/gen-debug-controls.py index 53c8fa70d76d..ff22b986475e 100755 --- a/utils/gen-debug-controls.py +++ b/utils/gen-debug-controls.py @@ -96,6 +96,7 @@ def main(argv): controls_map[k] = v obsolete_names = list(controls_map.keys()) + found_by_name = {} for m in matches: if not m.type: @@ -111,6 +112,12 @@ def main(argv): if m.size is not None: desc['size'] = m.size + c = found_by_name.setdefault(m.name, m) + if c.type != m.type or c.size != m.size: + logger.error( + f"Found multiple entries for control '{m.name}' with differing type or size") + return 1 + if m.name in controls_map: # Can't use == for modified check because of the special yaml dicts. update_needed = False @@ -127,7 +134,9 @@ def main(argv): controls_map[m.name].clear() controls_map[m.name].update(desc) - obsolete_names.remove(m.name) + # Don't try to remove more than once in case control was found multiple files. + if m.name in obsolete_names: + obsolete_names.remove(m.name) else: logger.info(f"Add control '{m.name}'") insert_before = len(controls) From patchwork Mon Jul 7 08:55:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23752 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 16E76C3237 for ; Mon, 7 Jul 2025 08:55:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B140068E8C; Mon, 7 Jul 2025 10:55:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NtB3Hy/X"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 461AD68E7F for ; Mon, 7 Jul 2025 10:55:43 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 87E21190D; Mon, 7 Jul 2025 10:55:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878516; bh=C1MQ014R0VPNE4SJ8AWH6q4meRaMz4TkQggRdCowNLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NtB3Hy/XcpspmtbauWBUhHGyyT41OoWmPtLKnnk6U/9AUaXZ1Ofm0r8BDXZRb1xtc jXEQxD8sEIYI0ky6hE3s1M9lG2Q1HtwCRyNuWcVaMCJqys6aVjx21W6UyqF1PMfAMy gIWT7od/Gvs2Mryyt7YuvaekkfzY2qQoPU1dmDVs= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Paul Elder , Isaac Scott Subject: [PATCH v3 3/9] utils: gen-debug-controls: Improve log output Date: Mon, 7 Jul 2025 10:55:06 +0200 Message-ID: <20250707085520.39777-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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" Add log statements for found controls and the file written. This makes it easier to understand what happens under the hood. While at it, create nice colored log out put using coloredlogs if available. Signed-off-by: Stefan Klug Acked-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Isaac Scott --- Changes in v3: - Collected tags Changes in v2: - Collected tag --- utils/gen-debug-controls.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/utils/gen-debug-controls.py b/utils/gen-debug-controls.py index ff22b986475e..a1c69bbd8294 100755 --- a/utils/gen-debug-controls.py +++ b/utils/gen-debug-controls.py @@ -17,8 +17,13 @@ import sys from dataclasses import dataclass from pathlib import Path -logger = logging.getLogger(__name__) -logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') +fmt = '%(levelname)s: %(message)s' +try: + import coloredlogs + coloredlogs.install(level=logging.INFO, fmt=fmt) +except ImportError: + logging.basicConfig(level=logging.INFO, format=fmt) + try: import ruamel.yaml as ruyaml @@ -27,6 +32,8 @@ except: f'Failed to import ruamel.yaml. Please install the ruamel.yaml package.') sys.exit(1) +logger = logging.getLogger(__name__) + @dataclass class FoundMatch: file: os.PathLike @@ -106,6 +113,7 @@ def main(argv): continue p = m.file.relative_to(root_dir) + logger.info(f"Found control {m.name} in {p}") desc = {'type': m.type, 'direction': 'out', 'description': f'Debug control {m.name} found in {p}'} @@ -165,6 +173,9 @@ def main(argv): "#\n")) yaml.dump(doc, f) + p = ctrl_file.relative_to(Path.cwd(), walk_up=True) + logger.info(f"Sucessfully updated {p}") + return 0 From patchwork Mon Jul 7 08:55:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23753 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 25F6CC3237 for ; Mon, 7 Jul 2025 08:55:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4ADD168E83; Mon, 7 Jul 2025 10:55:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kCkVd2n8"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B6BCE68E83 for ; Mon, 7 Jul 2025 10:55:45 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 224BD1942; Mon, 7 Jul 2025 10:55:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878519; bh=x3qexoZIskvY3vGUevhjP6zySz/iJV/J1oSl0YrWWCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kCkVd2n8X/UNo3oVihAlLHANvSLWLsowoTnAKnZOIJICTSUqpJ1YcBFaz7k3ZY+M4 XSxHMQdM65yKT4eXMVV1NnMySUZmpVKxMrNaDkwTTyzrzYoB5stIgndsl6T6BzcBb/ VYYPUgg60uQDlrd5PUQVM9qPzYiwLv3Uu+Lop5C4= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Daniel Scally , Paul Elder , Laurent Pinchart Subject: [PATCH v3 4/9] libipa: agc_mean_luminance: Add debug logging Date: Mon, 7 Jul 2025 10:55:07 +0200 Message-ID: <20250707085520.39777-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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 debugging the AEGC it is important to know when the constraints apply. As this is important information for anyone doing tuning file optimization, add it upstream. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Daniel Scally Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - Fixed line wrapping - Collected tags Changes in v2: - Collected tags --- src/ipa/libipa/agc_mean_luminance.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index d37a9b66103f..ebdb4d755741 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -467,12 +467,20 @@ double AgcMeanLuminance::constraintClampGain(uint32_t constraintModeIndex, hist.interQuantileMean(constraint.qLo, constraint.qHi); if (constraint.bound == AgcConstraint::Bound::Lower && - newGain > gain) + newGain > gain) { gain = newGain; + LOG(AgcMeanLuminance, Debug) + << "Apply lower bound: " << gain << " to " + << newGain; + } if (constraint.bound == AgcConstraint::Bound::Upper && - newGain < gain) + newGain < gain) { gain = newGain; + LOG(AgcMeanLuminance, Debug) + << "Apply upper bound: " << gain << " to " + << newGain; + } } return gain; From patchwork Mon Jul 7 08:55:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23754 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 27D66C3237 for ; Mon, 7 Jul 2025 08:55:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C397468E8A; Mon, 7 Jul 2025 10:55:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d/PcSh8g"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B1A2A68EA4 for ; Mon, 7 Jul 2025 10:55:48 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 02AF8190D; Mon, 7 Jul 2025 10:55:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878522; bh=xxhUzxlPH8fMQl+M9BwC+SoG9GeNTeoHt/QiXTFvgsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/PcSh8gCtC9CiUkuDCiPq49+nlAW2PMXHDPPjEJvt0qx/aOj5lRX7BS6bYvOcFhX DHQNrwgxZLdGYp6HTyVF2ESeRh7mQO9jeFq6FTTRkjD5qmAgWL/cH3QL+zO+lXvTPX NQmKqsn2BVR6Saz/ykxcNZUOZUxvz86WxkiSXxCI= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Paul Elder Subject: [PATCH v3 5/9] ipa: rkisp1: params: Check for empty parameters Date: Mon, 7 Jul 2025 10:55:08 +0200 Message-ID: <20250707085520.39777-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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" Add functions to check for empty parameter blocks. Modify the constructor so that a parameter block constructed from an empty span stays empty. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- Changes in v3: - Collected tags Changes in v2: - Removed unrelated get() functions --- src/ipa/rkisp1/params.cpp | 3 +++ src/ipa/rkisp1/params.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp index 4c0b051ce65d..b4a889e415fc 100644 --- a/src/ipa/rkisp1/params.cpp +++ b/src/ipa/rkisp1/params.cpp @@ -82,6 +82,9 @@ RkISP1ParamsBlockBase::RkISP1ParamsBlockBase(RkISP1Params *params, BlockType typ const Span &data) : params_(params), type_(type) { + if (data.empty()) + return; + if (params_->format() == V4L2_META_FMT_RK_ISP1_EXT_PARAMS) { header_ = data.subspan(0, sizeof(rkisp1_ext_params_block_header)); data_ = data.subspan(sizeof(rkisp1_ext_params_block_header)); diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h index 40450e34497a..04b06c2a6266 100644 --- a/src/ipa/rkisp1/params.h +++ b/src/ipa/rkisp1/params.h @@ -89,6 +89,9 @@ public: void setEnabled(bool enabled); + bool isValid() const { return !data_.empty(); } + explicit operator bool() const { return !data_.empty(); } + private: LIBCAMERA_DISABLE_COPY(RkISP1ParamsBlockBase) From patchwork Mon Jul 7 08:55:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23755 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 CA49BC3237 for ; Mon, 7 Jul 2025 08:55:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B7C068EA4; Mon, 7 Jul 2025 10:55:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OO4C9ELG"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EC1DE68E8A for ; Mon, 7 Jul 2025 10:55:51 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 5544E190D; Mon, 7 Jul 2025 10:55:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878525; bh=pSRWs5of3Y5tIEYObKitIetZEo4u3lD+WU/iyyCe/98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OO4C9ELGYRFSz8x0sYtzNe7UuVE/kQfRF6XNhEC+b59ChBxAb2rJJHUVpXiARPryt gtx0sDdQe7qu6chhiWUpbIzR2V6HfVPmIEpmOj0L212JtMPusIdSkgOUF8N6/5QeVt doaZ0YagIm+XiUxHRpaA6YwoJ/Hlb/NpcW4TKRzY= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Paul Elder Subject: [PATCH v3 6/9] pipeline: rkisp1: Add error log when parameter queuing fails Date: Mon, 7 Jul 2025 10:55:09 +0200 Message-ID: <20250707085520.39777-7-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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" Add a error statement when quieing of the parameter buffer fails for whatever reason. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- Changes in v3: - Collected tags - Removed hint regarding unsupported parameter types as this will be handled using the now upstreamed RKISP1_CID_SUPPORTED_PARAMS_BLOCKS. Changes in v2: - Also print the error code in case of failure --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 675f0a7490a6..d5bb8aced3c8 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -411,7 +411,14 @@ void RkISP1CameraData::paramsComputed(unsigned int frame, unsigned int bytesused return; info->paramBuffer->_d()->metadata().planes()[0].bytesused = bytesused; - pipe->param_->queueBuffer(info->paramBuffer); + + int ret = pipe->param_->queueBuffer(info->paramBuffer); + if (ret < 0) { + LOG(RkISP1, Error) << "Failed to queue parameter buffer: " + << strerror(-ret); + return; + } + pipe->stat_->queueBuffer(info->statBuffer); if (info->mainPathBuffer) From patchwork Mon Jul 7 08:55:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23756 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 95D23C3237 for ; Mon, 7 Jul 2025 08:55:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BA1A268EAB; Mon, 7 Jul 2025 10:55:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vZHbVaBF"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 91A3B68E7F for ; Mon, 7 Jul 2025 10:55:54 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 01FA4190D; Mon, 7 Jul 2025 10:55:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878528; bh=ls6nwpzwxajKJAT6TragKy3J0LKJ541owh/REBLPmLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZHbVaBFmwYvLf/TJilNtwgrToMulc6bDwh2o6WqE2FdH0gUopwzFz7PRfPY05Q9G jfj0wQsAPieqd9P1YVH2JkJVdabDGj632GCA4dTc82zu/w+aPY9T91QTGt2Yfj9gnD eSN6p26jCMOZOEAbH7bGa7GJPi7ywLPSpvXwC2+k= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 7/9] pipeline: v4l2_subdevice: Add color space to format string representation Date: Mon, 7 Jul 2025 10:55:10 +0200 Message-ID: <20250707085520.39777-8-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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" Add the color space to the string representation of V4L2SubdeviceFormat that is returned by toString() and operator<<(). Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Isaac Scott --- Changes in v3: - Moved color space output to V4L2SubdeviceFormat - Dropped tags, as the patch changed a bit more Changes in v2: - Collected tag --- src/libcamera/v4l2_subdevice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 33279654db8c..ce6b0d38cbf1 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -949,6 +949,8 @@ std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f) else out << it->second.name; + out << "/" << ColorSpace::toString(f.colorSpace); + return out; } From patchwork Mon Jul 7 08:55:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23757 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 120BAC3237 for ; Mon, 7 Jul 2025 08:56:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8660868E8C; Mon, 7 Jul 2025 10:56:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="R7gKpb48"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B2F1768EB1 for ; Mon, 7 Jul 2025 10:55:57 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 140D91942; Mon, 7 Jul 2025 10:55:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878531; bh=1wKU0pjobuw79Vf1aXQoXME+va0b4U8ybOtk7pQXB0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R7gKpb48flSLmcRIGN/wWo8WsoHNWR6UXvnvR83fMs9QFHh/4+tsYm5q/UoInBifc u5IAej0Qejw1nfwwxhZzHhZDJjgRrZoe9rHWEz/bklnaFvMEcs46Om0jXGjfjwPA6X oeiQ/09MEA6onveocOTcAERmatG9amKWC1k8BlF8= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Daniel Scally , Paul Elder Subject: [PATCH v3 8/9] libipa: agc_mean_luminance: Add exposure compensation support Date: Mon, 7 Jul 2025 10:55:11 +0200 Message-ID: <20250707085520.39777-9-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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" Exposure compensation allows to over- or under-expose an image by a given value. Add support for that in agc_mean_luminance. The added exposure compensation can lead to luminance target values that are close or above saturation and are therefore never reachable. Add a fix for that by limiting the maximum luminance target to 0.95. Signed-off-by: Stefan Klug Reviewed-by: Daniel Scally Reviewed-by: Paul Elder --- Changes in v3: - Fixed line wrap - Collected tags Changes in v2: - Fixed compiler error that slipped through in v1 - Improved commit message to explain the luminance target limitation - Collected tag --- src/ipa/libipa/agc_mean_luminance.cpp | 24 ++++++++++++++++++++++-- src/ipa/libipa/agc_mean_luminance.h | 6 ++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index ebdb4d755741..ff96a381ffce 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -44,6 +44,15 @@ static constexpr uint32_t kNumStartupFrames = 10; */ static constexpr double kDefaultRelativeLuminanceTarget = 0.16; +/* + * Maximum relative luminance target + * + * This value limits the relative luminance target after applying the exposure + * compensation. Targeting a value above this limit results in saturation + * and the inability to regulate properly. + */ +static constexpr double kMaxRelativeLuminanceTarget = 0.95; + /** * \struct AgcMeanLuminance::AgcConstraint * \brief The boundaries and target for an AeConstraintMode constraint @@ -134,7 +143,8 @@ static constexpr double kDefaultRelativeLuminanceTarget = 0.16; */ AgcMeanLuminance::AgcMeanLuminance() - : frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(0) + : exposureCompensation_(1.0), frameCount_(0), filteredExposure_(0s), + relativeLuminanceTarget_(0) { } @@ -368,6 +378,15 @@ int AgcMeanLuminance::parseTuningData(const YamlObject &tuningData) return parseExposureModes(tuningData); } +/** + * \fn AgcMeanLuminance::setExposureCompensation() + * \brief Set the exposure compensation value + * \param[in] gain The exposure compensation gain + * + * This function sets the exposure compensation value to be used in the + * AGC calculations. It is expressed as gain instead of EV. + */ + /** * \brief Set the ExposureModeHelper limits for this class * \param[in] minExposureTime Minimum exposure time to allow @@ -424,7 +443,8 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime, */ double AgcMeanLuminance::estimateInitialGain() const { - double yTarget = relativeLuminanceTarget_; + double yTarget = std::min(relativeLuminanceTarget_ * exposureCompensation_, + kMaxRelativeLuminanceTarget); double yGain = 1.0; /* diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h index c41391cb0b73..cad7ef845487 100644 --- a/src/ipa/libipa/agc_mean_luminance.h +++ b/src/ipa/libipa/agc_mean_luminance.h @@ -44,6 +44,11 @@ public: int parseTuningData(const YamlObject &tuningData); + void setExposureCompensation(double gain) + { + exposureCompensation_ = gain; + } + void setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime, double minGain, double maxGain); @@ -84,6 +89,7 @@ private: double gain); utils::Duration filterExposure(utils::Duration exposureValue); + double exposureCompensation_; uint64_t frameCount_; utils::Duration filteredExposure_; double relativeLuminanceTarget_; From patchwork Mon Jul 7 08:55:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23758 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 34522C3237 for ; Mon, 7 Jul 2025 08:56:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB0B768EB5; Mon, 7 Jul 2025 10:56:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FXWJikQ5"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D379B68EA6 for ; Mon, 7 Jul 2025 10:56:00 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c79f:85df:e7f5:4c31]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 3D629190D; Mon, 7 Jul 2025 10:55:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1751878534; bh=V3SARb52aSpZwSeFnkttvpZZ06JCkcaM6t/PpdEkqMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXWJikQ5nBglK2LwO9XPxeGada/vHtu5jsiJoGuIkqmmaD2qTvT7C0CdTLOYZgj1i TABi7IVnsPG/7drdNW4+IdIzvv87gZBAKaiL0E90EMKRQu9R6zUTXEZTM7xCi6XNY8 SEBOB34I0m8kz22kkbaIVe/8Kvkt3uWYDHb3pMkQ= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Paul Elder Subject: [PATCH v3 9/9] ipa: rkisp1: agc: Implement ExposureValue control Date: Mon, 7 Jul 2025 10:55:12 +0200 Message-ID: <20250707085520.39777-10-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250707085520.39777-1-stefan.klug@ideasonboard.com> References: <20250707085520.39777-1-stefan.klug@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" Now that agc_mean_luminance supports exposure correction, implement the corresponding ExposureValue control for rkisp1. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- Changes in v3: - Collected tags --- src/ipa/rkisp1/algorithms/agc.cpp | 10 ++++++++++ src/ipa/rkisp1/ipa_context.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 137a0750017b..35440b67e999 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -157,6 +157,7 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) ControlValue(controls::AnalogueGainModeAuto)); /* \todo Move this to the Camera class */ context.ctrlMap[&controls::AeEnable] = ControlInfo(false, true, true); + context.ctrlMap[&controls::ExposureValue] = ControlInfo(-8.0f, 8.0f, 0.0f); context.ctrlMap.merge(controls()); return 0; @@ -179,6 +180,7 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) context.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure; context.activeState.agc.autoExposureEnabled = !context.configuration.raw; context.activeState.agc.autoGainEnabled = !context.configuration.raw; + context.activeState.agc.exposureValue = 0.0; context.activeState.agc.constraintMode = static_cast(constraintModes().begin()->first); @@ -301,6 +303,11 @@ void Agc::queueRequest(IPAContext &context, static_cast(*constraintMode); frameContext.agc.constraintMode = agc.constraintMode; + const auto &exposureValue = controls.get(controls::ExposureValue); + if (exposureValue) + agc.exposureValue = *exposureValue; + frameContext.agc.exposureValue = agc.exposureValue; + const auto &frameDurationLimits = controls.get(controls::FrameDurationLimits); if (frameDurationLimits) { /* Limit the control value to the limits in ControlInfo */ @@ -407,6 +414,7 @@ void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext, metadata.set(controls::AeMeteringMode, frameContext.agc.meteringMode); metadata.set(controls::AeExposureMode, frameContext.agc.exposureMode); metadata.set(controls::AeConstraintMode, frameContext.agc.constraintMode); + metadata.set(controls::ExposureValue, frameContext.agc.exposureValue); } /** @@ -556,6 +564,8 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, double analogueGain = frameContext.sensor.gain; utils::Duration effectiveExposureValue = exposureTime * analogueGain; + setExposureCompensation(pow(2.0, frameContext.agc.exposureValue)); + utils::Duration newExposureTime; double aGain, dGain; std::tie(newExposureTime, aGain, dGain) = diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index f0d504215d34..7ccc7b501aff 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -81,6 +81,7 @@ struct IPAActiveState { bool autoExposureEnabled; bool autoGainEnabled; + double exposureValue; controls::AeConstraintModeEnum constraintMode; controls::AeExposureModeEnum exposureMode; controls::AeMeteringModeEnum meteringMode; @@ -129,6 +130,7 @@ struct IPAFrameContext : public FrameContext { struct { uint32_t exposure; double gain; + double exposureValue; uint32_t vblank; bool autoExposureEnabled; bool autoGainEnabled;