From patchwork Mon Jul 1 14:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20494 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 85B77BEFBE for ; Mon, 1 Jul 2024 14:41:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4318C62E17; Mon, 1 Jul 2024 16:41:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="N8mbrIJ7"; 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 5E6EA62E01 for ; Mon, 1 Jul 2024 16:41:39 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9B133289; Mon, 1 Jul 2024 16:41:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719844872; bh=9OfEPJgunPUuDfUjcEI6VFfSww4n4UtaKQheV72OlXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N8mbrIJ7RuHrKJWTkR1pTt5wNme1Pm8yFDyXloZ8QaXoGHu4hX4hk5EZaXNjZzIBr LzbH5o4KjKf0OqwjzyyTYgjZXBhwWYj+iY1lWJX+dgnX2w5GK2Y00A0NzR+/98oTTp JDS+M+ltukVwaIulmrYGynlXi2vq97aO1Ltseoao= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 1/5] ipa: libipa: Add black levels to camera sensor helper Date: Mon, 1 Jul 2024 16:38:24 +0200 Message-ID: <20240701144122.3418955-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701144122.3418955-1-stefan.klug@ideasonboard.com> References: <20240701144122.3418955-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" For a proper tuning process we need to know the sensor black levels. In most cases these are fixed and not reported by the kernel driver. Store them inside the sensor helpers for later retrieval by the algorithms. Signed-off-by: Stefan Klug --- src/ipa/libipa/camera_sensor_helper.cpp | 18 ++++++++++++++++++ src/ipa/libipa/camera_sensor_helper.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index 782ff9904e81..6d8850eb25a5 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -47,6 +47,21 @@ namespace ipa { * function. */ +/** + * \brief Fetch the black levels of the sensor + * + * This function returns the black levels of the sensor with respect to a 16bit + * pixel width in R, Gr, Gb, B order. If these are unknown an empty optional is + * returned. + * + * \return The black levels of the sensor + */ +std::optional +CameraSensorHelper::blackLevels() const +{ + return blackLevels_; +} + /** * \brief Compute gain code from the analogue gain absolute value * \param[in] gain The real gain to pass @@ -396,6 +411,7 @@ class CameraSensorHelperImx219 : public CameraSensorHelper public: CameraSensorHelperImx219() { + blackLevels_ = { 4096, 4096, 4096, 4096 }; gainType_ = AnalogueGainLinear; gainConstants_.linear = { 0, 256, -1, 256 }; } @@ -407,6 +423,7 @@ class CameraSensorHelperImx258 : public CameraSensorHelper public: CameraSensorHelperImx258() { + blackLevels_ = { 4096, 4096, 4096, 4096 }; gainType_ = AnalogueGainLinear; gainConstants_.linear = { 0, 512, -1, 512 }; } @@ -456,6 +473,7 @@ class CameraSensorHelperImx335 : public CameraSensorHelper public: CameraSensorHelperImx335() { + blackLevels_ = { 3200, 3200, 3200, 3200 }; gainType_ = AnalogueGainExponential; gainConstants_.exp = { 1.0, expGainDb(0.3) }; } diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h index 0d99073bea82..f025727c06ee 100644 --- a/src/ipa/libipa/camera_sensor_helper.h +++ b/src/ipa/libipa/camera_sensor_helper.h @@ -9,7 +9,9 @@ #include +#include #include +#include #include #include @@ -22,9 +24,12 @@ namespace ipa { class CameraSensorHelper { public: + typedef std::array BlackLevels; + CameraSensorHelper() = default; virtual ~CameraSensorHelper() = default; + virtual std::optional blackLevels() const; virtual uint32_t gainCode(double gain) const; virtual double gain(uint32_t gainCode) const; @@ -51,6 +56,7 @@ protected: AnalogueGainExpConstants exp; }; + std::optional blackLevels_; AnalogueGainType gainType_; AnalogueGainConstants gainConstants_; From patchwork Mon Jul 1 14:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20495 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 5BDEABEFBE for ; Mon, 1 Jul 2024 14:41:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0521162E25; Mon, 1 Jul 2024 16:41:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="n4qUt8df"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0654D62E24 for ; Mon, 1 Jul 2024 16:41:43 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B6403289; Mon, 1 Jul 2024 16:41:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719844875; bh=AfrMtpKNsw/KZaxtWd/pLBBlLylDbrflNDNoDiMXIkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n4qUt8dfm2vnOTIMM+14LA21eiMfsLxT0b9yHnAinK3gFp102umEgswz5VHc92rq8 Yq2iKtApmvnS0o340PS12RDt+5BaVqWjFeECO9UY2ToPehBV1ODTmjwTf0kCUqeiqy 8hjzA4igMC+XP3zNLObDy0D13ofR3U64kb3lLN94= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 2/5] ipa: rkisp1: Move camHelper into IPAContext Date: Mon, 1 Jul 2024 16:38:25 +0200 Message-ID: <20240701144122.3418955-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701144122.3418955-1-stefan.klug@ideasonboard.com> References: <20240701144122.3418955-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" To be able to query the black levels, the black level correction algorithm needs access to the camera sensor helper. Allow this by moving the camHelper_ member from IPARkISP1 into IPAContext. Signed-off-by: Stefan Klug Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/ipa/rkisp1/ipa_context.h | 4 ++++ src/ipa/rkisp1/rkisp1.cpp | 26 ++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 8602b408870e..d2dd6a904b59 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -178,6 +179,9 @@ struct IPAContext { FCQueue frameContexts; ControlInfoMap::Map ctrlMap; + + /* Interface to the Camera Helper */ + std::unique_ptr camHelper; }; } /* namespace ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index d31cdbab020b..23e0826cc335 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -29,7 +29,6 @@ #include "libcamera/internal/yaml_parser.h" #include "algorithms/algorithm.h" -#include "libipa/camera_sensor_helper.h" #include "ipa_context.h" @@ -81,9 +80,6 @@ private: ControlInfoMap sensorControls_; - /* Interface to the Camera Helper */ - std::unique_ptr camHelper_; - /* Local parameter storage */ struct IPAContext context_; }; @@ -115,7 +111,7 @@ const ControlInfoMap::Map rkisp1Controls{ } /* namespace */ IPARkISP1::IPARkISP1() - : context_({ {}, {}, {}, { kMaxFrameContexts }, {} }) + : context_({ {}, {}, {}, { kMaxFrameContexts }, {}, {} }) { } @@ -147,8 +143,8 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, LOG(IPARkISP1, Debug) << "Hardware revision is " << hwRevision; - camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel); - if (!camHelper_) { + context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel); + if (!context_.camHelper) { LOG(IPARkISP1, Error) << "Failed to create camera sensor helper for " << settings.sensorModel; @@ -250,8 +246,10 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, minExposure * context_.configuration.sensor.lineDuration; context_.configuration.sensor.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration; - context_.configuration.sensor.minAnalogueGain = camHelper_->gain(minGain); - context_.configuration.sensor.maxAnalogueGain = camHelper_->gain(maxGain); + context_.configuration.sensor.minAnalogueGain = + context_.camHelper->gain(minGain); + context_.configuration.sensor.maxAnalogueGain = + context_.camHelper->gain(maxGain); context_.configuration.raw = std::any_of(streamConfig.begin(), streamConfig.end(), [](auto &cfg) -> bool { @@ -352,7 +350,7 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId frameContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get(); frameContext.sensor.gain = - camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); + context_.camHelper->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); ControlList metadata(controls::controls); @@ -389,9 +387,9 @@ void IPARkISP1::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.emplace(std::piecewise_construct, std::forward_as_tuple(&controls::AnalogueGain), std::forward_as_tuple(minGain, maxGain, defGain)); @@ -436,7 +434,7 @@ void IPARkISP1::setControls(unsigned int frame) IPAFrameContext &frameContext = context_.frameContexts.get(frame); uint32_t exposure = frameContext.agc.exposure; - uint32_t gain = camHelper_->gainCode(frameContext.agc.gain); + uint32_t gain = context_.camHelper->gainCode(frameContext.agc.gain); ControlList ctrls(sensorControls_); ctrls.set(V4L2_CID_EXPOSURE, static_cast(exposure)); From patchwork Mon Jul 1 14:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20496 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 55346BEFBE for ; Mon, 1 Jul 2024 14:41:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1736463334; Mon, 1 Jul 2024 16:41:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="J4CltYvU"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C56162E24 for ; Mon, 1 Jul 2024 16:41:45 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7B1C1289; Mon, 1 Jul 2024 16:41:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719844878; bh=KPb4J19/zYBrN1CUguZ5WOA3gCeNPSb7o/hh2n8nF08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4CltYvUKvGyFDa4HWEbP/0ld/kd3KrRc/U7Cr5w8U1MrE8GXLcsFLBs7zbRWMDkJ AwbJboDbsEjgY6j05jT6irqUyMhuPFvFCZ0VGV/ZlT53lA7dYwB6Z1BFkn12P7MhOx Yb9OMxxWc4NyaBzYEQNeIiLXlFOcj6UF7aO/fCmE= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 3/5] ipa: rkisp1: blc: Query black levels from camera sensor helper Date: Mon, 1 Jul 2024 16:38:26 +0200 Message-ID: <20240701144122.3418955-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701144122.3418955-1-stefan.klug@ideasonboard.com> References: <20240701144122.3418955-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 black levels from the camera sensor helper are then used to do the black level correction. Black levels can still be overwritten by the tuning file. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/blc.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp index d2e743541c99..0c39c3b47da5 100644 --- a/src/ipa/rkisp1/algorithms/blc.cpp +++ b/src/ipa/rkisp1/algorithms/blc.cpp @@ -46,10 +46,30 @@ BlackLevelCorrection::BlackLevelCorrection() int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) { - blackLevelRed_ = tuningData["R"].get(256); - blackLevelGreenR_ = tuningData["Gr"].get(256); - blackLevelGreenB_ = tuningData["Gb"].get(256); - blackLevelBlue_ = tuningData["B"].get(256); + auto blackLevels = context.camHelper->blackLevels(); + if (blackLevels) { + Span levels = *blackLevels; + blackLevelRed_ = levels[0]; + blackLevelGreenR_ = levels[1]; + blackLevelGreenB_ = levels[2]; + blackLevelBlue_ = levels[3]; + } else + LOG(RkISP1Blc, Warning) + << "No black levels provided by camera sensor helper"; + + if (!blackLevels || (tuningData.contains("R") && + tuningData.contains("Gr") && + tuningData.contains("Gb") && + tuningData.contains("B"))) { + blackLevelRed_ = tuningData["R"].get(256); + blackLevelGreenR_ = tuningData["Gr"].get(256); + blackLevelGreenB_ = tuningData["Gb"].get(256); + blackLevelBlue_ = tuningData["B"].get(256); + + if (blackLevels) + LOG(RkISP1Blc, Warning) + << "Black levels overwritten by tuning file"; + } tuningParameters_ = true; From patchwork Mon Jul 1 14:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20497 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 24892BEFBE for ; Mon, 1 Jul 2024 14:41:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D87B063334; Mon, 1 Jul 2024 16:41:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="K7O8/wsv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 286CD63339 for ; Mon, 1 Jul 2024 16:41:48 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 66BFB289; Mon, 1 Jul 2024 16:41:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719844881; bh=gvU6lB7So5TEcjJYig+GviVf7c2kQ+bRxqYyOHh8Zvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K7O8/wsvT9u2WhjDS6aJci/78vtxpblGggW8q/tCZG4ZsEdM5e+M57IeMBsLA27LR nXD61KsbEau6atxiLyx05CmAR6OQPeUBe4a4BTx7vGM3khQTOVhRKPACoBxFVr3cSU QgJduHphS0kqXxjiqK1ug/C3FMcqhkjm8CiHcu2o= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 4/5] ipa: rkisp1: blc: Report sensor black levels in metadata Date: Mon, 1 Jul 2024 16:38:27 +0200 Message-ID: <20240701144122.3418955-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701144122.3418955-1-stefan.klug@ideasonboard.com> References: <20240701144122.3418955-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" For the tuning process it is necessary to know the sensor black levels. Add them to the metadata. Additionally enable raw support for this algorithm and add it to uncalibrated.yaml, so that black levels get reported when capturing tuning images. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/blc.cpp | 19 +++++++++++++++++++ src/ipa/rkisp1/algorithms/blc.h | 5 ++++- src/ipa/rkisp1/data/uncalibrated.yaml | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp index 0c39c3b47da5..a9f76b87d15a 100644 --- a/src/ipa/rkisp1/algorithms/blc.cpp +++ b/src/ipa/rkisp1/algorithms/blc.cpp @@ -9,6 +9,8 @@ #include +#include + #include "libcamera/internal/yaml_parser.h" /** @@ -38,6 +40,7 @@ LOG_DEFINE_CATEGORY(RkISP1Blc) BlackLevelCorrection::BlackLevelCorrection() : tuningParameters_(false) { + supportsRaw_ = true; } /** @@ -107,6 +110,22 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context, params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_BLS; } +/** + * \copydoc libcamera::ipa::Algorithm::process + */ +void BlackLevelCorrection::process([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + [[maybe_unused]] const rkisp1_stat_buffer *stats, + [[maybe_unused]] ControlList &metadata) +{ + metadata.set(controls::SensorBlackLevels, + { static_cast(blackLevelRed_), + static_cast(blackLevelGreenR_), + static_cast(blackLevelGreenB_), + static_cast(blackLevelBlue_) }); +} + REGISTER_IPA_ALGORITHM(BlackLevelCorrection, "BlackLevelCorrection") } /* namespace ipa::rkisp1::algorithms */ diff --git a/src/ipa/rkisp1/algorithms/blc.h b/src/ipa/rkisp1/algorithms/blc.h index 460ebcc15739..4ecac233f88b 100644 --- a/src/ipa/rkisp1/algorithms/blc.h +++ b/src/ipa/rkisp1/algorithms/blc.h @@ -23,7 +23,10 @@ public: void prepare(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, rkisp1_params_cfg *params) override; - + void process(IPAContext &context, const uint32_t frame, + IPAFrameContext &frameContext, + const rkisp1_stat_buffer *stats, + ControlList &metadata) override; private: bool tuningParameters_; int16_t blackLevelRed_; diff --git a/src/ipa/rkisp1/data/uncalibrated.yaml b/src/ipa/rkisp1/data/uncalibrated.yaml index a7bbd8d84263..609012967e02 100644 --- a/src/ipa/rkisp1/data/uncalibrated.yaml +++ b/src/ipa/rkisp1/data/uncalibrated.yaml @@ -5,4 +5,5 @@ version: 1 algorithms: - Agc: - Awb: + - BlackLevelCorrection: ... From patchwork Mon Jul 1 14:38:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20498 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 B7A3FBEFBE for ; Mon, 1 Jul 2024 14:41:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6C3B763331; Mon, 1 Jul 2024 16:41:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pm7Asl7y"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D136763331 for ; Mon, 1 Jul 2024 16:41:50 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:89b2:f6c7:b29b:4e5c]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E8DA289; Mon, 1 Jul 2024 16:41:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719844884; bh=tVxWJR2M1MtcigGANG+asBgk/dc7ObEaVvEtWPIvD+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pm7Asl7ytUbyzyWHoWbpFc+5I3ZLanEeOAma3YUOzV4+xboxQslSfVZbcg6CvPJ5e 8uH/JIdUOHKDHJzgFUgp50mlywxXSUxC6aGj1i24P/4VxfW10uVjpYzbF9noPlzsZC J1xfLVrjaZevkLZl9KAiqIAsCZcrd5VUnf5+aOOc= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 5/5] ipa: rkisp1: data: Update tuning files for imx219 and imx258 Date: Mon, 1 Jul 2024 16:38:28 +0200 Message-ID: <20240701144122.3418955-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701144122.3418955-1-stefan.klug@ideasonboard.com> References: <20240701144122.3418955-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" For imx219 the black level was incorrectly set to 256. According to the datasheet it is 64d for raw 10. Mapped to 16bit, this becomes 4096. For the imx258, BLC was not included at all. As only LSC data with rather low maximum values, the image quality is expected to only get better by adding black level correction. Signed-off-by: Stefan Klug Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/ipa/rkisp1/data/imx219.yaml | 4 ---- src/ipa/rkisp1/data/imx258.yaml | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ipa/rkisp1/data/imx219.yaml b/src/ipa/rkisp1/data/imx219.yaml index cbcc43b84ac7..0d99cb529392 100644 --- a/src/ipa/rkisp1/data/imx219.yaml +++ b/src/ipa/rkisp1/data/imx219.yaml @@ -6,10 +6,6 @@ algorithms: - Agc: - Awb: - BlackLevelCorrection: - R: 256 - Gr: 256 - Gb: 256 - B: 256 - LensShadingCorrection: x-size: [ 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625 ] y-size: [ 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625 ] diff --git a/src/ipa/rkisp1/data/imx258.yaml b/src/ipa/rkisp1/data/imx258.yaml index 43dddf20dcd2..202af36afbee 100644 --- a/src/ipa/rkisp1/data/imx258.yaml +++ b/src/ipa/rkisp1/data/imx258.yaml @@ -5,6 +5,7 @@ version: 1 algorithms: - Agc: - Awb: + - BlackLevelCorrection: - LensShadingCorrection: x-size: [ 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625 ] y-size: [ 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625 ]