Skip to content

Commit

Permalink
feat: usb video class (webcam) extension
Browse files Browse the repository at this point in the history
Add usb video class v4l drivers extension.

Signed-off-by: Jacob McSwain <jacob.a.mcswain@gmail.com>
Signed-off-by: Noel Georgi <git@frezbo.dev>
  • Loading branch information
USA-RedDragon authored and frezbo committed Jan 16, 2024
1 parent 411dbc2 commit 5a97a46
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .kres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
- thunderbolt
- usb-modem-drivers
- util-linux-tools
- v4l-uvc-drivers
- xe-guest-utilities
- zfs
additionalTargets:
Expand Down Expand Up @@ -76,7 +77,7 @@ spec:
- name: EXTENSIONS_IMAGE_REF
defaultValue: $(REGISTRY_AND_USERNAME)/extensions:$(TAG)
- name: PKGS
defaultValue: v1.7.0-alpha.0-7-g4c59641
defaultValue: v1.7.0-alpha.0-12-g583e519
depends:
- internal/extensions/descriptions.yaml
script:
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2023-12-25T18:19:39Z by kres latest.
# Generated on 2024-01-16T14:25:28Z by kres latest.

# common variables

Expand Down Expand Up @@ -78,14 +78,15 @@ TARGETS += tailscale
TARGETS += thunderbolt
TARGETS += usb-modem-drivers
TARGETS += util-linux-tools
TARGETS += v4l-uvc-drivers
TARGETS += xe-guest-utilities
TARGETS += zfs
NONFREE_TARGETS = nonfree-kmod-nvidia

# extra variables

EXTENSIONS_IMAGE_REF ?= $(REGISTRY_AND_USERNAME)/extensions:$(TAG)
PKGS ?= v1.7.0-alpha.0-7-g4c59641
PKGS ?= v1.7.0-alpha.0-12-g583e519

# help menu

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ cosign verify --certificate-identity-regexp '@siderolabs\.com$' --certificate-oi
| [nvidia](nvidia-gpu/nvidia-modules/) | [ghcr.io/siderolabs/nvidia-open-gpu-kernel-modules](https://github.com/siderolabs/extensions/pkgs/container/nvidia-open-gpu-kernel-modules) | NVIDIA OSS Driver | `nvidia driver upstream version`-`talos version` |
| [thunderbolt](drivers/thunderbolt/) | [ghcr.io/siderolabs/thunderbolt](https://github.com/siderolabs/extensions/pkgs/container/thunderbolt) | Thunderbolt drivers | `talos version` |
| [usb-modem](drivers/usb-modem/) | [ghcr.io/siderolabs/usb-modem-drivers](https://github.com/siderolabs/extensions/pkgs/container/usb-modem-drivers) | USB Modem drivers | `talos version` |
| [v4l-uvc](drivers/v4l-uvc/) | [ghcr.io/siderolabs/v4l-uvc-drivers](https://github.com/siderolabs/extensions/pkgs/container/v4l-uvc-drivers) | USB Video Class (Webcam) drivers | `talos version` |

### Miscellaneous

Expand Down
52 changes: 52 additions & 0 deletions drivers/v4l-uvc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Video4Linux USB Video Class extension

## Installation

See [Installing Extensions](https://github.com/siderolabs/extensions#installing-extensions).

## Usage

Enable the `uvcvideo` module in Talos machine config to enable `/dev/video` devices from USB devices supporting the USB video device class.

```yaml
machine:
kernel:
modules:
- name: uvcvideo
```
## Verifiying
You can verify the modules are enabled by reading the `/proc/modules` where it _should_ show the module is live.

For example:

```
❯ talosctl -n 192.168.42.15 read /proc/modules
uvcvideo 122880 - - Live 0xffffffffc065f000
videobuf2_vmalloc 16384 - - Live 0xffffffffc063b000
videobuf2_memops 16384 - - Live 0xffffffffc0588000
videobuf2_v4l2 28672 - - Live 0xffffffffc05b3000
videobuf2_common 61440 - - Live 0xffffffffc064f000
videodev 237568 - - Live 0xffffffffc0600000
mc 49152 - - Live 0xffffffffc05f3000
```

In addition, you should be able to verify presence of the video device if the USB device is plugged in, checking `/dev` directory.

For example:

```
❯ talosctl -n 192.168.42.15 ls /dev | grep video
192.168.42.15 video0
192.168.42.15 video1
```

You can also verify everything in dmesg:

```
❯ talosctl -n 192.168.42.15 dmesg
# look for lines like these:
kern: info: [2024-01-15T19:37:30.689914441Z]: videodev: Linux video capture interface: v2.00
kern: info: [2024-01-15T19:37:34.222751441Z]: usbcore: registered new interface driver uvcvideo
```
11 changes: 11 additions & 0 deletions drivers/v4l-uvc/files/modules.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
modules.order
modules.builtin
modules.builtin.modinfo
kernel/drivers/media/common/videobuf2/videobuf2-common.ko
kernel/drivers/media/common/videobuf2/videobuf2-memops.ko
kernel/drivers/media/common/videobuf2/videobuf2-v4l2.ko
kernel/drivers/media/common/videobuf2/videobuf2-vmalloc.ko
kernel/drivers/media/mc/mc.ko
kernel/drivers/media/usb/uvc/uvcvideo.ko
kernel/drivers/media/v4l2-core/v4l2-dv-timings.ko
kernel/drivers/media/v4l2-core/videodev.ko
11 changes: 11 additions & 0 deletions drivers/v4l-uvc/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: v1alpha1
metadata:
name: v4l-uvc
version: "$VERSION"
author: Jacob McSwain
description: |
This system extension provides the Video4Linux kernel modules required for USB Video Class devices built against a specific Talos version.
This driver enables Video4Linux devices such as webcams.
compatibility:
talos:
version: ">= v1.5.0"
29 changes: 29 additions & 0 deletions drivers/v4l-uvc/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: v4l-uvc-drivers
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
# The pkgs version for a particular release of Talos as defined in
# https://github.com/siderolabs/talos/blob/<talos version>/pkg/machinery/gendata/data/pkgs
- image: "{{ .PKGS_PREFIX }}/kernel:{{ .BUILD_ARG_PKGS }}"
steps:
- prepare:
- |
sed -i 's#$VERSION#{{ .VERSION }}#' /pkg/manifest.yaml
- install:
- |
export KERNELRELEASE=$(find /lib/modules -type d -name "*-talos" -exec basename {} \+)
mkdir -p /rootfs
xargs -a /pkg/files/modules.txt -I {} install -D /lib/modules/${KERNELRELEASE}/{} /rootfs/lib/modules/${KERNELRELEASE}/{}
depmod -b /rootfs ${KERNELRELEASE}
- test:
- |
# https://www.kernel.org/doc/html/v4.15/admin-guide/module-signing.html#signed-modules-and-stripping
find /rootfs/lib/modules -name '*.ko' -exec grep -FL '~Module signature appended~' {} \+
finalize:
- from: /rootfs
to: /rootfs
- from: /pkg/manifest.yaml
to: /
1 change: 1 addition & 0 deletions drivers/v4l-uvc/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION: "{{ .BUILD_ARG_TAG }}"
4 changes: 4 additions & 0 deletions reproducibility/pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ dependencies:
# - stage: usb-modem-drivers

- stage: util-linux-tools

# v4l-uvc-drivers can be ignored from reproducibility test since it's kernel modules copied from pkgs
# - stage: v4l-uvc-drivers

- stage: xe-guest-utilities
- stage: zfs

Expand Down

0 comments on commit 5a97a46

Please sign in to comment.