@@ -29,7 +29,7 @@ LOG_MODULE_REGISTER(usbd_uac2, CONFIG_USBD_UAC2_LOG_LEVEL);
29
29
+ AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node) \
30
30
+ AS_IS_USB_ISO_IN(node) /* ISO IN double buffering */ \
31
31
+ AS_IS_USB_ISO_OUT (node ) /* ISO OUT double buffering */ \
32
- + AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT (node )))
32
+ + 2 * AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT (node )))
33
33
#define COUNT_UAC2_EP_BUFFERS (i ) \
34
34
+ DT_PROP(DT_DRV_INST(i), interrupt_endpoint) \
35
35
DT_INST_FOREACH_CHILD(i, COUNT_UAC2_AS_ENDPOINT_BUFFERS)
@@ -88,6 +88,7 @@ struct uac2_ctx {
88
88
atomic_t as_queued ;
89
89
atomic_t as_double ;
90
90
uint32_t fb_queued ;
91
+ uint32_t fb_double ;
91
92
};
92
93
93
94
/* UAC2 device constant data */
@@ -441,7 +442,11 @@ static void write_explicit_feedback(struct usbd_class_data *const c_data,
441
442
LOG_ERR ("Failed to enqueue net_buf for 0x%02x" , ep );
442
443
net_buf_unref (buf );
443
444
} else {
444
- ctx -> fb_queued |= BIT (as_idx );
445
+ if (ctx -> fb_queued & BIT (as_idx )) {
446
+ ctx -> fb_double |= BIT (as_idx );
447
+ } else {
448
+ ctx -> fb_queued |= BIT (as_idx );
449
+ }
445
450
}
446
451
}
447
452
@@ -813,7 +818,17 @@ static int uac2_request(struct usbd_class_data *const c_data, struct net_buf *bu
813
818
terminal = cfg -> as_terminals [as_idx ];
814
819
815
820
if (is_feedback ) {
816
- ctx -> fb_queued &= ~BIT (as_idx );
821
+ bool clear_double = buf -> frags ;
822
+
823
+ if (ctx -> fb_queued & BIT (as_idx )) {
824
+ ctx -> fb_queued &= ~BIT (as_idx );
825
+ } else {
826
+ clear_double = true;
827
+ }
828
+
829
+ if (clear_double ) {
830
+ ctx -> fb_double &= ~BIT (as_idx );
831
+ }
817
832
} else if (!atomic_test_and_clear_bit (& ctx -> as_queued , as_idx ) || buf -> frags ) {
818
833
atomic_clear_bit (& ctx -> as_double , as_idx );
819
834
}
@@ -880,7 +895,7 @@ static void uac2_sof(struct usbd_class_data *const c_data)
880
895
* for now to allow faster recovery (i.e. reduce workload to be
881
896
* done during this frame).
882
897
*/
883
- if (ctx -> fb_queued & BIT (as_idx )) {
898
+ if (ctx -> fb_queued & ctx -> fb_double & BIT (as_idx )) {
884
899
continue ;
885
900
}
886
901
0 commit comments