[libcamera-devel] [PATCH 2/2] libcamera: v4l2_videodevice: Update bytesused when dq'ing MPLANE buffers

Kieran Bingham kieran.bingham at ideasonboard.com
Fri Oct 18 17:42:01 CEST 2019


When we dequeue a buffer using the MPLANE API, we currently set our
buffer->bytesused field to zero due to the zero entry in the V4L2 buffer
bytesused field.

The bytesused field is only really tracked for debug purposes currently,
so store the total bytese used from each plane in our local statistics
to identify actual data flow.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

---

This patch comes with a pinch of salt, we could also add a bytesused
field to the Plane class and intead update all the debug prints to
report the bytesused on a per-plane basis.
---
 src/libcamera/v4l2_videodevice.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 37f61b90ac46..71f141e7b511 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1124,13 +1124,20 @@ Buffer *V4L2VideoDevice::dequeueBuffer()
 		fdEvent_->setEnabled(false);
 
 	buffer->index_ = buf.index;
-	buffer->bytesused_ = buf.bytesused;
 	buffer->timestamp_ = buf.timestamp.tv_sec * 1000000000ULL
 			   + buf.timestamp.tv_usec * 1000ULL;
 	buffer->sequence_ = buf.sequence;
 	buffer->status_ = buf.flags & V4L2_BUF_FLAG_ERROR
 			? Buffer::BufferError : Buffer::BufferSuccess;
 
+	if (multiPlanar_) {
+		buffer->bytesused_ = 0;
+		for (unsigned int p = 0; p < buf.length; ++p)
+			buffer->bytesused_ += planes[p].bytesused;
+	} else {
+		buffer->bytesused_ = buf.bytesused;
+	}
+
 	return buffer;
 }
 
-- 
2.20.1



More information about the libcamera-devel mailing list