From patchwork Fri Nov 14 14:17:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 25069 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 A2BC6C3336 for ; Fri, 14 Nov 2025 14:17:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 433F560AC8; Fri, 14 Nov 2025 15:17:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SdNmKW1p"; 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 6224560AB5 for ; Fri, 14 Nov 2025 15:17:24 +0100 (CET) Received: from [192.168.1.101] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 68DC8BD2; Fri, 14 Nov 2025 15:15:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1763129723; bh=sHkzxU7P8tUG9VmY0HfmH5BmzTEMZ9oHFezgSarUqJI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SdNmKW1pDylCoL0h6JuwhF3SXhf8tdAdm2LPuT3Z6DtxdofOYQAK9rC/B1G9KKC6T ER6pj13OjHZ+htZK06RP8+uSGJ/rVclsoNgDlVvSnLsvsPJ/omO9+zlkb6Vp9Cb9/U 0lvkSkfCcyC9XWLp48cWcu2ZLzryoIV/YVtRxadc= From: Jacopo Mondi Date: Fri, 14 Nov 2025 15:17:12 +0100 Subject: [PATCH v3 17/19] ipa: rkisp1: agc: Calculate frame duration using cam helper MIME-Version: 1.0 Message-Id: <20251114-exposure-limits-v3-17-b7c07feba026@ideasonboard.com> References: <20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com> In-Reply-To: <20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Robert Mader , libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2539; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=sHkzxU7P8tUG9VmY0HfmH5BmzTEMZ9oHFezgSarUqJI=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpFznsiUYfYot8Z/IbPRgQ66+o83qnmtLGgQMJT gjc+4413raJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaRc57AAKCRByNAaPFqFW PD6HD/wLbfr+0btKgzQTTQCR4LsIHKt+sX2fcxZCEFGbm7jSIWr1FESnkKazK6kU3IjZS3OqehI DEGC9YukE7Ilz2EcneT6nD5ZWyah6YxJgU3AK3Sm5J/UYHU1H7HxXEhXMbHQ5NMSBJDThOKg73j QXA/6M64p/inq0msJOU5L/c7tLhl8K6ozTHlHXN8m4ACA42bPJuhXhy/M7z+NmnG5Kl4FnrphEd bHPLISHpAnD+KtPz+wcjHizI3bKSDtfdMfSDBkHw8c/+ytzR+qPfstQG5S4OtfyT3VM8geueTnc W37tRtQ3EZzlRkN5j28mHeWtCM9ojS2xx97ojrcMfwoxIwvla/njL2zKifi6deVXjwcNkA2TmMC 2uQcta+egpm3AhclhsZ1cxii9etvmOn6XgMqDyHVY/23etENyZLeQnxbQAG0Nb6ALJvHxQ2Me1c aV9u8GJyml8mPfp69hY6iotSPwfn1PGjPMpnTds6U/zliBXgsZoHfcBBpgx3w/WFijTkNQbNtNR 9YkmhOGt3o7esTlREyPN/Y3AnSnjEacC5VQ5wej2TuFLZtpBsXnWsAyGu4YjjceJmU2SvrUyIyM xsuS01jBNIU/FAEsktxmOxqWYPQdnBMH0YzbDVE+ABaWDcaH+flap6EB7fNafsWil+Ex3CZu55+ tW08UisHZVE+gGw== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" The RkISP1 IPA is the only IPA that derives from AgcMeanLuminance that populates the FrameDuration control. The way frame duration is calculated is by using the shutter time as returned by the Agc helpers and use that value to populate the FrameDuration metadata and calculate the vblank. This is however not correct as the exposure time shall be shorter than the frame duration by a sensor-specific margin. Use the camera sensor helper to calculate the minimum frame duration required to achieve the newly calculated shutter time. Signed-off-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/agc.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index a2ecd5c46a1fbcb728e23ed83b37b89fcdb80d84..10498eb6357d8917e299ac24f6c8ba8c33af4eae 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -501,21 +501,26 @@ double Agc::estimateLuminance(double gain) const * \brief Process frame duration and compute vblank * \param[in] context The shared IPA context * \param[in] frameContext The current frame context - * \param[in] frameDuration The target frame duration + * \param[in] shutterTime The target shutter duration * - * Compute and populate vblank from the target frame duration. + * Compute and populate vblank from a frame duration that allows to achieve the + * desired \a shutterTime */ void Agc::processFrameDuration(IPAContext &context, IPAFrameContext &frameContext, - utils::Duration frameDuration) + utils::Duration shutterTime) { - IPACameraSensorInfo &sensorInfo = context.sensorInfo; utils::Duration lineDuration = context.configuration.sensor.lineDuration; + utils::Duration frameDuration = + std::max(context.camHelper->minFrameDuration(shutterTime, lineDuration), + context.activeState.agc.minFrameDuration); - frameContext.agc.vblank = (frameDuration / lineDuration) - sensorInfo.outputSize.height; + frameContext.agc.vblank = (frameDuration / lineDuration) + - context.sensorInfo.outputSize.height; /* Update frame duration accounting for line length quantization. */ - frameContext.agc.frameDuration = (sensorInfo.outputSize.height + frameContext.agc.vblank) * lineDuration; + frameContext.agc.frameDuration = (context.sensorInfo.outputSize.height + + frameContext.agc.vblank) * lineDuration; } /**