Skip to content

Commit e2e928f

Browse files
vbrzeskitmon-nordic
authored andcommitted
[nrf fromtree] 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 <[email protected]> (cherry picked from commit e8638be) Signed-off-by: Tomasz Moń <[email protected]>
1 parent 07b6f0f commit e2e928f

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,11 @@ properties:
7878
type: int
7979
description: |
8080
Number of effectively used bits in audio subslot.
81+
82+
polling-period-us:
83+
type: int
84+
description: |
85+
Input or output endpoint polling period in microseconds. For USB full
86+
speed this could be clamped to 1ms or 32768ms depending on the value. For
87+
USB high speed this could be clamped to 125us or 4096ms depending on the
88+
value.

subsys/usb/device_next/class/usbd_uac2_macros.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,14 +707,22 @@
707707
#define AS_BYTES_PER_SAMPLE(node) \
708708
DT_PROP(node, subslot_size)
709709

710+
#define AS_FS_DATA_EP_BINTERVAL(node) \
711+
USB_FS_ISO_EP_INTERVAL(DT_PROP_OR(node, polling_period_us, 1000))
712+
713+
#define AS_HS_DATA_EP_BINTERVAL(node) \
714+
USB_HS_ISO_EP_INTERVAL(DT_PROP_OR(node, polling_period_us, 125))
715+
710716
/* Asynchronous endpoints needs space for 1 extra sample */
711717
#define AS_SAMPLES_PER_FRAME(node) \
712-
((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 1000) / 1000) + \
713-
UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
718+
(((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 1000) / 1000) \
719+
<< (AS_FS_DATA_EP_BINTERVAL(node) - 1)) + \
720+
UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
714721

715722
#define AS_SAMPLES_PER_MICROFRAME(node) \
716-
((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 8000) / 8000) + \
717-
UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
723+
(((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 8000) / 8000) \
724+
<< (AS_HS_DATA_EP_BINTERVAL(node) - 1)) + \
725+
UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
718726

719727
#define AS_DATA_EP_SYNC_TYPE(node) \
720728
COND_CODE_1(AS_IS_SOF_SYNCHRONIZED(node), (0x3 << 2), (0x1 << 2))
@@ -745,7 +753,7 @@
745753
AS_DATA_EP_ADDR(node), /* bEndpointAddress */ \
746754
AS_DATA_EP_ATTR(node), /* bmAttributes */ \
747755
U16_LE(AS_FS_DATA_EP_MAX_PACKET_SIZE(node)), /* wMaxPacketSize */ \
748-
0x01, /* bInterval */
756+
AS_FS_DATA_EP_BINTERVAL(node), /* bInterval */
749757

750758
#define AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTORS_ARRAYS(node) \
751759
static uint8_t DESCRIPTOR_NAME(fs_std_data_ep, node)[] = { \
@@ -758,7 +766,7 @@
758766
AS_DATA_EP_ADDR(node), /* bEndpointAddress */ \
759767
AS_DATA_EP_ATTR(node), /* bmAttributes */ \
760768
U16_LE(AS_HS_DATA_EP_MAX_PACKET_SIZE(node)), /* wMaxPacketSize */ \
761-
0x01, /* bInterval */
769+
AS_HS_DATA_EP_BINTERVAL(node), /* bInterval */
762770

763771
#define AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTORS_ARRAYS(node) \
764772
static uint8_t DESCRIPTOR_NAME(hs_std_data_ep, node)[] = { \

0 commit comments

Comments
 (0)