Linux USB Gadget Driver Being Extended For WebUSB

Written by Michael Larabel in Hardware on 30 December 2022 at 06:15 PM EST. 23 Comments
HARDWARE
The Linux USB gadget kernel driver saw a patch published today for exposing of a device's landing page as part of the WebUSB specification. WebUSB as a reminder is the industry standard for providing a JavaScript API to securely access USB devices from web pages and is already supported by the likes of Google Chrome and Microsoft Edge.

WebUSB enables access to USB hardware devices from web pages and is backed by the W3C. WebUSB works in a cross-platform way and can already be used on Linux with the likes of Google Chrome.


The patch sent out today for the Linux USB gadget driver wishing to expose a "landing page" URL for announcing the page for the device and describing the JavaScript interface for said gadget. The WebUSB device's landing page would be exposed via sysfs and also reported via the lsusb device output. WebUSB already can work on Linux with supported web browsers while this kernel patch is about being able to expose any relevant landing page.
This specification is published under the W3C Community Contributor Agreement, which in particular allows to implement the specification without any royalties.

The specification allows USB gadgets to announce an URL to landing page and describes a Javascript interface for websites to interact with the USB gadget, if the user allows it. It is currently supported by Chromium-based browsers, such as Chrome, Edge and Opera on all major operating systems including Linux.

This patch adds optional support for Linux-based USB gadgets wishing to expose such a landing page.

During device enumeration, a host recognizes that the announced USB version is at least 2.01, which means, that there are BOS descriptors available. The device than announces WebUSB support using a platform device capability. This includes a vendor code under which the landing page URL can be retrieved using a vendor-specific request.

See the kernel mailing list for more details on this WebUSB support patch for the USB gadget code. Those curious about the WebUSB API can find the current spec via GitHub.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week