2 * USB Audio Driver for ALSA
4 * Quirks and vendor-specific extensions for mixer interfaces
6 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
8 * Many codes borrowed from audio.c by
9 * Alan Cox (alan@lxorguk.ukuu.org.uk)
10 * Thomas Sailer (sailer@ife.ee.ethz.ch)
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include <linux/init.h>
29 #include <linux/slab.h>
30 #include <linux/usb.h>
31 #include <linux/usb/audio.h>
33 #include <sound/core.h>
34 #include <sound/control.h>
35 #include <sound/hwdep.h>
36 #include <sound/info.h>
40 #include "mixer_quirks.h"
43 extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl;
45 struct std_mono_table {
46 unsigned int unitid, control, cmask;
49 snd_kcontrol_tlv_rw_t *tlv_callback;
52 /* private_free callback */
53 static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
55 kfree(kctl->private_data);
56 kctl->private_data = NULL;
59 /* This function allows for the creation of standard UAC controls.
60 * See the quirks for M-Audio FTUs or Ebox-44.
61 * If you don't want to set a TLV callback pass NULL.
63 * Since there doesn't seem to be a devices that needs a multichannel
64 * version, we keep it mono for simplicity.
66 static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
72 snd_kcontrol_tlv_rw_t *tlv_callback)
75 struct usb_mixer_elem_info *cval;
76 struct snd_kcontrol *kctl;
78 cval = kzalloc(sizeof(*cval), GFP_KERNEL);
84 cval->val_type = val_type;
86 cval->control = control;
89 /* get_min_max() is called only for integer volumes later,
90 * so provide a short-cut for booleans */
98 kctl = snd_ctl_new1(snd_usb_feature_unit_ctl, cval);
105 snprintf(kctl->id.name, sizeof(kctl->id.name), name);
106 kctl->private_free = usb_mixer_elem_free;
110 kctl->tlv.c = tlv_callback;
111 kctl->vd[0].access |=
112 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
113 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
115 /* Add control to mixer */
116 err = snd_usb_mixer_add_control(mixer, kctl);
124 * Create a set of standard UAC controls from a table
126 static int snd_create_std_mono_table(struct usb_mixer_interface *mixer,
127 struct std_mono_table *t)
131 while (t->name != NULL) {
132 err = snd_create_std_mono_ctl(mixer, t->unitid, t->control,
133 t->cmask, t->val_type, t->name, t->tlv_callback);
143 * Sound Blaster remote control configuration
145 * format of remote control data:
147 * Audigy 2 NX: 06 80 xx 00 00 00
148 * Live! 24-bit: 06 80 xx yy 22 83
150 static const struct rc_config {
155 u8 min_packet_length; /* minimum accepted length of the URB result */
159 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
160 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
161 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
162 { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
163 { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
164 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
167 static void snd_usb_soundblaster_remote_complete(struct urb *urb)
169 struct usb_mixer_interface *mixer = urb->context;
170 const struct rc_config *rc = mixer->rc_cfg;
173 if (urb->status < 0 || urb->actual_length < rc->min_packet_length)
176 code = mixer->rc_buffer[rc->offset];
178 code |= mixer->rc_buffer[rc->offset + 1] << 8;
180 /* the Mute button actually changes the mixer control */
181 if (code == rc->mute_code)
182 snd_usb_mixer_notify_id(mixer, rc->mute_mixer_id);
183 mixer->rc_code = code;
185 wake_up(&mixer->rc_waitq);
188 static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf,
189 long count, loff_t *offset)
191 struct usb_mixer_interface *mixer = hw->private_data;
195 if (count != 1 && count != 4)
197 err = wait_event_interruptible(mixer->rc_waitq,
198 (rc_code = xchg(&mixer->rc_code, 0)) != 0);
201 err = put_user(rc_code, buf);
203 err = put_user(rc_code, (u32 __user *)buf);
205 return err < 0 ? err : count;
208 static unsigned int snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file,
211 struct usb_mixer_interface *mixer = hw->private_data;
213 poll_wait(file, &mixer->rc_waitq, wait);
214 return mixer->rc_code ? POLLIN | POLLRDNORM : 0;
217 static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
219 struct snd_hwdep *hwdep;
222 for (i = 0; i < ARRAY_SIZE(rc_configs); ++i)
223 if (rc_configs[i].usb_id == mixer->chip->usb_id)
225 if (i >= ARRAY_SIZE(rc_configs))
227 mixer->rc_cfg = &rc_configs[i];
229 len = mixer->rc_cfg->packet_length;
231 init_waitqueue_head(&mixer->rc_waitq);
232 err = snd_hwdep_new(mixer->chip->card, "SB remote control", 0, &hwdep);
235 snprintf(hwdep->name, sizeof(hwdep->name),
236 "%s remote control", mixer->chip->card->shortname);
237 hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC;
238 hwdep->private_data = mixer;
239 hwdep->ops.read = snd_usb_sbrc_hwdep_read;
240 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
241 hwdep->exclusive = 1;
243 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
246 mixer->rc_setup_packet = kmalloc(sizeof(*mixer->rc_setup_packet), GFP_KERNEL);
247 if (!mixer->rc_setup_packet) {
248 usb_free_urb(mixer->rc_urb);
249 mixer->rc_urb = NULL;
252 mixer->rc_setup_packet->bRequestType =
253 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
254 mixer->rc_setup_packet->bRequest = UAC_GET_MEM;
255 mixer->rc_setup_packet->wValue = cpu_to_le16(0);
256 mixer->rc_setup_packet->wIndex = cpu_to_le16(0);
257 mixer->rc_setup_packet->wLength = cpu_to_le16(len);
258 usb_fill_control_urb(mixer->rc_urb, mixer->chip->dev,
259 usb_rcvctrlpipe(mixer->chip->dev, 0),
260 (u8*)mixer->rc_setup_packet, mixer->rc_buffer, len,
261 snd_usb_soundblaster_remote_complete, mixer);
265 #define snd_audigy2nx_led_info snd_ctl_boolean_mono_info
267 static int snd_audigy2nx_led_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
269 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
270 int index = kcontrol->private_value;
272 ucontrol->value.integer.value[0] = mixer->audigy2nx_leds[index];
276 static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
278 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
279 int index = kcontrol->private_value;
280 int value = ucontrol->value.integer.value[0];
285 changed = value != mixer->audigy2nx_leds[index];
286 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3042))
287 err = snd_usb_ctl_msg(mixer->chip->dev,
288 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
289 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
291 /* USB X-Fi S51 Pro */
292 if (mixer->chip->usb_id == USB_ID(0x041e, 0x30df))
293 err = snd_usb_ctl_msg(mixer->chip->dev,
294 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
295 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
298 err = snd_usb_ctl_msg(mixer->chip->dev,
299 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
300 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
301 value, index + 2, NULL, 0);
304 mixer->audigy2nx_leds[index] = value;
308 static struct snd_kcontrol_new snd_audigy2nx_controls[] = {
310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
311 .name = "CMSS LED Switch",
312 .info = snd_audigy2nx_led_info,
313 .get = snd_audigy2nx_led_get,
314 .put = snd_audigy2nx_led_put,
318 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
319 .name = "Power LED Switch",
320 .info = snd_audigy2nx_led_info,
321 .get = snd_audigy2nx_led_get,
322 .put = snd_audigy2nx_led_put,
326 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
327 .name = "Dolby Digital LED Switch",
328 .info = snd_audigy2nx_led_info,
329 .get = snd_audigy2nx_led_get,
330 .put = snd_audigy2nx_led_put,
335 static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
339 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) {
340 /* USB X-Fi S51 doesn't have a CMSS LED */
341 if ((mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) && i == 0)
343 /* USB X-Fi S51 Pro doesn't have one either */
344 if ((mixer->chip->usb_id == USB_ID(0x041e, 0x30df)) && i == 0)
346 if (i > 1 && /* Live24ext has 2 LEDs only */
347 (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
348 mixer->chip->usb_id == USB_ID(0x041e, 0x3042) ||
349 mixer->chip->usb_id == USB_ID(0x041e, 0x30df) ||
350 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
352 err = snd_ctl_add(mixer->chip->card,
353 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer));
357 mixer->audigy2nx_leds[1] = 1; /* Power LED is on by default */
361 static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
362 struct snd_info_buffer *buffer)
364 static const struct sb_jack {
367 } jacks_audigy2nx[] = {
373 }, jacks_live24ext[] = {
374 {4, "line in"}, /* &1=Line, &2=Mic*/
375 {3, "hph out"}, /* headphones */
376 {0, "RC "}, /* last command, 6 bytes see rc_config above */
379 const struct sb_jack *jacks;
380 struct usb_mixer_interface *mixer = entry->private_data;
384 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
385 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
386 jacks = jacks_audigy2nx;
387 else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
388 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
389 jacks = jacks_live24ext;
393 for (i = 0; jacks[i].name; ++i) {
394 snd_iprintf(buffer, "%s: ", jacks[i].name);
395 err = snd_usb_ctl_msg(mixer->chip->dev,
396 usb_rcvctrlpipe(mixer->chip->dev, 0),
397 UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
398 USB_RECIP_INTERFACE, 0,
399 jacks[i].unitid << 8, buf, 3);
400 if (err == 3 && (buf[0] == 3 || buf[0] == 6))
401 snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]);
403 snd_iprintf(buffer, "?\n");
407 static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol)
410 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
412 ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02);
416 static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_value *ucontrol)
419 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
420 u8 old_status, new_status;
423 old_status = mixer->xonar_u1_status;
424 if (ucontrol->value.integer.value[0])
425 new_status = old_status | 0x02;
427 new_status = old_status & ~0x02;
428 changed = new_status != old_status;
429 err = snd_usb_ctl_msg(mixer->chip->dev,
430 usb_sndctrlpipe(mixer->chip->dev, 0), 0x08,
431 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
432 50, 0, &new_status, 1);
435 mixer->xonar_u1_status = new_status;
439 static struct snd_kcontrol_new snd_xonar_u1_output_switch = {
440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
441 .name = "Digital Playback Switch",
442 .info = snd_ctl_boolean_mono_info,
443 .get = snd_xonar_u1_switch_get,
444 .put = snd_xonar_u1_switch_put,
447 static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer)
451 err = snd_ctl_add(mixer->chip->card,
452 snd_ctl_new1(&snd_xonar_u1_output_switch, mixer));
455 mixer->xonar_u1_status = 0x05;
459 /* Native Instruments device quirks */
461 #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
463 static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_value *ucontrol)
466 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
467 struct usb_device *dev = mixer->chip->dev;
468 u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
469 u16 wIndex = kcontrol->private_value & 0xffff;
472 int ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest,
473 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
474 0, cpu_to_le16(wIndex),
475 &tmp, sizeof(tmp), 1000);
479 "unable to issue vendor read request (ret = %d)", ret);
483 ucontrol->value.integer.value[0] = tmp;
488 static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
489 struct snd_ctl_elem_value *ucontrol)
491 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
492 struct usb_device *dev = mixer->chip->dev;
493 u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
494 u16 wIndex = kcontrol->private_value & 0xffff;
495 u16 wValue = ucontrol->value.integer.value[0];
497 int ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest,
498 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
499 cpu_to_le16(wValue), cpu_to_le16(wIndex),
504 "unable to issue vendor write request (ret = %d)", ret);
511 static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = {
513 .name = "Direct Thru Channel A",
514 .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
517 .name = "Direct Thru Channel B",
518 .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
521 .name = "Phono Input Channel A",
522 .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
525 .name = "Phono Input Channel B",
526 .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
530 static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = {
532 .name = "Direct Thru Channel A",
533 .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
536 .name = "Direct Thru Channel B",
537 .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
540 .name = "Direct Thru Channel C",
541 .private_value = _MAKE_NI_CONTROL(0x01, 0x07),
544 .name = "Direct Thru Channel D",
545 .private_value = _MAKE_NI_CONTROL(0x01, 0x09),
548 .name = "Phono Input Channel A",
549 .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
552 .name = "Phono Input Channel B",
553 .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
556 .name = "Phono Input Channel C",
557 .private_value = _MAKE_NI_CONTROL(0x02, 0x07),
560 .name = "Phono Input Channel D",
561 .private_value = _MAKE_NI_CONTROL(0x02, 0x09),
565 static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
566 const struct snd_kcontrol_new *kc,
570 struct snd_kcontrol_new template = {
571 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
572 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
573 .get = snd_nativeinstruments_control_get,
574 .put = snd_nativeinstruments_control_put,
575 .info = snd_ctl_boolean_mono_info,
578 for (i = 0; i < count; i++) {
579 struct snd_kcontrol *c;
581 template.name = kc[i].name;
582 template.private_value = kc[i].private_value;
584 c = snd_ctl_new1(&template, mixer);
585 err = snd_ctl_add(mixer->chip->card, c);
594 /* M-Audio FastTrack Ultra quirks */
595 /* FTU Effect switch */
596 struct snd_ftu_eff_switch_priv_val {
597 struct usb_mixer_interface *mixer;
602 static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_info *uinfo)
605 static const char *texts[8] = {"Room 1",
615 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
617 uinfo->value.enumerated.items = 8;
618 if (uinfo->value.enumerated.item > 7)
619 uinfo->value.enumerated.item = 7;
620 strcpy(uinfo->value.enumerated.name,
621 texts[uinfo->value.enumerated.item]);
626 static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
627 struct snd_ctl_elem_value *ucontrol)
629 struct snd_usb_audio *chip;
630 struct usb_mixer_interface *mixer;
631 struct snd_ftu_eff_switch_priv_val *pval;
633 unsigned char value[2];
636 const int validx = 1;
637 const int val_len = 2;
642 pval = (struct snd_ftu_eff_switch_priv_val *)
645 if (pval->is_cached) {
646 ucontrol->value.enumerated.item[0] = pval->cached_value;
650 mixer = (struct usb_mixer_interface *) pval->mixer;
651 if (snd_BUG_ON(!mixer))
654 chip = (struct snd_usb_audio *) mixer->chip;
655 if (snd_BUG_ON(!chip))
659 err = snd_usb_ctl_msg(chip->dev,
660 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
661 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
662 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
667 ucontrol->value.enumerated.item[0] = value[0];
668 pval->cached_value = value[0];
674 static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
675 struct snd_ctl_elem_value *ucontrol)
677 struct snd_usb_audio *chip;
678 struct snd_ftu_eff_switch_priv_val *pval;
680 struct usb_mixer_interface *mixer;
681 int changed, cur_val, err, new_val;
682 unsigned char value[2];
686 const int validx = 1;
687 const int val_len = 2;
691 pval = (struct snd_ftu_eff_switch_priv_val *)
693 cur_val = pval->cached_value;
694 new_val = ucontrol->value.enumerated.item[0];
696 mixer = (struct usb_mixer_interface *) pval->mixer;
697 if (snd_BUG_ON(!mixer))
700 chip = (struct snd_usb_audio *) mixer->chip;
701 if (snd_BUG_ON(!chip))
704 if (!pval->is_cached) {
705 /* Read current value */
706 err = snd_usb_ctl_msg(chip->dev,
707 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
708 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
709 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
715 pval->cached_value = cur_val;
718 /* update value if needed */
719 if (cur_val != new_val) {
722 err = snd_usb_ctl_msg(chip->dev,
723 usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
724 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
725 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
730 pval->cached_value = new_val;
738 static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer)
740 static struct snd_kcontrol_new template = {
741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
742 .name = "Effect Program Switch",
744 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
745 .info = snd_ftu_eff_switch_info,
746 .get = snd_ftu_eff_switch_get,
747 .put = snd_ftu_eff_switch_put
751 struct snd_kcontrol *kctl;
752 struct snd_ftu_eff_switch_priv_val *pval;
754 pval = kzalloc(sizeof(*pval), GFP_KERNEL);
758 pval->cached_value = 0;
762 template.private_value = (unsigned long) pval;
763 kctl = snd_ctl_new1(&template, mixer->chip);
769 err = snd_ctl_add(mixer->chip->card, kctl);
776 /* Create volume controls for FTU devices*/
777 static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
780 unsigned int control, cmask;
783 const unsigned int id = 5;
784 const int val_type = USB_MIXER_S16;
786 for (out = 0; out < 8; out++) {
788 for (in = 0; in < 8; in++) {
790 snprintf(name, sizeof(name),
791 "AIn%d - Out%d Capture Volume",
793 err = snd_create_std_mono_ctl(mixer, id, control,
794 cmask, val_type, name,
795 &snd_usb_mixer_vol_tlv);
799 for (in = 8; in < 16; in++) {
801 snprintf(name, sizeof(name),
802 "DIn%d - Out%d Playback Volume",
804 err = snd_create_std_mono_ctl(mixer, id, control,
805 cmask, val_type, name,
806 &snd_usb_mixer_vol_tlv);
815 /* This control needs a volume quirk, see mixer.c */
816 static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
818 static const char name[] = "Effect Volume";
819 const unsigned int id = 6;
820 const int val_type = USB_MIXER_U8;
821 const unsigned int control = 2;
822 const unsigned int cmask = 0;
824 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
825 name, snd_usb_mixer_vol_tlv);
828 /* This control needs a volume quirk, see mixer.c */
829 static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
831 static const char name[] = "Effect Duration";
832 const unsigned int id = 6;
833 const int val_type = USB_MIXER_S16;
834 const unsigned int control = 3;
835 const unsigned int cmask = 0;
837 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
838 name, snd_usb_mixer_vol_tlv);
841 /* This control needs a volume quirk, see mixer.c */
842 static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
844 static const char name[] = "Effect Feedback Volume";
845 const unsigned int id = 6;
846 const int val_type = USB_MIXER_U8;
847 const unsigned int control = 4;
848 const unsigned int cmask = 0;
850 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
854 static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer)
860 const unsigned int id = 7;
861 const int val_type = USB_MIXER_S16;
862 const unsigned int control = 7;
864 for (ch = 0; ch < 4; ++ch) {
866 snprintf(name, sizeof(name),
867 "Effect Return %d Volume", ch + 1);
868 err = snd_create_std_mono_ctl(mixer, id, control,
869 cmask, val_type, name,
870 snd_usb_mixer_vol_tlv);
878 static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
884 const unsigned int id = 5;
885 const int val_type = USB_MIXER_S16;
886 const unsigned int control = 9;
888 for (ch = 0; ch < 8; ++ch) {
890 snprintf(name, sizeof(name),
891 "Effect Send AIn%d Volume", ch + 1);
892 err = snd_create_std_mono_ctl(mixer, id, control, cmask,
894 snd_usb_mixer_vol_tlv);
898 for (ch = 8; ch < 16; ++ch) {
900 snprintf(name, sizeof(name),
901 "Effect Send DIn%d Volume", ch - 7);
902 err = snd_create_std_mono_ctl(mixer, id, control, cmask,
904 snd_usb_mixer_vol_tlv);
911 static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
915 err = snd_ftu_create_volume_ctls(mixer);
919 err = snd_ftu_create_effect_switch(mixer);
922 err = snd_ftu_create_effect_volume_ctl(mixer);
926 err = snd_ftu_create_effect_duration_ctl(mixer);
930 err = snd_ftu_create_effect_feedback_ctl(mixer);
934 err = snd_ftu_create_effect_return_ctls(mixer);
938 err = snd_ftu_create_effect_send_ctls(mixer);
945 void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
946 unsigned char samplerate_id)
948 struct usb_mixer_interface *mixer;
949 struct usb_mixer_elem_info *cval;
950 int unitid = 12; /* SamleRate ExtensionUnit ID */
952 list_for_each_entry(mixer, &chip->mixer_list, list) {
953 cval = mixer->id_elems[unitid];
955 snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
958 snd_usb_mixer_notify_id(mixer, unitid);
965 * The mixer units for Ebox-44 are corrupt, and even where they
966 * are valid they presents mono controls as L and R channels of
967 * stereo. So we provide a good mixer here.
969 struct std_mono_table ebox44_table[] = {
974 .val_type = USB_MIXER_INV_BOOLEAN,
975 .name = "Headphone Playback Switch"
981 .val_type = USB_MIXER_S16,
982 .name = "Headphone A Mix Playback Volume"
988 .val_type = USB_MIXER_S16,
989 .name = "Headphone B Mix Playback Volume"
996 .val_type = USB_MIXER_INV_BOOLEAN,
997 .name = "Output Playback Switch"
1003 .val_type = USB_MIXER_S16,
1004 .name = "Output A Playback Volume"
1010 .val_type = USB_MIXER_S16,
1011 .name = "Output B Playback Volume"
1018 .val_type = USB_MIXER_INV_BOOLEAN,
1019 .name = "Input Capture Switch"
1025 .val_type = USB_MIXER_S16,
1026 .name = "Input A Capture Volume"
1032 .val_type = USB_MIXER_S16,
1033 .name = "Input B Capture Volume"
1039 int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
1042 struct snd_info_entry *entry;
1044 if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
1047 switch (mixer->chip->usb_id) {
1048 case USB_ID(0x041e, 0x3020):
1049 case USB_ID(0x041e, 0x3040):
1050 case USB_ID(0x041e, 0x3042):
1051 case USB_ID(0x041e, 0x30df):
1052 case USB_ID(0x041e, 0x3048):
1053 err = snd_audigy2nx_controls_create(mixer);
1056 if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
1057 snd_info_set_text_ops(entry, mixer,
1058 snd_audigy2nx_proc_read);
1061 case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
1062 case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
1063 err = snd_ftu_create_mixer(mixer);
1066 case USB_ID(0x0b05, 0x1739):
1067 case USB_ID(0x0b05, 0x1743):
1068 err = snd_xonar_u1_controls_create(mixer);
1071 case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
1072 err = snd_nativeinstruments_create_mixer(mixer,
1073 snd_nativeinstruments_ta6_mixers,
1074 ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
1077 case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
1078 err = snd_nativeinstruments_create_mixer(mixer,
1079 snd_nativeinstruments_ta10_mixers,
1080 ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
1083 case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
1084 /* detection is disabled in mixer_maps.c */
1085 err = snd_create_std_mono_table(mixer, ebox44_table);
1092 void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
1097 /* unit ids specific to Extigy/Audigy 2 NX: */
1099 case 0: /* remote control */
1100 mixer->rc_urb->dev = mixer->chip->dev;
1101 usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
1103 case 4: /* digital in jack */
1104 case 7: /* line in jacks */
1105 case 19: /* speaker out jacks */
1106 case 20: /* headphones out jack */
1108 /* live24ext: 4 = line-in jack */
1109 case 3: /* hp-out jack (may actuate Mute) */
1110 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1111 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1112 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
1115 snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid);