blob: b8977533b312770849d5c4e4baf8209312d6a5c3 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.hardware.usb.peripheral;
using zx;
struct FunctionDescriptor {
uint8 interface_class;
uint8 interface_subclass;
uint8 interface_protocol;
};
// The fields in DeviceDescriptor match those in usb_descriptor_t in the USB specification.
struct DeviceDescriptor {
uint16 bcdUSB;
uint8 bDeviceClass;
uint8 bDeviceSubClass;
uint8 bDeviceProtocol;
uint8 bMaxPacketSize0;
uint16 idVendor;
uint16 idProduct;
uint16 bcdDevice;
uint8 iManufacturer;
uint8 iProduct;
uint8 iSerialNumber;
uint8 bNumConfigurations;
};
const uint32 MAX_STRING_LENGTH = 127;
[Layout = "Simple"]
interface Device {
// Sets the device's USB device descriptor.
1: SetDeviceDescriptor(DeviceDescriptor desc) -> (zx.status s);
// Sets a string descriptor a string in the USB device descriptor.
2: AllocStringDesc(string:MAX_STRING_LENGTH name) -> (zx.status s, uint8 index);
// Adds a new function to the USB current configuration.
// Must be called before BindFunctions or after ClearFunctions.
3: AddFunction(FunctionDescriptor desc) -> (zx.status s);
// Tells the device to create child devices for the configuration's interfaces.
4: BindFunctions() -> (zx.status s);
// Tells the device to remove the child devices for the configuration's interfaces
// and reset the list of functions to empty.
5: ClearFunctions() -> (zx.status s);
// Returns the current USB mode.
6: GetMode() -> (zx.status s, uint32 mode);
// Sets the current USB mode.
7: SetMode(uint32 mode) -> (zx.status s);
};