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
3 // found in the LICENSE file.
7 enum TransferDirection {
12 enum ControlTransferType {
19 enum ControlTransferRecipient {
33 uint8 endpoint_number;
34 TransferDirection direction;
39 struct AlternateInterfaceInfo {
40 uint8 alternate_setting;
44 string? interface_name;
45 array<EndpointInfo> endpoints;
48 struct InterfaceInfo {
49 uint8 interface_number;
50 array<AlternateInterfaceInfo> alternates;
53 struct ConfigurationInfo {
54 uint8 configuration_value;
55 string? configuration_name;
56 array<InterfaceInfo> interfaces;
61 uint8 usb_version_major;
62 uint8 usb_version_minor;
63 uint8 usb_version_subminor;
69 uint8 device_version_major;
70 uint8 device_version_minor;
71 uint8 device_version_subminor;
72 string? manufacturer_name;
74 string? serial_number;
75 array<ConfigurationInfo> configurations;
78 struct ControlTransferParams {
79 ControlTransferType type;
80 ControlTransferRecipient recipient;
87 // The transfer completed successfully.
90 // The transfer failed due to a non-specific error.
93 // The transfer timed out.
96 // The transfer was cancelled.
99 // The transfer stalled.
102 // The transfer failed because the device was disconnected from the host.
105 // The transfer succeeded, but the device sent more data than was requested.
106 // This applies only to inbound transfers.
109 // The transfer succeeded, but the device sent less data than was requested.
110 // This applies only to inbound transfers.
115 // Closes the device. Calling this effectively invalidates the Device object.
118 // Retrieve a DeviceInfo struct containing metadata about the device,
119 // including the set of all available device configurations. May return null
120 // if the device has been closed.
121 GetDeviceInfo() => (DeviceInfo? info);
123 // Initiates a device control transfer to set the device's configuration to
124 // one with the configuration value |value|.
125 SetConfiguration(uint8 value) => (bool success);
127 // Claims a single interface in the current device configuration.
128 ClaimInterface(uint8 interface_number) => (bool success);
130 // Releases a claimed interface in the current device configuration.
131 ReleaseInterface(uint8 interface_number) => (bool success);
133 // Selects an alternate setting for a given claimed interface.
134 SetInterfaceAlternateSetting(uint8 interface_number, uint8 alternate_setting)
137 // Resets the device.
138 Reset() => (bool success);
140 // Clear the halt/stall condition for an endpoint.
141 ClearHalt(uint8 endpoint) => (bool success);
143 // Initiates an inbound control transfer request. |params| determine the
144 // details of the request. Transfers to recipients other than DEVICE require a
145 // corresponding interface to be claimed.
147 // |length| specifies the expected number of bytes to receive for this
148 // transfer. The size of |data| will never exceed |length|, and |data| will be
149 // null if |status| is neither COMPLETED, BABBLE, or SHORT_PACKET.
151 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
152 // indicates no timeout: the request will remain pending indefinitely until
153 // completed or otherwise terminated.
154 ControlTransferIn(ControlTransferParams params, uint32 length, uint32 timeout)
155 => (TransferStatus status, array<uint8>? data);
157 // Initiates an inbound control transfer request. |params| determine the
158 // details of the request. Transfers to recipients other than DEVICE require a
159 // corresponding interface to be claimed.
161 // |data| specifies the bytes to send the device in the body of the request.
163 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
164 // indicates no timeout: the request will remain pending indefinitely until
165 // completed or otherwise terminated.
166 ControlTransferOut(ControlTransferParams params,
169 => (TransferStatus status);
171 // Initiates an inbound generic transfer request on a specific endpoint. The
172 // interface to which |endpoint_number| belongs must be claimed, and the
173 // appropriate alternate setting must be set on that interface before
174 // transfers can be initiated on the endpoint. The endpoint must be of type
175 // BULK or INTERRUPT.
177 // |length| specifies the expected number of bytes to receive for this
178 // transfer. The size of |data| will never exceed |length|, and |data| will be
179 // null if |status| is neither COMPLETED, BABBLE, or SHORT_PACKET.
181 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
182 // indicates no timeout: the request will remain pending indefinitely until
183 // completed or otherwise terminated.
184 GenericTransferIn(uint8 endpoint_number, uint32 length, uint32 timeout)
185 => (TransferStatus status, array<uint8>? data);
187 // Initiates an outbound generic transfer request on a specific endpoint. The
188 // interface to which |endpoint_number| belongs must be claimed, and the
189 // appropriate alternate setting must be set on that interface before
190 // transfers can be initiated on the endpoint. The endpoint must be of type
191 // BULK or INTERRUPT.
193 // |data| specifies the bytes to send the device in the body of the request.
195 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
196 // indicates no timeout: the request will remain pending indefinitely until
197 // completed or otherwise terminated.
198 GenericTransferOut(uint8 endpoint_number, array<uint8> data, uint32 timeout)
199 => (TransferStatus status);
201 // Initiates an inbound isochronous transfer request on a specific endpoint.
202 // The interface to which |endpoint_number| belongs must be claimed, and the
203 // appropriate alternate setting must be set on that interface before
204 // transfers can be initiated on the endpoint. The endpoint must be of type
207 // |packet_length| specifies the maximum expected number of bytes to receive
208 // for each packet in this transfer. |num_packets| specifies the maximum total
209 // number of packets to receive.
211 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
212 // indicates no timeout: the request will remain pending indefinitely until
213 // completed or otherwise terminated.
215 // |packets| contains the set of packets received from the device, in order.
216 // No received packet's size will exceed |packet_length|, and will be null
217 // if |status| is neither COMPLETED, BABBLE, or SHORT_PACKET.
218 IsochronousTransferIn(uint8 endpoint_number,
220 uint32 packet_length,
222 => (TransferStatus status, array<array<uint8>>? packets);
224 // Initiates an outbound isochronous transfer request on a specific endpoint.
225 // The interface to which |endpoint_number| belongs must be claimed, and the
226 // appropriate alternate setting must be set on that interface before
227 // transfers can be initiated on the endpoint. The endpoint must be of type
230 // |packets| specifies the series of data packets to send to the device for
233 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
234 // indicates no timeout: the request will remain pending indefinitely until
235 // completed or otherwise terminated.
236 IsochronousTransferOut(uint8 endpoint_number,
237 array<array<uint8>> packets,
239 => (TransferStatus status);