关于BTR3等在Linux下USB 44.1KHz无声的问题飞傲社区|飞傲官方论坛|飞傲产品官方交流平台
回复:3 阅读:150   2019-07-23 00:54:32

给内核打上以下其中一个补丁,BTR3在Linux下USB 44.1KHz就有声音了:


diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index a2ab8e8d3a93..8dc2d73c9104 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -134,9 +134,6 @@ int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep)
        unsigned long flags;
        int ret;
 
-       if (ep->fill_max)
-               return ep->maxframesize;
-
        spin_lock_irqsave(&ep->lock, flags);
        ep->phase = (ep->phase & 0xffff)
                + (ep->freqm << ep->datainterval);


diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index a2ab8e8d3a93..7feecdbd6bb3 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -869,7 +869,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
 
        ep->datainterval = fmt->datainterval;
        ep->maxpacksize = fmt->maxpacksize;
-       ep->fill_max = !!(fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX);
+       ep->fill_max = 0;
 
        if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL)
                ep->freqn = get_usb_full_speed_rate(rate);


这样封包大小就会在44与45帧(176与180字节)之间跳动(相信是每1/100秒(每10个)里有9个44帧的跟1个45帧,这样就可以凑成每1秒44100帧,也就是44.1KHz),而不是固定在48帧(192字节)


也就是说,以下的AudioStreaming Endpoint Descriptor里宣告MaxPacketsOnly是错误的,因为明显与BTR3的需要相违背:


      AudioStreaming Interface Descriptor:
        bLength                14
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            2 Discrete
        tSamFreq[ 0]        48000
        tSamFreq[ 1]        44100
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x81
            Sampling Frequency
            MaxPacketsOnly
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay         0x0000


它的bmAttributes应改改为0x80(0b10000000)


3条回复 正序排序 倒序排序  GO!