From patchwork Sat Aug 31 21:02:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1907 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6A88760BB2 for ; Sat, 31 Aug 2019 23:03:02 +0200 (CEST) X-Halon-ID: b67a5b4d-cc32-11e9-903a-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [84.172.84.18]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id b67a5b4d-cc32-11e9-903a-005056917f90; Sat, 31 Aug 2019 23:02:59 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 31 Aug 2019 23:02:18 +0200 Message-Id: <20190831210220.29819-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20190831210220.29819-1-niklas.soderlund@ragnatech.se> References: <20190831210220.29819-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/6] libcamera: ipa: rkisp1: Fill in meta data about auto exposure X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 21:03:03 -0000 Fill in the meta data parsed from the statistics buffer and use the metaDataReady signal to notify the pipeline handler that the data is ready. The method to judge if auto exposure is converged or not is just as simple as the algorithm controlling the exposure time. If we are +/- 5% from our target value we are converged. Signed-off-by: Niklas Söderlund --- src/ipa/ipa_rkisp1.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/ipa/ipa_rkisp1.cpp b/src/ipa/ipa_rkisp1.cpp index 063b075d8358c30d..cc926867d6fde478 100644 --- a/src/ipa/ipa_rkisp1.cpp +++ b/src/ipa/ipa_rkisp1.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include @@ -112,8 +113,9 @@ void IPARkISP1::updateStatistics(const void *cookie, Buffer &statistics) const rkisp1_stat_buffer *stats = static_cast(statistics.mem()->planes()[0].mem()); const cifisp_stat *params = &stats->params; + IPAMetaData metaData = {}; - if ((stats->meas_type & CIFISP_STAT_AUTOEXP) && (statFrame_ % 2 == 0)) { + if (stats->meas_type & CIFISP_STAT_AUTOEXP) { const cifisp_ae_stat *ae = ¶ms->ae; const unsigned int target = 60; @@ -129,18 +131,28 @@ void IPARkISP1::updateStatistics(const void *cookie, Buffer &statistics) value /= num; double factor = (double)target / value; - double tmp; - tmp = factor * exposure_ * gain_ / minGain_; - exposure_ = utils::clamp((uint64_t)tmp, minExposure_, maxExposure_); + if (statFrame_ % 3 == 0) { + double tmp; - tmp = tmp / exposure_ * minGain_; - gain_ = utils::clamp((uint64_t)tmp, minGain_, maxGain_); + tmp = factor * exposure_ * gain_ / minGain_; + exposure_ = utils::clamp((uint64_t)tmp, minExposure_, maxExposure_); - setControls(); + tmp = tmp / exposure_ * minGain_; + gain_ = utils::clamp((uint64_t)tmp, minGain_, maxGain_); + + setControls(); + } + + metaData.aeState = fabs(factor - 1.0f) < 0.05f ? + AeState::Converged : AeState::Searching; + } else { + metaData.aeState = AeState::Inactive; } statFrame_++; + + metaDataReady.emit(cookie, metaData); } /*