@@ -1495,17 +1495,19 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
1495
1495
}
1496
1496
1497
1497
#if USE_ISO_EP_ALLOCATION
1498
- #if CFG_TUD_AUDIO_ENABLE_EP_IN
1498
+ #if CFG_TUD_AUDIO_ENABLE_EP_IN
1499
1499
uint8_t ep_in = 0 ;
1500
1500
uint16_t ep_in_size = 0 ;
1501
- #endif
1502
- #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1501
+ #endif
1502
+
1503
+ #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1503
1504
uint8_t ep_out = 0 ;
1504
1505
uint16_t ep_out_size = 0 ;
1505
- #endif
1506
- #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1506
+ #endif
1507
+
1508
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1507
1509
uint8_t ep_fb = 0 ;
1508
- #endif
1510
+ #endif
1509
1511
1510
1512
uint8_t const * p_desc = _audiod_fct [i ].p_desc ;
1511
1513
uint8_t const * p_desc_end = p_desc + _audiod_fct [i ].desc_length - TUD_AUDIO_DESC_IAD_LEN ;
@@ -1516,28 +1518,28 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
1516
1518
tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const * ) p_desc ;
1517
1519
if (desc_ep -> bmAttributes .xfer == TUSB_XFER_ISOCHRONOUS )
1518
1520
{
1519
- #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1521
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1520
1522
// Explicit feedback EP
1521
1523
if (desc_ep -> bmAttributes .usage == 1 )
1522
1524
{
1523
1525
ep_fb = desc_ep -> bEndpointAddress ;
1524
1526
}
1525
- #endif
1527
+ #endif
1526
1528
// Data EP
1527
1529
if (desc_ep -> bmAttributes .usage == 0 )
1528
1530
{
1529
1531
if (tu_edpt_dir (desc_ep -> bEndpointAddress ) == TUSB_DIR_IN )
1530
1532
{
1531
- #if CFG_TUD_AUDIO_ENABLE_EP_IN
1533
+ #if CFG_TUD_AUDIO_ENABLE_EP_IN
1532
1534
ep_in = desc_ep -> bEndpointAddress ;
1533
1535
ep_in_size = TU_MAX (tu_edpt_packet_size (desc_ep ), ep_in_size );
1534
- #endif
1536
+ #endif
1535
1537
} else
1536
1538
{
1537
- #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1539
+ #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1538
1540
ep_out = desc_ep -> bEndpointAddress ;
1539
1541
ep_out_size = TU_MAX (tu_edpt_packet_size (desc_ep ), ep_out_size );
1540
- #endif
1542
+ #endif
1541
1543
}
1542
1544
}
1543
1545
@@ -1546,26 +1548,28 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
1546
1548
p_desc = tu_desc_next (p_desc );
1547
1549
}
1548
1550
1549
- #if CFG_TUD_AUDIO_ENABLE_EP_IN
1551
+ #if CFG_TUD_AUDIO_ENABLE_EP_IN
1550
1552
if (ep_in )
1551
1553
{
1552
1554
usbd_edpt_iso_alloc (rhport , ep_in , ep_in_size );
1553
1555
}
1554
- #endif
1555
- #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1556
+ #endif
1557
+
1558
+ #if CFG_TUD_AUDIO_ENABLE_EP_OUT
1556
1559
if (ep_out )
1557
1560
{
1558
1561
usbd_edpt_iso_alloc (rhport , ep_out , ep_out_size );
1559
1562
}
1560
- #endif
1561
- #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1563
+ #endif
1564
+
1565
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1562
1566
if (ep_fb )
1563
1567
{
1564
1568
usbd_edpt_iso_alloc (rhport , ep_fb , 4 );
1565
1569
}
1566
- #endif
1570
+ #endif
1567
1571
1568
- #endif
1572
+ #endif // USE_ISO_EP_ALLOCATION
1569
1573
1570
1574
break ;
1571
1575
}
@@ -1628,59 +1632,61 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1628
1632
if (audio -> ep_in_as_intf_num == itf )
1629
1633
{
1630
1634
audio -> ep_in_as_intf_num = 0 ;
1631
- #if !USE_ISO_EP_ALLOCATION
1635
+ #if !USE_ISO_EP_ALLOCATION
1632
1636
usbd_edpt_close (rhport , audio -> ep_in );
1633
- #endif
1637
+ #endif
1638
+
1634
1639
// Clear FIFOs, since data is no longer valid
1635
- #if !CFG_TUD_AUDIO_ENABLE_ENCODING
1640
+ #if !CFG_TUD_AUDIO_ENABLE_ENCODING
1636
1641
tu_fifo_clear (& audio -> ep_in_ff );
1637
- #else
1642
+ #else
1638
1643
for (uint8_t cnt = 0 ; cnt < audio -> n_tx_supp_ff ; cnt ++ )
1639
1644
{
1640
1645
tu_fifo_clear (& audio -> tx_supp_ff [cnt ]);
1641
1646
}
1642
- #endif
1647
+ #endif
1643
1648
1644
1649
// Invoke callback - can be used to stop data sampling
1645
1650
if (tud_audio_set_itf_close_EP_cb ) TU_VERIFY (tud_audio_set_itf_close_EP_cb (rhport , p_request ));
1646
1651
1647
1652
audio -> ep_in = 0 ; // Necessary?
1648
1653
1649
1654
}
1650
- #endif
1655
+ #endif // CFG_TUD_AUDIO_ENABLE_EP_IN
1651
1656
1652
1657
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
1653
1658
if (audio -> ep_out_as_intf_num == itf )
1654
1659
{
1655
1660
audio -> ep_out_as_intf_num = 0 ;
1656
- #if !USE_ISO_EP_ALLOCATION
1661
+ #if !USE_ISO_EP_ALLOCATION
1657
1662
usbd_edpt_close (rhport , audio -> ep_out );
1658
- #endif
1663
+ #endif
1664
+
1659
1665
// Clear FIFOs, since data is no longer valid
1660
- #if !CFG_TUD_AUDIO_ENABLE_DECODING
1666
+ #if !CFG_TUD_AUDIO_ENABLE_DECODING
1661
1667
tu_fifo_clear (& audio -> ep_out_ff );
1662
- #else
1668
+ #else
1663
1669
for (uint8_t cnt = 0 ; cnt < audio -> n_rx_supp_ff ; cnt ++ )
1664
1670
{
1665
1671
tu_fifo_clear (& audio -> rx_supp_ff [cnt ]);
1666
1672
}
1667
- #endif
1673
+ #endif
1668
1674
1669
1675
// Invoke callback - can be used to stop data sampling
1670
1676
if (tud_audio_set_itf_close_EP_cb ) TU_VERIFY (tud_audio_set_itf_close_EP_cb (rhport , p_request ));
1671
1677
1672
1678
audio -> ep_out = 0 ; // Necessary?
1673
1679
1674
1680
// Close corresponding feedback EP
1675
- #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1676
- #if !USE_ISO_EP_ALLOCATION
1681
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1682
+ #if !USE_ISO_EP_ALLOCATION
1677
1683
usbd_edpt_close (rhport , audio -> ep_fb );
1678
- #endif
1684
+ #endif
1679
1685
audio -> ep_fb = 0 ;
1680
1686
tu_memclr (& audio -> feedback , sizeof (audio -> feedback ));
1681
- #endif
1687
+ #endif
1682
1688
}
1683
- #endif
1689
+ #endif // CFG_TUD_AUDIO_ENABLE_EP_OUT
1684
1690
1685
1691
// Save current alternative interface setting
1686
1692
audio -> alt_setting [idxItf ] = alt ;
@@ -1724,21 +1730,20 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1724
1730
audio -> ep_in_sz = tu_edpt_packet_size (desc_ep );
1725
1731
1726
1732
// If software encoding is enabled, parse for the corresponding parameters - doing this here means only AS interfaces with EPs get scanned for parameters
1727
- #if CFG_TUD_AUDIO_ENABLE_ENCODING
1733
+ #if CFG_TUD_AUDIO_ENABLE_ENCODING
1728
1734
audiod_parse_for_AS_params (audio , p_desc_parse_for_params , p_desc_end , itf );
1729
1735
1730
1736
// Reconfigure size of support FIFOs - this is necessary to avoid samples to get split in case of a wrap
1731
- #if CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING
1737
+ #if CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING
1732
1738
const uint16_t active_fifo_depth = (uint16_t ) ((audio -> tx_supp_ff_sz_max / audio -> n_bytes_per_sampe_tx ) * audio -> n_bytes_per_sampe_tx );
1733
1739
for (uint8_t cnt = 0 ; cnt < audio -> n_tx_supp_ff ; cnt ++ )
1734
1740
{
1735
1741
tu_fifo_config (& audio -> tx_supp_ff [cnt ], audio -> tx_supp_ff [cnt ].buffer , active_fifo_depth , 1 , true);
1736
1742
}
1737
1743
audio -> n_ff_used_tx = audio -> n_channels_tx / audio -> n_channels_per_ff_tx ;
1738
1744
TU_ASSERT ( audio -> n_ff_used_tx <= audio -> n_tx_supp_ff );
1739
- #endif
1740
-
1741
- #endif
1745
+ #endif
1746
+ #endif
1742
1747
1743
1748
// Schedule first transmit if alternate interface is not zero i.e. streaming is disabled - in case no sample data is available a ZLP is loaded
1744
1749
// It is necessary to trigger this here since the refill is done with an RX FIFO empty interrupt which can only trigger if something was in there
@@ -1755,30 +1760,30 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1755
1760
audio -> ep_out_as_intf_num = itf ;
1756
1761
audio -> ep_out_sz = tu_edpt_packet_size (desc_ep );
1757
1762
1758
- #if CFG_TUD_AUDIO_ENABLE_DECODING
1763
+ #if CFG_TUD_AUDIO_ENABLE_DECODING
1759
1764
audiod_parse_for_AS_params (audio , p_desc_parse_for_params , p_desc_end , itf );
1760
1765
1761
1766
// Reconfigure size of support FIFOs - this is necessary to avoid samples to get split in case of a wrap
1762
- #if CFG_TUD_AUDIO_ENABLE_TYPE_I_DECODING
1767
+ #if CFG_TUD_AUDIO_ENABLE_TYPE_I_DECODING
1763
1768
const uint16_t active_fifo_depth = (audio -> rx_supp_ff_sz_max / audio -> n_bytes_per_sampe_rx ) * audio -> n_bytes_per_sampe_rx ;
1764
1769
for (uint8_t cnt = 0 ; cnt < audio -> n_rx_supp_ff ; cnt ++ )
1765
1770
{
1766
1771
tu_fifo_config (& audio -> rx_supp_ff [cnt ], audio -> rx_supp_ff [cnt ].buffer , active_fifo_depth , 1 , true);
1767
1772
}
1768
1773
audio -> n_ff_used_rx = audio -> n_channels_rx / audio -> n_channels_per_ff_rx ;
1769
1774
TU_ASSERT ( audio -> n_ff_used_rx <= audio -> n_rx_supp_ff );
1770
- #endif
1771
- #endif
1775
+ #endif
1776
+ #endif
1772
1777
1773
1778
// Prepare for incoming data
1774
- #if USE_LINEAR_BUFFER_RX
1779
+ #if USE_LINEAR_BUFFER_RX
1775
1780
TU_VERIFY (usbd_edpt_xfer (rhport , audio -> ep_out , audio -> lin_buf_out , audio -> ep_out_sz ), false);
1776
- #else
1781
+ #else
1777
1782
TU_VERIFY (usbd_edpt_xfer_fifo (rhport , audio -> ep_out , & audio -> ep_out_ff , audio -> ep_out_sz ), false);
1778
- #endif
1783
+ #endif
1779
1784
}
1780
1785
1781
- #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1786
+ #if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1782
1787
if (tu_edpt_dir (ep_addr ) == TUSB_DIR_IN && desc_ep -> bmAttributes .usage == 1 ) // Check if usage is explicit data feedback
1783
1788
{
1784
1789
audio -> ep_fb = ep_addr ;
@@ -1787,7 +1792,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1787
1792
// Enable SOF interrupt if callback is implemented
1788
1793
if (tud_audio_feedback_interval_isr ) usbd_sof_enable (rhport , true);
1789
1794
}
1790
- #endif
1795
+ #endif
1791
1796
#endif // CFG_TUD_AUDIO_ENABLE_EP_OUT
1792
1797
1793
1798
foundEPs += 1 ;
@@ -1838,7 +1843,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
1838
1843
default : break ;
1839
1844
}
1840
1845
}
1841
- #endif
1846
+ #endif // CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
1842
1847
1843
1848
// We are done - abort loop
1844
1849
break ;
0 commit comments