[{"id":35482,"web_url":"https://patchwork.libcamera.org/comment/35482/","msgid":"<b2fa2697-a915-4dd9-b6cf-018aa2d9e74b@ideasonboard.com>","date":"2025-08-18T12:30:55","subject":"Re: [PATCH v3 17/19] rkisp1: agc: Agc add yTarget to frame context","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"On 15/08/2025 11:29, Stefan Klug wrote:\n> The upcoming WDR algorithm needs access to the effective yTarget value\n> for its calculations. Add it to the frame context.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n\n> ---\n>   src/ipa/rkisp1/algorithms/agc.cpp | 5 +++++\n>   src/ipa/rkisp1/ipa_context.h      | 2 ++\n>   2 files changed, 7 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index d566a3fbef4a..7a4d3b064415 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -207,6 +207,8 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n>   \t\t  context.configuration.sensor.minAnalogueGain,\n>   \t\t  context.configuration.sensor.maxAnalogueGain, {});\n>   \n> +\tcontext.activeState.agc.automatic.yTarget = effectiveYTarget();\n> +\n>   \tresetFrameCount();\n>   \n>   \treturn 0;\n> @@ -374,6 +376,8 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n>   \t\tframeContext.compress.gain = frameContext.agc.quantizationGain;\n>   \t}\n>   \n> +\tframeContext.agc.yTarget = context.activeState.agc.automatic.yTarget;\n> +\n>   \tif (frame > 0 && !frameContext.agc.updateMetering)\n>   \t\treturn;\n>   \n> @@ -618,6 +622,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>   \tactiveState.agc.automatic.exposure = newExposureTime / lineDuration;\n>   \tactiveState.agc.automatic.gain = aGain;\n>   \tactiveState.agc.automatic.quantizationGain = qGain;\n> +\tactiveState.agc.automatic.yTarget = effectiveYTarget();\n>   \t/*\n>   \t * Expand the target frame duration so that we do not run faster than\n>   \t * the minimum frame duration when we have short exposures.\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index 60cfab228edf..ab0bbe0eb690 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -79,6 +79,7 @@ struct IPAActiveState {\n>   \t\t\tuint32_t exposure;\n>   \t\t\tdouble gain;\n>   \t\t\tdouble quantizationGain;\n> +\t\t\tdouble yTarget;\n>   \t\t} automatic;\n>   \n>   \t\tbool autoExposureEnabled;\n> @@ -139,6 +140,7 @@ struct IPAFrameContext : public FrameContext {\n>   \t\tdouble exposureValue;\n>   \t\tdouble quantizationGain;\n>   \t\tuint32_t vblank;\n> +\t\tdouble yTarget;\n>   \t\tbool autoExposureEnabled;\n>   \t\tbool autoGainEnabled;\n>   \t\tcontrols::AeConstraintModeEnum constraintMode;","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 34298BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Aug 2025 12:31:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1173569259;\n\tMon, 18 Aug 2025 14:31:01 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 12DD469257\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Aug 2025 14:30:59 +0200 (CEST)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D2C1D2416\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Aug 2025 14:30:01 +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=\"f8EztGbo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755520201;\n\tbh=YSDjpyCc+BBGgRXscKq5ouC95kHQsId9ZyzGDzPZKa0=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=f8EztGboGgE61tDXgSwB8FI0nbgPSC7w/mCMMQ+/0WDTC0YdSyrgZjqs8nz2hNIn3\n\twix4ZQyYzH4ogs5JoDBRjGl0QT9ns+oBluzSCK1p2SgxTL1xf0eX/Obg4z8cawzElt\n\t69wmNGcq/OJi6BPmBGem+UKFp0t7j6eWbkH8fUOw=","Message-ID":"<b2fa2697-a915-4dd9-b6cf-018aa2d9e74b@ideasonboard.com>","Date":"Mon, 18 Aug 2025 13:30:55 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 17/19] rkisp1: agc: Agc add yTarget to frame context","To":"libcamera-devel@lists.libcamera.org","References":"<20250815102945.1602071-1-stefan.klug@ideasonboard.com>\n\t<20250815102945.1602071-18-stefan.klug@ideasonboard.com>","Content-Language":"en-US","From":"Dan Scally <dan.scally@ideasonboard.com>","In-Reply-To":"<20250815102945.1602071-18-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>"}},{"id":35701,"web_url":"https://patchwork.libcamera.org/comment/35701/","msgid":"<175706896560.1787083.17481898120367008259@neptunite.rasen.tech>","date":"2025-09-05T10:42:45","subject":"Re: [PATCH v3 17/19] rkisp1: agc: Agc add yTarget to frame context","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-08-15 19:29:37)\n> The upcoming WDR algorithm needs access to the effective yTarget value\n> for its calculations. Add it to the frame context.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/rkisp1/algorithms/agc.cpp | 5 +++++\n>  src/ipa/rkisp1/ipa_context.h      | 2 ++\n>  2 files changed, 7 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index d566a3fbef4a..7a4d3b064415 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -207,6 +207,8 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n>                   context.configuration.sensor.minAnalogueGain,\n>                   context.configuration.sensor.maxAnalogueGain, {});\n>  \n> +       context.activeState.agc.automatic.yTarget = effectiveYTarget();\n> +\n>         resetFrameCount();\n>  \n>         return 0;\n> @@ -374,6 +376,8 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n>                 frameContext.compress.gain = frameContext.agc.quantizationGain;\n>         }\n>  \n> +       frameContext.agc.yTarget = context.activeState.agc.automatic.yTarget;\n> +\n>         if (frame > 0 && !frameContext.agc.updateMetering)\n>                 return;\n>  \n> @@ -618,6 +622,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>         activeState.agc.automatic.exposure = newExposureTime / lineDuration;\n>         activeState.agc.automatic.gain = aGain;\n>         activeState.agc.automatic.quantizationGain = qGain;\n> +       activeState.agc.automatic.yTarget = effectiveYTarget();\n>         /*\n>          * Expand the target frame duration so that we do not run faster than\n>          * the minimum frame duration when we have short exposures.\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index 60cfab228edf..ab0bbe0eb690 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -79,6 +79,7 @@ struct IPAActiveState {\n>                         uint32_t exposure;\n>                         double gain;\n>                         double quantizationGain;\n> +                       double yTarget;\n>                 } automatic;\n>  \n>                 bool autoExposureEnabled;\n> @@ -139,6 +140,7 @@ struct IPAFrameContext : public FrameContext {\n>                 double exposureValue;\n>                 double quantizationGain;\n>                 uint32_t vblank;\n> +               double yTarget;\n>                 bool autoExposureEnabled;\n>                 bool autoGainEnabled;\n>                 controls::AeConstraintModeEnum constraintMode;\n> -- \n> 2.48.1\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 EDDFDBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  5 Sep 2025 10:42:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 99E2569345;\n\tFri,  5 Sep 2025 12:42:54 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 740CF69337\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Sep 2025 12:42:52 +0200 (CEST)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:dbfb:387c:7405:52bc])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id EFEA3F09;\n\tFri,  5 Sep 2025 12:41:41 +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=\"KQYNRc0v\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1757068902;\n\tbh=+800t7dezumFyAyBsa3iDh/EaKY7Qtl8h5d4L3I3XFw=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=KQYNRc0vTlK2V4P6WqrVw9b7zO3ok5f0anAtim73I5Qs6Z2ZHVoheWIPHVOG/baV1\n\t9G95JzwsJAnA/UpmdycVZ/caLrvjsLO/NdqX31hbwwtmuxd5X5ya1fOXkwmIaNJfnC\n\tNO90WG8C3+ND11CPESQw1qjFvoO+F6IGMBE4EeWQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250815102945.1602071-18-stefan.klug@ideasonboard.com>","References":"<20250815102945.1602071-1-stefan.klug@ideasonboard.com>\n\t<20250815102945.1602071-18-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v3 17/19] rkisp1: agc: Agc add yTarget to frame context","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 05 Sep 2025 19:42:45 +0900","Message-ID":"<175706896560.1787083.17481898120367008259@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]