[alsa-devel] Support for USB-Audio devices with Multiple configurations?
I'm writing some firmware for a USB microphone array with multiple configurations, and I'm wondering if it's possible to tell ALSA which configuration to use in a module option or something (device_setup, perhaps).
I've been looking through usbaudio.c in the kernel source (2.6.28-11-generic from the ubuntu Jaunty package), and I can't find any generic device configuration like that.
If this is not possible, does anyone have any recommendations on how to implement this? I can imagine doing it using quirks for this particular USB_ID, but this seems like a fairly generic type of capability, so I'd like to make it general if possible.
If anyone is wondering *why* I want multiple configurations: it's for bandwidth management. I have 8 channels, but I want to be able to sample 1 channel as fast as possible without wasting bandwidth on the other 7. I couldn't figure out a way to do that with a single configurations. Please let me know if you know one. ;-)
Thanks, Cameron.
Cameron Stone wrote:
I'm writing some firmware for a USB microphone array with multiple configurations, and I'm wondering if it's possible to tell ALSA which configuration to use in a module option or something (device_setup, perhaps).
I've been looking through usbaudio.c in the kernel source (2.6.28-11-generic from the ubuntu Jaunty package), and I can't find any generic device configuration like that.
If this is not possible, does anyone have any recommendations on how to implement this? I can imagine doing it using quirks for this particular USB_ID, but this seems like a fairly generic type of capability, so I'd like to make it general if possible.
While the USB specifications define configurations, there is no generic way how a driver could automatically determine which configuration to use.
If anyone is wondering *why* I want multiple configurations: it's for bandwidth management. I have 8 channels, but I want to be able to sample 1 channel as fast as possible without wasting bandwidth on the other 7. I couldn't figure out a way to do that with a single configurations.
Bandwidth management is implemented by having multiple alternate settings for the audio streaming interface. (This is why alternate setting zero must have no endpoint or a zero-sized endpoint, so that in the default case, the interface does not use any bandwidth.)
Best regards, Clemens
Clemens Ladisch wrote:
Cameron Stone wrote:
I'm writing some firmware for a USB microphone array with multiple configurations, and I'm wondering if it's possible to tell ALSA which configuration to use in a module option or something (device_setup, perhaps).
I've been looking through usbaudio.c in the kernel source (2.6.28-11-generic from the ubuntu Jaunty package), and I can't find any generic device configuration like that.
If this is not possible, does anyone have any recommendations on how to implement this? I can imagine doing it using quirks for this particular USB_ID, but this seems like a fairly generic type of capability, so I'd like to make it general if possible.
While the USB specifications define configurations, there is no generic way how a driver could automatically determine which configuration to use.
I was thinking in terms of a module parameter that would be set if a configuration other than the default (first) configuration was desired. Could that work?
If anyone is wondering *why* I want multiple configurations: it's for bandwidth management. I have 8 channels, but I want to be able to sample 1 channel as fast as possible without wasting bandwidth on the other 7. I couldn't figure out a way to do that with a single configurations.
Bandwidth management is implemented by having multiple alternate settings for the audio streaming interface. (This is why alternate setting zero must have no endpoint or a zero-sized endpoint, so that in the default case, the interface does not use any bandwidth.)
Is it possible to have alternate settings with different numbers of channels? I can see how I could easily en/disable the channels in the firmware, but I can't see how to inform the driver that the number of channels has changed.
Thanks, Cameron.
Clemens Ladisch wrote:
Cameron Stone wrote:
Is it possible to have alternate settings with different numbers of channels?
Yes. Each alternate setting has its own set of descriptors; you can change _any_ parameter in those descriptors.
Great, I've got this working now.
However, how do I ask arecord to use a particular alternate setting? I'd like to have two alternate settings with the same number of channels, but different microphones enabled. Is that possible? I'm using the following command line (my USB mic array is card 1):
$ arecord -Dplughw:1,0 test.wav -d 1 -c 4 -r 30
I have two alternate settings with 4 channels, and arecord seems to always choose the last one (the one with the highest alternate setting number. This could also be the alsa driver making this choice.
amixer can display and control the different interfaces using the second, but I can't find a command line option for arecord.
Thanks, Cameron.
FYI arecord -L returns:
front:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog Front speakers surround40:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 4.0 Surround output to Front and Rear speakers surround41:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 4.1 Surround output to Front, Rear and Subwoofer speakers surround50:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 5.0 Surround output to Front, Center and Rear speakers surround51:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers null Discard all samples (playback) or generate zero samples (capture) front:CARD=Adaptor,DEV=0 8-Mic AVR Adaptor, USB Audio Front speakers surround40:CARD=Adaptor,DEV=0 8-Mic AVR Adaptor, USB Audio 4.0 Surround output to Front and Rear speakers surround41:CARD=Adaptor,DEV=0 8-Mic AVR Adaptor, USB Audio 4.1 Surround output to Front, Rear and Subwoofer speakers surround50:CARD=Adaptor,DEV=0 8-Mic AVR Adaptor, USB Audio 5.0 Surround output to Front, Center and Rear speakers surround51:CARD=Adaptor,DEV=0 8-Mic AVR Adaptor, USB Audio 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71:CARD=Adaptor,DEV=0 8-Mic AVR Adaptor, USB Audio 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers iec958:CARD=Adaptor,DEV=0 8-Mic AVR Adaptor, USB Audio IEC958 (S/PDIF) Digital Audio Output
Cameron Stone wrote:
Clemens Ladisch wrote:
Each alternate setting has its own set of descriptors; you can change _any_ parameter in those descriptors.
Great, I've got this working now.
However, how do I ask arecord to use a particular alternate setting? I'd like to have two alternate settings with the same number of channels, but different microphones enabled. Is that possible?
This difference does not show up in the altsettings' descriptors, so the driver would not know which one to choose.
This needs to be a mixer control (a selector unit).
HTH Clemens
participants (2)
-
Cameron Stone
-
Clemens Ladisch