RE: UAC2 gadget not recognized on Windows 10
> Enabling SOF interrupts will be a big pain :-) Well, enabling the > interrupt itself is a no-brainer, but it'll cause terrible CPU overload. Oh, I see. Hmm... would it be possible to allow upper levels to config this dynamically ? I.e. for the ALSA subsystem there is no need for the SOF timestamps, whereas for my proposal they would be needed. And what kind of CPU overhead are we talking about ? The IRQs shouldn't come more often than every 125 us, and all that is needed is to take a timestamp value But I'm probably overlooking a lot of stuff... Regards /Robert
RE: UAC2 gadget not recognized on Windows 10
> >> I guess UAC1 doesn't need feedback endpoints, right? Seems like that > >> should be something specific to UAC2. At least for now. > > > > It seems like it is needed there aswell, see > > http://www.usb.org/developers/docs/devclass_docs/audio10.pdf (3.7.2.2) > > (Feedback endpoint == Synch Endpoint) > > fair enough, then it could be done generically in u_audio.c Ok, but I guess for the generic case (when it is possible to calculate the feedback value) that lower levels need to provide f.i. the high resolution timestamps of SOF IRQs to upper levels ? In the ALSA subsystem case, the calculation is straightforward and static. I don't know if you saw my proposal for a new UAC2 gadget upper level implementation, where the gadget should be exposed as a JACK client. In this case, there would be need for those SOF timestamps to be able to calculate the feedback value. Regards /Robert -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: UAC2 gadget not recognized on Windows 10
> I guess UAC1 doesn't need feedback endpoints, right? Seems like that > should be something specific to UAC2. At least for now. It seems like it is needed there aswell, see http://www.usb.org/developers/docs/devclass_docs/audio10.pdf (3.7.2.2) (Feedback endpoint == Synch Endpoint) Regards /R
RE: UAC2 gadget not recognized on Windows 10
> >> Indeed, that's also mandated by USB spec. Seems like we need to patch > >> f_uac2.c. Can you check if setting the IN endpoint as implicit feedback > >> data is enough? > > > > Just tried your proposed patches on 4.15.1 (with an RPi Zero) and with > > g_audio, unfortunately there is no change. Device is still not > > recognized, and having the same error code. > > > > So, a real feedback IN endpoint is needed ☹ > > I'll see if I can reproduce this here. Perhaps someone in the office has > Windows 10, who knows. Great! Regarding feedback (IN) endpoint: With the current architecture, i.e. UAC2 gadget connecting to ALSA subsystem, I think the implementation of a feedback endpoint should only need to return (fs/1000)/8 (i.e. number of frames per 125 us), so in case of fs = 48000, feedback should return 6, and for 44100 it would be 5.5125 (with 3 bytes encoded in 10.14 format). Unfortunately I have yet no idea where in the gadget driver hierarchy this stuff should be implemented. Should it be f_uac2.c ? Afaict, the endpoints themselves are declared in struct g_audio (u_audio.h), so that struct should be extended with a feedback_ep ? Learning as I go along... Regards /Robert
RE: UAC2 gadget not recognized on Windows 10
Hi Felipe, > Indeed, that's also mandated by USB spec. Seems like we need to patch > f_uac2.c. Can you check if setting the IN endpoint as implicit feedback > data is enough? Just tried your proposed patches on 4.15.1 (with an RPi Zero) and with g_audio, unfortunately there is no change. Device is still not recognized, and having the same error code. So, a real feedback IN endpoint is needed ☹ Regards /Robert
RE: UAC2 gadget not recognized on Windows 10
> > Yes, but that isn't the issue AFAIU ? In the USB 2.0 standard related > > to synchronization > > (http://sdphca.ucsd.edu/lab_equip_manuals/usb_20.pdf chapter 5.12.4), > > an isochronous OUT ep with asynchronous synchronization is *required* > > (at least by Microsoft) to have a feedback IN ep, to be able to report > > to the host the rate so no under- or overrun condition occurs. > > Indeed, that's also mandated by USB spec. Seems like we need to patch > f_uac2.c. Can you check if setting the IN endpoint as implicit feedback > data is enough? Thanks Felipe, I have all setup so I can try this. Regards /Robert -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: UAC2 gadget not recognized on Windows 10
> > It seems such a feedback endpoint is now required by the standard: > > "The USB 2.0 specification states that if isochronous OUT data > > endpoint uses the asynchronous synchronization, an isochronous > > feedback endpoint is needed." > > We actually have both EP IN and EP OUT on the UAC2 function: > > 272:static struct usb_endpoint_descriptor fs_epout_desc = { > 282:static struct usb_endpoint_descriptor hs_epout_desc = { > 349:static struct usb_endpoint_descriptor fs_epin_desc = { > 359:static struct usb_endpoint_descriptor hs_epin_desc = { Yes, but that isn't the issue AFAIU ? In the USB 2.0 standard related to synchronization (http://sdphca.ucsd.edu/lab_equip_manuals/usb_20.pdf chapter 5.12.4), an isochronous OUT ep with asynchronous synchronization is *required* (at least by Microsoft) to have a feedback IN ep, to be able to report to the host the rate so no under- or overrun condition occurs. Regards /Robert N�r��yb�X��ǧv�^�){.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�
UAC2 audio gadget queries
Hi all, I'm trying to get my head around how the UAC2 gadget stuff is supposed to work in relation to sample rate conversion etc. etc. From the docs (https://www.kernel.org/doc/htmldocs/gadget/structure.html), I surmise that: 1. USB controller driver 2. Gadget Driver 3. Upper Level (u_audio.c) connecting into ALSA subsystem What I'm not clear about is who is responsible for clocking ? For a more HW based gadget, an externally clocked DAC connected via I2S would pull data from a buffer, and the OUT endpoint would supply data into that endpoint and synchronize the host sending the data via the feedback IN endpoint. To play audio with the above structure would mean piping data from the UAC2 Gadget Capture device to the target ALSA output device, which in my case is an externally clocked DAC. The problem then arises that the "clock" of the UAC2 gadget and the output DAC are unrelated and there is no way to feedback the clocking to the UAC2 gadget via the ALSA interface (for the feedback endpoint). This can of course be handled by sample rate conversion, but it is suboptimal. A better approach would be IMO to create something like: 1. USB controller driver 2. Gadget driver 3. Upper Level connecting as a JACK client. In this scenario, JACK would already be setup to use the externally clocked DAC. By implementing a JACK client connecting to the gadget driver there would now be a direct way to supply the feedback endpoint with the data it needs. Please let me know if I'm missing something. All the best, /Robert -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: UAC2 gadget not recognized on Windows 10
> > > > 4.9 is over a year old, can you try 4.14, or even better yet, 4.15? Just to confirm, I've tried with 4.14.18 (latest from https://github.com/raspberrypi/firmware), and the problem remains. Regards /R N�r��yb�X��ǧv�^�){.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�
RE: UAC2 gadget not recognized on Windows 10
> "Wait, never mind – I recognize that failing status code. usbaudio2.sys is > complaining that you have an asynchronous data OUT endpoint but it can’t > find a corresponding feedback endpoint." > > Unfortunately I have no idea what that means. Yet , but putting it out there > in case someone else does. https://doc.micrium.com/display/DOC/Audio+Class+Overview#AudioClassOverview-FeedbackEndpoint It seems such a feedback endpoint is now required by the standard: "The USB 2.0 specification states that if isochronous OUT data endpoint uses the asynchronous synchronization, an isochronous feedback endpoint is needed." Regards /R N�r��yb�X��ǧv�^�){.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�
RE: UAC2 gadget not recognized on Windows 10
> > Kernel version is 4.9.68 (https://github.com/raspberrypi/linux , > > commit d5a3b4cab0c8eacc93e58cfa1bdbd259399caedd), the wTotalLength > > calc error is present in latest version also > > > (https://github.com/torvalds/linux/blob/master/drivers/usb/gadget/functio > n/f_uac2.c#L219) > > 4.9 is over a year old, can you try 4.14, or even better yet, 4.15? Ok, I'll try that. Meanwhile relaying information from the windows audio driver list (from Matthew van Eerde): "Wait, never mind – I recognize that failing status code. usbaudio2.sys is complaining that you have an asynchronous data OUT endpoint but it can’t find a corresponding feedback endpoint." Unfortunately I have no idea what that means. Yet , but putting it out there in case someone else does. Regards /Robert N�r��yb�X��ǧv�^�){.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�
RE: UAC2 gadget not recognized on Windows 10
> We don't do github pull requests for the kernel, please see the long > text response in that request for how to do it properly. > > Heck, we don't even use github :) I know, found it out the hard way > > > However, that wasn't enough. The device still isn't loaded properly. > > What do you mean by "not loaded properly"? > > What specific errors are reported? And what kernel version are you > using? Kernel version is 4.9.68 (https://github.com/raspberrypi/linux , commit d5a3b4cab0c8eacc93e58cfa1bdbd259399caedd), the wTotalLength calc error is present in latest version also (https://github.com/torvalds/linux/blob/master/drivers/usb/gadget/function/f_uac2.c#L219) Error is simply "This device cannot start. (Code 10)", with an excerpt from setupapi.dev.log: sto: {Configure Driver Package: exit(0x)} dvi: Install Device: Configuring device class. 15:36:08.031 dvi: Install Device: Configuring device class completed. 15:36:08.038 dvi: Device Status: 0x01806400, Problem: 0x1 (0xc493) dvi: Install Device: Starting device 'USB\VID_1D6B_0104\DEADBEEF00115599'. 15:36:08.045 dvi: Install Device: Starting device completed. 15:36:08.070 !!! dvi: Device not started: Device has problem: 0x0a (CM_PROB_FAILED_START), problem status: 0xc0440025. Using the TDD tool (http://www.thesycon.de/eng/usb_descriptordumper.shtml) I can see that the patch fixed the problem with wTotalLength, and now I can't see anything that looks suspicious. Regards /Robert
UAC2 gadget not recognized on Windows 10
Dear all, I'm struggling with getting a RPi Zero based UAC2 gadget working with Windows 10. In the progress I've found a bug in f_uac2.c , where wTotalLength was calculated erroneously https://github.com/torvalds/linux/pull/515 (I'll be preparing a proper patch submission for this, which I've tested on Raspbian Stretch Lite). However, that wasn't enough. The device still isn't loaded properly. Any pointers on how to proceed would be appreciated. The setup script for the gadget: - #!/bin/bash -e modprobe libcomposite cd /sys/kernel/config/usb_gadget/ mkdir g1 && cd g1 echo 0x1d6b > idVendor # Linux Foundation echo 0x0104 > idProduct # Multifunction Composite Gadget echo 0x0100 > bcdDevice # v1.0.0 echo 0x0200 > bcdUSB# USB 2.0 echo 0x01 > bDeviceClass echo 0x02 > bDeviceSubClass echo 0x20 > bDeviceProtocol mkdir -p strings/0x409 echo "deadbeef00115599" > strings/0x409/serialnumber echo "irq5 labs"> strings/0x409/manufacturer echo "Pi Zero Gadget" > strings/0x409/product mkdir -p functions/uac2.usb0 # audio echo 3 > functions/uac2.usb0/c_chmask echo 48000 > functions/uac2.usb0/c_srate echo 4 > functions/uac2.usb0/c_ssize echo 3 > functions/uac2.usb0/p_chmask echo 48000 > functions/uac2.usb0/p_srate echo 4 > functions/uac2.usb0/p_ssize mkdir -p configs/c.1 echo 250 > configs/c.1/MaxPower mkdir -p configs/c.1/strings/0x409 echo "Audio" > configs/c.1/strings/0x409/configuration ln -s functions/uac2.usb0 configs/c.1/ echo 1 > os_desc/use echo 0xcd> os_desc/b_vendor_code echo MSFT100 > os_desc/qw_sign ln -s configs/c.1 os_desc #udevadm settle -t 5 || : ls /sys/class/udc/ > UDC - Best regards /Robert Bielik Ps. Apologies if this isn't the correct forum for these kinds of questions. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html