Path: blob/main/devices/src/usb/xhci/xhci_backend_device.rs
5394 views
// Copyright 2019 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34use usb_util::DeviceSpeed;56use crate::usb::backend::error::Result;78/// Address of this usb device, as in Set Address standard usb device request.9pub type UsbDeviceAddress = u32;1011/// The type USB device provided by the backend device.12#[derive(PartialEq, Eq)]13pub enum BackendType {14Usb2,15Usb3,16}1718/// Xhci backend device is a virtual device connected to xHCI controller. It handles xhci transfers.19pub trait XhciBackendDevice: Send + Sync {20/// Returns the type of USB device provided by this device.21fn get_backend_type(&self) -> BackendType;22/// Get vendor id of this device.23fn get_vid(&self) -> u16;24/// Get product id of this device.25fn get_pid(&self) -> u16;26/// Set address of this backend.27fn set_address(&mut self, address: UsbDeviceAddress);28/// Reset the backend device.29fn reset(&mut self) -> Result<()>;30/// Get speed of this device.31fn get_speed(&self) -> Option<DeviceSpeed>;32/// Allocate streams for the endpoint33fn alloc_streams(&self, ep: u8, num_streams: u16) -> Result<()>;34/// Free streams for the endpoint35fn free_streams(&self, ep: u8) -> Result<()>;36/// Stop the backend device, allowing it to execute cleanup routines.37fn stop(&mut self);38}394041