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;
56 array<InterfaceInfo> interfaces;
67 uint16 device_version;
70 string? serial_number;
71 array<ConfigurationInfo> configurations;
74 struct ControlTransferParams {
75 ControlTransferType type;
76 ControlTransferRecipient recipient;
83 // The transfer completed successfully.
86 // The transfer failed due to a non-specific error.
89 // The transfer timed out.
92 // The transfer was cancelled.
95 // The transfer stalled.
98 // The transfer failed because the device was disconnected from the host.
101 // The transfer succeeded, but the device sent more data than was requested.
102 // This applies only to inbound transfers.
105 // The transfer succeeded, but the device sent less data than was requested.
106 // This applies only to inbound transfers.
111 // Closes the device. Calling this effectively invalidates the Device object.
114 // Retrieve a DeviceInfo struct containing metadata about the device,
115 // including the set of all available device configurations. May return null
116 // if the device has been closed.
117 GetDeviceInfo() => (DeviceInfo? info);
119 // Initiates a device control transfer to set the device's configuration to
120 // one with the configuration value |value|.
121 SetConfiguration(uint8 value) => (bool success);
123 // Claims a single interface in the current device configuration.
124 ClaimInterface(uint8 interface_number) => (bool success);
126 // Releases a claimed interface in the current device configuration.
127 ReleaseInterface(uint8 interface_number) => (bool success);
129 // Selects an alternate setting for a given claimed interface.
130 SetInterfaceAlternateSetting(uint8 interface_number, uint8 alternate_setting)
133 // Resets the device.
134 Reset() => (bool success);
136 // Initiates an inbound control transfer request. |params| determine the
137 // details of the request. Transfers to recipients other than DEVICE require a
138 // corresponding interface to be claimed.
140 // |length| specifies the expected number of bytes to receive for this
141 // transfer. The size of |data| will never exceed |length|, and |data| will be
142 // null if |status| is neither COMPLETED, BABBLE, or SHORT_PACKET.
144 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
145 // indicates no timeout: the request will remain pending indefinitely until
146 // completed or otherwise terminated.
147 ControlTransferIn(ControlTransferParams params, uint32 length, uint32 timeout)
148 => (TransferStatus status, array<uint8>? data);
150 // Initiates an inbound control transfer request. |params| determine the
151 // details of the request. Transfers to recipients other than DEVICE require a
152 // corresponding interface to be claimed.
154 // |data| specifies the bytes to send the device in the body of the request.
156 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
157 // indicates no timeout: the request will remain pending indefinitely until
158 // completed or otherwise terminated.
159 ControlTransferOut(ControlTransferParams params,
162 => (TransferStatus status);
164 // Initiates an inbound bulk transfer request on a specific endpoint. The
165 // interface to which |endpoint_number| belongs must be claimed, and the
166 // appropriate alternate setting must be set on that interface before
167 // transfers can be initiated on the endpoint. The endpoint must be of type
170 // |length| specifies the expected number of bytes to receive for this
171 // transfer. The size of |data| will never exceed |length|, and |data| will be
172 // null if |status| is neither COMPLETED, BABBLE, or SHORT_PACKET.
174 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
175 // indicates no timeout: the request will remain pending indefinitely until
176 // completed or otherwise terminated.
177 BulkTransferIn(uint8 endpoint_number, uint32 length, uint32 timeout)
178 => (TransferStatus status, array<uint8>? data);
180 // Initiates an outbound bulk transfer request on a specific endpoint. The
181 // interface to which |endpoint_number| belongs must be claimed, and the
182 // appropriate alternate setting must be set on that interface before
183 // transfers can be initiated on the endpoint. The endpoint must be of type
186 // |data| specifies the bytes to send the device in the body of the request.
188 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
189 // indicates no timeout: the request will remain pending indefinitely until
190 // completed or otherwise terminated.
191 BulkTransferOut(uint8 endpoint_number, array<uint8> data, uint32 timeout)
192 => (TransferStatus status);
194 // Initiates an inbound interrupt transfer request on a specific endpoint. The
195 // interface to which |endpoint_number| belongs must be claimed, and the
196 // appropriate alternate setting must be set on that interface before
197 // transfers can be initiated on the endpoint. The endpoint must be of type
200 // |length| specifies the expected number of bytes to receive for this
201 // transfer. The size of |data| will never exceed |length|, and |data| will be
202 // null if |status| is neither COMPLETED, BABBLE, or SHORT_PACKET.
204 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
205 // indicates no timeout: the request will remain pending indefinitely until
206 // completed or otherwise terminated.
207 InterruptTransferIn(uint8 endpoint_number, uint32 length, uint32 timeout)
208 => (TransferStatus status, array<uint8>? data);
210 // Initiates an outbound interrupt transfer request on a specific endpoint.
211 // The interface to which |endpoint_number| belongs must be claimed, and the
212 // appropriate alternate setting must be set on that interface before
213 // transfers can be initiated on the endpoint. The endpoint must be of type
216 // |data| specifies the bytes to send the device in the body of the request.
218 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
219 // indicates no timeout: the request will remain pending indefinitely until
220 // completed or otherwise terminated.
221 InterruptTransferOut(uint8 endpoint_number, array<uint8> data, uint32 timeout)
222 => (TransferStatus status);
224 // Initiates an inbound 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 // |packet_length| specifies the maximum expected number of bytes to receive
231 // for each packet in this transfer. |num_packets| specifies the maximum total
232 // number of packets to receive.
234 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
235 // indicates no timeout: the request will remain pending indefinitely until
236 // completed or otherwise terminated.
238 // |packets| contains the set of packets received from the device, in order.
239 // No received packet's size will exceed |packet_length|, and will be null
240 // if |status| is neither COMPLETED, BABBLE, or SHORT_PACKET.
241 IsochronousTransferIn(uint8 endpoint_number,
243 uint32 packet_length,
245 => (TransferStatus status, array<array<uint8>>? packets);
247 // Initiates an outbound isochronous transfer request on a specific endpoint.
248 // The interface to which |endpoint_number| belongs must be claimed, and the
249 // appropriate alternate setting must be set on that interface before
250 // transfers can be initiated on the endpoint. The endpoint must be of type
253 // |packets| specifies the series of data packets to send to the device for
256 // |timeout| specifies the request timeout in milliseconds. A timeout of 0
257 // indicates no timeout: the request will remain pending indefinitely until
258 // completed or otherwise terminated.
259 IsochronousTransferOut(uint8 endpoint_number,
260 array<array<uint8>> packets,
262 => (TransferStatus status);