{"id":26728,"url":"https://patchwork.libcamera.org/api/patches/26728/?format=json","web_url":"https://patchwork.libcamera.org/patch/26728/","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":"<20260512123619.120068-6-mzamazal@redhat.com>","date":"2026-05-12T12:36:09","name":"[RFC,v5,05/10] libcamera: shaders: Add LSC support","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0431305595414a5698c79e83947e38ad73bb4a07","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/26728/mbox/","series":[{"id":5936,"url":"https://patchwork.libcamera.org/api/series/5936/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5936","date":"2026-05-12T12:36:04","name":"LSC for SoftISP simple pipeline","version":5,"mbox":"https://patchwork.libcamera.org/series/5936/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26728/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26728/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 381AEBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 May 2026 12:36:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CCA5463033;\n\tTue, 12 May 2026 14:36:54 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED99A63024\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 May 2026 14:36:52 +0200 (CEST)","from mx-prod-mc-08.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-172-fZL0MPDVOYqT1exp0QgSzQ-1;\n\tTue, 12 May 2026 08:36:48 -0400","from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.17])\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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 9885D18002C9; Tue, 12 May 2026 12:36:46 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.50.44])\n\tby mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 00A841955D84; Tue, 12 May 2026 12:36:43 +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=\"e071FrAB\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1778589411;\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=ZejWO7eq6zPZKHw9LKkh1s6lR/zsy+h8NR3S8NCIeYg=;\n\tb=e071FrABe89jN+g88H3cg0Wz0uhim1GBnZUgjA9/3DENrSTtqeezZuvSx9cWPwJr3UBOUf\n\tDTVwhdYRbhPoR/T0YmXcKjbSZt8hE5MyBi/hYSUDTYNo93iHze/k1WlMqalaJdQhL7kTEZ\n\tWcLVKPfQRpMVP3ylrlpnT8UpAakgGlk=","X-MC-Unique":"fZL0MPDVOYqT1exp0QgSzQ-1","X-Mimecast-MFC-AGG-ID":"fZL0MPDVOYqT1exp0QgSzQ_1778589406","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Xander Pronk <xander.c.pronk@gmail.com>,\n\tBryan O'Donoghue <bod.linux@nxsw.ie>,\n\tHans de Goede <johannes.goede@oss.qualcomm.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tRick ten Wolde <rick_libcamera@wolde.info>,\n\tMilan Zamazal <mzamazal@redhat.com>","Subject":"[RFC PATCH v5 05/10] libcamera: shaders: Add LSC support","Date":"Tue, 12 May 2026 14:36:09 +0200","Message-ID":"<20260512123619.120068-6-mzamazal@redhat.com>","In-Reply-To":"<20260512123619.120068-1-mzamazal@redhat.com>","References":"<20260512123619.120068-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.17","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"MIlTQK2VPiw-BezY40tOJ8sHnqexAbW4_yFXqyP7vTI_1778589406","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":"From: Xander Pronk <xander.c.pronk@gmail.com>\n\nLens shading correction should be applied after black level\nsubtraction (in order to make the computations with meaningful values)\nand before white balance (especially before white balance stats are\ncomputed).\n\nNote that lens shading correction depends on temperature, which is\ncomputed from the preceding, rather than current, frame (this is due to\nhow white balance is currently computed).\n\nThe grid is specified in the YAML definition as follows:\n\n  - Lsc:\n      sets:\n        - ct: temperature-1\n          r: [ ... 16 x 16 float values ...]\n          g: [ ... 16 x 16 float values ...]\n          b: [ ... 16 x 16 float values ...]\n        - ct: temperature-2\n          r: [ ... 16 x 16 float values ...]\n          g: [ ... 16 x 16 float values ...]\n          b: [ ... 16 x 16 float values ...]\n        - ...\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nCo-developed-by: Rick ten Wolde <rick_libcamera@wolde.info>\nSigned-off-by: Rick ten Wolde <rick_libcamera@wolde.info>\nSigned-off-by: Xander Pronk <xander.c.pronk@gmail.com>\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/libcamera/shaders/bayer_1x_packed.frag | 8 ++++++++\n src/libcamera/shaders/bayer_unpacked.frag  | 8 ++++++++\n 2 files changed, 16 insertions(+)","diff":"diff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag\nindex 23747f78a..228c72309 100644\n--- a/src/libcamera/shaders/bayer_1x_packed.frag\n+++ b/src/libcamera/shaders/bayer_1x_packed.frag\n@@ -70,6 +70,10 @@ uniform vec3 blacklevel;\n uniform float gamma;\n uniform float contrastExp;\n \n+#if defined(APPLY_LSC)\n+uniform sampler2D lsc_tex;\n+#endif\n+\n float apply_contrast(float value)\n {\n \t// Apply simple S-curve\n@@ -227,6 +231,10 @@ void main(void)\n \n \trgb = rgb - blacklevel;\n \n+#if defined(APPLY_LSC)\n+\trgb = rgb * texture2D(lsc_tex, textureOut).rgb;\n+#endif\n+\n \t/*\n \t *   CCM is a 3x3 in the format\n \t *\ndiff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag\nindex 1b85196ae..af87bcc0f 100644\n--- a/src/libcamera/shaders/bayer_unpacked.frag\n+++ b/src/libcamera/shaders/bayer_unpacked.frag\n@@ -29,6 +29,10 @@ uniform vec3            blacklevel;\n uniform float           gamma;\n uniform float           contrastExp;\n \n+#if defined(APPLY_LSC)\n+uniform sampler2D lsc_tex;\n+#endif\n+\n float apply_contrast(float value)\n {\n     // Apply simple S-curve\n@@ -130,6 +134,10 @@ void main(void) {\n \n     rgb = rgb - blacklevel;\n \n+#if defined(APPLY_LSC)\n+    rgb = rgb * texture2D(lsc_tex, center.xy).rgb;\n+#endif\n+\n     /*\n      *   CCM is a 3x3 in the format\n      *\n","prefixes":["RFC","v5","05/10"]}