From patchwork Fri Apr 11 12:36:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23158 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 5094EC327D for ; Fri, 11 Apr 2025 12:36:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D361368A4C; Fri, 11 Apr 2025 14:36:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NyuE61t3"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D310689A5 for ; Fri, 11 Apr 2025 14:36:49 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C64FE1E6; Fri, 11 Apr 2025 14:34:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374889; bh=eOa6rzKFpDu74MPXL+0Pa8fhxQYG4EQwtqy+gehlCP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NyuE61t3owpyGN8YQgBZjghecXmyhKIMRLhST3cz8UTAm4G/TnfBRgNMZf0rlMVts VRyuQo0OMFXMTUS6dLtJKP7PMg4RGAxQj7Xc3RavzRe5JGbTsFou/hwsGtnIp0ZiX9 KOqG6HRc/qYnJJhhIrt0Z5rz9hQW7dSpUaoh+ln8= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham Subject: [PATCH v2 1/9] utils: gen-debug-controls: Remove line number from control description Date: Fri, 11 Apr 2025 14:36:29 +0200 Message-ID: <20250411123641.2144530-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 --- 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 Fri Apr 11 12:36:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23159 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 BE86CC327D for ; Fri, 11 Apr 2025 12:36:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7249468A9D; Fri, 11 Apr 2025 14:36:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="V2yDVZSm"; 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 3E23468A90 for ; Fri, 11 Apr 2025 14:36:52 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DBCAF735; Fri, 11 Apr 2025 14:34:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374893; bh=PfG1v9RSZ8jfa4zZ4EAddT/V3talYJ18VZsMaO34lEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V2yDVZSmSHgj3SyD77/R0fizQxFqMlP2PeY8Jm46sDVnCNeVTv7JQh8hQS0lDA6jh clOzCVXZyEWogwXHOUvhYo1BdQ3+0qOBgiqWZtqB5sMgn6ZjReYKTBDGtd+dgWia9r nEDd67OGtPJwplsQFvpO1jdLUA2kKPvod1nOEe28= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham Subject: [PATCH v2 2/9] utils: gen-debug-controls: Fix handling of controls that appear multiple times Date: Fri, 11 Apr 2025 14:36:30 +0200 Message-ID: <20250411123641.2144530-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 --- 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 Fri Apr 11 12:36:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23160 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 A0607C327D for ; Fri, 11 Apr 2025 12:36:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5155F68A90; Fri, 11 Apr 2025 14:36:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IJfe5QhW"; 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 14A3668A90 for ; Fri, 11 Apr 2025 14:36:55 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BEF6A7F5; Fri, 11 Apr 2025 14:34:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374895; bh=4JeMJBu26vCvazvklZn3yQgB0jc9civdYO4PGrUlA1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IJfe5QhWNW7GcX0AhSklEvyvNPVJQv8iBdAb4E2VvIfOqVAGhO8d5KMJveEFF4Tmc BXQ+n8HjFfHecPqXJwG93WdNrceq/AFUggZCTtsOEiJoB6qKtpzWy9PAcdqPopcxxX 2CrdjD8WkpJPxpYNxqKEihTdt1fIFqRA+QgFZTlo= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham Subject: [PATCH v2 3/9] utils: gen-debug-controls: Improve log output Date: Fri, 11 Apr 2025 14:36:31 +0200 Message-ID: <20250411123641.2144530-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 --- 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 Fri Apr 11 12:36:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23161 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 49C65C327D for ; Fri, 11 Apr 2025 12:37:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F3B5368AB0; Fri, 11 Apr 2025 14:36:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YyVzz7sp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 106AE68AA8 for ; Fri, 11 Apr 2025 14:36:58 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A91911E6; Fri, 11 Apr 2025 14:34:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374898; bh=AnGC7HT7rautr3JzU7N6bgqoP+fsGrVKtGRYvOLkXgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YyVzz7sp9K+HrcjNbPAa1tfxlkacXMqkzoU+uP7wpOM2YtMlp3fR3TfM/HLSqIrxT mbJojjQyB2D1uliLL5f6gE6hvdoDBx36KXpzjWtBRl6GQAUZFNbbKA59vh2ynTBmO3 xNjoSYJTD8RjlOAmmSid2pVXa8FhS8ZDNl7Jk+sA= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Daniel Scally Subject: [PATCH v2 4/9] libipa: agc_mean_luminance: Add debug logging Date: Fri, 11 Apr 2025 14:36:32 +0200 Message-ID: <20250411123641.2144530-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 --- Changes in v2: - Collected tags --- src/ipa/libipa/agc_mean_luminance.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index f617fde81101..9154f083a510 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -468,12 +468,16 @@ 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 Fri Apr 11 12:36:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23162 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 CC5F3C327D for ; Fri, 11 Apr 2025 12:37:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7848168AB4; Fri, 11 Apr 2025 14:37:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UbyCELFf"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A27A968AA8 for ; Fri, 11 Apr 2025 14:37:00 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 568D2667; Fri, 11 Apr 2025 14:35:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374901; bh=xIIy2K0wc7Ph23MpdCUr7Hu+hQJBMLVpuxN9xA/bXbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UbyCELFf/wpd8lcKtkV2Adge9bQUr1055y8583u0tdsVF+KZWAvHBZrd+vTD8LpM8 btO28pIxfpxTzla7OXP4wumfzqKr5RsGwtDJ/jbfgWyYXQCMA8peI5Q7QfSU2APsdp FHzy+2j3Zq4tDPy+uC0mx0zx97IEvQTt8tJd7tKw= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 5/9] ipa: rkisp1: params: Check for empty parameters Date: Fri, 11 Apr 2025 14:36:33 +0200 Message-ID: <20250411123641.2144530-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 --- 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 Fri Apr 11 12:36:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23163 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 AF2BBC327D for ; Fri, 11 Apr 2025 12:37:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6AE3E68A90; Fri, 11 Apr 2025 14:37:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pBcJhOOg"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A676968A90 for ; Fri, 11 Apr 2025 14:37:03 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57C8B1E6; Fri, 11 Apr 2025 14:35:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374904; bh=hEjttf+X0Z3Ha2p/Z8webfyhIN8pceaFTmQC/BEddRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBcJhOOgnuprPRhqKUL9D6PqSL8dViMZ1gmEmFCIOTDkCb87jbEKRr8B8deHIQQMM pj4OoWV8EQu/p8b7YXcONjCFHXBUAAIuQdmhyXd04WfxOVrnqVG1p/oK4OMYmd8rdP sydhUNd0X9Xdc/RG43QgFRt3h+nNzgaMZ875qRzQ= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 6/9] pipeline: rkisp1: Add more info when parameter queue fails Date: Fri, 11 Apr 2025 14:36:34 +0200 Message-ID: <20250411123641.2144530-7-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 the rkisp1 driver of the running kernel supports less parameter types than the libcamera build and such a parameter is used, queuing of the parameter buffer fails with -EINVAL. For the time being we have no way to query the kernel for supported parameter types at runtime. So at least print a error message that points the user in that direction. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- Changes in v2: - Also print the error code in case of failure --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 52633fe3cb85..9d7a3bd57ada 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -409,7 +409,15 @@ 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: " << ret + << " Maybe the kernel doesn't support the" + " required parameter types."; + return; + } + pipe->stat_->queueBuffer(info->statBuffer); if (info->mainPathBuffer) From patchwork Fri Apr 11 12:36:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23164 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 5A28DC327D for ; Fri, 11 Apr 2025 12:37:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 108BF68AB7; Fri, 11 Apr 2025 14:37:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cc1WT0hL"; 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 B963C68AB4 for ; Fri, 11 Apr 2025 14:37:06 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69502667; Fri, 11 Apr 2025 14:35:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374907; bh=SeLXgg9s3PLEqT2OXDoSLbE6kZAMyEtled4XP+VsL7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cc1WT0hLCD7HqjHkQI/iJzJuMIAYKZq8mpn8yTlKK4XPL8euAr4ChrICXJCECPPSD ELCMf39DIecPAodG4bK3O3Edqg+rzoLIT6guog9QYiWhUV8ICcJK/nsyc/WH+xZocA DpVotJg3RKzjxXC9exw8qe4yysWe9vz/BT11BJjM= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham Subject: [PATCH v2 7/9] pipeline: rkisp1: Add color space information to debug log Date: Fri, 11 Apr 2025 14:36:35 +0200 Message-ID: <20250411123641.2144530-8-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 6.13 kernel driver has a bug the the JPEG/sYCC color space is not applied correctly. Add the color space to the debug log output to be able to detect that now and later. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- Changes in v2: - Collected tag --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 9d7a3bd57ada..2708cecca0b0 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -891,7 +891,8 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) LOG(RkISP1, Debug) << "ISP output pad configured with " << format - << " crop " << outputCrop; + << " crop " << outputCrop + << " color space " << ColorSpace::toString(format.colorSpace); IPACameraSensorInfo sensorInfo; ret = data->sensor_->sensorInfo(&sensorInfo); From patchwork Fri Apr 11 12:36:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23165 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 B90FCC327D for ; Fri, 11 Apr 2025 12:37:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5166168ABA; Fri, 11 Apr 2025 14:37:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qhYWYepw"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC3EE68AB6 for ; Fri, 11 Apr 2025 14:37:09 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A296667; Fri, 11 Apr 2025 14:35:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374910; bh=bormeQ45cumqOupY+08k0pBAEDEU+j1PYfniDs9zcY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qhYWYepwfnCLBSCp1k0Zxw+Xp4ai1iMfACIJnhsntK5ZVdeIlOXhI3u4bR+Eeylo+ BkiIxtVDzC+WTYyR8V2RIXPR6cIf5XMLxn5x3609rkVljYgNWsOpOXe+B6HQC1lBB9 vjXVqB3Dlm4Y9+dcttjnXRrgcQNGRylpdqpn6HYQ= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Daniel Scally Subject: [PATCH v2 8/9] libipa: agc_mean_luminance: Add exposure compensation support Date: Fri, 11 Apr 2025 14:36:36 +0200 Message-ID: <20250411123641.2144530-9-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 --- 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 | 23 +++++++++++++++++++++-- src/ipa/libipa/agc_mean_luminance.h | 6 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index 9154f083a510..f6cb7144b31a 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,7 @@ static constexpr double kDefaultRelativeLuminanceTarget = 0.16; */ AgcMeanLuminance::AgcMeanLuminance() - : frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(0) + : exposureCompensation_(1.0), frameCount_(0), filteredExposure_(0s), relativeLuminanceTarget_(0) { } @@ -369,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 @@ -425,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 Fri Apr 11 12:36:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23166 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 6879BC327D for ; Fri, 11 Apr 2025 12:37:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1CCA468ABB; Fri, 11 Apr 2025 14:37:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P0pFMm00"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E39D68AB6 for ; Fri, 11 Apr 2025 14:37:12 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DA44F1E6; Fri, 11 Apr 2025 14:35:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744374913; bh=WNEhDYUGcTwAAFle3Q6jIyWw3xCZc1dMUxi0XAOy9qI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0pFMm00B+mOGyzl3LGObZmxg22UKzkgek5JohojtfMRKYyI9c3XskuQxljc1Zs4l tor2dxejQ42bou+1iE7hpiIiD2G45YNqfZj0CMn3FVqnproRJFwGKW8vbpwKGx3HeX rjJ6r99s8r1RUAOwxtmqRDPpiKdfniGMsPmP9Vb0= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 9/9] ipa: rkisp1: agc: Implement ExposureValue control Date: Fri, 11 Apr 2025 14:36:37 +0200 Message-ID: <20250411123641.2144530-10-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411123641.2144530-1-stefan.klug@ideasonboard.com> References: <20250411123641.2144530-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 --- 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 b3ac9400b74f..8e77455e7afd 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -158,6 +158,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; @@ -180,6 +181,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); @@ -302,6 +304,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 */ @@ -408,6 +415,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); } /** @@ -557,6 +565,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;