[{"id":36410,"web_url":"https://patchwork.libcamera.org/comment/36410/","msgid":"<hd3cill7canz76qixphx4jp6zkjlmezwkne22fokobbv6usin6@bmccwdqegdx3>","date":"2025-10-23T16:49:18","subject":"Re: [RFC PATCH 3/7] ipa: mali-c55: Confine blacklevel config","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Kieran\n\nOn Sat, Oct 11, 2025 at 05:03:31PM +0100, Kieran Bingham wrote:\n> Move the black level handling into the blc module.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/mali-c55/algorithms/blc.cpp | 20 +++++++++++++-------\n>  src/ipa/mali-c55/ipa_context.h      |  1 -\n>  src/ipa/mali-c55/mali-c55.cpp       | 10 ----------\n>  3 files changed, 13 insertions(+), 18 deletions(-)\n>\n> diff --git a/src/ipa/mali-c55/algorithms/blc.cpp b/src/ipa/mali-c55/algorithms/blc.cpp\n> index 85642c0435a2..1fdd00ccc2ea 100644\n> --- a/src/ipa/mali-c55/algorithms/blc.cpp\n> +++ b/src/ipa/mali-c55/algorithms/blc.cpp\n> @@ -64,17 +64,23 @@ int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context,\n>  int BlackLevelCorrection::configure(IPAContext &context,\n>  \t\t\t\t    [[maybe_unused]] const IPACameraSensorInfo &configInfo)\n>  {\n> +\tif (!context.camHelper->blackLevel().has_value())\n> +\t\treturn 0;\n> +\n> +\t/*\n> +\t * The black level from CameraSensorHelper is a 16-bit value.\n> +\t * The Mali-C55 ISP expects 20-bit settings, so we shift it to\n> +\t * the appropriate width\n> +\t */\n> +\tuint32_t blackLevel = context.camHelper->blackLevel().value() << 4;\n> +\n>  \t/*\n>  \t * If no Black Levels were passed in through tuning data then we could\n>  \t * use the value from the CameraSensorHelper if one is available.\n>  \t */\n> -\tif (context.configuration.sensor.blackLevel &&\n> -\t    !(offset00_ + offset01_ + offset10_ + offset11_)) {\n> -\t\toffset00_ = context.configuration.sensor.blackLevel;\n> -\t\toffset01_ = context.configuration.sensor.blackLevel;\n> -\t\toffset10_ = context.configuration.sensor.blackLevel;\n> -\t\toffset11_ = context.configuration.sensor.blackLevel;\n> -\t}\n> +\tif (blackLevel &&\n\nIf we get here we know that context.camHelper->blackLevel().has_value()\nIs it possible that it has value 0 ?\n\n> +\t    !(offset00_ + offset01_ + offset10_ + offset11_))\n> +\t\toffset00_ = offset01_ = offset10_ = offset11_ = blackLevel;\n>\n>  \treturn 0;\n>  }\n> diff --git a/src/ipa/mali-c55/ipa_context.h b/src/ipa/mali-c55/ipa_context.h\n> index bfa805c7b93f..6dd8e5b0edfc 100644\n> --- a/src/ipa/mali-c55/ipa_context.h\n> +++ b/src/ipa/mali-c55/ipa_context.h\n> @@ -31,7 +31,6 @@ struct IPASessionConfiguration {\n>  \tstruct {\n>  \t\tBayerFormat::Order bayerOrder;\n>  \t\tutils::Duration lineDuration;\n> -\t\tuint32_t blackLevel;\n>  \t} sensor;\n>  };\n>\n> diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp\n> index 0751513dc584..27f6501085b9 100644\n> --- a/src/ipa/mali-c55/mali-c55.cpp\n> +++ b/src/ipa/mali-c55/mali-c55.cpp\n> @@ -190,16 +190,6 @@ void IPAMaliC55::updateSessionConfiguration(const IPACameraSensorInfo &info,\n>  \tcontext_.configuration.agc.defaultExposure = defExposure;\n>  \tcontext_.configuration.agc.minAnalogueGain = context_.camHelper->gain(minGain);\n>  \tcontext_.configuration.agc.maxAnalogueGain = context_.camHelper->gain(maxGain);\n> -\n> -\tif (context_.camHelper->blackLevel().has_value()) {\n> -\t\t/*\n> -\t\t * The black level from CameraSensorHelper is a 16-bit value.\n> -\t\t * The Mali-C55 ISP expects 20-bit settings, so we shift it to\n> -\t\t * the appropriate width\n> -\t\t */\n> -\t\tcontext_.configuration.sensor.blackLevel =\n> -\t\t\tcontext_.camHelper->blackLevel().value() << 4;\n> -\t}\n>  }\n>\n>  void IPAMaliC55::updateControls(const IPACameraSensorInfo &sensorInfo,\n> --\n> 2.51.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7BD4BC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 16:49:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B42C860838;\n\tThu, 23 Oct 2025 18:49:24 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A036607FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 18:49:23 +0200 (CEST)","from ideasonboard.com (mob-5-90-63-16.net.vodafone.it [5.90.63.16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9C991EFE;\n\tThu, 23 Oct 2025 18:47:37 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"X96TzAzo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761238058;\n\tbh=9kPzxROkG43qCdLnlWLCQNFIqMz2UPVla8Auik3Y8v8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=X96TzAzoS+rtaBH7sGoyA8yTBP3OOcuTDd6AV7QVYB8o02gm7Mt4bWGP/9U2wb6AD\n\ttpol7GM/lN5u3E1Wk6KPCM04yQG/4UnTs2lpJuUJ+JQL6Tz7RAU5999AnbuKoUgUMR\n\txriuH/AghcWKe45zGeQPiPQcMu4T0a/fdSdZjQz0=","Date":"Thu, 23 Oct 2025 18:49:18 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Subject":"Re: [RFC PATCH 3/7] ipa: mali-c55: Confine blacklevel config","Message-ID":"<hd3cill7canz76qixphx4jp6zkjlmezwkne22fokobbv6usin6@bmccwdqegdx3>","References":"<20251011160335.50578-1-kieran.bingham@ideasonboard.com>\n\t<20251011160335.50578-4-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251011160335.50578-4-kieran.bingham@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]