From patchwork Sun Jun 16 16:39:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20339 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 E30FFC32D1 for ; Sun, 16 Jun 2024 16:40:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 479B6654A4; Sun, 16 Jun 2024 18:40:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nyBNZoxp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 485F6654A4 for ; Sun, 16 Jun 2024 18:39:46 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E444A581 for ; Sun, 16 Jun 2024 18:39:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555970; bh=T64M81Hstr4clue5nu8JTOwU06Oj25vE6cgxpk5BQws=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nyBNZoxp8XCrFqSu5p34M5cvWfszBlCWA13zQmXKXDWZKRSOcO5Su9Le2EVAjsAA5 +sUN6DTPKuX7fGxGamoPNy3bXcqP6an9pvKKae9T2hGw3kQ/9XundGHXKg8OXy6Cve 6vSaxU4nc73E7WWqx2mVh2Sf/yj0LCXKdGqmOzCM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 11/12] ipa: rkisp1: agc: Correctly clamp maximum shutter speed Date: Sun, 16 Jun 2024 19:39:09 +0300 Message-ID: <20240616163910.5506-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@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" The sensor's maximum shutter speed is clamped by the maximum frame duration specified in requests. If the requested maximum frame duration is lower than the sensor's minimum shutter speed, the Agc::process() function will pass a minimum value higher than the maximum to the setLimits() function, resulting in an assertion failure. Fix it by clamping the value to both the lower and the upper bounds. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/algorithms/agc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 5b917557b887..0018c43f18cf 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -420,8 +420,10 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, [](uint32_t x) { return x >> 4; }); expMeans_ = { params->ae.exp_mean, context.hw->numAeCells }; - utils::Duration maxShutterSpeed = std::min(context.configuration.sensor.maxShutterSpeed, - frameContext.agc.maxFrameDuration); + utils::Duration maxShutterSpeed = + std::clamp(frameContext.agc.maxFrameDuration, + context.configuration.sensor.minShutterSpeed, + context.configuration.sensor.maxShutterSpeed); setLimits(context.configuration.sensor.minShutterSpeed, maxShutterSpeed, context.configuration.sensor.minAnalogueGain,