[v1,2/5] ipa: rpi: Pass raw buffer format to the IPA
diff mbox series

Message ID 20261203130113.47873-3-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Extra pipeline processing "stages" for Raspberry Pi
Related show

Commit Message

David Plowman Dec. 2, 2026, 4:13 p.m. UTC
IPAs may in general need to behave differently based on the raw pixel
format, so we should make this information available. This may be
particularly important for the new pipeline "stages", where the IPA
side may need to do different things based on what it knows its
associated stage may do.

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) {