Vendor Audio Requests implementation

Discussions about USB Audio on XMOS devices
User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

fabriceo wrote: Mon Apr 17, 2023 11:38 am Ross, considering the possible coexistence with a SPDIF/ADAT interrupt, would be great to enhance the usb_audio_app 7.2 to extend this interrupt concept to other source like Volume or Terminal, with some helpers or defines :)
Interestingly it was a feature but was removed sometime in the distant past... possibly when we added the HID controls. We don't get many requests for this feature to he honest! I'll add it to the backlog though.


MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

We don't get many requests for this feature to he honest!
Dear Ross, that might be because none of vendors know about this. I saw many devices on the market that use additional MCU like STM32 to read/write vendor specific requests as neither XMOS nor Thesycon even not mention these possibilities. Zero documentation or code samples. Not much enthusiasm to support so trivial things. Even these 2 lines of code in sources doesn't work as is. If you think every hw engineer is genius or master of XUD programming like Fabrice, then I think you should think twice. :) For me it tooks some days to make work just that simple code, that was obvious for you and not even interesting. For vendors this topic, hw volume control knob and vendor specific requests, means HUGE. Believe me. As Fabrice said, volume knob is mandatory for Rune sertification. And as always, many thanks for your great job and your kind support.
User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

I wouldn't say it was uninteresting to me personally. I don't get paid to post on here and I'm only here in my free time so that shows some level of interest ;) By supporting you here in the open it serves as reference for other users too. Glad you have it working and good luck with your project.
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

Dear Ross, I understand that. Every time I upload a new firmware for our customers, I mandatory write on web-site big thanks to Ross personally and all XMOS guys for their great job. My huge respect and I wish you a long life and good health. I wish in ideal world and ideal time XMOS whould hire much more people to provide vendors with better documentation / basic tech support through the forum.
User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Thank you for your kind words, it is appreciated! Please do point us to your products so we can have a look!
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

[deleted tmi]
Last edited by MaximLiadov on Tue Apr 18, 2023 10:07 pm, edited 2 times in total.
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

fabriceo wrote: Mon Apr 17, 2023 11:38 am after some tests this morning, I confirm that it is possible to trigger the Audio Control Interrupt by calling XUD_SetReady_In(ep_int, g_intData, 6) from the SOF select case (which happens every 125us).
This way it is quite easy to detect a change in some global variables
I can confirm. Global variables sharing does its work much better than interrupt channel from clockgen I used before. SOF works much better for me - no more loosing any interrupt. Thanks for this advice!

Sorry for dumb question: how to ged rid out of separate L and R volume controls, just to keep one master fader? Fabrice, you mention that it's possible. I cannot find anything in descruptors.h. The thing is: some OSes (Apple) use Master only, some (Win) use channels only, some (Android, Linux) confusing customers with 3 faders in a raw. It's better to use the one and only master, synchronized with hw volume knob. Right?

Code: Select all

#if(OUTPUT_VOLUME_CONTROL == 1)
        /* Feature Unit Descriptor */
...
            {
#if (NUM_USB_CHAN_OUT > 0)
                0x0000000F,         /* bmaControls(0) : Mute and Volume host read and writable */
                0x0000000F,         /* bmaControls(1) */
#endif
#if (NUM_USB_CHAN_OUT > 1)
                0x0000000F,         /* bmaControls(2) */
#endif
bmaControls(0) master channel due to UAC2.0 page 81.
When I remove bmaControls(1) and (2) it doesn't work.

#define OUTPUT_VOLUME_CONTROL (0) - doesn't work. It is turning off completly all volume faders.
User avatar
fabriceo
XCore Addict
Posts: 181
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi

#define OUTPUT_VOLUME_CONTROL
is mandatory to enable the audio feature unit and thus the volume+Mute informations

regarding Master vs Left/right, my understanding of the 2.0 spec is that Channel number 0 is always referring to a Master Volume (and master Mute) which exists and is applied in addition to the individual channels settings. And not present in the FU descriptor.
So for your knob reporting and control, I would focus on the channel 0 (within audiorequest.xc)
that said you are right that depending on OS or front-end app, the L & R may be used.

you can intercept ch 1 & ch 2 data flow in FU_USBOUT, combine them with ch 0 and deal with that by yourself to supersede whats happen on windows. I mean when you receive FS_USBOUT you could set your knob with this formula:
knob = volsOut[0]+min(volsOut[1], volsOut[2])
and in the way back you could set volsOut[0] depending on a formula taking into consideration the actual value of volsOut[1] and [2] in order to keep the user balance setting and calculate a remaining delta to be applied on ch0.
well just an idea, maybe unclear :)
MaximLiadov
XCore Addict
Posts: 130
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

Dear Fabrice, thank you for your reply. I will keep experimenting and let you know if I have a good progress.

For the moment I see an issue with the host volume fader. It is moving not smooth, but with stuttering. Might be a problem with too much command trafic? Then I turn hw volume knob by just 1 step and send just one request by INT EP, host asks volume from the device 3 times, both left and right, total 6 times, no matter which channel I set in g_intData[2], 0, 1, 2. I thought it's a channel number, isn't it? I read UAC2.0 standard, of course, but I am not so sure, as host behavior in reply to this request is a bit odd. I tested on the latest Windows 11 build. Did you make it work flawless? Sorry for disturbing. You already helped me a lot. Very appriciated.
User avatar
fabriceo
XCore Addict
Posts: 181
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi, I see what you mean as I have got same thing in my experimentation: I d say that may be you trigger too much interrupt from SOF before the Host sends a Get request to FU_USBOUT (captured in audio request.xc).
Your variation detection in SOF should stop triggering the interrupt until an effective Get Request is received in FU_USBOUT, and a timeout could be implemented to resend every 500ms the interrupt if the Get is not received.(it is easy to decrement a variable in SOF at 8000kz).
cheers
Post Reply