OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 module device.mojom; | 5 module device.mojom; |
6 | 6 |
7 enum UsbOpenDeviceError { | 7 enum UsbOpenDeviceError { |
8 // Opening the device succeeded. | 8 // Opening the device succeeded. |
9 OK, | 9 OK, |
10 | 10 |
11 // The operating system denied access to the device. | 11 // The operating system denied access to the device. |
12 ACCESS_DENIED, | 12 ACCESS_DENIED, |
13 | 13 |
14 // The device is already open. | 14 // The device is already open. |
15 ALREADY_OPEN, | 15 ALREADY_OPEN, |
16 }; | 16 }; |
17 | 17 |
| 18 // Corresponds to the USBDirection WebIDL type. |
18 enum UsbTransferDirection { | 19 enum UsbTransferDirection { |
19 INBOUND, | 20 INBOUND = 0, |
20 OUTBOUND, | 21 OUTBOUND, |
21 }; | 22 }; |
22 | 23 |
23 enum UsbControlTransferType { | 24 enum UsbControlTransferType { |
24 STANDARD, | 25 STANDARD, |
25 CLASS, | 26 CLASS, |
26 VENDOR, | 27 VENDOR, |
27 RESERVED | 28 RESERVED |
28 }; | 29 }; |
29 | 30 |
| 31 // Corresponds to the USBRecipient WebIDL type. |
30 enum UsbControlTransferRecipient { | 32 enum UsbControlTransferRecipient { |
31 DEVICE, | 33 DEVICE, |
32 INTERFACE, | 34 INTERFACE, |
33 ENDPOINT, | 35 ENDPOINT, |
34 OTHER | 36 OTHER |
35 }; | 37 }; |
36 | 38 |
37 enum UsbEndpointType { | 39 enum UsbTransferType { |
| 40 CONTROL = 0, |
| 41 ISOCHRONOUS, |
38 BULK, | 42 BULK, |
39 INTERRUPT, | 43 INTERRUPT, |
40 ISOCHRONOUS, | |
41 }; | 44 }; |
42 | 45 |
43 struct UsbEndpointInfo { | 46 struct UsbEndpointInfo { |
44 uint8 endpoint_number; | 47 uint8 endpoint_number; |
45 UsbTransferDirection direction; | 48 UsbTransferDirection direction; |
46 UsbEndpointType type; | 49 UsbTransferType type; |
47 uint32 packet_size; | 50 uint32 packet_size; |
48 }; | 51 }; |
49 | 52 |
50 struct UsbAlternateInterfaceInfo { | 53 struct UsbAlternateInterfaceInfo { |
51 uint8 alternate_setting; | 54 uint8 alternate_setting; |
52 uint8 class_code; | 55 uint8 class_code; |
53 uint8 subclass_code; | 56 uint8 subclass_code; |
54 uint8 protocol_code; | 57 uint8 protocol_code; |
55 string? interface_name; | 58 string? interface_name; |
56 array<UsbEndpointInfo> endpoints; | 59 array<UsbEndpointInfo> endpoints; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 }; | 91 }; |
89 | 92 |
90 struct UsbControlTransferParams { | 93 struct UsbControlTransferParams { |
91 UsbControlTransferType type; | 94 UsbControlTransferType type; |
92 UsbControlTransferRecipient recipient; | 95 UsbControlTransferRecipient recipient; |
93 uint8 request; | 96 uint8 request; |
94 uint16 value; | 97 uint16 value; |
95 uint16 index; | 98 uint16 index; |
96 }; | 99 }; |
97 | 100 |
| 101 // This enum is exposed through the chrome.usb extension API so existing values |
| 102 // should not be changed or reordered. |
98 enum UsbTransferStatus { | 103 enum UsbTransferStatus { |
99 // The transfer completed successfully. | 104 // The transfer completed successfully. |
100 COMPLETED, | 105 COMPLETED = 0, |
101 | 106 |
102 // The transfer failed due to a non-specific error. | 107 // The transfer failed due to a non-specific error. |
103 TRANSFER_ERROR, | 108 TRANSFER_ERROR, |
104 | 109 |
105 // The transfer was not allowed. | |
106 PERMISSION_DENIED, | |
107 | |
108 // The transfer timed out. | 110 // The transfer timed out. |
109 TIMEOUT, | 111 TIMEOUT, |
110 | 112 |
111 // The transfer was cancelled. | 113 // The transfer was cancelled. |
112 CANCELLED, | 114 CANCELLED, |
113 | 115 |
114 // The transfer stalled. | 116 // The transfer stalled. |
115 STALLED, | 117 STALLED, |
116 | 118 |
117 // The transfer failed because the device was disconnected from the host. | 119 // The transfer failed because the device was disconnected from the host. |
118 DISCONNECT, | 120 DISCONNECT, |
119 | 121 |
120 // The transfer succeeded, but the device sent more data than was requested. | 122 // The transfer succeeded, but the device sent more data than was requested. |
121 // This applies only to inbound transfers. | 123 // This applies only to inbound transfers. |
122 BABBLE, | 124 BABBLE, |
123 | 125 |
124 // The transfer succeeded, but the device sent less data than was requested. | 126 // The transfer succeeded, but the device sent less data than was requested. |
125 // This applies only to inbound transfers. | 127 // This applies only to inbound transfers. |
126 SHORT_PACKET, | 128 SHORT_PACKET, |
| 129 |
| 130 // The transfer was not allowed. |
| 131 PERMISSION_DENIED, |
127 }; | 132 }; |
128 | 133 |
129 struct UsbIsochronousPacket { | 134 struct UsbIsochronousPacket { |
130 uint32 length; | 135 uint32 length; |
131 uint32 transferred_length; | 136 uint32 transferred_length; |
132 UsbTransferStatus status; | 137 UsbTransferStatus status; |
133 }; | 138 }; |
134 | 139 |
135 interface UsbDevice { | 140 interface UsbDevice { |
136 // Opens the device. Methods below require the device be opened first. | 141 // Opens the device. Methods below require the device be opened first. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // indicates no timeout: the request will remain pending indefinitely until | 262 // indicates no timeout: the request will remain pending indefinitely until |
258 // completed or otherwise terminated. | 263 // completed or otherwise terminated. |
259 | 264 |
260 // |packets| contains the status of each packet sent to the device, in order. | 265 // |packets| contains the status of each packet sent to the device, in order. |
261 IsochronousTransferOut(uint8 endpoint_number, | 266 IsochronousTransferOut(uint8 endpoint_number, |
262 array<uint8> data, | 267 array<uint8> data, |
263 array<uint32> packet_lengths, | 268 array<uint32> packet_lengths, |
264 uint32 timeout) | 269 uint32 timeout) |
265 => (array<UsbIsochronousPacket> packets); | 270 => (array<UsbIsochronousPacket> packets); |
266 }; | 271 }; |
OLD | NEW |