{"id":27383,"url":"https://patchwork.libcamera.org/api/patches/27383/?format=json","web_url":"https://patchwork.libcamera.org/patch/27383/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20260720095951.49979-6-mzamazal@redhat.com>","date":"2026-07-20T09:59:49","name":"[RFC,v9,5/6] libcamera: software_isp: Pass LSC availability to debayering","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e69a9690dbe2167cae56858518b2cfd867210921","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/27383/mbox/","series":[{"id":6062,"url":"https://patchwork.libcamera.org/api/series/6062/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6062","date":"2026-07-20T09:59:44","name":"LSC for SoftISP simple pipeline","version":9,"mbox":"https://patchwork.libcamera.org/series/6062/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27383/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27383/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 CEAFBBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jul 2026 10:00:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8554C66137;\n\tMon, 20 Jul 2026 12:00:23 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6845D66137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jul 2026 12:00:21 +0200 (CEST)","from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-625-unynn0k_OkGzi4vJxUgR1g-1;\n\tMon, 20 Jul 2026 06:00:16 -0400","from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id D81DB180257F; Mon, 20 Jul 2026 10:00:15 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.33.73])\n\tby mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id C35CE300418F; Mon, 20 Jul 2026 10:00:13 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"MW7DpFXl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1784541620;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=xR5kg88TjhRLRgbQ9f5uqCGtprcEcpc/yIwNofP6/eU=;\n\tb=MW7DpFXleGG0W5HpX62Su1Fq+2qowuJovaRYSt/xHroqxD5oreiNnhJ1DBRCk8275J9TX3\n\tCFd1hV3lw63H6NxF6GNwUFQNDuRRADVf2ukUCvMHHngIimlFws4LzU57aotrVzqsdB9Z91\n\tdLxf/B947t7Cwax3I6xhae176BgsoZk=","X-MC-Unique":"unynn0k_OkGzi4vJxUgR1g-1","X-Mimecast-MFC-AGG-ID":"unynn0k_OkGzi4vJxUgR1g_1784541616","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>, Bryan O'Donoghue <bod.linux@nxsw.ie>,\n\tHans de Goede <johannes.goede@oss.qualcomm.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"[RFC PATCH v9 5/6] libcamera: software_isp: Pass LSC availability to\n\tdebayering","Date":"Mon, 20 Jul 2026 11:59:49 +0200","Message-ID":"<20260720095951.49979-6-mzamazal@redhat.com>","In-Reply-To":"<20260720095951.49979-1-mzamazal@redhat.com>","References":"<20260720095951.49979-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.4","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"vyZEoILhfgduFIvy0BK8Y4yGzVjJVEhp6g06vIHVACc_1784541616","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","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":"The lens shading algorithm may or may not be enabled in the tuning file.\nDebayering configuration needs this information to arrange things\naccordingly, e.g. to set up shader parameters.\n\nLet's add a corresponding flag that is set in the LSC algorithm (if\npresent) and passed to Debayer::configure.  This is similar to what we\nalready do with CCM availability.\n\nThe flag is ignored by CPU ISP, where LSC is not going to be implemented\nfor now.\n\nReviewed-by: Bryan O'Donoghue <bod.linux@nxsw.ie>\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n .../internal/software_isp/software_isp.h         |  1 +\n include/libcamera/ipa/soft.mojom                 |  4 +++-\n src/ipa/simple/algorithms/lsc.cpp                | 16 +++++++++++-----\n src/ipa/simple/ipa_context.h                     |  1 +\n src/ipa/simple/soft_simple.cpp                   |  7 +++++--\n src/libcamera/software_isp/debayer.cpp           |  1 +\n src/libcamera/software_isp/debayer.h             |  3 ++-\n src/libcamera/software_isp/debayer_cpu.cpp       |  3 ++-\n src/libcamera/software_isp/debayer_cpu.h         |  3 ++-\n src/libcamera/software_isp/debayer_egl.cpp       |  5 ++++-\n src/libcamera/software_isp/debayer_egl.h         |  4 +++-\n src/libcamera/software_isp/software_isp.cpp      |  5 +++--\n 12 files changed, 38 insertions(+), 15 deletions(-)","diff":"diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h\nindex 4f72dce9b..f24c04890 100644\n--- a/include/libcamera/internal/software_isp/software_isp.h\n+++ b/include/libcamera/internal/software_isp/software_isp.h\n@@ -100,6 +100,7 @@ private:\n \tDebayerParams debayerParams_;\n \tDmaBufAllocator dmaHeap_;\n \tbool ccmEnabled_;\n+\tbool lscEnabled_;\n \n \tstd::unique_ptr<ipa::soft::IPAProxySoft> ipa_;\n \tstd::deque<FrameBuffer *> queuedInputBuffers_;\ndiff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom\nindex 77328c5fd..aaefd50c4 100644\n--- a/include/libcamera/ipa/soft.mojom\n+++ b/include/libcamera/ipa/soft.mojom\n@@ -18,7 +18,9 @@ interface IPASoftInterface {\n \t     libcamera.SharedFD fdParams,\n \t     libcamera.IPACameraSensorInfo sensorInfo,\n \t     libcamera.ControlInfoMap sensorControls)\n-\t\t=> (int32 ret, libcamera.ControlInfoMap ipaControls, bool ccmEnabled);\n+\t\t=> (int32 ret,\n+\t\t    libcamera.ControlInfoMap ipaControls,\n+\t\t    bool ccmEnabled, bool lscEnabled);\n \tstart() => (int32 ret);\n \tstop();\n \tconfigure(IPAConfigInfo configInfo)\ndiff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp\nindex f38eee4db..c531937c7 100644\n--- a/src/ipa/simple/algorithms/lsc.cpp\n+++ b/src/ipa/simple/algorithms/lsc.cpp\n@@ -20,11 +20,17 @@ int Lsc::init(IPAContext &context, const ValueNode &tuningData)\n \tfor (unsigned int i = 0; i < kGridSize; i++)\n \t\tgridPos_.push_back(static_cast<double>(i) / (kGridSize - 1));\n \n-\treturn lscAlgo_.init(tuningData, context.ctrlMap,\n-\t\t\t     { .keys = { \"r\", \"g\", \"b\" },\n-\t\t\t       .numHCells = kGridSize,\n-\t\t\t       .numVCells = kGridSize,\n-\t\t\t       .sensorSize = context.sensorInfo.activeAreaSize });\n+\tint ret = lscAlgo_.init(tuningData, context.ctrlMap,\n+\t\t\t\t{ .keys = { \"r\", \"g\", \"b\" },\n+\t\t\t\t  .numHCells = kGridSize,\n+\t\t\t\t  .numVCells = kGridSize,\n+\t\t\t\t  .sensorSize = context.sensorInfo.activeAreaSize });\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tcontext.lscEnabled = true;\n+\n+\treturn 0;\n }\n \n int Lsc::configure(IPAContext &context,\ndiff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\nindex 23c2cfd0a..0ac36a4a8 100644\n--- a/src/ipa/simple/ipa_context.h\n+++ b/src/ipa/simple/ipa_context.h\n@@ -93,6 +93,7 @@ struct IPAContext {\n \tFCQueue<IPAFrameContext> frameContexts;\n \tControlInfoMap::Map ctrlMap;\n \tbool ccmEnabled = false;\n+\tbool lscEnabled = false;\n \tipa::lsc::ActiveState lsc;\n };\n \ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex 629e1a32d..4c724183a 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -57,7 +57,8 @@ public:\n \t\t const IPACameraSensorInfo &sensorInfo,\n \t\t const ControlInfoMap &sensorControls,\n \t\t ControlInfoMap *ipaControls,\n-\t\t bool *ccmEnabled) override;\n+\t\t bool *ccmEnabled,\n+\t\t bool *lscEnabled) override;\n \tint configure(const IPAConfigInfo &configInfo) override;\n \n \tint start() override;\n@@ -97,7 +98,8 @@ int IPASoftSimple::init(const IPASettings &settings,\n \t\t\tconst IPACameraSensorInfo &sensorInfo,\n \t\t\tconst ControlInfoMap &sensorControls,\n \t\t\tControlInfoMap *ipaControls,\n-\t\t\tbool *ccmEnabled)\n+\t\t\tbool *ccmEnabled,\n+\t\t\tbool *lscEnabled)\n {\n \tcamHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n \tif (!camHelper_) {\n@@ -136,6 +138,7 @@ int IPASoftSimple::init(const IPASettings &settings,\n \t\treturn ret;\n \n \t*ccmEnabled = context_.ccmEnabled;\n+\t*lscEnabled = context_.lscEnabled;\n \n \tparams_ = nullptr;\n \tstats_ = nullptr;\ndiff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\nindex ca72207b1..5ae9f032f 100644\n--- a/src/libcamera/software_isp/debayer.cpp\n+++ b/src/libcamera/software_isp/debayer.cpp\n@@ -94,6 +94,7 @@ Debayer::~Debayer()\n  * \\param[in] inputCfg The input configuration\n  * \\param[in] outputCfgs The output configurations\n  * \\param[in] ccmEnabled Whether a color correction matrix is applied\n+ * \\param[in] lscEnabled Whether lens shading correction grid is provided\n  *\n  * \\return 0 on success, a negative errno on failure\n  */\ndiff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\nindex 28f1b857b..d6dc24d29 100644\n--- a/src/libcamera/software_isp/debayer.h\n+++ b/src/libcamera/software_isp/debayer.h\n@@ -40,7 +40,8 @@ public:\n \n \tvirtual int configure(const StreamConfiguration &inputCfg,\n \t\t\t      const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,\n-\t\t\t      bool ccmEnabled) = 0;\n+\t\t\t      bool ccmEnabled,\n+\t\t\t      bool lscEnabled) = 0;\n \n \tvirtual std::vector<PixelFormat> formats(PixelFormat inputFormat) = 0;\n \ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex ab22635fd..d3812f182 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -641,7 +641,8 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat,\n \n int DebayerCpu::configure(const StreamConfiguration &inputCfg,\n \t\t\t  const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,\n-\t\t\t  bool ccmEnabled)\n+\t\t\t  bool ccmEnabled,\n+\t\t\t  [[maybe_unused]] bool lscEnabled)\n {\n \tif (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0)\n \t\treturn -EINVAL;\ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex 5281c65cb..a3c24d06b 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -37,7 +37,8 @@ public:\n \n \tint configure(const StreamConfiguration &inputCfg,\n \t\t      const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,\n-\t\t      bool ccmEnabled) override;\n+\t\t      bool ccmEnabled,\n+\t\t      bool lscEnabled) override;\n \tSize patternSize(PixelFormat inputFormat) override;\n \tstd::vector<PixelFormat> formats(PixelFormat input) override;\n \tstd::tuple<unsigned int, unsigned int>\ndiff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex 7e08cae71..7cb0ee6ff 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -286,7 +286,8 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm\n \n int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n \t\t\t  const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,\n-\t\t\t  [[maybe_unused]] bool ccmEnabled)\n+\t\t\t  [[maybe_unused]] bool ccmEnabled,\n+\t\t\t  bool lscEnabled)\n {\n \tif (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0)\n \t\treturn -EINVAL;\n@@ -303,6 +304,8 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n \t\treturn -EINVAL;\n \t}\n \n+\tlscEnabled_ = lscEnabled;\n+\n \tinputConfig_.stride = inputCfg.stride;\n \tinputPixelFormat_ = inputCfg.pixelFormat;\n \twidth_ = inputCfg.size.width;\ndiff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\nindex d6223f3a9..26b009da4 100644\n--- a/src/libcamera/software_isp/debayer_egl.h\n+++ b/src/libcamera/software_isp/debayer_egl.h\n@@ -45,7 +45,8 @@ public:\n \n \tint configure(const StreamConfiguration &inputCfg,\n \t\t      const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,\n-\t\t      bool ccmEnabled) override;\n+\t\t      bool ccmEnabled,\n+\t\t      bool lscEnabled) override;\n \n \tSize patternSize(PixelFormat inputFormat) override;\n \n@@ -83,6 +84,7 @@ private:\n \tunsigned int inputBufferCount_;\n \tunsigned int outputBufferCount_;\n \n+\tbool lscEnabled_;\n \t/* Shader parameters */\n \tfloat firstRed_x_;\n \tfloat firstRed_y_;\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex c73a16ce0..a72d9c82c 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -163,7 +163,8 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n \t\t\t sensorInfo,\n \t\t\t sensor->controls(),\n \t\t\t ipaControls,\n-\t\t\t &ccmEnabled_);\n+\t\t\t &ccmEnabled_,\n+\t\t\t &lscEnabled_);\n \tif (ret) {\n \t\tLOG(SoftwareIsp, Error) << \"IPA init failed\";\n \t\tdebayer_.reset();\n@@ -292,7 +293,7 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg,\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_);\n+\tret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_, lscEnabled_);\n \tif (ret < 0)\n \t\treturn ret;\n \n","prefixes":["RFC","v9","5/6"]}