[v1,1/3] pipeline: rpi: Pass the raw buffer pixel format to the IPA
diff mbox series

Message ID 20261118140719.46849-2-david.plowman@raspberrypi.com
State New
Headers show
Series
  • RPi: prepare for "pixel peeping" IPAs
Related show

Commit Message

David Plowman Nov. 18, 2026, 1:15 p.m. UTC
We have to pass both the fourcc and the modifier so that the IPA can
reconstruct the PixelFormat faithfully, and we do so whether the raw
buffers are internal or external.

This is for the benefit of future IPAs that may want to peak at pixel
values.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 include/libcamera/ipa/raspberrypi.mojom            |  2 ++
 src/ipa/rpi/common/ipa_base.cpp                    |  1 +
 src/ipa/rpi/controller/camera_mode.h               |  3 +++
 .../pipeline/rpi/common/pipeline_base.cpp          | 14 ++++++++++++++
 4 files changed, 20 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom
index 1b7e0358..ed048526 100644
--- a/include/libcamera/ipa/raspberrypi.mojom
+++ b/include/libcamera/ipa/raspberrypi.mojom
@@ -37,6 +37,8 @@  struct BufferIds {
 
 struct ConfigParams {
 	uint32 transform;
+	uint32 rawFormat; /* raw buffer PixelFormat fourcc, or zero if unknown */
+	uint64 rawFormatModifier; /* raw buffer PixelFormat modifier */
 	libcamera.ControlInfoMap sensorControls;
 	libcamera.ControlInfoMap ispControls;
 	libcamera.ControlInfoMap lensControls;
diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp
index c2848344..2ed80d3e 100644
--- a/src/ipa/rpi/common/ipa_base.cpp
+++ b/src/ipa/rpi/common/ipa_base.cpp
@@ -215,6 +215,7 @@  int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa
 	setMode(sensorInfo);
 
 	mode_.transform = static_cast<libcamera::Transform>(params.transform);
+	mode_.rawFormat = PixelFormat(params.rawFormat, params.rawFormatModifier);
 
 	/* Pass the camera mode to the CamHelper to setup algorithms. */
 	helper_->setCameraMode(mode_);
diff --git a/src/ipa/rpi/controller/camera_mode.h b/src/ipa/rpi/controller/camera_mode.h
index 61162b32..400e5938 100644
--- a/src/ipa/rpi/controller/camera_mode.h
+++ b/src/ipa/rpi/controller/camera_mode.h
@@ -6,6 +6,7 @@ 
  */
 #pragma once
 
+#include <libcamera/pixel_format.h>
 #include <libcamera/transform.h>
 
 #include <libcamera/base/utils.h>
@@ -43,6 +44,8 @@  struct CameraMode {
 	libcamera::utils::Duration maxFrameDuration;
 	/* any camera transform *not* reflected already in the camera tuning */
 	libcamera::Transform transform;
+	/* PixelFormat of the raw buffers */
+	libcamera::PixelFormat rawFormat;
 	/* minimum and maximum frame lengths in units of lines */
 	uint32_t minFrameLength;
 	uint32_t maxFrameLength;
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index d6ce2dbf..6944d5c4 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -1236,6 +1236,20 @@  int CameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::Config
 	Transform transform = config->orientation / Orientation::Rotate0;
 	params.transform = static_cast<unsigned int>(transform);
 
+	/*
+	 * Send the format of the raw Bayer buffers, which should match what's
+	 * set on the frontend device, whether buffers are internal or not.
+	 */
+	V4L2DeviceFormat frontendFormat;
+	ret = frontendDevice()->getFormat(&frontendFormat);
+	if (ret) {
+		LOG(RPI, Error) << "Failed to get the frontend format";
+		return ret;
+	}
+	const PixelFormat rawFormat = frontendFormat.fourcc.toPixelFormat();
+	params.rawFormat = rawFormat.fourcc();
+	params.rawFormatModifier = rawFormat.modifier();
+
 	/* Ready the IPA - it must know about the sensor resolution. */
 	ret = ipa_->configure(sensorInfo_, params, result);
 	if (ret < 0) {