From patchwork Mon Dec 16 15:33:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22345 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 00ED1C32F6 for ; Mon, 16 Dec 2024 15:33:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 90E9267F6D; Mon, 16 Dec 2024 16:33:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eeQNuKwz"; 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 13B7F67F56 for ; Mon, 16 Dec 2024 16:33:49 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:bfdf:3a3c:e45:66e3]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E4F4675; Mon, 16 Dec 2024 16:33:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1734363192; bh=E1HLPsn5oMA/D2gUgRAKIoXrWI5inZA/mv0VgIjbfSA=; h=From:To:Cc:Subject:Date:From; b=eeQNuKwzhnS867eApmjaYgPib6XUmpw/tHsNbLdFPpACG04l+O3ec2NTAmhR1Hr7p 6xJsBfzM02owgv7qcBsMoanPDUTFvgrVY+9cxYySCNq1J/Sp5zFtxlCwuatc3xYHI5 GFKv8ZVCIb18HrhkLA0aGbqV+hdhRT4ft4KgMVQg= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [RFC PATCH] ipa: rkisp1: Initialize lsc tables on first frame Date: Mon, 16 Dec 2024 16:33:02 +0100 Message-ID: <20241216153344.201302-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 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" When sending the parameters for lens shading correction to the ISP on frame x (in the test mostly frame 4) stalls of the ISP were observed. From userland the symptom is that no buffers get returned anymore. Kernel wise the ISP constantly produces interrupts with RKISP1_CIF_ISP_V_START being set but no interrupts with RKISP1_CIF_ISP_FRAME. It turned out that this behavior wasn't observed when the lens shading correction parameters were written before receiving the first frame. Ensure that behavior in the lsc algorithm by unconditionally filling the params buffer on frame 0. Unfortunately there were also cases were no stalls were observed even though the lsc tables were not written on frame 0. So it is not clear if this fix fixes the actual root cause. Another reason for that change is that it is sensible to write the lsc data on frame 0, to minimize the flicker in the image when the first statistics come in (where they would have been written otherwise). Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/algorithms/lsc.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index e47aa2f0727e..15a43799ae27 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -410,12 +410,20 @@ void LensShadingCorrection::prepare(IPAContext &context, RkISP1Params *params) { uint32_t ct = context.activeState.awb.temperatureK; - if (std::abs(static_cast(ct) - static_cast(lastAppliedCt_)) < + /* + * The ISP in the imx8mp using linux 6.12 has a high probability for a + * stall when the lsc module isn't configured in the first frame. + * Therefore ensure that a lsc table is written unconditionally at the + * first frame. + */ + if (frame > 0 && + std::abs(static_cast(ct) - static_cast(lastAppliedCt_)) < kColourTemperatureChangeThreshhold) return; + unsigned int quantizedCt; const Components &set = sets_.getInterpolated(ct, &quantizedCt); - if (lastAppliedQuantizedCt_ == quantizedCt) + if (frame > 0 && lastAppliedQuantizedCt_ == quantizedCt) return; auto config = params->block();