[{"id":22590,"web_url":"https://patchwork.libcamera.org/comment/22590/","msgid":"<YkzJvOualz38BBXf@pendragon.ideasonboard.com>","date":"2022-04-05T22:59:08","subject":"Re: [libcamera-devel] [IPAIPU3 PATCH v4 6/6] ipa: ipu3: Inlink\n\tparseStatistics() into processStatsBuffer()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\ns/Inlink/Inline/\n\nOn Thu, Mar 31, 2022 at 10:00:58PM +0530, Umang Jain via libcamera-devel wrote:\n> Since we have moved away from switch/case on the operation ID,\n> there's little reason to split the operation in two functions.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  ipu3.cpp | 74 ++++++++++++++++++++++++--------------------------------\n>  1 file changed, 31 insertions(+), 43 deletions(-)\n> \n> diff --git a/ipu3.cpp b/ipu3.cpp\n> index a435005..9063d7e 100644\n> --- a/ipu3.cpp\n> +++ b/ipu3.cpp\n> @@ -61,10 +61,6 @@ private:\n>  \t\t\t    const ControlInfoMap &sensorControls,\n>  \t\t\t    ControlInfoMap *ipaControls);\n>  \tvoid runAiq(unsigned int frame);\n> -\tvoid parseStatistics(unsigned int frame,\n> -\t\t\t     int64_t frameTimestamp,\n> -\t\t\t     const ipu3_uapi_stats_3a *stats,\n> -\t\t\t     const ControlList& sensorCtrls);\n>  \n>  \tvoid setControls(unsigned int frame);\n>  \n> @@ -380,43 +376,6 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, const int64_t frameTimest\n>  \tconst ipu3_uapi_stats_3a *stats =\n>  \t\treinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());\n>  \n> -\tparseStatistics(frame, frameTimestamp, stats, sensorControls);\n> -}\n> -\n> -void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)\n> -{\n> -\t/* Run algorithms into/using this context structure */\n> -\tresultsHistory_.extendOne();\n> -\taiq::AiqResults& latestResults = resultsHistory_.latest();\n> -\n> -\t/* Todo: Refactor AiqInputParameters interface to set following parameters. */\n> -\taiqInputParams_.afParams.lens_position = lensPosition_;\n> -\taiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;\n> -\n> -\taiq_.run2a(frame, aiqInputParams_, latestResults);\n> -\n> -\texposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;\n> -\tgain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;\n> -\n> -\t/*\n> -\t * Af algorithm compares the timestamp of start of the lens movement and\n> -\t * that of the statistics generated to estimate whether next lens\n> -\t * position should be produced.\n> -\t * \\todo use the lens movement start time reported by the pipeline handler.\n> -\t */\n> -\tif (lensPosition_ != latestResults.af()->next_lens_position) {\n> -\t\tutils::time_point time = utils::clock::now();\n> -\t\tuint64_t usecs = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();\n> -\t\tlensMovementStartTime_ = usecs;\n> -\t}\n> -\tlensPosition_ = latestResults.af()->next_lens_position;\n> -}\n> -\n> -void IPAIPU3::parseStatistics(unsigned int frame,\n> -\t\t\t      int64_t frameTimestamp,\n> -\t\t\t      const ipu3_uapi_stats_3a *stats,\n> -\t\t\t      const ControlList& sensorCtrls)\n> -{\n>  \tControlList ctrls(controls::controls);\n>  \n>  \t/* \\todo React to statistics and update internal state machine. */\n> @@ -439,11 +398,11 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>  \tint32_t effectiveGain = 0;\n>  \tControlValue ctrlValue;\n>  \n> -\tctrlValue = sensorCtrls.get(V4L2_CID_EXPOSURE);\n> +\tctrlValue = sensorControls.get(V4L2_CID_EXPOSURE);\n>  \tif (!ctrlValue.isNone())\n>  \t\teffectiveExpo = ctrlValue.get<int32_t>();\n>  \n> -\tctrlValue = sensorCtrls.get(V4L2_CID_ANALOGUE_GAIN);\n> +\tctrlValue = sensorControls.get(V4L2_CID_ANALOGUE_GAIN);\n>  \tif (!ctrlValue.isNone())\n>  \t\teffectiveGain = ctrlValue.get<int32_t>();\n>  \n> @@ -473,6 +432,35 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>  \tmetadataReady.emit(frame, ctrls);\n>  }\n>  \n> +void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)\n> +{\n> +\t/* Run algorithms into/using this context structure */\n> +\tresultsHistory_.extendOne();\n> +\taiq::AiqResults& latestResults = resultsHistory_.latest();\n> +\n> +\t/* Todo: Refactor AiqInputParameters interface to set following parameters. */\n> +\taiqInputParams_.afParams.lens_position = lensPosition_;\n> +\taiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;\n> +\n> +\taiq_.run2a(frame, aiqInputParams_, latestResults);\n> +\n> +\texposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;\n> +\tgain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;\n> +\n> +\t/*\n> +\t * Af algorithm compares the timestamp of start of the lens movement and\n> +\t * that of the statistics generated to estimate whether next lens\n> +\t * position should be produced.\n> +\t * \\todo use the lens movement start time reported by the pipeline handler.\n> +\t */\n> +\tif (lensPosition_ != latestResults.af()->next_lens_position) {\n> +\t\tutils::time_point time = utils::clock::now();\n> +\t\tuint64_t usecs = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();\n> +\t\tlensMovementStartTime_ = usecs;\n> +\t}\n> +\tlensPosition_ = latestResults.af()->next_lens_position;\n> +}\n> +\n>  void IPAIPU3::setControls(unsigned int frame)\n>  {\n>  \tControlList sensorCtrls(ctrls_);","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 8E6AFC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Apr 2022 22:59:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 56DF5633A5;\n\tWed,  6 Apr 2022 00:59:13 +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 250CC633A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Apr 2022 00:59:12 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CE804482;\n\tWed,  6 Apr 2022 00:59:11 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1649199553;\n\tbh=6gNnrO3qVkCAtaQbj+JNGqeLoKTquxK5TqVtDFn9ogo=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=ilqe1bHYMQIHc5rMgS7R3Tgvi3htTpgOB89s71uWGLzhb1IoY5Xk7DffKUo6NmL3r\n\t2zINyg43WYVbuyt4xxYmPqURdgj5Xym0dzlQzwkzxjWlOMX2mHrHqh+YkMybZrIQoK\n\tOmomA6L8GHCwo6NKsDg90ocq39OjsyxrDaF8gBm0R6wkKPMwTY/V6GoCPITz+DUg4S\n\tNrCCdSNBh052OoAHCWz+9KSjQj1GxHeg0AbJ0qVTQfm7bZanda3yaJAbAViqwb3mnI\n\tyZdEfOkDy85swhA3T5JiqgZRMIhMMbyRkuI2+kesSV+VwG6iDhRPxONFDswhCrb+ql\n\tOr51ZRB19AdOQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1649199551;\n\tbh=6gNnrO3qVkCAtaQbj+JNGqeLoKTquxK5TqVtDFn9ogo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=C2SZm9dTwjN9j0uFU86zuqmbhJ5MOpQ/prA3sDHS1qL/+eELJqVmDqCG7E1pzkQ7o\n\tZCePKtIpUCcmzWrkp7XR2nXumezfT0I1dNFE5ERA5DAQM74hHJGMM+kMuFqnWQ5x48\n\tMI2L9INDDnGHdWZKdtcvR2AMrZVCi7/Z341m7Zss="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"C2SZm9dT\"; dkim-atps=neutral","Date":"Wed, 6 Apr 2022 01:59:08 +0300","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YkzJvOualz38BBXf@pendragon.ideasonboard.com>","References":"<20220331163058.171418-1-umang.jain@ideasonboard.com>\n\t<20220331163058.171418-7-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220331163058.171418-7-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [IPAIPU3 PATCH v4 6/6] ipa: ipu3: Inlink\n\tparseStatistics() into processStatsBuffer()","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]