This is a bug in the vim4 driver for amlvideo2
Details
I just installed Ubuntu on my VIM4 and am hitting this issue, too. Running strace -p $(pidof pipewire)
shows that the process appears to be in an infinite loop trying to enumerate video formats for attached cameras (note that I DO NOT have any cameras connected):
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305193, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305194, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305195, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305196, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305197, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
Looking at ls -l /proc/$(pidof pipewire)/fd
, fd 74 is pointing to /dev/video11
. According to v4l2-ctl
, this is an amlvideo2
. Querying the supported formats using v4l2-ctl -d /dev/video11 --list-formats-ext
results in… an infinite loop! Specifically, it looks like the driver claims the following formats are supported:
[0]: 'RGBR' (16-bit RGB 5-6-5 BE)
[1]: 'RGB3' (24-bit RGB 8-8-8)
[2]: 'BGR3' (24-bit BGR 8-8-8)
[3]: 'RGB4' (32-bit A/XRGB 8-8-8-8)
[4]: 'NV12' (Y/CbCr 4:2:0)
[5]: 'NV21' (Y/CrCb 4:2:0)
[6]: 'YU12' (Planar YUV 4:2:0)
[7]: 'YV12' (Planar YVU 4:2:0)
However, upon enumerating them, the driver reports that the number of formats for 565 is ZERO! This is probably an unchecked edge case, but is still invalid behavior for the driver according to the v4l2 spec. The fix is to skip reporting those format types as supported, or better yet, skip starting the driver if there is no camera connected to the board.
The simplest fix is to patch the driver to return EINVAL
when the VIDIOC_ENUM_FRAMESIZES
ioctl is invoked for formats with invalid indices. This is the recommended return value for out-of-bounds index access, and is how the v4l2 utility code determines when to exit the enumeration loop.