From patchwork Wed Oct 20 15:46:04 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: 14217 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 3D81DC324F for ; Wed, 20 Oct 2021 15:46:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2B32368F72; Wed, 20 Oct 2021 17:46:24 +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="mU6nvnPj"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3168068F63 for ; Wed, 20 Oct 2021 17:46:15 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:ce4b:1c5f:7302:b899]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DA7982A5; Wed, 20 Oct 2021 17:46:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634744774; bh=WQdHNjuZ38BqrUJ1EzXIwk0iS6RCaASC1C/w4W+XxC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mU6nvnPj205UVW6tKCrwKCoqPQc7B9/TysVIaFy972X1cqt3ELmNk+36D0FTWQZbT 5k1W912ku8q5FGobn72mqC9HnTYkWqd4Z8VFyRyTjx1YNRnJhl1sV8/FJgoscznFoi oeSRe7tIFNVWo0G1gLftC1a9E5lYsSYagumSF3nI= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Oct 2021 17:46:04 +0200 Message-Id: <20211020154607.180161-11-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211020154607.180161-1-jeanmichel.hautbois@ideasonboard.com> References: <20211020154607.180161-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/13] 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 | 13 +++++++++++-- src/ipa/ipu3/algorithms/agc.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index eec77378..19f3a420 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) { } @@ -58,9 +59,14 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo) context.configuration.agc.minAnalogueGain; context.frameContext.agc.exposure = minExposureLines_; + /* \todo replace the exposure in lines storage with time based ones */ minExposureLines_ = context.configuration.agc.minShutterSpeed / lineDuration_; maxExposureLines_ = context.configuration.agc.maxShutterSpeed / lineDuration_; + prevExposureValue_ = context.frameContext.agc.gain + * context.frameContext.agc.exposure + * lineDuration_; + return 0; } @@ -146,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_; @@ -175,6 +181,9 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain) exposure = shutterTime / lineDuration_; analogueGain = stepGain; + + /* Update the exposure value for the next process call */ + 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_; };