From patchwork Fri Oct 24 08:50:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24777 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 5B8EAC3259 for ; Fri, 24 Oct 2025 08:52:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1869C608B5; Fri, 24 Oct 2025 10:52:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="g3NhYVtm"; 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 B367160871 for ; Fri, 24 Oct 2025 10:52:09 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7edc:62f4:c118:1549]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 1BF981E47; Fri, 24 Oct 2025 10:50:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761295824; bh=JM75Hf0fKghmW5/ZsfZ4EOJip8kutXtOZC4v2jUHinM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g3NhYVtm4bz3/PWCAkza/3Fj6T79G30WIToX7M4nczuhZ3mDkmANs+rRinZ37YsUP Pyo/GFgVOun27FXrtOs0AYFBTiz5vd6b2pgds7b+pH4eSmUUqjvItJI5uYB71hsMOg pi5JD92jH5ezE0VXEzr3bqbY+SuP6ZUc4CHE3iis= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 11/35] ipa: rkisp1: Move setSensorControls signal to computeParams Date: Fri, 24 Oct 2025 10:50:35 +0200 Message-ID: <20251024085130.995967-12-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251024085130.995967-1-stefan.klug@ideasonboard.com> References: <20251024085130.995967-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" The setSensorControls event is emitted in the processStats() function. On first sight this looks reasonable as in processStats() we got the latest statistics and can therefore calculate the most up to date sensor controls. In the light of per-frame-controls however it produces difficult to solve timing issues: - The frame context in processStats() is the frame context of the frame that produced the stats, not for the frame that should be prepared and sent to the sensor. - To synchronize digital gain applied in the ISP with the analog gain applied in the sensor the set of parameters prepared for sensor and ISP must also be synchronized, which is not the case. To fix that, move the calculation and setting of sensor controls into the computeParams(). This way the model is far more easy to understand. We loose a tiny option for optimizations in that (in theory) we could delay the calculation of ISP parameters by another frame (assuming the sensor has a typical 2-frame delay). But all discussions and tests showed that keeping all parameters in sync is more important than that possible optimization for one frame. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/rkisp1.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index d64c72ecaf4f..ab8583e389d3 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -349,6 +349,9 @@ void IPARkISP1::computeParams(const uint32_t frame, const uint32_t bufferId) for (auto const &algo : algorithms()) algo->prepare(context_, frame, frameContext, ¶ms); + ControlList ctrls = getSensorControls(frameContext); + setSensorControls.emit(frame, ctrls); + paramsComputed.emit(frame, params.size()); } @@ -380,13 +383,6 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId, algo->process(context_, frame, frameContext, stats, metadata); } - /* - * \todo: Here we should do a lookahead that takes the sensor delays - * into account. - */ - ControlList ctrls = getSensorControls(frameContext); - setSensorControls.emit(frame, ctrls); - context_.debugMetadata.moveEntries(metadata); metadataReady.emit(frame, metadata); }