@@ -28,6 +28,7 @@ LOG_MODULE_REGISTER(usbd_uac2, CONFIG_USBD_UAC2_LOG_LEVEL);
28
28
IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_audio_streaming), ( \
29
29
+ AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node) \
30
30
+ AS_IS_USB_ISO_IN(node) /* ISO IN double buffering */ \
31
+ + AS_IS_USB_ISO_OUT (node ) /* ISO OUT double buffering */ \
31
32
+ AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT (node )))
32
33
#define COUNT_UAC2_EP_BUFFERS (i ) \
33
34
+ DT_PROP(DT_DRV_INST(i), interrupt_endpoint) \
@@ -348,6 +349,7 @@ static void schedule_iso_out_read(struct usbd_class_data *const c_data,
348
349
const struct uac2_cfg * cfg = dev -> config ;
349
350
struct uac2_ctx * ctx = dev -> data ;
350
351
struct net_buf * buf ;
352
+ atomic_t * queued_bits = & ctx -> as_queued ;
351
353
void * data_buf ;
352
354
int as_idx = terminal_to_as_interface (dev , terminal );
353
355
int ret ;
@@ -364,16 +366,19 @@ static void schedule_iso_out_read(struct usbd_class_data *const c_data,
364
366
return ;
365
367
}
366
368
367
- if (atomic_test_and_set_bit (& ctx -> as_queued , as_idx )) {
368
- /* Transfer already queued - do not requeue */
369
- return ;
369
+ if (atomic_test_and_set_bit (queued_bits , as_idx )) {
370
+ queued_bits = & ctx -> as_double ;
371
+ if (atomic_test_and_set_bit (queued_bits , as_idx )) {
372
+ /* Transfer already double queued - nothing to do */
373
+ return ;
374
+ }
370
375
}
371
376
372
377
/* Prepare transfer to read audio OUT data from host */
373
378
data_buf = ctx -> ops -> get_recv_buf (dev , terminal , mps , ctx -> user_data );
374
379
if (!data_buf ) {
375
380
LOG_ERR ("No data buffer for terminal %d" , terminal );
376
- atomic_clear_bit (& ctx -> as_queued , as_idx );
381
+ atomic_clear_bit (queued_bits , as_idx );
377
382
return ;
378
383
}
379
384
@@ -386,15 +391,15 @@ static void schedule_iso_out_read(struct usbd_class_data *const c_data,
386
391
*/
387
392
ctx -> ops -> data_recv_cb (dev , terminal ,
388
393
data_buf , 0 , ctx -> user_data );
389
- atomic_clear_bit (& ctx -> as_queued , as_idx );
394
+ atomic_clear_bit (queued_bits , as_idx );
390
395
return ;
391
396
}
392
397
393
398
ret = usbd_ep_enqueue (c_data , buf );
394
399
if (ret ) {
395
400
LOG_ERR ("Failed to enqueue net_buf for 0x%02x" , ep );
396
401
net_buf_unref (buf );
397
- atomic_clear_bit (& ctx -> as_queued , as_idx );
402
+ atomic_clear_bit (queued_bits , as_idx );
398
403
}
399
404
}
400
405
@@ -814,6 +819,10 @@ static int uac2_request(struct usbd_class_data *const c_data, struct net_buf *bu
814
819
if (USB_EP_DIR_IS_OUT (ep )) {
815
820
ctx -> ops -> data_recv_cb (dev , terminal , buf -> __buf , buf -> len ,
816
821
ctx -> user_data );
822
+ if (buf -> frags ) {
823
+ ctx -> ops -> data_recv_cb (dev , terminal , buf -> frags -> __buf ,
824
+ buf -> frags -> len , ctx -> user_data );
825
+ }
817
826
} else if (!is_feedback ) {
818
827
ctx -> ops -> buf_release_cb (dev , terminal , buf -> __buf , ctx -> user_data );
819
828
if (buf -> frags ) {
0 commit comments