Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / device / usb / usb_descriptors.h
blob93b6f625918ca12afaec24bcdf9ec0586f99934a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DEVICE_USB_USB_DESCRIPTORS_H_
6 #define DEVICE_USB_USB_DESCRIPTORS_H_
8 #include <stdint.h>
9 #include <vector>
11 #include "base/strings/string16.h"
13 namespace device {
15 enum UsbTransferType {
16 USB_TRANSFER_CONTROL = 0,
17 USB_TRANSFER_ISOCHRONOUS,
18 USB_TRANSFER_BULK,
19 USB_TRANSFER_INTERRUPT,
22 enum UsbEndpointDirection {
23 USB_DIRECTION_INBOUND = 0,
24 USB_DIRECTION_OUTBOUND,
27 enum UsbSynchronizationType {
28 USB_SYNCHRONIZATION_NONE = 0,
29 USB_SYNCHRONIZATION_ASYNCHRONOUS,
30 USB_SYNCHRONIZATION_ADAPTIVE,
31 USB_SYNCHRONIZATION_SYNCHRONOUS,
34 enum UsbUsageType {
35 USB_USAGE_DATA = 0,
36 USB_USAGE_FEEDBACK,
37 USB_USAGE_EXPLICIT_FEEDBACK
40 struct UsbEndpointDescriptor {
41 UsbEndpointDescriptor();
42 ~UsbEndpointDescriptor();
44 uint8_t address;
45 UsbEndpointDirection direction;
46 uint16_t maximum_packet_size;
47 UsbSynchronizationType synchronization_type;
48 UsbTransferType transfer_type;
49 UsbUsageType usage_type;
50 uint16_t polling_interval;
51 std::vector<uint8_t> extra_data;
54 struct UsbInterfaceDescriptor {
55 UsbInterfaceDescriptor();
56 ~UsbInterfaceDescriptor();
58 uint8_t interface_number;
59 uint8_t alternate_setting;
60 uint8_t interface_class;
61 uint8_t interface_subclass;
62 uint8_t interface_protocol;
63 std::vector<UsbEndpointDescriptor> endpoints;
64 std::vector<uint8_t> extra_data;
67 struct UsbConfigDescriptor {
68 UsbConfigDescriptor();
69 ~UsbConfigDescriptor();
71 uint8_t configuration_value;
72 bool self_powered;
73 bool remote_wakeup;
74 uint16_t maximum_power;
75 std::vector<UsbInterfaceDescriptor> interfaces;
76 std::vector<uint8_t> extra_data;
79 bool ParseUsbStringDescriptor(const std::vector<uint8_t>& descriptor,
80 base::string16* output);
82 } // namespace device
84 #endif // DEVICE_USB_USB_DESCRIPTORS_H_