1// Copyright 2018 The Fuchsia 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.
4
5library ddk.protocol.usb.dci;
6
7using ddk.protocol.usb.request;
8using zircon.hw.usb;
9using zx;
10
11[Layout = "ddk-protocol"]
12interface UsbDci {
13    /// Queues a USB request with the DCI driver.
14    RequestQueue(ddk.protocol.usb.request.UsbRequest? usb_request,
15                 ddk.protocol.usb.request.UsbRequestComplete? complete_cb) -> ();
16    /// Registers callback interface with the DCI driver.
17    SetInterface(UsbDciInterface @interface) -> (zx.status s);
18    /// Configures an endpoint based on provided descriptors.
19    ConfigEp(zircon.hw.usb.UsbEndpointDescriptor ep_desc,
20                zircon.hw.usb.UsbSsEpCompDescriptor ss_comp_desc) -> (zx.status s);
21    /// Disables the specified endpoint.
22    DisableEp(uint8 ep_address) -> (zx.status s);
23    /// Stalls the specified endpoint.
24    EpSetStall(uint8 ep_address) -> (zx.status s);
25    /// Clears a stall condition for the specified endpoint.
26    EpClearStall(uint8 ep_address) -> (zx.status s);
27    /// Returns the size needed for a |usb_request_t|, including private storage needed by the
28    /// HCI driver.
29    GetRequestSize() -> (usize size);
30};
31
32/// Interface for use by the DCI controller to call into the USB peripheral driver.
33[Layout = "ddk-interface"]
34interface UsbDciInterface {
35    /// Callback for handling ep0 control requests.
36    Control(zircon.hw.usb.UsbSetup setup, vector<voidptr> write) -> (zx.status status,
37                                                                     vector<voidptr> read);
38    /// Notifies change in USB connected state.
39    SetConnected(bool connected) -> ();
40    /// Notifies current USB speed..
41    SetSpeed(zircon.hw.usb.UsbSpeed speed) -> ();
42};
43