Browse Source

usb: device_next: uac2: support higher bInterval values

This commit adds a device-tree prop for the audio streaming
terminals to specify the bInterval values for the Isochronous
endpoints.

Signed-off-by: Victor Brzeski <vbrzeski@gmail.com>
pull/89290/head
Victor Brzeski 2 weeks ago committed by Dan Kalowsky
parent
commit
e8638befaf
  1. 8
      dts/bindings/usb/uac2/zephyr,uac2-audio-streaming.yaml
  2. 16
      subsys/usb/device_next/class/usbd_uac2_macros.h

8
dts/bindings/usb/uac2/zephyr,uac2-audio-streaming.yaml

@ -78,3 +78,11 @@ properties:
type: int type: int
description: | description: |
Number of effectively used bits in audio subslot. Number of effectively used bits in audio subslot.
polling-period-us:
type: int
description: |
Input or output endpoint polling period in microseconds. For USB full
speed this could be clamped to 1ms or 32768ms depending on the value. For
USB high speed this could be clamped to 125us or 4096ms depending on the
value.

16
subsys/usb/device_next/class/usbd_uac2_macros.h

@ -707,13 +707,21 @@
#define AS_BYTES_PER_SAMPLE(node) \ #define AS_BYTES_PER_SAMPLE(node) \
DT_PROP(node, subslot_size) DT_PROP(node, subslot_size)
#define AS_FS_DATA_EP_BINTERVAL(node) \
USB_FS_ISO_EP_INTERVAL(DT_PROP_OR(node, polling_period_us, 1000))
#define AS_HS_DATA_EP_BINTERVAL(node) \
USB_HS_ISO_EP_INTERVAL(DT_PROP_OR(node, polling_period_us, 125))
/* Asynchronous endpoints needs space for 1 extra sample */ /* Asynchronous endpoints needs space for 1 extra sample */
#define AS_SAMPLES_PER_FRAME(node) \ #define AS_SAMPLES_PER_FRAME(node) \
((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 1000) / 1000) + \ (((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 1000) / 1000) \
<< (AS_FS_DATA_EP_BINTERVAL(node) - 1)) + \
UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node))) UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
#define AS_SAMPLES_PER_MICROFRAME(node) \ #define AS_SAMPLES_PER_MICROFRAME(node) \
((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 8000) / 8000) + \ (((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 8000) / 8000) \
<< (AS_HS_DATA_EP_BINTERVAL(node) - 1)) + \
UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node))) UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
#define AS_DATA_EP_SYNC_TYPE(node) \ #define AS_DATA_EP_SYNC_TYPE(node) \
@ -745,7 +753,7 @@
AS_DATA_EP_ADDR(node), /* bEndpointAddress */ \ AS_DATA_EP_ADDR(node), /* bEndpointAddress */ \
AS_DATA_EP_ATTR(node), /* bmAttributes */ \ AS_DATA_EP_ATTR(node), /* bmAttributes */ \
U16_LE(AS_FS_DATA_EP_MAX_PACKET_SIZE(node)), /* wMaxPacketSize */ \ U16_LE(AS_FS_DATA_EP_MAX_PACKET_SIZE(node)), /* wMaxPacketSize */ \
0x01, /* bInterval */ AS_FS_DATA_EP_BINTERVAL(node), /* bInterval */
#define AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTORS_ARRAYS(node) \ #define AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTORS_ARRAYS(node) \
static uint8_t DESCRIPTOR_NAME(fs_std_data_ep, node)[] = { \ static uint8_t DESCRIPTOR_NAME(fs_std_data_ep, node)[] = { \
@ -758,7 +766,7 @@
AS_DATA_EP_ADDR(node), /* bEndpointAddress */ \ AS_DATA_EP_ADDR(node), /* bEndpointAddress */ \
AS_DATA_EP_ATTR(node), /* bmAttributes */ \ AS_DATA_EP_ATTR(node), /* bmAttributes */ \
U16_LE(AS_HS_DATA_EP_MAX_PACKET_SIZE(node)), /* wMaxPacketSize */ \ U16_LE(AS_HS_DATA_EP_MAX_PACKET_SIZE(node)), /* wMaxPacketSize */ \
0x01, /* bInterval */ AS_HS_DATA_EP_BINTERVAL(node), /* bInterval */
#define AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTORS_ARRAYS(node) \ #define AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTORS_ARRAYS(node) \
static uint8_t DESCRIPTOR_NAME(hs_std_data_ep, node)[] = { \ static uint8_t DESCRIPTOR_NAME(hs_std_data_ep, node)[] = { \

Loading…
Cancel
Save