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; | |
90 }; | 88 }; |
91 | 89 |
92 struct UsbConfigDescriptor { | 90 struct UsbConfigDescriptor { |
93 UsbConfigDescriptor(uint8_t configuration_value, | 91 UsbConfigDescriptor(uint8_t configuration_value, |
94 bool self_powered, | 92 bool self_powered, |
95 bool remote_wakeup, | 93 bool remote_wakeup, |
96 uint16_t maximum_power); | 94 uint16_t maximum_power); |
97 UsbConfigDescriptor() = delete; | 95 UsbConfigDescriptor() = delete; |
98 ~UsbConfigDescriptor(); | 96 ~UsbConfigDescriptor(); |
99 | 97 |
100 // Scans through |extra_data| for interface association descriptors and | |
101 // populates |first_interface| for each interface in this configuration. | |
102 void AssignFirstInterfaceNumbers(); | |
103 | |
104 uint8_t configuration_value; | 98 uint8_t configuration_value; |
105 bool self_powered; | 99 bool self_powered; |
106 bool remote_wakeup; | 100 bool remote_wakeup; |
107 uint16_t maximum_power; | 101 uint16_t maximum_power; |
108 std::vector<UsbInterfaceDescriptor> interfaces; | 102 std::vector<UsbInterfaceDescriptor> interfaces; |
109 std::vector<uint8_t> extra_data; | 103 std::vector<uint8_t> extra_data; |
110 }; | 104 }; |
111 | 105 |
112 bool ParseUsbStringDescriptor(const std::vector<uint8_t>& descriptor, | 106 bool ParseUsbStringDescriptor(const std::vector<uint8_t>& descriptor, |
113 base::string16* output); | 107 base::string16* output); |
114 | 108 |
115 void ReadUsbStringDescriptors( | 109 void ReadUsbStringDescriptors( |
116 scoped_refptr<UsbDeviceHandle> device_handle, | 110 scoped_refptr<UsbDeviceHandle> device_handle, |
117 scoped_ptr<std::map<uint8_t, base::string16>> index_map, | 111 scoped_ptr<std::map<uint8_t, base::string16>> index_map, |
118 const base::Callback<void(scoped_ptr<std::map<uint8_t, base::string16>>)>& | 112 const base::Callback<void(scoped_ptr<std::map<uint8_t, base::string16>>)>& |
119 callback); | 113 callback); |
120 | 114 |
121 } // namespace device | 115 } // namespace device |
122 | 116 |
123 #endif // DEVICE_USB_USB_DESCRIPTORS_H_ | 117 #endif // DEVICE_USB_USB_DESCRIPTORS_H_ |
OLD | NEW |