[libcamera-devel,v3,05/12] libcamera: rpi: Allow platformValidate() to adjust format strides
diff mbox series

Message ID 20230915130650.35691-6-jacopo.mondi@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Introduce SensorConfiguration
Related show

Commit Message

Jacopo Mondi Sept. 15, 2023, 1:06 p.m. UTC
From: Naushir Patuck <naush@raspberrypi.com>

Propagate any changes to the format stride done by platformValidate().
The stride value may be adjusted for performace reasons.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index dff4164a5f02..2d787f4b99ed 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -305,6 +305,17 @@  CameraConfiguration::Status RPiCameraConfiguration::validate()
 		V4L2DeviceFormat format;
 		format.fourcc = out.dev->toV4L2PixelFormat(cfg.pixelFormat);
 		format.size = cfg.size;
+
+		/*
+		 * platformValidate may have worked out the correct stride so we
+		 * must pass it in. This also needs the planesCount to be set
+		 * correctly or the stride will be ignored.
+		 */
+		const PixelFormat &pixFormat = format.fourcc.toPixelFormat();
+		const PixelFormatInfo &info = PixelFormatInfo::info(pixFormat);
+		format.planesCount = info.numPlanes();
+		format.planes[0].bpl = cfg.stride;
+
 		/* We want to send the associated YCbCr info through to the driver. */
 		format.colorSpace = yuvColorSpace_;