@@ -29,7 +29,7 @@ LOG_MODULE_REGISTER(usbd_uac2, CONFIG_USBD_UAC2_LOG_LEVEL);
2929 + AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node) + \
3030 + AS_IS_USB_ISO_IN(node) /* ISO IN double buffering */ + \
3131 + 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 )))
3333#define COUNT_UAC2_EP_BUFFERS (i ) \
3434 + DT_PROP(DT_DRV_INST(i), interrupt_endpoint) \
3535 DT_INST_FOREACH_CHILD(i, COUNT_UAC2_AS_ENDPOINT_BUFFERS)
@@ -88,6 +88,7 @@ struct uac2_ctx {
8888 atomic_t as_queued ;
8989 atomic_t as_double ;
9090 uint32_t fb_queued ;
91+ uint32_t fb_double ;
9192};
9293
9394/* UAC2 device constant data */
@@ -441,7 +442,11 @@ static void write_explicit_feedback(struct usbd_class_data *const c_data,
441442 LOG_ERR ("Failed to enqueue net_buf for 0x%02x" , ep );
442443 net_buf_unref (buf );
443444 } 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+ }
445450 }
446451}
447452
@@ -813,7 +818,17 @@ static int uac2_request(struct usbd_class_data *const c_data, struct net_buf *bu
813818 terminal = cfg -> as_terminals [as_idx ];
814819
815820 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+ }
817832 } else if (!atomic_test_and_clear_bit (& ctx -> as_queued , as_idx ) || buf -> frags ) {
818833 atomic_clear_bit (& ctx -> as_double , as_idx );
819834 }
@@ -880,7 +895,7 @@ static void uac2_sof(struct usbd_class_data *const c_data)
880895 * for now to allow faster recovery (i.e. reduce workload to be
881896 * done during this frame).
882897 */
883- if (ctx -> fb_queued & BIT (as_idx )) {
898+ if (ctx -> fb_queued & ctx -> fb_double & BIT (as_idx )) {
884899 continue ;
885900 }
886901
0 commit comments