From patchwork Fri Feb 28 12:55:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22898 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 A1B0FC3259 for ; Fri, 28 Feb 2025 12:56:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 61DB2687BA; Fri, 28 Feb 2025 13:56:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Kd6saCJT"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EFF3B68779 for ; Fri, 28 Feb 2025 13:56:11 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:a7e:b81b:5754:579]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B90C8606; Fri, 28 Feb 2025 13:54:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1740747282; bh=jfWt3vcpi/oPWJ4CUwlEdWHx902yi+uElEhZdRa7Af8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kd6saCJTakos8y3yzUubNIWyGMEq3fzdeW34pgsR2Zi/FxYOvFCh/u18FolyjLvBp ZP3n8iF+2o/tRRRDLwzC8tjSaJHU1gE4/iwMnKTFsJm2tZN1PvEnNqukibbwNFVPAz 8BHdc2S2GH0sxsTRkuJgVKmqbxoos7RRotA6JKi4= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 2/3] ipa: libipa: agc_mean_luminance: Error out when effectiveExposureValue is zero Date: Fri, 28 Feb 2025 13:55:54 +0100 Message-ID: <20250228125600.3241397-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250228125600.3241397-1-stefan.klug@ideasonboard.com> References: <20250228125600.3241397-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 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" In a proper system it never happens that the effectiveExposureValue drops to zero. If that still happens due to a bug outside of agc_mean_luminance, the calculated gain goes towards infinity but the newExposureValue is still 0 because it is the result of multiplying the effectiveExposureTime with the gain, leading to wild oscillations. Catch that condition, print an error message and set the new effective exposure value to an arbitrary 10ms. Note that in any case the underlying problem must be fixed. The important change is the added error message to be able to detect such a situation. Signed-off-by: Stefan Klug Reviewed-by: Daniel Scally --- src/ipa/libipa/agc_mean_luminance.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index 02555a44d271..a7343c18f5aa 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -541,6 +541,13 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex, std::shared_ptr exposureModeHelper = exposureModeHelpers_.at(exposureModeIndex); + if (effectiveExposureValue == 0s) { + LOG(AgcMeanLuminance, Error) << "Effective exposure value is 0." + << " Resetting exposure time and" + << " gain to arbitrary defaults."; + return exposureModeHelper->splitExposure(10ms); + } + double gain = estimateInitialGain(); gain = constraintClampGain(constraintModeIndex, yHist, gain);