From patchwork Wed Oct 13 15:41:21 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: 14125 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 ADCBEC3243 for ; Wed, 13 Oct 2021 15:41:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 55A4168F66; Wed, 13 Oct 2021 17:41:43 +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="Wu5mkaFL"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 89FA660501 for ; Wed, 13 Oct 2021 17:41:32 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:3857:aa01:4281:bd9f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 11E2918FF; Wed, 13 Oct 2021 17:41:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634139692; bh=tT+3e4I6PPVlDiKUoAVYAZdJS5Kymi2iN6FL5iK6F4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wu5mkaFL9RswjApjSaHKzsoL3c3VSblt4YkSSvMalbyoNRbk4+Jq7UbmG7Yfhfbob x5I+J11HtkIqvmUYAhnfyFdJxj52O0lSSNtKQWgqOAismVg34GdsXExFP+Y4XMSou1 cI/1AYHGElZjZsiQameYA94DnfPqK6jHHfozQw7U= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Wed, 13 Oct 2021 17:41:21 +0200 Message-Id: <20211013154125.133419-10-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211013154125.133419-1-jeanmichel.hautbois@ideasonboard.com> References: <20211013154125.133419-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/13] ipa: ipu3: agc: Rename gains properly 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 have mixed terms between gain, analogue gain and the exposure value gain. Makes it clear when we are using the analogue gain from the sensor, and when we are using the calculated gain to be applied to the exposure value to reach the target. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/ipu3/algorithms/agc.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index 3ec1c60c..bd28998a 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -123,7 +123,7 @@ void Agc::filterExposure() LOG(IPU3Agc, Debug) << "After filtering, total_exposure " << filteredExposure_; } -void Agc::lockExposureGain(uint32_t &exposure, double &gain) +void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain) { /* Algorithm initialization should wait for first valid frames */ /* \todo - have a number of frames given by DelayedControls ? @@ -135,16 +135,17 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain) if (std::abs(iqMean_ - kEvGainTarget * knumHistogramBins) <= 1) { LOG(IPU3Agc, Debug) << "!!! Good exposure with iqMean = " << iqMean_; } else { - double newGain = kEvGainTarget * knumHistogramBins / iqMean_; + double evGain = kEvGainTarget * knumHistogramBins / iqMean_; /* extracted from Rpi::Agc::computeTargetExposure */ Duration currentShutter = exposure * lineDuration_; - currentExposureNoDg_ = currentShutter * gain; + currentExposureNoDg_ = currentShutter * analogueGain; LOG(IPU3Agc, Debug) << "Actual total exposure " << currentExposureNoDg_ << " Shutter speed " << currentShutter - << " Gain " << gain; + << " Gain " << analogueGain + << " Needed ev gain " << evGain; - currentExposure_ = currentExposureNoDg_ * newGain; + currentExposure_ = currentExposureNoDg_ * evGain; Duration maxTotalExposure = kMaxShutterSpeed * kMaxGain; currentExposure_ = std::min(currentExposure_, maxTotalExposure); LOG(IPU3Agc, Debug) << "Target total exposure " << currentExposure_ @@ -180,7 +181,7 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain) << stepGain; exposure = shutterTime / lineDuration_; - gain = stepGain; + analogueGain = stepGain; } lastFrame_ = frameCount_; } @@ -188,9 +189,9 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain) void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats) { uint32_t &exposure = context.frameContext.agc.exposure; - double &gain = context.frameContext.agc.gain; + double &analogueGain = context.frameContext.agc.gain; processBrightness(stats, context.configuration.grid.bdsGrid); - lockExposureGain(exposure, gain); + lockExposureGain(exposure, analogueGain); frameCount_++; }