[libcamera-devel] [PATCH 17/30] libcamera: v4l2_videodevice: Add support for multi plane output buffers

Niklas Söderlund niklas.soderlund at ragnatech.se
Wed Nov 27 00:36:07 CET 2019


When queuing an output buffer it was assumed it only had one plane. With
the recent rework of the buffer code it's now trivial to add support
multi plane output buffers, add support for it.

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 src/libcamera/v4l2_videodevice.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 8f962c7e9d0c7d01..a05dd6a1f7d86eaa 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1014,7 +1014,17 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer)
 	if (V4L2_TYPE_IS_OUTPUT(buf.type)) {
 		const BufferInfo &info = buffer->info();
 
-		buf.bytesused = info.planes()[0].bytesused;
+		if (multiPlanar) {
+			unsigned int nplane = 0;
+			for (const BufferInfo::Plane &plane : info.planes()) {
+				v4l2Planes[nplane].bytesused = plane.bytesused;
+				nplane++;
+			}
+		} else {
+			if (info.planes().size())
+				buf.bytesused = info.planes()[0].bytesused;
+		}
+
 		buf.sequence = info.sequence();
 		buf.timestamp.tv_sec = info.timestamp() / 1000000000;
 		buf.timestamp.tv_usec = (info.timestamp() / 1000) % 1000000;
-- 
2.24.0



More information about the libcamera-devel mailing list