OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_USB_USB_DESCRIPTORS_H_ | 5 #ifndef DEVICE_USB_USB_DESCRIPTORS_H_ |
6 #define DEVICE_USB_USB_DESCRIPTORS_H_ | 6 #define DEVICE_USB_USB_DESCRIPTORS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 UsbInterfaceDescriptor() = delete; | 78 UsbInterfaceDescriptor() = delete; |
79 ~UsbInterfaceDescriptor(); | 79 ~UsbInterfaceDescriptor(); |
80 | 80 |
81 uint8_t interface_number; | 81 uint8_t interface_number; |
82 uint8_t alternate_setting; | 82 uint8_t alternate_setting; |
83 uint8_t interface_class; | 83 uint8_t interface_class; |
84 uint8_t interface_subclass; | 84 uint8_t interface_subclass; |
85 uint8_t interface_protocol; | 85 uint8_t interface_protocol; |
86 std::vector<UsbEndpointDescriptor> endpoints; | 86 std::vector<UsbEndpointDescriptor> endpoints; |
87 std::vector<uint8_t> extra_data; | 87 std::vector<uint8_t> extra_data; |
| 88 // First interface of the function to which this interface belongs. |
| 89 uint8_t first_interface; |
88 }; | 90 }; |
89 | 91 |
90 struct UsbConfigDescriptor { | 92 struct UsbConfigDescriptor { |
91 UsbConfigDescriptor(uint8_t configuration_value, | 93 UsbConfigDescriptor(uint8_t configuration_value, |
92 bool self_powered, | 94 bool self_powered, |
93 bool remote_wakeup, | 95 bool remote_wakeup, |
94 uint16_t maximum_power); | 96 uint16_t maximum_power); |
95 UsbConfigDescriptor() = delete; | 97 UsbConfigDescriptor() = delete; |
96 ~UsbConfigDescriptor(); | 98 ~UsbConfigDescriptor(); |
97 | 99 |
| 100 // Scans through |extra_data| for interface association descriptors and |
| 101 // populates |first_interface| for each interface in this configuration. |
| 102 void AssignFirstInterfaceNumbers(); |
| 103 |
98 uint8_t configuration_value; | 104 uint8_t configuration_value; |
99 bool self_powered; | 105 bool self_powered; |
100 bool remote_wakeup; | 106 bool remote_wakeup; |
101 uint16_t maximum_power; | 107 uint16_t maximum_power; |
102 std::vector<UsbInterfaceDescriptor> interfaces; | 108 std::vector<UsbInterfaceDescriptor> interfaces; |
103 std::vector<uint8_t> extra_data; | 109 std::vector<uint8_t> extra_data; |
104 }; | 110 }; |
105 | 111 |
106 bool ParseUsbStringDescriptor(const std::vector<uint8_t>& descriptor, | 112 bool ParseUsbStringDescriptor(const std::vector<uint8_t>& descriptor, |
107 base::string16* output); | 113 base::string16* output); |
108 | 114 |
109 void ReadUsbStringDescriptors( | 115 void ReadUsbStringDescriptors( |
110 scoped_refptr<UsbDeviceHandle> device_handle, | 116 scoped_refptr<UsbDeviceHandle> device_handle, |
111 scoped_ptr<std::map<uint8_t, base::string16>> index_map, | 117 scoped_ptr<std::map<uint8_t, base::string16>> index_map, |
112 const base::Callback<void(scoped_ptr<std::map<uint8_t, base::string16>>)>& | 118 const base::Callback<void(scoped_ptr<std::map<uint8_t, base::string16>>)>& |
113 callback); | 119 callback); |
114 | 120 |
115 } // namespace device | 121 } // namespace device |
116 | 122 |
117 #endif // DEVICE_USB_USB_DESCRIPTORS_H_ | 123 #endif // DEVICE_USB_USB_DESCRIPTORS_H_ |
OLD | NEW |