From patchwork Thu Jul 2 15:24:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 27158 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 12EF6C3302 for ; Thu, 2 Jul 2026 15:24:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1ECF165FBB; Thu, 2 Jul 2026 17:24:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mkNbOwdF"; 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 34AFD65FB6 for ; Thu, 2 Jul 2026 17:24:39 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:15a:f743:880f:9f16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7647B3A2; Thu, 2 Jul 2026 17:23:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1783005833; bh=jmZu/4wAGs8iSqb02ZacH8F6EtEiCasfAgf/6hWah2U=; h=From:To:Cc:Subject:Date:From; b=mkNbOwdFzZI2r25xzBORKMm8GTb1Jt376xZ9BFER6sNwScaMRd2LDgcQDLzHPLVgg g7nXymYCprGDcvgA2Wg3xXDs6q1Fder50Jzl7OsJ3oc2bwFhh5jOKzTif4+MlHX6l0 OYffLC3ecwIQYVTLtya0vDAHWSFBLmTu7aX3NGLM= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [RFC PATCH] ipa: rkisp1: lsc: Workaround ISP stalls when toggling LSC Date: Thu, 2 Jul 2026 17:24:27 +0200 Message-ID: <20260702152434.1123571-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.53.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" ISP stalls were observed by repeatedly toggling the LSC enable bit. The probability of a lockup is quite high and easily reproducible by manually toggling the LensShadingCorrectionEnable control in camshark. As no fix proper kernel side fix could be found, workaround the issue by keeping LSC enabled and writing 1.0 to the gain table. Signed-off-by: Stefan Klug --- Hi all, The intention of this patch is merely to document the issue. A proper fix on the kernel side would definitely be preferable. But although I spent some time debugging the kernel interrupt handling I wasn't able to come up with a fix. It looks like enabling the LSC module is somehow racy. One thing I was wondering but didn't spent the time to test: In the driver the order of events is: RKISP1_CIF_ISP_FRAME -> rkisp1_params_isr() -> ... -> rkisp1_ext_params_lsc() -> "write lsc tables" and then shortly after, the next frame starts with RKISP1_CIF_ISP_V_START. I didn't test if writing the lsc tables actually overlapped with the V_START signal. Should we possibly write the LSC tables after the V_START interrupt, as these are ping pong maps anyways? Best regards, Stefan --- src/ipa/rkisp1/algorithms/lsc.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index faf88effde01..251a2714b617 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -532,13 +532,28 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context, } auto config = params->block(); - config.setEnabled(frameContext.lsc.enabled); - - if (!frameContext.lsc.enabled) - return; + /* + * ISP lockups were observed when toggling the LSC enable bit + * repeatedly. There is no known kernel side fix. Workaround the issue + * by leaving lsc enabled all the time and setting the gain values to + * 1.0 in case lsc should be disabled. + */ + config.setEnabled(true); setParameters(*config); + if (!frameContext.lsc.enabled) { + for (int i = 0; i < RKISP1_CIF_ISP_LSC_SAMPLES_MAX; i++) { + for (int j = 0; j < RKISP1_CIF_ISP_LSC_SAMPLES_MAX; j++) { + config->r_data_tbl[i][j] = 1024; + config->gr_data_tbl[i][j] = 1024; + config->gb_data_tbl[i][j] = 1024; + config->b_data_tbl[i][j] = 1024; + } + } + return; + } + const Components &set = sets_.getInterpolated(quantizedCt); copyTable(*config, set);