OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Multimedia => Topic started by: Mikhail on August 25, 2022, 09:41:12 pm

Title: XHCI and USB Audio perspectives
Post by: Mikhail on August 25, 2022, 09:41:12 pm
Greetings, dear community.
Please tell me what prospects to get UAC1/2 support for controllers without EHCI support.
As far as I understand now, the problem is the lack of isochronous support in the current drivers.
At the moment, there are more and more boards with controllers that support only XHCI interfaces, sound devices in USB ports do not work on such boards.
Does no one output sound via USB?
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on August 26, 2022, 12:32:50 am
AN USB 12.13 drivers should support isochronous endpoints with XHCI controllers. Have you tried the AN drivers ?

David had contacted me that there *might* be problems with USBAUDIO.SYS / USBAUD2.SYS in conjunction with XHCI but he was not 100 % positive, therefore you should give it a try.

Title: Re: XHCI and USB Audio perspectives
Post by: Dave Yeo on August 26, 2022, 01:57:17 am
If they don't work and you have a current AOS subscription, you should open an issue. David is pretty responsive and often will fix things
Title: Re: XHCI and USB Audio perspectives
Post by: Neil Waldhauer on August 26, 2022, 03:43:35 pm
The USB audio driver worked with my XHCI only system a while ago in testing.

Recent advances in Uniaud made USB sound unnecessary on my systems.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on August 26, 2022, 05:37:55 pm
Mikhail is looking for something that supports sample rates well beyond 44.1 kHz and also 32-bit sample depth. Uniaud cannot do that, partly because only USB AUDIO knows about those new PCM sample formats and partly because Uniaud on board HW does not support that.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on August 27, 2022, 01:20:02 am
After installing the latest driver 12.13 into my system, UAC2 audio devices did not work through the ports of controllers with pure XHCI mode.
At the same time, the absence of any errors seemed very strange to me. In fact, there is simply no sound, playback does not start. PM123 player or the built-in player tries to start WAV file playback and that's it, the timer hangs at 00:00 there are no errors, you can switch tracks, do whatever you want, there is no sound.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on August 27, 2022, 07:32:17 pm
Mikhail is looking for something that supports sample rates well beyond 44.1 kHz and also 32-bit sample depth. Uniaud cannot do that, partly because only USB AUDIO knows about those new PCM sample formats and partly because Uniaud on board HW does not support that.
Lars, thank you for the clarifications and your support.

I'm not really looking for quality in PCM formats above 44.1Khz/16Bit.
Yes, recordings in 96kHz/24bit or 192khz/24bit formats can sound good.
But even in 44.1Khz / 16Bit PCM there is a huge amount of information that is not audible if you connect an amplifier, speakers or headphones directly to the analog output of the computer's sound card.
In order to transmit an audio signal from a computer to an external, higher-quality DAC (digital-to-analog converter), you need to use either: USB bus (USBAudio), or AES/Coax or i2c LVDS (Uniaud).
There are very few digital signal output cards for a computer, there are only a couple of pieces for i2c output (there are also not many devices that will receive an i2c signal).
For this reason, there is no alternative to USBAudio for high-quality audio output yet.
OS/2 outputs extremely high quality audio.
If simple conditions are met, it is possible to receive a signal better than that of specialized devices from DCS, Aurender.

Title: Re: XHCI and USB Audio perspectives
Post by: Andi B. on August 27, 2022, 08:16:02 pm
Quote
There are very few digital signal output cards for a computer
All my systems have SPDIF. I think this is usual for desktop PCs.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on August 27, 2022, 10:03:51 pm
Indeed, SPDIF is found on some motherboards, both in the Toslink (Optical) and Coaxial versions.
But there are fewer and fewer such boards, now digital audio is mainly encoded inside HDMI or DP, for transmission to AV receivers.
Of course, this method of signal output is better than analog.
Comparing the sound quality after a DAC that has both SPDIF and USB input is not in favor of SPDIF.
The decrease in quality at the output of SPDIF after cheap motherboard chips has quite understandable reasons, but I think it is wrong to describe them here.
Again, supporting only a very limited set of audio formats in UNIAUD is a significant problem.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on August 28, 2022, 05:48:34 pm
I cannot promise but David pointed me to some potential issue with XHCI where a change to the audio driver might be necessary. I am off for two weeks, thereafter I'll try and build a test version of USBAUD2.SYS.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on August 28, 2022, 11:42:43 pm
Hooray.
Hope is the best I could get.
Thanks for the perspective.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 13, 2022, 05:27:23 pm
Hi Mikhail,

find attached a test version of usbaud2.sys. Just save the old files and copy these to the \mmos2 directory.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 18, 2022, 01:41:25 am
 Hey Lars,

 Finally got my Behringer UMC202HD back from being borrowed and tried your test driver with the ArcaNoae 12.13 XHCI drivers (on a XHCI only system). Unfortunately, couldn't get any sound out of it, and MP3's don't even start to play. I'm willing to do some testing if you want...

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on September 18, 2022, 12:59:09 pm
same result
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 18, 2022, 05:59:51 pm
 Hi Mikhail,

 Does your device appear in the hardware manager or USB resource manager when you plug it in? Mine does not, so I opened a ticket at ArcaNoae...

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on September 18, 2022, 06:38:19 pm
Hi David,

I use the PM123 player to play audio over the DLNA protocol. The player has an OS2audio plugin that displays the properties and capabilities of the connected audio device. When trying to connect a UAC device to a USB3 port with an XHCI interface, the plugin shows that it seems to "see" the device, there are no errors, it even tries to start playback, but immediately stops.

I have very..  a heavily stripped-down version of OS2, which is downloaded over the network from a 16MB image, it simply lacks many system applications, such as USB and HW manager. There is not even a permanent hard drive or SSD in the system)

Before asking for help, I deployed the full distribution on the SSD, in order to make sure that my problem is not related to the config or the absence of some files, at the time of testing the standard version of USBaudio 244, the connected devices were not visible in PCIDOCK.

Regards,
Mikhail
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 19, 2022, 07:12:45 am
May I add the following:

if a USB device is not seen at all under any USB resource manager, then this is not the fault of USBAUDIO.SYS or USBAUD2.SYS because these drivers have nothing to do with device detection. Rather the opposite: these drivers are called for any USB device that is detected and then, they check if they can handle the device or not. If they can handle it, they will then serve the device.

Since various USB resource manager variants (including the HW Explorer or my updated HW Manager) use the USBCALLS/USBRESMG combination to find and list USB devices, then it must be these components that do not properly work. By the way: you can also use the "lsusb.exe" application, provided by Paul. In that case, you also need the latest LIBUSB package which you can pull from netlabs or install via ANPM (it`s an RPM file). The advantage of "lsusb.exe" is that it will give you a very detailed view of the device descriptors (if you specify the -v switch) which will help in finding potential bugs in the USB audio drivers (I just found one two days ago when I realized that the logic to detect the unit that controls the volume would find the wrong unit for some devices like for example my audio 2.0 device ...).

Potentially, it can also be the USB base system (that is: USBD.SYS, USB(U|O|E|X)HCD.SYS) that could be faulty because USBRESMG.SYS relies on their proper operation. But if it were, it would be more likely that no USB devices are detected at all.
This is really odd.

EDIT: I just looked at Davids (Azarewicz) response to Davids (McKenna) AN ticket. He reports that a very fundamental "descriptor read" request does not work. In that case, there is nothing I could do. I am surprised that any USB audio device would fail that request because it is so fundamental, it renders the device useless. In that case there is either a bug in the USB base stack OR the device HW/FW is faulty/unreliable OR the device needs some "quirk" workaround because it has some expectation of how the "descriptor read" request is issued that is not mandated by the USB base specification.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 19, 2022, 07:14:07 am
Hey Lars,

 Finally got my Behringer UMC202HD back from being borrowed and tried your test driver with the ArcaNoae 12.13 XHCI drivers (on a XHCI only system). Unfortunately, couldn't get any sound out of it, and MP3's don't even start to play. I'm willing to do some testing if you want...

Regards,

Hi David,

please always mention if it is an audio 1.0 device (USBAUDIO.SYS) or an audio 2.0 device (USBAUD2.SYS). Otherwise, it will be more difficult to tell what the failure cause is ...
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 19, 2022, 07:44:25 am
Hey Lars,

 Finally got my Behringer UMC202HD back from being borrowed and tried your test driver with the ArcaNoae 12.13 XHCI drivers (on a XHCI only system). Unfortunately, couldn't get any sound out of it, and MP3's don't even start to play. I'm willing to do some testing if you want...

Regards,

Two questions/requests:
1) is that device also not detected with my USB stack ? Of course, you will need an EHCI controller to test (a XHCI only system does not work with my USB stack)

I could try and find a "quirk" workaround. David, it would be helpful if you could search the internet for problems with the UMC202HD device. Potentially you will find linux related bug reports. That might give me a clue as to how the workaround needs to look like (I have to ensure that I don`t break the detection logic for all other devices ...)
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 19, 2022, 02:28:16 pm
 Hi Lars,

 Thanks for your analysis! This device is supposedly USB audio 2.0 class compliant. It also supposedly works with Linux, although I found one report of it working intermittently until a kernel recompile, and another where it stopped working after a kernel upgrade, but mostly reports of it working with various Linux apps (I don't have a Linux install to test on). I can say it is correctly recognized on Windows, and works.

  I tried lsusb -v, but that failed to detect it too, ending with:

[C:\]lsusb -v > lsusb.txt
can't get debug descriptor: No such file or directory
can't get device qualifier: No such file or directory
can't get debug descriptor: No such file or directory
can't get device qualifier: Invalid argument
can't get debug descriptor: Invalid argument

 One of the reasons I got this device in the first place was that Wim Brul used a virtually identical device (UMC204HD - same with MIDI I/O added) to develop his audio recording app.

 I have a laptop with USB2 ports I'll give your drivers a try with later today... thanks again!

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on September 19, 2022, 03:16:03 pm
David, thank you for opening a ticket in AN.
To successfully promote the ticket, I suggest attaching a log from the configuration where the UAC2 device is connected to the USB2 ehci port of the controller. There it should correctly convey information about itself, which can lead David Azarevich to the right thoughts.
Now FUNDAMENTAL problems are being poked at the incompatibility of a specific UAC2 device, which of course is far from the truth.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 19, 2022, 03:30:46 pm
Hi Lars,

  I tried lsusb -v, but that failed to detect it too, ending with:

[C:\]lsusb -v > lsusb.txt
can't get debug descriptor: No such file or directory
can't get device qualifier: No such file or directory
can't get debug descriptor: No such file or directory
can't get device qualifier: Invalid argument
can't get debug descriptor: Invalid argument


Ok, that could be expected. lsusb.exe uses LIBUSB that in turn uses USBCALLS/USBRESMG. Since USBCALLS/USBRESMG fails, then LIBUSB and therefore lsusb.exe will also fail.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 19, 2022, 04:32:50 pm
 Hey Guys,

 I did some more testing  - tried using a plug on the back of the computer instead of the one on the front (which is attached to the MoBo by a bunch of wires) and now the unit is detected in the hardware manager! Strange because the mouse/keyboard radio works fine on the front connectors. lsusb still shows the same errors though.

 But it still doesn't work - there is no sound when trying to play an MP3 with PM123 using the UAC2 interface. I tried Lars' test driver and the one from the 10.244 package, but same result - PM123 just hangs at 0:00 when trying to play.

  So I have an old laptop with both USB2 and USB3 ports. It has the AN 12.13 USB drivers installed. I installed the USB audio drivers from Lars' 10.244 and DLL's on it too. The Behringer unit is detected by the hardware manager on both ports and actually can play with sound using PM123 on the USB2 ports! But on the USB3 ports it just hangs at 0:00. So this Behringer device WILL work with OS/2 - i'll report this finding on the AN ticket.

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on September 19, 2022, 06:47:14 pm
Ugh.. Although I think David Azarevich's arguments are not correct *, try using an active USB hub with external power to connect your UAC2 device. This should eliminate doubts that the device does not have enough power from the port of your computer.

Anyway, we will pass the ball to the other side)

*In my case, UAC2 devices with external power are used, which do not use the USB power bus from the computer at all, so David's arguments are not clear to me.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 19, 2022, 06:58:13 pm
 Hi Mikhail,

  Yes, I tried that - still doesn't get detected. So far it has only been detected on my desktop one time. On the laptop it is always detected. So I have an additional problem with detection on the desktop.

  For testing Lars' driver I will stay with the laptop since I know it can work there at least on the USB2 ports.

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 19, 2022, 09:05:21 pm
 Hi All,

  Tried Lars' test driver posted above on my laptop, but it produces no sound thru either USB2 or USB3 ports. Back to the 10.244 version and it works again on USB2 ports only.

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on September 20, 2022, 01:00:51 pm
It seems your arguments have had an effect on David Azarewicz.
Now we need to understand how to trace a problem, how to get the missing data to finalize the driver in AN.
Title: Re: XHCI and USB Audio perspectives
Post by: Andreas Schnellbacher on September 20, 2022, 04:48:01 pm
That bug seems to be non-public.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 21, 2022, 12:24:26 am
That bug seems to be non-public.

https://mantis.arcanoae.com/view.php?id=3322
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 21, 2022, 12:35:43 am
Try the attached, also with USB3. That attempts to fix what David calls "it doesn't work because of a defect in the audio class driver. This driver is apparently not compatible with USB3/XHCI".

Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 21, 2022, 01:21:40 am
 Hi Lars,

  Tried your new build  of usbaud2.sys and it works with USB2 plugs on my laptop, but not with USB3 plugs. Plugged in to a USB3 plug, when starting playback there is a 'click' noise, then PM123 just hangs at 0:00, but can be stopped and shut down. Plugged in to a USB2 plug, PM123 plays anything I try thru the Behringer. This is of course with the AN 12.14 test drivers available at arcanoae.com.

  If you need any other testing info, just ask.

  It might be good if when posting test versions to give them a date in the zip file name so we can be specific about what is being tested...

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 21, 2022, 07:12:49 am
Hi David,

this was just a quick shot.

Anyway: removing what David (Azariewicz) claims to be the problem obviously did not help.
To be honest, I also doubt that the USB audio drivers do not conform to the spec.

What had been in the code before and what I now removed is not only backed by the usb audio spec (in fact, the usb audio 1.0 spec mandates it under certain conditions) but also by the libuvc implementation (which I worked on in the past) which does the same (from an application level) after it has stopped streaming to a UVC compliant video device: to set the alternate setting of the audio (or video, in case of libuvc) streaming interface to 0. The speciality of alternate setting 0 (compared to alternate settings >=1) is that it contains no endpoints which is odd (but hey, that`s what the audio 1.0 spec specifies !) and serves the purpose to release any bandwidth if you do not stream data.

Needless to say that libuvc was ported from Linux, so obviously, it works under Linux and very likely also for USB3, otherwise somebody would have complained. And it works under OS/2, at least when I only use USB 2.

I am out of ideas.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 21, 2022, 10:35:54 pm
 Hi Lars,

  Thanks for giving it a shot. I'm starting to get the idea that USB in general is a patchwork 'hall of mirrors' so it's amazing anyone can keep track of how it all fits together....

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Dave Yeo on September 22, 2022, 01:55:41 am
Hi Lars,

  Thanks for giving it a shot. I'm starting to get the idea that USB in general is a patchwork 'hall of mirrors' so it's amazing anyone can keep track of how it all fits together....

Regards,

My understanding is there was the standard, which IBM followed, then there was the MS way, which did not follow the standard and was not documented.
USB3 is supposed to be better, but David seems to be working around weirdness in the hardware too much, with Intel being the worst, which is kind of surprising.
You might want to try an older (2 or 3 versions or more back) and see if that helps, David has been making things more strict I think.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 22, 2022, 09:26:45 am
Hi Lars,

  Thanks for giving it a shot. I'm starting to get the idea that USB in general is a patchwork 'hall of mirrors' so it's amazing anyone can keep track of how it all fits together....

Regards,

My understanding is there was the standard, which IBM followed, then there was the MS way, which did not follow the standard and was not documented.
USB3 is supposed to be better, but David seems to be working around weirdness in the hardware too much, with Intel being the worst, which is kind of surprising.
You might want to try an older (2 or 3 versions or more back) and see if that helps, David has been making things more strict I think.

In order to not mix up things:
1) "there was a standard that IBM followed, then there was the MS way": this statement only relates to device enumeration and this is mostly controlled by USBD.SYS. This has been changed to the MS way a long,long time ago and I don´t think that David has changed that in any way

2) "USB3 is supposed to be better": this is about typical requests like setting a device address or selecting an alternate setting of an interface. For < USB3, quite a bit of SW interaction was necessary to do that, USB3 does that almost all in HW with only very little SW interaction (which also involved timing issues which is always a bit unreliable to do in SW if you need fairly precise timing). In that way, USB3 is indeed better (apart from performance, of course)

Some of the requests in 2) are used during device enumeration in 1), so there is some relation to 1) , but it is not the same problem. They are 2 different problems.


Title: Re: XHCI and USB Audio perspectives - new test version
Post by: Lars on September 24, 2022, 09:28:23 am
Hallo David et al,

please test the attached. Just unzip the USBAUD2.SY? and TRC00EE.TFF files and put them in the proper directories.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 24, 2022, 02:58:00 pm
Hi Lars,

  SVN2347 works fine with my Behringer UMC202HD when plugged in to a USB2 connector, but get no sound when plugged in to a USB3 connector (get a faint 'click' sound when starting) and PM123 hangs at 0:00. This is on my HP Pavilion dv7 laptop running AOS 5.0.7 and the 12.14 USB test drivers...

  If you want to get into tracing or any other testing I'm willing...

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 24, 2022, 03:58:46 pm
I had some email exchange with David. He told me that "isochronous in" endpoints are not yet completely/properly supported.

However USB audio 2.0 requires "isochronous in" endpoints as feedback endpoints to tell the audio driver how many samples per time unit the device expects to get (to iron out variances in transmission speed/to maintain the needed data rate when streaming). USB audio 1.0 (USBAUDIO.SYS) did not yet require that and therefore USB audio 1.0 should not be affected.

He also pointed me to a XHCI driver test build that you can find here:
https://www.arcanoae.com/resources/downloadables/experimental-builds/

It is worth trying because apart from other stuff, he has also modified isochronous support.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 24, 2022, 09:03:59 pm
Hi Lars,

  The test drivers you reference are the ones I am using (David A had me use those when I reported the device not being detected). But if the 'isochronous in' endpoints you mention are needed but not fully implemented (for USB3), then I guess we have to wait for that...

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 24, 2022, 11:08:09 pm
That is strange, because I installed the AN drivers and at least my audio 2.0 device works ok and I tried with "USB3 only" ports.
Please retry with the attached.
What you will notice is that it sounds a bit corrupted as David had already said. But it will play.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 24, 2022, 11:53:53 pm
Hi Lars,

  Thanks! Tried SVN2351, but couldn't get it to work on any connector - on a USB2 connector PM123 would act like it is playing a file (timer counts, EQ waveform displays), but no sound came thru. On a USB3 connector PM123 would not play (as usual) and hang at 0:00.

  Back to SVN2347 and I can play on a USB2 connector only. One thing I noticed I didn't notice before... if the Behringer is connected to the USB2 connector while booting, then PM123 will not play sound until I unplug the Behringer, then plug back in.

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 25, 2022, 12:20:04 am
Are you sure you are using

https://repos.arcanoae.com/misc/USB-12.14-20220829-test.exe

Make sure that you update all components and only take the usb audio drivers from my package.
What USB HW are you using ? I am using AMD/ATI. As I said, on my system it now works ok, with all flavours: UHCI,OHCI,EHCI,XHCI.

Try the attached. Maybe it makes a difference.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 25, 2022, 12:25:32 am
Can you also attach the descriptor report for the Behringer ?
And then, also a trace. Make sure you also update TRC00EE.TFF ! I have enhanced tracing (added additional tracepoints).
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on September 25, 2022, 08:56:57 am
David, can you create a ticket against USBAUD2 at Netlabs and attach all info there ? It´s becoming too cluttered here.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on September 25, 2022, 03:57:38 pm
Hi Lars,

  I created a ticket per your request, we can continue there. Definitely using the 20220829 AN drivers, but not the USBAUDIO parts. I attached lsusb results there as well as testlog reports on the system. I will need your guidance setting up for tracing.

  The SVN2354 driver works with USB2, but again USSB3 hangs at 0:00 when trying to play using PM123.

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on October 03, 2022, 01:02:15 pm
David, can you create a ticket against USBAUD2 at Netlabs and attach all info there ? It´s becoming too cluttered here.

I would like to ask you to post the interim results of diagnostics in this thread.
As far as I understand there is positive news?
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on October 03, 2022, 01:51:52 pm
intermediate results:

1) I fixed a bug in the selection of the proper feature unit (volume control) in both, USBAUDIO.SYS and USBAUD2.sys so that volume can be properly set (fixed problem for my own audio 2.0 device)
2) I fixed a bug in USBAUD2.SYS regarding setting the proper interface when programming sample frequency: this finally makes the "Savitech SA9227" (ID 262a:9227) device stream properly
3) fixed a bug (?) in USBAUD2.SYS regarding handling of sync feedback isochronous endpoint input which is a precondition to getting streaming to work properly (fixed problem for my own audio 2.0 device)

4) the general/overall problem of streaming to a XHCI (USB3) attached audio device has been fixed by an update to the XHCI host controller (HC) driver (currently only a test release at the AN site):

https://repos.arcanoae.com/misc/USB-12.14-20220926-test.exe

5) I am currently trying to get volume control to properly work on the "Behringer UMC202HD" USB audio 2.0 device. Even though I did 1), it still won`t work properly. Under investigation. But this device seems to be a piece of s**t, regarding the comments I read on the internet, for example:

https://nandakumar.org/blog/2022/02/umc202hd-linux.html

Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on October 03, 2022, 02:37:05 pm
Good news!
Fans of good sound have to wait for the official USB driver package from AN.

Thank you very much, the problem would hardly have been solved without you.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on October 30, 2022, 02:09:07 pm
I have now uploaded usbdrv245.zip to Hobbes (currently, in "incoming" directory). That contains the updated USBAUDIO and USBAUD2 audio drivers.
For the updated XHCI host controller driver, that's up to AN. I suspect they are going to deliver that with AN 5.1.
Title: Re: XHCI and USB Audio perspectives
Post by: David McKenna on October 30, 2022, 09:46:58 pm
Hi Lars,

  Thanks for the update... I can report that it works perfectly, even with my POS Behringer UMC202HD USB audio 2.0 adapter on both USB2 and USB3 (test driver), and sounds great! I also tried it with a CMedia 'matchbox' type USB audio 1.0 adapter and that works as well. Fantastic!

Regards,
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on December 06, 2022, 11:27:58 pm
Question to the community of USB Audio device users.
I am interested in the opinion of those who use USB 3.0 XHCI port to connect an audio device, do you play audio files of different resolutions correctly?
Especially when switching between tracks of different resolutions, for example, when switching from 16bit/44.1kHz to 24bit/48kHz, is there any sound slowing down, and can your audio device display a stream format that does it get?

In my case, from the first time after switching from one resolution file to another, the signal parameters on the audio device do not change and the sound is distorted, only after restarting playback, the sound is played correctly and the device overrides the stream format.

I am using USB drivers 12.14 and have tried different versions of USB audio drivers from Lars with the same result. The software playing the file does not matter, the symptoms are the same on the built-in player and on PM123.

Maybe there are some suggestions, what could be the problem?
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 07, 2022, 07:31:47 am
That could either be the audio class driver (USBAUDIO, usbaud2) or the HC driver (USBXHCD). If you can, borrow a USB 2.0 (ehci) plug-in card from someone and see if that makes a difference (don't forget to add the USBEHCD driver to config.sys). If yes, it's the HC driver. If not, it's the audio class driver.

EDIT: I just tried on my system (using USBEHCD HC driver, no XHCI). I can swap sound file play (using different sample rate and resolution) without a problem, meaning, I can start playing one file, interrupting by playing another file with different sample rate and bit resolution and once that second file has finished playing, automatically resuming playing the first file. I have no distortion, glitch or anything else.

But that might also depend on the USB audio HW (not all USB audio HW behaves the very same way even though there are standards ...).
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on December 08, 2022, 12:51:35 am
Good time of day.

Lars, thank you for your feedback.
I've done the tests you mentioned. So far I have only an audio device based on Amanero. Another one based on Xmos will arrive at the weekend.

So far, the results are as follows:
The problem with changing the frequency on the device receiving the audio stream manifests itself on both EHCI controllers and XHCI.
In the beginning I used USB drivers version 12.14 and USB Audio driver 10.247
I have a motherboard Supermicro x10SBA with an EHCI controller on which I can turn off XHCI, and there is also a motherboard on which there is only XHCI and there is a separate PCI-e board with XHCI. After I made sure that the problem repeats on any of the controllers on the same set of software, I switched to an already tested board with an EHCI controller.

1. Remove the XHCI driver from Config, downgrade the USB driver version to 12.13, then to 12.12 - The problem persists.
2. USB driver version 12.12 and USB Audio driver 10.244 - No problem, everything is clear.
3. USB driver version 12.14 and USB Audio driver 10.244 - No problem, everything is clear.
4. USB drivers version 12.12 and USB Audio drivers SVN2364, SVN2368, 10.247 - The problem persists.

An interesting observation. Reset the audio device to 16bit/44/1kHz mode
I consistently play Wav audio files in various formats one by one, let's say so:
16/44.1 -> 24/48 -> 24/96 -> 24/192,
then on the indicator of the audio device we will see such a sequence of switching formats:
16/44.1 (Ok) -> 16/44.1 (Ops, it was necessary to switch to 24/48) -> 24/48 (Switched but not there, we need 24/96) -> 24/96 (again the parameters of the previous stream))
I have the impression that the switching is not on the frequency of the stream that should start, and on the frequency of the previous one.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 08, 2022, 10:34:41 am
Then this is one of the cases where the audio USB HW is different enough in behaviour for two devices to work differently with the very same USB audio class driver.
As so often we have to find the "greatest common denominator" to make it work with Anamero but not to break it with the other devices that work (my device as an example ...).

If I find the time, we can do some trial and error to find that "greatest common denominator" but I cannot promise.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 08, 2022, 10:54:17 am
1. Remove the XHCI driver from Config, downgrade the USB driver version to 12.13, then to 12.12 - The problem persists.
2. USB driver version 12.12 and USB Audio driver 10.245 - No problem, everything is clear.
3. USB driver version 12.14 and USB Audio driver 10.245 - No problem, everything is clear.
4. USB drivers version 12.12 and USB Audio drivers SVN2364, SVN2368, 1.247 - The problem persists.

Are you sure about that ? I have not changed anything except for the support for 4 new subtypes (8 kHz, 24/32-bit,mono/stereo) in USBAUDIO.SYS and USBAUD2.SYS from 10.245 to 10.247. So how can it work with 10.245 but not with 10.247 ?
Have you done a full reinstallation of the 10.247 USB audio driver install package, including all subcomponents that it contains, and not just copying/unzipping files ?

I still claim it has something to do with the HC drivers.

As a test, can you only test with my USB driver set ? Just install all of 10.247 to test with EHCI. If done, you can revert back to 12.14.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on December 08, 2022, 12:16:43 pm
Yes, my mistake. The version I used in test 2 and 3 is 10.244
I apologize.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on December 08, 2022, 12:27:50 pm
Have you done a full reinstallation of the 10.247 USB audio driver install package, including all subcomponents that it contains, and not just copying/unzipping files ?
I did two installations of USB audio drivers, on two different systems:
1. On a brand new, fresh ArcaOS, I installed the package via minstall
2. On the PXE boot version I copied usbaud2.sys
In both cases, the problem was the same.

As a test, can you only test with my USB driver set ? Just install all of 10.247 to test with EHCI. If done, you can revert back to 12.14.
OK - today I will try and describe the result.
I tried to replace the USB drivers completely with your package version 10.247.
The result is the same.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on December 08, 2022, 10:39:29 pm
Amanero is a programmable interface, depending on the firmware, this device can be used for different application environments.
In fact, there are only two branches of current firmware.
I flashed Amanero with two different firmware: for Linux OS and Windows. In order to evaluate their behavior in the OS2 environment.

On the firmware for Linux, the device works fine on USB 12.x drivers from AN + USB Audio 10.244 and those below the version. Starting with version 10.245 USB Audio, there is support for working with XHCI controllers, but there is also a problem of determining the sampling frequency (possible only on Amanero audio adapters, tomorrow I will find out how the XMOS chips behave).

On Windows firmware, the device works fine only with USB + USBAudio 10.xx drivers, and with any versions, including 10.247. On USB 12.xx versions from AN Amanero is not detected. But since a driver for XHCI controllers has not yet been released for version 10.xx, then on my current motherboard I have to use the Amanero firmware for Linux and the USB 12.14 + USB Audio 10.247 drivers. Start playing the track twice when the sampling frequency of the audio file changes.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 09, 2022, 12:34:15 am
Ok, you have proven that it is the USB audio class drivers that matter.

But this is a nightmare. I can try and roll back changes but it's going to be trial and error.
It's obvious that the FW for Linux and Windows behaves differently and for a good reason (obviously, Linux and Windows have different expectations of how an USB audio device should behave). I cannot say how much time I have for this experiment.
Would you be able to install Wireshark and the USB capture/filter driver that comes with it and take a trace of what happens when you play a sound file ? What I would need to know is what commands the OS sends in what sequence when an attempt is made to play a sound file. The OS/2 audio class driver would then have to mirror that behaviour (and hope it does not break for all other devices ...).

And that said, I would think that you would need to do this under Linux because you are using Linux FW (does Wireshark even exist under Linux ? I don't know).

It would make sense to raise a problem report so that the AN stack is able to detect the Anamero device if it uses FW for Windows. You are a paying AN customer, you are entitled to do so.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 09, 2022, 01:56:49 am
On the firmware for Linux, the device works fine on USB 12.x drivers from AN + USB Audio 10.244 and those below the version. Starting with version 10.245 USB Audio, there is support for working with XHCI controllers, but there is also a problem of determining the sampling frequency (possible only on Amanero audio adapters, tomorrow I will find out how the XMOS chips behave).

On Windows firmware, the device works fine only with USB + USBAudio 10.xx drivers, and with any versions, including 10.247. On USB 12.xx versions from AN Amanero is not detected. But since a driver for XHCI controllers has not yet been released for version 10.xx, then on my current motherboard I have to use the Amanero firmware for Linux and the USB 12.14 + USB Audio 10.247 drivers. Start playing the track twice when the sampling frequency of the audio file changes.

Can you save USB descriptor info for these 2 different FW versions ? You can save USB descriptor info by running "lsusb.exe".
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 09, 2022, 01:58:22 am
By the way: I have an XMOS device as a USB audio 2.0 device:

Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 ?
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x20b1 XMOS Ltd
  idProduct          0x3060
  bcdDevice            0.03
  iManufacturer           1
  iProduct                2
  iSerial                 0
  bNumConfigurations      2
...

That device at least works fine with USBAUD2.SYS version 10.247.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on December 09, 2022, 02:09:39 am
In fact, I drew a slightly different conclusion from the situation.
I believe that the problem is in the USB stack from AN and since for both firmware versions your drivers 10.xx are suitable, as long as we don't run into the need to connect the device to the XHCI controller. As soon as the XHCI and USBD driver from AN appears, miracles begin. For example , such:
If there are 2 XHCI controllers in the system and we connect a USB Audio device to the port of the second controller, then playback speeds up - multiple times, and the timer of the player runs very fast and the sound is distorted.
When using the XHCI driver from AN, fatal errors appear, crashes when switching tracks (I mentioned them in the letter).

The fact that there is an acceptable USB audio operation on the EHCI controller ports with firmware for Linux only shows that the EHCI driver can be called selectively working.

By the way, the device on the Amanero controller works fine both under Windows OS on linux firmware and under Linux OS on Windows firmware. There are nuances when switching to DSD format and separate drivers are needed under windows when using the Windows firmware version, which just smooth out these clicks.

It seems to me if there was a 10.250 version of the driver with the file usbxhcd.sys then there would be no such problems in it :-)

Yes, I can save the descriptors. I'll post them here. I have already read the descriptors once, on the previous Amanero device with old firmware. Here they are below and in the attachment.

Code: [Select]
Bus 001 Device 002: ID 16d0:0a23 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239
  bDeviceSubClass         2
  bDeviceProtocol         1
  bMaxPacketSize0        64
  idVendor           0x16d0
  idProduct          0x0a23
  bcdDevice            1.9b
  iManufacturer           1 Amanero Technologies
  iProduct                2 Combo384 Amanero
  iSerial                 3 413-001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          213
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x40
      (Missing must-be-set bit!)
      Self Powered
    MaxPower                0mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          1
      bFunctionSubClass       0
      bFunctionProtocol      32
      iFunction               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1
      bInterfaceSubClass      1
      bInterfaceProtocol     32
      iInterface              0
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               2.00
        bCategory               1
        wTotalLength           72
        bmControl            0x00
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               41
        bmAttributes         0x03 Internal programmable Clock
        bmControls           0x07
          Clock Frequency Control (read/write)
          Clock Validity Control (read-only)
        bAssocTerminal          0
        iClockSource            2 Combo384 Amanero
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     11 (CLOCK_SELECTOR)
        bUnitID                40
        bNrInPins               1
        baCSourceID( 0)        41
        bmControls           0x03
          Clock Selector Control (read/write)
        iClockSelector          2 Combo384 Amanero
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID            42
        wTerminalType      0x0101
        bAssocTerminal          0
        bCSourceID             40
        bNrChannels             2
        bmChannelConfig   0x00000000
        bmControls    0x0000
        iChannelNames           0
        iTerminal               0
      AudioControl Interface Descriptor:
        bLength                18
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                10
        bSourceID              42
        bmaControls( 0)      0x0000000f
          Mute Control (read/write)
          Volume Control (read/write)
        bmaControls( 1)      0x0000000f
          Mute Control (read/write)
          Volume Control (read/write)
        bmaControls( 2)      0x0000000f
          Mute Control (read/write)
          Volume Control (read/write)
        iFeature                0
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            43
        wTerminalType      0x0301
        bAssocTerminal          0
        bSourceID              10
        bCSourceID             40
        bmControls         0x0000
        iTerminal               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1
      bInterfaceSubClass      2
      bInterfaceProtocol     32
      iInterface              0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass         1
      bInterfaceSubClass      2
      bInterfaceProtocol     32
      iInterface              0
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink          42
        bmControls           0x00
        bFormatType             1
        bmFormats               1
          PCM
        bNrChannels             2
        bmChannelConfig   0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         32
      ** UNRECOGNIZED:  08 25 01 00 00 02 08 00
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0308  1x 776 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes           17
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Feedback
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           2
      bInterfaceClass         1
      bInterfaceSubClass      2
      bInterfaceProtocol     32
      iInterface              0
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink          42
        bmControls           0x00
        bFormatType             1
        bmFormats               1
          PCM
        bNrChannels             2
        bmChannelConfig   0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         32
      ** UNRECOGNIZED:  08 25 01 00 00 02 08 00
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0308  1x 776 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes           17
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Feedback
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               4
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 09, 2022, 12:29:56 pm
I looked at both of the descriptor dumps (Linux and Windows). Are these really for the same physical device ?

The "Linux dump" shows an audio interface (which of course was expected).
However, the "Windows dump" shows a vendor specific bulk interface (like it were a memory stick) but no audio interface.
With the Windows descriptor set, the device should never be detected as an audio device.
To me, the Windows descriptor set looks like it is for FW update or some such.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on December 09, 2022, 08:21:49 pm
The descriptors for the Windows firmware version were written correctly. For USB drivers version 12.14, the descriptors are read this way.
On USB drivers version 10.247, the result is completely different - more complete.

By the way, I compared a few descriptors and on the Linux version of the firmware, the files there are the same (It seems).

I also considered the descriptors from the M2tech hiface two device, it really works better, especially if installed in the USB 3.0 XHCI port on a PCIe card. There are no questions about the work at all, and frequency switching works and there are no artifacts in the sound, the device does not support DSD from 44/16 to 192/24. Everything would be fine, but if you plug M2tech into the port of the motherboard, then a crackle in the sound and freezes when executing player commands begins.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 10, 2022, 02:25:20 pm
The problems you describe regarding the M2tech device are clearly a problem of the host controller driver USBXHCD.SYS (most likely) and/or USBD.SYS (less likely) because USBAUD2.SYS does not touch the HW and knows nothing about what HC instance or USB port is used (it does not distinguish between the onboard HC and the plugin card HC).
Since you are using AN USB stack, you will need to raise a problem report with AN.
If they don't respond, the only advice remaining is: switch over to another OS, Linux or Windows, whatever you prefer.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on December 10, 2022, 07:08:14 pm
If they don't respond, the only advice remaining is: switch over to another OS, Linux or Windows, whatever you prefer.
I am deeply immersed in the topic of sound quality of different operating systems on specially prepared computers. OS/2 in general and OS/4 in particular sounds the best of all systems. If the difference was not fundamental, I would have switched to Windows or Linux a long time ago. There would be much less problems with compatibility.
Title: Re: XHCI and USB Audio perspectives
Post by: Lars on December 17, 2022, 01:19:34 pm
As to point 3) in my last email to you: please try the attached and see if that makes a difference.
Unfortunately, I cannot send any ZIP file to you that contains .SYS driver files (Google rejects).
You could also send me an upload link via private message.
Title: Re: XHCI and USB Audio perspectives
Post by: Mikhail on January 13, 2023, 11:36:08 pm
I will clarify the current status.
USB Audio devices of Class 2.0 on the ports of XHCI controllers do not work stably.
The problems described in the topics above have not yet been solved.
Most devices experience problems with cracking and dropping samples, sometimes slightly noticeable, sometimes very noticeable.
Other devices cannot synchronize the sampling frequency of the audio stream with the signal source the first time. As a result, the playback speed changes.

Unfortunately - AN rejected my ticket to the XHCI driver with this problem.

If there are those who wish to repeat the appeal, use only the release versions of drivers and OS when preparing logs.