[3/3] libcamera: pipeline: ipu3: Bound viewfinder size to the ImgU limits
diff mbox series

Message ID 20261103104131.87331-4-guyliandejong@proton.me
State New
Headers show
Series
  • ipu3: Fix support for small sensors such as the OV9734
Related show

Commit Message

GuyliandeJong Nov. 3, 2026, 10:41 a.m. UTC
The default size of the Viewfinder and VideoRecording streams is
1280x720, bounded by the sensor resolution. It is also used as the
maximum size of the StreamFormats ranges reported for these roles.

validate() requires the ImgU outputs to be strictly smaller than the
CIO2 output, aligned down to 64x32. For a sensor no wider than 1280
pixels or no taller than 736 lines, the default size is then larger than
what validate() accepts. With the OV9734 (1296x734) on a Surface
Laptop 2, 1280x720 is reported while validate() adjusts it to 1280x704.
Applications that pick sizes from StreamFormats, such as PipeWire, get
configurations adjusted behind their back, which made WirePlumber
abort.

Apply the same margin to the sensor resolution as validate() and as
the StillCapture role already does, before bounding it to 1280x720.
Larger sensors are not affected.

Signed-off-by: GuyliandeJong <guyliandejong@proton.me>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 14cab9e5..730fdfc5 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -444,10 +444,14 @@  PipelineHandlerIPU3::generateConfiguration(Camera *camera, std::span<const Strea
 		case StreamRole::VideoRecording: {
 			/*
 			 * Default viewfinder and videorecording to 1280x720,
-			 * capped to the maximum sensor resolution and aligned
+			 * capped to the largest output strictly smaller than
+			 * the sensor resolution (see validate()) and aligned
 			 * to the ImgU output constraints.
 			 */
-			size = sensorResolution.boundedTo(kViewfinderSize)
+			size = sensorResolution.shrunkBy({ 1, 1 })
+					       .alignedDownTo(ImgUDevice::kOutputMarginWidth,
+							      ImgUDevice::kOutputMarginHeight)
+					       .boundedTo(kViewfinderSize)
 					       .alignedDownTo(ImgUDevice::kOutputAlignWidth,
 							      ImgUDevice::kOutputAlignHeight);
 			pixelFormat = formats::NV12;