[{"id":20729,"web_url":"https://patchwork.libcamera.org/comment/20729/","msgid":"<163638861032.275423.18000256046104592288@Monstersaurus>","date":"2021-11-08T16:23:30","subject":"Re: [libcamera-devel] [PATCH 21/22] ipa: ipu3: Move ExposureTime to\n\tIPA","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jean-Michel Hautbois (2021-11-08 13:13:49)\n> Now that we have the exposure time calculated, pass it to the\n> controls::ExposureTime and don't use the pipeline handler for it\n> anymore. While at it, use the same line duration value for ExposureTime\n> and FrameDuration.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/ipu3.cpp                | 9 +++++++--\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 2 --\n>  2 files changed, 7 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index ca3f2417..24c77be8 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -691,12 +691,17 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>  \n>         setControls(frame);\n>  \n> +       double lineDuration = sensorInfo_.lineLength\n> +                           / (sensorInfo_.pixelRate / 1e6);\n\nIs this something that should be calculated / cached at configure time?\n\n> +\n>         /* \\todo Use VBlank value calculated from each frame exposure. */\n> -       int64_t frameDuration = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) /\n> -                               (sensorInfo_.pixelRate / 1e6);\n> +       int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height)\n> +                             * lineDuration;\n>         ctrls.set(controls::FrameDuration, frameDuration);\n>  \n>         ctrls.set(controls::ColourTemperature, context_.frameContext->awb.temperatureK);\n\nnew line here if you're keeping the int32_t calculation split.\n\n> +       int32_t exposureTime = context_.frameContext->agc.exposure * lineDuration;\n> +       ctrls.set(controls::ExposureTime, exposureTime);\n\nOtherwise, it could go in one statement, particularly if we take a local\nalias pointer for the frameContext as it is likely to be accessed so much:\n\n\tIPAFrameContext *frameContext = context_.frameContext;\n\n\tctrls.set(controls::ExposureTime, frameContext->agc.exposure * lineDuration);\n\n>  \n>         /*\n>          * \\todo We should be able to add 'anything' (with a Control) in here to\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 5d87f6e5..97003681 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -1322,8 +1322,6 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer)\n>         pipe()->completeBuffer(request, buffer);\n>  \n>         request->metadata().set(controls::draft::PipelineDepth, 3);\n> -       /* \\todo Move the ExposureTime control to the IPA. */\n> -       request->metadata().set(controls::ExposureTime, exposureTime_);\n\nDoes the pipeline handler still need an exposureTime_ ? Can it be\nremoved? or is something else using it?\n\n\n>         /* \\todo Actually apply the scaler crop region to the ImgU. */\n>         if (request->controls().contains(controls::ScalerCrop))\n>                 cropRegion_ = request->controls().get(controls::ScalerCrop);\n> -- \n> 2.32.0\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 5E37DBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Nov 2021 16:23:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AC49E6035D;\n\tMon,  8 Nov 2021 17:23:34 +0100 (CET)","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 3CD586032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Nov 2021 17:23:33 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BDBA3E51;\n\tMon,  8 Nov 2021 17:23:32 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZlF1WKhJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636388612;\n\tbh=HN5+0bHlhC2j05Nj/ajvxDBuCkvLdPXxZibO02YN83U=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=ZlF1WKhJE38OVDK6i8pUKig0OTp0aS4dirAtP/i54LY1u1g9nCa8cJVOX1gY2TLKI\n\tWjphP3ogfKQuth998dtFJURFX5GNq+xbbTYTiH9ySBE2yni6HYxZXq8x9K0e/WeNep\n\tkXxsVO63M7ZcI1A0yzJKcPwFeuKymOuhRMz+CUEQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211108131350.130665-22-jeanmichel.hautbois@ideasonboard.com>","References":"<20211108131350.130665-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211108131350.130665-22-jeanmichel.hautbois@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 08 Nov 2021 16:23:30 +0000","Message-ID":"<163638861032.275423.18000256046104592288@Monstersaurus>","User-Agent":"alot/0.9.1","Subject":"Re: [libcamera-devel] [PATCH 21/22] ipa: ipu3: Move ExposureTime to\n\tIPA","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":20821,"web_url":"https://patchwork.libcamera.org/comment/20821/","msgid":"<13e29664-9796-6da2-a219-db80c8102c3d@ideasonboard.com>","date":"2021-11-10T18:03:09","subject":"Re: [libcamera-devel] [PATCH 21/22] ipa: ipu3: Move ExposureTime to\n\tIPA","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Kieran,\n\nOn 08/11/2021 17:23, Kieran Bingham wrote:\n> Quoting Jean-Michel Hautbois (2021-11-08 13:13:49)\n>> Now that we have the exposure time calculated, pass it to the\n>> controls::ExposureTime and don't use the pipeline handler for it\n>> anymore. While at it, use the same line duration value for ExposureTime\n>> and FrameDuration.\n>>\n>> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n>> ---\n>>   src/ipa/ipu3/ipu3.cpp                | 9 +++++++--\n>>   src/libcamera/pipeline/ipu3/ipu3.cpp | 2 --\n>>   2 files changed, 7 insertions(+), 4 deletions(-)\n>>\n>> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n>> index ca3f2417..24c77be8 100644\n>> --- a/src/ipa/ipu3/ipu3.cpp\n>> +++ b/src/ipa/ipu3/ipu3.cpp\n>> @@ -691,12 +691,17 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>>   \n>>          setControls(frame);\n>>   \n>> +       double lineDuration = sensorInfo_.lineLength\n>> +                           / (sensorInfo_.pixelRate / 1e6);\n> \n> Is this something that should be calculated / cached at configure time?\n\nIt can, indeed !\n\n>> +\n>>          /* \\todo Use VBlank value calculated from each frame exposure. */\n>> -       int64_t frameDuration = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) /\n>> -                               (sensorInfo_.pixelRate / 1e6);\n>> +       int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height)\n>> +                             * lineDuration;\n>>          ctrls.set(controls::FrameDuration, frameDuration);\n>>   \n>>          ctrls.set(controls::ColourTemperature, context_.frameContext->awb.temperatureK);\n> \n> new line here if you're keeping the int32_t calculation split.\n> \n>> +       int32_t exposureTime = context_.frameContext->agc.exposure * lineDuration;\n>> +       ctrls.set(controls::ExposureTime, exposureTime);\n> \n> Otherwise, it could go in one statement, particularly if we take a local\n> alias pointer for the frameContext as it is likely to be accessed so much:\n> \n> \tIPAFrameContext *frameContext = context_.frameContext;\n> \n> \tctrls.set(controls::ExposureTime, frameContext->agc.exposure * lineDuration);\n> \n\nSure.\n\n>>   \n>>          /*\n>>           * \\todo We should be able to add 'anything' (with a Control) in here to\n>> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n>> index 5d87f6e5..97003681 100644\n>> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n>> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n>> @@ -1322,8 +1322,6 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer)\n>>          pipe()->completeBuffer(request, buffer);\n>>   \n>>          request->metadata().set(controls::draft::PipelineDepth, 3);\n>> -       /* \\todo Move the ExposureTime control to the IPA. */\n>> -       request->metadata().set(controls::ExposureTime, exposureTime_);\n> \n> Does the pipeline handler still need an exposureTime_ ? Can it be\n> removed? or is something else using it?\n\nGood catch. It is set in PipelineHandlerIPU3::updateControls() and never \nused anymore, so it should be removed from the pipeline handler now :-).\n\n> \n> \n>>          /* \\todo Actually apply the scaler crop region to the ImgU. */\n>>          if (request->controls().contains(controls::ScalerCrop))\n>>                  cropRegion_ = request->controls().get(controls::ScalerCrop);\n>> -- \n>> 2.32.0\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 C34ABBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Nov 2021 18:03:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D2776035D;\n\tWed, 10 Nov 2021 19:03:13 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 04AEE6033C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Nov 2021 19:03:11 +0100 (CET)","from [IPV6:2a01:e0a:169:7140:7713:3465:89e6:c5cd] (unknown\n\t[IPv6:2a01:e0a:169:7140:7713:3465:89e6:c5cd])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AA6449FF;\n\tWed, 10 Nov 2021 19:03:11 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RquouP9t\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636567391;\n\tbh=qfUOPf3pQqx6D+C0Fnki7khbOAu1XrL9EihXHuQzrzg=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=RquouP9tFPIMQoKNU5EEfZMV+/tGRdriGUk6wBBF5o8eYWEbzEgwFlYQiTNzcUo/x\n\tU4PcaLt6aGN0Q6Np3H9meMmpy81zlG0cAYhtYnL24z8MQbKDUpzR+ogp3GsqbHTdaU\n\tfAyAR34VWBKtmIlH9a2OARK6ttSDlAavTEK5vkCM=","Message-ID":"<13e29664-9796-6da2-a219-db80c8102c3d@ideasonboard.com>","Date":"Wed, 10 Nov 2021 19:03:09 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.2.1","Content-Language":"en-US","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20211108131350.130665-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211108131350.130665-22-jeanmichel.hautbois@ideasonboard.com>\n\t<163638861032.275423.18000256046104592288@Monstersaurus>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","In-Reply-To":"<163638861032.275423.18000256046104592288@Monstersaurus>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 21/22] ipa: ipu3: Move ExposureTime to\n\tIPA","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>"}}]