{"id":22345,"url":"https://patchwork.libcamera.org/api/1.1/patches/22345/?format=json","web_url":"https://patchwork.libcamera.org/patch/22345/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20241216153344.201302-1-stefan.klug@ideasonboard.com>","date":"2024-12-16T15:33:02","name":"[RFC] ipa: rkisp1: Initialize lsc tables on first frame","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"c476d03b629c68408ccd41582a047244224bc1f5","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22345/mbox/","series":[{"id":4895,"url":"https://patchwork.libcamera.org/api/1.1/series/4895/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4895","date":"2024-12-16T15:33:02","name":"[RFC] ipa: rkisp1: Initialize lsc tables on first frame","version":1,"mbox":"https://patchwork.libcamera.org/series/4895/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22345/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22345/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 00ED1C32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Dec 2024 15:33:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 90E9267F6D;\n\tMon, 16 Dec 2024 16:33:50 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13B7F67F56\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Dec 2024 16:33:49 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:bfdf:3a3c:e45:66e3])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E4F4675;\n\tMon, 16 Dec 2024 16:33:12 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eeQNuKwz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734363192;\n\tbh=E1HLPsn5oMA/D2gUgRAKIoXrWI5inZA/mv0VgIjbfSA=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=eeQNuKwzhnS867eApmjaYgPib6XUmpw/tHsNbLdFPpACG04l+O3ec2NTAmhR1Hr7p\n\t6xJsBfzM02owgv7qcBsMoanPDUTFvgrVY+9cxYySCNq1J/Sp5zFtxlCwuatc3xYHI5\n\tGFKv8ZVCIb18HrhkLA0aGbqV+hdhRT4ft4KgMVQg=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"When sending the parameters for lens shading correction to the ISP on\nframe x (in the test mostly frame 4) stalls of the ISP were observed.\nFrom userland the symptom is that no buffers get returned anymore.\nKernel wise the ISP constantly produces interrupts with\nRKISP1_CIF_ISP_V_START being set but no interrupts with\nRKISP1_CIF_ISP_FRAME. It turned out that this behavior wasn't observed\nwhen the lens shading correction parameters were written before\nreceiving the first frame. Ensure that behavior in the lsc algorithm by\nunconditionally filling the params buffer on frame 0.\n\nUnfortunately there were also cases were no stalls were observed even\nthough the lsc tables were not written on frame 0. So it is not clear\nif this fix fixes the actual root cause.\n\nAnother reason for that change is that it is sensible to write the lsc\ndata on frame 0, to minimize the flicker in the image when the first\nstatistics come in (where they would have been written otherwise).\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n\n src/ipa/rkisp1/algorithms/lsc.cpp | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\nindex e47aa2f0727e..15a43799ae27 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.cpp\n+++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n@@ -410,12 +410,20 @@ void LensShadingCorrection::prepare(IPAContext &context,\n \t\t\t\t    RkISP1Params *params)\n {\n \tuint32_t ct = context.activeState.awb.temperatureK;\n-\tif (std::abs(static_cast<int>(ct) - static_cast<int>(lastAppliedCt_)) <\n+\t/*\n+\t * The ISP in the imx8mp using linux 6.12 has a high probability for a\n+\t * stall when the lsc module isn't configured in the first frame.\n+\t * Therefore ensure that a lsc table is written unconditionally at the\n+\t * first frame.\n+\t*/\n+\tif (frame > 0 &&\n+\t    std::abs(static_cast<int>(ct) - static_cast<int>(lastAppliedCt_)) <\n \t    kColourTemperatureChangeThreshhold)\n \t\treturn;\n+\n \tunsigned int quantizedCt;\n \tconst Components &set = sets_.getInterpolated(ct, &quantizedCt);\n-\tif (lastAppliedQuantizedCt_ == quantizedCt)\n+\tif (frame > 0 && lastAppliedQuantizedCt_ == quantizedCt)\n \t\treturn;\n \n \tauto config = params->block<BlockType::Lsc>();\n","prefixes":["RFC"]}