1// Copyright 2016 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
5#pragma once
6
7#include <ddk/device.h>
8
9zx_status_t usb_util_control(usb_device_t* dev, uint8_t request_type,  uint8_t request,
10                             uint16_t value, uint16_t index, void* data, size_t length);
11
12zx_status_t usb_util_get_descriptor(usb_device_t* dev, uint16_t type, uint16_t index,
13                                    uint16_t language, void* data, size_t length);
14
15// Fetch the descriptor using the provided descriptor ID and language ID.  If
16// the language ID requested is not available, the first entry of the language
17// ID table will be used instead and be provided in the updated version of the
18// parameter.
19//
20// The string will be encoded using UTF-8, and will be truncated to fit the
21// space provided by the buflen parameter.  buflen will be updated to indicate
22// the amount of space needed to hold the actual UTF-8 encoded string lenth, and
23// may be larger than the original value passed.  Embedded nulls may be present
24// in the string, and the result may not be null terminated if the string
25// occupies the entire provided buffer.
26//
27zx_status_t usb_util_get_string_descriptor(usb_device_t* dev, uint8_t desc_id,
28                                           uint16_t* inout_lang_id, uint8_t* buf,
29                                           size_t* inout_buflen);
30