2022-01-05 13:44:48 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEPHYR_INCLUDE_USBD_CLASS_H
|
|
|
|
#define ZEPHYR_INCLUDE_USBD_CLASS_H
|
|
|
|
|
|
|
|
#include <zephyr/usb/usbd.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Handle endpoint transfer result
|
|
|
|
*
|
|
|
|
* @param[in] uds_ctx Pointer to device context
|
|
|
|
* @param[in] buf Pointer to UDC request buffer
|
2023-07-25 11:15:04 +02:00
|
|
|
* @param[in] err Transfer status
|
2022-01-05 13:44:48 +01:00
|
|
|
*
|
|
|
|
* @return usbd_class_request() return value
|
|
|
|
*/
|
2024-05-29 14:06:25 +02:00
|
|
|
int usbd_class_handle_xfer(struct usbd_context *const uds_ctx,
|
2022-01-05 13:44:48 +01:00
|
|
|
struct net_buf *const buf,
|
|
|
|
const int err);
|
|
|
|
|
|
|
|
/**
|
usb: device_next: make HS support compliant with the USB2.0 specification
For specification-compliant high-speed support, we need to support
device quilifiers and other-speed-configuration descriptor requests. We
also need to store different configurations of the class/function
descriptors, which typically only affect the endpoint descriptors. With
this change, the stack expects class/function descriptors to be passed
as an array of struct usb_desc_header pointers to e.g. interface,
interface-specific, and endpoint descriptors, with the last element of
the array pointing to a nil descriptor. And also passed for a specific
speed, for now we support full and high speed configurations.
During instantiation, the class/function implementation must choose the
correct configuration in the full-speed and high-speed descriptor sets
for values such as maximum packet size and bInterval values of interrupt
and isochronous endpoints.
During initialization, the stack reads the highest speed supported by
the controller and uses it to get the appropriate descriptors set
from the instance. If the controller supports only full speed, the stack
configures the class/function descriptor for full speed only, if the
controller supports high speed, the stack configures the descriptors for
high speed only, and a class/function must update the full speed
descriptor during the init callback processing.
During device operation, the class/function implementation must check
the actual speed of the device and use the correct configuration, such
as the endpoint address or maximum packet size.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-01-02 17:10:06 +01:00
|
|
|
* @brief Calculate the length of the class function descriptor
|
2022-01-05 13:44:48 +01:00
|
|
|
*
|
usb: device_next: make HS support compliant with the USB2.0 specification
For specification-compliant high-speed support, we need to support
device quilifiers and other-speed-configuration descriptor requests. We
also need to store different configurations of the class/function
descriptors, which typically only affect the endpoint descriptors. With
this change, the stack expects class/function descriptors to be passed
as an array of struct usb_desc_header pointers to e.g. interface,
interface-specific, and endpoint descriptors, with the last element of
the array pointing to a nil descriptor. And also passed for a specific
speed, for now we support full and high speed configurations.
During instantiation, the class/function implementation must choose the
correct configuration in the full-speed and high-speed descriptor sets
for values such as maximum packet size and bInterval values of interrupt
and isochronous endpoints.
During initialization, the stack reads the highest speed supported by
the controller and uses it to get the appropriate descriptors set
from the instance. If the controller supports only full speed, the stack
configures the class/function descriptor for full speed only, if the
controller supports high speed, the stack configures the descriptors for
high speed only, and a class/function must update the full speed
descriptor during the init callback processing.
During device operation, the class/function implementation must check
the actual speed of the device and use the correct configuration, such
as the endpoint address or maximum packet size.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-01-02 17:10:06 +01:00
|
|
|
* Calculate the length of the class instance function descriptor.
|
2022-01-05 13:44:48 +01:00
|
|
|
* Calculated length does not include any string descriptors that may be
|
|
|
|
* used by the class instance.
|
|
|
|
*
|
2024-03-19 14:52:52 +01:00
|
|
|
* @param[in] c_data Pointer to a class data
|
usb: device_next: make HS support compliant with the USB2.0 specification
For specification-compliant high-speed support, we need to support
device quilifiers and other-speed-configuration descriptor requests. We
also need to store different configurations of the class/function
descriptors, which typically only affect the endpoint descriptors. With
this change, the stack expects class/function descriptors to be passed
as an array of struct usb_desc_header pointers to e.g. interface,
interface-specific, and endpoint descriptors, with the last element of
the array pointing to a nil descriptor. And also passed for a specific
speed, for now we support full and high speed configurations.
During instantiation, the class/function implementation must choose the
correct configuration in the full-speed and high-speed descriptor sets
for values such as maximum packet size and bInterval values of interrupt
and isochronous endpoints.
During initialization, the stack reads the highest speed supported by
the controller and uses it to get the appropriate descriptors set
from the instance. If the controller supports only full speed, the stack
configures the class/function descriptor for full speed only, if the
controller supports high speed, the stack configures the descriptors for
high speed only, and a class/function must update the full speed
descriptor during the init callback processing.
During device operation, the class/function implementation must check
the actual speed of the device and use the correct configuration, such
as the endpoint address or maximum packet size.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-01-02 17:10:06 +01:00
|
|
|
* @param[in] speed Speed-dependent descriptor selector
|
2022-01-05 13:44:48 +01:00
|
|
|
*
|
|
|
|
* @return Length of the class descriptor
|
|
|
|
*/
|
2024-03-19 14:52:52 +01:00
|
|
|
size_t usbd_class_desc_len(struct usbd_class_data *const c_data,
|
usb: device_next: make HS support compliant with the USB2.0 specification
For specification-compliant high-speed support, we need to support
device quilifiers and other-speed-configuration descriptor requests. We
also need to store different configurations of the class/function
descriptors, which typically only affect the endpoint descriptors. With
this change, the stack expects class/function descriptors to be passed
as an array of struct usb_desc_header pointers to e.g. interface,
interface-specific, and endpoint descriptors, with the last element of
the array pointing to a nil descriptor. And also passed for a specific
speed, for now we support full and high speed configurations.
During instantiation, the class/function implementation must choose the
correct configuration in the full-speed and high-speed descriptor sets
for values such as maximum packet size and bInterval values of interrupt
and isochronous endpoints.
During initialization, the stack reads the highest speed supported by
the controller and uses it to get the appropriate descriptors set
from the instance. If the controller supports only full speed, the stack
configures the class/function descriptor for full speed only, if the
controller supports high speed, the stack configures the descriptors for
high speed only, and a class/function must update the full speed
descriptor during the init callback processing.
During device operation, the class/function implementation must check
the actual speed of the device and use the correct configuration, such
as the endpoint address or maximum packet size.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-01-02 17:10:06 +01:00
|
|
|
const enum usbd_speed speed);
|
2022-01-05 13:44:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get class context by bInterfaceNumber value
|
|
|
|
*
|
|
|
|
* The function searches the class instance list for the interface number.
|
|
|
|
*
|
|
|
|
* @param[in] uds_ctx Pointer to device context
|
|
|
|
* @param[in] inum Interface number
|
|
|
|
*
|
2024-03-19 15:53:04 +01:00
|
|
|
* @return Class c_nd pointer or NULL
|
2022-01-05 13:44:48 +01:00
|
|
|
*/
|
2024-05-29 14:06:25 +02:00
|
|
|
struct usbd_class_node *usbd_class_get_by_iface(struct usbd_context *uds_ctx,
|
2022-01-05 13:44:48 +01:00
|
|
|
uint8_t i_n);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get class context by configuration and interface number
|
|
|
|
*
|
|
|
|
* @param[in] uds_ctx Pointer to device context
|
2024-02-29 11:18:28 +01:00
|
|
|
* @param[in] speed Speed the configuration number refers to
|
2022-01-05 13:44:48 +01:00
|
|
|
* @param[in] cnum Configuration number
|
|
|
|
* @param[in] inum Interface number
|
|
|
|
*
|
2024-03-19 15:53:04 +01:00
|
|
|
* @return Class c_nd pointer or NULL
|
2022-01-05 13:44:48 +01:00
|
|
|
*/
|
2024-05-29 14:06:25 +02:00
|
|
|
struct usbd_class_node *usbd_class_get_by_config(struct usbd_context *uds_ctx,
|
2024-02-29 11:18:28 +01:00
|
|
|
const enum usbd_speed speed,
|
2022-01-05 13:44:48 +01:00
|
|
|
uint8_t cnum,
|
|
|
|
uint8_t inum);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get class context by endpoint address
|
|
|
|
*
|
|
|
|
* The function searches the class instance list for the endpoint address.
|
|
|
|
*
|
|
|
|
* @param[in] uds_ctx Pointer to device context
|
|
|
|
* @param[in] ep Endpoint address
|
|
|
|
*
|
2024-03-19 15:53:04 +01:00
|
|
|
* @return Class c_nd pointer or NULL
|
2022-01-05 13:44:48 +01:00
|
|
|
*/
|
2024-05-29 14:06:25 +02:00
|
|
|
struct usbd_class_node *usbd_class_get_by_ep(struct usbd_context *uds_ctx,
|
2022-01-05 13:44:48 +01:00
|
|
|
uint8_t ep);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get class context by request (bRequest)
|
|
|
|
*
|
|
|
|
* The function searches the class instance list and
|
|
|
|
* compares the vendor request table with request value.
|
|
|
|
* The function is only used if the request type is Vendor and
|
|
|
|
* request recipient is Device.
|
|
|
|
* Accordingly only the first class instance can be found.
|
|
|
|
*
|
|
|
|
* @param[in] uds_ctx Pointer to device context
|
|
|
|
* @param[in] request bRequest value
|
|
|
|
*
|
2024-03-19 15:53:04 +01:00
|
|
|
* @return Class c_nd pointer or NULL
|
2022-01-05 13:44:48 +01:00
|
|
|
*/
|
2024-05-29 14:06:25 +02:00
|
|
|
struct usbd_class_node *usbd_class_get_by_req(struct usbd_context *uds_ctx,
|
2022-01-05 13:44:48 +01:00
|
|
|
uint8_t request);
|
|
|
|
|
2023-05-15 11:52:25 +02:00
|
|
|
/**
|
|
|
|
* @brief Remove all registered class instances from a configuration
|
|
|
|
*
|
|
|
|
* @param[in] uds_ctx Pointer to device context
|
2024-02-29 11:18:28 +01:00
|
|
|
* @param[in] speed Speed the configuration number applies to
|
2023-05-15 11:52:25 +02:00
|
|
|
* @param[in] cfg Configuration number (bConfigurationValue)
|
|
|
|
*
|
|
|
|
* @return 0 on success, other values on fail.
|
|
|
|
*/
|
2024-05-29 14:06:25 +02:00
|
|
|
int usbd_class_remove_all(struct usbd_context *const uds_ctx,
|
2024-02-29 11:18:28 +01:00
|
|
|
const enum usbd_speed speed,
|
2023-05-15 11:52:25 +02:00
|
|
|
const uint8_t cfg);
|
|
|
|
|
2022-01-05 13:44:48 +01:00
|
|
|
#endif /* ZEPHYR_INCLUDE_USBD_CLASS_H */
|