Re: usb: gadget: dwc2: not getting audio data

Minas Harutyunyan
2023-05-18T11:22:51Z

Hi Palak,

On 5/17/23 23:02, PALAK SHAH wrote:
> Hi Minas,
>
> Minas wrote:
>
>> So, to set req num to 32 resolve time gap issue and ISOC OUT transfers
>> (aplay) going OK. Please keep this 32 setting always.
>
> I will keep UAC1_DEF_REQ_NUM at 32.
>
> Please note that I am NOT DOING APLAY here. We are currently only testing SPEAKERS, not microphone. The 5.10.100 kernel has some parameter checks (f_audio_validate_opts ), so I had to enable microphone (EP4(IN)). But I am not testing microphone.
>
> I am trying to CAPTURE AUDIO on my Linux device (acting as an audio gadget). I am playing some audio using you tube on the host machine. And it sending the data to my device, which is target. The endpoint from which I want to capture data is EP1(OUT).
>
>
> Minas wrote:
>
>> Arecord. In latest log I see that function driver, besides EP1OUT (which for aplay and it normally works),
>
>> queued 32 requests to EP4IN, which I assume endpoint for ISOC IN for arecord. But transfer on EP4IN never > start. Please provide me log and usb trace when you doing aplay with arecord.
>
>
> Again, I am not running aplay yet. I am testing only arecord to make sure that the audio data from the USB target (host machine) can be retrieved.
>
> Before changing the number of request to 32, the dwc2 isochronous transfers will stop. With the count 32, the endpoint isn’t shutting down, BUT I want to capture the data using ARECORD in a file and that is not happening. The file is only 44 bytes.
>
> Below is the example of what I am doing -
>
> HOST MACHINE -
>
> PLAY AUDIO USING YOUTUBE, DEVICE SOUND SETTINGS SELECT LINUX AUDIO GADGET
>
>
>
> LINUX DEVICE (USB AUD GADGET)
>
> ARECORD -f S32_LE -c 2 test.wav // try to capture the data coming on EP1(OUT)
>
> Even though I am seeing data on EP1(OUT), the test.wav is only 44 bytes.
>
> I have attached USB trace file. The logs are the same as I sent yesterday.
>
> Thanks,
> Palak
>
> -----Original Message-----
> From: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
> Sent: Wednesday, May 17, 2023 2:05 AM
> To: PALAK SHAH <palak.shah@raritan.com>; Maynard CABIENTE <maynard.cabiente@raritan.com>
> Cc: linux-usb@vger.kernel.org
> Subject: Re: usb: gadget: dwc2: not getting audio data
>
> Hi Palak,
>
> On 5/17/23 00:43, PALAK SHAH wrote:
>> Hi Minas,
>> 1. Depend on which uac(uac1 or uac2) you use, increase 2 to 32
>>
>> I change the #define UAC1_DEF_REQ_NUM 32.
>>
>> When I do this, what I see is, that when I play audio on the target, I don’t see the ENDPOINT shutdown. HOWEVER, when I try to record the data, I DO NOT RECORD any data.
>> The arecord file is empty with only 44 bytes. I saw the same behavior 2 months ago with the older version of kernel.
>>
>
> So, to set req num to 32 resolve time gap issue and ISOC OUT transfers
> (aplay) going OK. Please keep this 32 setting always.
>
> Arecord. In latest log I see that function driver, besides EP1OUT (which for aplay and it normally works), queued 32 requests to EP4IN, which I assume endpoint for ISOC IN for arecord. But transfer on EP4IN never start. Please provide me log and usb tarce when you doing aplay with arecord.
>
>> The logs show that the data comes on EP1(OUT) and the buffer queues upto #255 and then wraps around to 0. USB sniffer also shows data coming in.
> Wrapping from #255 to #0 is Ok, driver allocate 256 descriptors
>
>
> Thanks,
> Minas
>
>>

On device machine run recording by follow command:
arecord -D plughw:CARD=UAC2Gadget,DEV=0 test.wav

On host machine playing audio by follow command:
aplay -D plughw:CARD=audiogadget,DEV=0
/usr/share/sounds/alsa/Front_Center.wav

On play finish terminated arecord by CTRL-C

Recorded test.wav file contain audio data.

Thanks,
Minas