Index | Thread | Search

From:
Marcus Glocker <marcus@nazgul.ch>
Subject:
Re: sys/uvideo: fill v4l2_capability the right way
To:
"Kirill A. Korinsky" <kirill@korins.ky>
Cc:
tech@openbsd.org
Date:
Sat, 28 Dec 2024 18:32:06 +0100

Download raw body.

Thread
On Sat, Dec 28, 2024 at 04:18:57PM GMT, Kirill A. Korinsky wrote:

> tech@,
> 
> Some V4L consumers, for example libwebrtc which is used by firefox, uses
> bus_info to find the desired webcam.
> 
> Our logic with hardcoded string leads that firefox uses /dev/video0, and
> switch to another webcam simple doesn't work.
> 
> This behaviour of Linux uvc_meta_v4l2_querycap which uses constant as
> driver name, and device as bus_info.
> 
> Ok?
> 
> Index: sys/dev/usb/uvideo.c
> ===================================================================
> RCS file: /home/cvs/src/sys/dev/usb/uvideo.c,v
> diff -u -p -u -p -r1.231 uvideo.c
> --- sys/dev/usb/uvideo.c	22 Dec 2024 20:30:04 -0000	1.231
> +++ sys/dev/usb/uvideo.c	28 Dec 2024 15:08:42 -0000
> @@ -2931,9 +2931,9 @@ uvideo_querycap(void *v, struct v4l2_cap
>  	struct uvideo_softc *sc = v;
> 
>  	bzero(caps, sizeof(*caps));
> -	strlcpy(caps->driver, DEVNAME(sc), sizeof(caps->driver));
> +	strlcpy(caps->driver, "uvideo", sizeof(caps->driver));

This makes sense to me.

>  	strlcpy(caps->card, sc->sc_udev->product, sizeof(caps->card));
> -	strlcpy(caps->bus_info, "usb", sizeof(caps->bus_info));
> +	strlcpy(caps->bus_info, DEVNAME(sc), sizeof(caps->bus_info));

For this change I'm not 100% convinced yet.  "video0" for example isn't
a bus per se.  The videoio.h comment gives an example:

	* @bus_info:     name of the bus (e.g. "PCI:" + pci_name(pci_dev) )

Do you know how libwebrtc is parsing this field exactly?  Would
something like "video0@usb" work as well?  To at least keep the bus
information in this field?

>  	caps->version = 1;
>  	caps->device_caps = V4L2_CAP_VIDEO_CAPTURE
> 
> 
> --
> wbr, Kirill
>