ALSA: hda - Check validity of CORB/RIRB WP reads
[deliverable/linux.git] / sound / usb / mixer_quirks.c
CommitLineData
7b1eda22
DM
1/*
2 * USB Audio Driver for ALSA
3 *
4 * Quirks and vendor-specific extensions for mixer interfaces
5 *
6 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
7 *
8 * Many codes borrowed from audio.c by
9 * Alan Cox (alan@lxorguk.ukuu.org.uk)
10 * Thomas Sailer (sailer@ife.ee.ethz.ch)
11 *
12 *
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.
17 *
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.
22 *
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
26 */
27
28#include <linux/init.h>
36db0456 29#include <linux/slab.h>
7b1eda22
DM
30#include <linux/usb.h>
31#include <linux/usb/audio.h>
32
33#include <sound/core.h>
34#include <sound/control.h>
35#include <sound/hwdep.h>
36#include <sound/info.h>
37
38#include "usbaudio.h"
f0b5e634 39#include "mixer.h"
7b1eda22
DM
40#include "mixer_quirks.h"
41#include "helper.h"
42
d5a0bf6c
DM
43extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl;
44
b71dad18
MH
45struct std_mono_table {
46 unsigned int unitid, control, cmask;
47 int val_type;
48 const char *name;
49 snd_kcontrol_tlv_rw_t *tlv_callback;
50};
51
8a4d1d39
FH
52/* private_free callback */
53static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
54{
55 kfree(kctl->private_data);
56 kctl->private_data = NULL;
57}
58
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.
62 *
63 * Since there doesn't seem to be a devices that needs a multichannel
64 * version, we keep it mono for simplicity.
65 */
9f814105 66static int snd_create_std_mono_ctl_offset(struct usb_mixer_interface *mixer,
8a4d1d39
FH
67 unsigned int unitid,
68 unsigned int control,
69 unsigned int cmask,
70 int val_type,
9f814105 71 unsigned int idx_off,
8a4d1d39
FH
72 const char *name,
73 snd_kcontrol_tlv_rw_t *tlv_callback)
74{
75 int err;
76 struct usb_mixer_elem_info *cval;
77 struct snd_kcontrol *kctl;
78
79 cval = kzalloc(sizeof(*cval), GFP_KERNEL);
80 if (!cval)
81 return -ENOMEM;
82
83 cval->id = unitid;
84 cval->mixer = mixer;
85 cval->val_type = val_type;
86 cval->channels = 1;
87 cval->control = control;
88 cval->cmask = cmask;
9f814105 89 cval->idx_off = idx_off;
8a4d1d39 90
7df4a691
MH
91 /* get_min_max() is called only for integer volumes later,
92 * so provide a short-cut for booleans */
8a4d1d39
FH
93 cval->min = 0;
94 cval->max = 1;
95 cval->res = 0;
96 cval->dBmin = 0;
97 cval->dBmax = 0;
98
99 /* Create control */
100 kctl = snd_ctl_new1(snd_usb_feature_unit_ctl, cval);
101 if (!kctl) {
102 kfree(cval);
103 return -ENOMEM;
104 }
105
106 /* Set name */
107 snprintf(kctl->id.name, sizeof(kctl->id.name), name);
108 kctl->private_free = usb_mixer_elem_free;
109
110 /* set TLV */
111 if (tlv_callback) {
112 kctl->tlv.c = tlv_callback;
113 kctl->vd[0].access |=
114 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
115 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
116 }
117 /* Add control to mixer */
118 err = snd_usb_mixer_add_control(mixer, kctl);
119 if (err < 0)
120 return err;
121
122 return 0;
123}
124
9f814105
EZ
125static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
126 unsigned int unitid,
127 unsigned int control,
128 unsigned int cmask,
129 int val_type,
130 const char *name,
131 snd_kcontrol_tlv_rw_t *tlv_callback)
132{
133 return snd_create_std_mono_ctl_offset(mixer, unitid, control, cmask,
134 val_type, 0 /* Offset */, name, tlv_callback);
135}
136
b71dad18
MH
137/*
138 * Create a set of standard UAC controls from a table
139 */
140static int snd_create_std_mono_table(struct usb_mixer_interface *mixer,
141 struct std_mono_table *t)
142{
143 int err;
144
145 while (t->name != NULL) {
146 err = snd_create_std_mono_ctl(mixer, t->unitid, t->control,
147 t->cmask, t->val_type, t->name, t->tlv_callback);
148 if (err < 0)
149 return err;
150 t++;
151 }
152
153 return 0;
154}
155
7b1eda22
DM
156/*
157 * Sound Blaster remote control configuration
158 *
159 * format of remote control data:
160 * Extigy: xx 00
161 * Audigy 2 NX: 06 80 xx 00 00 00
162 * Live! 24-bit: 06 80 xx yy 22 83
163 */
164static const struct rc_config {
165 u32 usb_id;
166 u8 offset;
167 u8 length;
168 u8 packet_length;
169 u8 min_packet_length; /* minimum accepted length of the URB result */
170 u8 mute_mixer_id;
171 u32 mute_code;
172} rc_configs[] = {
173 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
174 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
175 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
ca8dc34e 176 { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
7cdd8d73 177 { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
7b1eda22
DM
178 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
179};
180
181static void snd_usb_soundblaster_remote_complete(struct urb *urb)
182{
183 struct usb_mixer_interface *mixer = urb->context;
184 const struct rc_config *rc = mixer->rc_cfg;
185 u32 code;
186
187 if (urb->status < 0 || urb->actual_length < rc->min_packet_length)
188 return;
189
190 code = mixer->rc_buffer[rc->offset];
191 if (rc->length == 2)
192 code |= mixer->rc_buffer[rc->offset + 1] << 8;
193
194 /* the Mute button actually changes the mixer control */
195 if (code == rc->mute_code)
196 snd_usb_mixer_notify_id(mixer, rc->mute_mixer_id);
197 mixer->rc_code = code;
198 wmb();
199 wake_up(&mixer->rc_waitq);
200}
201
202static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf,
203 long count, loff_t *offset)
204{
205 struct usb_mixer_interface *mixer = hw->private_data;
206 int err;
207 u32 rc_code;
208
209 if (count != 1 && count != 4)
210 return -EINVAL;
211 err = wait_event_interruptible(mixer->rc_waitq,
212 (rc_code = xchg(&mixer->rc_code, 0)) != 0);
213 if (err == 0) {
214 if (count == 1)
215 err = put_user(rc_code, buf);
216 else
217 err = put_user(rc_code, (u32 __user *)buf);
218 }
219 return err < 0 ? err : count;
220}
221
222static unsigned int snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file,
223 poll_table *wait)
224{
225 struct usb_mixer_interface *mixer = hw->private_data;
226
227 poll_wait(file, &mixer->rc_waitq, wait);
228 return mixer->rc_code ? POLLIN | POLLRDNORM : 0;
229}
230
231static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
232{
233 struct snd_hwdep *hwdep;
234 int err, len, i;
235
236 for (i = 0; i < ARRAY_SIZE(rc_configs); ++i)
237 if (rc_configs[i].usb_id == mixer->chip->usb_id)
238 break;
239 if (i >= ARRAY_SIZE(rc_configs))
240 return 0;
241 mixer->rc_cfg = &rc_configs[i];
242
243 len = mixer->rc_cfg->packet_length;
244
245 init_waitqueue_head(&mixer->rc_waitq);
246 err = snd_hwdep_new(mixer->chip->card, "SB remote control", 0, &hwdep);
247 if (err < 0)
248 return err;
249 snprintf(hwdep->name, sizeof(hwdep->name),
250 "%s remote control", mixer->chip->card->shortname);
251 hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC;
252 hwdep->private_data = mixer;
253 hwdep->ops.read = snd_usb_sbrc_hwdep_read;
254 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
255 hwdep->exclusive = 1;
256
257 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
258 if (!mixer->rc_urb)
259 return -ENOMEM;
260 mixer->rc_setup_packet = kmalloc(sizeof(*mixer->rc_setup_packet), GFP_KERNEL);
261 if (!mixer->rc_setup_packet) {
262 usb_free_urb(mixer->rc_urb);
263 mixer->rc_urb = NULL;
264 return -ENOMEM;
265 }
266 mixer->rc_setup_packet->bRequestType =
267 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
268 mixer->rc_setup_packet->bRequest = UAC_GET_MEM;
269 mixer->rc_setup_packet->wValue = cpu_to_le16(0);
270 mixer->rc_setup_packet->wIndex = cpu_to_le16(0);
271 mixer->rc_setup_packet->wLength = cpu_to_le16(len);
272 usb_fill_control_urb(mixer->rc_urb, mixer->chip->dev,
273 usb_rcvctrlpipe(mixer->chip->dev, 0),
274 (u8*)mixer->rc_setup_packet, mixer->rc_buffer, len,
275 snd_usb_soundblaster_remote_complete, mixer);
276 return 0;
277}
278
279#define snd_audigy2nx_led_info snd_ctl_boolean_mono_info
280
281static int snd_audigy2nx_led_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
282{
283 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
284 int index = kcontrol->private_value;
285
286 ucontrol->value.integer.value[0] = mixer->audigy2nx_leds[index];
287 return 0;
288}
289
290static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
291{
292 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
293 int index = kcontrol->private_value;
294 int value = ucontrol->value.integer.value[0];
295 int err, changed;
296
297 if (value > 1)
298 return -EINVAL;
299 changed = value != mixer->audigy2nx_leds[index];
888ea7d5
TI
300 down_read(&mixer->chip->shutdown_rwsem);
301 if (mixer->chip->shutdown) {
302 err = -ENODEV;
303 goto out;
304 }
ca8dc34e
MJ
305 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3042))
306 err = snd_usb_ctl_msg(mixer->chip->dev,
307 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
308 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
17d900c4 309 !value, 0, NULL, 0);
7cdd8d73
MB
310 /* USB X-Fi S51 Pro */
311 if (mixer->chip->usb_id == USB_ID(0x041e, 0x30df))
312 err = snd_usb_ctl_msg(mixer->chip->dev,
313 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
314 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
17d900c4 315 !value, 0, NULL, 0);
ca8dc34e
MJ
316 else
317 err = snd_usb_ctl_msg(mixer->chip->dev,
7b1eda22
DM
318 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
319 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
17d900c4 320 value, index + 2, NULL, 0);
888ea7d5
TI
321 out:
322 up_read(&mixer->chip->shutdown_rwsem);
7b1eda22
DM
323 if (err < 0)
324 return err;
325 mixer->audigy2nx_leds[index] = value;
326 return changed;
327}
328
329static struct snd_kcontrol_new snd_audigy2nx_controls[] = {
330 {
331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
332 .name = "CMSS LED Switch",
333 .info = snd_audigy2nx_led_info,
334 .get = snd_audigy2nx_led_get,
335 .put = snd_audigy2nx_led_put,
336 .private_value = 0,
337 },
338 {
339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
340 .name = "Power LED Switch",
341 .info = snd_audigy2nx_led_info,
342 .get = snd_audigy2nx_led_get,
343 .put = snd_audigy2nx_led_put,
344 .private_value = 1,
345 },
346 {
347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
348 .name = "Dolby Digital LED Switch",
349 .info = snd_audigy2nx_led_info,
350 .get = snd_audigy2nx_led_get,
351 .put = snd_audigy2nx_led_put,
352 .private_value = 2,
353 },
354};
355
356static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
357{
358 int i, err;
359
360 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) {
ca8dc34e
MJ
361 /* USB X-Fi S51 doesn't have a CMSS LED */
362 if ((mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) && i == 0)
363 continue;
7cdd8d73
MB
364 /* USB X-Fi S51 Pro doesn't have one either */
365 if ((mixer->chip->usb_id == USB_ID(0x041e, 0x30df)) && i == 0)
366 continue;
7b1eda22
DM
367 if (i > 1 && /* Live24ext has 2 LEDs only */
368 (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
ca8dc34e 369 mixer->chip->usb_id == USB_ID(0x041e, 0x3042) ||
7cdd8d73 370 mixer->chip->usb_id == USB_ID(0x041e, 0x30df) ||
7b1eda22
DM
371 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
372 break;
373 err = snd_ctl_add(mixer->chip->card,
374 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer));
375 if (err < 0)
376 return err;
377 }
378 mixer->audigy2nx_leds[1] = 1; /* Power LED is on by default */
379 return 0;
380}
381
382static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
383 struct snd_info_buffer *buffer)
384{
385 static const struct sb_jack {
386 int unitid;
387 const char *name;
388 } jacks_audigy2nx[] = {
389 {4, "dig in "},
390 {7, "line in"},
391 {19, "spk out"},
392 {20, "hph out"},
393 {-1, NULL}
394 }, jacks_live24ext[] = {
395 {4, "line in"}, /* &1=Line, &2=Mic*/
396 {3, "hph out"}, /* headphones */
397 {0, "RC "}, /* last command, 6 bytes see rc_config above */
398 {-1, NULL}
399 };
400 const struct sb_jack *jacks;
401 struct usb_mixer_interface *mixer = entry->private_data;
402 int i, err;
403 u8 buf[3];
404
405 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
406 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
407 jacks = jacks_audigy2nx;
408 else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
409 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
410 jacks = jacks_live24ext;
411 else
412 return;
413
414 for (i = 0; jacks[i].name; ++i) {
415 snd_iprintf(buffer, "%s: ", jacks[i].name);
888ea7d5
TI
416 down_read(&mixer->chip->shutdown_rwsem);
417 if (mixer->chip->shutdown)
418 err = 0;
419 else
420 err = snd_usb_ctl_msg(mixer->chip->dev,
7b1eda22
DM
421 usb_rcvctrlpipe(mixer->chip->dev, 0),
422 UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
423 USB_RECIP_INTERFACE, 0,
17d900c4 424 jacks[i].unitid << 8, buf, 3);
888ea7d5 425 up_read(&mixer->chip->shutdown_rwsem);
7b1eda22
DM
426 if (err == 3 && (buf[0] == 3 || buf[0] == 6))
427 snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]);
428 else
429 snd_iprintf(buffer, "?\n");
430 }
431}
432
433static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol,
434 struct snd_ctl_elem_value *ucontrol)
435{
436 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
437
438 ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02);
439 return 0;
440}
441
442static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
443 struct snd_ctl_elem_value *ucontrol)
444{
445 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
446 u8 old_status, new_status;
447 int err, changed;
448
449 old_status = mixer->xonar_u1_status;
450 if (ucontrol->value.integer.value[0])
451 new_status = old_status | 0x02;
452 else
453 new_status = old_status & ~0x02;
454 changed = new_status != old_status;
888ea7d5
TI
455 down_read(&mixer->chip->shutdown_rwsem);
456 if (mixer->chip->shutdown)
457 err = -ENODEV;
458 else
459 err = snd_usb_ctl_msg(mixer->chip->dev,
7b1eda22
DM
460 usb_sndctrlpipe(mixer->chip->dev, 0), 0x08,
461 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
17d900c4 462 50, 0, &new_status, 1);
888ea7d5 463 up_read(&mixer->chip->shutdown_rwsem);
7b1eda22
DM
464 if (err < 0)
465 return err;
466 mixer->xonar_u1_status = new_status;
467 return changed;
468}
469
470static struct snd_kcontrol_new snd_xonar_u1_output_switch = {
471 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
472 .name = "Digital Playback Switch",
473 .info = snd_ctl_boolean_mono_info,
474 .get = snd_xonar_u1_switch_get,
475 .put = snd_xonar_u1_switch_put,
476};
477
478static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer)
479{
480 int err;
481
482 err = snd_ctl_add(mixer->chip->card,
483 snd_ctl_new1(&snd_xonar_u1_output_switch, mixer));
484 if (err < 0)
485 return err;
486 mixer->xonar_u1_status = 0x05;
487 return 0;
488}
489
54a8c500
DM
490/* Native Instruments device quirks */
491
492#define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
493
494static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
495 struct snd_ctl_elem_value *ucontrol)
496{
497 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
498 struct usb_device *dev = mixer->chip->dev;
499 u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
500 u16 wIndex = kcontrol->private_value & 0xffff;
501 u8 tmp;
888ea7d5 502 int ret;
54a8c500 503
888ea7d5
TI
504 down_read(&mixer->chip->shutdown_rwsem);
505 if (mixer->chip->shutdown)
506 ret = -ENODEV;
507 else
508 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest,
54a8c500
DM
509 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
510 0, cpu_to_le16(wIndex),
511 &tmp, sizeof(tmp), 1000);
888ea7d5 512 up_read(&mixer->chip->shutdown_rwsem);
54a8c500
DM
513
514 if (ret < 0) {
515 snd_printk(KERN_ERR
516 "unable to issue vendor read request (ret = %d)", ret);
517 return ret;
518 }
519
520 ucontrol->value.integer.value[0] = tmp;
521
522 return 0;
523}
524
525static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
527{
528 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
529 struct usb_device *dev = mixer->chip->dev;
530 u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
531 u16 wIndex = kcontrol->private_value & 0xffff;
532 u16 wValue = ucontrol->value.integer.value[0];
888ea7d5 533 int ret;
54a8c500 534
888ea7d5
TI
535 down_read(&mixer->chip->shutdown_rwsem);
536 if (mixer->chip->shutdown)
537 ret = -ENODEV;
538 else
539 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest,
54a8c500
DM
540 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
541 cpu_to_le16(wValue), cpu_to_le16(wIndex),
542 NULL, 0, 1000);
888ea7d5 543 up_read(&mixer->chip->shutdown_rwsem);
54a8c500
DM
544
545 if (ret < 0) {
546 snd_printk(KERN_ERR
547 "unable to issue vendor write request (ret = %d)", ret);
548 return ret;
549 }
550
551 return 0;
552}
553
554static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = {
555 {
556 .name = "Direct Thru Channel A",
557 .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
558 },
559 {
560 .name = "Direct Thru Channel B",
561 .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
562 },
563 {
564 .name = "Phono Input Channel A",
565 .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
566 },
567 {
568 .name = "Phono Input Channel B",
569 .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
570 },
571};
572
573static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = {
574 {
575 .name = "Direct Thru Channel A",
576 .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
577 },
578 {
579 .name = "Direct Thru Channel B",
580 .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
581 },
582 {
583 .name = "Direct Thru Channel C",
584 .private_value = _MAKE_NI_CONTROL(0x01, 0x07),
585 },
586 {
587 .name = "Direct Thru Channel D",
588 .private_value = _MAKE_NI_CONTROL(0x01, 0x09),
589 },
590 {
591 .name = "Phono Input Channel A",
592 .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
593 },
594 {
595 .name = "Phono Input Channel B",
596 .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
597 },
598 {
599 .name = "Phono Input Channel C",
600 .private_value = _MAKE_NI_CONTROL(0x02, 0x07),
601 },
602 {
603 .name = "Phono Input Channel D",
604 .private_value = _MAKE_NI_CONTROL(0x02, 0x09),
605 },
606};
607
608static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
609 const struct snd_kcontrol_new *kc,
610 unsigned int count)
611{
612 int i, err = 0;
613 struct snd_kcontrol_new template = {
614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
615 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
616 .get = snd_nativeinstruments_control_get,
617 .put = snd_nativeinstruments_control_put,
618 .info = snd_ctl_boolean_mono_info,
619 };
620
621 for (i = 0; i < count; i++) {
622 struct snd_kcontrol *c;
623
624 template.name = kc[i].name;
625 template.private_value = kc[i].private_value;
626
627 c = snd_ctl_new1(&template, mixer);
628 err = snd_ctl_add(mixer->chip->card, c);
629
630 if (err < 0)
631 break;
632 }
633
634 return err;
635}
636
d5a0bf6c 637/* M-Audio FastTrack Ultra quirks */
d847ce0e 638/* FTU Effect switch (also used by C400) */
d34bf148
FH
639struct snd_ftu_eff_switch_priv_val {
640 struct usb_mixer_interface *mixer;
641 int cached_value;
642 int is_cached;
d847ce0e
EZ
643 int bUnitID;
644 int validx;
d34bf148
FH
645};
646
647static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
648 struct snd_ctl_elem_info *uinfo)
649{
650 static const char *texts[8] = {"Room 1",
651 "Room 2",
652 "Room 3",
653 "Hall 1",
654 "Hall 2",
655 "Plate",
656 "Delay",
657 "Echo"
658 };
659
660 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
661 uinfo->count = 1;
662 uinfo->value.enumerated.items = 8;
663 if (uinfo->value.enumerated.item > 7)
664 uinfo->value.enumerated.item = 7;
665 strcpy(uinfo->value.enumerated.name,
666 texts[uinfo->value.enumerated.item]);
667
668 return 0;
669}
670
671static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
672 struct snd_ctl_elem_value *ucontrol)
673{
674 struct snd_usb_audio *chip;
675 struct usb_mixer_interface *mixer;
676 struct snd_ftu_eff_switch_priv_val *pval;
677 int err;
678 unsigned char value[2];
d847ce0e 679 int id, validx;
d34bf148 680
d34bf148
FH
681 const int val_len = 2;
682
683 value[0] = 0x00;
684 value[1] = 0x00;
685
686 pval = (struct snd_ftu_eff_switch_priv_val *)
687 kctl->private_value;
688
689 if (pval->is_cached) {
690 ucontrol->value.enumerated.item[0] = pval->cached_value;
691 return 0;
692 }
693
694 mixer = (struct usb_mixer_interface *) pval->mixer;
695 if (snd_BUG_ON(!mixer))
696 return -EINVAL;
697
698 chip = (struct snd_usb_audio *) mixer->chip;
699 if (snd_BUG_ON(!chip))
700 return -EINVAL;
701
d847ce0e
EZ
702 id = pval->bUnitID;
703 validx = pval->validx;
d34bf148 704
888ea7d5
TI
705 down_read(&mixer->chip->shutdown_rwsem);
706 if (mixer->chip->shutdown)
707 err = -ENODEV;
708 else
709 err = snd_usb_ctl_msg(chip->dev,
d34bf148
FH
710 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
711 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
712 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
713 value, val_len);
888ea7d5 714 up_read(&mixer->chip->shutdown_rwsem);
d34bf148
FH
715 if (err < 0)
716 return err;
717
718 ucontrol->value.enumerated.item[0] = value[0];
719 pval->cached_value = value[0];
720 pval->is_cached = 1;
721
722 return 0;
723}
724
725static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
726 struct snd_ctl_elem_value *ucontrol)
727{
728 struct snd_usb_audio *chip;
729 struct snd_ftu_eff_switch_priv_val *pval;
730
731 struct usb_mixer_interface *mixer;
732 int changed, cur_val, err, new_val;
733 unsigned char value[2];
d847ce0e 734 int id, validx;
d34bf148 735
d34bf148
FH
736 const int val_len = 2;
737
738 changed = 0;
739
740 pval = (struct snd_ftu_eff_switch_priv_val *)
741 kctl->private_value;
742 cur_val = pval->cached_value;
743 new_val = ucontrol->value.enumerated.item[0];
744
745 mixer = (struct usb_mixer_interface *) pval->mixer;
746 if (snd_BUG_ON(!mixer))
747 return -EINVAL;
748
749 chip = (struct snd_usb_audio *) mixer->chip;
750 if (snd_BUG_ON(!chip))
751 return -EINVAL;
752
d847ce0e
EZ
753 id = pval->bUnitID;
754 validx = pval->validx;
755
d34bf148
FH
756 if (!pval->is_cached) {
757 /* Read current value */
888ea7d5
TI
758 down_read(&mixer->chip->shutdown_rwsem);
759 if (mixer->chip->shutdown)
760 err = -ENODEV;
761 else
762 err = snd_usb_ctl_msg(chip->dev,
d34bf148
FH
763 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
764 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
765 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
766 value, val_len);
888ea7d5 767 up_read(&mixer->chip->shutdown_rwsem);
d34bf148
FH
768 if (err < 0)
769 return err;
770
771 cur_val = value[0];
772 pval->cached_value = cur_val;
773 pval->is_cached = 1;
774 }
775 /* update value if needed */
776 if (cur_val != new_val) {
777 value[0] = new_val;
778 value[1] = 0;
888ea7d5
TI
779 down_read(&mixer->chip->shutdown_rwsem);
780 if (mixer->chip->shutdown)
781 err = -ENODEV;
782 else
783 err = snd_usb_ctl_msg(chip->dev,
d34bf148
FH
784 usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
785 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
786 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
787 value, val_len);
888ea7d5 788 up_read(&mixer->chip->shutdown_rwsem);
d34bf148
FH
789 if (err < 0)
790 return err;
791
792 pval->cached_value = new_val;
793 pval->is_cached = 1;
794 changed = 1;
795 }
796
797 return changed;
798}
799
d847ce0e
EZ
800static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
801 int validx, int bUnitID)
d34bf148
FH
802{
803 static struct snd_kcontrol_new template = {
804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
805 .name = "Effect Program Switch",
806 .index = 0,
807 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
808 .info = snd_ftu_eff_switch_info,
809 .get = snd_ftu_eff_switch_get,
810 .put = snd_ftu_eff_switch_put
811 };
812
813 int err;
814 struct snd_kcontrol *kctl;
815 struct snd_ftu_eff_switch_priv_val *pval;
816
817 pval = kzalloc(sizeof(*pval), GFP_KERNEL);
818 if (!pval)
819 return -ENOMEM;
820
821 pval->cached_value = 0;
822 pval->is_cached = 0;
823 pval->mixer = mixer;
d847ce0e
EZ
824 pval->bUnitID = bUnitID;
825 pval->validx = validx;
d34bf148
FH
826
827 template.private_value = (unsigned long) pval;
828 kctl = snd_ctl_new1(&template, mixer->chip);
829 if (!kctl) {
830 kfree(pval);
831 return -ENOMEM;
832 }
833
834 err = snd_ctl_add(mixer->chip->card, kctl);
835 if (err < 0)
836 return err;
837
838 return 0;
839}
d5a0bf6c 840
cfe8f97c
FH
841/* Create volume controls for FTU devices*/
842static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
d5a0bf6c
DM
843{
844 char name[64];
8a4d1d39 845 unsigned int control, cmask;
d5a0bf6c
DM
846 int in, out, err;
847
8a4d1d39
FH
848 const unsigned int id = 5;
849 const int val_type = USB_MIXER_S16;
850
d5a0bf6c 851 for (out = 0; out < 8; out++) {
8a4d1d39 852 control = out + 1;
d5a0bf6c 853 for (in = 0; in < 8; in++) {
8a4d1d39 854 cmask = 1 << in;
d5a0bf6c 855 snprintf(name, sizeof(name),
8a4d1d39
FH
856 "AIn%d - Out%d Capture Volume",
857 in + 1, out + 1);
858 err = snd_create_std_mono_ctl(mixer, id, control,
859 cmask, val_type, name,
25ee7ef8 860 &snd_usb_mixer_vol_tlv);
d5a0bf6c
DM
861 if (err < 0)
862 return err;
863 }
d5a0bf6c 864 for (in = 8; in < 16; in++) {
8a4d1d39 865 cmask = 1 << in;
d5a0bf6c 866 snprintf(name, sizeof(name),
8a4d1d39
FH
867 "DIn%d - Out%d Playback Volume",
868 in - 7, out + 1);
869 err = snd_create_std_mono_ctl(mixer, id, control,
870 cmask, val_type, name,
25ee7ef8 871 &snd_usb_mixer_vol_tlv);
d5a0bf6c
DM
872 if (err < 0)
873 return err;
874 }
875 }
876
877 return 0;
878}
879
d34bf148
FH
880/* This control needs a volume quirk, see mixer.c */
881static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
882{
883 static const char name[] = "Effect Volume";
884 const unsigned int id = 6;
885 const int val_type = USB_MIXER_U8;
886 const unsigned int control = 2;
887 const unsigned int cmask = 0;
888
889 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
890 name, snd_usb_mixer_vol_tlv);
891}
892
893/* This control needs a volume quirk, see mixer.c */
894static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
895{
896 static const char name[] = "Effect Duration";
897 const unsigned int id = 6;
898 const int val_type = USB_MIXER_S16;
899 const unsigned int control = 3;
900 const unsigned int cmask = 0;
901
902 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
903 name, snd_usb_mixer_vol_tlv);
904}
905
906/* This control needs a volume quirk, see mixer.c */
907static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
908{
909 static const char name[] = "Effect Feedback Volume";
910 const unsigned int id = 6;
911 const int val_type = USB_MIXER_U8;
912 const unsigned int control = 4;
913 const unsigned int cmask = 0;
914
915 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
916 name, NULL);
917}
918
919static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer)
920{
921 unsigned int cmask;
922 int err, ch;
923 char name[48];
924
925 const unsigned int id = 7;
926 const int val_type = USB_MIXER_S16;
927 const unsigned int control = 7;
928
929 for (ch = 0; ch < 4; ++ch) {
930 cmask = 1 << ch;
931 snprintf(name, sizeof(name),
932 "Effect Return %d Volume", ch + 1);
933 err = snd_create_std_mono_ctl(mixer, id, control,
934 cmask, val_type, name,
935 snd_usb_mixer_vol_tlv);
936 if (err < 0)
937 return err;
938 }
939
940 return 0;
941}
942
943static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
944{
945 unsigned int cmask;
946 int err, ch;
947 char name[48];
948
949 const unsigned int id = 5;
950 const int val_type = USB_MIXER_S16;
951 const unsigned int control = 9;
952
953 for (ch = 0; ch < 8; ++ch) {
954 cmask = 1 << ch;
955 snprintf(name, sizeof(name),
956 "Effect Send AIn%d Volume", ch + 1);
957 err = snd_create_std_mono_ctl(mixer, id, control, cmask,
958 val_type, name,
959 snd_usb_mixer_vol_tlv);
960 if (err < 0)
961 return err;
962 }
963 for (ch = 8; ch < 16; ++ch) {
964 cmask = 1 << ch;
965 snprintf(name, sizeof(name),
966 "Effect Send DIn%d Volume", ch - 7);
967 err = snd_create_std_mono_ctl(mixer, id, control, cmask,
968 val_type, name,
969 snd_usb_mixer_vol_tlv);
970 if (err < 0)
971 return err;
972 }
973 return 0;
974}
975
cfe8f97c 976static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
7536c301 977{
8a4d1d39 978 int err;
7536c301 979
cfe8f97c 980 err = snd_ftu_create_volume_ctls(mixer);
8a4d1d39
FH
981 if (err < 0)
982 return err;
7536c301 983
d847ce0e 984 err = snd_ftu_create_effect_switch(mixer, 1, 6);
d34bf148
FH
985 if (err < 0)
986 return err;
d847ce0e 987
d34bf148
FH
988 err = snd_ftu_create_effect_volume_ctl(mixer);
989 if (err < 0)
990 return err;
991
992 err = snd_ftu_create_effect_duration_ctl(mixer);
993 if (err < 0)
994 return err;
995
996 err = snd_ftu_create_effect_feedback_ctl(mixer);
997 if (err < 0)
998 return err;
999
1000 err = snd_ftu_create_effect_return_ctls(mixer);
1001 if (err < 0)
1002 return err;
1003
1004 err = snd_ftu_create_effect_send_ctls(mixer);
1005 if (err < 0)
1006 return err;
1007
8a4d1d39 1008 return 0;
7536c301
MH
1009}
1010
7b1eda22
DM
1011void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
1012 unsigned char samplerate_id)
1013{
1014 struct usb_mixer_interface *mixer;
1015 struct usb_mixer_elem_info *cval;
1016 int unitid = 12; /* SamleRate ExtensionUnit ID */
1017
1018 list_for_each_entry(mixer, &chip->mixer_list, list) {
1019 cval = mixer->id_elems[unitid];
1020 if (cval) {
1021 snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
1022 cval->control << 8,
1023 samplerate_id);
1024 snd_usb_mixer_notify_id(mixer, unitid);
1025 }
1026 break;
1027 }
1028}
1029
09d8e3a7
EZ
1030/* M-Audio Fast Track C400 */
1031/* C400 volume controls, this control needs a volume quirk, see mixer.c */
1032static int snd_c400_create_vol_ctls(struct usb_mixer_interface *mixer)
1033{
1034 char name[64];
1035 unsigned int cmask, offset;
1036 int out, chan, err;
1037
1038 const unsigned int id = 0x40;
1039 const int val_type = USB_MIXER_S16;
1040 const int control = 1;
1041
1042 for (chan = 0; chan < 10; chan++) {
1043 for (out = 0; out < 6; out++) {
1044 if (chan < 6) {
1045 snprintf(name, sizeof(name),
1046 "PCM%d-Out%d Playback Volume",
1047 chan + 1, out + 1);
1048 } else {
1049 snprintf(name, sizeof(name),
1050 "In%d-Out%d Playback Volume",
1051 chan - 5, out + 1);
1052 }
1053
1054 cmask = (out == 0) ? 0 : 1 << (out - 1);
1055 offset = chan * 6;
1056 err = snd_create_std_mono_ctl_offset(mixer, id, control,
1057 cmask, val_type, offset, name,
1058 &snd_usb_mixer_vol_tlv);
1059 if (err < 0)
1060 return err;
1061 }
1062 }
1063
1064 return 0;
1065}
1066
1067/* This control needs a volume quirk, see mixer.c */
1068static int snd_c400_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
1069{
1070 static const char name[] = "Effect Volume";
1071 const unsigned int id = 0x43;
1072 const int val_type = USB_MIXER_U8;
1073 const unsigned int control = 3;
1074 const unsigned int cmask = 0;
1075
1076 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
1077 name, snd_usb_mixer_vol_tlv);
1078}
1079
1080/* This control needs a volume quirk, see mixer.c */
1081static int snd_c400_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
1082{
1083 static const char name[] = "Effect Duration";
1084 const unsigned int id = 0x43;
1085 const int val_type = USB_MIXER_S16;
1086 const unsigned int control = 4;
1087 const unsigned int cmask = 0;
1088
1089 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
1090 name, snd_usb_mixer_vol_tlv);
1091}
1092
1093/* This control needs a volume quirk, see mixer.c */
1094static int snd_c400_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
1095{
1096 static const char name[] = "Effect Feedback Volume";
1097 const unsigned int id = 0x43;
1098 const int val_type = USB_MIXER_U8;
1099 const unsigned int control = 5;
1100 const unsigned int cmask = 0;
1101
1102 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
1103 name, NULL);
1104}
1105
1106static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface *mixer)
1107{
1108 char name[64];
1109 unsigned int cmask;
1110 int chan, err;
1111
1112 const unsigned int id = 0x42;
1113 const int val_type = USB_MIXER_S16;
1114 const int control = 1;
1115
1116 for (chan = 0; chan < 10; chan++) {
1117 if (chan < 6) {
1118 snprintf(name, sizeof(name),
1119 "Effect Send DOut%d",
1120 chan + 1);
1121 } else {
1122 snprintf(name, sizeof(name),
1123 "Effect Send AIn%d",
1124 chan - 5);
1125 }
1126
1127 cmask = (chan == 0) ? 0 : 1 << (chan - 1);
1128 err = snd_create_std_mono_ctl(mixer, id, control,
1129 cmask, val_type, name,
1130 &snd_usb_mixer_vol_tlv);
1131 if (err < 0)
1132 return err;
1133 }
1134
1135 return 0;
1136}
1137
1138static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface *mixer)
1139{
1140 char name[64];
1141 unsigned int cmask;
1142 int chan, err;
1143
1144 const unsigned int id = 0x40;
1145 const int val_type = USB_MIXER_S16;
1146 const int control = 1;
1147 const int chan_id[6] = { 0, 7, 2, 9, 4, 0xb };
1148 const unsigned int offset = 0x3c;
1149 /* { 0x3c, 0x43, 0x3e, 0x45, 0x40, 0x47 } */
1150
1151 for (chan = 0; chan < 6; chan++) {
1152 snprintf(name, sizeof(name),
1153 "Effect Return %d",
1154 chan + 1);
1155
1156 cmask = (chan_id[chan] == 0) ? 0 : 1 << (chan_id[chan] - 1);
1157 err = snd_create_std_mono_ctl_offset(mixer, id, control,
1158 cmask, val_type, offset, name,
1159 &snd_usb_mixer_vol_tlv);
1160 if (err < 0)
1161 return err;
1162 }
1163
1164 return 0;
1165}
1166
1167static int snd_c400_create_mixer(struct usb_mixer_interface *mixer)
1168{
1169 int err;
1170
1171 err = snd_c400_create_vol_ctls(mixer);
1172 if (err < 0)
1173 return err;
1174
1175 err = snd_c400_create_effect_vol_ctls(mixer);
1176 if (err < 0)
1177 return err;
1178
1179 err = snd_c400_create_effect_ret_vol_ctls(mixer);
1180 if (err < 0)
1181 return err;
1182
1183 err = snd_ftu_create_effect_switch(mixer, 2, 0x43);
1184 if (err < 0)
1185 return err;
1186
1187 err = snd_c400_create_effect_volume_ctl(mixer);
1188 if (err < 0)
1189 return err;
1190
1191 err = snd_c400_create_effect_duration_ctl(mixer);
1192 if (err < 0)
1193 return err;
1194
1195 err = snd_c400_create_effect_feedback_ctl(mixer);
1196 if (err < 0)
1197 return err;
1198
1199 return 0;
1200}
1201
b71dad18
MH
1202/*
1203 * The mixer units for Ebox-44 are corrupt, and even where they
1204 * are valid they presents mono controls as L and R channels of
1205 * stereo. So we provide a good mixer here.
1206 */
1207struct std_mono_table ebox44_table[] = {
989b0138
MH
1208 {
1209 .unitid = 4,
1210 .control = 1,
1211 .cmask = 0x0,
1212 .val_type = USB_MIXER_INV_BOOLEAN,
1213 .name = "Headphone Playback Switch"
1214 },
1215 {
1216 .unitid = 4,
1217 .control = 2,
1218 .cmask = 0x1,
1219 .val_type = USB_MIXER_S16,
1220 .name = "Headphone A Mix Playback Volume"
1221 },
1222 {
1223 .unitid = 4,
1224 .control = 2,
1225 .cmask = 0x2,
1226 .val_type = USB_MIXER_S16,
1227 .name = "Headphone B Mix Playback Volume"
1228 },
b71dad18 1229
989b0138
MH
1230 {
1231 .unitid = 7,
1232 .control = 1,
1233 .cmask = 0x0,
1234 .val_type = USB_MIXER_INV_BOOLEAN,
1235 .name = "Output Playback Switch"
1236 },
1237 {
1238 .unitid = 7,
1239 .control = 2,
1240 .cmask = 0x1,
1241 .val_type = USB_MIXER_S16,
1242 .name = "Output A Playback Volume"
1243 },
1244 {
1245 .unitid = 7,
1246 .control = 2,
1247 .cmask = 0x2,
1248 .val_type = USB_MIXER_S16,
1249 .name = "Output B Playback Volume"
1250 },
b71dad18 1251
989b0138
MH
1252 {
1253 .unitid = 10,
1254 .control = 1,
1255 .cmask = 0x0,
1256 .val_type = USB_MIXER_INV_BOOLEAN,
1257 .name = "Input Capture Switch"
1258 },
1259 {
1260 .unitid = 10,
1261 .control = 2,
1262 .cmask = 0x1,
1263 .val_type = USB_MIXER_S16,
1264 .name = "Input A Capture Volume"
1265 },
1266 {
1267 .unitid = 10,
1268 .control = 2,
1269 .cmask = 0x2,
1270 .val_type = USB_MIXER_S16,
1271 .name = "Input B Capture Volume"
1272 },
b71dad18 1273
989b0138 1274 {}
b71dad18
MH
1275};
1276
7b1eda22
DM
1277int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
1278{
3347b26c 1279 int err = 0;
7b1eda22
DM
1280 struct snd_info_entry *entry;
1281
1282 if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
1283 return err;
1284
3347b26c
DM
1285 switch (mixer->chip->usb_id) {
1286 case USB_ID(0x041e, 0x3020):
1287 case USB_ID(0x041e, 0x3040):
1288 case USB_ID(0x041e, 0x3042):
7cdd8d73 1289 case USB_ID(0x041e, 0x30df):
3347b26c
DM
1290 case USB_ID(0x041e, 0x3048):
1291 err = snd_audigy2nx_controls_create(mixer);
1292 if (err < 0)
1293 break;
7b1eda22
DM
1294 if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
1295 snd_info_set_text_ops(entry, mixer,
1296 snd_audigy2nx_proc_read);
3347b26c 1297 break;
7b1eda22 1298
09d8e3a7
EZ
1299 case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
1300 err = snd_c400_create_mixer(mixer);
1301 break;
1302
d5a0bf6c
DM
1303 case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
1304 case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
cfe8f97c 1305 err = snd_ftu_create_mixer(mixer);
d5a0bf6c
DM
1306 break;
1307
3347b26c
DM
1308 case USB_ID(0x0b05, 0x1739):
1309 case USB_ID(0x0b05, 0x1743):
7b1eda22 1310 err = snd_xonar_u1_controls_create(mixer);
3347b26c 1311 break;
7b1eda22 1312
3347b26c 1313 case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
54a8c500
DM
1314 err = snd_nativeinstruments_create_mixer(mixer,
1315 snd_nativeinstruments_ta6_mixers,
1316 ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
3347b26c 1317 break;
54a8c500 1318
3347b26c 1319 case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
54a8c500
DM
1320 err = snd_nativeinstruments_create_mixer(mixer,
1321 snd_nativeinstruments_ta10_mixers,
1322 ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
3347b26c 1323 break;
7536c301
MH
1324
1325 case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
b71dad18
MH
1326 /* detection is disabled in mixer_maps.c */
1327 err = snd_create_std_mono_table(mixer, ebox44_table);
7536c301 1328 break;
54a8c500
DM
1329 }
1330
3347b26c 1331 return err;
7b1eda22
DM
1332}
1333
1334void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
1335 int unitid)
1336{
1337 if (!mixer->rc_cfg)
1338 return;
1339 /* unit ids specific to Extigy/Audigy 2 NX: */
1340 switch (unitid) {
1341 case 0: /* remote control */
1342 mixer->rc_urb->dev = mixer->chip->dev;
1343 usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
1344 break;
1345 case 4: /* digital in jack */
1346 case 7: /* line in jacks */
1347 case 19: /* speaker out jacks */
1348 case 20: /* headphones out jack */
1349 break;
1350 /* live24ext: 4 = line-in jack */
1351 case 3: /* hp-out jack (may actuate Mute) */
1352 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1353 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1354 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
1355 break;
1356 default:
1357 snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid);
1358 break;
1359 }
1360}
1361
This page took 0.14504 seconds and 5 git commands to generate.