Skip to content

Commit f270e28

Browse files
Victor Brzeskivbrzeski
authored andcommitted
usb: device_next: uac2: Support configurable polling rates
1 parent 6131774 commit f270e28

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,9 @@ 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 type reports polling period in microseconds. For USB full
86+
speed this could be clamped to 1ms or 255ms depending on the value.

subsys/usb/device_next/class/usbd_uac2_macros.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,21 @@
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) + \
718+
((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 1000) / 1000) * \
719+
AS_FS_DATA_EP_BINTERVAL(node) + \
713720
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) + \
723+
(((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 8000) / 8000) << \
724+
(AS_HS_DATA_EP_BINTERVAL(node) - 1)) + \
717725
UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
718726

719727
#define AS_DATA_EP_SYNC_TYPE(node) \
@@ -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)