From patchwork Mon Sep 14 14:02:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 28282 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 E7E01C3368 for ; Mon, 14 Sep 2026 14:05:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43F5368716; Mon, 14 Sep 2026 16:05:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tHUIGJCd"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1EB9068716 for ; Mon, 14 Sep 2026 16:05:07 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:a279:75fa:1f6c:7f40]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2BE22512; Mon, 14 Sep 2026 16:03:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1789394607; bh=TFxhtbHvbIZ9IQ0dgoTOz2berkdVByWH0UVL3YfNy7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tHUIGJCd0uRroJVkliauHJXS1RG0zKEmhBOGMnEURVmbP+Hm7CSruZkKf+UTV5Zzb ZxZYmx/WJwYBE/m3j+5D5NLIonVoOO6g8p3vJLZHU1bX3V8HNzsPg/4y2u5+xveVS/ nV/IHOaj4zKF2PrSWdx2Zrab8Hgb3I74QM2l080I= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 38/41] ipa: rkisp1: Gracefully handle FCQueue overruns Date: Mon, 14 Sep 2026 16:02:51 +0200 Message-ID: <20260914140309.3354666-39-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260914140309.3354666-1-stefan.klug@ideasonboard.com> References: <20260914140309.3354666-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" Gracefully handle all cases where the FCQueue could overflow. The most interesting case is computeParams(), because in that situation we don't know what we might have missed and therefore need to ensure that the ISP parameters get fully reinitialised on the next successful call to computeParams(). In the other cases we just log an error. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/rkisp1.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 8627b4044d30..ca3b0d31d9f6 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -85,6 +85,7 @@ private: /* Local parameter storage */ struct IPAContext context_; + bool initializeParams_; }; namespace { @@ -218,6 +219,7 @@ void IPARkISP1::start(const ControlList &controls, const uint32_t paramBufferId, { IPAFrameContext *frameContext = context_.frameContexts.getOrInitContext(0, controls); ASSERT(frameContext); + initializeParams_ = true; if (paramBufferId != 0) result->paramBufferBytesUsed = computeParamsInternal(*frameContext, @@ -332,7 +334,9 @@ uint32_t IPARkISP1::computeParamsInternal(IPAFrameContext &frameContext, const u unsigned int frame = frameContext.frame(); for (const auto &algo : algorithms()) algo->prepare(context_, frame, frameContext, - ¶ms, frame == 0); + ¶ms, initializeParams_); + + initializeParams_ = false; return params.bytesused(); } @@ -340,7 +344,15 @@ uint32_t IPARkISP1::computeParamsInternal(IPAFrameContext &frameContext, const u void IPARkISP1::computeParams(const uint32_t frame, const uint32_t bufferId) { IPAFrameContext *frameContext = context_.frameContexts.getOrInitContext(frame); - ASSERT(frameContext); + + if (!frameContext) { + LOG(IPARkISP1, Error) << "Failed to compute params for frame: " + << frame; + initializeParams_ = true; + if (bufferId != 0) + paramsComputed.emit(frame, bufferId, 0); + return; + } if (bufferId != 0) { uint32_t size = computeParamsInternal(*frameContext, bufferId); @@ -355,7 +367,14 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId, const ControlList &sensorControls) { IPAFrameContext *frameContext = context_.frameContexts.getOrInitContext(frame); - ASSERT(frameContext); + ControlList metadata(controls::controls); + + if (!frameContext) { + LOG(IPARkISP1, Error) << "Failed to process stats for frame: " + << frame; + metadataReady.emit(frame, bufferId, metadata); + return; + } /* * In raw capture mode, the ISP is bypassed and no statistics buffer is @@ -369,8 +388,6 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId, std::tie(frameContext->sensor.exposure, frameContext->sensor.gain) = agc::extractControls(sensorControls, context_.camHelper.get()); - ControlList metadata(controls::controls); - for (const auto &a : algorithms()) { Algorithm *algo = static_cast(a.get()); if (algo->disabled_)