@@ -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;
}
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@ideasonboard.com> --- src/libcamera/v4l2_videodevice.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)