{"id":27189,"url":"https://patchwork.libcamera.org/api/patches/27189/?format=json","web_url":"https://patchwork.libcamera.org/patch/27189/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260703153819.1088752-10-barnabas.pocze@ideasonboard.com>","date":"2026-07-03T15:38:11","name":"[RFC,v1,09/17] ipa: mali-c55: Remove `DigitalGain` support","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"df1f66e7ed49530b5485639da1dc2b34c7c6d2e7","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/27189/mbox/","series":[{"id":6036,"url":"https://patchwork.libcamera.org/api/series/6036/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6036","date":"2026-07-03T15:38:02","name":"ipa: libipa: agc rework","version":1,"mbox":"https://patchwork.libcamera.org/series/6036/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27189/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27189/checks/","tags":{},"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 B283BC3308\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Jul 2026 15:38:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4964366013;\n\tFri,  3 Jul 2026 17:38:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ACD0E65FDB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Jul 2026 17:38:24 +0200 (CEST)","from pb-laptop.local (185.221.140.128.nat.pool.zt.hu\n\t[185.221.140.128])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A4DEDF3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Jul 2026 17:37:38 +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=\"odu/k0LX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783093058;\n\tbh=NNyDV7gIsfCimV6vCLZyrJiavwy/f/CN6usMamS2Y+g=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=odu/k0LXD6PURPVAI3oS6sKWXrEIr2cC5qjtUyNT+Ato8jqpLn4LF8s8rGjoec4bJ\n\tlplN+iYNx2Vt0VXgBGyCTzPhhUT9iPrvTQJoJ28GIICaWvPK7hemMP+0yPrCLwAwL0\n\t847/BzFAdnp81SZ3NoA8yLiocvg9pUcGp6It573E=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[RFC PATCH v1 09/17] ipa: mali-c55: Remove `DigitalGain` support","Date":"Fri,  3 Jul 2026 17:38:11 +0200","Message-ID":"<20260703153819.1088752-10-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260703153819.1088752-1-barnabas.pocze@ideasonboard.com>","References":"<20260703153819.1088752-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","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>"},"content":"The mali-c55 agc algorithm still mainly uses the `AeEnable` control,\nbut the interaction of that control and `AeEnable` is not well defined,\nand not other platform supports setting it. So remove it for now until\nthings are properly defined.\n\nLink: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/262\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/ipa/mali-c55/algorithms/agc.cpp | 57 ++---------------------------\n src/ipa/mali-c55/algorithms/agc.h   |  3 --\n src/ipa/mali-c55/ipa_context.h      |  3 --\n 3 files changed, 4 insertions(+), 59 deletions(-)","diff":"diff --git a/src/ipa/mali-c55/algorithms/agc.cpp b/src/ipa/mali-c55/algorithms/agc.cpp\nindex 6e091603f9..8d104e01f2 100644\n--- a/src/ipa/mali-c55/algorithms/agc.cpp\n+++ b/src/ipa/mali-c55/algorithms/agc.cpp\n@@ -16,7 +16,6 @@\n #include <libcamera/property_ids.h>\n \n #include \"libipa/colours.h\"\n-#include \"libipa/fixedpoint.h\"\n \n namespace libcamera {\n \n@@ -33,14 +32,6 @@ LOG_DEFINE_CATEGORY(MaliC55Agc)\n  */\n static constexpr unsigned int kNumHistogramBins = 256;\n \n-/*\n- * The Mali-C55 ISP has a digital gain block which allows setting gain in Q5.8\n- * format, a range of 0.0 to (very nearly) 32.0. We clamp from 1.0 to the actual\n- * max value which is 8191 * 2^-8.\n- */\n-static constexpr float kMinDigitalGain = 1.0;\n-static constexpr float kMaxDigitalGain = UQ<5, 8>::TraitsType::max;\n-\n uint32_t AgcStatistics::decodeBinValue(uint16_t binVal)\n {\n \tint exponent = (binVal & 0xf000) >> 12;\n@@ -137,8 +128,6 @@ int Agc::init(IPAContext &context, const ValueNode &tuningData)\n \t\treturn ret;\n \n \tcontext.ctrlMap[&controls::AeEnable] = ControlInfo(false, true);\n-\tcontext.ctrlMap[&controls::DigitalGain] = ControlInfo(\n-\t\tkMinDigitalGain, kMaxDigitalGain, kMinDigitalGain);\n \tcontext.ctrlMap.merge(agc_.controls());\n \n \treturn 0;\n@@ -158,10 +147,8 @@ int Agc::configure(IPAContext &context,\n \tcontext.activeState.agc.autoEnabled = true;\n \tcontext.activeState.agc.automatic.sensorGain = context.configuration.agc.minAnalogueGain;\n \tcontext.activeState.agc.automatic.exposure = context.configuration.agc.defaultExposure;\n-\tcontext.activeState.agc.automatic.ispGain = kMinDigitalGain;\n \tcontext.activeState.agc.manual.sensorGain = context.configuration.agc.minAnalogueGain;\n \tcontext.activeState.agc.manual.exposure = context.configuration.agc.defaultExposure;\n-\tcontext.activeState.agc.manual.ispGain = kMinDigitalGain;\n \tcontext.activeState.agc.constraintMode = agc_.constraintModes().begin()->first;\n \tcontext.activeState.agc.exposureMode = agc_.exposureModeHelpers().begin()->first;\n \n@@ -226,32 +213,6 @@ void Agc::queueRequest(IPAContext &context, const uint32_t frame,\n \t\t\t<< \"Analogue gain set to \" << agc.manual.sensorGain\n \t\t\t<< \" on request sequence \" << frame;\n \t}\n-\n-\tconst auto &digitalGain = controls.get(controls::DigitalGain);\n-\tif (digitalGain) {\n-\t\tagc.manual.ispGain = *digitalGain;\n-\n-\t\tLOG(MaliC55Agc, Debug)\n-\t\t\t<< \"Digital gain set to \" << agc.manual.ispGain\n-\t\t\t<< \" on request sequence \" << frame;\n-\t}\n-}\n-\n-void Agc::fillGainParamBlock(IPAContext &context, IPAFrameContext &frameContext,\n-\t\t\t     MaliC55Params *params)\n-{\n-\tIPAActiveState &activeState = context.activeState;\n-\tUQ<5, 8> gain;\n-\n-\tif (activeState.agc.autoEnabled)\n-\t\tgain = activeState.agc.automatic.ispGain;\n-\telse\n-\t\tgain = activeState.agc.manual.ispGain;\n-\n-\tauto block = params->block<MaliC55Blocks::Dgain>();\n-\tblock->gain = gain.quantized();\n-\n-\tframeContext.agc.ispGain = gain;\n }\n \n void Agc::fillParamsBuffer(MaliC55Params *params, enum MaliC55Blocks type)\n@@ -304,11 +265,9 @@ void Agc::fillWeightsArrayBuffer(MaliC55Params *params, const enum MaliC55Blocks\n \tstd::fill(weights.begin(), weights.end(), 1);\n }\n \n-void Agc::prepare(IPAContext &context, const uint32_t frame,\n-\t\t  IPAFrameContext &frameContext, MaliC55Params *params)\n+void Agc::prepare([[maybe_unused]] IPAContext &context, const uint32_t frame,\n+\t\t  [[maybe_unused]]  IPAFrameContext &frameContext, MaliC55Params *params)\n {\n-\tfillGainParamBlock(context, frameContext, params);\n-\n \tif (frame > 0)\n \t\treturn;\n \n@@ -370,10 +329,8 @@ void Agc::process(IPAContext &context,\n \t */\n \tuint32_t exposure = frameContext.agc.exposure;\n \tdouble analogueGain = frameContext.agc.sensorGain;\n-\tdouble digitalGain = frameContext.agc.ispGain.value();\n-\tdouble totalGain = analogueGain * digitalGain;\n \tutils::Duration currentShutter = exposure * configuration.sensor.lineDuration;\n-\tutils::Duration effectiveExposureValue = currentShutter * totalGain;\n+\tutils::Duration effectiveExposureValue = currentShutter * analogueGain;\n \tAgcTraits agcTraits(statistics_);\n \n \n@@ -384,21 +341,15 @@ void Agc::process(IPAContext &context,\n \t\t\t\t    activeState.agc.exposureMode, statistics_.yHist,\n \t\t\t\t    effectiveExposureValue, agcTraits);\n \n-\tUQ<5, 8> dGainQ = std::clamp(static_cast<float>(dGain),\n-\t\t\t\t     kMinDigitalGain,\n-\t\t\t\t     kMaxDigitalGain);\n-\n \tLOG(MaliC55Agc, Debug)\n \t\t<< \"Divided up shutter, analogue gain and digital gain are \"\n-\t\t<< shutterTime << \", \" << aGain << \" and \" << dGainQ;\n+\t\t<< shutterTime << \", \" << aGain << \" and \" << dGain;\n \n \tactiveState.agc.automatic.exposure = shutterTime / configuration.sensor.lineDuration;\n \tactiveState.agc.automatic.sensorGain = aGain;\n-\tactiveState.agc.automatic.ispGain = dGainQ;\n \n \tmetadata.set(controls::ExposureTime, currentShutter.get<std::micro>());\n \tmetadata.set(controls::AnalogueGain, frameContext.agc.sensorGain);\n-\tmetadata.set(controls::DigitalGain, frameContext.agc.ispGain.value());\n \tmetadata.set(controls::ColourTemperature, context.activeState.agc.temperatureK);\n }\n \ndiff --git a/src/ipa/mali-c55/algorithms/agc.h b/src/ipa/mali-c55/algorithms/agc.h\nindex e36378a2ac..ec7fe28c17 100644\n--- a/src/ipa/mali-c55/algorithms/agc.h\n+++ b/src/ipa/mali-c55/algorithms/agc.h\n@@ -64,9 +64,6 @@ public:\n \t\t     ControlList &metadata) override;\n \n private:\n-\tvoid fillGainParamBlock(IPAContext &context,\n-\t\t\t\tIPAFrameContext &frameContext,\n-\t\t\t\tMaliC55Params *params);\n \tvoid fillParamsBuffer(MaliC55Params *params, enum MaliC55Blocks type);\n \tvoid fillWeightsArrayBuffer(MaliC55Params *params, enum MaliC55Blocks type);\n \ndiff --git a/src/ipa/mali-c55/ipa_context.h b/src/ipa/mali-c55/ipa_context.h\nindex ac4b837738..075d6f66ef 100644\n--- a/src/ipa/mali-c55/ipa_context.h\n+++ b/src/ipa/mali-c55/ipa_context.h\n@@ -41,12 +41,10 @@ struct IPAActiveState {\n \t\tstruct {\n \t\t\tuint32_t exposure;\n \t\t\tdouble sensorGain;\n-\t\t\tUQ<5, 8> ispGain;\n \t\t} automatic;\n \t\tstruct {\n \t\t\tuint32_t exposure;\n \t\t\tdouble sensorGain;\n-\t\t\tUQ<5, 8> ispGain;\n \t\t} manual;\n \t\tbool autoEnabled;\n \t\tuint32_t constraintMode;\n@@ -64,7 +62,6 @@ struct IPAFrameContext : public FrameContext {\n \tstruct {\n \t\tuint32_t exposure;\n \t\tdouble sensorGain;\n-\t\tUQ<5, 8> ispGain;\n \t} agc;\n \n \tstruct {\n","prefixes":["RFC","v1","09/17"]}