diff mbox series

Simultaneous play/record on implicit feedback device causes 'endpoint in use' error

Message ID BN7PR11MB2755B1BC150703C0DFC2DA919CCC0@BN7PR11MB2755.namprd11.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series Simultaneous play/record on implicit feedback device causes 'endpoint in use' error | expand

Commit Message

Robert Giaraffa Oct. 30, 2018, 11:15 p.m. UTC
My company (Silicon Labs) makes a CP2615 USB audio class 1.0 device which uses implicit feedback.  I saw these two issues when testing with aplay/arecord/alsabat/alsaloop:


  *   During playback-only operation, the implicit feedback (IN) endpoint was not active.


  *   During play/record operation, the implicit feedback values were not acted on, i.e. the host always sent 192 bytes per OUT packet even if previous IN packets had been 188 or 196 bytes.

This behavior was observed on these systems:

RaspberryPi2:    Raspbian 9 (stretch), kernel v4.14.72
x86-64:                 Ubuntu 18.04, kernel v4.15.0-36

I was able to get implicit feedback working properly in playback mode by adding a device-specific quirk to 'pcm.c' that is similar to existing quirks for implicit-feedback devices, e.g. M-Audio Fast Track Ultra.  (Note: The following patch applies to kernel v4.14.72.  In v4.18, the set_sync_ep_implicit_fb_quirk function was changed so that there is a single call to usb_ifnum_to_if(), rather than a call for each device-dependent quirk.)

$ git diff pcm.c

After adding the patch, I verified that implicit feedback worked properly for playback, i.e. the OUT samples per packet tracked previous IN values.  However, when attempting to perform simultaneous play and record via alsabat, alsaloop, or separate aplay/arecord, the system reports the 'endpoint already in use' error when attempting to set the format for the IN endpoint that is already in use (note that this dmesg log has customized printk messages):

    [Oct23 10:13] snd_usb_hw_params->set_format()
    [  +0.000014] set_format(): dev:b3856c00 alts:b67e8824 ifnum: 3
    [  +0.001654] set_format()->usb_set_interface 3:1
    [  +0.000006] Creating new playback data endpoint 03
    [  +0.000004] Creating new capture data endpoint 83

<Begin Playback. SYNC endpoint also starts because feedback is implicit>

    [  +0.000027] snd_usb_pcm_prepare->set_format()
    [  +0.000005] set_format(): dev:b3856c00 alts:b67e8824 ifnum: 3
    [  +0.000755] Setting params for EP 03 (type 0, 12 urbs), ret=0
    [  +0.000017] Setting params for EP 83 (type 0, 12 urbs), ret=0
    [  +0.000004] Starting DATA_EP 03 @b9224000
    [  +0.000004] snd_usb_endpoint_implicit_feedback_sink (03) is TRUE
    [  +0.001495] Starting SYNC_EP 83 @b9222000

<After playing for 0.5s, start recording. Failure occurs because EP83 is already in use.>

    [  +0.493035] snd_usb_hw_params->set_format()
    [  +0.000016] set_format(): dev:b3856c00 alts:b67e88a4 ifnum: 4
    [  +0.001549] set_format()->usb_set_interface 4:1
    [  +0.000005] Re-using EP 83 in iface 4:1
    [  +0.000028] snd_usb_pcm_prepare->set_format()
    [  +0.000004] set_format(): dev:b3856c00 alts:b67e88a4 ifnum: 4
*** [  +0.003196] *** snd_usb_endpoint_set_params(): EP #83: already in use
    [  +0.000003] configure_endpoint->endpoint_set_params: err=FFFFFFF0

I bought a used Fast Track Ultra device for comparison testing, and found that it behaved the same way as the CP2615 does with the implicit feedback quirk: in playback-only mode implicit feedback works properly, but play/record causes the 'EP already in use' error.

Are there any suggestions on how I can resolve this issue?  Any help would be greatly appreciated!

Thanks,
Bob Giaraffa

Comments

Takashi Iwai Oct. 31, 2018, 11:57 a.m. UTC | #1
On Wed, 31 Oct 2018 00:15:51 +0100,
Robert Giaraffa wrote:
> 
> My company (Silicon Labs) makes a CP2615 USB audio class 1.0 device which uses implicit feedback.  I saw these two issues when testing with aplay/arecord/alsabat/alsaloop:
> 
> 
>   *   During playback-only operation, the implicit feedback (IN) endpoint was not active.
> 
> 
>   *   During play/record operation, the implicit feedback values were not acted on, i.e. the host always sent 192 bytes per OUT packet even if previous IN packets had been 188 or 196 bytes.
> 
> This behavior was observed on these systems:
> 
> RaspberryPi2:    Raspbian 9 (stretch), kernel v4.14.72
> x86-64:                 Ubuntu 18.04, kernel v4.15.0-36
> 
> I was able to get implicit feedback working properly in playback mode by adding a device-specific quirk to 'pcm.c' that is similar to existing quirks for implicit-feedback devices, e.g. M-Audio Fast Track Ultra.  (Note: The following patch applies to kernel v4.14.72.  In v4.18, the set_sync_ep_implicit_fb_quirk function was changed so that there is a single call to usb_ifnum_to_if(), rather than a call for each device-dependent quirk.)
> 
> $ git diff pcm.c
> diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
> index b9c9a19f..6fb5567b 100644
> --- a/sound/usb/pcm.c
> +++ b/sound/usb/pcm.c
> @@ -358,6 +358,21 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
>                 alts = &iface->altsetting[1];
>                 goto add_sync_ep;
> 
> +       case USB_ID(0x10C4, 0xEAC1):    // Silicon Labs CP2615
> +               // Ensure CP2615 is configured in Async Mode
> +               if (attr != USB_ENDPOINT_SYNC_ASYNC)
> +                       return 0;
> +
> +               // In P16R16 async mode, AudioIN EP (IF:4 EP:0x83) used for implicit feedback
> +               ep = 0x83;
> +               iface = usb_ifnum_to_if(dev, 4);
> +
> +               if (!iface || iface->num_altsetting == 0)
> +                       return -EINVAL;
> +
> +               alts = &iface->altsetting[1];
> +               goto add_sync_ep;
> +
>         }
>         if (attr == USB_ENDPOINT_SYNC_ASYNC &&
>             altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
> 
> After adding the patch, I verified that implicit feedback worked properly for playback, i.e. the OUT samples per packet tracked previous IN values.  However, when attempting to perform simultaneous play and record via alsabat, alsaloop, or separate aplay/arecord, the system reports the 'endpoint already in use' error when attempting to set the format for the IN endpoint that is already in use (note that this dmesg log has customized printk messages):
> 
>     [Oct23 10:13] snd_usb_hw_params->set_format()
>     [  +0.000014] set_format(): dev:b3856c00 alts:b67e8824 ifnum: 3
>     [  +0.001654] set_format()->usb_set_interface 3:1
>     [  +0.000006] Creating new playback data endpoint 03
>     [  +0.000004] Creating new capture data endpoint 83
> 
> <Begin Playback. SYNC endpoint also starts because feedback is implicit>
> 
>     [  +0.000027] snd_usb_pcm_prepare->set_format()
>     [  +0.000005] set_format(): dev:b3856c00 alts:b67e8824 ifnum: 3
>     [  +0.000755] Setting params for EP 03 (type 0, 12 urbs), ret=0
>     [  +0.000017] Setting params for EP 83 (type 0, 12 urbs), ret=0
>     [  +0.000004] Starting DATA_EP 03 @b9224000
>     [  +0.000004] snd_usb_endpoint_implicit_feedback_sink (03) is TRUE
>     [  +0.001495] Starting SYNC_EP 83 @b9222000
> 
> <After playing for 0.5s, start recording. Failure occurs because EP83 is already in use.>
> 
>     [  +0.493035] snd_usb_hw_params->set_format()
>     [  +0.000016] set_format(): dev:b3856c00 alts:b67e88a4 ifnum: 4
>     [  +0.001549] set_format()->usb_set_interface 4:1
>     [  +0.000005] Re-using EP 83 in iface 4:1
>     [  +0.000028] snd_usb_pcm_prepare->set_format()
>     [  +0.000004] set_format(): dev:b3856c00 alts:b67e88a4 ifnum: 4
> *** [  +0.003196] *** snd_usb_endpoint_set_params(): EP #83: already in use
>     [  +0.000003] configure_endpoint->endpoint_set_params: err=FFFFFFF0
> 
> I bought a used Fast Track Ultra device for comparison testing, and found that it behaved the same way as the CP2615 does with the implicit feedback quirk: in playback-only mode implicit feedback works properly, but play/record causes the 'EP already in use' error.
> 
> Are there any suggestions on how I can resolve this issue?  Any help would be greatly appreciated!

How about starting the recording before the playback?

Adding Daniel to Cc, who implemented the code originally.


Takashi
Robert Giaraffa Oct. 31, 2018, 7:45 p.m. UTC | #2
Thank you very much for your prompt response.



I tested the CP2615 and Fast Track Ultra by running aplay and arecord sequentially on my RPi2 v4.14.72 (with patched snd-usb-audio.ko that includes implicit feedback quirk for CP2615).  Although there were minor differences in the system logs for the two devices (e.g. 'cannot submit urb'), but otherwise both devices behaved the same: whichever operation is started last resulted in the 'Endpoint already in use' error, regardless of sequence.  Detailed info below:



=========================================

// CP2615: Run arecord first, then aplay:

=========================================

- No console error after starting 'arecord':

    $ sudo arecord -fdat -d5 junk.wav

        Recording WAVE 'junk.wav' :

        Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

- System log messages after starting 'arecord' (no errors present, printks are for info only):

    [Oct31 10:52] snd_usb_hw_params->set_format()

    [  +0.000021] set_format(): dev:b6f1f000 alts:b7a62864 ifnum: 4

    [  +0.001655] set_format()->usb_set_interface 4:1

    [  +0.000006] Re-using EP 83 in iface 4:1

    [  +0.000004] set_sync_endpoint() early return (NumEP=01)

    [  +0.000034] snd_usb_pcm_prepare->set_format()

    [  +0.000005] set_format(): dev:b6f1f000 alts:b7a62864 ifnum: 4

    [  +0.000002] set_format() early return (fmt==subs->cur_audiofmt)

    [  +0.000782] Setting params for EP 83 (type 0, 12 urbs), ret=0

    [  +0.001106] Starting DATA_EP 83 @b6cb4000



- After starting aplay, console reports 'Unable to install hw params'

  and system log reports 'EP #83: already in use':

  $ sudo aplay -fdat 997Hz_-3dB_48kHz_16bit_10s.wav

      Playing WAVE '997Hz_-3dB_48kHz_16bit_10s.wav' :

      Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

==> aplay: set_params:1363: Unable to install hw params:

    ACCESS:  RW_INTERLEAVED

    FORMAT:  S16_LE

    SUBFORMAT:  STD

    SAMPLE_BITS: 16

    FRAME_BITS: 32

    CHANNELS: 2

    RATE: 48000

    PERIOD_TIME: 125000

    PERIOD_SIZE: 6000

    PERIOD_BYTES: 24000

    PERIODS: 4

    BUFFER_TIME: 500000

    BUFFER_SIZE: 24000

    BUFFER_BYTES: 96000

    TICK_TIME: 0



    [  +1.466748] snd_usb_hw_params->set_format()

    [  +0.000018] set_format(): dev:b6f1f000 alts:b7a628a4 ifnum: 3

    [  +0.001550] set_format()->usb_set_interface 3:1

    [  +0.000005] Re-using EP 3 in iface 3:1

    [  +0.000006] *** CP2615 setting sync EP quirk

    [  +0.000003] Re-using EP 83 in iface 4:1

    [  +0.000003] set_sync_endpoint() early return (NumEP=01)

    [  +0.000036] snd_usb_pcm_prepare->set_format()

    [  +0.000005] set_format(): dev:b6f1f000 alts:b7a628a4 ifnum: 3

    [  +0.000002] set_format() early return (fmt==subs->cur_audiofmt)

    [  +0.004645] Setting params for EP 03 (type 0, 12 urbs), ret=0

==> [  +0.000006] *** snd_usb_endpoint_set_params(): EP #83: already in use

    [  +0.000003] configure_sync_endpoint->endpoint_set_params: err=FFFFFFF0

    [  +0.000003] snd_usb_pcm_prepare()->configure_endpoint(): err = FFFFFFF0

    [  +3.532988] Stopping data EP

    [  +0.000035] Setting FLAG_STOPPING on EP83

    [  +0.000011] Waiting for EP 83 to stop



=========================================

// CP2615: Run aplay first, then arecord:

=========================================

- No console error after starting aplay:

    $ sudo aplay -fdat 997Hz_-3dB_48kHz_16bit_10s.wav

        Playing WAVE '997Hz_-3dB_48kHz_16bit_10s.wav' :

        Signed 16 bit Little Endian, Rate 48000 Hz, Stereo



- dmesg after starting aplay (info only, no errors):

    [Oct31 11:14] snd_usb_hw_params->set_format()

    [  +0.000018] set_format(): dev:b6f1f000 alts:b7a628a4 ifnum: 3

    [  +0.001630] set_format()->usb_set_interface 3:1

    [  +0.000005] Re-using EP 3 in iface 3:1

    [  +0.000005] *** CP2615 setting sync EP quirk

    [  +0.000003] Re-using EP 83 in iface 4:1

    [  +0.000004] set_sync_endpoint() early return (NumEP=01)

    [  +0.000036] snd_usb_pcm_prepare->set_format()

    [  +0.000004] set_format(): dev:b6f1f000 alts:b7a628a4 ifnum: 3

    [  +0.000003] set_format() early return (fmt==subs->cur_audiofmt)

    [  +0.000768] Setting params for EP 03 (type 0, 12 urbs), ret=0

    [  +0.000031] Setting params for EP 83 (type 0, 12 urbs), ret=0

    [  +0.000004] Starting DATA_EP 03 @b6cb0000

    [  +0.000004] snd_usb_endpoint_implicit_feedback_sink (03) is TRUE

    [  +0.001588] Starting SYNC_EP 83 @b6cb4000



- Console error after starting arecord:

    $ sudo arecord -fdat -d5 junk.wav

        Recording WAVE 'junk.wav' :

        Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

==>   arecord: set_params:1363: Unable to install hw params:

      ACCESS:  RW_INTERLEAVED

      FORMAT:  S16_LE

      SUBFORMAT:  STD

      SAMPLE_BITS: 16

      FRAME_BITS: 32

      CHANNELS: 2

      RATE: 48000

      PERIOD_TIME: 125000

      PERIOD_SIZE: 6000

      PERIOD_BYTES: 24000

      PERIODS: 4

      BUFFER_TIME: 500000

      BUFFER_SIZE: 24000

      BUFFER_BYTES: 96000

      TICK_TIME: 0



- dmesg after starting arecord ('EP #83 already in use'):

    [  +2.410222] snd_usb_hw_params->set_format()

    [  +0.000017] set_format(): dev:b6f1f000 alts:b7a62864 ifnum: 4

    [  +0.001487] set_format()->usb_set_interface 4:1

    [  +0.000005] Re-using EP 83 in iface 4:1

    [  +0.000004] set_sync_endpoint() early return (NumEP=01)

    [  +0.000032] snd_usb_pcm_prepare->set_format()

    [  +0.000004] set_format(): dev:b6f1f000 alts:b7a62864 ifnum: 4

    [  +0.000003] set_format() early return (fmt==subs->cur_audiofmt)

==> [  +0.003509] *** snd_usb_endpoint_set_params(): EP #83: already in use

    [  +0.000008] configure_endpoint->endpoint_set_params: err=FFFFFFF0

    [  +0.000004] snd_usb_pcm_prepare()->configure_endpoint(): err = FFFFFFF0



- After arecord failed, aplay did nothing for ~45s, after which this console

  error appeared:

    aplay: pcm_write:2011: write error: Input/output error



  These messages then appeared in the system log, and aplay exited:

    [Oct31 11:15] Stopping sync EP

    [  +0.000011] Setting FLAG_STOPPING on EP83

    [  +0.000002] Stopping data EP

    [  +0.000003] Setting FLAG_STOPPING on EP03

    [  +0.000012] Waiting for EP 83 to stop

    [  +0.000003] Waiting for EP 03 to stop



=================================================

// FastTrackUltra: Run arecord first, then aplay:

=================================================

- No console error after starting 'arecord':

    $ sudo arecord -c2 -Dplughw:Ultra -r48000 -fS24_3LE -d5 junk.wav

        Recording WAVE 'junk.wav' :

        Signed 24 bit Little Endian in 3bytes, Rate 48000 Hz, Stereo



- System log messages after starting 'arecord' (???: Is the '-75' an error?):

    [Oct31 13:46] snd_usb_hw_params->set_format()

    [  +0.000019] set_format(): dev:b6f87400 alts:b6c019a4 ifnum: 2

    [  +0.000331] set_format()->usb_set_interface 2:1

    [  +0.000006] Creating new capture data endpoint 81

    [  +0.000012] set_sync_endpoint() early return (NumEP=01)

    [  +0.000127] snd_usb_pcm_prepare->set_format()

    [  +0.000005] set_format(): dev:b6f87400 alts:b6c019a4 ifnum: 2

    [  +0.000003] set_format() early return (fmt==subs->cur_audiofmt)

    [  +0.000586] Setting params for EP 81 (type 0, 12 urbs), ret=0

    [  +0.001588] Starting DATA_EP 81 @b9cc0000

??? [  +0.001360] usb 1-1.4: frame 1 active: -75



- After starting aplay, console reports 'Unable to install hw params'

  and system log reports 'EP #83: already in use' (similar to CP2615 case).

    $ sudo aplay -c2 -Dplughw:Ultra -r48000 -fS24_3LE 24bit.wav

    Playing WAVE '24bit.wav' : Signed 24 bit Little Endian in 3bytes, Rate 48000 Hz, Stereo

==> aplay: set_params:1363: Unable to install hw params:

    ACCESS:  RW_INTERLEAVED

    FORMAT:  S24_3LE

    SUBFORMAT:  STD

    SAMPLE_BITS: 24

    FRAME_BITS: 48

    CHANNELS: 2

    RATE: 48000

    PERIOD_TIME: 125000

    PERIOD_SIZE: 6000

    PERIOD_BYTES: 36000

    PERIODS: 4

    BUFFER_TIME: 500000

    BUFFER_SIZE: 24000

    BUFFER_BYTES: 144000

    TICK_TIME: 0



=================================================

// FastTrackUltra: Run aplay first, then arecord:

=================================================

- No console error after starting aplay:

     $ sudo aplay -c2 -Dplughw:Ultra -r48000 -fS24_3LE 24bit.wav

         Playing WAVE '24bit.wav' :

         Signed 24 bit Little Endian in 3bytes, Rate 48000 Hz, Stereo



- dmesg after starting aplay (info only, no errors):

    [Oct31 13:55] snd_usb_hw_params->set_format()

    [  +0.000017] set_format(): dev:b6f87400 alts:b6cbc264 ifnum: 1

    [  +0.000260] set_format()->usb_set_interface 1:1

    [  +0.000006] Re-using EP 1 in iface 1:1

    [  +0.000005] Re-using EP 81 in iface 2:1

    [  +0.000004] set_sync_endpoint(): mode is Playback with adaptive FB

    [  +0.000119] snd_usb_pcm_prepare->set_format()

    [  +0.000006] set_format(): dev:b6f87400 alts:b6cbc264 ifnum: 1

    [  +0.000002] set_format() early return (fmt==subs->cur_audiofmt)

    [  +0.000499] Setting params for EP 01 (type 0, 12 urbs), ret=0

    [  +0.000031] Setting params for EP 81 (type 0, 12 urbs), ret=0

    [  +0.000004] Starting DATA_EP 01 @b9cc6000

    [  +0.000005] snd_usb_endpoint_implicit_feedback_sink (01) is TRUE

    [  +0.000247] Starting SYNC_EP 81 @b9cc0000



- After starting arecord, console reports 'Unable to install hw params' and arecord exits:

    $ sudo arecord -c2 -Dplughw:Ultra -r48000 -fS24_3LE -d5 junk.wav

        Recording WAVE 'junk.wav' : Signed 24 bit Little Endian in 3bytes, Rate 48000 Hz, Stereo

==>     arecord: set_params:1363: Unable to install hw params:

        ACCESS:  RW_INTERLEAVED

        FORMAT:  S24_3LE

        SUBFORMAT:  STD

        SAMPLE_BITS: 24

        FRAME_BITS: 48

        CHANNELS: 2

        RATE: 48000

        PERIOD_TIME: 125000

        PERIOD_SIZE: 6000

        PERIOD_BYTES: 36000

        PERIODS: 4

        BUFFER_TIME: 500000

        BUFFER_SIZE: 24000

        BUFFER_BYTES: 144000

        TICK_TIME: 0



- ... and the system log reports 'EP already in use' and 'cannot submit urb' errors:

    [  +1.364234] snd_usb_hw_params->set_format()

    [  +0.000018] set_format(): dev:b6f87400 alts:b6c019a4 ifnum: 2

==> [  +0.000037] usb 1-1.4: cannot submit urb (err = -2)

    [  +0.000004] ERROR snd_complete_urb(): Cannot submit urb (err = -2)

    [  +0.000225] set_format()->usb_set_interface 2:1

    [  +0.000005] Re-using EP 81 in iface 2:1

    [  +0.000006] set_sync_endpoint() early return (NumEP=01)

    [  +0.000091] snd_usb_pcm_prepare->set_format()

    [  +0.000005] set_format(): dev:b6f87400 alts:b6c019a4 ifnum: 2

    [  +0.000002] set_format() early return (fmt==subs->cur_audiofmt)

==> [  +0.000564] *** snd_usb_endpoint_set_params(): EP #81: already in use

    [  +0.000004] configure_endpoint->endpoint_set_params: err=FFFFFFF0

    [  +0.000003] snd_usb_pcm_prepare()->configure_endpoint(): err = FFFFFFF0



- After arecord failed and exited, aplay did nothing (i.e. was hung) and

  had to be terminated with ^c. Console message after terminating aplay:

    Aborted by signal Interrupt...

    aplay: pcm_write:2011: write error: Interrupted system call



- System log messages after terminating aplay:

    [Oct31 14:00] Stopping sync EP

    [  +0.000012] Setting FLAG_STOPPING on EP81

    [  +0.000004] Stopping data EP

    [  +0.000003] Setting FLAG_STOPPING on EP01

    [  +0.000150] Waiting for EP 81 to stop

    [  +0.000004] Waiting for EP 01 to stop
Takashi Iwai Nov. 2, 2018, 3:57 p.m. UTC | #3
On Wed, 31 Oct 2018 20:45:07 +0100,
Robert Giaraffa wrote:
> 
> Thank you very much for your prompt response.
> 
> I tested the CP2615 and Fast Track Ultra by running aplay and arecord
> sequentially on my RPi2 v4.14.72 (with patched snd-usb-audio.ko that includes
> implicit feedback quirk for CP2615).  Although there were minor differences in
> the system logs for the two devices (e.g. ‘cannot submit urb’), but otherwise
> both devices behaved the same: whichever operation is started last resulted in
> the 'Endpoint already in use' error, regardless of sequence.  Detailed info
> below:

OK, so we obviously don't support the full duplex in this mode.

As a first step, could you try the simple patch below, and test in a
sequence record -> playback?  At least it should skip the check, and
proceed further.


thanks,

Takashi

--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -639,6 +639,10 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs)
 						   subs->cur_audiofmt,
 						   NULL);
 
+	if (subs->sync_endpoint->type == SND_USB_ENDPOINT_TYPE_DATA &&
+	    subs->sync_endpoint->use_count)
+		return 0;
+
 	/* Try to find the best matching audioformat. */
 	list_for_each_entry(fp, &sync_subs->fmt_list, list) {
 		int score = match_endpoint_audioformats(subs,
Alexander Tsoy Jan. 15, 2020, 3:33 p.m. UTC | #4
В Пт, 02/11/2018 в 16:57 +0100, Takashi Iwai пишет:
> On Wed, 31 Oct 2018 20:45:07 +0100,
> Robert Giaraffa wrote:
> > Thank you very much for your prompt response.
> > 
> > I tested the CP2615 and Fast Track Ultra by running aplay and
> > arecord
> > sequentially on my RPi2 v4.14.72 (with patched snd-usb-audio.ko
> > that includes
> > implicit feedback quirk for CP2615).  Although there were minor
> > differences in
> > the system logs for the two devices (e.g. ‘cannot submit urb’), but
> > otherwise
> > both devices behaved the same: whichever operation is started last
> > resulted in
> > the 'Endpoint already in use' error, regardless of
> > sequence.  Detailed info
> > below:
> 
> OK, so we obviously don't support the full duplex in this mode.
> 
> As a first step, could you try the simple patch below, and test in a
> sequence record -> playback?  At least it should skip the check, and
> proceed further.
> 
> 
> thanks,
> 
> Takashi
> 
> --- a/sound/usb/pcm.c
> +++ b/sound/usb/pcm.c
> @@ -639,6 +639,10 @@ static int configure_sync_endpoint(struct
> snd_usb_substream *subs)
>  						   subs->cur_audiofmt,
>  						   NULL);
>  
> +	if (subs->sync_endpoint->type == SND_USB_ENDPOINT_TYPE_DATA &&
> +	    subs->sync_endpoint->use_count)
> +		return 0;
> +
>  	/* Try to find the best matching audioformat. */
>  	list_for_each_entry(fp, &sync_subs->fmt_list, list) {
>  		int score = match_endpoint_audioformats(subs,

Well, this works... sort of:

[  107.368218] usb 5-1: setting usb interface 2:1
[  107.368225] usb 5-1: Creating new capture data endpoint #81
[  107.834139] usb 5-1: Setting params for ep #81 (type 0, 12 urbs),
ret=0
[  107.834272] usb 5-1: Starting data EP @00000000a802b8ef
[  110.296773] usb 5-1: setting usb interface 1:1
[  110.296779] usb 5-1: Creating new playback data endpoint #1
[  110.296811] usb 5-1: Re-using EP 81 in iface 2,1 @00000000a802b8ef
[  110.298381] usb 5-1: Setting params for ep #1 (type 0, 12 urbs),
ret=0
[  110.298385] usb 5-1: Starting data EP @00000000b2e4f53f
[  110.300585] usb 5-1: Starting sync EP @00000000a802b8ef


but aplay aborts after several seconds:

$ LANG=C aplay -c 4 -r 48000 -f S32_LE -D hw:M4,0 test48000.wav 
Playing WAVE 'test48000.wav' : Signed 32 bit Little Endian, Rate 48000
Hz, Channels 4
aplay: pcm_write:2053: write error: Input/output error



And an interesting note: jack is the only app that can use the card
with implicit feedback in full duplex mode even without that patch.


> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
diff mbox series

Patch

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index b9c9a19f..6fb5567b 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -358,6 +358,21 @@  static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
                alts = &iface->altsetting[1];
                goto add_sync_ep;

+       case USB_ID(0x10C4, 0xEAC1):    // Silicon Labs CP2615
+               // Ensure CP2615 is configured in Async Mode
+               if (attr != USB_ENDPOINT_SYNC_ASYNC)
+                       return 0;
+
+               // In P16R16 async mode, AudioIN EP (IF:4 EP:0x83) used for implicit feedback
+               ep = 0x83;
+               iface = usb_ifnum_to_if(dev, 4);
+
+               if (!iface || iface->num_altsetting == 0)
+                       return -EINVAL;
+
+               alts = &iface->altsetting[1];
+               goto add_sync_ep;
+
        }
        if (attr == USB_ENDPOINT_SYNC_ASYNC &&
            altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&