diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h
index b64910637..c8ed91949 100644
--- a/include/libcamera/internal/software_isp/software_isp.h
+++ b/include/libcamera/internal/software_isp/software_isp.h
@@ -102,6 +102,7 @@ private:
 	DmaBufAllocator dmaHeap_;
 	bool ccmEnabled_;
 	bool lscEnabled_;
+	std::optional<Size> lscGridSize_;
 
 	std::unique_ptr<ipa::softisp::IPAProxySoftIsp> ipa_;
 	std::deque<FrameBuffer *> queuedInputBuffers_;
diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
index 4f6659000..65820eabd 100644
--- a/src/libcamera/software_isp/debayer.cpp
+++ b/src/libcamera/software_isp/debayer.cpp
@@ -112,7 +112,8 @@ Debayer::~Debayer()
  * \param[in] inputCfg The input configuration
  * \param[in] outputCfgs The output configurations
  * \param[in] ccmEnabled Whether a color correction matrix is applied
- * \param[in] lscEnabled Whether lens shading correction grid is provided
+ * \param[in] lscGridSize The size of the lens shading correction grid;
+     empty if the correction is not enabled
  *
  * \return 0 on success, a negative errno on failure
  */
diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h
index e30a05279..246b85b67 100644
--- a/src/libcamera/software_isp/debayer.h
+++ b/src/libcamera/software_isp/debayer.h
@@ -41,7 +41,7 @@ public:
 	virtual int configure(const StreamConfiguration &inputCfg,
 			      const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
 			      bool ccmEnabled,
-			      bool lscEnabled) = 0;
+			      const std::optional<Size> &lscGridSize) = 0;
 
 	virtual std::vector<PixelFormat> formats(PixelFormat inputFormat) = 0;
 
diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
index 91867baa6..2ac4f142f 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -625,7 +625,7 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat,
 int DebayerCpu::configure(const StreamConfiguration &inputCfg,
 			  const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
 			  bool ccmEnabled,
-			  [[maybe_unused]] bool lscEnabled)
+			  [[maybe_unused]] const std::optional<Size> &lscGridSize)
 {
 	if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) {
 		LOG(Debayer, Error)
diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h
index ae570893b..5759ad08f 100644
--- a/src/libcamera/software_isp/debayer_cpu.h
+++ b/src/libcamera/software_isp/debayer_cpu.h
@@ -38,7 +38,7 @@ public:
 	int configure(const StreamConfiguration &inputCfg,
 		      const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
 		      bool ccmEnabled,
-		      bool lscEnabled) override;
+		      const std::optional<Size> &lscGridSize) override;
 	Size patternSize(PixelFormat inputFormat) override;
 	std::vector<PixelFormat> formats(PixelFormat input) override;
 	std::tuple<unsigned int, unsigned int>
diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index 33933b11d..ce836f088 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -146,7 +146,7 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm
 	/* Specify GL_OES_EGL_image_external */
 	egl_.pushEnv(shaderEnv, "#extension GL_OES_EGL_image_external: enable");
 
-	if (lscEnabled_)
+	if (lscGridSize_)
 		egl_.pushEnv(shaderEnv, "#define APPLY_LSC");
 
 	/*
@@ -280,7 +280,7 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm
 int DebayerEGL::configure(const StreamConfiguration &inputCfg,
 			  const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
 			  [[maybe_unused]] bool ccmEnabled,
-			  bool lscEnabled)
+			  const std::optional<Size> &lscGridSize)
 {
 	if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) {
 		LOG(Debayer, Error)
@@ -300,7 +300,7 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,
 		return -EINVAL;
 	}
 
-	lscEnabled_ = lscEnabled;
+	lscGridSize_ = lscGridSize;
 
 	inputConfig_.stride = inputCfg.stride;
 	inputPixelFormat_ = inputCfg.pixelFormat;
@@ -478,7 +478,7 @@ void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerPara
 	glUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm.data().data());
 	LOG(Debayer, Debug) << " ccmUniformDataIn_ " << ccmUniformDataIn_ << " data " << params.combinedMatrix;
 
-	if (lscEnabled_ && params.lscLutVersion != lscLutVersion_) {
+	if (lscGridSize_ && params.lscLutVersion != lscLutVersion_) {
 		egl_.updateTexture2D(*eglImageLscLookup_, params.lscLut.data());
 		lscLutVersion_ = params.lscLutVersion;
 		glUniform1i(textureUniformLsc_, eglImageLscLookup_->texture_unit_uniform_id_);
@@ -691,12 +691,12 @@ int DebayerEGL::start()
 	if (initBayerShaders(inputPixelFormat_, outputPixelFormat_))
 		return -EINVAL;
 
-	if (lscEnabled_) {
-		constexpr unsigned int gridSize = DebayerParams::kLscGridSize;
-		constexpr unsigned int stride = gridSize * DebayerParams::kLscBytesPerCell;
+	if (lscGridSize_) {
+		const Size &gridSize = lscGridSize_.value();
+		const unsigned int stride = gridSize.width * DebayerParams::kLscBytesPerCell;
 		eglImageLscLookup_.emplace(GL_RGBA,
-					   gridSize,
-					   gridSize,
+					   gridSize.width,
+					   gridSize.height,
 					   stride,
 					   GL_TEXTURE2,
 					   2);
diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h
index cbbc6a450..977e1871e 100644
--- a/src/libcamera/software_isp/debayer_egl.h
+++ b/src/libcamera/software_isp/debayer_egl.h
@@ -46,7 +46,7 @@ public:
 	int configure(const StreamConfiguration &inputCfg,
 		      const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
 		      bool ccmEnabled,
-		      bool lscEnabled) override;
+		      const std::optional<Size> &lscGridSize) override;
 
 	Size patternSize(PixelFormat inputFormat) override;
 
@@ -84,7 +84,7 @@ private:
 	unsigned int outputBufferCount_;
 
 	/* LSC lookup table */
-	bool lscEnabled_;
+	std::optional<Size> lscGridSize_;
 	std::optional<eGLImage> eglImageLscLookup_;
 	std::optional<uint64_t> lscLutVersion_;
 
diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp
index 627625b4f..88349598a 100644
--- a/src/libcamera/software_isp/software_isp.cpp
+++ b/src/libcamera/software_isp/software_isp.cpp
@@ -171,6 +171,11 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
 		return;
 	}
 
+	if (lscEnabled_)
+		lscGridSize_ = Size(DebayerParams::kLscGridSize, DebayerParams::kLscGridSize);
+	else
+		lscGridSize_.reset();
+
 	ipa_->paramsComputed.connect(this, &SoftwareIsp::saveIspParams);
 	ipa_->metadataReady.connect(this,
 				    [this](uint32_t frame, const ControlList &metadata) {
@@ -294,7 +299,7 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg,
 	if (ret < 0)
 		return ret;
 
-	ret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_, lscEnabled_);
+	ret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_, lscGridSize_);
 	if (ret < 0)
 		return ret;
 
