From patchwork Thu Aug 27 10:41:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 28118 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 18F26C3342 for ; Thu, 27 Aug 2026 10:41:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1176868480; Thu, 27 Aug 2026 12:41:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SsLnSUq7"; 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 9674068459 for ; Thu, 27 Aug 2026 12:41:12 +0200 (CEST) Received: from pb-laptop.local (185.221.143.32.nat.pool.zt.hu [185.221.143.32]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 14C1E5B3 for ; Thu, 27 Aug 2026 12:39:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1787827186; bh=kfPn6rjM6J/cpYrswCnkhl9vPdjCyhsVecfw7PZiYf8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SsLnSUq7rpSNspAAIXUFM4KWTpiAvmVLSFHZA4pLQDctzPQHWJg16cSk1l5fo4SYL ia5UynNms4aDTglM5hFD1uLyg5/Be783LE2bm/9p5hpc4usB1pCuX7QPTiNzKAkvvP 0dj2iE8Jc9KxLt7FNcvUHV4MLZFbHBG5pb/fQ1xU= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 7/8] ipa: libipa: agc: Rework frame duration limit calculation Date: Thu, 27 Aug 2026 12:41:07 +0200 Message-ID: <20260827104108.1432632-8-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260827104108.1432632-1-barnabas.pocze@ideasonboard.com> References: <20260827104108.1432632-1-barnabas.pocze@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 frame duration is calculated as frameHeight * lineDuration, but it was effectively repeating the linu duration calculation, but with microsecond precision. Instead, simply reuse the already calculated line duration. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/ipa/libipa/agc.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp index ce5b2ab6f6..6783055a5e 100644 --- a/src/ipa/libipa/agc.cpp +++ b/src/ipa/libipa/agc.cpp @@ -396,18 +396,14 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state, */ const ControlInfo &v4l2VBlank = config.sensorControls.find(V4L2_CID_VBLANK)->second; - std::array frameHeights{ - v4l2VBlank.min().get() + config.sensorInfo.outputSize.height, - v4l2VBlank.max().get() + config.sensorInfo.outputSize.height, - v4l2VBlank.def().get() + config.sensorInfo.outputSize.height, + const struct { + uint32_t min; + uint32_t max; + } frameHeights = { + .min = v4l2VBlank.min().get() + config.sensorInfo.outputSize.height, + .max = v4l2VBlank.max().get() + config.sensorInfo.outputSize.height, }; - std::array frameDurations; - for (unsigned int i = 0; i < frameHeights.size(); ++i) { - uint64_t frameSize = static_cast(lineLength) * frameHeights[i]; - frameDurations[i] = frameSize * 1000000U / config.sensorInfo.pixelRate; - } - /* * When the AGC computes the new exposure values for a frame, it needs * to know the limits for exposure time and analogue gain. As it depends @@ -420,8 +416,8 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state, session.minAnalogueGain = minGain; session.maxAnalogueGain = maxGain; session.defAnalogueGain = defGain; - session.minFrameDuration = std::chrono::microseconds(frameDurations[0]); - session.maxFrameDuration = std::chrono::microseconds(frameDurations[1]); + session.minFrameDuration = frameHeights.min * session.lineDuration; + session.maxFrameDuration = frameHeights.max * session.lineDuration; /* Configure the default exposure and gain. */ state = {}; @@ -460,8 +456,12 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state, static_cast(defExposure * lineDurationUs), }; config.ctrlMap[&controls::FrameDurationLimits] = ControlInfo{ - frameDurations[0], frameDurations[1], - Span{ { frameDurations[0], frameDurations[1] } }, + static_cast(session.minFrameDuration.get()), + static_cast(session.maxFrameDuration.get()), + Span{{ + static_cast(state.minFrameDuration.get()), + static_cast(state.maxFrameDuration.get()), + }}, }; const auto add = [&](const ControlId &cid, const auto &automatic, const auto &manual) {