[libcamera-devel] [PATCH 1/4] libcamera: v4l2_videodevice: Ensure non-zero bytesused for output buffers
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sun Oct 2 02:36:09 CEST 2022
The V4L2 API specification indicates that, for an output video device,
the driver will interpret a zero bytesused value as the buffer length
(for v4l2_buffer) or the plane length (for v4l2_plane). The videobuf2
framework implements this behaviour, but also considers this case as
deprecated and prints a warning:
[ 54.375534] use of bytesused == 0 is deprecated and will be removed in the future,
[ 54.388026] use the actual size instead.
Avoid the warning by setting bytesused to the buffer or plane length
before queuing a buffer to an output video device.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/libcamera/v4l2_videodevice.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 955e150867ef..1dbb839ed456 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1645,10 +1645,10 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
}
if (multiPlanar) {
- v4l2Planes[0].bytesused = bytesused;
+ v4l2Planes[0].bytesused = bytesused ? : length;
v4l2Planes[0].length = length;
} else {
- buf.bytesused = bytesused;
+ buf.bytesused = bytesused ? : length;
buf.length = length;
}
} else if (multiPlanar) {
@@ -1658,7 +1658,8 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
* V4L2 buffer is guaranteed to be equal at this point.
*/
for (auto [i, plane] : utils::enumerate(planes)) {
- v4l2Planes[i].bytesused = metadata.planes()[i].bytesused;
+ v4l2Planes[i].bytesused = metadata.planes()[i].bytesused
+ ? : plane.length;
v4l2Planes[i].length = plane.length;
}
} else {
@@ -1666,7 +1667,8 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
* Single-planar API with a single plane in the buffer
* is trivial to handle.
*/
- buf.bytesused = metadata.planes()[0].bytesused;
+ buf.bytesused = metadata.planes()[0].bytesused
+ ? : planes[0].length;
buf.length = planes[0].length;
}
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list