From bc7ff6e2897f6b80368fb21bd08414125a946c8f Mon Sep 17 00:00:00 2001 From: Umang Jain Date: Thu, 31 Mar 2022 21:22:09 +0530 Subject: ipa: ipu3: Inline parseStatistics() into processStatsBuffer() 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 Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- ipu3.cpp | 74 +++++++++++++++++++++++++++------------------------------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index 0543a2e..7ecd377 100644 --- a/ipu3.cpp +++ b/ipu3.cpp @@ -60,10 +60,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); @@ -379,43 +375,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. */ @@ -438,11 +397,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(); @@ -472,6 +431,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_); -- cgit v1.2.1