# fuchsia.hardware.usb.policy

<br />

Communication between USB driver components and the USB policy manager
In this context, the USB policy manager is the client and the
USB driver components - such as the dwc3 driver - are the servers.

The first supported driver component is for the USB controller hardware,
whether used as USB Host or a USB Device. Any data which does not apply
to the current mode of the controller should be left undefined.
Added: HEAD

## **PROTOCOLS**

## Controller

*Defined in [fuchsia.hardware.usb.policy/controller.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.usb.policy/controller.fidl;l=43)*

Protocol for communicating with a low-level USB hardware controller.

This interface allows the USB policy component to act as a client and monitor
the hardware's state.

<br />

### WatchDeviceState

Notify a client of an updated device state value via a hanging get.
The first time this is called, it will return right away with the
current state. Subsequent calls will hang until there is a change
to report.
Returns a table containing the updated device state.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.usb.policy#DeviceStateWatcher_WatchDeviceState_Result` |

## DeviceStateWatcher

*Defined in [fuchsia.hardware.usb.policy/controller.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.usb.policy/controller.fidl;l=30)*

An interface to watch for updates to the USB device state.

<br />

### WatchDeviceState

Notify a client of an updated device state value via a hanging get.
The first time this is called, it will return right away with the
current state. Subsequent calls will hang until there is a change
to report.
Returns a table containing the updated device state.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.usb.policy#DeviceStateWatcher_WatchDeviceState_Result` |

## **ENUMS**

### DeviceState [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

Type: `uint32`

*Defined in [fuchsia.hardware.usb.policy/controller.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.usb.policy/controller.fidl;l=9)*

Device States mirrors the descriptions in Section 9.1 of the USB 2.0 spec

<br />

| Name | Value | Description |
|---|---|---|
| ### NOT_ATTACHED | `0` |   |
| ### ATTACHED | `1` |   |
| ### POWERED | `2` |   |
| ### DEFAULT | `5` | 3 is reserved for RECONNECTING, which is an unused legacy value for wireless USB 4 is reserved for UNAUTHENTICATED, which is an unused legacy value for wireless USB |
| ### ADDRESS | `6` |   |
| ### CONFIGURED | `7` |   |
| ### SUSPENDED | `8` |   |

## **TABLES**

### DeviceStateUpdate

*Defined in [fuchsia.hardware.usb.policy/controller.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.usb.policy/controller.fidl;l=22)*

A table representing the current state of a USB device.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `state` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.usb.policy#DeviceState` | The current USB device state. |
| ### 2 | `address` | `uint8` | The USB device address. |

## **UNIONS**

### DeviceStateWatcher_WatchDeviceState_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.usb.policy/controller.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.usb.policy/controller.fidl;l=36)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.usb.policy#DeviceStateUpdate` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Status` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

## **SERVICES**

### Service

*Defined in [fuchsia.hardware.usb.policy/controller.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.usb.policy/controller.fidl;l=48)*

| Name | Type | Transport |
|---|---|---|
| [controller](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.usb.policy/controller.fidl;l=50) | `fuchsia.hardware.usb.policy/Controller` | Channel |

<br />