git: uvc - Initial port of webcam driver from FreeBSD
Michael Neumann
mneumann at crater.dragonflybsd.org
Tue Jul 29 13:04:43 PDT 2025
commit a79869670e17876395a0e3300fda2f4471d896cb
Author: Michael Neumann <mneumann at ntecs.de>
Date: Tue May 6 16:03:42 2025 +0200
uvc - Initial port of webcam driver from FreeBSD
This adds preliminary support for USB Video Class (UVC) devices
or so called "webcams".
The port is based on [1] (branch feature-uvc-prepare-submit3) as of
May 10, 2025.
Tested with the built-in USB HD Webcam of my Panasonic CF-SV7 as well as
with a no-name external webcam. Works in chrome, cheese and with
ffmpeg. Does not work in Firefox (waits for permissions) or pwcview.
To record from webcam with ffmpeg:
ffmpeg -f v4l2 -i /dev/video0 -vcodec rawvideo record.mkv
After closing the video device, you still have to kldunload uvc and
kldload uvc again, otherwise it either stops working or you'll get
strange artifacts.
Here are the additions I made:
* Applied some automatic DragonFly conversions using the following
Makefile script:
replace:
ruby -i -p -e '$$_.gsub!(%r[dev/usb], "bus/u4b")' *.c *.h
ruby -i -p -e '$$_.gsub!(%r[(malloc|free)\(], "k\\1(")' *.c *.h
ruby -i -p -e '$$_.gsub!(%r{([a-z]*)printf\(}, "k\\1printf(")' *.c *.h
* Add STAILQ_FOREACH_SAFE macros adapted from
netproto/802_11/ieee80211_dragonfly.h
* Add atomic_subtract_64 macro
* Add kqueue support, replacing FreeBSD's poll code
* Fix mmap implementation
* Properly size uvc_data_request packages for UVC versions >= 1.5
to 48 bytes (taken from OpenBSD). This is required to recognize
my webcam.
[1]: https://github.com/lwhsu/freebsd-src/tree/feature-uvc-prepare-submit3
Summary of changes:
sys/bus/u4b/Makefile | 2 +-
sys/bus/u4b/quirk/usb_quirk.c | 4 +
sys/bus/u4b/quirk/usb_quirk.h | 23 +
sys/bus/u4b/usb.h | 4 +
sys/bus/u4b/usb/Makefile | 2 +-
sys/bus/u4b/usb_device.c | 147 ++
sys/bus/u4b/usb_device.h | 4 +
sys/bus/u4b/usb_transfer.c | 26 +
sys/bus/u4b/usb_transfer.h | 1 +
sys/bus/u4b/usbdevs | 1 +
sys/bus/u4b/usbdi.h | 3 +
sys/bus/u4b/{gadget/g_modem => uvc}/Makefile | 19 +-
sys/bus/u4b/uvc/uvc_buf.c | 762 +++++++
sys/bus/u4b/uvc/uvc_buf.h | 116 ++
sys/bus/u4b/uvc/uvc_ctrls.c | 1163 +++++++++++
sys/bus/u4b/uvc/uvc_drv.c | 2789 ++++++++++++++++++++++++++
sys/bus/u4b/uvc/uvc_drv.h | 780 +++++++
sys/bus/u4b/uvc/uvc_v4l2.c | 799 ++++++++
sys/bus/u4b/uvc/uvc_v4l2.h | 100 +
sys/contrib/v4l/videodev.h | 367 ++++
sys/contrib/v4l/videodev2.h | 1907 ++++++++++++++++++
sys/cpu/x86_64/include/atomic.h | 1 +
22 files changed, 9011 insertions(+), 9 deletions(-)
copy sys/bus/u4b/{gadget/g_modem => uvc}/Makefile (82%)
create mode 100644 sys/bus/u4b/uvc/uvc_buf.c
create mode 100644 sys/bus/u4b/uvc/uvc_buf.h
create mode 100644 sys/bus/u4b/uvc/uvc_ctrls.c
create mode 100644 sys/bus/u4b/uvc/uvc_drv.c
create mode 100644 sys/bus/u4b/uvc/uvc_drv.h
create mode 100644 sys/bus/u4b/uvc/uvc_v4l2.c
create mode 100644 sys/bus/u4b/uvc/uvc_v4l2.h
create mode 100644 sys/contrib/v4l/videodev.h
create mode 100644 sys/contrib/v4l/videodev2.h
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/a79869670e17876395a0e3300fda2f4471d896cb
--
DragonFly BSD source repository
More information about the Commits
mailing list