ALSA: usb-mixer: Add support for UAC2 devices
This patch series adds support for mixer interfaces in USB audio class v2 devices. Successfully tested on a XMOS L1 eval kit. They apply on top of the topic/usb branch.
There's a number significant differences between v1 and v2 implementations, which the patches itself may explain best :)
I moved most quirks out into a seperate file, and hope you agree that it's cleaner that way. Most descriptors are now parsed with structs which makes the code more readable. However, there are quite some descriptors with variable field lengths so they can't be mapped into structs. I introduces some macros to access these fields.
Again, please test this with v1 devices, as I can't be entirely confident that I didn't break anything in the transition.
Thanks,
Daniel
[PATCH 1/6] linux/usb/audio.h: split header
[PATCH 2/6] ALSA: usb-mixer: use defines from audio.h [PATCH 3/6] ALSA: usb-mixer: factor out quirks
[PATCH 4/6] ALSA: usb-mixer: rename usbmixer.[ch] -> mixer.[ch] [PATCH 5/6] ALSA: usb-mixer: parse descriptors with structs [PATCH 6/6] ALSA: usb-mixer: Add support for Audio Class v2.0
PATCH 1/6 linux/usb/audio.h: split header
- Split the audio.h file in two to clearly denote the differences between the standards.
- Add many more defines to audio-v2.h. Most of them are not currently used.
- Replaced a magic value with a proper define
--- include/linux/usb/audio-v2.h | 319 ++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/audio.h | 50 +------ sound/usb/card.c | 3 +- sound/usb/endpoint.c | 1 + sound/usb/format.c | 1 + sound/usb/pcm.c | 5 +- 6 files changed, 333 insertions(+), 46 deletions(-) create mode 100644 include/linux/usb/audio-v2.h
include/linux/usb/audio-v2.h new file +319 -0
@@ -0,0 +1,319 @@ +/* +* Copyright (c) 2010 Daniel Mack <[email protected]> +* +* This software is distributed under the terms of the GNU General Public +* License ("GPL") version 2, as published by the Free Software Foundation. +* +* This file holds USB constants and structures defined +* by the USB Device Class Definition for Audio Devices in version 2.0. +* Comments below reference relevant sections of the documents contained +* in http://www.usb.org/developers/devclass_docs/Audio2.0_final.zip +*/ + +#ifndef __LINUX_USB_AUDIO_V2_H +#define __LINUX_USB_AUDIO_V2_H + +#include <linux/types.h> + +/* v1.0 and v2.0 of this standard have many things in common. For the rest +* of the definitions, please refer to audio.h */ + +/* 4.7.2.1 Clock Source Descriptor */ + +struct uac_clock_source_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bClockID; +__u8 bmAttributes; +__u8 bmControls; +__u8 bAssocTerminal; +__u8 iClockSource; +} __attribute__((packed)); + +/* 4.7.2.2 Clock Source Descriptor */ + +struct uac_clock_selector_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bClockID; +__u8 bNrInPins; +__u8 bmControls; +__u8 baCSourceID[]; +} __attribute__((packed)); + +/* 4.9.2 Class-Specific AS Interface Descriptor */ + +struct uac_as_header_descriptor_v2 { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bTerminalLink; +__u8 bmControls; +__u8 bFormatType; +__u32 bmFormats; +__u8 bNrChannels; +__u32 bmChannelConfig; +__u8 iChannelNames; +} __attribute__((packed)); + + +/* A.7 Audio Function Category Codes */ +#define UAC2_FUNCTION_SUBCLASS_UNDEFINED 0x00 +#define UAC2_FUNCTION_DESKTOP_SPEAKER 0x01 +#define UAC2_FUNCTION_HOME_THEATER 0x02 +#define UAC2_FUNCTION_MICROPHONE 0x03 +#define UAC2_FUNCTION_HEADSET 0x04 +#define UAC2_FUNCTION_TELEPHONE 0x05 +#define UAC2_FUNCTION_CONVERTER 0x06 +#define UAC2_FUNCTION_SOUND_RECORDER 0x07 +#define UAC2_FUNCTION_IO_BOX 0x08 +#define UAC2_FUNCTION_MUSICAL_INSTRUMENT 0x09 +#define UAC2_FUNCTION_PRO_AUDIO 0x0a +#define UAC2_FUNCTION_AUDIO_VIDEO 0x0b +#define UAC2_FUNCTION_CONTROL_PANEL 0x0c +#define UAC2_FUNCTION_OTHER 0xff + +/* A.9 Audio Class-Specific AC Interface Descriptor Subtypes */ +/* see audio.h for the rest, which is identical to v1 */ +#define UAC2_EFFECT_UNIT 0x07 +#define UAC2_PROCESSING_UNIT_V2 0x08 +#define UAC2_EXTENSION_UNIT_V2 0x09 +#define UAC2_CLOCK_SOURCE 0x0a +#define UAC2_CLOCK_SELECTOR 0x0b +#define UAC2_CLOCK_MULTIPLIER 0x0c +#define UAC2_SAMPLE_RATE_CONVERTER 0x0d + +/* A.10 Audio Class-Specific AS Interface Descriptor Subtypes */ +/* see audio.h for the rest, which is identical to v1 */ +#define UAC2_ENCODER 0x03 +#define UAC2_DECODER 0x04 + +/* A.11 Effect Unit Effect Types */ +#define UAC2_EFFECT_UNDEFINED 0x00 +#define UAC2_EFFECT_PARAM_EQ 0x01 +#define UAC2_EFFECT_REVERB 0x02 +#define UAC2_EFFECT_MOD_DELAY 0x03 +#define UAC2_EFFECT_DYN_RANGE_COMP 0x04 + +/* A.12 Processing Unit Process Types */ +#define UAC2_PROCESS_UNDEFINED 0x00 +#define UAC2_PROCESS_UP_DOWNMIX 0x01 +#define UAC2_PROCESS_DOLBY_PROLOCIC 0x02 +#define UAC2_PROCESS_STEREO_EXTENDER 0x03 + +/* A.14 Audio Class-Specific Request Codes */ +#define UAC2_CS_CUR 0x01 +#define UAC2_CS_RANGE 0x02 + +/* A.15 Encoder Type Codes */ +#define UAC2_ENCODER_UNDEFINED 0x00 +#define UAC2_ENCODER_OTHER 0x01 +#define UAC2_ENCODER_MPEG 0x02 +#define UAC2_ENCODER_AC3 0x03 +#define UAC2_ENCODER_WMA 0x04 +#define UAC2_ENCODER_DTS 0x05 + +/* A.16 Decoder Type Codes */ +#define UAC2_DECODER_UNDEFINED 0x00 +#define UAC2_DECODER_OTHER 0x01 +#define UAC2_DECODER_MPEG 0x02 +#define UAC2_DECODER_AC3 0x03 +#define UAC2_DECODER_WMA 0x04 +#define UAC2_DECODER_DTS 0x05 + +/* A.17.1 Clock Source Control Selectors */ +#define UAC2_CS_UNDEFINED 0x00 +#define UAC2_CS_CONTROL_SAM_FREQ 0x01 +#define UAC2_CS_CONTROL_CLOCK_VALID 0x02 + +/* A.17.2 Clock Selector Control Selectors */ +#define UAC2_CX_UNDEFINED 0x00 +#define UAC2_CX_CLOCK_SELECTOR 0x01 + +/* A.17.3 Clock Multiplier Control Selectors */ +#define UAC2_CM_UNDEFINED 0x00 +#define UAC2_CM_NUMERATOR 0x01 +#define UAC2_CM_DENOMINTATOR 0x02 + +/* A.17.4 Terminal Control Selectors */ +#define UAC2_TE_UNDEFINED 0x00 +#define UAC2_TE_COPY_PROTECT 0x01 +#define UAC2_TE_CONNECTOR 0x02 +#define UAC2_TE_OVERLOAD 0x03 +#define UAC2_TE_CLUSTER 0x04 +#define UAC2_TE_UNDERFLOW 0x05 +#define UAC2_TE_OVERFLOW 0x06 +#define UAC2_TE_LATENCY 0x07 + +/* A.17.5 Mixer Control Selectors */ +#define UAC2_MU_UNDEFINED 0x00 +#define UAC2_MU_MIXER 0x01 +#define UAC2_MU_CLUSTER 0x02 +#define UAC2_MU_UNDERFLOW 0x03 +#define UAC2_MU_OVERFLOW 0x04 +#define UAC2_MU_LATENCY 0x05 + +/* A.17.6 Selector Control Selectors */ +#define UAC2_SU_UNDEFINED 0x00 +#define UAC2_SU_SELECTOR 0x01 +#define UAC2_SU_LATENCY 0x02 + +/* A.17.7 Feature Unit Control Selectors */ +/* see audio.h for the rest, which is identical to v1 */ +#define UAC2_FU_INPUT_GAIN 0x0b +#define UAC2_FU_INPUT_GAIN_PAD 0x0c +#define UAC2_FU_PHASE_INVERTER 0x0d +#define UAC2_FU_UNDERFLOW 0x0e +#define UAC2_FU_OVERFLOW 0x0f +#define UAC2_FU_LATENCY 0x10 + +/* A.17.8.1 Parametric Equalizer Section Effect Unit Control Selectors */ +#define UAC2_PE_UNDEFINED 0x00 +#define UAC2_PE_ENABLE 0x01 +#define UAC2_PE_CENTERFREQ 0x02 +#define UAC2_PE_QFACTOR 0x03 +#define UAC2_PE_GAIN 0x04 +#define UAC2_PE_UNDERFLOW 0x05 +#define UAC2_PE_OVERFLOW 0x06 +#define UAC2_PE_LATENCY 0x07 + +/* A.17.8.2 Reverberation Effect Unit Control Selectors */ +#define UAC2_RV_UNDEFINED 0x00 +#define UAC2_RV_ENABLE 0x01 +#define UAC2_RV_TYPE 0x02 +#define UAC2_RV_LEVEL 0x03 +#define UAC2_RV_TIME 0x04 +#define UAC2_RV_FEEDBACK 0x05 +#define UAC2_RV_PREDELAY 0x06 +#define UAC2_RV_DENSITY 0x07 +#define UAC2_RV_HIFREQ_ROLLOFF 0x08 +#define UAC2_RV_UNDERFLOW 0x09 +#define UAC2_RV_OVERFLOW 0x0a +#define UAC2_RV_LATENCY 0x0b + +/* A.17.8.3 Modulation Delay Effect Control Selectors */ +#define UAC2_MD_UNDEFINED 0x00 +#define UAC2_MD_ENABLE 0x01 +#define UAC2_MD_BALANCE 0x02 +#define UAC2_MD_RATE 0x03 +#define UAC2_MD_DEPTH 0x04 +#define UAC2_MD_TIME 0x05 +#define UAC2_MD_FEEDBACK 0x06 +#define UAC2_MD_UNDERFLOW 0x07 +#define UAC2_MD_OVERFLOW 0x08 +#define UAC2_MD_LATENCY 0x09 + +/* A.17.8.4 Dynamic Range Compressor Effect Unit Control Selectors */ +#define UAC2_DR_UNDEFINED 0x00 +#define UAC2_DR_ENABLE 0x01 +#define UAC2_DR_COMPRESSION_RATE 0x02 +#define UAC2_DR_MAXAMPL 0x03 +#define UAC2_DR_THRESHOLD 0x04 +#define UAC2_DR_ATTACK_TIME 0x05 +#define UAC2_DR_RELEASE_TIME 0x06 +#define UAC2_DR_UNDEFLOW 0x07 +#define UAC2_DR_OVERFLOW 0x08 +#define UAC2_DR_LATENCY 0x09 + +/* A.17.9.1 Up/Down-mix Processing Unit Control Selectors */ +#define UAC2_UD_UNDEFINED 0x00 +#define UAC2_UD_ENABLE 0x01 +#define UAC2_UD_MODE_SELECT 0x02 +#define UAC2_UD_CLUSTER 0x03 +#define UAC2_UD_UNDERFLOW 0x04 +#define UAC2_UD_OVERFLOW 0x05 +#define UAC2_UD_LATENCY 0x06 + +/* A.17.9.2 Dolby Prologic[tm] Processing Unit Control Selectors */ +#define UAC2_DP_UNDEFINED 0x00 +#define UAC2_DP_ENABLE 0x01 +#define UAC2_DP_MODE_SELECT 0x02 +#define UAC2_DP_CLUSTER 0x03 +#define UAC2_DP_UNDERFFLOW 0x04 +#define UAC2_DP_OVERFLOW 0x05 +#define UAC2_DP_LATENCY 0x06 + +/* A.17.9.3 Stereo Expander Processing Unit Control Selectors */ +#define UAC2_ST_EXT_UNDEFINED 0x00 +#define UAC2_ST_EXT_ENABLE 0x01 +#define UAC2_ST_EXT_WIDTH 0x02 +#define UAC2_ST_EXT_UNDEFLOW 0x03 +#define UAC2_ST_EXT_OVERFLOW 0x04 +#define UAC2_ST_EXT_LATENCY 0x05 + +/* A.17.10 Extension Unit Control Selectors */ +#define UAC2_XU_UNDEFINED 0x00 +#define UAC2_XU_ENABLE 0x01 +#define UAC2_XU_CLUSTER 0x02 +#define UAC2_XU_UNDERFLOW 0x03 +#define UAC2_XU_OVERFLOW 0x04 +#define UAC2_XU_LATENCY 0x05 + +/* A.17.11 AudioStreaming Interface Control Selectors */ +#define UAC2_AS_UNDEFINED 0x00 +#define UAC2_AS_ACT_ALT_SETTING 0x01 +#define UAC2_AS_VAL_ALT_SETTINGS 0x02 +#define UAC2_AS_AUDIO_DATA_FORMAT 0x03 + +/* A.17.12 Encoder Control Selectors */ +#define UAC2_EN_UNDEFINED 0x00 +#define UAC2_EN_BIT_RATE 0x01 +#define UAC2_EN_QUALITY 0x02 +#define UAC2_EN_VBR 0x03 +#define UAC2_EN_TYPE 0x04 +#define UAC2_EN_UNDERFLOW 0x05 +#define UAC2_EN_OVERFLOW 0x06 +#define UAC2_EN_ENCODER_ERROR 0x07 +#define UAC2_EN_PARAM1 0x08 +#define UAC2_EN_PARAM2 0x09 +#define UAC2_EN_PARAM3 0x0a +#define UAC2_EN_PARAM4 0x0b +#define UAC2_EN_PARAM5 0x0c +#define UAC2_EN_PARAM6 0x0d +#define UAC2_EN_PARAM7 0x0e +#define UAC2_EN_PARAM8 0x0f + +/* A.17.13.1 MPEG Decoder Control Selectors */ +#define UAC2_MPEG_UNDEFINED 0x00 +#define UAC2_MPEG_DUAL_CHANNEL 0x01 +#define UAC2_MPEG_SECOND_STEREO 0x02 +#define UAC2_MPEG_MULTILINGUAL 0x03 +#define UAC2_MPEG_DYN_RANGE 0x04 +#define UAC2_MPEG_SCALING 0x05 +#define UAC2_MPEG_HILO_SCALING 0x06 +#define UAC2_MPEG_UNDERFLOW 0x07 +#define UAC2_MPEG_OVERFLOW 0x08 +#define UAC2_MPEG_DECODER_ERROR 0x09 + +/* A17.13.2 AC3 Decoder Control Selectors */ +#define UAC2_AC3_UNDEFINED 0x00 +#define UAC2_AC3_MODE 0x01 +#define UAC2_AC3_DYN_RANGE 0x02 +#define UAC2_AC3_SCALING 0x03 +#define UAC2_AC3_HILO_SCALING 0x04 +#define UAC2_AC3_UNDERFLOW 0x05 +#define UAC2_AC3_OVERFLOW 0x06 +#define UAC2_AC3_DECODER_ERROR 0x07 + +/* A17.13.3 WMA Decoder Control Selectors */ +#define UAC2_WMA_UNDEFINED 0x00 +#define UAC2_WMA_UNDERFLOW 0x01 +#define UAC2_WMA_OVERFLOW 0x02 +#define UAC2_WMA_DECODER_ERROR 0x03 + +/* A17.13.4 DTS Decoder Control Selectors */ +#define UAC2_DTS_UNDEFINED 0x00 +#define UAC2_DTS_UNDERFLOW 0x01 +#define UAC2_DTS_OVERFLOW 0x02 +#define UAC2_DTS_DECODER_ERROR 0x03 + +/* A17.14 Endpoint Control Selectors */ +#define UAC2_EP_CS_UNDEFINED 0x00 +#define UAC2_EP_CS_PITCH 0x01 +#define UAC2_EP_CS_DATA_OVERRUN 0x02 +#define UAC2_EP_CS_DATA_UNDERRUN 0x03 + +#endif /* __LINUX_USB_AUDIO_V2_H */ +
include/linux/usb/audio.h +7 -43
97 lines not on this page · raw message
sound/usb/card.c +2 -1
@@ -45,6 +45,7 @@#include <linux/moduleparam.h> #include <linux/mutex.h> #include <linux/usb/audio.h> +#include <linux/usb/audio-v2.h> #include <sound/core.h> #include <sound/info.h>
@@ -250,7 +251,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)* clock selectors and sample rate conversion units. */ cs =snd_usb_find_csint_desc (host_iface->extra, host_iface->extralen, -NULL ,UAC_CLOCK_SOURCE ); +NULL ,UAC2_CLOCK_SOURCE );if (!cs) {snd_printk (KERN_ERR "CLOCK_SOURCE descriptor not found\n" );
sound/usb/endpoint.c +1 -0
@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/usb.h> #include <linux/usb/audio.h> +#include <linux/usb/audio-v2.h> #include <sound/core.h> #include <sound/pcm.h>
sound/usb/format.c +1 -0
@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/usb.h> #include <linux/usb/audio.h> +#include <linux/usb/audio-v2.h> #include <sound/core.h> #include <sound/pcm.h>
sound/usb/pcm.c +3 -2
@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/usb.h> #include <linux/usb/audio.h> +#include <linux/usb/audio-v2.h> #include <sound/core.h> #include <sound/pcm.h>
@@ -215,7 +216,7 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, data[3 ] = rate >>24 ;if ((err =snd_usb_ctl_msg (dev,usb_sndctrlpipe (dev,0 ),UAC2_CS_CUR ,USB_TYPE_CLASS |USB_RECIP_INTERFACE |USB_DIR_OUT , -0x0100 , chip->clock_id <<8 , +UAC2_CS_CONTROL_SAM_FREQ <<8 , chip->clock_id <<8 , data,sizeof (data),1000 )) <0 ) {snd_printk (KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n" , dev->devnum, iface, fmt->altsetting, rate);
@@ -223,7 +224,7 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, }if ((err =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ),UAC2_CS_CUR ,USB_TYPE_CLASS |USB_RECIP_INTERFACE |USB_DIR_IN , -0x0100 , chip->clock_id <<8 , +UAC2_CS_CONTROL_SAM_FREQ <<8 , chip->clock_id <<8 , data,sizeof (data),1000 )) <0 ) {snd_printk (KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n" , dev->devnum, iface, fmt->altsetting);
Signature · 1 line
1.6.6.2
PATCH 2/6 ALSA: usb-mixer: use defines from audio.h
No need for the private enum.
--- sound/usb/format.c | 6 ++++-- sound/usb/usbmixer.c | 27 ++++++--------------------- sound/usb/usbmixer_maps.c | 4 ++-- 3 files changed, 12 insertions(+), 25 deletions(-)
sound/usb/format.c +4 -2
@@ -218,7 +218,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,/* get the number of sample rates first by only fetching 2 bytes */ ret =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ),UAC2_CS_RANGE ,USB_TYPE_CLASS |USB_RECIP_INTERFACE |USB_DIR_IN , -0x0100 , chip->clock_id <<8 , tmp,sizeof (tmp),1000 ); +UAC2_CS_CONTROL_SAM_FREQ <<8 , chip->clock_id <<8 , + tmp,sizeof (tmp),1000 );if (ret <0 ) {snd_printk (KERN_ERR "unable to retrieve number of sample rates\n" );
@@ -236,7 +237,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,/* now get the full information */ ret =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ),UAC2_CS_RANGE ,USB_TYPE_CLASS |USB_RECIP_INTERFACE |USB_DIR_IN , -0x0100 , chip->clock_id <<8 , data, data_size,1000 ); +UAC2_CS_CONTROL_SAM_FREQ <<8 , chip->clock_id <<8 , + data, data_size,1000 );if (ret <0 ) {snd_printk (KERN_ERR "unable to retrieve sample rate range\n" );
sound/usb/usbmixer.c +6 -21
@@ -136,21 +136,6 @@ struct usb_mixer_elem_info {u8 initialized; }; - -enum { -USB_FEATURE_NONE =0 , -USB_FEATURE_MUTE =1 , -USB_FEATURE_VOLUME , -USB_FEATURE_BASS , -USB_FEATURE_MID , -USB_FEATURE_TREBLE , -USB_FEATURE_GEQ , -USB_FEATURE_AGC , -USB_FEATURE_DELAY , -USB_FEATURE_BASSBOOST , -USB_FEATURE_LOUDNESS -}; -enum {USB_MIXER_BOOLEAN ,USB_MIXER_INV_BOOLEAN ,
@@ -954,7 +939,7 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, control++;/* change from zero-based to 1-based value */ -if (control ==USB_FEATURE_GEQ ) { +if (control ==UAC_GRAPHIC_EQUALIZER_CONTROL ) {/* FIXME: not supported yet */ return ; }
@@ -1001,8 +986,8 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, kctl->id.name, sizeof(kctl->id.name));switch (control) { -case USB_FEATURE_MUTE : -case USB_FEATURE_VOLUME : +case UAC_MUTE_CONTROL : +case UAC_VOLUME_CONTROL :/* determine the control name. the rule is: * - if a name id is given in descriptor, use it. * - if the connected input can be determined, then use the name
@@ -1029,9 +1014,9 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, len =append_ctl_name (kctl," Playback" ); } } -append_ctl_name (kctl, control ==USB_FEATURE_MUTE ? +append_ctl_name (kctl, control ==UAC_MUTE_CONTROL ?" Switch" :" Volume" ); -if (control ==USB_FEATURE_VOLUME ) { +if (control ==UAC_VOLUME_CONTROL ) { kctl->tlv.c = mixer_vol_tlv; kctl->vd[0 ].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ |
@@ -1120,7 +1105,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, voidsnd_printk (KERN_INFO "usbmixer: master volume quirk for PCM2702 chip\n" );/* disable non-functional volume control */ - master_bits &= ~(1 << (USB_FEATURE_VOLUME -1 )); + master_bits &= ~UAC_FU_VOLUME ;break ; }if (channels >0 )
sound/usb/usbmixer_maps.c +2 -2
@@ -85,8 +85,8 @@ static struct usbmix_name_map extigy_map[] = {/* 16: MU (w/o controls) */ { 17, NULL, 1 }, /* DISABLED: PU-switch (any effect?) */ { 17, "Channel Routing", 2 }, /* PU: mode select */ - { 18, "Tone Control - Bass", USB_FEATURE_BASS }, /* FU */ - { 18, "Tone Control - Treble", USB_FEATURE_TREBLE }, /* FU */ + { 18, "Tone Control - Bass", UAC_BASS_CONTROL }, /* FU */ + { 18, "Tone Control - Treble", UAC_TREBLE_CONTROL }, /* FU */ { 18, "Master Playback" }, /* FU; others *//* 19: OT speaker */ /* 20: OT headphone */
Signature · 1 line
1.6.6.2
PATCH 3/6 ALSA: usb-mixer: factor out quirks
Move all non-standard mixer controls and vendor-specific extensions to a separate file. Some structs need to be exported now.
--- sound/usb/Makefile | 1 + sound/usb/mixer_quirks.c | 411 ++++++++++++++++++++++++++++++++++++++++++++ sound/usb/mixer_quirks.h | 13 ++ sound/usb/quirks.c | 1 + sound/usb/usbmixer.c | 425 ++-------------------------------------------- sound/usb/usbmixer.h | 45 +++++- 6 files changed, 480 insertions(+), 416 deletions(-) create mode 100644 sound/usb/mixer_quirks.c create mode 100644 sound/usb/mixer_quirks.h
sound/usb/Makefile +1 -0
@@ -4,6 +4,7 @@ snd-usb-audio-objs := card.o \ usbmixer.o \ + mixer_quirks.o \ proc.o \ quirks.o \ format.o \
sound/usb/mixer_quirks.c new file +411 -0
411 lines not on this page · raw message
sound/usb/mixer_quirks.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef SND_USB_MIXER_QUIRKS_H +#define SND_USB_MIXER_QUIRKS_H + +int snd_usb_mixer_apply_create_quirk (struct usb_mixer_interface *mixer); + +void snd_emuusb_set_samplerate (struct snd_usb_audio *chip, +unsigned char samplerate_id); + +void snd_usb_mixer_rc_memory_change (struct usb_mixer_interface *mixer, +int unitid); + +#endif /* SND_USB_MIXER_QUIRKS_H */ +
sound/usb/quirks.c +1 -0
@@ -25,6 +25,7 @@#include "usbaudio.h" #include "card.h" #include "usbmixer.h" +#include "mixer_quirks.h" #include "midi.h" #include "quirks.h" #include "helper.h"
sound/usb/usbmixer.c +11 -414
500 lines not on this page · raw message
sound/usb/usbmixer.h +43 -2
54 lines not on this page · raw message
Signature · 1 line
1.6.6.2
PATCH 4/6 ALSA: usb-mixer: rename usbmixer.[ch] -> mixer.[ch]
For clearer namespace, also rename usbmixer_maps.c -> mixer_maps.c
---
sound/usb/Makefile | 2 +-
sound/usb/card.c | 2 +-
sound/usb/{usbmixer.c => mixer.c} | 4 ++--
sound/usb/{usbmixer.h => mixer.h} | 0
sound/usb/{usbmixer_maps.c => mixer_maps.c} | 0
sound/usb/mixer_quirks.c | 2 +-
sound/usb/quirks.c | 2 +-
7 files changed, 6 insertions(+), 6 deletions(-)
rename sound/usb/{usbmixer.c => mixer.c} (99%)
rename sound/usb/{usbmixer.h => mixer.h} (100%)
rename sound/usb/{usbmixer_maps.c => mixer_maps.c} (100%)sound/usb/Makefile +1 -1
@@ -3,7 +3,7 @@ # snd-usb-audio-objs := card.o \ - usbmixer.o \ + mixer.o \ mixer_quirks.o \ proc.o \ quirks.o \
sound/usb/card.c +1 -1
@@ -56,7 +56,7 @@#include "usbaudio.h" #include "card.h" #include "midi.h" -#include "usbmixer.h" +#include "mixer.h" #include "proc.h" #include "quirks.h" #include "endpoint.h"
sound/usb/mixer.c renamed from sound/usb/usbmixer.c +2 -2
@@ -41,7 +41,7 @@#include <sound/tlv.h> #include "usbaudio.h" -#include "usbmixer.h" +#include "mixer.h" #include "helper.h" #include "mixer_quirks.h"
@@ -132,7 +132,7 @@ enum {* if the mixer topology is too complicated and the parsed names are * ambiguous, add the entries in usbmixer_maps.c. */ -#include "usbmixer_maps.c" +#include "mixer_maps.c" static const struct usbmix_name_map *find_map (struct mixer_build *state,int unitid,int control)
sound/usb/mixer.h renamed from sound/usb/usbmixer.h +0 -0
sound/usb/mixer_maps.c renamed from sound/usb/usbmixer_maps.c +0 -0
sound/usb/mixer_quirks.c +1 -1
@@ -35,7 +35,7 @@#include <sound/info.h> #include "usbaudio.h" -#include "usbmixer.h" +#include "mixer.h" #include "mixer_quirks.h" #include "helper.h"
sound/usb/quirks.c +1 -1
@@ -24,7 +24,7 @@#include "usbaudio.h" #include "card.h" -#include "usbmixer.h" +#include "mixer.h" #include "mixer_quirks.h" #include "midi.h" #include "quirks.h"
Signature · 1 line
1.6.6.2
PATCH 5/6 ALSA: usb-mixer: parse descriptors with structs
Introduce a number of new structs for mixer, selector, feature and processing units and some static inline helpers to access fields which have dynamic offsets. Use them in mixer.c to parse the descriptors. This is necessary for the upcoming audio v2 parsers.
--- include/linux/usb/audio.h | 129 +++++++++++++++++++++++++++++++++++++++++---- sound/usb/mixer.c | 87 ++++++++++++++++-------------- 2 files changed, 166 insertions(+), 50 deletions(-)
include/linux/usb/audio.h +119 -10
@@ -181,6 +181,125 @@ struct uac_feature_unit_descriptor_##ch { \__u8 iFeature; \ } __attribute__ ((packed)) +/* 4.3.2.3 Mixer Unit Descriptor */ +struct uac_mixer_unit_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bUnitID; +__u8 bNrInPins; +__u8 baSourceID[]; +} __attribute__ ((packed)); + +static inline __u8 uac_mixer_unit_bNrChannels (struct uac_mixer_unit_descriptor *desc) +{ +return desc->baSourceID[desc->bNrInPins]; +} + +static inline __u16 uac_mixer_unit_wChannelConfig (struct uac_mixer_unit_descriptor *desc) +{ +return (desc->baSourceID[desc->bNrInPins +2 ] <<8 ) | + desc->baSourceID[desc->bNrInPins +1 ]; +} + +static inline __u8 uac_mixer_unit_iChannelNames (struct uac_mixer_unit_descriptor *desc) +{ +return desc->baSourceID[desc->bNrInPins +3 ]; +} + +static inline __u8 *uac_mixer_unit_bmControls (struct uac_mixer_unit_descriptor *desc) +{ +return &desc->baSourceID[desc->bNrInPins +4 ]; +} + +static inline __u8 uac_mixer_unit_iMixer (struct uac_mixer_unit_descriptor *desc) +{ +__u8 *raw = (__u8 *) desc; +return raw[desc->bLength -1 ]; +} + +/* 4.3.2.4 Selector Unit Descriptor */ +struct uac_selector_unit_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bUintID; +__u8 bNrInPins; +__u8 baSourceID[]; +} __attribute__ ((packed)); + +static inline __u8 uac_selector_unit_iSelector (struct uac_selector_unit_descriptor *desc) +{ +__u8 *raw = (__u8 *) desc; +return raw[desc->bLength -1 ]; +} + +/* 4.3.2.5 Feature Unit Descriptor */ +struct uac_feature_unit_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bUnitID; +__u8 bSourceID; +__u8 bControlSize; +__u8 bmaControls[0 ];/* variable length */ +} __attribute__((packed)); + +static inline __u8 uac_feature_unit_iFeature (struct uac_feature_unit_descriptor *desc) +{ +__u8 *raw = (__u8 *) desc; +return raw[desc->bLength -1 ]; +} + +/* 4.3.2.6 Processing Unit Descriptors */ +struct uac_processing_unit_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bUnitID; +__u16 wProcessType; +__u8 bNrInPins; +__u8 baSourceID[]; +} __attribute__ ((packed)); + +static inline __u8 uac_processing_unit_bNrChannels (struct uac_processing_unit_descriptor *desc) +{ +return desc->baSourceID[desc->bNrInPins]; +} + +static inline __u16 uac_processing_unit_wChannelConfig (struct uac_processing_unit_descriptor *desc) +{ +return (desc->baSourceID[desc->bNrInPins +2 ] <<8 ) | + desc->baSourceID[desc->bNrInPins +1 ]; +} + +static inline __u8 uac_processing_unit_iChannelNames (struct uac_processing_unit_descriptor *desc) +{ +return desc->baSourceID[desc->bNrInPins +3 ]; +} + +static inline __u8 uac_processing_unit_bControlSize (struct uac_processing_unit_descriptor *desc) +{ +return desc->baSourceID[desc->bNrInPins +4 ]; +} + +static inline __u8 *uac_processing_unit_bmControls (struct uac_processing_unit_descriptor *desc) +{ +return &desc->baSourceID[desc->bNrInPins +5 ]; +} + +static inline __u8 uac_processing_unit_iProcessing (struct uac_processing_unit_descriptor *desc) +{ +__u8 control_size =uac_processing_unit_bControlSize (desc); +return desc->baSourceID[desc->bNrInPins + control_size]; +} + +static inline __u8 *uac_processing_unit_specific (struct uac_processing_unit_descriptor *desc) +{ +__u8 control_size =uac_processing_unit_bControlSize (desc); +return &desc->baSourceID[desc->bNrInPins + control_size +1 ]; +} +/* 4.5.2 Class-Specific AS Interface Descriptor */ struct uac_as_header_descriptor_v1 {__u8 bLength;/* in bytes: 7 */
@@ -315,16 +434,6 @@ struct uac_iso_endpoint_descriptor {/* A.10.2 Feature Unit Control Selectors */ -struct uac_feature_unit_descriptor { -__u8 bLength; -__u8 bDescriptorType; -__u8 bDescriptorSubtype; -__u8 bUnitID; -__u8 bSourceID; -__u8 bControlSize; -__u8 controls[0 ];/* variable length */ -} __attribute__((packed)); -#define UAC_FU_CONTROL_UNDEFINED 0x00#define UAC_MUTE_CONTROL 0x01#define UAC_VOLUME_CONTROL 0x02
sound/usb/mixer.c +47 -40
265 lines not on this page · raw message
Signature · 1 line
1.6.6.2
PATCH 6/6 ALSA: usb-mixer: Add support for Audio Class v2.0
USB Audio Class v2.0 compliant devices have different descriptors and a different way of setting/getting min/max/res/cur properties. This patch adds support for them.
--- include/linux/usb/audio-v2.h | 47 ++++++ include/linux/usb/audio.h | 71 +++++++--- sound/usb/mixer.c | 322 +++++++++++++++++++++++++++++++----------- sound/usb/mixer.h | 3 + 4 files changed, 343 insertions(+), 100 deletions(-)
include/linux/usb/audio-v2.h +47 -0
@@ -43,6 +43,53 @@ struct uac_clock_selector_descriptor {__u8 baCSourceID[]; } __attribute__((packed)); +/* 4.7.2.4 Input terminal descriptor */ + +struct uac2_input_terminal_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bTerminalID; +__u16 wTerminalType; +__u8 bAssocTerminal; +__u8 bCSourceID; +__u8 bNrChannels; +__u32 bmChannelConfig; +__u8 iChannelNames; +__u16 bmControls; +__u8 iTerminal; +} __attribute__((packed)); + +/* 4.7.2.5 Output terminal descriptor */ + +struct uac2_output_terminal_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bTerminalID; +__u16 wTerminalType; +__u8 bAssocTerminal; +__u8 bSourceID; +__u8 bCSourceID; +__u16 bmControls; +__u8 iTerminal; +} __attribute__((packed)); + + + +/* 4.7.2.8 Feature Unit Descriptor */ + +struct uac2_feature_unit_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bUnitID; +__u8 bSourceID; +/* bmaControls is actually u32, +* but u8 is needed for the hybrid parser */ +__u8 bmaControls[0 ];/* variable length */ +} __attribute__((packed)); +/* 4.9.2 Class-Specific AS Interface Descriptor */ struct uac_as_header_descriptor_v2 {
include/linux/usb/audio.h +51 -20
107 lines not on this page · raw message
sound/usb/mixer.c +242 -80
502 lines not on this page · raw message
sound/usb/mixer.h +3 -0
@@ -10,6 +10,9 @@ struct usb_mixer_interface {/* array[MAX_ID_ELEMS], indexed by unit id */ struct usb_mixer_elem_info **id_elems; +/* the usb audio specification version this interface complies to */ +int protocol; +/* Sound Blaster remote control stuff */ const struct rc_config *rc_cfg;u32 rc_code;
Signature · 1 line
1.6.6.2
Re: [PATCH 1/6] linux/usb/audio.h: split header
In reply to Daniel MackQuoted 9 lines · Daniel Mack
- Split the
audio.hfile in two to clearly denote the differences between the standards.
- Add many more defines toaudio-v2.h. Most of them are not currently used.
- Replaced a magic value with a proper defineSigned-off-by Daniel Mack <[email protected]>Cc Clemens Ladisch <[email protected]>Cc Takashi Iwai <[email protected]>
Sorry Greg, I forgot to Cc: you on this.
As the patch touch both the include files and audio code, it would go thru the ALSA channel again if you don't mind.
Thanks,
Daniel
Quoted 521 lines
--- include/linux/usb/audio-v2.h | 319 ++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/audio.h | 50 +------ sound/usb/card.c | 3 +- sound/usb/endpoint.c | 1 + sound/usb/format.c | 1 + sound/usb/pcm.c | 5 +- 6 files changed, 333 insertions(+), 46 deletions(-) create mode 100644 include/linux/usb/audio-v2.hinclude/linux/usb/audio-v2.h new file +319
-0@@ -0,0 +1,319 @@ +/* +* Copyright (c) 2010 Daniel Mack <[email protected]> +* +* This software is distributed under the terms of the GNU General Public +* License ("GPL") version 2, as published by the Free Software Foundation. +* +* This file holds USB constants and structures defined +* by the USB Device Class Definition for Audio Devices in version 2.0. +* Comments below reference relevant sections of the documents contained +* in http://www.usb.org/developers/devclass_docs/Audio2.0_final.zip +*/ + +#ifndef __LINUX_USB_AUDIO_V2_H +#define __LINUX_USB_AUDIO_V2_H + +#include <linux/types.h> + +/* v1.0 and v2.0 of this standard have many things in common. For the rest +* of the definitions, please refer to audio.h */ + +/* 4.7.2.1 Clock Source Descriptor */ + +struct uac_clock_source_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bClockID; +__u8 bmAttributes; +__u8 bmControls; +__u8 bAssocTerminal; +__u8 iClockSource; +} __attribute__((packed)); + +/* 4.7.2.2 Clock Source Descriptor */ + +struct uac_clock_selector_descriptor { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bClockID; +__u8 bNrInPins; +__u8 bmControls; +__u8 baCSourceID[]; +} __attribute__((packed)); + +/* 4.9.2 Class-Specific AS Interface Descriptor */ + +struct uac_as_header_descriptor_v2 { +__u8 bLength; +__u8 bDescriptorType; +__u8 bDescriptorSubtype; +__u8 bTerminalLink; +__u8 bmControls; +__u8 bFormatType; +__u32 bmFormats; +__u8 bNrChannels; +__u32 bmChannelConfig; +__u8 iChannelNames; +} __attribute__((packed)); + + +/* A.7 Audio Function Category Codes */ +#define UAC2_FUNCTION_SUBCLASS_UNDEFINED 0x00 +#define UAC2_FUNCTION_DESKTOP_SPEAKER 0x01 +#define UAC2_FUNCTION_HOME_THEATER 0x02 +#define UAC2_FUNCTION_MICROPHONE 0x03 +#define UAC2_FUNCTION_HEADSET 0x04 +#define UAC2_FUNCTION_TELEPHONE 0x05 +#define UAC2_FUNCTION_CONVERTER 0x06 +#define UAC2_FUNCTION_SOUND_RECORDER 0x07 +#define UAC2_FUNCTION_IO_BOX 0x08 +#define UAC2_FUNCTION_MUSICAL_INSTRUMENT 0x09 +#define UAC2_FUNCTION_PRO_AUDIO 0x0a +#define UAC2_FUNCTION_AUDIO_VIDEO 0x0b +#define UAC2_FUNCTION_CONTROL_PANEL 0x0c +#define UAC2_FUNCTION_OTHER 0xff + +/* A.9 Audio Class-Specific AC Interface Descriptor Subtypes */ +/* see audio.h for the rest, which is identical to v1 */ +#define UAC2_EFFECT_UNIT 0x07 +#define UAC2_PROCESSING_UNIT_V2 0x08 +#define UAC2_EXTENSION_UNIT_V2 0x09 +#define UAC2_CLOCK_SOURCE 0x0a +#define UAC2_CLOCK_SELECTOR 0x0b +#define UAC2_CLOCK_MULTIPLIER 0x0c +#define UAC2_SAMPLE_RATE_CONVERTER 0x0d + +/* A.10 Audio Class-Specific AS Interface Descriptor Subtypes */ +/* see audio.h for the rest, which is identical to v1 */ +#define UAC2_ENCODER 0x03 +#define UAC2_DECODER 0x04 + +/* A.11 Effect Unit Effect Types */ +#define UAC2_EFFECT_UNDEFINED 0x00 +#define UAC2_EFFECT_PARAM_EQ 0x01 +#define UAC2_EFFECT_REVERB 0x02 +#define UAC2_EFFECT_MOD_DELAY 0x03 +#define UAC2_EFFECT_DYN_RANGE_COMP 0x04 + +/* A.12 Processing Unit Process Types */ +#define UAC2_PROCESS_UNDEFINED 0x00 +#define UAC2_PROCESS_UP_DOWNMIX 0x01 +#define UAC2_PROCESS_DOLBY_PROLOCIC 0x02 +#define UAC2_PROCESS_STEREO_EXTENDER 0x03 + +/* A.14 Audio Class-Specific Request Codes */ +#define UAC2_CS_CUR 0x01 +#define UAC2_CS_RANGE 0x02 + +/* A.15 Encoder Type Codes */ +#define UAC2_ENCODER_UNDEFINED 0x00 +#define UAC2_ENCODER_OTHER 0x01 +#define UAC2_ENCODER_MPEG 0x02 +#define UAC2_ENCODER_AC3 0x03 +#define UAC2_ENCODER_WMA 0x04 +#define UAC2_ENCODER_DTS 0x05 + +/* A.16 Decoder Type Codes */ +#define UAC2_DECODER_UNDEFINED 0x00 +#define UAC2_DECODER_OTHER 0x01 +#define UAC2_DECODER_MPEG 0x02 +#define UAC2_DECODER_AC3 0x03 +#define UAC2_DECODER_WMA 0x04 +#define UAC2_DECODER_DTS 0x05 + +/* A.17.1 Clock Source Control Selectors */ +#define UAC2_CS_UNDEFINED 0x00 +#define UAC2_CS_CONTROL_SAM_FREQ 0x01 +#define UAC2_CS_CONTROL_CLOCK_VALID 0x02 + +/* A.17.2 Clock Selector Control Selectors */ +#define UAC2_CX_UNDEFINED 0x00 +#define UAC2_CX_CLOCK_SELECTOR 0x01 + +/* A.17.3 Clock Multiplier Control Selectors */ +#define UAC2_CM_UNDEFINED 0x00 +#define UAC2_CM_NUMERATOR 0x01 +#define UAC2_CM_DENOMINTATOR 0x02 + +/* A.17.4 Terminal Control Selectors */ +#define UAC2_TE_UNDEFINED 0x00 +#define UAC2_TE_COPY_PROTECT 0x01 +#define UAC2_TE_CONNECTOR 0x02 +#define UAC2_TE_OVERLOAD 0x03 +#define UAC2_TE_CLUSTER 0x04 +#define UAC2_TE_UNDERFLOW 0x05 +#define UAC2_TE_OVERFLOW 0x06 +#define UAC2_TE_LATENCY 0x07 + +/* A.17.5 Mixer Control Selectors */ +#define UAC2_MU_UNDEFINED 0x00 +#define UAC2_MU_MIXER 0x01 +#define UAC2_MU_CLUSTER 0x02 +#define UAC2_MU_UNDERFLOW 0x03 +#define UAC2_MU_OVERFLOW 0x04 +#define UAC2_MU_LATENCY 0x05 + +/* A.17.6 Selector Control Selectors */ +#define UAC2_SU_UNDEFINED 0x00 +#define UAC2_SU_SELECTOR 0x01 +#define UAC2_SU_LATENCY 0x02 + +/* A.17.7 Feature Unit Control Selectors */ +/* see audio.h for the rest, which is identical to v1 */ +#define UAC2_FU_INPUT_GAIN 0x0b +#define UAC2_FU_INPUT_GAIN_PAD 0x0c +#define UAC2_FU_PHASE_INVERTER 0x0d +#define UAC2_FU_UNDERFLOW 0x0e +#define UAC2_FU_OVERFLOW 0x0f +#define UAC2_FU_LATENCY 0x10 + +/* A.17.8.1 Parametric Equalizer Section Effect Unit Control Selectors */ +#define UAC2_PE_UNDEFINED 0x00 +#define UAC2_PE_ENABLE 0x01 +#define UAC2_PE_CENTERFREQ 0x02 +#define UAC2_PE_QFACTOR 0x03 +#define UAC2_PE_GAIN 0x04 +#define UAC2_PE_UNDERFLOW 0x05 +#define UAC2_PE_OVERFLOW 0x06 +#define UAC2_PE_LATENCY 0x07 + +/* A.17.8.2 Reverberation Effect Unit Control Selectors */ +#define UAC2_RV_UNDEFINED 0x00 +#define UAC2_RV_ENABLE 0x01 +#define UAC2_RV_TYPE 0x02 +#define UAC2_RV_LEVEL 0x03 +#define UAC2_RV_TIME 0x04 +#define UAC2_RV_FEEDBACK 0x05 +#define UAC2_RV_PREDELAY 0x06 +#define UAC2_RV_DENSITY 0x07 +#define UAC2_RV_HIFREQ_ROLLOFF 0x08 +#define UAC2_RV_UNDERFLOW 0x09 +#define UAC2_RV_OVERFLOW 0x0a +#define UAC2_RV_LATENCY 0x0b + +/* A.17.8.3 Modulation Delay Effect Control Selectors */ +#define UAC2_MD_UNDEFINED 0x00 +#define UAC2_MD_ENABLE 0x01 +#define UAC2_MD_BALANCE 0x02 +#define UAC2_MD_RATE 0x03 +#define UAC2_MD_DEPTH 0x04 +#define UAC2_MD_TIME 0x05 +#define UAC2_MD_FEEDBACK 0x06 +#define UAC2_MD_UNDERFLOW 0x07 +#define UAC2_MD_OVERFLOW 0x08 +#define UAC2_MD_LATENCY 0x09 + +/* A.17.8.4 Dynamic Range Compressor Effect Unit Control Selectors */ +#define UAC2_DR_UNDEFINED 0x00 +#define UAC2_DR_ENABLE 0x01 +#define UAC2_DR_COMPRESSION_RATE 0x02 +#define UAC2_DR_MAXAMPL 0x03 +#define UAC2_DR_THRESHOLD 0x04 +#define UAC2_DR_ATTACK_TIME 0x05 +#define UAC2_DR_RELEASE_TIME 0x06 +#define UAC2_DR_UNDEFLOW 0x07 +#define UAC2_DR_OVERFLOW 0x08 +#define UAC2_DR_LATENCY 0x09 + +/* A.17.9.1 Up/Down-mix Processing Unit Control Selectors */ +#define UAC2_UD_UNDEFINED 0x00 +#define UAC2_UD_ENABLE 0x01 +#define UAC2_UD_MODE_SELECT 0x02 +#define UAC2_UD_CLUSTER 0x03 +#define UAC2_UD_UNDERFLOW 0x04 +#define UAC2_UD_OVERFLOW 0x05 +#define UAC2_UD_LATENCY 0x06 + +/* A.17.9.2 Dolby Prologic[tm] Processing Unit Control Selectors */ +#define UAC2_DP_UNDEFINED 0x00 +#define UAC2_DP_ENABLE 0x01 +#define UAC2_DP_MODE_SELECT 0x02 +#define UAC2_DP_CLUSTER 0x03 +#define UAC2_DP_UNDERFFLOW 0x04 +#define UAC2_DP_OVERFLOW 0x05 +#define UAC2_DP_LATENCY 0x06 + +/* A.17.9.3 Stereo Expander Processing Unit Control Selectors */ +#define UAC2_ST_EXT_UNDEFINED 0x00 +#define UAC2_ST_EXT_ENABLE 0x01 +#define UAC2_ST_EXT_WIDTH 0x02 +#define UAC2_ST_EXT_UNDEFLOW 0x03 +#define UAC2_ST_EXT_OVERFLOW 0x04 +#define UAC2_ST_EXT_LATENCY 0x05 + +/* A.17.10 Extension Unit Control Selectors */ +#define UAC2_XU_UNDEFINED 0x00 +#define UAC2_XU_ENABLE 0x01 +#define UAC2_XU_CLUSTER 0x02 +#define UAC2_XU_UNDERFLOW 0x03 +#define UAC2_XU_OVERFLOW 0x04 +#define UAC2_XU_LATENCY 0x05 + +/* A.17.11 AudioStreaming Interface Control Selectors */ +#define UAC2_AS_UNDEFINED 0x00 +#define UAC2_AS_ACT_ALT_SETTING 0x01 +#define UAC2_AS_VAL_ALT_SETTINGS 0x02 +#define UAC2_AS_AUDIO_DATA_FORMAT 0x03 + +/* A.17.12 Encoder Control Selectors */ +#define UAC2_EN_UNDEFINED 0x00 +#define UAC2_EN_BIT_RATE 0x01 +#define UAC2_EN_QUALITY 0x02 +#define UAC2_EN_VBR 0x03 +#define UAC2_EN_TYPE 0x04 +#define UAC2_EN_UNDERFLOW 0x05 +#define UAC2_EN_OVERFLOW 0x06 +#define UAC2_EN_ENCODER_ERROR 0x07 +#define UAC2_EN_PARAM1 0x08 +#define UAC2_EN_PARAM2 0x09 +#define UAC2_EN_PARAM3 0x0a +#define UAC2_EN_PARAM4 0x0b +#define UAC2_EN_PARAM5 0x0c +#define UAC2_EN_PARAM6 0x0d +#define UAC2_EN_PARAM7 0x0e +#define UAC2_EN_PARAM8 0x0f + +/* A.17.13.1 MPEG Decoder Control Selectors */ +#define UAC2_MPEG_UNDEFINED 0x00 +#define UAC2_MPEG_DUAL_CHANNEL 0x01 +#define UAC2_MPEG_SECOND_STEREO 0x02 +#define UAC2_MPEG_MULTILINGUAL 0x03 +#define UAC2_MPEG_DYN_RANGE 0x04 +#define UAC2_MPEG_SCALING 0x05 +#define UAC2_MPEG_HILO_SCALING 0x06 +#define UAC2_MPEG_UNDERFLOW 0x07 +#define UAC2_MPEG_OVERFLOW 0x08 +#define UAC2_MPEG_DECODER_ERROR 0x09 + +/* A17.13.2 AC3 Decoder Control Selectors */ +#define UAC2_AC3_UNDEFINED 0x00 +#define UAC2_AC3_MODE 0x01 +#define UAC2_AC3_DYN_RANGE 0x02 +#define UAC2_AC3_SCALING 0x03 +#define UAC2_AC3_HILO_SCALING 0x04 +#define UAC2_AC3_UNDERFLOW 0x05 +#define UAC2_AC3_OVERFLOW 0x06 +#define UAC2_AC3_DECODER_ERROR 0x07 + +/* A17.13.3 WMA Decoder Control Selectors */ +#define UAC2_WMA_UNDEFINED 0x00 +#define UAC2_WMA_UNDERFLOW 0x01 +#define UAC2_WMA_OVERFLOW 0x02 +#define UAC2_WMA_DECODER_ERROR 0x03 + +/* A17.13.4 DTS Decoder Control Selectors */ +#define UAC2_DTS_UNDEFINED 0x00 +#define UAC2_DTS_UNDERFLOW 0x01 +#define UAC2_DTS_OVERFLOW 0x02 +#define UAC2_DTS_DECODER_ERROR 0x03 + +/* A17.14 Endpoint Control Selectors */ +#define UAC2_EP_CS_UNDEFINED 0x00 +#define UAC2_EP_CS_PITCH 0x01 +#define UAC2_EP_CS_DATA_OVERRUN 0x02 +#define UAC2_EP_CS_DATA_UNDERRUN 0x03 + +#endif /* __LINUX_USB_AUDIO_V2_H */ +include/linux/usb/audio.h +7
-43@@ -13,6 +13,9 @@* Comments below reference relevant sections of that document: * * http://www.usb.org/developers/devclass_docs/audio10.pdf +* +* Types and defines in this file are either specific to version 1.0 of +* this standard or common for newer versions. */ #ifndef __LINUX_USB_AUDIO_H@@ -20,14 +23,15 @@#include <linux/types.h> +/* bInterfaceProtocol values to denote the version of the standard used */ +#define UAC_VERSION_1 0x00 +#define UAC_VERSION_2 0x20 +/* A.2 Audio Interface Subclass Codes */ #define USB_SUBCLASS_AUDIOCONTROL 0x01#define USB_SUBCLASS_AUDIOSTREAMING 0x02#define USB_SUBCLASS_MIDISTREAMING 0x03 -#define UAC_VERSION_1 0x00 -#define UAC_VERSION_2 0x20 -/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ #define UAC_HEADER 0x01#define UAC_INPUT_TERMINAL 0x02@@ -38,15 +42,6 @@#define UAC_PROCESSING_UNIT_V1 0x07#define UAC_EXTENSION_UNIT_V1 0x08 -/* UAC v2.0 types */ -#define UAC_EFFECT_UNIT 0x07 -#define UAC_PROCESSING_UNIT_V2 0x08 -#define UAC_EXTENSION_UNIT_V2 0x09 -#define UAC_CLOCK_SOURCE 0x0a -#define UAC_CLOCK_SELECTOR 0x0b -#define UAC_CLOCK_MULTIPLIER 0x0c -#define UAC_SAMPLE_RATE_CONVERTER 0x0d -/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ #define UAC_AS_GENERAL 0x01#define UAC_FORMAT_TYPE 0x02@@ -78,10 +73,6 @@#define UAC_GET_STAT 0xff -/* Audio class v2.0 handles all the parameter calls differently */ -#define UAC2_CS_CUR 0x01 -#define UAC2_CS_RANGE 0x02 -/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ #define UAC_MS_HEADER 0x01#define UAC_MIDI_IN_JACK 0x02@@ -200,19 +191,6 @@ struct uac_as_header_descriptor_v1 {__le16 wFormatTag;/* The Audio Data Format */ } __attribute__ ((packed)); -struct uac_as_header_descriptor_v2 { -__u8 bLength; -__u8 bDescriptorType; -__u8 bDescriptorSubtype; -__u8 bTerminalLink; -__u8 bmControls; -__u8 bFormatType; -__u32 bmFormats; -__u8 bNrChannels; -__u32 bmChannelConfig; -__u8 iChannelNames; -} __attribute__((packed)); -#define UAC_DT_AS_HEADER_SIZE 7/* Formats - A.1.1 Audio Data Format Type I Codes */ @@ -277,7 +255,6 @@ struct uac_format_type_i_ext_descriptor {__u8 bSideBandProtocol; } __attribute__((packed)); -/* Formats - Audio Data Format Type I Codes */ #define UAC_FORMAT_TYPE_II_MPEG 0x1001@@ -336,19 +313,6 @@ struct uac_iso_endpoint_descriptor {#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02#define UAC_EP_CS_ATTR_FILL_MAX 0x80 -/* Audio class v2.0: CLOCK_SOURCE descriptor */ - -struct uac_clock_source_descriptor { -__u8 bLength; -__u8 bDescriptorType; -__u8 bDescriptorSubtype; -__u8 bClockID; -__u8 bmAttributes; -__u8 bmControls; -__u8 bAssocTerminal; -__u8 iClockSource; -} __attribute__((packed)); -/* A.10.2 Feature Unit Control Selectors */ struct uac_feature_unit_descriptor {sound/usb/card.c +2
-1@@ -45,6 +45,7 @@#include <linux/moduleparam.h> #include <linux/mutex.h> #include <linux/usb/audio.h> +#include <linux/usb/audio-v2.h> #include <sound/core.h> #include <sound/info.h> @@ -250,7 +251,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)* clock selectors and sample rate conversion units. */ cs =snd_usb_find_csint_desc (host_iface->extra, host_iface->extralen, -NULL ,UAC_CLOCK_SOURCE ); +NULL ,UAC2_CLOCK_SOURCE );if (!cs) {snd_printk (KERN_ERR "CLOCK_SOURCE descriptor not found\n" );sound/usb/endpoint.c +1
-0@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/usb.h> #include <linux/usb/audio.h> +#include <linux/usb/audio-v2.h> #include <sound/core.h> #include <sound/pcm.h> sound/usb/format.c +1
-0@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/usb.h> #include <linux/usb/audio.h> +#include <linux/usb/audio-v2.h> #include <sound/core.h> #include <sound/pcm.h> sound/usb/pcm.c +3
-2@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/usb.h> #include <linux/usb/audio.h> +#include <linux/usb/audio-v2.h> #include <sound/core.h> #include <sound/pcm.h> @@ -215,7 +216,7 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, data[3 ] = rate >>24 ;if ((err =snd_usb_ctl_msg (dev,usb_sndctrlpipe (dev,0 ),UAC2_CS_CUR ,USB_TYPE_CLASS |USB_RECIP_INTERFACE |USB_DIR_OUT , -0x0100 , chip->clock_id <<8 , +UAC2_CS_CONTROL_SAM_FREQ <<8 , chip->clock_id <<8 , data,sizeof (data),1000 )) <0 ) {snd_printk (KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n" , dev->devnum, iface, fmt->altsetting, rate);@@ -223,7 +224,7 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, }if ((err =snd_usb_ctl_msg (dev,usb_rcvctrlpipe (dev,0 ),UAC2_CS_CUR ,USB_TYPE_CLASS |USB_RECIP_INTERFACE |USB_DIR_IN , -0x0100 , chip->clock_id <<8 , +UAC2_CS_CONTROL_SAM_FREQ <<8 , chip->clock_id <<8 , data,sizeof (data),1000 )) <0 ) {snd_printk (KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n" , dev->devnum, iface, fmt->altsetting);Signature · 1 line
1.6.6.2
Greg KH
Acked-byRe: [PATCH 1/6] linux/usb/audio.h: split header
Quoted 7 lines · Daniel Mack
Quoted 6 lines · Daniel Mack
- Split the
audio.hfile in two to clearly denote the differences between the standards.
- Add many more defines toaudio-v2.h. Most of them are not currently used.
- Replaced a magic value with a proper define
Quoted 8 lines
Quoted 3 lines
Signed-off-by Daniel Mack <[email protected]>Cc Clemens Ladisch <[email protected]>Cc Takashi Iwai <[email protected]>Sorry Greg, I forgot to Cc: you on this.
As the patch touch both the include files and audio code, it would go thru the ALSA channel again if you don't mind.
No objection from me:
thanks,
greg k-h
At Thu, 11 Mar 2010 21:13:19 +0100,
Quoted 21 lines · Daniel Mack
This patch series adds support for mixer interfaces in USB audio class v2 devices. Successfully tested on a XMOS L1 eval kit. They apply on top of the topic/usb branch.
There's a number significant differences between v1 and v2 implementations, which the patches itself may explain best :)
I moved most quirks out into a seperate file, and hope you agree that it's cleaner that way. Most descriptors are now parsed with structs which makes the code more readable. However, there are quite some descriptors with variable field lengths so they can't be mapped into structs. I introduces some macros to access these fields.
Again, please test this with v1 devices, as I can't be entirely confident that I didn't break anything in the transition.
Thanks,
Daniel
Quoted 6 lines
[PATCH 1/6]
linux/usb/audio.h: split header
[PATCH 2/6] ALSA: usb-mixer: use defines fromaudio.h[PATCH 3/6] ALSA: usb-mixer: factor out quirks
[PATCH 4/6] ALSA: usb-mixer: rename usbmixer.[ch] -> mixer.[ch] [PATCH 5/6] ALSA: usb-mixer: parse descriptors with structs [PATCH 6/6] ALSA: usb-mixer: Add support for Audio Class v2.0
All applied now. Thanks!
Takashi