Show a patch.

GET /api/patches/27372/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 27372,
    "url": "https://patchwork.libcamera.org/api/patches/27372/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/27372/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20260716222515.251464-5-mzamazal@redhat.com>",
    "date": "2026-07-16T22:25:11",
    "name": "[RFC,v8,4/6] libcamera: shaders: Add LSC support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c95ad522484f67c3d1de215636e79ac11de81dda",
    "submitter": {
        "id": 177,
        "url": "https://patchwork.libcamera.org/api/people/177/?format=api",
        "name": "Milan Zamazal",
        "email": "mzamazal@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/27372/mbox/",
    "series": [
        {
            "id": 6060,
            "url": "https://patchwork.libcamera.org/api/series/6060/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6060",
            "date": "2026-07-16T22:25:07",
            "name": "LSC for SoftISP simple pipeline",
            "version": 8,
            "mbox": "https://patchwork.libcamera.org/series/6060/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/27372/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/27372/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 E8DC1C3304\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Jul 2026 22:25:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8485767E3F;\n\tFri, 17 Jul 2026 00:25:49 +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 DBAE467E2B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jul 2026 00:25:47 +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-619-gS26_IaAObS2aGVbZYguAg-1;\n\tThu, 16 Jul 2026 18:25:41 -0400",
            "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.111])\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 D6AE21956044; Thu, 16 Jul 2026 22:25:39 +0000 (UTC)",
            "from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.11])\n\tby mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id BD4F11800361; Thu, 16 Jul 2026 22:25:36 +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=\"IPyp4c2u\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1784240746;\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=QRuJ5/9KcNuHCpobXEKvlUmLimeiVOhqvPLI+TvS71g=;\n\tb=IPyp4c2uyPZPG1m0F7pcRxmztziOY/L6jiJxMr6gJu9ghPIjM/uqUbHDR3ZMZchzj9WFMA\n\ts7bF5suja7Cpuc+0sqse3phTv1/cbHKSECWg/zxJvh+sJpjYmzC2WZ7j0y5ge05lyECKu8\n\tzNoopeS6iKYk0Fq2+08tBzaNW5AFFw4=",
        "X-MC-Unique": "gS26_IaAObS2aGVbZYguAg-1",
        "X-Mimecast-MFC-AGG-ID": "gS26_IaAObS2aGVbZYguAg_1784240740",
        "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 v8 4/6] libcamera: shaders: Add LSC support",
        "Date": "Fri, 17 Jul 2026 00:25:11 +0200",
        "Message-ID": "<20260716222515.251464-5-mzamazal@redhat.com>",
        "In-Reply-To": "<20260716222515.251464-1-mzamazal@redhat.com>",
        "References": "<20260716222515.251464-1-mzamazal@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.111",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-MFC-PROC-ID": "Dtc8kYfyInlLCpUF27_BWaIwZ8Si_sKcIzgNPqRagSY_1784240740",
        "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 shaders are compiled on initialisation, while lens shading\ncorrection can be enabled or disabled dynamically, using the\ncorresponding control.  The whole correction in the shader is wrapped by\na conditional macro to be able to disable it and all the related\noverheads if Lsc algorithm is not enabled at all.\n\nIf Lsc algorithm is enabled, the correction is always applied, whether\nthe given control is enabled or not.  If it is not, 1.0 multipliers are\nexpected to be provided.  This is because lens shading correction is\nsupposed to be rarely switched off using the runtime control when Lsc\nalgorithm is enabled, e.g. only for demoing or debugging purposes.\nWe prefer accepting the performance penalty of applying a no-op\ncorrection in such cases rather than disturbing GPU computation in the\nregular flow by introducing a runtime `if'.\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 0b641a5f3..e1c6fad4c 100644\n--- a/src/libcamera/shaders/bayer_1x_packed.frag\n+++ b/src/libcamera/shaders/bayer_1x_packed.frag\n@@ -71,6 +71,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@@ -232,6 +236,10 @@ void main(void)\n \t */\n \trgb = (rgb - blacklevel) / (1.0 - blacklevel);\n \n+#if defined(APPLY_LSC)\n+        rgb = rgb * texture2D(lsc_tex, textureOut).rgb;\n+#endif\n+\n \t/* Apply AWB gains, and saturate each channel at sensor range */\n \trgb = clamp(rgb * awb, vec3(0.0), vec3(1.0));\n \ndiff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag\nindex 10c5e941b..5b870fb2c 100644\n--- a/src/libcamera/shaders/bayer_unpacked.frag\n+++ b/src/libcamera/shaders/bayer_unpacked.frag\n@@ -30,6 +30,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@@ -135,6 +139,10 @@ void main(void) {\n      */\n     rgb = (rgb - blacklevel) / (1.0 - blacklevel);\n \n+#if defined(APPLY_LSC)\n+    rgb = rgb * texture2D(lsc_tex, center.xy).rgb;\n+#endif\n+\n     /* Apply AWB gains, and saturate each channel at sensor range */\n     rgb = clamp(rgb * awb, vec3(0.0), vec3(1.0));\n \n",
    "prefixes": [
        "RFC",
        "v8",
        "4/6"
    ]
}