Add channel map support to usb-audio
cover Add channel map support to usb-audio
Hi,
the following patches are my recent work to add the channel map support to usb-audio driver. Since UAC2 has yet more channel definitions, I had to extend SNDRV_CHMAP_*.
Other than that, a fairly straightforward implementation by converting the channel config bitmap of usb descriptor to the chmap array.
Takashi
PATCH 1/2 ALSA: Extend chmap definitions for UAC2
USB audio class 2 has more channel map positions than we currently have. Let's add missing definitions.
--- include/uapi/sound/asound.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
include/uapi/sound/asound.h +11 -1
@@ -492,7 +492,17 @@ enum {SNDRV_CHMAP_TRL ,/* top rear left */ SNDRV_CHMAP_TRR ,/* top rear right */ SNDRV_CHMAP_TRC ,/* top rear center */ - SNDRV_CHMAP_LAST = SNDRV_CHMAP_TRC, +/* new definitions for UAC2 */ +SNDRV_CHMAP_TFLC ,/* top front left center */ +SNDRV_CHMAP_TFRC ,/* top front right center */ +SNDRV_CHMAP_TSL ,/* top side left */ +SNDRV_CHMAP_TSR ,/* top side right */ +SNDRV_CHMAP_LLFE ,/* left LFE */ +SNDRV_CHMAP_RLFE ,/* right LFE */ +SNDRV_CHMAP_BC ,/* bottom center */ +SNDRV_CHMAP_BLC ,/* bottom left center */ +SNDRV_CHMAP_BRC ,/* bottom right center */ + SNDRV_CHMAP_LAST = SNDRV_CHMAP_BRC, };#define SNDRV_CHMAP_POSITION_MASK 0xffff
Signature · 1 line
1.8.0
PATCH 2/2 ALSA: usb-audio: add channel map support
In reply to Takashi IwaiAdd the support for channel maps of the PCM streams on USB audio devices. The channel map information is already found in ChannelConfig descriptor entries, which haven't been referred until now.
Each chmap entry is added to audioformat list entry and copied to TLV dynamically instead of creating a whole chmap array.
--- sound/usb/card.h | 2 + sound/usb/stream.c | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 227 insertions(+), 5 deletions(-)
sound/usb/card.h +2 -0
@@ -27,6 +27,7 @@ struct audioformat {unsigned int nr_rates;/* number of rate table entries */ unsigned int *rate_table;/* rate table */ unsigned char clock;/* associated clock */ +struct snd_pcm_chmap_elem *chmap;/* (optional) channel map */ };struct snd_usb_substream ;
@@ -109,6 +110,7 @@ struct snd_usb_substream {struct audioformat *cur_audiofmt;/* current audioformat pointer (for hw_params callback) */ snd_pcm_format_t pcm_format;/* current audio format (for hw_params callback) */ unsigned int channels;/* current number of channels (for hw_params callback) */ +unsigned int channels_max;/* max channels in the all audiofmts */ unsigned int cur_rate;/* current rate (for hw_params callback) */ unsigned int period_bytes;/* current period bytes (for hw_params callback) */ unsigned int altset_idx;/* USB data format: index of alternate setting */
sound/usb/stream.c +225 -5
320 lines not on this page · raw message
Signature · 1 line
1.8.0