[WIP,RFC,21/26] pipeline: rpi: Split bayerOrder from PixelFormat
diff mbox series

Message ID 20261023-b4-raw-model-v1-21-eadb9948901b@ideasonboard.com
State New
Headers show
Series
  • Support the new common raw sensor model
Related show

Commit Message

Jai Luthra Oct. 23, 2026, 10:58 a.m. UTC
With only generic (bayer-order independent) formats supported throughout
libcamera now, ensure that we populate StreamConfiguration::bayerOrder
when generating new configurations, and update them during validate()
depending upon the combined flips and transforms.

Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
 src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index 435f460bbf8c..8453c8668542 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -248,11 +248,10 @@  CameraConfiguration::Status RPiCameraConfiguration::validate()
 		 * to the user request.
 		 */
 
-		BayerFormat cfgBayer = BayerFormat::fromPixelFormat(rawStream->pixelFormat);
-		cfgBayer.cfa = data_->sensor_->bayerOrder(combinedTransform_);
+		ColorFilterArray cfa = data_->sensor_->bayerOrder(combinedTransform_);
 
-		if (rawStream->pixelFormat != cfgBayer.toPixelFormat()) {
-			rawStream->pixelFormat = cfgBayer.toPixelFormat();
+		if (!rawStream->bayerOrder || rawStream->bayerOrder.value() != cfa) {
+			rawStream->bayerOrder = cfa;
 			status = Adjusted;
 		}
 	}
@@ -500,6 +499,16 @@  PipelineHandlerBase::generateConfiguration(Camera *camera, std::span<const Strea
 		cfg.pixelFormat = *pixelFormat;
 		cfg.colorSpace = colorSpace;
 		cfg.bufferCount = bufferCount;
+
+		/*
+		 * Colour order of the raw data is only relevant for raw
+		 * streams. Populate the sensor's native (untransformed) color
+		 * filter array order; validate() will update it with the
+		 * order resulting from the transform applied to the sensor.
+		 */
+		if (role == StreamRole::Raw)
+			cfg.bayerOrder = data->sensor_->bayerOrder(Transform::Identity);
+
 		config->addConfiguration(cfg);
 	}