{"id":26527,"url":"https://patchwork.libcamera.org/api/1.1/patches/26527/?format=json","web_url":"https://patchwork.libcamera.org/patch/26527/","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":"<20260420183949.110548-6-mzamazal@redhat.com>","date":"2026-04-20T18:39:43","name":"[RFC,v2,5/8] libcamera: shaders: Add LSC support","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"552665da86d48d2a89a0e58cd5b8fe1cd3ac9ad4","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/1.1/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26527/mbox/","series":[{"id":5883,"url":"https://patchwork.libcamera.org/api/1.1/series/5883/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5883","date":"2026-04-20T18:39:38","name":"LSC for SoftISP simple pipeline","version":2,"mbox":"https://patchwork.libcamera.org/series/5883/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26527/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26527/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 74E4FC32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Apr 2026 18:40:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 132FC62EEC;\n\tMon, 20 Apr 2026 20:40:19 +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 050B862EE9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Apr 2026 20:40:15 +0200 (CEST)","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-76-50JmUzGLNraqIG55M5F94g-1;\n\tMon, 20 Apr 2026 14:40:11 -0400","from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.93])\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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 75D5219560A3; Mon, 20 Apr 2026 18:40:10 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.48.16])\n\tby mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 645BC1800357; Mon, 20 Apr 2026 18:40:08 +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=\"FU4P/QHl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1776710414;\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=aMbR13c8I7W4CyhZ/3vdhASfNbiIUev0l3DpXlfWP64=;\n\tb=FU4P/QHlyj7Pf9CnUPVNHyoLwUHXQU5DZS8vg0BvItssW+0Jtp1gKcboLxSfQoZ1r0r6k5\n\tNOj6atkE+jg72emj3t2930g7LkU7GRQ2jgGz9KY47x46c1adEl8nUAVs7uVf37ZbS2/9kl\n\tDkA6yjfFDGAwE7fVWnPKNlLCx2o2mog=","X-MC-Unique":"50JmUzGLNraqIG55M5F94g-1","X-Mimecast-MFC-AGG-ID":"50JmUzGLNraqIG55M5F94g_1776710410","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Xander Pronk <xander.c.pronk@gmail.com>,\n\tHans de Goede <johannes.goede@oss.qualcomm.com>,\n\tRick ten Wolde <rick_libcamera@wolde.info>,\n\tMilan Zamazal <mzamazal@redhat.com>","Subject":"[RFC PATCH v2 5/8] libcamera: shaders: Add LSC support","Date":"Mon, 20 Apr 2026 20:39:43 +0200","Message-ID":"<20260420183949.110548-6-mzamazal@redhat.com>","In-Reply-To":"<20260420183949.110548-1-mzamazal@redhat.com>","References":"<20260420183949.110548-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.93","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"D8mSwy68doD1yvz1hWSqZCHy8BerTsKyVUWLtSxJPtE_1776710410","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 depends\non white balance, so there is a chicken-egg problem.  Currently, we\ndetermine white balance and temperature from the preceding frame.\n\nTODO: It's unknown why the LSC is computed in the shader the way it is.\n\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..efc2fec72 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(DO_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+\t#if defined(DO_LSC)\n+\trgb = rgb + rgb * 3.0 * texture2D(lsc_tex, textureOut).rgb;\n+\t#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..cc82e656c 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(DO_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(DO_LSC)\n+    rgb = rgb + rgb * 3.0 * texture2D(lsc_tex, center.xy).rgb;\n+    #endif\n+\n     /*\n      *   CCM is a 3x3 in the format\n      *\n","prefixes":["RFC","v2","5/8"]}