From patchwork Fri Oct 24 08:50:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24789 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 2C04BC3259 for ; Fri, 24 Oct 2025 08:52:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC6BA608F1; Fri, 24 Oct 2025 10:52:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="j6NYDYtJ"; 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 9971B608C7 for ; Fri, 24 Oct 2025 10:52:46 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7edc:62f4:c118:1549]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 15D7E484E; Fri, 24 Oct 2025 10:51:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761295861; bh=dxCtoWpqKdzg6ayd/boXKOq/crNZYfHq5PZj88Ea2eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j6NYDYtJGMNgNCoyO+RYaQ/vcamY/7Ism/UoOyhaA6hI1q11+8xkLGBIHmt1FQ9L3 htdDbvs2l+dCqW2Zn2ChxI6UPTfNCkVGITq+KB8NKvg9A+VkXuac7CP+K7Ltj+htQJ CWSdlhnhq+rvHtDIAbmKPSTAAWaWmpyXj1cfTu1w= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 23/35] ipa: rkisp1: Lazy initialise frame context Date: Fri, 24 Oct 2025 10:50:47 +0200 Message-ID: <20251024085130.995967-24-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" For per frame control we want to tick the IPA by the sensor frame sequence instead of the request frame sequence. This has the side effect that the IPA must be able to cope with situations where a frame context is required for a frame that was not queued before (computeParams is called without a corresponding request) or processStats is called for an unexpected sequence number (because a scratch buffer was used on kernel side) Prepare for that by allowing the frame context to be initialized on demand. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/awb.cpp | 2 ++ src/ipa/rkisp1/ipa_context.h | 2 ++ src/ipa/rkisp1/rkisp1.cpp | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 399fb51be414..27109478c340 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -172,6 +172,8 @@ void Awb::queueRequest(IPAContext &context, awbAlgo_->handleControls(controls); frameContext.awb.autoEnabled = awb.autoEnabled; + frameContext.awb.gains = awb.automatic.gains; + frameContext.awb.temperatureK = awb.automatic.temperatureK; if (awb.autoEnabled) return; diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index f85a130d9c23..185951fb8286 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -214,6 +214,8 @@ struct IPAFrameContext : public FrameContext { double strength; double gain; } wdr; + + bool initialised; }; struct IPAContext { diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 01b30c947a0a..23d80bc43c5d 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -343,6 +343,10 @@ void IPARkISP1::initializeFrameContext(const uint32_t frame, IPAFrameContext &frameContext, const ControlList &controls) { + if (frameContext.initialised) + return; + + frameContext.initialised = true; for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get()); if (algo->disabled_) @@ -354,6 +358,7 @@ void IPARkISP1::initializeFrameContext(const uint32_t frame, void IPARkISP1::computeParams(const uint32_t frame, const uint32_t bufferId) { IPAFrameContext &frameContext = context_.frameContexts.get(frame); + initializeFrameContext(frame, frameContext, {}); /* * \todo: This needs discussion. In raw mode, computeParams is @@ -383,6 +388,7 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId, const ControlList &sensorControls) { IPAFrameContext &frameContext = context_.frameContexts.get(frame); + initializeFrameContext(frame, frameContext, {}); /* * In raw capture mode, the ISP is bypassed and no statistics buffer is