aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/core/pcm_native.c8
-rw-r--r--sound/core/sound.c4
-rw-r--r--sound/core/sound_oss.c2
-rw-r--r--sound/oss/coproc.h2
-rw-r--r--sound/oss/v_midi.h5
-rw-r--r--sound/pci/atiixp.c1
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c10
-rw-r--r--sound/pci/echoaudio/echoaudio.c4
-rw-r--r--sound/pci/hda/hda_intel.c25
-rw-r--r--sound/pci/hda/patch_realtek.c127
-rw-r--r--sound/pci/hda/patch_sigmatel.c61
-rw-r--r--sound/pci/riptide/riptide.c2
-rw-r--r--sound/soc/codecs/tlv320aic23.c2
-rw-r--r--sound/soc/codecs/wm8350.c2
-rw-r--r--sound/soc/codecs/wm8903.c3
-rw-r--r--sound/soc/omap/Makefile2
-rw-r--r--sound/soc/omap/omap3pandora.c1
-rw-r--r--sound/sound_core.c2
-rw-r--r--sound/usb/caiaq/midi.h2
-rw-r--r--sound/usb/usbaudio.c553
-rw-r--r--sound/usb/usbaudio.h90
-rw-r--r--sound/usb/usbmidi.c10
-rw-r--r--sound/usb/usbmixer.c112
-rw-r--r--sound/usb/usbquirks.h77
-rw-r--r--sound/usb/usx2y/us122l.c6
25 files changed, 747 insertions, 366 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 17935746eb1..87288762403 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -316,10 +316,10 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
316 if (!params->info) 316 if (!params->info)
317 params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES; 317 params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES;
318 if (!params->fifo_size) { 318 if (!params->fifo_size) {
319 if (snd_mask_min(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT]) == 319 m = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
320 snd_mask_max(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT]) && 320 i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
321 snd_mask_min(&params->masks[SNDRV_PCM_HW_PARAM_CHANNELS]) == 321 if (snd_mask_min(m) == snd_mask_max(m) &&
322 snd_mask_max(&params->masks[SNDRV_PCM_HW_PARAM_CHANNELS])) { 322 snd_interval_min(i) == snd_interval_max(i)) {
323 changed = substream->ops->ioctl(substream, 323 changed = substream->ops->ioctl(substream,
324 SNDRV_PCM_IOCTL1_FIFO_SIZE, params); 324 SNDRV_PCM_IOCTL1_FIFO_SIZE, params);
325 if (changed < 0) 325 if (changed < 0)
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 7872a02f6ca..563d1967a0a 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -468,5 +468,5 @@ static void __exit alsa_sound_exit(void)
468 unregister_chrdev(major, "alsa"); 468 unregister_chrdev(major, "alsa");
469} 469}
470 470
471module_init(alsa_sound_init) 471subsys_initcall(alsa_sound_init);
472module_exit(alsa_sound_exit) 472module_exit(alsa_sound_exit);
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c
index 7fe12264ff8..0c164e5e432 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -93,7 +93,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
93 default: 93 default:
94 return -EINVAL; 94 return -EINVAL;
95 } 95 }
96 if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OSS_MINORS)) 96 if (minor < 0 || minor >= SNDRV_OSS_MINORS)
97 return -EINVAL; 97 return -EINVAL;
98 return minor; 98 return minor;
99} 99}
diff --git a/sound/oss/coproc.h b/sound/oss/coproc.h
index 7306346e9ac..7bec21bbdd8 100644
--- a/sound/oss/coproc.h
+++ b/sound/oss/coproc.h
@@ -4,7 +4,7 @@
4 */ 4 */
5 5
6/* 6/*
7 * Coprocessor access types 7 * Coprocessor access types
8 */ 8 */
9#define COPR_CUSTOM 0x0001 /* Custom applications */ 9#define COPR_CUSTOM 0x0001 /* Custom applications */
10#define COPR_MIDI 0x0002 /* MIDI (MPU-401) emulation */ 10#define COPR_MIDI 0x0002 /* MIDI (MPU-401) emulation */
diff --git a/sound/oss/v_midi.h b/sound/oss/v_midi.h
index 1b86cb45c60..08e2185ee81 100644
--- a/sound/oss/v_midi.h
+++ b/sound/oss/v_midi.h
@@ -2,9 +2,9 @@ typedef struct vmidi_devc {
2 int dev; 2 int dev;
3 3
4 /* State variables */ 4 /* State variables */
5 int opened; 5 int opened;
6 spinlock_t lock; 6 spinlock_t lock;
7 7
8 /* MIDI fields */ 8 /* MIDI fields */
9 int my_mididev; 9 int my_mididev;
10 int pair_mididev; 10 int pair_mididev;
@@ -12,4 +12,3 @@ typedef struct vmidi_devc {
12 int intr_active; 12 int intr_active;
13 void (*midi_input_intr) (int dev, unsigned char data); 13 void (*midi_input_intr) (int dev, unsigned char data);
14 } vmidi_devc; 14 } vmidi_devc;
15
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 81e2bfc1125..49d572a7b23 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -297,6 +297,7 @@ static DEFINE_PCI_DEVICE_TABLE(snd_atiixp_ids) = {
297MODULE_DEVICE_TABLE(pci, snd_atiixp_ids); 297MODULE_DEVICE_TABLE(pci, snd_atiixp_ids);
298 298
299static struct snd_pci_quirk atiixp_quirks[] __devinitdata = { 299static struct snd_pci_quirk atiixp_quirks[] __devinitdata = {
300 SND_PCI_QUIRK(0x105b, 0x0c81, "Foxconn RC4107MA-RS2", 0),
300 SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0), 301 SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0),
301 { } /* terminator */ 302 { } /* terminator */
302}; 303};
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 56fcf00c0e2..3f99a5e8528 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -2238,11 +2238,11 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
2238 2238
2239 /* set the desired CODEC mode */ 2239 /* set the desired CODEC mode */
2240 if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) { 2240 if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) {
2241 snd_printdd("cs46xx: CODOEC1 mode %04x\n",0x0); 2241 snd_printdd("cs46xx: CODEC1 mode %04x\n", 0x0);
2242 snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x0); 2242 snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x0);
2243 } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) { 2243 } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) {
2244 snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3); 2244 snd_printdd("cs46xx: CODEC2 mode %04x\n", 0x3);
2245 snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3); 2245 snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x3);
2246 } else { 2246 } else {
2247 snd_BUG(); /* should never happen ... */ 2247 snd_BUG(); /* should never happen ... */
2248 } 2248 }
@@ -2266,7 +2266,7 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
2266 return; 2266 return;
2267 2267
2268 /* test if we can write to the record gain volume register */ 2268 /* test if we can write to the record gain volume register */
2269 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05); 2269 snd_ac97_write(ac97, AC97_REC_GAIN, 0x8a05);
2270 if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05) 2270 if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05)
2271 return; 2271 return;
2272 2272
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 2783ce6c236..8dab82d7d19 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -1864,7 +1864,9 @@ static irqreturn_t snd_echo_interrupt(int irq, void *dev_id)
1864 /* The hardware doesn't tell us which substream caused the irq, 1864 /* The hardware doesn't tell us which substream caused the irq,
1865 thus we have to check all running substreams. */ 1865 thus we have to check all running substreams. */
1866 for (ss = 0; ss < DSP_MAXPIPES; ss++) { 1866 for (ss = 0; ss < DSP_MAXPIPES; ss++) {
1867 if ((substream = chip->substream[ss])) { 1867 substream = chip->substream[ss];
1868 if (substream && ((struct audiopipe *)substream->runtime->
1869 private_data)->state == PIPE_STATE_STARTED) {
1868 period = pcm_pointer(substream) / 1870 period = pcm_pointer(substream) /
1869 substream->runtime->period_size; 1871 substream->runtime->period_size;
1870 if (period != chip->last_period[ss]) { 1872 if (period != chip->last_period[ss]) {
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index ac05bef7c2e..8d8e0b5aa24 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -426,6 +426,7 @@ struct azx {
426 426
427 /* flags */ 427 /* flags */
428 int position_fix; 428 int position_fix;
429 int poll_count;
429 unsigned int running :1; 430 unsigned int running :1;
430 unsigned int initialized :1; 431 unsigned int initialized :1;
431 unsigned int single_cmd :1; 432 unsigned int single_cmd :1;
@@ -506,7 +507,7 @@ static char *driver_short_names[] __devinitdata = {
506#define get_azx_dev(substream) (substream->runtime->private_data) 507#define get_azx_dev(substream) (substream->runtime->private_data)
507 508
508static int azx_acquire_irq(struct azx *chip, int do_disconnect); 509static int azx_acquire_irq(struct azx *chip, int do_disconnect);
509 510static int azx_send_cmd(struct hda_bus *bus, unsigned int val);
510/* 511/*
511 * Interface for HD codec 512 * Interface for HD codec
512 */ 513 */
@@ -664,11 +665,12 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
664{ 665{
665 struct azx *chip = bus->private_data; 666 struct azx *chip = bus->private_data;
666 unsigned long timeout; 667 unsigned long timeout;
668 int do_poll = 0;
667 669
668 again: 670 again:
669 timeout = jiffies + msecs_to_jiffies(1000); 671 timeout = jiffies + msecs_to_jiffies(1000);
670 for (;;) { 672 for (;;) {
671 if (chip->polling_mode) { 673 if (chip->polling_mode || do_poll) {
672 spin_lock_irq(&chip->reg_lock); 674 spin_lock_irq(&chip->reg_lock);
673 azx_update_rirb(chip); 675 azx_update_rirb(chip);
674 spin_unlock_irq(&chip->reg_lock); 676 spin_unlock_irq(&chip->reg_lock);
@@ -676,6 +678,9 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
676 if (!chip->rirb.cmds[addr]) { 678 if (!chip->rirb.cmds[addr]) {
677 smp_rmb(); 679 smp_rmb();
678 bus->rirb_error = 0; 680 bus->rirb_error = 0;
681
682 if (!do_poll)
683 chip->poll_count = 0;
679 return chip->rirb.res[addr]; /* the last value */ 684 return chip->rirb.res[addr]; /* the last value */
680 } 685 }
681 if (time_after(jiffies, timeout)) 686 if (time_after(jiffies, timeout))
@@ -688,6 +693,16 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
688 } 693 }
689 } 694 }
690 695
696 if (!chip->polling_mode && chip->poll_count < 2) {
697 snd_printdd(SFX "azx_get_response timeout, "
698 "polling the codec once: last cmd=0x%08x\n",
699 chip->last_cmd[addr]);
700 do_poll = 1;
701 chip->poll_count++;
702 goto again;
703 }
704
705
691 if (!chip->polling_mode) { 706 if (!chip->polling_mode) {
692 snd_printk(KERN_WARNING SFX "azx_get_response timeout, " 707 snd_printk(KERN_WARNING SFX "azx_get_response timeout, "
693 "switching to polling mode: last cmd=0x%08x\n", 708 "switching to polling mode: last cmd=0x%08x\n",
@@ -1878,6 +1893,9 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
1878 1893
1879 if (!bdl_pos_adj[chip->dev_index]) 1894 if (!bdl_pos_adj[chip->dev_index])
1880 return 1; /* no delayed ack */ 1895 return 1; /* no delayed ack */
1896 if (WARN_ONCE(!azx_dev->period_bytes,
1897 "hda-intel: zero azx_dev->period_bytes"))
1898 return 0; /* this shouldn't happen! */
1881 if (pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) 1899 if (pos % azx_dev->period_bytes > azx_dev->period_bytes / 2)
1882 return 0; /* NG - it's below the period boundary */ 1900 return 0; /* NG - it's below the period boundary */
1883 return 1; /* OK, it's fine */ 1901 return 1; /* OK, it's fine */
@@ -2043,7 +2061,7 @@ static int azx_acquire_irq(struct azx *chip, int do_disconnect)
2043{ 2061{
2044 if (request_irq(chip->pci->irq, azx_interrupt, 2062 if (request_irq(chip->pci->irq, azx_interrupt,
2045 chip->msi ? 0 : IRQF_SHARED, 2063 chip->msi ? 0 : IRQF_SHARED,
2046 "HDA Intel", chip)) { 2064 "hda_intel", chip)) {
2047 printk(KERN_ERR "hda-intel: unable to grab IRQ %d, " 2065 printk(KERN_ERR "hda-intel: unable to grab IRQ %d, "
2048 "disabling device\n", chip->pci->irq); 2066 "disabling device\n", chip->pci->irq);
2049 if (do_disconnect) 2067 if (do_disconnect)
@@ -2332,6 +2350,7 @@ static void __devinit check_probe_mask(struct azx *chip, int dev)
2332 */ 2350 */
2333static struct snd_pci_quirk msi_black_list[] __devinitdata = { 2351static struct snd_pci_quirk msi_black_list[] __devinitdata = {
2334 SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ 2352 SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */
2353 SND_PCI_QUIRK(0x1043, 0x829c, "ASUS", 0), /* nvidia */
2335 {} 2354 {}
2336}; 2355};
2337 2356
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 141ff446104..f628c33d80b 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1097,6 +1097,16 @@ static void alc889_coef_init(struct hda_codec *codec)
1097 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); 1097 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1098} 1098}
1099 1099
1100/* turn on/off EAPD control (only if available) */
1101static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1102{
1103 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1104 return;
1105 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1106 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1107 on ? 2 : 0);
1108}
1109
1100static void alc_auto_init_amp(struct hda_codec *codec, int type) 1110static void alc_auto_init_amp(struct hda_codec *codec, int type)
1101{ 1111{
1102 unsigned int tmp; 1112 unsigned int tmp;
@@ -1114,25 +1124,22 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
1114 case ALC_INIT_DEFAULT: 1124 case ALC_INIT_DEFAULT:
1115 switch (codec->vendor_id) { 1125 switch (codec->vendor_id) {
1116 case 0x10ec0260: 1126 case 0x10ec0260:
1117 snd_hda_codec_write(codec, 0x0f, 0, 1127 set_eapd(codec, 0x0f, 1);
1118 AC_VERB_SET_EAPD_BTLENABLE, 2); 1128 set_eapd(codec, 0x10, 1);
1119 snd_hda_codec_write(codec, 0x10, 0,
1120 AC_VERB_SET_EAPD_BTLENABLE, 2);
1121 break; 1129 break;
1122 case 0x10ec0262: 1130 case 0x10ec0262:
1123 case 0x10ec0267: 1131 case 0x10ec0267:
1124 case 0x10ec0268: 1132 case 0x10ec0268:
1125 case 0x10ec0269: 1133 case 0x10ec0269:
1134 case 0x10ec0270:
1126 case 0x10ec0272: 1135 case 0x10ec0272:
1127 case 0x10ec0660: 1136 case 0x10ec0660:
1128 case 0x10ec0662: 1137 case 0x10ec0662:
1129 case 0x10ec0663: 1138 case 0x10ec0663:
1130 case 0x10ec0862: 1139 case 0x10ec0862:
1131 case 0x10ec0889: 1140 case 0x10ec0889:
1132 snd_hda_codec_write(codec, 0x14, 0, 1141 set_eapd(codec, 0x14, 1);
1133 AC_VERB_SET_EAPD_BTLENABLE, 2); 1142 set_eapd(codec, 0x15, 1);
1134 snd_hda_codec_write(codec, 0x15, 0,
1135 AC_VERB_SET_EAPD_BTLENABLE, 2);
1136 break; 1143 break;
1137 } 1144 }
1138 switch (codec->vendor_id) { 1145 switch (codec->vendor_id) {
@@ -1234,6 +1241,8 @@ static void alc_init_auto_mic(struct hda_codec *codec)
1234 return; /* invalid entry */ 1241 return; /* invalid entry */
1235 } 1242 }
1236 } 1243 }
1244 if (!ext || !fixed)
1245 return;
1237 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) 1246 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1238 return; /* no unsol support */ 1247 return; /* no unsol support */
1239 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n", 1248 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
@@ -4917,6 +4926,49 @@ static void fixup_automic_adc(struct hda_codec *codec)
4917 spec->auto_mic = 0; /* disable auto-mic to be sure */ 4926 spec->auto_mic = 0; /* disable auto-mic to be sure */
4918} 4927}
4919 4928
4929/* choose the ADC/MUX containing the input pin and initialize the setup */
4930static void fixup_single_adc(struct hda_codec *codec)
4931{
4932 struct alc_spec *spec = codec->spec;
4933 hda_nid_t pin;
4934 int i;
4935
4936 /* search for the input pin; there must be only one */
4937 for (i = 0; i < AUTO_PIN_LAST; i++) {
4938 if (spec->autocfg.input_pins[i]) {
4939 pin = spec->autocfg.input_pins[i];
4940 break;
4941 }
4942 }
4943 if (!pin)
4944 return;
4945
4946 /* set the default connection to that pin */
4947 for (i = 0; i < spec->num_adc_nids; i++) {
4948 hda_nid_t cap = spec->capsrc_nids ?
4949 spec->capsrc_nids[i] : spec->adc_nids[i];
4950 int idx;
4951
4952 idx = get_connection_index(codec, cap, pin);
4953 if (idx < 0)
4954 continue;
4955 /* use only this ADC */
4956 if (spec->capsrc_nids)
4957 spec->capsrc_nids += i;
4958 spec->adc_nids += i;
4959 spec->num_adc_nids = 1;
4960 /* select or unmute this route */
4961 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4962 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4963 HDA_AMP_MUTE, 0);
4964 } else {
4965 snd_hda_codec_write_cache(codec, cap, 0,
4966 AC_VERB_SET_CONNECT_SEL, idx);
4967 }
4968 return;
4969 }
4970}
4971
4920static void set_capture_mixer(struct hda_codec *codec) 4972static void set_capture_mixer(struct hda_codec *codec)
4921{ 4973{
4922 struct alc_spec *spec = codec->spec; 4974 struct alc_spec *spec = codec->spec;
@@ -4929,14 +4981,15 @@ static void set_capture_mixer(struct hda_codec *codec)
4929 alc_capture_mixer3 }, 4981 alc_capture_mixer3 },
4930 }; 4982 };
4931 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { 4983 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4932 int mux; 4984 int mux = 0;
4933 if (spec->auto_mic) { 4985 if (spec->auto_mic)
4934 mux = 0;
4935 fixup_automic_adc(codec); 4986 fixup_automic_adc(codec);
4936 } else if (spec->input_mux && spec->input_mux->num_items > 1) 4987 else if (spec->input_mux) {
4937 mux = 1; 4988 if (spec->input_mux->num_items > 1)
4938 else 4989 mux = 1;
4939 mux = 0; 4990 else if (spec->input_mux->num_items == 1)
4991 fixup_single_adc(codec);
4992 }
4940 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1]; 4993 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4941 } 4994 }
4942} 4995}
@@ -7201,8 +7254,8 @@ static struct snd_kcontrol_new alc885_mb5_mixer[] = {
7201 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT), 7254 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7202 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT), 7255 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7203 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT), 7256 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7204 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT), 7257 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7205 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT), 7258 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7206 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7207 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7260 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 7261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
@@ -7603,6 +7656,7 @@ static struct hda_verb alc885_mb5_init_verbs[] = {
7603 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 7656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7604 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 7657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7605 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03}, 7658 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7659 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7606 /* Front Mic pin: input vref at 80% */ 7660 /* Front Mic pin: input vref at 80% */
7607 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 7661 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7662 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
@@ -7787,6 +7841,27 @@ static void alc885_mbp3_setup(struct hda_codec *codec)
7787 spec->autocfg.speaker_pins[0] = 0x14; 7841 spec->autocfg.speaker_pins[0] = 0x14;
7788} 7842}
7789 7843
7844static void alc885_mb5_automute(struct hda_codec *codec)
7845{
7846 unsigned int present;
7847
7848 present = snd_hda_codec_read(codec, 0x14, 0,
7849 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7850 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
7851 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7852 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7853 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7854
7855}
7856
7857static void alc885_mb5_unsol_event(struct hda_codec *codec,
7858 unsigned int res)
7859{
7860 /* Headphone insertion or removal. */
7861 if ((res >> 26) == ALC880_HP_EVENT)
7862 alc885_mb5_automute(codec);
7863}
7864
7790static void alc885_imac91_automute(struct hda_codec *codec) 7865static void alc885_imac91_automute(struct hda_codec *codec)
7791{ 7866{
7792 unsigned int present; 7867 unsigned int present;
@@ -9233,6 +9308,8 @@ static struct alc_config_preset alc882_presets[] = {
9233 .input_mux = &mb5_capture_source, 9308 .input_mux = &mb5_capture_source,
9234 .dig_out_nid = ALC882_DIGOUT_NID, 9309 .dig_out_nid = ALC882_DIGOUT_NID,
9235 .dig_in_nid = ALC882_DIGIN_NID, 9310 .dig_in_nid = ALC882_DIGIN_NID,
9311 .unsol_event = alc885_mb5_unsol_event,
9312 .init_hook = alc885_mb5_automute,
9236 }, 9313 },
9237 [ALC885_MACPRO] = { 9314 [ALC885_MACPRO] = {
9238 .mixers = { alc882_macpro_mixer }, 9315 .mixers = { alc882_macpro_mixer },
@@ -9510,6 +9587,7 @@ static struct alc_config_preset alc882_presets[] = {
9510 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 9587 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9511 .channel_mode = alc883_3ST_6ch_modes, 9588 .channel_mode = alc883_3ST_6ch_modes,
9512 .need_dac_fix = 1, 9589 .need_dac_fix = 1,
9590 .const_channel_count = 6,
9513 .num_mux_defs = 9591 .num_mux_defs =
9514 ARRAY_SIZE(alc888_2_capture_sources), 9592 ARRAY_SIZE(alc888_2_capture_sources),
9515 .input_mux = alc888_2_capture_sources, 9593 .input_mux = alc888_2_capture_sources,
@@ -10420,7 +10498,7 @@ static void alc262_hp_t5735_setup(struct hda_codec *codec)
10420 struct alc_spec *spec = codec->spec; 10498 struct alc_spec *spec = codec->spec;
10421 10499
10422 spec->autocfg.hp_pins[0] = 0x15; 10500 spec->autocfg.hp_pins[0] = 0x15;
10423 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ 10501 spec->autocfg.speaker_pins[0] = 0x14;
10424} 10502}
10425 10503
10426static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { 10504static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
@@ -11310,7 +11388,7 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11310} 11388}
11311 11389
11312#define alc262_auto_create_input_ctls \ 11390#define alc262_auto_create_input_ctls \
11313 alc880_auto_create_input_ctls 11391 alc882_auto_create_input_ctls
11314 11392
11315/* 11393/*
11316 * generic initialization of ADC, input mixers and output mixers 11394 * generic initialization of ADC, input mixers and output mixers
@@ -11849,9 +11927,9 @@ static struct alc_config_preset alc262_presets[] = {
11849 .num_channel_mode = ARRAY_SIZE(alc262_modes), 11927 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11850 .channel_mode = alc262_modes, 11928 .channel_mode = alc262_modes,
11851 .input_mux = &alc262_capture_source, 11929 .input_mux = &alc262_capture_source,
11852 .unsol_event = alc_automute_amp_unsol_event, 11930 .unsol_event = alc_sku_unsol_event,
11853 .setup = alc262_hp_t5735_setup, 11931 .setup = alc262_hp_t5735_setup,
11854 .init_hook = alc_automute_amp, 11932 .init_hook = alc_inithook,
11855 }, 11933 },
11856 [ALC262_HP_RP5700] = { 11934 [ALC262_HP_RP5700] = {
11857 .mixers = { alc262_hp_rp5700_mixer }, 11935 .mixers = { alc262_hp_rp5700_mixer },
@@ -12605,6 +12683,7 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12605 dac = 0x02; 12683 dac = 0x02;
12606 break; 12684 break;
12607 case 0x15: 12685 case 0x15:
12686 case 0x21:
12608 dac = 0x03; 12687 dac = 0x03;
12609 break; 12688 break;
12610 default: 12689 default:
@@ -14991,6 +15070,8 @@ static int patch_alc861(struct hda_codec *codec)
14991 spec->stream_digital_playback = &alc861_pcm_digital_playback; 15070 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14992 spec->stream_digital_capture = &alc861_pcm_digital_capture; 15071 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14993 15072
15073 if (!spec->cap_mixer)
15074 set_capture_mixer(codec);
14994 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); 15075 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14995 15076
14996 spec->vmaster_nid = 0x03; 15077 spec->vmaster_nid = 0x03;
@@ -15633,7 +15714,7 @@ static struct alc_config_preset alc861vd_presets[] = {
15633static int alc861vd_auto_create_input_ctls(struct hda_codec *codec, 15714static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15634 const struct auto_pin_cfg *cfg) 15715 const struct auto_pin_cfg *cfg)
15635{ 15716{
15636 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0); 15717 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
15637} 15718}
15638 15719
15639 15720
@@ -17391,7 +17472,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
17391 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), 17472 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
17392 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", 17473 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17393 ALC662_3ST_6ch_DIG), 17474 ALC662_3ST_6ch_DIG),
17394 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4), 17475 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
17395 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10), 17476 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
17396 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", 17477 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17397 ALC662_3ST_6ch_DIG), 17478 ALC662_3ST_6ch_DIG),
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 117919aa17f..dbffb5b5c69 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -4737,6 +4737,26 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4737 } 4737 }
4738} 4738}
4739 4739
4740static int hp_blike_system(u32 subsystem_id);
4741
4742static void set_hp_led_gpio(struct hda_codec *codec)
4743{
4744 struct sigmatel_spec *spec = codec->spec;
4745 switch (codec->vendor_id) {
4746 case 0x111d7608:
4747 /* GPIO 0 */
4748 spec->gpio_led = 0x01;
4749 break;
4750 case 0x111d7600:
4751 case 0x111d7601:
4752 case 0x111d7602:
4753 case 0x111d7603:
4754 /* GPIO 3 */
4755 spec->gpio_led = 0x08;
4756 break;
4757 }
4758}
4759
4740/* 4760/*
4741 * This method searches for the mute LED GPIO configuration 4761 * This method searches for the mute LED GPIO configuration
4742 * provided as OEM string in SMBIOS. The format of that string 4762 * provided as OEM string in SMBIOS. The format of that string
@@ -4748,6 +4768,14 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4748 * 4768 *
4749 * So, HP B-series like systems may have HP_Mute_LED_0 (current models) 4769 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4750 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings 4770 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
4771 *
4772 *
4773 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4774 * SMBIOS - at least the ones I have seen do not have them - which include
4775 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4776 * HP Pavilion dv9500t CTO.
4777 * Need more information on whether it is true across the entire series.
4778 * -- kunal
4751 */ 4779 */
4752static int find_mute_led_gpio(struct hda_codec *codec) 4780static int find_mute_led_gpio(struct hda_codec *codec)
4753{ 4781{
@@ -4758,28 +4786,27 @@ static int find_mute_led_gpio(struct hda_codec *codec)
4758 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, 4786 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4759 NULL, dev))) { 4787 NULL, dev))) {
4760 if (sscanf(dev->name, "HP_Mute_LED_%d_%d", 4788 if (sscanf(dev->name, "HP_Mute_LED_%d_%d",
4761 &spec->gpio_led_polarity, 4789 &spec->gpio_led_polarity,
4762 &spec->gpio_led) == 2) { 4790 &spec->gpio_led) == 2) {
4763 spec->gpio_led = 1 << spec->gpio_led; 4791 spec->gpio_led = 1 << spec->gpio_led;
4764 return 1; 4792 return 1;
4765 } 4793 }
4766 if (sscanf(dev->name, "HP_Mute_LED_%d", 4794 if (sscanf(dev->name, "HP_Mute_LED_%d",
4767 &spec->gpio_led_polarity) == 1) { 4795 &spec->gpio_led_polarity) == 1) {
4768 switch (codec->vendor_id) { 4796 set_hp_led_gpio(codec);
4769 case 0x111d7608: 4797 return 1;
4770 /* GPIO 0 */
4771 spec->gpio_led = 0x01;
4772 return 1;
4773 case 0x111d7600:
4774 case 0x111d7601:
4775 case 0x111d7602:
4776 case 0x111d7603:
4777 /* GPIO 3 */
4778 spec->gpio_led = 0x08;
4779 return 1;
4780 }
4781 } 4798 }
4782 } 4799 }
4800
4801 /*
4802 * Fallback case - if we don't find the DMI strings,
4803 * we statically set the GPIO - if not a B-series system.
4804 */
4805 if (!hp_blike_system(codec->subsystem_id)) {
4806 set_hp_led_gpio(codec);
4807 spec->gpio_led_polarity = 1;
4808 return 1;
4809 }
4783 } 4810 }
4784 return 0; 4811 return 0;
4785} 4812}
@@ -5603,6 +5630,8 @@ again:
5603 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); 5630 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5604 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); 5631 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5605 5632
5633 snd_printdd("Found board config: %d\n", spec->board_config);
5634
5606 switch (spec->board_config) { 5635 switch (spec->board_config) {
5607 case STAC_HP_M4: 5636 case STAC_HP_M4:
5608 /* enable internal microphone */ 5637 /* enable internal microphone */
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index bb08a2855fc..960a227eb65 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1058,7 +1058,7 @@ setsamplerate(struct cmdif *cif, unsigned char *intdec, unsigned int rate)
1058 rptr.retwords[2] != M && 1058 rptr.retwords[2] != M &&
1059 rptr.retwords[3] != N && 1059 rptr.retwords[3] != N &&
1060 i++ < MAX_WRITE_RETRY); 1060 i++ < MAX_WRITE_RETRY);
1061 if (i == MAX_WRITE_RETRY) { 1061 if (i > MAX_WRITE_RETRY) {
1062 snd_printdd("sent samplerate %d: %d failed\n", 1062 snd_printdd("sent samplerate %d: %d failed\n",
1063 *intdec, rate); 1063 *intdec, rate);
1064 return -EIO; 1064 return -EIO;
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
index a9dc5fb5477..da589d8664d 100644
--- a/sound/soc/codecs/tlv320aic23.c
+++ b/sound/soc/codecs/tlv320aic23.c
@@ -627,7 +627,7 @@ static int tlv320aic23_resume(struct platform_device *pdev)
627 u16 reg; 627 u16 reg;
628 628
629 /* Sync reg_cache with the hardware */ 629 /* Sync reg_cache with the hardware */
630 for (reg = 0; reg < TLV320AIC23_RESET; reg++) { 630 for (reg = 0; reg <= TLV320AIC23_ACTIVE; reg++) {
631 u16 val = tlv320aic23_read_reg_cache(codec, reg); 631 u16 val = tlv320aic23_read_reg_cache(codec, reg);
632 tlv320aic23_write(codec, reg, val); 632 tlv320aic23_write(codec, reg, val);
633 } 633 }
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index ebbf11b653a..718ef912e75 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -925,7 +925,7 @@ static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
925 iface |= 0x3 << 8; 925 iface |= 0x3 << 8;
926 break; 926 break;
927 case SND_SOC_DAIFMT_DSP_B: 927 case SND_SOC_DAIFMT_DSP_B:
928 iface |= 0x3 << 8; /* lg not sure which mode */ 928 iface |= 0x3 << 8 | WM8350_AIF_LRCLK_INV;
929 break; 929 break;
930 default: 930 default:
931 return -EINVAL; 931 return -EINVAL;
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index ce5515e3f2b..3595bd57c4e 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -1504,7 +1504,7 @@ static int wm8903_resume(struct platform_device *pdev)
1504 struct i2c_client *i2c = codec->control_data; 1504 struct i2c_client *i2c = codec->control_data;
1505 int i; 1505 int i;
1506 u16 *reg_cache = codec->reg_cache; 1506 u16 *reg_cache = codec->reg_cache;
1507 u16 *tmp_cache = kmemdup(codec->reg_cache, sizeof(wm8903_reg_defaults), 1507 u16 *tmp_cache = kmemdup(reg_cache, sizeof(wm8903_reg_defaults),
1508 GFP_KERNEL); 1508 GFP_KERNEL);
1509 1509
1510 /* Bring the codec back up to standby first to minimise pop/clicks */ 1510 /* Bring the codec back up to standby first to minimise pop/clicks */
@@ -1516,6 +1516,7 @@ static int wm8903_resume(struct platform_device *pdev)
1516 for (i = 2; i < ARRAY_SIZE(wm8903_reg_defaults); i++) 1516 for (i = 2; i < ARRAY_SIZE(wm8903_reg_defaults); i++)
1517 if (tmp_cache[i] != reg_cache[i]) 1517 if (tmp_cache[i] != reg_cache[i])
1518 snd_soc_write(codec, i, tmp_cache[i]); 1518 snd_soc_write(codec, i, tmp_cache[i]);
1519 kfree(tmp_cache);
1519 } else { 1520 } else {
1520 dev_err(&i2c->dev, "Failed to allocate temporary cache\n"); 1521 dev_err(&i2c->dev, "Failed to allocate temporary cache\n");
1521 } 1522 }
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile
index 3db8a6c523f..19283e5edfb 100644
--- a/sound/soc/omap/Makefile
+++ b/sound/soc/omap/Makefile
@@ -25,7 +25,7 @@ obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o
25obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o 25obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o
26obj-$(CONFIG_SND_OMAP_SOC_OMAP2EVM) += snd-soc-omap2evm.o 26obj-$(CONFIG_SND_OMAP_SOC_OMAP2EVM) += snd-soc-omap2evm.o
27obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o 27obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o
28obj-$(CONFIG_SND_OMAP_SOC_OMAP3517EVM) += snd-soc-am3517evm.o 28obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o
29obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o 29obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o
30obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o 30obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o
31obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o 31obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c
index 71b2c161158..68980c19a3b 100644
--- a/sound/soc/omap/omap3pandora.c
+++ b/sound/soc/omap/omap3pandora.c
@@ -145,6 +145,7 @@ static const struct snd_soc_dapm_widget omap3pandora_in_dapm_widgets[] = {
145}; 145};
146 146
147static const struct snd_soc_dapm_route omap3pandora_out_map[] = { 147static const struct snd_soc_dapm_route omap3pandora_out_map[] = {
148 {"PCM DAC", NULL, "APLL Enable"},
148 {"Headphone Amplifier", NULL, "PCM DAC"}, 149 {"Headphone Amplifier", NULL, "PCM DAC"},
149 {"Line Out", NULL, "PCM DAC"}, 150 {"Line Out", NULL, "PCM DAC"},
150 {"Headphone Jack", NULL, "Headphone Amplifier"}, 151 {"Headphone Jack", NULL, "Headphone Amplifier"},
diff --git a/sound/sound_core.c b/sound/sound_core.c
index dbca7c909a3..7c2d677a2df 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -61,7 +61,7 @@ static void __exit cleanup_soundcore(void)
61 class_destroy(sound_class); 61 class_destroy(sound_class);
62} 62}
63 63
64module_init(init_soundcore); 64subsys_initcall(init_soundcore);
65module_exit(cleanup_soundcore); 65module_exit(cleanup_soundcore);
66 66
67 67
diff --git a/sound/usb/caiaq/midi.h b/sound/usb/caiaq/midi.h
index 9d16db027fc..380f984babc 100644
--- a/sound/usb/caiaq/midi.h
+++ b/sound/usb/caiaq/midi.h
@@ -3,6 +3,6 @@
3 3
4int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *dev); 4int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *dev);
5void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, int port, const char *buf, int len); 5void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, int port, const char *buf, int len);
6void snd_usb_caiaq_midi_output_done(struct urb* urb); 6void snd_usb_caiaq_midi_output_done(struct urb *urb);
7 7
8#endif /* CAIAQ_MIDI_H */ 8#endif /* CAIAQ_MIDI_H */
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 7ad8089b233..20b656e9f90 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -46,6 +46,9 @@
46#include <linux/usb.h> 46#include <linux/usb.h>
47#include <linux/moduleparam.h> 47#include <linux/moduleparam.h>
48#include <linux/mutex.h> 48#include <linux/mutex.h>
49#include <linux/usb/audio.h>
50#include <linux/usb/ch9.h>
51
49#include <sound/core.h> 52#include <sound/core.h>
50#include <sound/info.h> 53#include <sound/info.h>
51#include <sound/pcm.h> 54#include <sound/pcm.h>
@@ -596,7 +599,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,
596 if (subs->transfer_done >= runtime->period_size) { 599 if (subs->transfer_done >= runtime->period_size) {
597 subs->transfer_done -= runtime->period_size; 600 subs->transfer_done -= runtime->period_size;
598 period_elapsed = 1; 601 period_elapsed = 1;
599 if (subs->fmt_type == USB_FORMAT_TYPE_II) { 602 if (subs->fmt_type == UAC_FORMAT_TYPE_II) {
600 if (subs->transfer_done > 0) { 603 if (subs->transfer_done > 0) {
601 /* FIXME: fill-max mode is not 604 /* FIXME: fill-max mode is not
602 * supported yet */ 605 * supported yet */
@@ -1104,7 +1107,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1104 u->packets = (i + 1) * total_packs / subs->nurbs 1107 u->packets = (i + 1) * total_packs / subs->nurbs
1105 - i * total_packs / subs->nurbs; 1108 - i * total_packs / subs->nurbs;
1106 u->buffer_size = maxsize * u->packets; 1109 u->buffer_size = maxsize * u->packets;
1107 if (subs->fmt_type == USB_FORMAT_TYPE_II) 1110 if (subs->fmt_type == UAC_FORMAT_TYPE_II)
1108 u->packets++; /* for transfer delimiter */ 1111 u->packets++; /* for transfer delimiter */
1109 u->urb = usb_alloc_urb(u->packets, GFP_KERNEL); 1112 u->urb = usb_alloc_urb(u->packets, GFP_KERNEL);
1110 if (!u->urb) 1113 if (!u->urb)
@@ -1180,7 +1183,7 @@ static struct audioformat *find_format(struct snd_usb_substream *subs, unsigned
1180 if (i >= fp->nr_rates) 1183 if (i >= fp->nr_rates)
1181 continue; 1184 continue;
1182 } 1185 }
1183 attr = fp->ep_attr & EP_ATTR_MASK; 1186 attr = fp->ep_attr & USB_ENDPOINT_SYNCTYPE;
1184 if (! found) { 1187 if (! found) {
1185 found = fp; 1188 found = fp;
1186 cur_attr = attr; 1189 cur_attr = attr;
@@ -1192,14 +1195,14 @@ static struct audioformat *find_format(struct snd_usb_substream *subs, unsigned
1192 * M-audio audiophile USB. 1195 * M-audio audiophile USB.
1193 */ 1196 */
1194 if (attr != cur_attr) { 1197 if (attr != cur_attr) {
1195 if ((attr == EP_ATTR_ASYNC && 1198 if ((attr == USB_ENDPOINT_SYNC_ASYNC &&
1196 subs->direction == SNDRV_PCM_STREAM_PLAYBACK) || 1199 subs->direction == SNDRV_PCM_STREAM_PLAYBACK) ||
1197 (attr == EP_ATTR_ADAPTIVE && 1200 (attr == USB_ENDPOINT_SYNC_ADAPTIVE &&
1198 subs->direction == SNDRV_PCM_STREAM_CAPTURE)) 1201 subs->direction == SNDRV_PCM_STREAM_CAPTURE))
1199 continue; 1202 continue;
1200 if ((cur_attr == EP_ATTR_ASYNC && 1203 if ((cur_attr == USB_ENDPOINT_SYNC_ASYNC &&
1201 subs->direction == SNDRV_PCM_STREAM_PLAYBACK) || 1204 subs->direction == SNDRV_PCM_STREAM_PLAYBACK) ||
1202 (cur_attr == EP_ATTR_ADAPTIVE && 1205 (cur_attr == USB_ENDPOINT_SYNC_ADAPTIVE &&
1203 subs->direction == SNDRV_PCM_STREAM_CAPTURE)) { 1206 subs->direction == SNDRV_PCM_STREAM_CAPTURE)) {
1204 found = fp; 1207 found = fp;
1205 cur_attr = attr; 1208 cur_attr = attr;
@@ -1229,11 +1232,11 @@ static int init_usb_pitch(struct usb_device *dev, int iface,
1229 1232
1230 ep = get_endpoint(alts, 0)->bEndpointAddress; 1233 ep = get_endpoint(alts, 0)->bEndpointAddress;
1231 /* if endpoint has pitch control, enable it */ 1234 /* if endpoint has pitch control, enable it */
1232 if (fmt->attributes & EP_CS_ATTR_PITCH_CONTROL) { 1235 if (fmt->attributes & UAC_EP_CS_ATTR_PITCH_CONTROL) {
1233 data[0] = 1; 1236 data[0] = 1;
1234 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 1237 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
1235 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 1238 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
1236 PITCH_CONTROL << 8, ep, data, 1, 1000)) < 0) { 1239 UAC_EP_CS_ATTR_PITCH_CONTROL << 8, ep, data, 1, 1000)) < 0) {
1237 snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n", 1240 snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n",
1238 dev->devnum, iface, ep); 1241 dev->devnum, iface, ep);
1239 return err; 1242 return err;
@@ -1252,21 +1255,21 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface,
1252 1255
1253 ep = get_endpoint(alts, 0)->bEndpointAddress; 1256 ep = get_endpoint(alts, 0)->bEndpointAddress;
1254 /* if endpoint has sampling rate control, set it */ 1257 /* if endpoint has sampling rate control, set it */
1255 if (fmt->attributes & EP_CS_ATTR_SAMPLE_RATE) { 1258 if (fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE) {
1256 int crate; 1259 int crate;
1257 data[0] = rate; 1260 data[0] = rate;
1258 data[1] = rate >> 8; 1261 data[1] = rate >> 8;
1259 data[2] = rate >> 16; 1262 data[2] = rate >> 16;
1260 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 1263 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
1261 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 1264 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
1262 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1265 UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000)) < 0) {
1263 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n", 1266 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
1264 dev->devnum, iface, fmt->altsetting, rate, ep); 1267 dev->devnum, iface, fmt->altsetting, rate, ep);
1265 return err; 1268 return err;
1266 } 1269 }
1267 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, 1270 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,
1268 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, 1271 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
1269 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1272 UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000)) < 0) {
1270 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n", 1273 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
1271 dev->devnum, iface, fmt->altsetting, ep); 1274 dev->devnum, iface, fmt->altsetting, ep);
1272 return 0; /* some devices don't support reading */ 1275 return 0; /* some devices don't support reading */
@@ -1384,9 +1387,9 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1384 * descriptors which fool us. if it has only one EP, 1387 * descriptors which fool us. if it has only one EP,
1385 * assume it as adaptive-out or sync-in. 1388 * assume it as adaptive-out or sync-in.
1386 */ 1389 */
1387 attr = fmt->ep_attr & EP_ATTR_MASK; 1390 attr = fmt->ep_attr & USB_ENDPOINT_SYNCTYPE;
1388 if (((is_playback && attr == EP_ATTR_ASYNC) || 1391 if (((is_playback && attr == USB_ENDPOINT_SYNC_ASYNC) ||
1389 (! is_playback && attr == EP_ATTR_ADAPTIVE)) && 1392 (! is_playback && attr == USB_ENDPOINT_SYNC_ADAPTIVE)) &&
1390 altsd->bNumEndpoints >= 2) { 1393 altsd->bNumEndpoints >= 2) {
1391 /* check sync-pipe endpoint */ 1394 /* check sync-pipe endpoint */
1392 /* ... and check descriptor size before accessing bSynchAddress 1395 /* ... and check descriptor size before accessing bSynchAddress
@@ -1426,7 +1429,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1426 } 1429 }
1427 1430
1428 /* always fill max packet size */ 1431 /* always fill max packet size */
1429 if (fmt->attributes & EP_CS_ATTR_FILL_MAX) 1432 if (fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX)
1430 subs->fill_max = 1; 1433 subs->fill_max = 1;
1431 1434
1432 if ((err = init_usb_pitch(dev, subs->interface, alts, fmt)) < 0) 1435 if ((err = init_usb_pitch(dev, subs->interface, alts, fmt)) < 0)
@@ -1884,7 +1887,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1884 runtime->hw.channels_min = fp->channels; 1887 runtime->hw.channels_min = fp->channels;
1885 if (runtime->hw.channels_max < fp->channels) 1888 if (runtime->hw.channels_max < fp->channels)
1886 runtime->hw.channels_max = fp->channels; 1889 runtime->hw.channels_max = fp->channels;
1887 if (fp->fmt_type == USB_FORMAT_TYPE_II && fp->frame_size > 0) { 1890 if (fp->fmt_type == UAC_FORMAT_TYPE_II && fp->frame_size > 0) {
1888 /* FIXME: there might be more than one audio formats... */ 1891 /* FIXME: there might be more than one audio formats... */
1889 runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = 1892 runtime->hw.period_bytes_min = runtime->hw.period_bytes_max =
1890 fp->frame_size; 1893 fp->frame_size;
@@ -1959,7 +1962,7 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
1959 struct snd_usb_stream *as = snd_pcm_substream_chip(substream); 1962 struct snd_usb_stream *as = snd_pcm_substream_chip(substream);
1960 struct snd_usb_substream *subs = &as->substream[direction]; 1963 struct snd_usb_substream *subs = &as->substream[direction];
1961 1964
1962 if (subs->interface >= 0) { 1965 if (!as->chip->shutdown && subs->interface >= 0) {
1963 usb_set_interface(subs->dev, subs->interface, 0); 1966 usb_set_interface(subs->dev, subs->interface, 0);
1964 subs->interface = -1; 1967 subs->interface = -1;
1965 } 1968 }
@@ -2118,7 +2121,7 @@ static struct usb_device_id usb_audio_ids [] = {
2118#include "usbquirks.h" 2121#include "usbquirks.h"
2119 { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS), 2122 { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS),
2120 .bInterfaceClass = USB_CLASS_AUDIO, 2123 .bInterfaceClass = USB_CLASS_AUDIO,
2121 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL }, 2124 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL },
2122 { } /* Terminating entry */ 2125 { } /* Terminating entry */
2123}; 2126};
2124 2127
@@ -2157,7 +2160,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2157 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", 2160 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n",
2158 fp->endpoint & USB_ENDPOINT_NUMBER_MASK, 2161 fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
2159 fp->endpoint & USB_DIR_IN ? "IN" : "OUT", 2162 fp->endpoint & USB_DIR_IN ? "IN" : "OUT",
2160 sync_types[(fp->ep_attr & EP_ATTR_MASK) >> 2]); 2163 sync_types[(fp->ep_attr & USB_ENDPOINT_SYNCTYPE) >> 2]);
2161 if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) { 2164 if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) {
2162 snd_iprintf(buffer, " Rates: %d - %d (continuous)\n", 2165 snd_iprintf(buffer, " Rates: %d - %d (continuous)\n",
2163 fp->rate_min, fp->rate_max); 2166 fp->rate_min, fp->rate_max);
@@ -2420,29 +2423,68 @@ static int is_big_endian_format(struct snd_usb_audio *chip, struct audioformat *
2420 * @format: the format tag (wFormatTag) 2423 * @format: the format tag (wFormatTag)
2421 * @fmt: the format type descriptor 2424 * @fmt: the format type descriptor
2422 */ 2425 */
2423static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audioformat *fp, 2426static int parse_audio_format_i_type(struct snd_usb_audio *chip,
2424 int format, unsigned char *fmt) 2427 struct audioformat *fp,
2428 int format, void *_fmt,
2429 int protocol)
2425{ 2430{
2426 int pcm_format; 2431 int pcm_format, i;
2427 int sample_width, sample_bytes; 2432 int sample_width, sample_bytes;
2428 2433
2434 switch (protocol) {
2435 case UAC_VERSION_1: {
2436 struct uac_format_type_i_discrete_descriptor *fmt = _fmt;
2437 sample_width = fmt->bBitResolution;
2438 sample_bytes = fmt->bSubframeSize;
2439 break;
2440 }
2441
2442 case UAC_VERSION_2: {
2443 struct uac_format_type_i_ext_descriptor *fmt = _fmt;
2444 sample_width = fmt->bBitResolution;
2445 sample_bytes = fmt->bSubslotSize;
2446
2447 /*
2448 * FIXME
2449 * USB audio class v2 devices specify a bitmap of possible
2450 * audio formats rather than one fix value. For now, we just
2451 * pick one of them and report that as the only possible
2452 * value for this setting.
2453 * The bit allocation map is in fact compatible to the
2454 * wFormatTag of the v1 AS streaming descriptors, which is why
2455 * we can simply map the matrix.
2456 */
2457
2458 for (i = 0; i < 5; i++)
2459 if (format & (1UL << i)) {
2460 format = i + 1;
2461 break;
2462 }
2463
2464 break;
2465 }
2466
2467 default:
2468 return -EINVAL;
2469 }
2470
2429 /* FIXME: correct endianess and sign? */ 2471 /* FIXME: correct endianess and sign? */
2430 pcm_format = -1; 2472 pcm_format = -1;
2431 sample_width = fmt[6]; 2473
2432 sample_bytes = fmt[5];
2433 switch (format) { 2474 switch (format) {
2434 case 0: /* some devices don't define this correctly... */ 2475 case UAC_FORMAT_TYPE_I_UNDEFINED: /* some devices don't define this correctly... */
2435 snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", 2476 snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n",
2436 chip->dev->devnum, fp->iface, fp->altsetting); 2477 chip->dev->devnum, fp->iface, fp->altsetting);
2437 /* fall-through */ 2478 /* fall-through */
2438 case USB_AUDIO_FORMAT_PCM: 2479 case UAC_FORMAT_TYPE_I_PCM:
2439 if (sample_width > sample_bytes * 8) { 2480 if (sample_width > sample_bytes * 8) {
2440 snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n", 2481 snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n",
2441 chip->dev->devnum, fp->iface, fp->altsetting, 2482 chip->dev->devnum, fp->iface, fp->altsetting,
2442 sample_width, sample_bytes); 2483 sample_width, sample_bytes);
2443 } 2484 }
2444 /* check the format byte size */ 2485 /* check the format byte size */
2445 switch (fmt[5]) { 2486 printk(" XXXXX SAMPLE BYTES %d\n", sample_bytes);
2487 switch (sample_bytes) {
2446 case 1: 2488 case 1:
2447 pcm_format = SNDRV_PCM_FORMAT_S8; 2489 pcm_format = SNDRV_PCM_FORMAT_S8;
2448 break; 2490 break;
@@ -2463,12 +2505,12 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor
2463 break; 2505 break;
2464 default: 2506 default:
2465 snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n", 2507 snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n",
2466 chip->dev->devnum, fp->iface, 2508 chip->dev->devnum, fp->iface, fp->altsetting,
2467 fp->altsetting, sample_width, sample_bytes); 2509 sample_width, sample_bytes);
2468 break; 2510 break;
2469 } 2511 }
2470 break; 2512 break;
2471 case USB_AUDIO_FORMAT_PCM8: 2513 case UAC_FORMAT_TYPE_I_PCM8:
2472 pcm_format = SNDRV_PCM_FORMAT_U8; 2514 pcm_format = SNDRV_PCM_FORMAT_U8;
2473 2515
2474 /* Dallas DS4201 workaround: it advertises U8 format, but really 2516 /* Dallas DS4201 workaround: it advertises U8 format, but really
@@ -2476,13 +2518,13 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor
2476 if (chip->usb_id == USB_ID(0x04fa, 0x4201)) 2518 if (chip->usb_id == USB_ID(0x04fa, 0x4201))
2477 pcm_format = SNDRV_PCM_FORMAT_S8; 2519 pcm_format = SNDRV_PCM_FORMAT_S8;
2478 break; 2520 break;
2479 case USB_AUDIO_FORMAT_IEEE_FLOAT: 2521 case UAC_FORMAT_TYPE_I_IEEE_FLOAT:
2480 pcm_format = SNDRV_PCM_FORMAT_FLOAT_LE; 2522 pcm_format = SNDRV_PCM_FORMAT_FLOAT_LE;
2481 break; 2523 break;
2482 case USB_AUDIO_FORMAT_ALAW: 2524 case UAC_FORMAT_TYPE_I_ALAW:
2483 pcm_format = SNDRV_PCM_FORMAT_A_LAW; 2525 pcm_format = SNDRV_PCM_FORMAT_A_LAW;
2484 break; 2526 break;
2485 case USB_AUDIO_FORMAT_MU_LAW: 2527 case UAC_FORMAT_TYPE_I_MULAW:
2486 pcm_format = SNDRV_PCM_FORMAT_MU_LAW; 2528 pcm_format = SNDRV_PCM_FORMAT_MU_LAW;
2487 break; 2529 break;
2488 default: 2530 default:
@@ -2496,7 +2538,7 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor
2496 2538
2497/* 2539/*
2498 * parse the format descriptor and stores the possible sample rates 2540 * parse the format descriptor and stores the possible sample rates
2499 * on the audioformat table. 2541 * on the audioformat table (audio class v1).
2500 * 2542 *
2501 * @dev: usb device 2543 * @dev: usb device
2502 * @fp: audioformat record 2544 * @fp: audioformat record
@@ -2504,13 +2546,13 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor
2504 * @offset: the start offset of descriptor pointing the rate type 2546 * @offset: the start offset of descriptor pointing the rate type
2505 * (7 for type I and II, 8 for type II) 2547 * (7 for type I and II, 8 for type II)
2506 */ 2548 */
2507static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioformat *fp, 2549static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audioformat *fp,
2508 unsigned char *fmt, int offset) 2550 unsigned char *fmt, int offset)
2509{ 2551{
2510 int nr_rates = fmt[offset]; 2552 int nr_rates = fmt[offset];
2511 2553
2512 if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { 2554 if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) {
2513 snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", 2555 snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n",
2514 chip->dev->devnum, fp->iface, fp->altsetting); 2556 chip->dev->devnum, fp->iface, fp->altsetting);
2515 return -1; 2557 return -1;
2516 } 2558 }
@@ -2561,14 +2603,87 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
2561} 2603}
2562 2604
2563/* 2605/*
2606 * parse the format descriptor and stores the possible sample rates
2607 * on the audioformat table (audio class v2).
2608 */
2609static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
2610 struct audioformat *fp,
2611 struct usb_host_interface *iface)
2612{
2613 struct usb_device *dev = chip->dev;
2614 unsigned char tmp[2], *data;
2615 int i, nr_rates, data_size, ret = 0;
2616
2617 /* get the number of sample rates first by only fetching 2 bytes */
2618 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
2619 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
2620 0x0100, chip->clock_id << 8, tmp, sizeof(tmp), 1000);
2621
2622 if (ret < 0) {
2623 snd_printk(KERN_ERR "unable to retrieve number of sample rates\n");
2624 goto err;
2625 }
2626
2627 nr_rates = (tmp[1] << 8) | tmp[0];
2628 data_size = 2 + 12 * nr_rates;
2629 data = kzalloc(data_size, GFP_KERNEL);
2630 if (!data) {
2631 ret = -ENOMEM;
2632 goto err;
2633 }
2634
2635 /* now get the full information */
2636 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
2637 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
2638 0x0100, chip->clock_id << 8, data, data_size, 1000);
2639
2640 if (ret < 0) {
2641 snd_printk(KERN_ERR "unable to retrieve sample rate range\n");
2642 ret = -EINVAL;
2643 goto err_free;
2644 }
2645
2646 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
2647 if (!fp->rate_table) {
2648 ret = -ENOMEM;
2649 goto err_free;
2650 }
2651
2652 fp->nr_rates = 0;
2653 fp->rate_min = fp->rate_max = 0;
2654
2655 for (i = 0; i < nr_rates; i++) {
2656 int rate = combine_quad(&data[2 + 12 * i]);
2657
2658 fp->rate_table[fp->nr_rates] = rate;
2659 if (!fp->rate_min || rate < fp->rate_min)
2660 fp->rate_min = rate;
2661 if (!fp->rate_max || rate > fp->rate_max)
2662 fp->rate_max = rate;
2663 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
2664 fp->nr_rates++;
2665 }
2666
2667err_free:
2668 kfree(data);
2669err:
2670 return ret;
2671}
2672
2673/*
2564 * parse the format type I and III descriptors 2674 * parse the format type I and III descriptors
2565 */ 2675 */
2566static int parse_audio_format_i(struct snd_usb_audio *chip, struct audioformat *fp, 2676static int parse_audio_format_i(struct snd_usb_audio *chip,
2567 int format, unsigned char *fmt) 2677 struct audioformat *fp,
2678 int format, void *_fmt,
2679 struct usb_host_interface *iface)
2568{ 2680{
2569 int pcm_format; 2681 struct usb_interface_descriptor *altsd = get_iface_desc(iface);
2682 struct uac_format_type_i_discrete_descriptor *fmt = _fmt;
2683 int protocol = altsd->bInterfaceProtocol;
2684 int pcm_format, ret;
2570 2685
2571 if (fmt[3] == USB_FORMAT_TYPE_III) { 2686 if (fmt->bFormatType == UAC_FORMAT_TYPE_III) {
2572 /* FIXME: the format type is really IECxxx 2687 /* FIXME: the format type is really IECxxx
2573 * but we give normal PCM format to get the existing 2688 * but we give normal PCM format to get the existing
2574 * apps working... 2689 * apps working...
@@ -2586,34 +2701,57 @@ static int parse_audio_format_i(struct snd_usb_audio *chip, struct audioformat *
2586 pcm_format = SNDRV_PCM_FORMAT_S16_LE; 2701 pcm_format = SNDRV_PCM_FORMAT_S16_LE;
2587 } 2702 }
2588 } else { 2703 } else {
2589 pcm_format = parse_audio_format_i_type(chip, fp, format, fmt); 2704 pcm_format = parse_audio_format_i_type(chip, fp, format, fmt, protocol);
2590 if (pcm_format < 0) 2705 if (pcm_format < 0)
2591 return -1; 2706 return -1;
2592 } 2707 }
2708
2593 fp->format = pcm_format; 2709 fp->format = pcm_format;
2594 fp->channels = fmt[4]; 2710
2711 /* gather possible sample rates */
2712 /* audio class v1 reports possible sample rates as part of the
2713 * proprietary class specific descriptor.
2714 * audio class v2 uses class specific EP0 range requests for that.
2715 */
2716 switch (protocol) {
2717 case UAC_VERSION_1:
2718 fp->channels = fmt->bNrChannels;
2719 ret = parse_audio_format_rates_v1(chip, fp, _fmt, 7);
2720 break;
2721 case UAC_VERSION_2:
2722 /* fp->channels is already set in this case */
2723 ret = parse_audio_format_rates_v2(chip, fp, iface);
2724 break;
2725 }
2726
2595 if (fp->channels < 1) { 2727 if (fp->channels < 1) {
2596 snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n", 2728 snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n",
2597 chip->dev->devnum, fp->iface, fp->altsetting, fp->channels); 2729 chip->dev->devnum, fp->iface, fp->altsetting, fp->channels);
2598 return -1; 2730 return -1;
2599 } 2731 }
2600 return parse_audio_format_rates(chip, fp, fmt, 7); 2732
2733 return ret;
2601} 2734}
2602 2735
2603/* 2736/*
2604 * prase the format type II descriptor 2737 * parse the format type II descriptor
2605 */ 2738 */
2606static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat *fp, 2739static int parse_audio_format_ii(struct snd_usb_audio *chip,
2607 int format, unsigned char *fmt) 2740 struct audioformat *fp,
2741 int format, void *_fmt,
2742 struct usb_host_interface *iface)
2608{ 2743{
2609 int brate, framesize; 2744 int brate, framesize, ret;
2745 struct usb_interface_descriptor *altsd = get_iface_desc(iface);
2746 int protocol = altsd->bInterfaceProtocol;
2747
2610 switch (format) { 2748 switch (format) {
2611 case USB_AUDIO_FORMAT_AC3: 2749 case UAC_FORMAT_TYPE_II_AC3:
2612 /* FIXME: there is no AC3 format defined yet */ 2750 /* FIXME: there is no AC3 format defined yet */
2613 // fp->format = SNDRV_PCM_FORMAT_AC3; 2751 // fp->format = SNDRV_PCM_FORMAT_AC3;
2614 fp->format = SNDRV_PCM_FORMAT_U8; /* temporarily hack to receive byte streams */ 2752 fp->format = SNDRV_PCM_FORMAT_U8; /* temporarily hack to receive byte streams */
2615 break; 2753 break;
2616 case USB_AUDIO_FORMAT_MPEG: 2754 case UAC_FORMAT_TYPE_II_MPEG:
2617 fp->format = SNDRV_PCM_FORMAT_MPEG; 2755 fp->format = SNDRV_PCM_FORMAT_MPEG;
2618 break; 2756 break;
2619 default: 2757 default:
@@ -2622,26 +2760,46 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat
2622 fp->format = SNDRV_PCM_FORMAT_MPEG; 2760 fp->format = SNDRV_PCM_FORMAT_MPEG;
2623 break; 2761 break;
2624 } 2762 }
2763
2625 fp->channels = 1; 2764 fp->channels = 1;
2626 brate = combine_word(&fmt[4]); /* fmt[4,5] : wMaxBitRate (in kbps) */ 2765
2627 framesize = combine_word(&fmt[6]); /* fmt[6,7]: wSamplesPerFrame */ 2766 switch (protocol) {
2628 snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); 2767 case UAC_VERSION_1: {
2629 fp->frame_size = framesize; 2768 struct uac_format_type_ii_discrete_descriptor *fmt = _fmt;
2630 return parse_audio_format_rates(chip, fp, fmt, 8); /* fmt[8..] sample rates */ 2769 brate = le16_to_cpu(fmt->wMaxBitRate);
2770 framesize = le16_to_cpu(fmt->wSamplesPerFrame);
2771 snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
2772 fp->frame_size = framesize;
2773 ret = parse_audio_format_rates_v1(chip, fp, _fmt, 8); /* fmt[8..] sample rates */
2774 break;
2775 }
2776 case UAC_VERSION_2: {
2777 struct uac_format_type_ii_ext_descriptor *fmt = _fmt;
2778 brate = le16_to_cpu(fmt->wMaxBitRate);
2779 framesize = le16_to_cpu(fmt->wSamplesPerFrame);
2780 snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
2781 fp->frame_size = framesize;
2782 ret = parse_audio_format_rates_v2(chip, fp, iface);
2783 break;
2784 }
2785 }
2786
2787 return ret;
2631} 2788}
2632 2789
2633static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, 2790static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp,
2634 int format, unsigned char *fmt, int stream) 2791 int format, unsigned char *fmt, int stream,
2792 struct usb_host_interface *iface)
2635{ 2793{
2636 int err; 2794 int err;
2637 2795
2638 switch (fmt[3]) { 2796 switch (fmt[3]) {
2639 case USB_FORMAT_TYPE_I: 2797 case UAC_FORMAT_TYPE_I:
2640 case USB_FORMAT_TYPE_III: 2798 case UAC_FORMAT_TYPE_III:
2641 err = parse_audio_format_i(chip, fp, format, fmt); 2799 err = parse_audio_format_i(chip, fp, format, fmt, iface);
2642 break; 2800 break;
2643 case USB_FORMAT_TYPE_II: 2801 case UAC_FORMAT_TYPE_II:
2644 err = parse_audio_format_ii(chip, fp, format, fmt); 2802 err = parse_audio_format_ii(chip, fp, format, fmt, iface);
2645 break; 2803 break;
2646 default: 2804 default:
2647 snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", 2805 snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n",
@@ -2659,7 +2817,7 @@ static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp
2659 if (chip->usb_id == USB_ID(0x041e, 0x3000) || 2817 if (chip->usb_id == USB_ID(0x041e, 0x3000) ||
2660 chip->usb_id == USB_ID(0x041e, 0x3020) || 2818 chip->usb_id == USB_ID(0x041e, 0x3020) ||
2661 chip->usb_id == USB_ID(0x041e, 0x3061)) { 2819 chip->usb_id == USB_ID(0x041e, 0x3061)) {
2662 if (fmt[3] == USB_FORMAT_TYPE_I && 2820 if (fmt[3] == UAC_FORMAT_TYPE_I &&
2663 fp->rates != SNDRV_PCM_RATE_48000 && 2821 fp->rates != SNDRV_PCM_RATE_48000 &&
2664 fp->rates != SNDRV_PCM_RATE_96000) 2822 fp->rates != SNDRV_PCM_RATE_96000)
2665 return -1; 2823 return -1;
@@ -2688,10 +2846,10 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2688 struct usb_host_interface *alts; 2846 struct usb_host_interface *alts;
2689 struct usb_interface_descriptor *altsd; 2847 struct usb_interface_descriptor *altsd;
2690 int i, altno, err, stream; 2848 int i, altno, err, stream;
2691 int format; 2849 int format = 0, num_channels = 0;
2692 struct audioformat *fp = NULL; 2850 struct audioformat *fp = NULL;
2693 unsigned char *fmt, *csep; 2851 unsigned char *fmt, *csep;
2694 int num; 2852 int num, protocol;
2695 2853
2696 dev = chip->dev; 2854 dev = chip->dev;
2697 2855
@@ -2710,10 +2868,11 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2710 for (i = 0; i < num; i++) { 2868 for (i = 0; i < num; i++) {
2711 alts = &iface->altsetting[i]; 2869 alts = &iface->altsetting[i];
2712 altsd = get_iface_desc(alts); 2870 altsd = get_iface_desc(alts);
2871 protocol = altsd->bInterfaceProtocol;
2713 /* skip invalid one */ 2872 /* skip invalid one */
2714 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && 2873 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO &&
2715 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || 2874 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) ||
2716 (altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING && 2875 (altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING &&
2717 altsd->bInterfaceSubClass != USB_SUBCLASS_VENDOR_SPEC) || 2876 altsd->bInterfaceSubClass != USB_SUBCLASS_VENDOR_SPEC) ||
2718 altsd->bNumEndpoints < 1 || 2877 altsd->bNumEndpoints < 1 ||
2719 le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 0) 2878 le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 0)
@@ -2734,30 +2893,65 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2734 continue; 2893 continue;
2735 2894
2736 /* get audio formats */ 2895 /* get audio formats */
2737 fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, AS_GENERAL); 2896 switch (protocol) {
2738 if (!fmt) { 2897 case UAC_VERSION_1: {
2739 snd_printk(KERN_ERR "%d:%u:%d : AS_GENERAL descriptor not found\n", 2898 struct uac_as_header_descriptor_v1 *as =
2740 dev->devnum, iface_no, altno); 2899 snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
2741 continue; 2900
2901 if (!as) {
2902 snd_printk(KERN_ERR "%d:%u:%d : UAC_AS_GENERAL descriptor not found\n",
2903 dev->devnum, iface_no, altno);
2904 continue;
2905 }
2906
2907 if (as->bLength < sizeof(*as)) {
2908 snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_AS_GENERAL desc\n",
2909 dev->devnum, iface_no, altno);
2910 continue;
2911 }
2912
2913 format = le16_to_cpu(as->wFormatTag); /* remember the format value */
2914 break;
2742 } 2915 }
2743 2916
2744 if (fmt[0] < 7) { 2917 case UAC_VERSION_2: {
2745 snd_printk(KERN_ERR "%d:%u:%d : invalid AS_GENERAL desc\n", 2918 struct uac_as_header_descriptor_v2 *as =
2746 dev->devnum, iface_no, altno); 2919 snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
2747 continue; 2920
2921 if (!as) {
2922 snd_printk(KERN_ERR "%d:%u:%d : UAC_AS_GENERAL descriptor not found\n",
2923 dev->devnum, iface_no, altno);
2924 continue;
2925 }
2926
2927 if (as->bLength < sizeof(*as)) {
2928 snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_AS_GENERAL desc\n",
2929 dev->devnum, iface_no, altno);
2930 continue;
2931 }
2932
2933 num_channels = as->bNrChannels;
2934 format = le32_to_cpu(as->bmFormats);
2935
2936 break;
2748 } 2937 }
2749 2938
2750 format = (fmt[6] << 8) | fmt[5]; /* remember the format value */ 2939 default:
2940 snd_printk(KERN_ERR "%d:%u:%d : unknown interface protocol %04x\n",
2941 dev->devnum, iface_no, altno, protocol);
2942 continue;
2943 }
2751 2944
2752 /* get format type */ 2945 /* get format type */
2753 fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, FORMAT_TYPE); 2946 fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_FORMAT_TYPE);
2754 if (!fmt) { 2947 if (!fmt) {
2755 snd_printk(KERN_ERR "%d:%u:%d : no FORMAT_TYPE desc\n", 2948 snd_printk(KERN_ERR "%d:%u:%d : no UAC_FORMAT_TYPE desc\n",
2756 dev->devnum, iface_no, altno); 2949 dev->devnum, iface_no, altno);
2757 continue; 2950 continue;
2758 } 2951 }
2759 if (fmt[0] < 8) { 2952 if (((protocol == UAC_VERSION_1) && (fmt[0] < 8)) ||
2760 snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", 2953 ((protocol == UAC_VERSION_2) && (fmt[0] != 6))) {
2954 snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n",
2761 dev->devnum, iface_no, altno); 2955 dev->devnum, iface_no, altno);
2762 continue; 2956 continue;
2763 } 2957 }
@@ -2770,6 +2964,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2770 if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 && 2964 if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 &&
2771 fp && fp->altsetting == 1 && fp->channels == 1 && 2965 fp && fp->altsetting == 1 && fp->channels == 1 &&
2772 fp->format == SNDRV_PCM_FORMAT_S16_LE && 2966 fp->format == SNDRV_PCM_FORMAT_S16_LE &&
2967 protocol == UAC_VERSION_1 &&
2773 le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 2968 le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) ==
2774 fp->maxpacksize * 2) 2969 fp->maxpacksize * 2)
2775 continue; 2970 continue;
@@ -2778,7 +2973,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2778 /* Creamware Noah has this descriptor after the 2nd endpoint */ 2973 /* Creamware Noah has this descriptor after the 2nd endpoint */
2779 if (!csep && altsd->bNumEndpoints >= 2) 2974 if (!csep && altsd->bNumEndpoints >= 2)
2780 csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); 2975 csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT);
2781 if (!csep || csep[0] < 7 || csep[2] != EP_GENERAL) { 2976 if (!csep || csep[0] < 7 || csep[2] != UAC_EP_GENERAL) {
2782 snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" 2977 snd_printk(KERN_WARNING "%d:%u:%d : no or invalid"
2783 " class specific endpoint descriptor\n", 2978 " class specific endpoint descriptor\n",
2784 dev->devnum, iface_no, altno); 2979 dev->devnum, iface_no, altno);
@@ -2798,6 +2993,8 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2798 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 2993 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
2799 fp->datainterval = parse_datainterval(chip, alts); 2994 fp->datainterval = parse_datainterval(chip, alts);
2800 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 2995 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2996 /* num_channels is only set for v2 interfaces */
2997 fp->channels = num_channels;
2801 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) 2998 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH)
2802 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) 2999 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1)
2803 * (fp->maxpacksize & 0x7ff); 3000 * (fp->maxpacksize & 0x7ff);
@@ -2810,12 +3007,12 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2810 /* Optoplay sets the sample rate attribute although 3007 /* Optoplay sets the sample rate attribute although
2811 * it seems not supporting it in fact. 3008 * it seems not supporting it in fact.
2812 */ 3009 */
2813 fp->attributes &= ~EP_CS_ATTR_SAMPLE_RATE; 3010 fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE;
2814 break; 3011 break;
2815 case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ 3012 case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
2816 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ 3013 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
2817 /* doesn't set the sample rate attribute, but supports it */ 3014 /* doesn't set the sample rate attribute, but supports it */
2818 fp->attributes |= EP_CS_ATTR_SAMPLE_RATE; 3015 fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
2819 break; 3016 break;
2820 case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ 3017 case USB_ID(0x047f, 0x0ca1): /* plantronics headset */
2821 case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is 3018 case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is
@@ -2824,16 +3021,16 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2824 * plantronics headset and Griffin iMic have set adaptive-in 3021 * plantronics headset and Griffin iMic have set adaptive-in
2825 * although it's really not... 3022 * although it's really not...
2826 */ 3023 */
2827 fp->ep_attr &= ~EP_ATTR_MASK; 3024 fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE;
2828 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 3025 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
2829 fp->ep_attr |= EP_ATTR_ADAPTIVE; 3026 fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE;
2830 else 3027 else
2831 fp->ep_attr |= EP_ATTR_SYNC; 3028 fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC;
2832 break; 3029 break;
2833 } 3030 }
2834 3031
2835 /* ok, let's parse further... */ 3032 /* ok, let's parse further... */
2836 if (parse_audio_format(chip, fp, format, fmt, stream) < 0) { 3033 if (parse_audio_format(chip, fp, format, fmt, stream, alts) < 0) {
2837 kfree(fp->rate_table); 3034 kfree(fp->rate_table);
2838 kfree(fp); 3035 kfree(fp);
2839 continue; 3036 continue;
@@ -2875,6 +3072,65 @@ static void snd_usb_stream_disconnect(struct list_head *head)
2875 } 3072 }
2876} 3073}
2877 3074
3075static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int interface)
3076{
3077 struct usb_device *dev = chip->dev;
3078 struct usb_host_interface *alts;
3079 struct usb_interface_descriptor *altsd;
3080 struct usb_interface *iface = usb_ifnum_to_if(dev, interface);
3081
3082 if (!iface) {
3083 snd_printk(KERN_ERR "%d:%u:%d : does not exist\n",
3084 dev->devnum, ctrlif, interface);
3085 return -EINVAL;
3086 }
3087
3088 if (usb_interface_claimed(iface)) {
3089 snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n",
3090 dev->devnum, ctrlif, interface);
3091 return -EINVAL;
3092 }
3093
3094 alts = &iface->altsetting[0];
3095 altsd = get_iface_desc(alts);
3096 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO ||
3097 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) &&
3098 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) {
3099 int err = snd_usbmidi_create(chip->card, iface,
3100 &chip->midi_list, NULL);
3101 if (err < 0) {
3102 snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n",
3103 dev->devnum, ctrlif, interface);
3104 return -EINVAL;
3105 }
3106 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
3107
3108 return 0;
3109 }
3110
3111 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO &&
3112 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) ||
3113 altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) {
3114 snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n",
3115 dev->devnum, ctrlif, interface, altsd->bInterfaceClass);
3116 /* skip non-supported classes */
3117 return -EINVAL;
3118 }
3119
3120 if (snd_usb_get_speed(dev) == USB_SPEED_LOW) {
3121 snd_printk(KERN_ERR "low speed audio streaming not supported\n");
3122 return -EINVAL;
3123 }
3124
3125 if (! parse_audio_endpoints(chip, interface)) {
3126 usb_set_interface(dev, interface, 0); /* reset the current interface */
3127 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
3128 return -EINVAL;
3129 }
3130
3131 return 0;
3132}
3133
2878/* 3134/*
2879 * parse audio control descriptor and create pcm/midi streams 3135 * parse audio control descriptor and create pcm/midi streams
2880 */ 3136 */
@@ -2882,67 +3138,81 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
2882{ 3138{
2883 struct usb_device *dev = chip->dev; 3139 struct usb_device *dev = chip->dev;
2884 struct usb_host_interface *host_iface; 3140 struct usb_host_interface *host_iface;
2885 struct usb_interface *iface; 3141 struct usb_interface_descriptor *altsd;
2886 unsigned char *p1; 3142 void *control_header;
2887 int i, j; 3143 int i, protocol;
2888 3144
2889 /* find audiocontrol interface */ 3145 /* find audiocontrol interface */
2890 host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0]; 3146 host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0];
2891 if (!(p1 = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen, NULL, HEADER))) { 3147 control_header = snd_usb_find_csint_desc(host_iface->extra,
2892 snd_printk(KERN_ERR "cannot find HEADER\n"); 3148 host_iface->extralen,
2893 return -EINVAL; 3149 NULL, UAC_HEADER);
2894 } 3150 altsd = get_iface_desc(host_iface);
2895 if (! p1[7] || p1[0] < 8 + p1[7]) { 3151 protocol = altsd->bInterfaceProtocol;
2896 snd_printk(KERN_ERR "invalid HEADER\n"); 3152
3153 if (!control_header) {
3154 snd_printk(KERN_ERR "cannot find UAC_HEADER\n");
2897 return -EINVAL; 3155 return -EINVAL;
2898 } 3156 }
2899 3157
2900 /* 3158 switch (protocol) {
2901 * parse all USB audio streaming interfaces 3159 case UAC_VERSION_1: {
2902 */ 3160 struct uac_ac_header_descriptor_v1 *h1 = control_header;
2903 for (i = 0; i < p1[7]; i++) { 3161
2904 struct usb_host_interface *alts; 3162 if (!h1->bInCollection) {
2905 struct usb_interface_descriptor *altsd; 3163 snd_printk(KERN_INFO "skipping empty audio interface (v1)\n");
2906 j = p1[8 + i]; 3164 return -EINVAL;
2907 iface = usb_ifnum_to_if(dev, j);
2908 if (!iface) {
2909 snd_printk(KERN_ERR "%d:%u:%d : does not exist\n",
2910 dev->devnum, ctrlif, j);
2911 continue;
2912 }
2913 if (usb_interface_claimed(iface)) {
2914 snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", dev->devnum, ctrlif, j);
2915 continue;
2916 } 3165 }
2917 alts = &iface->altsetting[0]; 3166
2918 altsd = get_iface_desc(alts); 3167 if (h1->bLength < sizeof(*h1) + h1->bInCollection) {
2919 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || 3168 snd_printk(KERN_ERR "invalid UAC_HEADER (v1)\n");
2920 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && 3169 return -EINVAL;
2921 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) {
2922 int err = snd_usbmidi_create(chip->card, iface,
2923 &chip->midi_list, NULL);
2924 if (err < 0) {
2925 snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j);
2926 continue;
2927 }
2928 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
2929 continue;
2930 } 3170 }
2931 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && 3171
2932 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || 3172 for (i = 0; i < h1->bInCollection; i++)
2933 altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING) { 3173 snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]);
2934 snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n", dev->devnum, ctrlif, j, altsd->bInterfaceClass); 3174
2935 /* skip non-supported classes */ 3175 break;
2936 continue; 3176 }
3177
3178 case UAC_VERSION_2: {
3179 struct uac_clock_source_descriptor *cs;
3180 struct usb_interface_assoc_descriptor *assoc =
3181 usb_ifnum_to_if(dev, ctrlif)->intf_assoc;
3182
3183 if (!assoc) {
3184 snd_printk(KERN_ERR "Audio class v2 interfaces need an interface association\n");
3185 return -EINVAL;
2937 } 3186 }
2938 if (snd_usb_get_speed(dev) == USB_SPEED_LOW) { 3187
2939 snd_printk(KERN_ERR "low speed audio streaming not supported\n"); 3188 /* FIXME: for now, we expect there is at least one clock source
2940 continue; 3189 * descriptor and we always take the first one.
3190 * We should properly support devices with multiple clock sources,
3191 * clock selectors and sample rate conversion units. */
3192
3193 cs = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen,
3194 NULL, UAC_CLOCK_SOURCE);
3195
3196 if (!cs) {
3197 snd_printk(KERN_ERR "CLOCK_SOURCE descriptor not found\n");
3198 return -EINVAL;
2941 } 3199 }
2942 if (! parse_audio_endpoints(chip, j)) { 3200
2943 usb_set_interface(dev, j, 0); /* reset the current interface */ 3201 chip->clock_id = cs->bClockID;
2944 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 3202
3203 for (i = 0; i < assoc->bInterfaceCount; i++) {
3204 int intf = assoc->bFirstInterface + i;
3205
3206 if (intf != ctrlif)
3207 snd_usb_create_stream(chip, ctrlif, intf);
2945 } 3208 }
3209
3210 break;
3211 }
3212
3213 default:
3214 snd_printk(KERN_ERR "unknown protocol version 0x%02x\n", protocol);
3215 return -EINVAL;
2946 } 3216 }
2947 3217
2948 return 0; 3218 return 0;
@@ -3033,7 +3303,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
3033 static const struct audioformat ua_format = { 3303 static const struct audioformat ua_format = {
3034 .format = SNDRV_PCM_FORMAT_S24_3LE, 3304 .format = SNDRV_PCM_FORMAT_S24_3LE,
3035 .channels = 2, 3305 .channels = 2,
3036 .fmt_type = USB_FORMAT_TYPE_I, 3306 .fmt_type = UAC_FORMAT_TYPE_I,
3037 .altsetting = 1, 3307 .altsetting = 1,
3038 .altset_idx = 1, 3308 .altset_idx = 1,
3039 .rates = SNDRV_PCM_RATE_CONTINUOUS, 3309 .rates = SNDRV_PCM_RATE_CONTINUOUS,
@@ -3554,7 +3824,6 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
3554 ifnum = get_iface_desc(alts)->bInterfaceNumber; 3824 ifnum = get_iface_desc(alts)->bInterfaceNumber;
3555 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), 3825 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
3556 le16_to_cpu(dev->descriptor.idProduct)); 3826 le16_to_cpu(dev->descriptor.idProduct));
3557
3558 if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum) 3827 if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum)
3559 goto __err_val; 3828 goto __err_val;
3560 3829
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index 96c558a76ba..42c299cbf63 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -21,93 +21,6 @@
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24
25/*
26 */
27
28#define USB_SUBCLASS_AUDIO_CONTROL 0x01
29#define USB_SUBCLASS_AUDIO_STREAMING 0x02
30#define USB_SUBCLASS_MIDI_STREAMING 0x03
31#define USB_SUBCLASS_VENDOR_SPEC 0xff
32
33#define HEADER 0x01
34#define INPUT_TERMINAL 0x02
35#define OUTPUT_TERMINAL 0x03
36#define MIXER_UNIT 0x04
37#define SELECTOR_UNIT 0x05
38#define FEATURE_UNIT 0x06
39#define PROCESSING_UNIT 0x07
40#define EXTENSION_UNIT 0x08
41
42#define AS_GENERAL 0x01
43#define FORMAT_TYPE 0x02
44#define FORMAT_SPECIFIC 0x03
45
46#define EP_GENERAL 0x01
47
48#define MS_GENERAL 0x01
49#define MIDI_IN_JACK 0x02
50#define MIDI_OUT_JACK 0x03
51
52/* endpoint attributes */
53#define EP_ATTR_MASK 0x0c
54#define EP_ATTR_ASYNC 0x04
55#define EP_ATTR_ADAPTIVE 0x08
56#define EP_ATTR_SYNC 0x0c
57
58/* cs endpoint attributes */
59#define EP_CS_ATTR_SAMPLE_RATE 0x01
60#define EP_CS_ATTR_PITCH_CONTROL 0x02
61#define EP_CS_ATTR_FILL_MAX 0x80
62
63/* Audio Class specific Request Codes */
64
65#define SET_CUR 0x01
66#define GET_CUR 0x81
67#define SET_MIN 0x02
68#define GET_MIN 0x82
69#define SET_MAX 0x03
70#define GET_MAX 0x83
71#define SET_RES 0x04
72#define GET_RES 0x84
73#define SET_MEM 0x05
74#define GET_MEM 0x85
75#define GET_STAT 0xff
76
77/* Terminal Control Selectors */
78
79#define COPY_PROTECT_CONTROL 0x01
80
81/* Endpoint Control Selectors */
82
83#define SAMPLING_FREQ_CONTROL 0x01
84#define PITCH_CONTROL 0x02
85
86/* Format Types */
87#define USB_FORMAT_TYPE_I 0x01
88#define USB_FORMAT_TYPE_II 0x02
89#define USB_FORMAT_TYPE_III 0x03
90
91/* type I */
92#define USB_AUDIO_FORMAT_PCM 0x01
93#define USB_AUDIO_FORMAT_PCM8 0x02
94#define USB_AUDIO_FORMAT_IEEE_FLOAT 0x03
95#define USB_AUDIO_FORMAT_ALAW 0x04
96#define USB_AUDIO_FORMAT_MU_LAW 0x05
97
98/* type II */
99#define USB_AUDIO_FORMAT_MPEG 0x1001
100#define USB_AUDIO_FORMAT_AC3 0x1002
101
102/* type III */
103#define USB_AUDIO_FORMAT_IEC1937_AC3 0x2001
104#define USB_AUDIO_FORMAT_IEC1937_MPEG1_LAYER1 0x2002
105#define USB_AUDIO_FORMAT_IEC1937_MPEG2_NOEXT 0x2003
106#define USB_AUDIO_FORMAT_IEC1937_MPEG2_EXT 0x2004
107#define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER1_LS 0x2005
108#define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER23_LS 0x2006
109
110
111/* maximum number of endpoints per interface */ 24/* maximum number of endpoints per interface */
112#define MIDI_MAX_ENDPOINTS 2 25#define MIDI_MAX_ENDPOINTS 2
113 26
@@ -129,6 +42,9 @@ struct snd_usb_audio {
129 int num_interfaces; 42 int num_interfaces;
130 int num_suspended_intf; 43 int num_suspended_intf;
131 44
45 /* for audio class v2 */
46 int clock_id;
47
132 struct list_head pcm_list; /* list of pcm streams */ 48 struct list_head pcm_list; /* list of pcm streams */
133 int pcm_devs; 49 int pcm_devs;
134 50
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index b2da478a0fa..2c59afd9961 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -46,6 +46,8 @@
46#include <linux/timer.h> 46#include <linux/timer.h>
47#include <linux/usb.h> 47#include <linux/usb.h>
48#include <linux/wait.h> 48#include <linux/wait.h>
49#include <linux/usb/audio.h>
50
49#include <sound/core.h> 51#include <sound/core.h>
50#include <sound/control.h> 52#include <sound/control.h>
51#include <sound/rawmidi.h> 53#include <sound/rawmidi.h>
@@ -1540,7 +1542,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1540 if (hostif->extralen >= 7 && 1542 if (hostif->extralen >= 7 &&
1541 ms_header->bLength >= 7 && 1543 ms_header->bLength >= 7 &&
1542 ms_header->bDescriptorType == USB_DT_CS_INTERFACE && 1544 ms_header->bDescriptorType == USB_DT_CS_INTERFACE &&
1543 ms_header->bDescriptorSubtype == HEADER) 1545 ms_header->bDescriptorSubtype == UAC_HEADER)
1544 snd_printdd(KERN_INFO "MIDIStreaming version %02x.%02x\n", 1546 snd_printdd(KERN_INFO "MIDIStreaming version %02x.%02x\n",
1545 ms_header->bcdMSC[1], ms_header->bcdMSC[0]); 1547 ms_header->bcdMSC[1], ms_header->bcdMSC[0]);
1546 else 1548 else
@@ -1556,7 +1558,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1556 if (hostep->extralen < 4 || 1558 if (hostep->extralen < 4 ||
1557 ms_ep->bLength < 4 || 1559 ms_ep->bLength < 4 ||
1558 ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT || 1560 ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT ||
1559 ms_ep->bDescriptorSubtype != MS_GENERAL) 1561 ms_ep->bDescriptorSubtype != UAC_MS_GENERAL)
1560 continue; 1562 continue;
1561 if (usb_endpoint_dir_out(ep)) { 1563 if (usb_endpoint_dir_out(ep)) {
1562 if (endpoints[epidx].out_ep) { 1564 if (endpoints[epidx].out_ep) {
@@ -1768,9 +1770,9 @@ static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi,
1768 cs_desc < hostif->extra + hostif->extralen && cs_desc[0] >= 2; 1770 cs_desc < hostif->extra + hostif->extralen && cs_desc[0] >= 2;
1769 cs_desc += cs_desc[0]) { 1771 cs_desc += cs_desc[0]) {
1770 if (cs_desc[1] == USB_DT_CS_INTERFACE) { 1772 if (cs_desc[1] == USB_DT_CS_INTERFACE) {
1771 if (cs_desc[2] == MIDI_IN_JACK) 1773 if (cs_desc[2] == UAC_MIDI_IN_JACK)
1772 endpoint->in_cables = (endpoint->in_cables << 1) | 1; 1774 endpoint->in_cables = (endpoint->in_cables << 1) | 1;
1773 else if (cs_desc[2] == MIDI_OUT_JACK) 1775 else if (cs_desc[2] == UAC_MIDI_OUT_JACK)
1774 endpoint->out_cables = (endpoint->out_cables << 1) | 1; 1776 endpoint->out_cables = (endpoint->out_cables << 1) | 1;
1775 } 1777 }
1776 } 1778 }
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 35b4830fb0c..8e8f871b74c 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -32,6 +32,8 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/usb/audio.h>
36
35#include <sound/core.h> 37#include <sound/core.h>
36#include <sound/control.h> 38#include <sound/control.h>
37#include <sound/hwdep.h> 39#include <sound/hwdep.h>
@@ -284,7 +286,7 @@ static void *find_audio_control_unit(struct mixer_build *state, unsigned char un
284 p = NULL; 286 p = NULL;
285 while ((p = snd_usb_find_desc(state->buffer, state->buflen, p, 287 while ((p = snd_usb_find_desc(state->buffer, state->buflen, p,
286 USB_DT_CS_INTERFACE)) != NULL) { 288 USB_DT_CS_INTERFACE)) != NULL) {
287 if (p[0] >= 4 && p[2] >= INPUT_TERMINAL && p[2] <= EXTENSION_UNIT && p[3] == unit) 289 if (p[0] >= 4 && p[2] >= UAC_INPUT_TERMINAL && p[2] <= UAC_EXTENSION_UNIT_V1 && p[3] == unit)
288 return p; 290 return p;
289 } 291 }
290 return NULL; 292 return NULL;
@@ -405,14 +407,14 @@ static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int vali
405 407
406static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *value) 408static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *value)
407{ 409{
408 return get_ctl_value(cval, GET_CUR, validx, value); 410 return get_ctl_value(cval, UAC_GET_CUR, validx, value);
409} 411}
410 412
411/* channel = 0: master, 1 = first channel */ 413/* channel = 0: master, 1 = first channel */
412static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval, 414static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval,
413 int channel, int *value) 415 int channel, int *value)
414{ 416{
415 return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); 417 return get_ctl_value(cval, UAC_GET_CUR, (cval->control << 8) | channel, value);
416} 418}
417 419
418static int get_cur_mix_value(struct usb_mixer_elem_info *cval, 420static int get_cur_mix_value(struct usb_mixer_elem_info *cval,
@@ -466,14 +468,14 @@ static int set_ctl_value(struct usb_mixer_elem_info *cval, int request, int vali
466 468
467static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value) 469static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value)
468{ 470{
469 return set_ctl_value(cval, SET_CUR, validx, value); 471 return set_ctl_value(cval, UAC_SET_CUR, validx, value);
470} 472}
471 473
472static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, 474static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
473 int index, int value) 475 int index, int value)
474{ 476{
475 int err; 477 int err;
476 err = set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, 478 err = set_ctl_value(cval, UAC_SET_CUR, (cval->control << 8) | channel,
477 value); 479 value);
478 if (err < 0) 480 if (err < 0)
479 return err; 481 return err;
@@ -603,13 +605,13 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm
603 if (term_only) 605 if (term_only)
604 return 0; 606 return 0;
605 switch (iterm->type >> 16) { 607 switch (iterm->type >> 16) {
606 case SELECTOR_UNIT: 608 case UAC_SELECTOR_UNIT:
607 strcpy(name, "Selector"); return 8; 609 strcpy(name, "Selector"); return 8;
608 case PROCESSING_UNIT: 610 case UAC_PROCESSING_UNIT_V1:
609 strcpy(name, "Process Unit"); return 12; 611 strcpy(name, "Process Unit"); return 12;
610 case EXTENSION_UNIT: 612 case UAC_EXTENSION_UNIT_V1:
611 strcpy(name, "Ext Unit"); return 8; 613 strcpy(name, "Ext Unit"); return 8;
612 case MIXER_UNIT: 614 case UAC_MIXER_UNIT:
613 strcpy(name, "Mixer"); return 5; 615 strcpy(name, "Mixer"); return 5;
614 default: 616 default:
615 return sprintf(name, "Unit %d", iterm->id); 617 return sprintf(name, "Unit %d", iterm->id);
@@ -648,22 +650,22 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
648 while ((p1 = find_audio_control_unit(state, id)) != NULL) { 650 while ((p1 = find_audio_control_unit(state, id)) != NULL) {
649 term->id = id; 651 term->id = id;
650 switch (p1[2]) { 652 switch (p1[2]) {
651 case INPUT_TERMINAL: 653 case UAC_INPUT_TERMINAL:
652 term->type = combine_word(p1 + 4); 654 term->type = combine_word(p1 + 4);
653 term->channels = p1[7]; 655 term->channels = p1[7];
654 term->chconfig = combine_word(p1 + 8); 656 term->chconfig = combine_word(p1 + 8);
655 term->name = p1[11]; 657 term->name = p1[11];
656 return 0; 658 return 0;
657 case FEATURE_UNIT: 659 case UAC_FEATURE_UNIT:
658 id = p1[4]; 660 id = p1[4];
659 break; /* continue to parse */ 661 break; /* continue to parse */
660 case MIXER_UNIT: 662 case UAC_MIXER_UNIT:
661 term->type = p1[2] << 16; /* virtual type */ 663 term->type = p1[2] << 16; /* virtual type */
662 term->channels = p1[5 + p1[4]]; 664 term->channels = p1[5 + p1[4]];
663 term->chconfig = combine_word(p1 + 6 + p1[4]); 665 term->chconfig = combine_word(p1 + 6 + p1[4]);
664 term->name = p1[p1[0] - 1]; 666 term->name = p1[p1[0] - 1];
665 return 0; 667 return 0;
666 case SELECTOR_UNIT: 668 case UAC_SELECTOR_UNIT:
667 /* call recursively to retrieve the channel info */ 669 /* call recursively to retrieve the channel info */
668 if (check_input_term(state, p1[5], term) < 0) 670 if (check_input_term(state, p1[5], term) < 0)
669 return -ENODEV; 671 return -ENODEV;
@@ -671,8 +673,8 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
671 term->id = id; 673 term->id = id;
672 term->name = p1[9 + p1[0] - 1]; 674 term->name = p1[9 + p1[0] - 1];
673 return 0; 675 return 0;
674 case PROCESSING_UNIT: 676 case UAC_PROCESSING_UNIT_V1:
675 case EXTENSION_UNIT: 677 case UAC_EXTENSION_UNIT_V1:
676 if (p1[6] == 1) { 678 if (p1[6] == 1) {
677 id = p1[7]; 679 id = p1[7];
678 break; /* continue to parse */ 680 break; /* continue to parse */
@@ -750,23 +752,23 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
750 break; 752 break;
751 } 753 }
752 } 754 }
753 if (get_ctl_value(cval, GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || 755 if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 ||
754 get_ctl_value(cval, GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { 756 get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) {
755 snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", 757 snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n",
756 cval->id, cval->mixer->ctrlif, cval->control, cval->id); 758 cval->id, cval->mixer->ctrlif, cval->control, cval->id);
757 return -EINVAL; 759 return -EINVAL;
758 } 760 }
759 if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { 761 if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) {
760 cval->res = 1; 762 cval->res = 1;
761 } else { 763 } else {
762 int last_valid_res = cval->res; 764 int last_valid_res = cval->res;
763 765
764 while (cval->res > 1) { 766 while (cval->res > 1) {
765 if (set_ctl_value(cval, SET_RES, (cval->control << 8) | minchn, cval->res / 2) < 0) 767 if (set_ctl_value(cval, UAC_SET_RES, (cval->control << 8) | minchn, cval->res / 2) < 0)
766 break; 768 break;
767 cval->res /= 2; 769 cval->res /= 2;
768 } 770 }
769 if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) 771 if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0)
770 cval->res = last_valid_res; 772 cval->res = last_valid_res;
771 } 773 }
772 if (cval->res == 0) 774 if (cval->res == 0)
@@ -1086,29 +1088,30 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc,
1086 * 1088 *
1087 * most of controlls are defined here. 1089 * most of controlls are defined here.
1088 */ 1090 */
1089static int parse_audio_feature_unit(struct mixer_build *state, int unitid, unsigned char *ftr) 1091static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void *_ftr)
1090{ 1092{
1091 int channels, i, j; 1093 int channels, i, j;
1092 struct usb_audio_term iterm; 1094 struct usb_audio_term iterm;
1093 unsigned int master_bits, first_ch_bits; 1095 unsigned int master_bits, first_ch_bits;
1094 int err, csize; 1096 int err, csize;
1097 struct uac_feature_unit_descriptor *ftr = _ftr;
1095 1098
1096 if (ftr[0] < 7 || ! (csize = ftr[5]) || ftr[0] < 7 + csize) { 1099 if (ftr->bLength < 7 || ! (csize = ftr->bControlSize) || ftr->bLength < 7 + csize) {
1097 snd_printk(KERN_ERR "usbaudio: unit %u: invalid FEATURE_UNIT descriptor\n", unitid); 1100 snd_printk(KERN_ERR "usbaudio: unit %u: invalid UAC_FEATURE_UNIT descriptor\n", unitid);
1098 return -EINVAL; 1101 return -EINVAL;
1099 } 1102 }
1100 1103
1101 /* parse the source unit */ 1104 /* parse the source unit */
1102 if ((err = parse_audio_unit(state, ftr[4])) < 0) 1105 if ((err = parse_audio_unit(state, ftr->bSourceID)) < 0)
1103 return err; 1106 return err;
1104 1107
1105 /* determine the input source type and name */ 1108 /* determine the input source type and name */
1106 if (check_input_term(state, ftr[4], &iterm) < 0) 1109 if (check_input_term(state, ftr->bSourceID, &iterm) < 0)
1107 return -EINVAL; 1110 return -EINVAL;
1108 1111
1109 channels = (ftr[0] - 7) / csize - 1; 1112 channels = (ftr->bLength - 7) / csize - 1;
1110 1113
1111 master_bits = snd_usb_combine_bytes(ftr + 6, csize); 1114 master_bits = snd_usb_combine_bytes(ftr->controls, csize);
1112 /* master configuration quirks */ 1115 /* master configuration quirks */
1113 switch (state->chip->usb_id) { 1116 switch (state->chip->usb_id) {
1114 case USB_ID(0x08bb, 0x2702): 1117 case USB_ID(0x08bb, 0x2702):
@@ -1119,21 +1122,21 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, unsig
1119 break; 1122 break;
1120 } 1123 }
1121 if (channels > 0) 1124 if (channels > 0)
1122 first_ch_bits = snd_usb_combine_bytes(ftr + 6 + csize, csize); 1125 first_ch_bits = snd_usb_combine_bytes(ftr->controls + csize, csize);
1123 else 1126 else
1124 first_ch_bits = 0; 1127 first_ch_bits = 0;
1125 /* check all control types */ 1128 /* check all control types */
1126 for (i = 0; i < 10; i++) { 1129 for (i = 0; i < 10; i++) {
1127 unsigned int ch_bits = 0; 1130 unsigned int ch_bits = 0;
1128 for (j = 0; j < channels; j++) { 1131 for (j = 0; j < channels; j++) {
1129 unsigned int mask = snd_usb_combine_bytes(ftr + 6 + csize * (j+1), csize); 1132 unsigned int mask = snd_usb_combine_bytes(ftr->controls + csize * (j+1), csize);
1130 if (mask & (1 << i)) 1133 if (mask & (1 << i))
1131 ch_bits |= (1 << j); 1134 ch_bits |= (1 << j);
1132 } 1135 }
1133 if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ 1136 if (ch_bits & 1) /* the first channel must be set (for ease of programming) */
1134 build_feature_ctl(state, ftr, ch_bits, i, &iterm, unitid); 1137 build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid);
1135 if (master_bits & (1 << i)) 1138 if (master_bits & (1 << i))
1136 build_feature_ctl(state, ftr, 0, i, &iterm, unitid); 1139 build_feature_ctl(state, _ftr, 0, i, &iterm, unitid);
1137 } 1140 }
1138 1141
1139 return 0; 1142 return 0;
@@ -1736,17 +1739,17 @@ static int parse_audio_unit(struct mixer_build *state, int unitid)
1736 } 1739 }
1737 1740
1738 switch (p1[2]) { 1741 switch (p1[2]) {
1739 case INPUT_TERMINAL: 1742 case UAC_INPUT_TERMINAL:
1740 return 0; /* NOP */ 1743 return 0; /* NOP */
1741 case MIXER_UNIT: 1744 case UAC_MIXER_UNIT:
1742 return parse_audio_mixer_unit(state, unitid, p1); 1745 return parse_audio_mixer_unit(state, unitid, p1);
1743 case SELECTOR_UNIT: 1746 case UAC_SELECTOR_UNIT:
1744 return parse_audio_selector_unit(state, unitid, p1); 1747 return parse_audio_selector_unit(state, unitid, p1);
1745 case FEATURE_UNIT: 1748 case UAC_FEATURE_UNIT:
1746 return parse_audio_feature_unit(state, unitid, p1); 1749 return parse_audio_feature_unit(state, unitid, p1);
1747 case PROCESSING_UNIT: 1750 case UAC_PROCESSING_UNIT_V1:
1748 return parse_audio_processing_unit(state, unitid, p1); 1751 return parse_audio_processing_unit(state, unitid, p1);
1749 case EXTENSION_UNIT: 1752 case UAC_EXTENSION_UNIT_V1:
1750 return parse_audio_extension_unit(state, unitid, p1); 1753 return parse_audio_extension_unit(state, unitid, p1);
1751 default: 1754 default:
1752 snd_printk(KERN_ERR "usbaudio: unit %u: unexpected type 0x%02x\n", unitid, p1[2]); 1755 snd_printk(KERN_ERR "usbaudio: unit %u: unexpected type 0x%02x\n", unitid, p1[2]);
@@ -1776,11 +1779,11 @@ static int snd_usb_mixer_dev_free(struct snd_device *device)
1776/* 1779/*
1777 * create mixer controls 1780 * create mixer controls
1778 * 1781 *
1779 * walk through all OUTPUT_TERMINAL descriptors to search for mixers 1782 * walk through all UAC_OUTPUT_TERMINAL descriptors to search for mixers
1780 */ 1783 */
1781static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) 1784static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
1782{ 1785{
1783 unsigned char *desc; 1786 struct uac_output_terminal_descriptor_v1 *desc;
1784 struct mixer_build state; 1787 struct mixer_build state;
1785 int err; 1788 int err;
1786 const struct usbmix_ctl_map *map; 1789 const struct usbmix_ctl_map *map;
@@ -1804,14 +1807,14 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
1804 } 1807 }
1805 1808
1806 desc = NULL; 1809 desc = NULL;
1807 while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, OUTPUT_TERMINAL)) != NULL) { 1810 while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, UAC_OUTPUT_TERMINAL)) != NULL) {
1808 if (desc[0] < 9) 1811 if (desc->bLength < 9)
1809 continue; /* invalid descriptor? */ 1812 continue; /* invalid descriptor? */
1810 set_bit(desc[3], state.unitbitmap); /* mark terminal ID as visited */ 1813 set_bit(desc->bTerminalID, state.unitbitmap); /* mark terminal ID as visited */
1811 state.oterm.id = desc[3]; 1814 state.oterm.id = desc->bTerminalID;
1812 state.oterm.type = combine_word(&desc[4]); 1815 state.oterm.type = le16_to_cpu(desc->wTerminalType);
1813 state.oterm.name = desc[8]; 1816 state.oterm.name = desc->iTerminal;
1814 err = parse_audio_unit(&state, desc[7]); 1817 err = parse_audio_unit(&state, desc->bSourceID);
1815 if (err < 0) 1818 if (err < 0)
1816 return err; 1819 return err;
1817 } 1820 }
@@ -2044,7 +2047,7 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
2044 } 2047 }
2045 mixer->rc_setup_packet->bRequestType = 2048 mixer->rc_setup_packet->bRequestType =
2046 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; 2049 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
2047 mixer->rc_setup_packet->bRequest = GET_MEM; 2050 mixer->rc_setup_packet->bRequest = UAC_GET_MEM;
2048 mixer->rc_setup_packet->wValue = cpu_to_le16(0); 2051 mixer->rc_setup_packet->wValue = cpu_to_le16(0);
2049 mixer->rc_setup_packet->wIndex = cpu_to_le16(0); 2052 mixer->rc_setup_packet->wIndex = cpu_to_le16(0);
2050 mixer->rc_setup_packet->wLength = cpu_to_le16(len); 2053 mixer->rc_setup_packet->wLength = cpu_to_le16(len);
@@ -2167,7 +2170,7 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
2167 snd_iprintf(buffer, "%s: ", jacks[i].name); 2170 snd_iprintf(buffer, "%s: ", jacks[i].name);
2168 err = snd_usb_ctl_msg(mixer->chip->dev, 2171 err = snd_usb_ctl_msg(mixer->chip->dev,
2169 usb_rcvctrlpipe(mixer->chip->dev, 0), 2172 usb_rcvctrlpipe(mixer->chip->dev, 0),
2170 GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | 2173 UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
2171 USB_RECIP_INTERFACE, 0, 2174 USB_RECIP_INTERFACE, 0,
2172 jacks[i].unitid << 8, buf, 3, 100); 2175 jacks[i].unitid << 8, buf, 3, 100);
2173 if (err == 3 && (buf[0] == 3 || buf[0] == 6)) 2176 if (err == 3 && (buf[0] == 3 || buf[0] == 6))
@@ -2255,7 +2258,8 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
2255 }; 2258 };
2256 struct usb_mixer_interface *mixer; 2259 struct usb_mixer_interface *mixer;
2257 struct snd_info_entry *entry; 2260 struct snd_info_entry *entry;
2258 int err; 2261 struct usb_host_interface *host_iface;
2262 int err, protocol;
2259 2263
2260 strcpy(chip->card->mixername, "USB Mixer"); 2264 strcpy(chip->card->mixername, "USB Mixer");
2261 2265
@@ -2272,6 +2276,16 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
2272 return -ENOMEM; 2276 return -ENOMEM;
2273 } 2277 }
2274 2278
2279 host_iface = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0];
2280 protocol = host_iface->desc.bInterfaceProtocol;
2281
2282 /* FIXME! */
2283 if (protocol != UAC_VERSION_1) {
2284 snd_printk(KERN_WARNING "mixer interface protocol 0x%02x not yet supported\n",
2285 protocol);
2286 return 0;
2287 }
2288
2275 if ((err = snd_usb_mixer_controls(mixer)) < 0 || 2289 if ((err = snd_usb_mixer_controls(mixer)) < 0 ||
2276 (err = snd_usb_mixer_status_create(mixer)) < 0) 2290 (err = snd_usb_mixer_status_create(mixer)) < 0)
2277 goto _error; 2291 goto _error;
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 977d980fb11..2b426c1fd0e 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -91,7 +91,7 @@
91 .idVendor = 0x046d, 91 .idVendor = 0x046d,
92 .idProduct = 0x0850, 92 .idProduct = 0x0850,
93 .bInterfaceClass = USB_CLASS_AUDIO, 93 .bInterfaceClass = USB_CLASS_AUDIO,
94 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 94 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL
95}, 95},
96{ 96{
97 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 97 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
@@ -100,7 +100,7 @@
100 .idVendor = 0x046d, 100 .idVendor = 0x046d,
101 .idProduct = 0x08ae, 101 .idProduct = 0x08ae,
102 .bInterfaceClass = USB_CLASS_AUDIO, 102 .bInterfaceClass = USB_CLASS_AUDIO,
103 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 103 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL
104}, 104},
105{ 105{
106 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 106 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
@@ -109,7 +109,7 @@
109 .idVendor = 0x046d, 109 .idVendor = 0x046d,
110 .idProduct = 0x08c6, 110 .idProduct = 0x08c6,
111 .bInterfaceClass = USB_CLASS_AUDIO, 111 .bInterfaceClass = USB_CLASS_AUDIO,
112 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 112 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL
113}, 113},
114{ 114{
115 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 115 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
@@ -118,7 +118,7 @@
118 .idVendor = 0x046d, 118 .idVendor = 0x046d,
119 .idProduct = 0x08f0, 119 .idProduct = 0x08f0,
120 .bInterfaceClass = USB_CLASS_AUDIO, 120 .bInterfaceClass = USB_CLASS_AUDIO,
121 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 121 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL
122}, 122},
123{ 123{
124 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 124 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
@@ -127,7 +127,7 @@
127 .idVendor = 0x046d, 127 .idVendor = 0x046d,
128 .idProduct = 0x08f5, 128 .idProduct = 0x08f5,
129 .bInterfaceClass = USB_CLASS_AUDIO, 129 .bInterfaceClass = USB_CLASS_AUDIO,
130 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 130 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL
131}, 131},
132{ 132{
133 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 133 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
@@ -136,7 +136,7 @@
136 .idVendor = 0x046d, 136 .idVendor = 0x046d,
137 .idProduct = 0x08f6, 137 .idProduct = 0x08f6,
138 .bInterfaceClass = USB_CLASS_AUDIO, 138 .bInterfaceClass = USB_CLASS_AUDIO,
139 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 139 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL
140}, 140},
141{ 141{
142 USB_DEVICE(0x046d, 0x0990), 142 USB_DEVICE(0x046d, 0x0990),
@@ -301,7 +301,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
301 .iface = 1, 301 .iface = 1,
302 .altsetting = 1, 302 .altsetting = 1,
303 .altset_idx = 1, 303 .altset_idx = 1,
304 .attributes = EP_CS_ATTR_FILL_MAX, 304 .attributes = UAC_EP_CS_ATTR_FILL_MAX,
305 .endpoint = 0x81, 305 .endpoint = 0x81,
306 .ep_attr = 0x05, 306 .ep_attr = 0x05,
307 .rates = SNDRV_PCM_RATE_CONTINUOUS, 307 .rates = SNDRV_PCM_RATE_CONTINUOUS,
@@ -2078,7 +2078,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2078 USB_DEVICE_ID_MATCH_INT_CLASS | 2078 USB_DEVICE_ID_MATCH_INT_CLASS |
2079 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2079 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2080 .bInterfaceClass = USB_CLASS_AUDIO, 2080 .bInterfaceClass = USB_CLASS_AUDIO,
2081 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, 2081 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2082 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2082 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2083 .vendor_name = "Hauppauge", 2083 .vendor_name = "Hauppauge",
2084 .product_name = "HVR-950Q", 2084 .product_name = "HVR-950Q",
@@ -2092,7 +2092,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2092 USB_DEVICE_ID_MATCH_INT_CLASS | 2092 USB_DEVICE_ID_MATCH_INT_CLASS |
2093 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2093 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2094 .bInterfaceClass = USB_CLASS_AUDIO, 2094 .bInterfaceClass = USB_CLASS_AUDIO,
2095 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, 2095 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2096 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2096 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2097 .vendor_name = "Hauppauge", 2097 .vendor_name = "Hauppauge",
2098 .product_name = "HVR-950Q", 2098 .product_name = "HVR-950Q",
@@ -2106,7 +2106,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2106 USB_DEVICE_ID_MATCH_INT_CLASS | 2106 USB_DEVICE_ID_MATCH_INT_CLASS |
2107 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2107 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2108 .bInterfaceClass = USB_CLASS_AUDIO, 2108 .bInterfaceClass = USB_CLASS_AUDIO,
2109 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, 2109 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2110 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2110 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2111 .vendor_name = "Hauppauge", 2111 .vendor_name = "Hauppauge",
2112 .product_name = "HVR-950Q", 2112 .product_name = "HVR-950Q",
@@ -2120,7 +2120,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2120 USB_DEVICE_ID_MATCH_INT_CLASS | 2120 USB_DEVICE_ID_MATCH_INT_CLASS |
2121 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2121 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2122 .bInterfaceClass = USB_CLASS_AUDIO, 2122 .bInterfaceClass = USB_CLASS_AUDIO,
2123 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, 2123 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2124 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2124 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2125 .vendor_name = "Hauppauge", 2125 .vendor_name = "Hauppauge",
2126 .product_name = "HVR-950Q", 2126 .product_name = "HVR-950Q",
@@ -2134,7 +2134,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2134 USB_DEVICE_ID_MATCH_INT_CLASS | 2134 USB_DEVICE_ID_MATCH_INT_CLASS |
2135 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2135 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2136 .bInterfaceClass = USB_CLASS_AUDIO, 2136 .bInterfaceClass = USB_CLASS_AUDIO,
2137 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, 2137 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2138 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2138 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2139 .vendor_name = "Hauppauge", 2139 .vendor_name = "Hauppauge",
2140 .product_name = "HVR-950Q", 2140 .product_name = "HVR-950Q",
@@ -2148,7 +2148,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2148 USB_DEVICE_ID_MATCH_INT_CLASS | 2148 USB_DEVICE_ID_MATCH_INT_CLASS |
2149 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2149 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2150 .bInterfaceClass = USB_CLASS_AUDIO, 2150 .bInterfaceClass = USB_CLASS_AUDIO,
2151 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, 2151 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2152 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2152 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2153 .vendor_name = "Hauppauge", 2153 .vendor_name = "Hauppauge",
2154 .product_name = "HVR-950Q", 2154 .product_name = "HVR-950Q",
@@ -2162,7 +2162,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2162 USB_DEVICE_ID_MATCH_INT_CLASS | 2162 USB_DEVICE_ID_MATCH_INT_CLASS |
2163 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2163 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2164 .bInterfaceClass = USB_CLASS_AUDIO, 2164 .bInterfaceClass = USB_CLASS_AUDIO,
2165 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, 2165 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2166 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2166 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2167 .vendor_name = "Hauppauge", 2167 .vendor_name = "Hauppauge",
2168 .product_name = "HVR-950Q", 2168 .product_name = "HVR-950Q",
@@ -2176,7 +2176,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2176 USB_DEVICE_ID_MATCH_INT_CLASS | 2176 USB_DEVICE_ID_MATCH_INT_CLASS |
2177 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2177 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2178 .bInterfaceClass = USB_CLASS_AUDIO, 2178 .bInterfaceClass = USB_CLASS_AUDIO,
2179 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL, 2179 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
2180 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2180 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2181 .vendor_name = "Hauppauge", 2181 .vendor_name = "Hauppauge",
2182 .product_name = "HVR-850", 2182 .product_name = "HVR-850",
@@ -2185,6 +2185,51 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2185 } 2185 }
2186}, 2186},
2187 2187
2188/* Digidesign Mbox */
2189{
2190 /* Thanks to Clemens Ladisch <clemens@ladisch.de> */
2191 USB_DEVICE(0x0dba, 0x1000),
2192 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
2193 .vendor_name = "Digidesign",
2194 .product_name = "MBox",
2195 .ifnum = QUIRK_ANY_INTERFACE,
2196 .type = QUIRK_COMPOSITE,
2197 .data = (const struct snd_usb_audio_quirk[]){
2198 {
2199 .ifnum = 0,
2200 .type = QUIRK_IGNORE_INTERFACE,
2201 },
2202 {
2203 .ifnum = 1,
2204 .type = QUIRK_AUDIO_FIXED_ENDPOINT,
2205 .data = &(const struct audioformat) {
2206 .format = SNDRV_PCM_FORMAT_S24_3BE,
2207 .channels = 2,
2208 .iface = 1,
2209 .altsetting = 1,
2210 .altset_idx = 1,
2211 .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
2212 .endpoint = 0x02,
2213 .ep_attr = 0x01,
2214 .maxpacksize = 0x130,
2215 .rates = SNDRV_PCM_RATE_44100 |
2216 SNDRV_PCM_RATE_48000,
2217 .rate_min = 44100,
2218 .rate_max = 48000,
2219 .nr_rates = 2,
2220 .rate_table = (unsigned int[]) {
2221 44100, 48000
2222 }
2223 }
2224 },
2225 {
2226 .ifnum = -1
2227 }
2228 }
2229
2230 }
2231},
2232
2188{ 2233{
2189 /* 2234 /*
2190 * Some USB MIDI devices don't have an audio control interface, 2235 * Some USB MIDI devices don't have an audio control interface,
@@ -2193,7 +2238,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2193 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | 2238 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
2194 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2239 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
2195 .bInterfaceClass = USB_CLASS_AUDIO, 2240 .bInterfaceClass = USB_CLASS_AUDIO,
2196 .bInterfaceSubClass = USB_SUBCLASS_MIDI_STREAMING, 2241 .bInterfaceSubClass = USB_SUBCLASS_MIDISTREAMING,
2197 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 2242 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
2198 .ifnum = QUIRK_ANY_INTERFACE, 2243 .ifnum = QUIRK_ANY_INTERFACE,
2199 .type = QUIRK_MIDI_STANDARD_INTERFACE 2244 .type = QUIRK_MIDI_STANDARD_INTERFACE
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 91bb29666d2..44deb21b177 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -16,6 +16,8 @@
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <linux/usb.h>
20#include <linux/usb/audio.h>
19#include <sound/core.h> 21#include <sound/core.h>
20#include <sound/hwdep.h> 22#include <sound/hwdep.h>
21#include <sound/pcm.h> 23#include <sound/pcm.h>
@@ -315,9 +317,9 @@ static int us122l_set_sample_rate(struct usb_device *dev, int rate)
315 data[0] = rate; 317 data[0] = rate;
316 data[1] = rate >> 8; 318 data[1] = rate >> 8;
317 data[2] = rate >> 16; 319 data[2] = rate >> 16;
318 err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 320 err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
319 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 321 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
320 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000); 322 UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000);
321 if (err < 0) 323 if (err < 0)
322 snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", 324 snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n",
323 dev->devnum, rate, ep); 325 dev->devnum, rate, ep);