[PATCH] v4l2-utils: libv4l2: Remove unconditional sleep after STREAMOFF and enable REQBUFS(count=0)

From: Rivka S

Date: Tue Feb 17 2026 - 06:13:22 EST


Remove the unconditional sleep(1) after VIDIOC_STREAMOFF and
enable the REQBUFS(count=0) call when freeing buffers.

The current implementation calls sleep(1) after STREAMOFF
with a FIXME comment suggesting a need to ensure that
all buffers have stopped. However, the videobuf2
implementation documents that vb2_core_streamoff()
cancels the queue and removes all buffers from the driver
and vb2, returning control to userspace as part of the
stream stop procedure.

Since STREAMOFF already performs queue cancellation,
remove the additional sleep delay as is it unnecessary and does
not provide deterministic synchronization.

Re-enable the REQBUFS(count=0) call, which was previously disabled due to
historical limitations in the old video-buf implementation. Modern buffer
frameworks expect this ioctl to release all buffers as defined by the
V4L2 API.

Signed-off-by: Rivka S <s0533160580@xxxxxxxxx>
---
utils/libv4l2util/v4l2_driver.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/utils/libv4l2util/v4l2_driver.c b/utils/libv4l2util/v4l2_driver.c
index c9560326..28fc1bcf 100644
--- a/utils/libv4l2util/v4l2_driver.c
+++ b/utils/libv4l2util/v4l2_driver.c
@@ -569,17 +569,11 @@ int v4l2_free_bufs(struct v4l2_driver *drv)
if (xioctl(drv->fd,VIDIOC_STREAMOFF,&drv->reqbuf.type)<0)
return errno;

- sleep (1); // FIXME: Should check if all buffers are stopped

-/* V4L2 API says REQBUFS with count=0 should be used to release buffer.
- However, video-buf.c doesn't implement it.
- */
-#if 0
if (xioctl(drv->fd,VIDIOC_REQBUFS,&drv->reqbuf)<0) {
perror("reqbufs while freeing buffers");
return errno;
}
-#endif

if (drv->reqbuf.count != 0) {
fprintf(stderr,"REQBUFS returned %d buffers while asking for freeing it!\n",
--
2.43.0