• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use super::xhci_transfer::XhciTransfer;
6 use crate::usb::host_backend::error::Result;
7 use usb_util::DeviceSpeed;
8 
9 /// Address of this usb device, as in Set Address standard usb device request.
10 pub type UsbDeviceAddress = u32;
11 
12 /// The type USB device provided by the backend device.
13 #[derive(PartialEq, Eq)]
14 pub enum BackendType {
15     Usb2,
16     Usb3,
17 }
18 
19 /// Xhci backend device is a virtual device connected to xHCI controller. It handles xhci transfers.
20 pub trait XhciBackendDevice: Send {
21     /// Returns the type of USB device provided by this device.
get_backend_type(&self) -> BackendType22     fn get_backend_type(&self) -> BackendType;
23     /// Get vendor id of this device.
get_vid(&self) -> u1624     fn get_vid(&self) -> u16;
25     /// Get product id of this device.
get_pid(&self) -> u1626     fn get_pid(&self) -> u16;
27     /// Submit a xhci transfer to backend.
submit_transfer(&mut self, transfer: XhciTransfer) -> Result<()>28     fn submit_transfer(&mut self, transfer: XhciTransfer) -> Result<()>;
29     /// Set address of this backend.
set_address(&mut self, address: UsbDeviceAddress)30     fn set_address(&mut self, address: UsbDeviceAddress);
31     /// Reset the backend device.
reset(&mut self) -> Result<()>32     fn reset(&mut self) -> Result<()>;
33     /// Get speed of this device.
get_speed(&self) -> Option<DeviceSpeed>34     fn get_speed(&self) -> Option<DeviceSpeed>;
35 }
36