[libcamera-devel] [PATCH 14/20] pipeline: rpi: Move flip handling validation code

Naushir Patuck naush at raspberrypi.com
Fri Oct 6 15:19:54 CEST 2023


Move the handling of Bayer order changes due to flips entirely into
platformValidate(). This removes the need for this code to be split
between platformValidate() and validate() as it is right now.

Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
Reviewed-by: David Plowman <david.plowman at raspberrypi.com>
---
 .../pipeline/rpi/common/pipeline_base.cpp          | 14 --------------
 src/libcamera/pipeline/rpi/vc4/vc4.cpp             | 12 ++++++++++--
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index 825eae80d014..7437d38dc9ba 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -242,20 +242,6 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
 		if (ret)
 			return Invalid;
 
-		/*
-		 * Some sensors change their Bayer order when they are h-flipped
-		 * or v-flipped, according to the transform. If this one does, we
-		 * must advertise the transformed Bayer order in the raw stream.
-		 * Note how we must fetch the "native" (i.e. untransformed) Bayer
-		 * order, because the sensor may currently be flipped!
-		 */
-		BayerFormat bayer = BayerFormat::fromPixelFormat(raw.cfg->pixelFormat);
-		if (data_->flipsAlterBayerOrder_) {
-			bayer.order = data_->nativeBayerOrder_;
-			bayer = bayer.transform(combinedTransform_);
-		}
-		raw.cfg->pixelFormat = bayer.toPixelFormat();
-
 		if (RPi::PipelineHandlerBase::updateStreamConfig(raw.cfg, raw.format))
 			status = Adjusted;
 	}
diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
index 233473e2fe2b..4b42ddc71115 100644
--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp
+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
@@ -411,9 +411,17 @@ CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig
 		StreamConfiguration *rawStream = rawStreams[0].cfg;
 		BayerFormat rawBayer = BayerFormat::fromMbusCode(rpiConfig->sensorFormat_.mbus_code);
 
-		/* Handle flips to make sure to match the RAW stream format. */
-		if (flipsAlterBayerOrder_)
+		/*
+		 * Some sensors change their Bayer order when they are h-flipped
+		 * or v-flipped, according to the transform. If this one does, we
+		 * must advertise the transformed Bayer order in the raw stream.
+		 * Note how we must fetch the "native" (i.e. untransformed) Bayer
+		 * order, because the sensor may currently be flipped!
+		 */
+		if (flipsAlterBayerOrder_) {
+			rawBayer.order = nativeBayerOrder_;
 			rawBayer = rawBayer.transform(rpiConfig->combinedTransform_);
+		}
 
 		/* Apply the user requested packing. */
 		rawBayer.packing = BayerFormat::fromPixelFormat(rawStream->pixelFormat).packing;
-- 
2.34.1



More information about the libcamera-devel mailing list