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