[{"id":37956,"web_url":"https://patchwork.libcamera.org/comment/37956/","msgid":"<fbe58602-ef1c-48dc-876d-20d84fc6bbd8@collabora.com>","date":"2026-01-26T15:58:19","subject":"Re: [PATCH v4 08/15] libcamera: ipa: simple: Move contrast settings\n\tto adjust.cpp","submitter":{"id":140,"url":"https://patchwork.libcamera.org/api/people/140/","name":"Robert Mader","email":"robert.mader@collabora.com"},"content":"Reviewed-by: Robert Mader <robert.mader@collabora.com>\n\nOn 22.01.26 17:19, Milan Zamazal wrote:\n> Let's move the contrast settings from lut.cpp to adjust.cpp, where they\n> belong, similarly to saturation.\n>\n> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>   src/ipa/simple/algorithms/adjust.cpp | 14 +++++++++++\n>   src/ipa/simple/algorithms/lut.cpp    | 35 +---------------------------\n>   src/ipa/simple/algorithms/lut.h      | 11 ---------\n>   3 files changed, 15 insertions(+), 45 deletions(-)\n>\n> diff --git a/src/ipa/simple/algorithms/adjust.cpp b/src/ipa/simple/algorithms/adjust.cpp\n> index 8ce0631e4..27ae2a53a 100644\n> --- a/src/ipa/simple/algorithms/adjust.cpp\n> +++ b/src/ipa/simple/algorithms/adjust.cpp\n> @@ -23,6 +23,7 @@ LOG_DEFINE_CATEGORY(IPASoftAdjust)\n>   \n>   int Adjust::init(IPAContext &context, [[maybe_unused]] const YamlObject &tuningData)\n>   {\n> +\tcontext.ctrlMap[&controls::Contrast] = ControlInfo(0.0f, 2.0f, 1.0f);\n>   \tif (context.ccmEnabled)\n>   \t\tcontext.ctrlMap[&controls::Saturation] = ControlInfo(0.0f, 2.0f, 1.0f);\n>   \treturn 0;\n> @@ -31,6 +32,7 @@ int Adjust::init(IPAContext &context, [[maybe_unused]] const YamlObject &tuningD\n>   int Adjust::configure(IPAContext &context,\n>   \t\t      [[maybe_unused]] const IPAConfigInfo &configInfo)\n>   {\n> +\tcontext.activeState.knobs.contrast = std::optional<double>();\n>   \tcontext.activeState.knobs.saturation = std::optional<double>();\n>   \n>   \treturn 0;\n> @@ -41,6 +43,12 @@ void Adjust::queueRequest(typename Module::Context &context,\n>   \t\t\t  [[maybe_unused]] typename Module::FrameContext &frameContext,\n>   \t\t\t  const ControlList &controls)\n>   {\n> +\tconst auto &contrast = controls.get(controls::Contrast);\n> +\tif (contrast.has_value()) {\n> +\t\tcontext.activeState.knobs.contrast = contrast;\n> +\t\tLOG(IPASoftAdjust, Debug) << \"Setting contrast to \" << contrast.value();\n> +\t}\n> +\n>   \tconst auto &saturation = controls.get(controls::Saturation);\n>   \tif (saturation.has_value()) {\n>   \t\tcontext.activeState.knobs.saturation = saturation;\n> @@ -75,6 +83,8 @@ void Adjust::prepare(IPAContext &context,\n>   \t\t     IPAFrameContext &frameContext,\n>   \t\t     [[maybe_unused]] DebayerParams *params)\n>   {\n> +\tframeContext.contrast = context.activeState.knobs.contrast;\n> +\n>   \tif (!context.ccmEnabled)\n>   \t\treturn;\n>   \n> @@ -95,6 +105,10 @@ void Adjust::process([[maybe_unused]] IPAContext &context,\n>   \t\t     [[maybe_unused]] const SwIspStats *stats,\n>   \t\t     ControlList &metadata)\n>   {\n> +\tconst auto &contrast = frameContext.contrast;\n> +\tif (contrast)\n> +\t\tmetadata.set(controls::Contrast, contrast.value());\n> +\n>   \tconst auto &saturation = frameContext.saturation;\n>   \tmetadata.set(controls::Saturation, saturation.value_or(1.0));\n>   }\n> diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\n> index 141ea17fa..3a00bf4ee 100644\n> --- a/src/ipa/simple/algorithms/lut.cpp\n> +++ b/src/ipa/simple/algorithms/lut.cpp\n> @@ -24,36 +24,16 @@ LOG_DEFINE_CATEGORY(IPASoftLut)\n>   \n>   namespace ipa::soft::algorithms {\n>   \n> -int Lut::init(IPAContext &context,\n> -\t      [[maybe_unused]] const YamlObject &tuningData)\n> -{\n> -\tcontext.ctrlMap[&controls::Contrast] = ControlInfo(0.0f, 2.0f, 1.0f);\n> -\treturn 0;\n> -}\n> -\n>   int Lut::configure(IPAContext &context,\n>   \t\t   [[maybe_unused]] const IPAConfigInfo &configInfo)\n>   {\n>   \t/* Gamma value is fixed */\n>   \tcontext.configuration.gamma = 1.0 / 2.2;\n> -\tcontext.activeState.knobs.contrast = std::optional<double>();\n>   \tupdateGammaTable(context);\n>   \n>   \treturn 0;\n>   }\n>   \n> -void Lut::queueRequest(typename Module::Context &context,\n> -\t\t       [[maybe_unused]] const uint32_t frame,\n> -\t\t       [[maybe_unused]] typename Module::FrameContext &frameContext,\n> -\t\t       const ControlList &controls)\n> -{\n> -\tconst auto &contrast = controls.get(controls::Contrast);\n> -\tif (contrast.has_value()) {\n> -\t\tcontext.activeState.knobs.contrast = contrast;\n> -\t\tLOG(IPASoftLut, Debug) << \"Setting contrast to \" << contrast.value();\n> -\t}\n> -}\n> -\n>   void Lut::updateGammaTable(IPAContext &context)\n>   {\n>   \tconst auto blackLevel = context.activeState.blc.level;\n> @@ -96,11 +76,9 @@ int16_t Lut::matrixValue(unsigned int i, float ccm) const\n>   \n>   void Lut::prepare(IPAContext &context,\n>   \t\t  [[maybe_unused]] const uint32_t frame,\n> -\t\t  IPAFrameContext &frameContext,\n> +\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n>   \t\t  DebayerParams *params)\n>   {\n> -\tframeContext.contrast = context.activeState.knobs.contrast;\n> -\n>   \t/*\n>   \t * Update the gamma table if needed. This means if black level changes\n>   \t * and since the black level gets updated only if a lower value is\n> @@ -157,17 +135,6 @@ void Lut::prepare(IPAContext &context,\n>   \tparams->contrastExp = context.activeState.gamma.contrastExp;\n>   }\n>   \n> -void Lut::process([[maybe_unused]] IPAContext &context,\n> -\t\t  [[maybe_unused]] const uint32_t frame,\n> -\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n> -\t\t  [[maybe_unused]] const SwIspStats *stats,\n> -\t\t  ControlList &metadata)\n> -{\n> -\tconst auto &contrast = frameContext.contrast;\n> -\tif (contrast)\n> -\t\tmetadata.set(controls::Contrast, contrast.value());\n> -}\n> -\n>   REGISTER_IPA_ALGORITHM(Lut, \"Lut\")\n>   \n>   } /* namespace ipa::soft::algorithms */\n> diff --git a/src/ipa/simple/algorithms/lut.h b/src/ipa/simple/algorithms/lut.h\n> index 0eafd0695..ad16d1e8e 100644\n> --- a/src/ipa/simple/algorithms/lut.h\n> +++ b/src/ipa/simple/algorithms/lut.h\n> @@ -19,22 +19,11 @@ public:\n>   \tLut() = default;\n>   \t~Lut() = default;\n>   \n> -\tint init(IPAContext &context, const YamlObject &tuningData) override;\n>   \tint configure(IPAContext &context, const IPAConfigInfo &configInfo) override;\n> -\tvoid queueRequest(typename Module::Context &context,\n> -\t\t\t  const uint32_t frame,\n> -\t\t\t  typename Module::FrameContext &frameContext,\n> -\t\t\t  const ControlList &controls)\n> -\t\toverride;\n>   \tvoid prepare(IPAContext &context,\n>   \t\t     const uint32_t frame,\n>   \t\t     IPAFrameContext &frameContext,\n>   \t\t     DebayerParams *params) override;\n> -\tvoid process(IPAContext &context,\n> -\t\t     const uint32_t frame,\n> -\t\t     IPAFrameContext &frameContext,\n> -\t\t     const SwIspStats *stats,\n> -\t\t     ControlList &metadata) override;\n>   \n>   private:\n>   \tvoid updateGammaTable(IPAContext &context);","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 1E8DAC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Jan 2026 15:58:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CF73261FD0;\n\tMon, 26 Jan 2026 16:58:28 +0100 (CET)","from sender4-op-o12.zoho.com (sender4-op-o12.zoho.com\n\t[136.143.188.12])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 02A2961FC4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jan 2026 16:58:26 +0100 (CET)","by mx.zohomail.com with SMTPS id 1769443101967302.6630264786006;\n\tMon, 26 Jan 2026 07:58:21 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=collabora.com\n\theader.i=robert.mader@collabora.com header.b=\"OiiJldbT\"; \n\tdkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1769443104; cv=none; \n\td=zohomail.com; s=zohoarc; \n\tb=RFZHqcN93BkKZVe4zgdcSG7t9CWnWyg8cyEoKL7dBJi/2dxEwFBRBtXRQdCNmyTHlV1OnDWANJZPlcWDb2aXGecLz/Is5VeutzS7vMpi/xcniKFYZORWCLWAp0e2hDc4TNhLH6zbcgBZqLQC7+KdFMntukJ/IPK5WM4BQmWZt8A=","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; \n\ts=zohoarc; t=1769443104;\n\th=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc;\n\tbh=AKt63HQmYrAoZzkf94ln/Ouq/FoQlexTSZVzjl9CN4I=; \n\tb=HqacyCkqOc70AYcgV6eSW/rQI3OgR6PYD6KNQ009Ymrl8IGqhGZQYQABQKUfEeyoVkCAShUJTjgBHjTE0Y4FndKnn7VviLP6e6e8xYt1nbUpGYyOA83XIj/Oq9dqLv/U7wFVZKg5sF7/3gFsdoZqRN7ORBYeJsEFnM3iSapbuNY=","ARC-Authentication-Results":"i=1; mx.zohomail.com;\n\tdkim=pass  header.i=collabora.com;\n\tspf=pass  smtp.mailfrom=robert.mader@collabora.com;\n\tdmarc=pass header.from=<robert.mader@collabora.com>","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1769443104;\n\ts=zohomail; d=collabora.com; i=robert.mader@collabora.com;\n\th=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc;\n\tbh=AKt63HQmYrAoZzkf94ln/Ouq/FoQlexTSZVzjl9CN4I=;\n\tb=OiiJldbT60VIRVOWshkRjnXVoeAWENosNb8N0SPpgKa9sb0j4kzOI1dYcJv1tCU1\n\tJvq27qusZUhGR+Fq9L7xGtL15XvEBrhwABoJC4yNYbXSWOkNjnSjol8UX3OkcWHVsZ9\n\tjRCp9q0uvO460XauGwbow+kR0hU0U5jqRKkmN7Is=","Message-ID":"<fbe58602-ef1c-48dc-876d-20d84fc6bbd8@collabora.com>","Date":"Mon, 26 Jan 2026 16:58:19 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v4 08/15] libcamera: ipa: simple: Move contrast settings\n\tto adjust.cpp","To":"libcamera-devel@lists.libcamera.org","References":"<20260122161935.208562-1-mzamazal@redhat.com>\n\t<20260122161935.208562-9-mzamazal@redhat.com>","Content-Language":"en-US, de-DE","From":"Robert Mader <robert.mader@collabora.com>","In-Reply-To":"<20260122161935.208562-9-mzamazal@redhat.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>"}}]