crosvm/usb_util
Leonid Lobachev 0eed9a4ce3 usb: fix descriptors parsing for interfaces with multiple alternative settings.
Previous code assumed there's a single InterfaceDescriptor per
ConfigDescriptor's bNumInterfaces. Which means they can only have a
single alternative setting. However that isn't always the case.
For example Logitech C930E webcam has the following configuration:
Device Descriptor:
  bNumConfigurations      1
  Configuration Descriptor:
    bNumInterfaces          4
    Interface Descriptor:
      bInterfaceNumber        0
      bAlternateSetting       0
    Interface Descriptor:
      bInterfaceNumber        1
      bAlternateSetting       0
    Interface Descriptor:
      bInterfaceNumber        1
      bAlternateSetting       1
<skipped>
    Interface Descriptor:
      bInterfaceNumber        1
      bAlternateSetting      11
    Interface Descriptor:
      bInterfaceNumber        2
      bAlternateSetting       0
    Interface Descriptor:
      bInterfaceNumber        3
      bAlternateSetting       0
    Interface Descriptor:
      bInterfaceNumber        3
      bAlternateSetting       1
<skipped>

Trying to attach a device where this isn't true led to errors like this:
[transfer_ring_controller.rs:50] failed to send transfer to backend

Tested by attaching Logitech C930E webcam to VM and
./ci/builder 'cargo test -p usb_util'

Change-Id: Iab671bff26558838becbbafe0a43ed6dc220306c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2983386
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Leonid Lobachev <leonidl@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-09 23:44:58 +00:00
..
src usb: fix descriptors parsing for interfaces with multiple alternative settings. 2021-07-09 23:44:58 +00:00
Cargo.toml Add "base" crate and transition crosvm usages to it from sys_util 2020-08-06 18:19:44 +00:00