From patchwork Sat Oct 11 16:03:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24589 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 3534EBE080 for ; Sat, 11 Oct 2025 16:03:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8E52060448; Sat, 11 Oct 2025 18:03:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BFLqoar2"; 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 B3412603E0 for ; Sat, 11 Oct 2025 18:03:42 +0200 (CEST) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0A67EC67; Sat, 11 Oct 2025 18:02:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760198526; bh=Qx3/aEVsGwiwIQgMReTV/B86As0EsyAIvYy1JM7/Yrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFLqoar2u1SETs3Z1udpevZaZCSuo/2MoRLgzaCfia4BcY/uoTp1ZAsdj6gKYX2wF K+E4oRc/M+M6hE9Kxtqz9eitpwG3THeQgIABMasEOq0PYIroxdVITRMh+7ZNymiji3 pWAntYZG+M0lBUFphF+1IYkX4YbxU18+Ucw8UKMQ= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [RFC PATCH 1/7] ipa: mali-c55: blc: mark offset member variables Date: Sat, 11 Oct 2025 17:03:29 +0100 Message-ID: <20251011160335.50578-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011160335.50578-1-kieran.bingham@ideasonboard.com> References: <20251011160335.50578-1-kieran.bingham@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" Rename the offset variables to use a suffixed '_' to make it clear these variables are stored in the class. Signed-off-by: Kieran Bingham --- src/ipa/mali-c55/algorithms/blc.cpp | 42 ++++++++++++++--------------- src/ipa/mali-c55/algorithms/blc.h | 8 +++--- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/ipa/mali-c55/algorithms/blc.cpp b/src/ipa/mali-c55/algorithms/blc.cpp index 2a54c86a91f8..85642c0435a2 100644 --- a/src/ipa/mali-c55/algorithms/blc.cpp +++ b/src/ipa/mali-c55/algorithms/blc.cpp @@ -38,13 +38,13 @@ BlackLevelCorrection::BlackLevelCorrection() int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) { - offset00 = tuningData["offset00"].get(0); - offset01 = tuningData["offset01"].get(0); - offset10 = tuningData["offset10"].get(0); - offset11 = tuningData["offset11"].get(0); + offset00_ = tuningData["offset00"].get(0); + offset01_ = tuningData["offset01"].get(0); + offset10_ = tuningData["offset10"].get(0); + offset11_ = tuningData["offset11"].get(0); - if (offset00 > kMaxOffset || offset01 > kMaxOffset || - offset10 > kMaxOffset || offset11 > kMaxOffset) { + if (offset00_ > kMaxOffset || offset01_ > kMaxOffset || + offset10_ > kMaxOffset || offset11_ > kMaxOffset) { LOG(MaliC55Blc, Error) << "Invalid black level offsets"; return -EINVAL; } @@ -52,8 +52,8 @@ int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context, tuningParameters_ = true; LOG(MaliC55Blc, Debug) - << "Black levels: 00 " << offset00 << ", 01 " << offset01 - << ", 10 " << offset10 << ", 11 " << offset11; + << "Black levels: 00 " << offset00_ << ", 01 " << offset01_ + << ", 10 " << offset10_ << ", 11 " << offset11_; return 0; } @@ -69,11 +69,11 @@ int BlackLevelCorrection::configure(IPAContext &context, * use the value from the CameraSensorHelper if one is available. */ if (context.configuration.sensor.blackLevel && - !(offset00 + offset01 + offset10 + offset11)) { - offset00 = context.configuration.sensor.blackLevel; - offset01 = context.configuration.sensor.blackLevel; - offset10 = context.configuration.sensor.blackLevel; - offset11 = context.configuration.sensor.blackLevel; + !(offset00_ + offset01_ + offset10_ + offset11_)) { + offset00_ = context.configuration.sensor.blackLevel; + offset01_ = context.configuration.sensor.blackLevel; + offset10_ = context.configuration.sensor.blackLevel; + offset11_ = context.configuration.sensor.blackLevel; } return 0; @@ -100,10 +100,10 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context, block.header->flags = MALI_C55_PARAM_BLOCK_FL_NONE; block.header->size = sizeof(mali_c55_params_sensor_off_preshading); - block.sensor_offs->chan00 = offset00; - block.sensor_offs->chan01 = offset01; - block.sensor_offs->chan10 = offset10; - block.sensor_offs->chan11 = offset11; + block.sensor_offs->chan00 = offset00_; + block.sensor_offs->chan01 = offset01_; + block.sensor_offs->chan10 = offset10_; + block.sensor_offs->chan11 = offset11_; params->total_size += block.header->size; } @@ -126,10 +126,10 @@ void BlackLevelCorrection::process([[maybe_unused]] IPAContext &context, * \todo Account for bayer order. */ metadata.set(controls::SensorBlackLevels, { - static_cast(offset00 >> 4), - static_cast(offset01 >> 4), - static_cast(offset10 >> 4), - static_cast(offset11 >> 4), + static_cast(offset00_ >> 4), + static_cast(offset01_ >> 4), + static_cast(offset10_ >> 4), + static_cast(offset11_ >> 4), }); } diff --git a/src/ipa/mali-c55/algorithms/blc.h b/src/ipa/mali-c55/algorithms/blc.h index 9696e8e9f2aa..29dcafdfec70 100644 --- a/src/ipa/mali-c55/algorithms/blc.h +++ b/src/ipa/mali-c55/algorithms/blc.h @@ -32,10 +32,10 @@ private: static constexpr uint32_t kMaxOffset = 0xfffff; bool tuningParameters_; - uint32_t offset00; - uint32_t offset01; - uint32_t offset10; - uint32_t offset11; + uint32_t offset00_; + uint32_t offset01_; + uint32_t offset10_; + uint32_t offset11_; }; } /* namespace ipa::mali_c55::algorithms */ From patchwork Sat Oct 11 16:03:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24590 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 E6592BE080 for ; Sat, 11 Oct 2025 16:03:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A0E7C6043B; Sat, 11 Oct 2025 18:03:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qrWpDVOA"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CF26260428 for ; Sat, 11 Oct 2025 18:03:42 +0200 (CEST) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 51177C6A; Sat, 11 Oct 2025 18:02:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760198526; bh=+NFqsKRHsSiJ1Vtz/eaFrEwgw7KFXq6h/Cuzffq2IUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qrWpDVOAMEG8ZK0+B73e1gnNSTcqk8DU4PRVdlmhW/SXLwymTBGwGmTZyUYvMYTa6 F92zukrFO/APps8Tm88PslgQMMAY65BEV1dMWiP8RvZc5Qsqi9TLPle1azB2LXys0I 27Wxgbo27Z1ZeMjTwY6Xt5a4F0le1CJH48aMj7wQ= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [RFC PATCH 2/7] ipa: mali-c55: Move CameraHelper to context Date: Sat, 11 Oct 2025 17:03:30 +0100 Message-ID: <20251011160335.50578-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011160335.50578-1-kieran.bingham@ideasonboard.com> References: <20251011160335.50578-1-kieran.bingham@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" Move the CameraHelper sensor to the Context so that it can be used by the algorithms directly. Signed-off-by: Kieran Bingham --- src/ipa/mali-c55/ipa_context.h | 4 ++++ src/ipa/mali-c55/mali-c55.cpp | 27 ++++++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/ipa/mali-c55/ipa_context.h b/src/ipa/mali-c55/ipa_context.h index 13885eb83b5c..bfa805c7b93f 100644 --- a/src/ipa/mali-c55/ipa_context.h +++ b/src/ipa/mali-c55/ipa_context.h @@ -12,6 +12,7 @@ #include "libcamera/internal/bayer_format.h" +#include #include namespace libcamera { @@ -83,6 +84,9 @@ struct IPAContext { FCQueue frameContexts; ControlInfoMap::Map ctrlMap; + + /* Interface to the Camera Helper */ + std::unique_ptr camHelper; }; } /* namespace ipa::mali_c55 */ diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp index 7d45e7310aec..0751513dc584 100644 --- a/src/ipa/mali-c55/mali-c55.cpp +++ b/src/ipa/mali-c55/mali-c55.cpp @@ -74,9 +74,6 @@ private: ControlInfoMap sensorControls_; - /* Interface to the Camera Helper */ - std::unique_ptr camHelper_; - /* Local parameter storage */ struct IPAContext context_; }; @@ -98,8 +95,8 @@ std::string IPAMaliC55::logPrefix() const int IPAMaliC55::init(const IPASettings &settings, const IPAConfigInfo &ipaConfig, ControlInfoMap *ipaControls) { - camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel); - if (!camHelper_) { + context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel); + if (!context_.camHelper) { LOG(IPAMaliC55, Error) << "Failed to create camera sensor helper for " << settings.sensorModel; @@ -142,10 +139,10 @@ void IPAMaliC55::setControls() if (activeState.agc.autoEnabled) { exposure = activeState.agc.automatic.exposure; - gain = camHelper_->gainCode(activeState.agc.automatic.sensorGain); + gain = context_.camHelper->gainCode(activeState.agc.automatic.sensorGain); } else { exposure = activeState.agc.manual.exposure; - gain = camHelper_->gainCode(activeState.agc.manual.sensorGain); + gain = context_.camHelper->gainCode(activeState.agc.manual.sensorGain); } ControlList ctrls(sensorControls_); @@ -191,17 +188,17 @@ void IPAMaliC55::updateSessionConfiguration(const IPACameraSensorInfo &info, context_.configuration.agc.minShutterSpeed = minExposure * context_.configuration.sensor.lineDuration; context_.configuration.agc.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration; context_.configuration.agc.defaultExposure = defExposure; - context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain); - context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain); + context_.configuration.agc.minAnalogueGain = context_.camHelper->gain(minGain); + context_.configuration.agc.maxAnalogueGain = context_.camHelper->gain(maxGain); - if (camHelper_->blackLevel().has_value()) { + if (context_.camHelper->blackLevel().has_value()) { /* * The black level from CameraSensorHelper is a 16-bit value. * The Mali-C55 ISP expects 20-bit settings, so we shift it to * the appropriate width */ context_.configuration.sensor.blackLevel = - camHelper_->blackLevel().value() << 4; + context_.camHelper->blackLevel().value() << 4; } } @@ -252,9 +249,9 @@ void IPAMaliC55::updateControls(const IPACameraSensorInfo &sensorInfo, /* Compute the analogue gain limits. */ const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second; - float minGain = camHelper_->gain(v4l2Gain.min().get()); - float maxGain = camHelper_->gain(v4l2Gain.max().get()); - float defGain = camHelper_->gain(v4l2Gain.def().get()); + float minGain = context_.camHelper->gain(v4l2Gain.min().get()); + float maxGain = context_.camHelper->gain(v4l2Gain.max().get()); + float defGain = context_.camHelper->gain(v4l2Gain.def().get()); ctrlMap[&controls::AnalogueGain] = ControlInfo(minGain, maxGain, defGain); /* @@ -362,7 +359,7 @@ void IPAMaliC55::processStats(unsigned int request, unsigned int bufferId, frameContext.agc.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get(); frameContext.agc.sensorGain = - camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); + context_.camHelper->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); ControlList metadata(controls::controls); From patchwork Sat Oct 11 16:03:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24591 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 DD669C3264 for ; Sat, 11 Oct 2025 16:03:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 40635603E0; Sat, 11 Oct 2025 18:03:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jyqlr67w"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EDD1C603F6 for ; Sat, 11 Oct 2025 18:03:42 +0200 (CEST) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 93001C6E; Sat, 11 Oct 2025 18:02:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760198526; bh=vZE+O3/GeB6WLj0YL/jTDfnqXpcuUbtztkh+G5cjnzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jyqlr67wHDUw8iajAtLFUKdJrrXBF5V5Kn5b44R9X0Ps1BFpYNR77IyGswrBFf9w/ DSmCJHnSp64FFuhYnhyAoyKSDrXthRwMipWBxcFVFAjFOP4fOzdI+plFKkH0cpCI9z ZU8hwTLANPci4zHSyMb5CcabQVLrexF/2hgVmN4w= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [RFC PATCH 3/7] ipa: mali-c55: Confine blacklevel config Date: Sat, 11 Oct 2025 17:03:31 +0100 Message-ID: <20251011160335.50578-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011160335.50578-1-kieran.bingham@ideasonboard.com> References: <20251011160335.50578-1-kieran.bingham@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" Move the black level handling into the blc module. Signed-off-by: Kieran Bingham --- src/ipa/mali-c55/algorithms/blc.cpp | 20 +++++++++++++------- src/ipa/mali-c55/ipa_context.h | 1 - src/ipa/mali-c55/mali-c55.cpp | 10 ---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/ipa/mali-c55/algorithms/blc.cpp b/src/ipa/mali-c55/algorithms/blc.cpp index 85642c0435a2..1fdd00ccc2ea 100644 --- a/src/ipa/mali-c55/algorithms/blc.cpp +++ b/src/ipa/mali-c55/algorithms/blc.cpp @@ -64,17 +64,23 @@ int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context, int BlackLevelCorrection::configure(IPAContext &context, [[maybe_unused]] const IPACameraSensorInfo &configInfo) { + if (!context.camHelper->blackLevel().has_value()) + return 0; + + /* + * The black level from CameraSensorHelper is a 16-bit value. + * The Mali-C55 ISP expects 20-bit settings, so we shift it to + * the appropriate width + */ + uint32_t blackLevel = context.camHelper->blackLevel().value() << 4; + /* * If no Black Levels were passed in through tuning data then we could * use the value from the CameraSensorHelper if one is available. */ - if (context.configuration.sensor.blackLevel && - !(offset00_ + offset01_ + offset10_ + offset11_)) { - offset00_ = context.configuration.sensor.blackLevel; - offset01_ = context.configuration.sensor.blackLevel; - offset10_ = context.configuration.sensor.blackLevel; - offset11_ = context.configuration.sensor.blackLevel; - } + if (blackLevel && + !(offset00_ + offset01_ + offset10_ + offset11_)) + offset00_ = offset01_ = offset10_ = offset11_ = blackLevel; return 0; } diff --git a/src/ipa/mali-c55/ipa_context.h b/src/ipa/mali-c55/ipa_context.h index bfa805c7b93f..6dd8e5b0edfc 100644 --- a/src/ipa/mali-c55/ipa_context.h +++ b/src/ipa/mali-c55/ipa_context.h @@ -31,7 +31,6 @@ struct IPASessionConfiguration { struct { BayerFormat::Order bayerOrder; utils::Duration lineDuration; - uint32_t blackLevel; } sensor; }; diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp index 0751513dc584..27f6501085b9 100644 --- a/src/ipa/mali-c55/mali-c55.cpp +++ b/src/ipa/mali-c55/mali-c55.cpp @@ -190,16 +190,6 @@ void IPAMaliC55::updateSessionConfiguration(const IPACameraSensorInfo &info, context_.configuration.agc.defaultExposure = defExposure; context_.configuration.agc.minAnalogueGain = context_.camHelper->gain(minGain); context_.configuration.agc.maxAnalogueGain = context_.camHelper->gain(maxGain); - - if (context_.camHelper->blackLevel().has_value()) { - /* - * The black level from CameraSensorHelper is a 16-bit value. - * The Mali-C55 ISP expects 20-bit settings, so we shift it to - * the appropriate width - */ - context_.configuration.sensor.blackLevel = - context_.camHelper->blackLevel().value() << 4; - } } void IPAMaliC55::updateControls(const IPACameraSensorInfo &sensorInfo, From patchwork Sat Oct 11 16:03:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24592 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 69026BE080 for ; Sat, 11 Oct 2025 16:03:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C66BF6044B; Sat, 11 Oct 2025 18:03:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bPTEgzT5"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3378060436 for ; Sat, 11 Oct 2025 18:03:43 +0200 (CEST) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DB29BE91; Sat, 11 Oct 2025 18:02:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760198527; bh=dz3/zkWSOlZ4sZF0l4NoDwO2DSdStd8c9M67qOktTF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bPTEgzT5cmB8yooR3RrVUt/cT0+FCuNhce69duFaqR9SA8C34SlnDterotKtcb2Z4 B/pRD85Ynt814jz93bLfoGhay/SMluABJJfd0D/FQyk076KDuvFVIQ+BsufptQFzzr t37CRDk+fosY1A/RLWz7fj//K2p8CC/pgWLzm6vM= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [RFC PATCH 4/7] ipa: softipa: Extend configure operation to pass controls Date: Sat, 11 Oct 2025 17:03:32 +0100 Message-ID: <20251011160335.50578-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011160335.50578-1-kieran.bingham@ideasonboard.com> References: <20251011160335.50578-1-kieran.bingham@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" Extend the SoftIPA interface to support passing IPA controls during the configuration phase so that updates can be made according to the resolutions selected. Signed-off-by: Kieran Bingham --- include/libcamera/internal/software_isp/software_isp.h | 3 ++- include/libcamera/ipa/soft.mojom | 2 +- src/ipa/simple/soft_simple.cpp | 6 ++++-- src/libcamera/pipeline/simple/simple.cpp | 2 +- src/libcamera/software_isp/software_isp.cpp | 5 +++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index 78624659245c..0bc695177634 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -65,7 +65,8 @@ public: int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, - const ipa::soft::IPAConfigInfo &configInfo); + const ipa::soft::IPAConfigInfo &configInfo, + ControlInfoMap *ipaControls); int exportBuffers(const Stream *stream, unsigned int count, std::vector> *buffers); diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom index 77328c5fd51d..3acac53981e7 100644 --- a/include/libcamera/ipa/soft.mojom +++ b/include/libcamera/ipa/soft.mojom @@ -22,7 +22,7 @@ interface IPASoftInterface { start() => (int32 ret); stop(); configure(IPAConfigInfo configInfo) - => (int32 ret); + => (int32 ret, libcamera.ControlInfoMap ipaControls); [async] queueRequest(uint32 frame, libcamera.ControlList sensorControls); [async] computeParams(uint32 frame); diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp index b147aca2e343..0821d214815f 100644 --- a/src/ipa/simple/soft_simple.cpp +++ b/src/ipa/simple/soft_simple.cpp @@ -57,7 +57,8 @@ public: const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls, bool *ccmEnabled) override; - int configure(const IPAConfigInfo &configInfo) override; + int configure(const IPAConfigInfo &configInfo, + ControlInfoMap *ipaControls) override; int start() override; void stop() override; @@ -193,7 +194,8 @@ int IPASoftSimple::init(const IPASettings &settings, return 0; } -int IPASoftSimple::configure(const IPAConfigInfo &configInfo) +int IPASoftSimple::configure(const IPAConfigInfo &configInfo, + [[maybe_unused]] ControlInfoMap *ipaControls) { sensorInfoMap_ = configInfo.sensorControls; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index c816cffc9e6a..a7e7ac25bac2 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1414,7 +1414,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) } else { ipa::soft::IPAConfigInfo configInfo; configInfo.sensorControls = data->sensor_->controls(); - return data->swIsp_->configure(inputCfg, outputCfgs, configInfo); + return data->swIsp_->configure(inputCfg, outputCfgs, configInfo, &data->controlInfo_); } } diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index b7651b7d2627..953409c42fee 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -255,11 +255,12 @@ SoftwareIsp::strideAndFrameSize(const PixelFormat &outputFormat, const Size &siz */ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, - const ipa::soft::IPAConfigInfo &configInfo) + const ipa::soft::IPAConfigInfo &configInfo, + ControlInfoMap *ipaControls) { ASSERT(ipa_ && debayer_); - int ret = ipa_->configure(configInfo); + int ret = ipa_->configure(configInfo, ipaControls); if (ret < 0) return ret; From patchwork Sat Oct 11 16:03:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24593 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 B5FECC3331 for ; Sat, 11 Oct 2025 16:03:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 92D3860461; Sat, 11 Oct 2025 18:03:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TLqXATX+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E9FC60443 for ; Sat, 11 Oct 2025 18:03:43 +0200 (CEST) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2E6BAF0F; Sat, 11 Oct 2025 18:02:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760198527; bh=Ha/BSR0e6IO1ScJhvHZHHgbiYlSuK3dxK9DL3yf6IJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLqXATX+j8s0fjx8nLwwuy//9sKIt9TNdUaZQ/2c+f2OhkMyXtsopTNAudyOnWitG cH+4O3Hv3ef4Y0XhawEmHR1OShItSTYproxkO88gj1kKrFZ+qJIZx30gadC7+IqMU/ 3x1lxaCwmXpKiQRWyhf/q+8TvZVMMpm0lfBEcdPw= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [RFC PATCH 5/7] ipa: softipa: Pass IPACameraSensorInfo to configure Date: Sat, 11 Oct 2025 17:03:33 +0100 Message-ID: <20251011160335.50578-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011160335.50578-1-kieran.bingham@ideasonboard.com> References: <20251011160335.50578-1-kieran.bingham@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" Pass the CameraSensorInfo in to the configure phase of the IPA from the CameraSensor class, allowing the context to be used when configuring the IPA. Signed-off-by: Kieran Bingham --- include/libcamera/ipa/soft.mojom | 1 + src/libcamera/pipeline/simple/simple.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom index 3acac53981e7..7bdbb65b4458 100644 --- a/include/libcamera/ipa/soft.mojom +++ b/include/libcamera/ipa/soft.mojom @@ -9,6 +9,7 @@ module ipa.soft; import "include/libcamera/ipa/core.mojom"; struct IPAConfigInfo { + libcamera.IPACameraSensorInfo sensorInfo; libcamera.ControlInfoMap sensorControls; }; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index a7e7ac25bac2..7d56effec50b 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1412,8 +1412,14 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) if (data->converter_) { return data->converter_->configure(inputCfg, outputCfgs); } else { - ipa::soft::IPAConfigInfo configInfo; - configInfo.sensorControls = data->sensor_->controls(); + IPACameraSensorInfo sensorInfo; + ret = data->sensor_->sensorInfo(&sensorInfo); + if (ret) + return ret; + + ipa::soft::IPAConfigInfo configInfo{ sensorInfo, + data->sensor_->controls() }; + return data->swIsp_->configure(inputCfg, outputCfgs, configInfo, &data->controlInfo_); } } From patchwork Sat Oct 11 16:03:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24594 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 0FDBBC3332 for ; Sat, 11 Oct 2025 16:03:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 992E56044D; Sat, 11 Oct 2025 18:03:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fw9fkwRL"; 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 C3F9B603E0 for ; Sat, 11 Oct 2025 18:03:43 +0200 (CEST) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 787E5111D; Sat, 11 Oct 2025 18:02:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760198527; bh=nUwo8X77he7xCHYXX1WZpsW4CByiA4itnK5MKcAtNkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fw9fkwRLUirzvu3HJkG5h+6GFPy1QlwAz3VTaWE7PIuQ/2vkvXLACh/P+eG+PCv1H ZqvXW6qmIs+P+1xuPuB1OYFW6U8oqSOn/tGd2LNDz+zRpD1ceUTaMcd45CpE7pw15T C3P4Dy2uNnucCt0aDyJwnPURJNSfsSD9ntvATNMQ= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [RFC PATCH 6/7] ipa: softipa: Move camhelper to context Date: Sat, 11 Oct 2025 17:03:34 +0100 Message-ID: <20251011160335.50578-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011160335.50578-1-kieran.bingham@ideasonboard.com> References: <20251011160335.50578-1-kieran.bingham@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" Move the camhelper to the context structure so that it can be accessible for algorithms to use directly where needed. Signed-off-by: Kieran Bingham --- src/ipa/simple/ipa_context.h | 3 +++ src/ipa/simple/soft_simple.cpp | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h index c3081e3069b5..3d6a8b72861f 100644 --- a/src/ipa/simple/ipa_context.h +++ b/src/ipa/simple/ipa_context.h @@ -16,6 +16,7 @@ #include "libcamera/internal/matrix.h" #include "libcamera/internal/vector.h" +#include #include #include "core_ipa_interface.h" @@ -103,6 +104,8 @@ struct IPAContext { FCQueue frameContexts; ControlInfoMap::Map ctrlMap; bool ccmEnabled = false; + + std::unique_ptr camHelper; }; } /* namespace ipa::soft */ diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp index 0821d214815f..68ddf71e9f24 100644 --- a/src/ipa/simple/soft_simple.cpp +++ b/src/ipa/simple/soft_simple.cpp @@ -76,7 +76,6 @@ private: DebayerParams *params_; SwIspStats *stats_; - std::unique_ptr camHelper_; ControlInfoMap sensorInfoMap_; /* Local parameter storage */ @@ -99,8 +98,8 @@ int IPASoftSimple::init(const IPASettings &settings, ControlInfoMap *ipaControls, bool *ccmEnabled) { - camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel); - if (!camHelper_) { + context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel); + if (!context_.camHelper) { LOG(IPASoft, Warning) << "Failed to create camera sensor helper for " << settings.sensorModel; @@ -220,15 +219,15 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo, int32_t againMax = gainInfo.max().get(); int32_t againDef = gainInfo.def().get(); - if (camHelper_) { - context_.configuration.agc.againMin = camHelper_->gain(againMin); - context_.configuration.agc.againMax = camHelper_->gain(againMax); - context_.configuration.agc.again10 = camHelper_->gain(1.0); + if (context_.camHelper) { + context_.configuration.agc.againMin = context_.camHelper->gain(againMin); + context_.configuration.agc.againMax = context_.camHelper->gain(againMax); + context_.configuration.agc.again10 = context_.camHelper->gain(1.0); context_.configuration.agc.againMinStep = (context_.configuration.agc.againMax - context_.configuration.agc.againMin) / 100.0; - if (camHelper_->blackLevel().has_value()) { + if (context_.camHelper->blackLevel().has_value()) { /* * The black level from camHelper_ is a 16 bit value, software ISP * works with 8 bit pixel values, both regardless of the actual @@ -236,7 +235,7 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo, * by dividing the value from the helper by 256. */ context_.configuration.black.level = - camHelper_->blackLevel().value() / 256; + context_.camHelper->blackLevel().value() / 256; } } else { /* @@ -313,7 +312,7 @@ void IPASoftSimple::processStats(const uint32_t frame, frameContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get(); int32_t again = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get(); - frameContext.sensor.gain = camHelper_ ? camHelper_->gain(again) : again; + frameContext.sensor.gain = context_.camHelper ? context_.camHelper->gain(again) : again; ControlList metadata(controls::controls); for (auto const &algo : algorithms()) @@ -332,7 +331,7 @@ void IPASoftSimple::processStats(const uint32_t frame, auto &againNew = frameContext.sensor.gain; ctrls.set(V4L2_CID_EXPOSURE, frameContext.sensor.exposure); ctrls.set(V4L2_CID_ANALOGUE_GAIN, - static_cast(camHelper_ ? camHelper_->gainCode(againNew) : againNew)); + static_cast(context_.camHelper ? context_.camHelper->gainCode(againNew) : againNew)); setSensorControls.emit(ctrls); } From patchwork Sat Oct 11 16:03:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 24595 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 72F5EC3333 for ; Sat, 11 Oct 2025 16:03:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2A5DC6045D; Sat, 11 Oct 2025 18:03:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cW03qz9Y"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0FC6960444 for ; Sat, 11 Oct 2025 18:03:44 +0200 (CEST) Received: from charm.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BD89D1440; Sat, 11 Oct 2025 18:02:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760198527; bh=nxf7Xf9wsexXXjyeHfSxMTXDkiecYW9cv9lUMG4B/t4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cW03qz9YR7xG+OiCLVJgwA49u2TGKvW3tPIA3/2V8erzI3qQcHm+Livg9bqdyGKWX cQgt4fHQo1ulZrv286x1Ft/IfryGjrSnTX5sombKMOaPY5TuTuD87vkgCSsJ65jBNI PxlmCLjoxxvQKWGIumuJqFhwgKdDi1dXdApgUHlo= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [RFC PATCH 7/7] ipa: softipa: Confine black level configuration Date: Sat, 11 Oct 2025 17:03:35 +0100 Message-ID: <20251011160335.50578-8-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011160335.50578-1-kieran.bingham@ideasonboard.com> References: <20251011160335.50578-1-kieran.bingham@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" Move the black level handling entirely into the blc module. Signed-off-by: Kieran Bingham --- src/ipa/simple/algorithms/blc.cpp | 11 +++++++++++ src/ipa/simple/soft_simple.cpp | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp index 370385afc683..060006d350ee 100644 --- a/src/ipa/simple/algorithms/blc.cpp +++ b/src/ipa/simple/algorithms/blc.cpp @@ -40,10 +40,21 @@ int BlackLevel::init([[maybe_unused]] IPAContext &context, int BlackLevel::configure(IPAContext &context, [[maybe_unused]] const IPAConfigInfo &configInfo) { + /* + * The black level from camHelper_ is a 16 bit value, software ISP + * works with 8 bit pixel values, both regardless of the actual + * sensor pixel width. Hence we obtain the pixel-based black value + * by dividing the value from the helper by 256. + */ + context.configuration.black.level = + context.camHelper->blackLevel().value() / 256; + if (definedLevel_.has_value()) context.configuration.black.level = definedLevel_; + context.activeState.blc.level = context.configuration.black.level.value_or(16); + return 0; } diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp index 68ddf71e9f24..caae2c586e9b 100644 --- a/src/ipa/simple/soft_simple.cpp +++ b/src/ipa/simple/soft_simple.cpp @@ -227,16 +227,6 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo, (context_.configuration.agc.againMax - context_.configuration.agc.againMin) / 100.0; - if (context_.camHelper->blackLevel().has_value()) { - /* - * The black level from camHelper_ is a 16 bit value, software ISP - * works with 8 bit pixel values, both regardless of the actual - * sensor pixel width. Hence we obtain the pixel-based black value - * by dividing the value from the helper by 256. - */ - context_.configuration.black.level = - context_.camHelper->blackLevel().value() / 256; - } } else { /* * The camera sensor gain (g) is usually not equal to the value written