Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: device/usb/usb_descriptors.h

Issue 1468423003: Construct USB descriptors over explicit values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Android code. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/usb/usb_configuration_android.cc ('k') | device/usb/usb_descriptors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 USB_SYNCHRONIZATION_SYNCHRONOUS, 42 USB_SYNCHRONIZATION_SYNCHRONOUS,
43 }; 43 };
44 44
45 enum UsbUsageType { 45 enum UsbUsageType {
46 USB_USAGE_DATA = 0, 46 USB_USAGE_DATA = 0,
47 USB_USAGE_FEEDBACK, 47 USB_USAGE_FEEDBACK,
48 USB_USAGE_EXPLICIT_FEEDBACK 48 USB_USAGE_EXPLICIT_FEEDBACK
49 }; 49 };
50 50
51 struct UsbEndpointDescriptor { 51 struct UsbEndpointDescriptor {
52 UsbEndpointDescriptor(); 52 UsbEndpointDescriptor(uint8_t address,
53 UsbEndpointDirection direction,
54 uint16_t maximum_packet_size,
55 UsbSynchronizationType synchronization_type,
56 UsbTransferType transfer_type,
57 UsbUsageType usage_type,
58 uint16_t polling_interval);
59 UsbEndpointDescriptor() = delete;
53 ~UsbEndpointDescriptor(); 60 ~UsbEndpointDescriptor();
54 61
55 uint8_t address; 62 uint8_t address;
56 UsbEndpointDirection direction; 63 UsbEndpointDirection direction;
57 uint16_t maximum_packet_size; 64 uint16_t maximum_packet_size;
58 UsbSynchronizationType synchronization_type; 65 UsbSynchronizationType synchronization_type;
59 UsbTransferType transfer_type; 66 UsbTransferType transfer_type;
60 UsbUsageType usage_type; 67 UsbUsageType usage_type;
61 uint16_t polling_interval; 68 uint16_t polling_interval;
62 std::vector<uint8_t> extra_data; 69 std::vector<uint8_t> extra_data;
63 }; 70 };
64 71
65 struct UsbInterfaceDescriptor { 72 struct UsbInterfaceDescriptor {
66 UsbInterfaceDescriptor(); 73 UsbInterfaceDescriptor(uint8_t interface_number,
74 uint8_t alternate_setting,
75 uint8_t interface_class,
76 uint8_t interface_subclass,
77 uint8_t interface_protocol);
78 UsbInterfaceDescriptor() = delete;
67 ~UsbInterfaceDescriptor(); 79 ~UsbInterfaceDescriptor();
68 80
69 uint8_t interface_number; 81 uint8_t interface_number;
70 uint8_t alternate_setting; 82 uint8_t alternate_setting;
71 uint8_t interface_class; 83 uint8_t interface_class;
72 uint8_t interface_subclass; 84 uint8_t interface_subclass;
73 uint8_t interface_protocol; 85 uint8_t interface_protocol;
74 std::vector<UsbEndpointDescriptor> endpoints; 86 std::vector<UsbEndpointDescriptor> endpoints;
75 std::vector<uint8_t> extra_data; 87 std::vector<uint8_t> extra_data;
76 }; 88 };
77 89
78 struct UsbConfigDescriptor { 90 struct UsbConfigDescriptor {
79 UsbConfigDescriptor(); 91 UsbConfigDescriptor(uint8_t configuration_value,
92 bool self_powered,
93 bool remote_wakeup,
94 uint16_t maximum_power);
95 UsbConfigDescriptor() = delete;
80 ~UsbConfigDescriptor(); 96 ~UsbConfigDescriptor();
81 97
82 uint8_t configuration_value; 98 uint8_t configuration_value;
83 bool self_powered; 99 bool self_powered;
84 bool remote_wakeup; 100 bool remote_wakeup;
85 uint16_t maximum_power; 101 uint16_t maximum_power;
86 std::vector<UsbInterfaceDescriptor> interfaces; 102 std::vector<UsbInterfaceDescriptor> interfaces;
87 std::vector<uint8_t> extra_data; 103 std::vector<uint8_t> extra_data;
88 }; 104 };
89 105
90 bool ParseUsbStringDescriptor(const std::vector<uint8_t>& descriptor, 106 bool ParseUsbStringDescriptor(const std::vector<uint8_t>& descriptor,
91 base::string16* output); 107 base::string16* output);
92 108
93 void ReadUsbStringDescriptors( 109 void ReadUsbStringDescriptors(
94 scoped_refptr<UsbDeviceHandle> device_handle, 110 scoped_refptr<UsbDeviceHandle> device_handle,
95 scoped_ptr<std::map<uint8_t, base::string16>> index_map, 111 scoped_ptr<std::map<uint8_t, base::string16>> index_map,
96 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>>)>&
97 callback); 113 callback);
98 114
99 } // namespace device 115 } // namespace device
100 116
101 #endif // DEVICE_USB_USB_DESCRIPTORS_H_ 117 #endif // DEVICE_USB_USB_DESCRIPTORS_H_
OLDNEW
« no previous file with comments | « device/usb/usb_configuration_android.cc ('k') | device/usb/usb_descriptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698