mirror of
https://github.com/zephyrproject-rtos/zephyr.git
synced 2024-12-04 11:39:46 +08:00
a1b77fd589
git grep -l 'u\(8\|16\|32\|64\)_t' | \ xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g" git grep -l 's\(8\|16\|32\|64\)_t' | \ xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g" Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
68 lines
1.5 KiB
C
68 lines
1.5 KiB
C
/*
|
|
* Copyright (c) 2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#define LOG_LEVEL CONFIG_USB_DEVICE_LOG_LEVEL
|
|
#include <logging/log.h>
|
|
LOG_MODULE_REGISTER(usb_bos);
|
|
|
|
#include <zephyr.h>
|
|
|
|
#include <usb/usb_device.h>
|
|
#include <usb/usb_common.h>
|
|
|
|
#include <usb/bos.h>
|
|
|
|
extern const uint8_t __usb_bos_desc_start[];
|
|
extern const uint8_t __usb_bos_desc_end[];
|
|
|
|
USB_DEVICE_BOS_DESC_DEFINE_HDR struct usb_bos_descriptor hdr = {
|
|
.bLength = sizeof(struct usb_bos_descriptor),
|
|
.bDescriptorType = USB_BINARY_OBJECT_STORE_DESC,
|
|
.wTotalLength = 0, /* should be corrected with register */
|
|
.bNumDeviceCaps = 0, /* should be set with register */
|
|
};
|
|
|
|
size_t usb_bos_get_length(void)
|
|
{
|
|
return __usb_bos_desc_end - __usb_bos_desc_start;
|
|
}
|
|
|
|
const void *usb_bos_get_header(void)
|
|
{
|
|
return __usb_bos_desc_start;
|
|
}
|
|
|
|
void usb_bos_fix_total_length(void)
|
|
{
|
|
struct usb_bos_descriptor *hdr = (void *)__usb_bos_desc_start;
|
|
|
|
hdr->wTotalLength = usb_bos_get_length();
|
|
}
|
|
|
|
void usb_bos_register_cap(struct usb_bos_platform_descriptor *desc)
|
|
{
|
|
struct usb_bos_descriptor *hdr = (void *)__usb_bos_desc_start;
|
|
|
|
/* Has effect only on first register */
|
|
hdr->wTotalLength = usb_bos_get_length();
|
|
|
|
hdr->bNumDeviceCaps += 1U;
|
|
}
|
|
|
|
int usb_handle_bos(struct usb_setup_packet *setup,
|
|
int32_t *len, uint8_t **data)
|
|
{
|
|
if (GET_DESC_TYPE(setup->wValue) == DESCRIPTOR_TYPE_BOS) {
|
|
LOG_DBG("Read BOS descriptor");
|
|
*data = (uint8_t *)usb_bos_get_header();
|
|
*len = usb_bos_get_length();
|
|
|
|
return 0;
|
|
}
|
|
|
|
return -ENOTSUP;
|
|
}
|