From patchwork Mon Jun 28 20:22:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 12741 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 D1C54C321F for ; Mon, 28 Jun 2021 20:23:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5C64E684DA; Mon, 28 Jun 2021 22:23:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QowV7j1O"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA189684DB for ; Mon, 28 Jun 2021 22:23:00 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:c3ad:78d0:405e:fc33]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E51D26FE; Mon, 28 Jun 2021 22:23:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1624911780; bh=0H5RRW/aa76Aso5YRFDVtrh9+lxoQDWTFOIFvrwtN2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QowV7j1OHlNii6w/9SNk1P1shqNl36idreabYlTM/PIbs4NAc/Yey3Kvufx85tP3P SXyoYouFhREUqPrMRSTyQrevpSlPubgb98Ie6jT5CUSbPxP8tfnvd1XylgELjkvM3l ehUW6/mDpsaP3gL5VhNqsSLG07W8fdQgnonLGzKI= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Jun 2021 22:22:54 +0200 Message-Id: <20210628202255.138874-7-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628202255.138874-1-jeanmichel.hautbois@ideasonboard.com> References: <20210628202255.138874-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 6/7] ipa: ipu3: Call exposure and gain controls from AGC 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" IPAIPU3 does not need to directly know the exposure and gain limits. Move the control min and max values to IPU3Agc as for the moment it is the one which needs to use the values. Signed-off-by: Jean-Michel Hautbois --- src/ipa/ipu3/ipu3.cpp | 14 +++----------- src/ipa/ipu3/ipu3_agc.cpp | 28 +++++++++++++++++++++++----- src/ipa/ipu3/ipu3_agc.h | 11 +++++++++-- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 9a2def64..40b626ed 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -67,11 +67,7 @@ private: /* Camera sensor controls. */ uint32_t defVBlank_; uint32_t exposure_; - uint32_t minExposure_; - uint32_t maxExposure_; uint32_t gain_; - uint32_t minGain_; - uint32_t maxGain_; /* Interface to the AWB algorithm */ std::unique_ptr awbAlgo_; @@ -187,13 +183,9 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo) return -EINVAL; } - minExposure_ = std::max(itExp->second.min().get(), 1); - maxExposure_ = itExp->second.max().get(); - exposure_ = minExposure_; + exposure_ = itExp->second.def().get(); - minGain_ = std::max(itGain->second.min().get(), 1); - maxGain_ = itGain->second.max().get(); - gain_ = minGain_; + gain_ = itGain->second.def().get(); defVBlank_ = itVBlank->second.def().get(); @@ -205,7 +197,7 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo) awbAlgo_->initialise(params_, configInfo.bdsOutputSize, bdsGrid_); agcAlgo_ = std::make_unique(); - agcAlgo_->initialise(bdsGrid_, sensorInfo_); + agcAlgo_->initialise(bdsGrid_, configInfo); return 0; } diff --git a/src/ipa/ipu3/ipu3_agc.cpp b/src/ipa/ipu3/ipu3_agc.cpp index 6253ab94..042d67fa 100644 --- a/src/ipa/ipu3/ipu3_agc.cpp +++ b/src/ipa/ipu3/ipu3_agc.cpp @@ -10,10 +10,12 @@ #include #include #include +#include -#include +#include -#include +#include +#include #include "libipa/histogram.h" @@ -59,12 +61,28 @@ IPU3Agc::IPU3Agc() { } -void IPU3Agc::initialise(struct ipu3_uapi_grid_config &bdsGrid, const IPACameraSensorInfo &sensorInfo) +void IPU3Agc::initialise(struct ipu3_uapi_grid_config &bdsGrid, const IPAConfigInfo &configInfo) { aeGrid_ = bdsGrid; + ctrls_ = configInfo.entityControls.at(0); - lineDuration_ = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate; - maxExposureTime_ = kMaxExposure * lineDuration_; + const auto itExp = ctrls_.find(V4L2_CID_EXPOSURE); + if (itExp == ctrls_.end()) { + LOG(IPU3Agc, Debug) << "Can't find exposure control"; + return; + } + minExposure_ = itExp->second.min().get(); + maxExposure_ = itExp->second.max().get(); + lineDuration_ = configInfo.sensorInfo.lineLength * 1.0s / configInfo.sensorInfo.pixelRate; + maxExposureTime_ = maxExposure_ * lineDuration_; + + const auto itGain = ctrls_.find(V4L2_CID_ANALOGUE_GAIN); + if (itGain == ctrls_.end()) { + LOG(IPU3Agc, Debug) << "Can't find gain control"; + return; + } + minGain_ = std::max(itGain->second.min().get(), 1); + maxGain_ = itGain->second.max().get(); } void IPU3Agc::processBrightness(const ipu3_uapi_stats_3a *stats) diff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/ipu3_agc.h index 774c8385..ce43c534 100644 --- a/src/ipa/ipu3/ipu3_agc.h +++ b/src/ipa/ipu3/ipu3_agc.h @@ -15,7 +15,7 @@ #include #include - +#include #include #include "libipa/algorithm.h" @@ -35,8 +35,8 @@ public: IPU3Agc(); ~IPU3Agc() = default; - void initialise(struct ipu3_uapi_grid_config &bdsGrid, const IPACameraSensorInfo &sensorInfo); void process(const ipu3_uapi_stats_3a *stats, uint32_t &exposure, double &gain); + void initialise(struct ipu3_uapi_grid_config &bdsGrid, const IPAConfigInfo &configInfo); bool converged() { return converged_; } bool updateControls() { return updateControls_; } /* \todo Use a metadata exchange between IPAs */ @@ -48,6 +48,13 @@ private: void lockExposureGain(uint32_t &exposure, double &gain); struct ipu3_uapi_grid_config aeGrid_; + ControlInfoMap ctrls_; + + uint32_t minExposure_; + uint32_t maxExposure_; + + uint32_t minGain_; + uint32_t maxGain_; uint64_t frameCount_; uint64_t lastFrame_;