From patchwork Thu Oct 21 16:43:58 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: 14233 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 E5BA5C324F for ; Thu, 21 Oct 2021 16:44:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A0DB368F7D; Thu, 21 Oct 2021 18:44:19 +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="GTg5FcUh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A5DB68F5D for ; Thu, 21 Oct 2021 18:44:07 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:f9d:5926:ad90:4996]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 54ED8276; Thu, 21 Oct 2021 18:44:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634834647; bh=svqh+A4Ef6cG7H2+0geRHj5YGbf2ySWXbeprnI7qqEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GTg5FcUh76vahX2Iegsh6wMeKKrerkecz9Q2yXFEbCupcU66v5UMi45uSqfDzu9DZ uySYpVS31vtEeAPZ4pPRlTh18bDv/iGfGvCMvdu3xcWrhuo5hEQVJV9HJrNot8s503 P5yPJLXLDCz3hHl2jynfISIY0O2mQgFOA0fZEq3c= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Thu, 21 Oct 2021 18:43:58 +0200 Message-Id: <20211021164401.110033-12-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211021164401.110033-1-jeanmichel.hautbois@ideasonboard.com> References: <20211021164401.110033-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 11/14] ipa: ipu3: agc: Introduce previous exposure value 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" We need to calculate the gain on the previous exposure value calculated. Now that we initialise the exposure and gain values in configure(), we know the initial exposure value, and we can set it before any loop is running. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/ipu3/algorithms/agc.cpp | 19 +++++++++++++++++-- src/ipa/ipu3/algorithms/agc.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index e7c59f3d..43ef89df 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -42,7 +42,8 @@ static constexpr double kEvGainTarget = 0.5; Agc::Agc() : frameCount_(0), lastFrame_(0), iqMean_(0.0), lineDuration_(0s), minExposureLines_(0), maxExposureLines_(0), filteredExposure_(0s), - filteredExposureNoDg_(0s), currentExposure_(0s), currentExposureNoDg_(0s) + filteredExposureNoDg_(0s), currentExposure_(0s), + currentExposureNoDg_(0s), prevExposureValue_(0s) { } @@ -62,6 +63,10 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo) context.configuration.agc.minAnalogueGain; context.frameContext.agc.exposure = minExposureLines_; + prevExposureValue_ = context.frameContext.agc.gain + * context.frameContext.agc.exposure + * lineDuration_; + return 0; } @@ -147,7 +152,7 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain) << " Gain " << analogueGain << " Needed ev gain " << evGain; - currentExposure_ = currentExposureNoDg_ * evGain; + currentExposure_ = prevExposureValue_ * evGain; utils::Duration minShutterSpeed = minExposureLines_ * lineDuration_; utils::Duration maxShutterSpeed = maxExposureLines_ * lineDuration_; @@ -176,6 +181,16 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain) exposure = shutterTime / lineDuration_; analogueGain = stepGain; + + /* + * Update the exposure value for the next process call. + * + * \todo Obtain the values of the exposure time and analog gain + * that were actually used by the sensor, either from embedded + * data when available, or from the delayed controls + * infrastructure in case a slow down caused a mismatch. + */ + prevExposureValue_ = shutterTime * analogueGain; } lastFrame_ = frameCount_; } diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h index cd26d08c..2ae88e9f 100644 --- a/src/ipa/ipu3/algorithms/agc.h +++ b/src/ipa/ipu3/algorithms/agc.h @@ -49,6 +49,7 @@ private: utils::Duration filteredExposureNoDg_; utils::Duration currentExposure_; utils::Duration currentExposureNoDg_; + utils::Duration prevExposureValue_; uint32_t stride_; };