Yifan-Liu1 opened a new pull request, #21446:
URL: https://github.com/apache/nuttx/pull/21446
## Summary
Add a USB Video Class host class driver that enumerates UVC 1.1/1.5 cameras
and exposes each of them through the NuttX camera upper half as `/dev/videoN`,
so that any V4L2 capture application can use a USB camera.
The driver parses the VideoControl and VideoStreaming descriptor sets,
implements PROBE/COMMIT negotiation together with the class-specific control
requests, and streams frames over isochronous IN endpoints. Payload headers
delimit frames, so a frame may span several transfers; the pipeline keeps a
configurable number of ISO slots in flight, each sized in packets rather than
frames. Bandwidth negotiation walks the alternate settings until one matches
the requested frame size, transport errors restart the stream, and teardown is
safe while slots are still awaiting a resubmit.
Supported payloads: MJPEG, frame-based (H.264/HEVC) and uncompressed YUYV,
UYVY, NV12, YVU420, YUV420, M420, GREY, RGB565 and BGR24, matched by the format
GUID.
Two small commits come with it: the class is registered on the simulated
host so the driver can be exercised with a camera passed through by libusb, and
the new functionality is documented.
Depends on #21443, which makes class control requests reach the device over
the simulated host and lets the composite builder copy all alternate settings
of an interface.
## Impact
- New: `drivers/usbhost/usbhost_uvc.c`, `usbhost_uvc.h`, `uvc_video.h`,
`Documentation/os/drivers/special/uvc_host.rst`.
- `drivers/usbhost/Kconfig`, `Make.defs`, `CMakeLists.txt`: new
`CONFIG_USBHOST_UVC` option (depends on `VIDEO_STREAM`, `USBHOST_HAVE_ASYNCH`
and `SCHED_HPWORK`).
- `include/nuttx/usb/usbhost.h`: declares `usbhost_uvc_initialize()` next to
the other class initializers.
- `arch/sim/src/sim/sim_usbhost.c`: registers the class on the simulated
host under `CONFIG_USBHOST_UVC`.
- The class definitions that only this driver uses live in a private header;
the public UVC definitions in `include/nuttx/usb/uvc.h` stay with the gadget
driver.
- Nothing existing changes behaviour: the driver is off by default and
registers only when a board asks for it.
## Testing
Build (simulator, gcc 13.4, libusb 1.0.25), after enabling
`CONFIG_DRIVERS_VIDEO`, `CONFIG_VIDEO_STREAM`, `CONFIG_USBHOST_UVC` and the
camera's `CONFIG_SIM_USB_VID`/`CONFIG_SIM_USB_PID` in the `sim:usbhost`
configuration:
./tools/configure.sh sim:usbhost
make -j$(nproc)
No new warnings; `tools/checkpatch.sh -c -u -m -g` is clean for all three
commits, and the documentation builds with `make html`.
Runtime, with a UVC camera passed through to the simulator by libusb
(captured with `apps/testing/v4l2_capture`, which uses the same ioctl sequence
as `apps/examples/camera`):
device : /dev/video0
driver : UVC Camera Driv
caps : 0x04000001
formats:
JPEG JPEG
YUYV YUYV
selected format: JPEG
frame sizes for 4745504a:
1920x1080
1280x720
800x600
640x480
640x360
negotiated: JPEG 640x480, buffer 1048576
uvc_execute_probe_commit: UVC: probe verified OK
uvc_execute_probe_commit: UVC: commit OK
uvc_set_interface_alt: UVC: required payload=1024
uvc_set_interface_alt: UVC: selected alt=5 payload=1024
uvc_iso_pipe_init: UVC: pipe init slots=2 pkts=32 maxpkt=1024 bufsz=32768
uvc_capture_thread: UVC: pipe ready slots=2 pkts=32 maxpkt=1024
frame 0: index 0, 43098 bytes, sequence 0
frame 1: index 1, 42952 bytes, sequence 0
...
frame 9: index 0, 43352 bytes, sequence 8
captured 10 frames, 433622 bytes in 599 ms (16 fps)
## Limitations
- One video streaming interface per camera.
- Isochronous endpoints only; cameras that use bulk endpoints for video data
are not supported.
- High bandwidth alternate settings (several transactions per microframe)
work only if the host controller programs Max Burst Size accordingly.
- No colour space conversion; uncompressed payloads are passed through as
they arrive.
--
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]