{"id":26496,"url":"https://patchwork.libcamera.org/api/patches/26496/?format=json","web_url":"https://patchwork.libcamera.org/patch/26496/","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":"<20260407-kbingham-awb-split-v1-13-a39af3f4dc20@ideasonboard.com>","date":"2026-04-07T22:01:16","name":"[13/13] ipa: libipa: awb: factor out common prepare","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1ac56c28eb6ca71a4cc59a2d1c5e5e3ed397c146","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26496/mbox/","series":[{"id":5874,"url":"https://patchwork.libcamera.org/api/series/5874/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5874","date":"2026-04-07T22:01:03","name":"ipa: simple: Convert to libipa AWB implementation","version":1,"mbox":"https://patchwork.libcamera.org/series/5874/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26496/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26496/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 94F90C32FA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Apr 2026 22:03:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 55FA162E07;\n\tWed,  8 Apr 2026 00:02:58 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2622562DA7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2026 00:02:44 +0200 (CEST)","from [192.168.0.204] (ams.linuxembedded.co.uk [209.38.108.23])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5123725B7;\n\tWed,  8 Apr 2026 00:01:16 +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=\"ekxKGIOd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775599276;\n\tbh=5JfiMzRudcttUvGqI+sxwQvMjSY3DKrSpztYaCa7ooo=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=ekxKGIOdKJsdEOWjgwx0iQS2TqsaysAy/V8oPVisT+KodfmPBtIqC/2ajxphJHdm4\n\tueOYMlDr0EcU3dNnp+Eol/eMxLRE0rbRhHdsOJBd/miESX9lqIzQLHnP2qE2jnKXqF\n\t04EGMpIOQGCZ187DRqL0CgMgbRieG9B+FWFQ/Jfk=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Date":"Tue, 07 Apr 2026 23:01:16 +0100","Subject":"[PATCH 13/13] ipa: libipa: awb: factor out common prepare","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20260407-kbingham-awb-split-v1-13-a39af3f4dc20@ideasonboard.com>","References":"<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>","In-Reply-To":"<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>","X-Mailer":"b4 0.14.2","X-Developer-Signature":"v=1; a=ed25519-sha256; t=1775599360; l=4270;\n\ti=kieran.bingham@ideasonboard.com; s=20260204;\n\th=from:subject:message-id; \n\tbh=5JfiMzRudcttUvGqI+sxwQvMjSY3DKrSpztYaCa7ooo=;\n\tb=HGzGuZlj5Vhg3l1F0ilZUj99PFgK7adjPqpiy0DN+k72pPcv2n5VDbFBtmGxDSWpBf40EQZ3Q\n\tJajqiz1A51tD+yKhg5cmgQxH56LYA80TNMGDVRbGKmfL8I/SojpUF8o","X-Developer-Key":"i=kieran.bingham@ideasonboard.com; a=ed25519;\n\tpk=IOxS2C6nWHNjLfkDR71Iesk904i6wJDfEERqV7hDBdY=","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":"Move the common duplicated code from both the simple and rkisp1 IPA modules\nand add these to the prepare function of libipa awb module.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/libipa/awb.cpp            | 20 ++++++++++++++++++++\n src/ipa/libipa/awb.h              |  4 ++++\n src/ipa/rkisp1/algorithms/awb.cpp | 11 ++---------\n src/ipa/simple/algorithms/awb.cpp | 12 +++---------\n 4 files changed, 29 insertions(+), 18 deletions(-)","diff":"diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp\nindex cac6b4bd206faa4f32680e16c7522685cfd30cac..b079a9c24b0d2d1e11b8da1087023af715765e31 100644\n--- a/src/ipa/libipa/awb.cpp\n+++ b/src/ipa/libipa/awb.cpp\n@@ -227,6 +227,26 @@ void AwbAlgorithm::queueRequest(awb::ActiveState &state,\n \tframeContext.temperatureK = state.manual.temperatureK;\n }\n \n+/**\n+ * \\brief Prepare the AWB frame context ready for usage\n+ * \\param[in] state The AWB specific active state shared across frames\n+ * \\param[in] frame The frame number to apply the control values\n+ * \\param[in] frameContext The current frame's AWB specific context\n+ */\n+void AwbAlgorithm::prepare(awb::ActiveState &state,\n+\t\t\t   [[maybe_unused]] const uint32_t frame,\n+\t\t\t   awb::FrameContext &frameContext)\n+{\n+\t/*\n+\t * When AutoAWB is enabled, this is the latest opportunity to take\n+\t * the most recent and up to date desired AWB gains.\n+\t */\n+\tif (frameContext.autoEnabled) {\n+\t\tframeContext.gains = state.automatic.gains;\n+\t\tframeContext.temperatureK = state.automatic.temperatureK;\n+\t}\n+}\n+\n /**\n  * \\fn AwbAlgorithm::calculateAwb()\n  * \\brief Calculate AWB data from the given statistics\ndiff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h\nindex 0256ff8ca3429288c317d3ee940255c4a5391357..ae061f4082ed947c5b8df95bd33566be6777849f 100644\n--- a/src/ipa/libipa/awb.h\n+++ b/src/ipa/libipa/awb.h\n@@ -73,6 +73,10 @@ public:\n \t\t\t  awb::FrameContext &frameContext,\n \t\t\t  const ControlList &controls);\n \n+\tvoid prepare(awb::ActiveState &state,\n+\t\t     [[maybe_unused]] const uint32_t frame,\n+\t\t     awb::FrameContext &frameContext);\n+\n \tvirtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0;\n \tvirtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0;\n \ndiff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex b91132fc6177650b9338867359583bf5429ea7e5..9aacb0cff0e747dba588e45434c108d592742701 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -160,15 +160,8 @@ void Awb::queueRequest(IPAContext &context,\n void Awb::prepare(IPAContext &context, const uint32_t frame,\n \t\t  IPAFrameContext &frameContext, RkISP1Params *params)\n {\n-\t/*\n-\t * This is the latest time we can read the active state. This is the\n-\t * most up-to-date automatic values we can read.\n-\t */\n-\tif (frameContext.awb.autoEnabled) {\n-\t\tconst auto &awb = context.activeState.awb;\n-\t\tframeContext.awb.gains = awb.automatic.gains;\n-\t\tframeContext.awb.temperatureK = awb.automatic.temperatureK;\n-\t}\n+\tawbAlgo_->prepare(context.activeState.awb,\n+\t\t\t  frame, frameContext.awb);\n \n \tauto gainConfig = params->block<BlockType::AwbGain>();\n \tgainConfig.setEnabled(true);\ndiff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\nindex d8516871562724fc65ffbb67161ff4fd988c4b1c..6ce1ed340a5338e25f44145942de95f7f4f6c637 100644\n--- a/src/ipa/simple/algorithms/awb.cpp\n+++ b/src/ipa/simple/algorithms/awb.cpp\n@@ -124,18 +124,12 @@ void Awb::queueRequest(IPAContext &context,\n }\n \n void Awb::prepare(IPAContext &context,\n-\t\t  [[maybe_unused]] const uint32_t frame,\n+\t\t  const uint32_t frame,\n \t\t  IPAFrameContext &frameContext,\n \t\t  DebayerParams *params)\n {\n-\t/*\n-\t * When AutoAWB is enabled, this is the latest opportunity to take\n-\t * the most recent and up to date desired AWB gains.\n-\t */\n-\tif (frameContext.awb.autoEnabled) {\n-\t\tframeContext.awb.gains = context.activeState.awb.automatic.gains;\n-\t\tframeContext.awb.temperatureK = context.activeState.awb.automatic.temperatureK;\n-\t}\n+\tawbAlgo_->prepare(context.activeState.awb,\n+\t\t\t  frame, frameContext.awb);\n \n \tparams->gains = frameContext.awb.gains;\n }\n","prefixes":["13/13"]}