From patchwork Thu Mar 31 16:30:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15599 X-Patchwork-Delegate: umang.jain@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 88D96C3256 for ; Thu, 31 Mar 2022 16:31:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C49C6563F; Thu, 31 Mar 2022 18:31:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648744298; bh=3ccGD3IjTda+w4Gj9Sb9LbL0gb50X1i1BGLRk7TpEqg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FZwIlDVIxTGnukZPeYdyvfDJXDX9y2Fzmd5utw9GNlvzuBZMwdKDyN3Wfi9FbyzhQ nTa+W2fm0O/gI8fhgFd6DB1+GBiZWPQE9vqPvpJ0I/LF0PWwNZ+2ryfL+xZ3Q2RU2d 2JvmGYaL80tlQe1e0gt/+wiqthUOoe69fw4mc19oBxIQ/r2QjKv6RoSX5X9Q9JFpQG Pd3Rekk5WkBYvW98JPqq6UTHwCjbboRh1r+fzpJahRWFKFDm1zLZx59sZjRcWmTXF0 KR6MgfjeqyY+F4Q40RKc2+tWNmKwt5YNf5K6FN3tinxcAYR2p4H0e6rMiO/XjgdFhc 6Y8B7p7MPgN3g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7927C65637 for ; Thu, 31 Mar 2022 18:31:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="knkiCqQd"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.74.73.150]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8AD118E6; Thu, 31 Mar 2022 18:31:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648744296; bh=3ccGD3IjTda+w4Gj9Sb9LbL0gb50X1i1BGLRk7TpEqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=knkiCqQdSEUWwDMty3CyNX+eRtK9f8Js0wgkZe3+PDTg+0Dfl6fkDrYh7/teJImiR ZJ+f7Mnre44BQGFQSYe9K6B1u26T0gsH6YxI/NzY7PuO3UcF2O+YWpnmuMVpK5fEBN f5UC+l9R+W8cEfWdN5i8xCblYktafrY7/KACHN1g= To: libcamera-devel@lists.libcamera.org Date: Thu, 31 Mar 2022 22:00:58 +0530 Message-Id: <20220331163058.171418-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220331163058.171418-1-umang.jain@ideasonboard.com> References: <20220331163058.171418-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [IPAIPU3 PATCH v4 6/6] ipa: ipu3: Inlink parseStatistics() into processStatsBuffer() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Since we have moved away from switch/case on the operation ID, there's little reason to split the operation in two functions. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart --- ipu3.cpp | 74 ++++++++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index a435005..9063d7e 100644 --- a/ipu3.cpp +++ b/ipu3.cpp @@ -61,10 +61,6 @@ private: const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls); void runAiq(unsigned int frame); - void parseStatistics(unsigned int frame, - int64_t frameTimestamp, - const ipu3_uapi_stats_3a *stats, - const ControlList& sensorCtrls); void setControls(unsigned int frame); @@ -380,43 +376,6 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, const int64_t frameTimest const ipu3_uapi_stats_3a *stats = reinterpret_cast(mem.data()); - parseStatistics(frame, frameTimestamp, stats, sensorControls); -} - -void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame) -{ - /* Run algorithms into/using this context structure */ - resultsHistory_.extendOne(); - aiq::AiqResults& latestResults = resultsHistory_.latest(); - - /* Todo: Refactor AiqInputParameters interface to set following parameters. */ - aiqInputParams_.afParams.lens_position = lensPosition_; - aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_; - - aiq_.run2a(frame, aiqInputParams_, latestResults); - - exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time; - gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global; - - /* - * Af algorithm compares the timestamp of start of the lens movement and - * that of the statistics generated to estimate whether next lens - * position should be produced. - * \todo use the lens movement start time reported by the pipeline handler. - */ - if (lensPosition_ != latestResults.af()->next_lens_position) { - utils::time_point time = utils::clock::now(); - uint64_t usecs = std::chrono::duration_cast(time.time_since_epoch()).count(); - lensMovementStartTime_ = usecs; - } - lensPosition_ = latestResults.af()->next_lens_position; -} - -void IPAIPU3::parseStatistics(unsigned int frame, - int64_t frameTimestamp, - const ipu3_uapi_stats_3a *stats, - const ControlList& sensorCtrls) -{ ControlList ctrls(controls::controls); /* \todo React to statistics and update internal state machine. */ @@ -439,11 +398,11 @@ void IPAIPU3::parseStatistics(unsigned int frame, int32_t effectiveGain = 0; ControlValue ctrlValue; - ctrlValue = sensorCtrls.get(V4L2_CID_EXPOSURE); + ctrlValue = sensorControls.get(V4L2_CID_EXPOSURE); if (!ctrlValue.isNone()) effectiveExpo = ctrlValue.get(); - ctrlValue = sensorCtrls.get(V4L2_CID_ANALOGUE_GAIN); + ctrlValue = sensorControls.get(V4L2_CID_ANALOGUE_GAIN); if (!ctrlValue.isNone()) effectiveGain = ctrlValue.get(); @@ -473,6 +432,35 @@ void IPAIPU3::parseStatistics(unsigned int frame, metadataReady.emit(frame, ctrls); } +void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame) +{ + /* Run algorithms into/using this context structure */ + resultsHistory_.extendOne(); + aiq::AiqResults& latestResults = resultsHistory_.latest(); + + /* Todo: Refactor AiqInputParameters interface to set following parameters. */ + aiqInputParams_.afParams.lens_position = lensPosition_; + aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_; + + aiq_.run2a(frame, aiqInputParams_, latestResults); + + exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time; + gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global; + + /* + * Af algorithm compares the timestamp of start of the lens movement and + * that of the statistics generated to estimate whether next lens + * position should be produced. + * \todo use the lens movement start time reported by the pipeline handler. + */ + if (lensPosition_ != latestResults.af()->next_lens_position) { + utils::time_point time = utils::clock::now(); + uint64_t usecs = std::chrono::duration_cast(time.time_since_epoch()).count(); + lensMovementStartTime_ = usecs; + } + lensPosition_ = latestResults.af()->next_lens_position; +} + void IPAIPU3::setControls(unsigned int frame) { ControlList sensorCtrls(ctrls_);