diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2017-09-12 15:47:31 +0200 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-22 10:18:50 -0700 |
commit | 77f011206c87a7a3e8cd93d3635c6c4f0ea3e32d (patch) | |
tree | 75d281c3355aa9c1918e29c31a63037d81768add /common/webusb_desc.c | |
parent | e3333972d5bcf110fd2c51de92097a546694d0a1 (diff) | |
download | chrome-ec-77f011206c87a7a3e8cd93d3635c6c4f0ea3e32d.tar.gz |
Add WebUSB descriptor support
The WebUSB specification defines a specific Platform Descriptor in the
Binary Object Store:
https://wicg.github.io/webusb/#webusb-platform-capability-descriptor
This descriptor provides a special 'Landing page' URL to the host
browser and associated privileges for it.
Bump the USB version for BOS descriptors to 2.1 to be compatible with
Chrome implementation.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=none
BRANCH=twinkie
TEST=manual: on Twinkie (chip/stm32) and HG proto2 (chip/g), enumerate
WebUSB descriptors with lsusb and connect to a WebUSB page in Chrome
R61+.
Change-Id: I7211ab554f4a6c156c1e8e79a3d9f0d6644217c6
Reviewed-on: https://chromium-review.googlesource.com/664813
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/webusb_desc.c')
-rw-r--r-- | common/webusb_desc.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/common/webusb_desc.c b/common/webusb_desc.c new file mode 100644 index 0000000000..41d39006e0 --- /dev/null +++ b/common/webusb_desc.c @@ -0,0 +1,46 @@ +/* Copyright 2017 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/* WebUSB platform descriptor */ + +#include "common.h" +#include "usb_descriptor.h" +#include "util.h" + +#ifndef CONFIG_USB_BOS +#error "CONFIG_USB_BOS must be defined to use WebUSB descriptor" +#endif + +const void *webusb_url = USB_URL_DESC(HTTPS, CONFIG_WEBUSB_URL); + +/* + * Platform Descriptor in the device Binary Object Store + * as defined by USB 3.1 spec chapter 9.6.2. + */ +static struct { + struct usb_bos_hdr_descriptor bos; + struct usb_platform_descriptor platform; +} bos_desc = { + .bos = { + .bLength = USB_DT_BOS_SIZE, + .bDescriptorType = USB_DT_BOS, + .wTotalLength = (USB_DT_BOS_SIZE + USB_DT_PLATFORM_SIZE), + .bNumDeviceCaps = 1, /* platform caps */ + }, + .platform = { + .bLength = USB_DT_PLATFORM_SIZE, + .bDescriptorType = USB_DT_DEVICE_CAPABILITY, + .bDevCapabilityType = USB_DC_DTYPE_PLATFORM, + .bReserved = 0, + .PlatformCapUUID = USB_PLAT_CAP_WEBUSB, + .bcdVersion = 0x0100, + .bVendorCode = 0x01, + .iLandingPage = 1, + }, +}; + +const struct bos_context bos_ctx = { + .descp = (void *)&bos_desc, + .size = sizeof(bos_desc), +}; |