[{"id":20347,"web_url":"https://patchwork.libcamera.org/comment/20347/","msgid":"<YXDQ5jrQbi7KOhVt@pendragon.ideasonboard.com>","date":"2021-10-21T02:31:02","subject":"Re: [libcamera-devel] [PATCH v2 10/13] ipa: ipu3: agc: Introduce\n\tprevious exposure value","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nThank you for the patch.\n\nOn Wed, Oct 20, 2021 at 05:46:04PM +0200, Jean-Michel Hautbois wrote:\n> We need to calculate the gain on the previous exposure value calculated.\n> Now that we initialise the exposure and gain values in configure(), we\n> know the initial exposure value, and we can set it before any loop is\n> running.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 13 +++++++++++--\n>  src/ipa/ipu3/algorithms/agc.h   |  1 +\n>  2 files changed, 12 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index eec77378..19f3a420 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -42,7 +42,8 @@ static constexpr double kEvGainTarget = 0.5;\n>  Agc::Agc()\n>  \t: frameCount_(0), lastFrame_(0), iqMean_(0.0), lineDuration_(0s),\n>  \t  minExposureLines_(0), maxExposureLines_(0), filteredExposure_(0s),\n> -\t  filteredExposureNoDg_(0s), currentExposure_(0s), currentExposureNoDg_(0s)\n> +\t  filteredExposureNoDg_(0s), currentExposure_(0s),\n> +\t  currentExposureNoDg_(0s), prevExposureValue_(0s)\n>  {\n>  }\n>  \n> @@ -58,9 +59,14 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>  \t\tcontext.configuration.agc.minAnalogueGain;\n>  \tcontext.frameContext.agc.exposure = minExposureLines_;\n>  \n> +\t/* \\todo replace the exposure in lines storage with time based ones */\n\nThis could have gone to an earlier patch.\n\n>  \tminExposureLines_ = context.configuration.agc.minShutterSpeed / lineDuration_;\n>  \tmaxExposureLines_ = context.configuration.agc.maxShutterSpeed / lineDuration_;\n>  \n> +\tprevExposureValue_ = context.frameContext.agc.gain\n> +\t\t\t   * context.frameContext.agc.exposure\n> +\t\t\t   * lineDuration_;\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -146,7 +152,7 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain)\n>  \t\t\t\t    << \" Gain \" << analogueGain\n>  \t\t\t\t    << \" Needed ev gain \" << evGain;\n>  \n> -\t\tcurrentExposure_ = currentExposureNoDg_ * evGain;\n> +\t\tcurrentExposure_ = prevExposureValue_ * evGain;\n>  \t\tutils::Duration minShutterSpeed = minExposureLines_ * lineDuration_;\n>  \t\tutils::Duration maxShutterSpeed = maxExposureLines_ * lineDuration_;\n>  \n> @@ -175,6 +181,9 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain)\n>  \n>  \t\texposure = shutterTime / lineDuration_;\n>  \t\tanalogueGain = stepGain;\n> +\n> +\t\t/* Update the exposure value for the next process call */\n\n\t\t/*\n\t\t * Update the exposure value for the next process call.\n\t\t *\n\t\t * \\todo Obtain the values of the exposure time and analog gain\n\t\t * that were actually used by the sensor, either from embedded\n\t\t * data when available, or from the delayed controls\n\t\t * infrastructure in case a slow down caused a mismatch.\n\t\t */\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\tprevExposureValue_ = shutterTime * analogueGain;\n>  \t}\n>  \tlastFrame_ = frameCount_;\n>  }\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index cd26d08c..2ae88e9f 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -49,6 +49,7 @@ private:\n>  \tutils::Duration filteredExposureNoDg_;\n>  \tutils::Duration currentExposure_;\n>  \tutils::Duration currentExposureNoDg_;\n> +\tutils::Duration prevExposureValue_;\n>  \n>  \tuint32_t stride_;\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 0163CBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Oct 2021 02:31:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5B75968F5B;\n\tThu, 21 Oct 2021 04:31:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 230A860124\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Oct 2021 04:31:22 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 96C302BA;\n\tThu, 21 Oct 2021 04:31:21 +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=\"Iy6SPC+z\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634783481;\n\tbh=rNoRqVxzUYMQcg8ppw/uDoE0cEgtLMlutfjXSoCJ7DI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Iy6SPC+zNX9AIRzpw+ZQlL4cd5FqBC53D72vQzMZe6fgwOmk0HGqZnQOU3NNBe88Z\n\tWWSw7AfLc8HqGiptKc39+9OK3jo/RiomY4R6/jIB7pW4biy5A6cFF3sxU7u2FMwuP/\n\t3jDT5usDMUw39r8nxuhGjoi3O4XccPpxaJjV9whE=","Date":"Thu, 21 Oct 2021 05:31:02 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YXDQ5jrQbi7KOhVt@pendragon.ideasonboard.com>","References":"<20211020154607.180161-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211020154607.180161-11-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211020154607.180161-11-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 10/13] ipa: ipu3: agc: Introduce\n\tprevious exposure value","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]