pub enum UsbRequest {
ConnectToEndpoint {
ep_addr: u8,
ep: ServerEnd<EndpointMarker>,
responder: UsbConnectToEndpointResponder,
},
GetDeviceSpeed {
responder: UsbGetDeviceSpeedResponder,
},
GetDeviceId {
responder: UsbGetDeviceIdResponder,
},
GetDeviceDescriptor {
responder: UsbGetDeviceDescriptorResponder,
},
GetConfigurationDescriptor {
config: u8,
responder: UsbGetConfigurationDescriptorResponder,
},
GetConfiguration {
responder: UsbGetConfigurationResponder,
},
SetConfiguration {
configuration: u8,
responder: UsbSetConfigurationResponder,
},
SetInterface {
interface_number: u8,
alt_setting: u8,
responder: UsbSetInterfaceResponder,
},
ControlTransfer {
setup: UsbSetup,
timeout_ns: i64,
write_data: Vec<u8>,
responder: UsbControlTransferResponder,
},
EnableEndpoint {
ep_desc: UsbEndpointDescriptor,
ss_com_desc: UsbSsEpCompDescriptor,
enable: bool,
responder: UsbEnableEndpointResponder,
},
ResetEndpoint {
ep_address: u8,
responder: UsbResetEndpointResponder,
},
#[non_exhaustive] _UnknownMethod {
ordinal: u64,
control_handle: UsbControlHandle,
method_type: MethodType,
},
}Expand description
Protocol for managing and communicating with an attached USB device on the host bus.
Unless otherwise noted, methods on this protocol reply only after the corresponding USB bus transaction (if any) and host controller state update have completed.
Variants§
ConnectToEndpoint
Connects a channel to the specified USB endpoint (ep_addr).
Endpoint 0 (the default control pipe) cannot be connected via this method; use
[ControlTransfer] instead.
Closing the [Usb] channel does not automatically close open [Endpoint] channels, which
remain bound to the underlying host controller until explicitly closed by the client or
disconnected when the physical USB device is unplugged.
- error:
ZX_ERR_INVALID_ARGSifep_addrrefers to endpoint 0 or an endpoint number > 15.ZX_ERR_NOT_FOUNDif the device or endpoint address does not exist.ZX_ERR_ALREADY_BOUNDif the endpoint is already bound to an active channel.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.
GetDeviceSpeed
Returns the negotiated bus speed of the USB device.
Fields
responder: UsbGetDeviceSpeedResponderGetDeviceId
Returns the internal device ID assigned by the USB host controller / bus driver.
Fields
responder: UsbGetDeviceIdResponderGetDeviceDescriptor
Returns the USB device descriptor.
Fields
responder: UsbGetDeviceDescriptorResponderGetConfigurationDescriptor
Returns the full raw configuration descriptor hierarchy (in standard USB wire format) for
the configuration with bConfigurationValue == config.
- error:
ZX_ERR_INVALID_ARGSifconfigdoes not match any configuration descriptor on the device.
GetConfiguration
Returns the bConfigurationValue of the currently active USB configuration.
Fields
responder: UsbGetConfigurationResponderSetConfiguration
Selects the active USB configuration (SET_CONFIGURATION) and updates the host controller
state.
Replies after the SET_CONFIGURATION control transfer and controller state update complete.
- error:
ZX_ERR_INVALID_ARGSifconfigurationdoes not match any configuration on the device.ZX_ERR_TIMED_OUTif the control transfer times out.ZX_ERR_IO_REFUSEDif the device stalls the request.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.ZX_ERR_NOT_SUPPORTEDif invoked on an interface-scoped connection that prohibits device-wide configuration changes.
SetInterface
Selects an alternate setting for the specified USB interface (SET_INTERFACE) and updates
the host controller state.
Replies after the SET_INTERFACE control transfer and controller state update complete.
- error:
ZX_ERR_INVALID_ARGSifinterface_numberoralt_settingis invalid.ZX_ERR_TIMED_OUTif the control transfer times out.ZX_ERR_IO_REFUSEDif the device stalls the request.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.
ControlTransfer
Performs a synchronous USB control transfer (IN or OUT) over endpoint 0.
Replies after the control transaction completes on the bus (and any associated host
controller state updates for standard SET_CONFIGURATION or SET_INTERFACE requests
finish).
While this method can be used to read descriptors, prefer [GetDeviceDescriptor] and
[GetConfigurationDescriptor] when reading descriptors.
If timeout_ns is 0 or negative, a default 5-second timeout is used (per USB 2.0
Section 9.2.6.4).
- error:
ZX_ERR_INVALID_ARGSif the setup packet length orwrite_datasize is invalid.ZX_ERR_TIMED_OUTif the control transfer does not complete within the timeout.ZX_ERR_IO_REFUSEDif the device returns a STALL handshake.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.ZX_ERR_NOT_SUPPORTEDif the server does not support raw control transfers.
EnableEndpoint
Enables or disables a USB endpoint on the host controller, configuring it as specified by the provided descriptors.
Replies after the host controller has updated its endpoint context and transfer ring state.
- error:
ZX_ERR_INVALID_ARGSif the endpoint descriptor is invalid.ZX_ERR_NO_RESOURCESif the host controller lacks bandwidth or resources.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.ZX_ERR_NOT_SUPPORTEDif the server does not support direct endpoint configuration.
Fields
ep_desc: UsbEndpointDescriptorss_com_desc: UsbSsEpCompDescriptorresponder: UsbEnableEndpointResponderResetEndpoint
Resets an endpoint on the host controller that is in a halted or error state, returning the host controller’s endpoint ring and data toggle to a normal running state.
Note: To clear a halt condition on a non-control endpoint, clients should also issue a
standard CLEAR_FEATURE(ENDPOINT_HALT) control request to the device to reset the device’s
data toggle to DATA0.
- error:
ZX_ERR_INVALID_ARGSif the endpoint is not halted or the address is invalid.ZX_ERR_IO_NOT_PRESENTif the device has been disconnected.
#[non_exhaustive]_UnknownMethod
An interaction was received which does not match any known method.
Fields
This variant is marked as non-exhaustive
control_handle: UsbControlHandlemethod_type: MethodTypeImplementations§
Source§impl UsbRequest
impl UsbRequest
pub fn into_connect_to_endpoint( self, ) -> Option<(u8, ServerEnd<EndpointMarker>, UsbConnectToEndpointResponder)>
pub fn into_get_device_speed(self) -> Option<UsbGetDeviceSpeedResponder>
pub fn into_get_device_id(self) -> Option<UsbGetDeviceIdResponder>
pub fn into_get_device_descriptor( self, ) -> Option<UsbGetDeviceDescriptorResponder>
pub fn into_get_configuration_descriptor( self, ) -> Option<(u8, UsbGetConfigurationDescriptorResponder)>
pub fn into_get_configuration(self) -> Option<UsbGetConfigurationResponder>
pub fn into_set_configuration( self, ) -> Option<(u8, UsbSetConfigurationResponder)>
pub fn into_set_interface(self) -> Option<(u8, u8, UsbSetInterfaceResponder)>
pub fn into_control_transfer( self, ) -> Option<(UsbSetup, i64, Vec<u8>, UsbControlTransferResponder)>
pub fn into_enable_endpoint( self, ) -> Option<(UsbEndpointDescriptor, UsbSsEpCompDescriptor, bool, UsbEnableEndpointResponder)>
pub fn into_reset_endpoint(self) -> Option<(u8, UsbResetEndpointResponder)>
Sourcepub fn method_name(&self) -> &'static str
pub fn method_name(&self) -> &'static str
Name of the method defined in FIDL