{"id":26528,"url":"https://patchwork.libcamera.org/api/1.1/patches/26528/?format=json","web_url":"https://patchwork.libcamera.org/patch/26528/","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-8-mzamazal@redhat.com>","date":"2026-04-20T18:39:45","name":"[RFC,v2,7/8] libcamera: software_isp: debayer_egl: Add LSC support","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f76eef5a33abac9cff487cea9c404189eed9af6e","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/26528/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/26528/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26528/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 0FC7DBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Apr 2026 18:40:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BBE1062EF7;\n\tMon, 20 Apr 2026 20:40:21 +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 5C8B262EF3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Apr 2026 20:40:19 +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-156-83lSNLp8O02asFWiUNZMkA-1;\n\tMon, 20 Apr 2026 14:40:16 -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 16D491956095; Mon, 20 Apr 2026 18:40:15 +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 02EC4180047F; Mon, 20 Apr 2026 18:40:12 +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=\"SwLZWOfT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1776710417;\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=3ppH+azBFu0bos5jf4k4gpbTKyVtdcdC8mOKHIIZw4s=;\n\tb=SwLZWOfTe223EIgRWfojQaRJKaa7cPjj50Vco3+CeMqAMtW8DdOTJZtKsCsf/VMann27mV\n\tJplNEEc2jOoLUAW8oo1kSb1YNROowKLyX4Hy4oC5RTdHLuJpNASn86xfOd/8zxeVYTsHfa\n\tdGIOriUjRctUm2vSf2hHhXLusl/i718=","X-MC-Unique":"83lSNLp8O02asFWiUNZMkA-1","X-Mimecast-MFC-AGG-ID":"83lSNLp8O02asFWiUNZMkA_1776710415","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 7/8] libcamera: software_isp: debayer_egl: Add LSC\n\tsupport","Date":"Mon, 20 Apr 2026 20:39:45 +0200","Message-ID":"<20260420183949.110548-8-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":"pufnuvyGW9DOg1b43nbZiAoMHHJ_9vhqd5mVvMQbSWA_1776710415","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\nAdd support for passing the LSC table from debayerParams to the shaders.\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/software_isp/debayer_egl.cpp | 22 +++++++++++++++++++++-\n src/libcamera/software_isp/debayer_egl.h   |  5 +++++\n 2 files changed, 26 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\nindex 399915164..301dfc1c6 100644\n--- a/src/libcamera/software_isp/debayer_egl.cpp\n+++ b/src/libcamera/software_isp/debayer_egl.cpp\n@@ -111,6 +111,9 @@ int DebayerEGL::getShaderVariableLocations(void)\n \ttextureUniformBayerFirstRed_ = glGetUniformLocation(programId_, \"tex_bayer_first_red\");\n \ttextureUniformProjMatrix_ = glGetUniformLocation(programId_, \"proj_matrix\");\n \n+\tif (lscEnabled_)\n+\t\ttextureUniformLsc_ = glGetUniformLocation(programId_, \"lsc_tex\");\n+\n \tLOG(Debayer, Debug) << \"vertexIn \" << attributeVertex_ << \" textureIn \" << attributeTexture_\n \t\t\t    << \" tex_y \" << textureUniformBayerDataIn_\n \t\t\t    << \" ccm \" << ccmUniformDataIn_\n@@ -121,7 +124,8 @@ int DebayerEGL::getShaderVariableLocations(void)\n \t\t\t    << \" tex_size \" << textureUniformSize_\n \t\t\t    << \" stride_factor \" << textureUniformStrideFactor_\n \t\t\t    << \" tex_bayer_first_red \" << textureUniformBayerFirstRed_\n-\t\t\t    << \" proj_matrix \" << textureUniformProjMatrix_;\n+\t\t\t    << \" proj_matrix \" << textureUniformProjMatrix_\n+\t\t\t    << \" lsc \" << (lscEnabled_ ? textureUniformLsc_ : -1);\n \treturn 0;\n }\n \n@@ -140,6 +144,9 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm\n \t/* Specify GL_OES_EGL_image_external */\n \tegl_.pushEnv(shaderEnv, \"#extension GL_OES_EGL_image_external: enable\");\n \n+\tif (lscEnabled_)\n+\t\tegl_.pushEnv(shaderEnv, \"#define DO_LSC\");\n+\n \t/*\n \t * Tell shaders how to re-order output taking account of how the pixels\n \t * are actually stored by EGL.\n@@ -339,6 +346,12 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n \t */\n \tstats_->setWindow(Rectangle(window_.size()));\n \n+\tif (lscEnabled_) {\n+\t\tconstexpr unsigned int gridSize = DebayerParams::kLscGridSize;\n+\t\teglImageLscLookup_ =\n+\t\t\tstd::make_unique<eGLImage>(gridSize, gridSize, gridSize * 3, GL_TEXTURE2, 2);\n+\t}\n+\n \treturn 0;\n }\n \n@@ -478,6 +491,13 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams &params)\n \tglUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm);\n \tLOG(Debayer, Debug) << \" ccmUniformDataIn_ \" << ccmUniformDataIn_ << \" data \" << params.combinedMatrix;\n \n+\tif (lscEnabled_) {\n+\t\tegl_.createTexture2D(*eglImageLscLookup_, GL_RGB,\n+\t\t\t\t     DebayerParams::kLscGridSize, DebayerParams::kLscGridSize,\n+\t\t\t\t     params.lscLut.data(), GL_LINEAR);\n+\t\tglUniform1i(textureUniformLsc_, eglImageLscLookup_->texture_unit_uniform_id_);\n+\t}\n+\n \t/*\n \t * 0 = Red, 1 = Green, 2 = Blue\n \t */\ndiff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h\nindex f96077af5..38271a316 100644\n--- a/src/libcamera/software_isp/debayer_egl.h\n+++ b/src/libcamera/software_isp/debayer_egl.h\n@@ -85,7 +85,10 @@ private:\n \tstd::unique_ptr<eGLImage> eglImageBayerIn_;\n \tstd::unique_ptr<eGLImage> eglImageBayerOut_;\n \n+\t/* LSC lookup table */\n+\tstd::unique_ptr<eGLImage> eglImageLscLookup_;\n \tbool lscEnabled_;\n+\n \t/* Shader parameters */\n \tfloat firstRed_x_;\n \tfloat firstRed_y_;\n@@ -99,6 +102,8 @@ private:\n \n \tGLint textureUniformBayerDataIn_;\n \n+\tGLint textureUniformLsc_;\n+\n \t/* Represent per-frame CCM as a uniform vector of floats 3 x 3 */\n \tGLint ccmUniformDataIn_;\n \n","prefixes":["RFC","v2","7/8"]}