blue-debug opened a new pull request, #21471: URL: https://github.com/apache/nuttx/pull/21471
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary This PR fixes bugs in the V4L2 capture driver and video_framebuff. The code they fix was already in NuttX before #21448, so these are not follow-ups of #21448 and there is no #21448 commit they could be squashed into; fixes for code that #21448 itself added were squashed into its commits before it was merged. Each fix is its own commit: - video/framebuff: REQBUFS with the same buffer count kept the old container chain, so containers still queued from the previous stream pointed into the buffer heap REQBUFS had just freed. - video/v4l2_cap: poll teardown cleared the slot of the wrong queue when a still capture started or stopped during poll(), leaving a dangling pollfd. - video/v4l2: close and unlink cleared `i_private` only after freeing the capture manager, and open() after unlink re-initialized a device that was being removed. - video/v4l2_cap: `start_capture()` ignored the lower half's errors, so DQBUF could wait forever; QBUF did not check the buffer index, the memory type or USERPTR buffers, and left its container queued when it failed. A new framebuff helper takes that container back out of the queue. The new index check runs before a container is taken and covers every memory type, so it replaces the DMA-BUF-only index check that #21448 added inside the DMA-BUF case. ## Impact Affects: V4L2 capture driver and video_framebuff. Behavior: STREAMON, QBUF and DQBUF return the lower half's error instead of blocking later. QBUF returns -EINVAL for a bad index, an unknown memory type, MMAP before REQBUFS or a USERPTR buffer that is NULL or shorter than a frame. open() of an unlinked device returns -ENODEV. Compatibility: no API or struct changes. ## Testing Simulator (sim:nxcamera, NSH). Every commit builds on its own with apache/nuttx-apps master, and checkpatch passes. nxcamera captures 10 frames from a v4l2loopback device fed by FFmpeg, as described in the sim:nxcamera section of Documentation/platforms/sim/sim/boards/sim/index.rst. Logs (excerpt): ``` nsh> uname -a NuttX 13.1.0 f39d9070ac8 Nov 5 2026 09:41:40 sim sim nsh> mount -t hostfs -o fs=/tmp/v4l2-test/capture /host nsh> nxcamera nxcamera> input /dev/video0 nxcamera> output /host/frames.yuv 10 nxcamera> stream 640 480 30 YU12 nxcamera> q nsh> ls -l /host /host: -rw-r--r-- 4608000 2026-11-05 01:41 frames.yuv ... ``` Result: PASS. The 10 captured frames are byte-identical to FFmpeg's smptebars frame, as on master. Additional platform coverage: - BES platform (Cortex-M55): these fixes run in Vela's camera stack with a USB UVC camera. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
