[WIP,RFC,24/26] pipeline: rpi: vc4: Migrate to generic RAW formats
diff mbox series

Message ID 20261023-b4-raw-model-v1-24-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
Unicam supports both the new media bus codes and fourcc values.

VC4 ISP unfortunately uses fourcc values to talk to the firmware, so we
instead convert the new generic fourcc to the legacy (bayer-order
specific) values before configuring it.

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

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
index 3236cc70c6a4..efd393a5c4a6 100644
--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp
+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
@@ -15,6 +15,7 @@ 
 
 #include "libcamera/internal/device_enumerator.h"
 #include "libcamera/internal/dma_buf_allocator.h"
+#include "libcamera/internal/v4l2_pixelformat.h"
 #include "libcamera/internal/v4l2_subdevice.h"
 
 #include "../common/pipeline_base.h"
@@ -622,6 +623,14 @@  int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi
 	V4L2VideoDevice *unicam = unicam_[Unicam::Image].dev();
 	V4L2DeviceFormat unicamFormat;
 
+	/*
+	 * The sensor bayer order is the order of the data arriving at the
+	 * Unicam image input, as affected by any transform applied to the
+	 * sensor.
+	 */
+	ColorFilterArray sensorBayerOrder =
+		sensor_->bayerOrder(rpiConfig->combinedTransform_);
+
 	/*
 	 * See which streams are requested, and route the user
 	 * StreamConfiguration appropriately.
@@ -641,9 +650,13 @@  int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi
 	if (ret)
 		return ret;
 
+	V4L2DeviceFormat ispFormat = unicamFormat;
+	ispFormat.fourcc.toNonGeneric(sensorBayerOrder);
+
 	LOG(RPI, Info) << "Sensor: " << sensor_->id()
 		       << " - Selected sensor format: " << rpiConfig->sensorFormat_
-		       << " - Selected unicam format: " << unicamFormat;
+		       << " - Selected unicam format: " << unicamFormat
+		       << " - Selected ISP input format: " << ispFormat;
 
 	/*
 	 * Configure the Unicam embedded data output format only if the sensor
@@ -684,7 +697,7 @@  int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi
 	 * 3. Configure the ISP.
 	 */
 
-	ret = isp_[Isp::Input].dev()->setFormat(&unicamFormat);
+	ret = isp_[Isp::Input].dev()->setFormat(&ispFormat);
 	if (ret)
 		return ret;