Merge branch 'timer/cleanup' into late/mvebu2
[GitHub/mt8127/android_kernel_alcatel_ttab.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
1d31affb
DW
433/* ASUS Xonar U1 / U3 controls */
434
7b1eda22
DM
435static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_value *ucontrol)
437{
438 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
439
440 ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02);
441 return 0;
442}
443
444static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_value *ucontrol)
446{
447 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
448 u8 old_status, new_status;
449 int err, changed;
450
451 old_status = mixer->xonar_u1_status;
452 if (ucontrol->value.integer.value[0])
453 new_status = old_status | 0x02;
454 else
455 new_status = old_status & ~0x02;
456 changed = new_status != old_status;
888ea7d5
TI
457 down_read(&mixer->chip->shutdown_rwsem);
458 if (mixer->chip->shutdown)
459 err = -ENODEV;
460 else
461 err = snd_usb_ctl_msg(mixer->chip->dev,
7b1eda22
DM
462 usb_sndctrlpipe(mixer->chip->dev, 0), 0x08,
463 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
17d900c4 464 50, 0, &new_status, 1);
888ea7d5 465 up_read(&mixer->chip->shutdown_rwsem);
7b1eda22
DM
466 if (err < 0)
467 return err;
468 mixer->xonar_u1_status = new_status;
469 return changed;
470}
471
472static struct snd_kcontrol_new snd_xonar_u1_output_switch = {
473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
474 .name = "Digital Playback Switch",
475 .info = snd_ctl_boolean_mono_info,
476 .get = snd_xonar_u1_switch_get,
477 .put = snd_xonar_u1_switch_put,
478};
479
480static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer)
481{
482 int err;
483
484 err = snd_ctl_add(mixer->chip->card,
485 snd_ctl_new1(&snd_xonar_u1_output_switch, mixer));
486 if (err < 0)
487 return err;
488 mixer->xonar_u1_status = 0x05;
489 return 0;
490}
491
54a8c500
DM
492/* Native Instruments device quirks */
493
494#define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
495
496static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
497 struct snd_ctl_elem_value *ucontrol)
498{
499 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
500 struct usb_device *dev = mixer->chip->dev;
501 u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
502 u16 wIndex = kcontrol->private_value & 0xffff;
503 u8 tmp;
888ea7d5 504 int ret;
54a8c500 505
888ea7d5
TI
506 down_read(&mixer->chip->shutdown_rwsem);
507 if (mixer->chip->shutdown)
508 ret = -ENODEV;
509 else
510 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest,
54a8c500
DM
511 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
512 0, cpu_to_le16(wIndex),
513 &tmp, sizeof(tmp), 1000);
888ea7d5 514 up_read(&mixer->chip->shutdown_rwsem);
54a8c500
DM
515
516 if (ret < 0) {
517 snd_printk(KERN_ERR
518 "unable to issue vendor read request (ret = %d)", ret);
519 return ret;
520 }
521
522 ucontrol->value.integer.value[0] = tmp;
523
524 return 0;
525}
526
527static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
528 struct snd_ctl_elem_value *ucontrol)
529{
530 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
531 struct usb_device *dev = mixer->chip->dev;
532 u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
533 u16 wIndex = kcontrol->private_value & 0xffff;
534 u16 wValue = ucontrol->value.integer.value[0];
888ea7d5 535 int ret;
54a8c500 536
888ea7d5
TI
537 down_read(&mixer->chip->shutdown_rwsem);
538 if (mixer->chip->shutdown)
539 ret = -ENODEV;
540 else
541 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest,
54a8c500
DM
542 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
543 cpu_to_le16(wValue), cpu_to_le16(wIndex),
544 NULL, 0, 1000);
888ea7d5 545 up_read(&mixer->chip->shutdown_rwsem);
54a8c500
DM
546
547 if (ret < 0) {
548 snd_printk(KERN_ERR
549 "unable to issue vendor write request (ret = %d)", ret);
550 return ret;
551 }
552
553 return 0;
554}
555
556static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = {
557 {
558 .name = "Direct Thru Channel A",
559 .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
560 },
561 {
562 .name = "Direct Thru Channel B",
563 .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
564 },
565 {
566 .name = "Phono Input Channel A",
567 .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
568 },
569 {
570 .name = "Phono Input Channel B",
571 .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
572 },
573};
574
575static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = {
576 {
577 .name = "Direct Thru Channel A",
578 .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
579 },
580 {
581 .name = "Direct Thru Channel B",
582 .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
583 },
584 {
585 .name = "Direct Thru Channel C",
586 .private_value = _MAKE_NI_CONTROL(0x01, 0x07),
587 },
588 {
589 .name = "Direct Thru Channel D",
590 .private_value = _MAKE_NI_CONTROL(0x01, 0x09),
591 },
592 {
593 .name = "Phono Input Channel A",
594 .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
595 },
596 {
597 .name = "Phono Input Channel B",
598 .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
599 },
600 {
601 .name = "Phono Input Channel C",
602 .private_value = _MAKE_NI_CONTROL(0x02, 0x07),
603 },
604 {
605 .name = "Phono Input Channel D",
606 .private_value = _MAKE_NI_CONTROL(0x02, 0x09),
607 },
608};
609
610static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
611 const struct snd_kcontrol_new *kc,
612 unsigned int count)
613{
614 int i, err = 0;
615 struct snd_kcontrol_new template = {
616 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
617 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
618 .get = snd_nativeinstruments_control_get,
619 .put = snd_nativeinstruments_control_put,
620 .info = snd_ctl_boolean_mono_info,
621 };
622
623 for (i = 0; i < count; i++) {
624 struct snd_kcontrol *c;
625
626 template.name = kc[i].name;
627 template.private_value = kc[i].private_value;
628
629 c = snd_ctl_new1(&template, mixer);
630 err = snd_ctl_add(mixer->chip->card, c);
631
632 if (err < 0)
633 break;
634 }
635
636 return err;
637}
638
d5a0bf6c 639/* M-Audio FastTrack Ultra quirks */
d847ce0e 640/* FTU Effect switch (also used by C400) */
d34bf148
FH
641struct snd_ftu_eff_switch_priv_val {
642 struct usb_mixer_interface *mixer;
643 int cached_value;
644 int is_cached;
d847ce0e
EZ
645 int bUnitID;
646 int validx;
d34bf148
FH
647};
648
649static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
650 struct snd_ctl_elem_info *uinfo)
651{
652 static const char *texts[8] = {"Room 1",
653 "Room 2",
654 "Room 3",
655 "Hall 1",
656 "Hall 2",
657 "Plate",
658 "Delay",
659 "Echo"
660 };
661
662 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
663 uinfo->count = 1;
664 uinfo->value.enumerated.items = 8;
665 if (uinfo->value.enumerated.item > 7)
666 uinfo->value.enumerated.item = 7;
667 strcpy(uinfo->value.enumerated.name,
668 texts[uinfo->value.enumerated.item]);
669
670 return 0;
671}
672
673static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
674 struct snd_ctl_elem_value *ucontrol)
675{
676 struct snd_usb_audio *chip;
677 struct usb_mixer_interface *mixer;
678 struct snd_ftu_eff_switch_priv_val *pval;
679 int err;
680 unsigned char value[2];
d847ce0e 681 int id, validx;
d34bf148 682
d34bf148
FH
683 const int val_len = 2;
684
685 value[0] = 0x00;
686 value[1] = 0x00;
687
688 pval = (struct snd_ftu_eff_switch_priv_val *)
689 kctl->private_value;
690
691 if (pval->is_cached) {
692 ucontrol->value.enumerated.item[0] = pval->cached_value;
693 return 0;
694 }
695
696 mixer = (struct usb_mixer_interface *) pval->mixer;
697 if (snd_BUG_ON(!mixer))
698 return -EINVAL;
699
700 chip = (struct snd_usb_audio *) mixer->chip;
701 if (snd_BUG_ON(!chip))
702 return -EINVAL;
703
d847ce0e
EZ
704 id = pval->bUnitID;
705 validx = pval->validx;
d34bf148 706
888ea7d5
TI
707 down_read(&mixer->chip->shutdown_rwsem);
708 if (mixer->chip->shutdown)
709 err = -ENODEV;
710 else
711 err = snd_usb_ctl_msg(chip->dev,
d34bf148
FH
712 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
713 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
714 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
715 value, val_len);
888ea7d5 716 up_read(&mixer->chip->shutdown_rwsem);
d34bf148
FH
717 if (err < 0)
718 return err;
719
720 ucontrol->value.enumerated.item[0] = value[0];
721 pval->cached_value = value[0];
722 pval->is_cached = 1;
723
724 return 0;
725}
726
727static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
728 struct snd_ctl_elem_value *ucontrol)
729{
730 struct snd_usb_audio *chip;
731 struct snd_ftu_eff_switch_priv_val *pval;
732
733 struct usb_mixer_interface *mixer;
734 int changed, cur_val, err, new_val;
735 unsigned char value[2];
d847ce0e 736 int id, validx;
d34bf148 737
d34bf148
FH
738 const int val_len = 2;
739
740 changed = 0;
741
742 pval = (struct snd_ftu_eff_switch_priv_val *)
743 kctl->private_value;
744 cur_val = pval->cached_value;
745 new_val = ucontrol->value.enumerated.item[0];
746
747 mixer = (struct usb_mixer_interface *) pval->mixer;
748 if (snd_BUG_ON(!mixer))
749 return -EINVAL;
750
751 chip = (struct snd_usb_audio *) mixer->chip;
752 if (snd_BUG_ON(!chip))
753 return -EINVAL;
754
d847ce0e
EZ
755 id = pval->bUnitID;
756 validx = pval->validx;
757
d34bf148
FH
758 if (!pval->is_cached) {
759 /* Read current value */
888ea7d5
TI
760 down_read(&mixer->chip->shutdown_rwsem);
761 if (mixer->chip->shutdown)
762 err = -ENODEV;
763 else
764 err = snd_usb_ctl_msg(chip->dev,
d34bf148
FH
765 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
766 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
767 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
768 value, val_len);
888ea7d5 769 up_read(&mixer->chip->shutdown_rwsem);
d34bf148
FH
770 if (err < 0)
771 return err;
772
773 cur_val = value[0];
774 pval->cached_value = cur_val;
775 pval->is_cached = 1;
776 }
777 /* update value if needed */
778 if (cur_val != new_val) {
779 value[0] = new_val;
780 value[1] = 0;
888ea7d5
TI
781 down_read(&mixer->chip->shutdown_rwsem);
782 if (mixer->chip->shutdown)
783 err = -ENODEV;
784 else
785 err = snd_usb_ctl_msg(chip->dev,
d34bf148
FH
786 usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
787 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
788 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
789 value, val_len);
888ea7d5 790 up_read(&mixer->chip->shutdown_rwsem);
d34bf148
FH
791 if (err < 0)
792 return err;
793
794 pval->cached_value = new_val;
795 pval->is_cached = 1;
796 changed = 1;
797 }
798
799 return changed;
800}
801
d847ce0e
EZ
802static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
803 int validx, int bUnitID)
d34bf148
FH
804{
805 static struct snd_kcontrol_new template = {
806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
807 .name = "Effect Program Switch",
808 .index = 0,
809 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
810 .info = snd_ftu_eff_switch_info,
811 .get = snd_ftu_eff_switch_get,
812 .put = snd_ftu_eff_switch_put
813 };
814
815 int err;
816 struct snd_kcontrol *kctl;
817 struct snd_ftu_eff_switch_priv_val *pval;
818
819 pval = kzalloc(sizeof(*pval), GFP_KERNEL);
820 if (!pval)
821 return -ENOMEM;
822
823 pval->cached_value = 0;
824 pval->is_cached = 0;
825 pval->mixer = mixer;
d847ce0e
EZ
826 pval->bUnitID = bUnitID;
827 pval->validx = validx;
d34bf148
FH
828
829 template.private_value = (unsigned long) pval;
830 kctl = snd_ctl_new1(&template, mixer->chip);
831 if (!kctl) {
832 kfree(pval);
833 return -ENOMEM;
834 }
835
836 err = snd_ctl_add(mixer->chip->card, kctl);
837 if (err < 0)
838 return err;
839
840 return 0;
841}
d5a0bf6c 842
cfe8f97c
FH
843/* Create volume controls for FTU devices*/
844static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
d5a0bf6c
DM
845{
846 char name[64];
8a4d1d39 847 unsigned int control, cmask;
d5a0bf6c
DM
848 int in, out, err;
849
8a4d1d39
FH
850 const unsigned int id = 5;
851 const int val_type = USB_MIXER_S16;
852
d5a0bf6c 853 for (out = 0; out < 8; out++) {
8a4d1d39 854 control = out + 1;
d5a0bf6c 855 for (in = 0; in < 8; in++) {
8a4d1d39 856 cmask = 1 << in;
d5a0bf6c 857 snprintf(name, sizeof(name),
8a4d1d39
FH
858 "AIn%d - Out%d Capture Volume",
859 in + 1, out + 1);
860 err = snd_create_std_mono_ctl(mixer, id, control,
861 cmask, val_type, name,
25ee7ef8 862 &snd_usb_mixer_vol_tlv);
d5a0bf6c
DM
863 if (err < 0)
864 return err;
865 }
d5a0bf6c 866 for (in = 8; in < 16; in++) {
8a4d1d39 867 cmask = 1 << in;
d5a0bf6c 868 snprintf(name, sizeof(name),
8a4d1d39
FH
869 "DIn%d - Out%d Playback Volume",
870 in - 7, out + 1);
871 err = snd_create_std_mono_ctl(mixer, id, control,
872 cmask, val_type, name,
25ee7ef8 873 &snd_usb_mixer_vol_tlv);
d5a0bf6c
DM
874 if (err < 0)
875 return err;
876 }
877 }
878
879 return 0;
880}
881
d34bf148
FH
882/* This control needs a volume quirk, see mixer.c */
883static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
884{
885 static const char name[] = "Effect Volume";
886 const unsigned int id = 6;
887 const int val_type = USB_MIXER_U8;
888 const unsigned int control = 2;
889 const unsigned int cmask = 0;
890
891 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
892 name, snd_usb_mixer_vol_tlv);
893}
894
895/* This control needs a volume quirk, see mixer.c */
896static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
897{
898 static const char name[] = "Effect Duration";
899 const unsigned int id = 6;
900 const int val_type = USB_MIXER_S16;
901 const unsigned int control = 3;
902 const unsigned int cmask = 0;
903
904 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
905 name, snd_usb_mixer_vol_tlv);
906}
907
908/* This control needs a volume quirk, see mixer.c */
909static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
910{
911 static const char name[] = "Effect Feedback Volume";
912 const unsigned int id = 6;
913 const int val_type = USB_MIXER_U8;
914 const unsigned int control = 4;
915 const unsigned int cmask = 0;
916
917 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
918 name, NULL);
919}
920
921static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer)
922{
923 unsigned int cmask;
924 int err, ch;
925 char name[48];
926
927 const unsigned int id = 7;
928 const int val_type = USB_MIXER_S16;
929 const unsigned int control = 7;
930
931 for (ch = 0; ch < 4; ++ch) {
932 cmask = 1 << ch;
933 snprintf(name, sizeof(name),
934 "Effect Return %d Volume", ch + 1);
935 err = snd_create_std_mono_ctl(mixer, id, control,
936 cmask, val_type, name,
937 snd_usb_mixer_vol_tlv);
938 if (err < 0)
939 return err;
940 }
941
942 return 0;
943}
944
945static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
946{
947 unsigned int cmask;
948 int err, ch;
949 char name[48];
950
951 const unsigned int id = 5;
952 const int val_type = USB_MIXER_S16;
953 const unsigned int control = 9;
954
955 for (ch = 0; ch < 8; ++ch) {
956 cmask = 1 << ch;
957 snprintf(name, sizeof(name),
958 "Effect Send AIn%d Volume", ch + 1);
959 err = snd_create_std_mono_ctl(mixer, id, control, cmask,
960 val_type, name,
961 snd_usb_mixer_vol_tlv);
962 if (err < 0)
963 return err;
964 }
965 for (ch = 8; ch < 16; ++ch) {
966 cmask = 1 << ch;
967 snprintf(name, sizeof(name),
968 "Effect Send DIn%d Volume", ch - 7);
969 err = snd_create_std_mono_ctl(mixer, id, control, cmask,
970 val_type, name,
971 snd_usb_mixer_vol_tlv);
972 if (err < 0)
973 return err;
974 }
975 return 0;
976}
977
cfe8f97c 978static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
7536c301 979{
8a4d1d39 980 int err;
7536c301 981
cfe8f97c 982 err = snd_ftu_create_volume_ctls(mixer);
8a4d1d39
FH
983 if (err < 0)
984 return err;
7536c301 985
d847ce0e 986 err = snd_ftu_create_effect_switch(mixer, 1, 6);
d34bf148
FH
987 if (err < 0)
988 return err;
d847ce0e 989
d34bf148
FH
990 err = snd_ftu_create_effect_volume_ctl(mixer);
991 if (err < 0)
992 return err;
993
994 err = snd_ftu_create_effect_duration_ctl(mixer);
995 if (err < 0)
996 return err;
997
998 err = snd_ftu_create_effect_feedback_ctl(mixer);
999 if (err < 0)
1000 return err;
1001
1002 err = snd_ftu_create_effect_return_ctls(mixer);
1003 if (err < 0)
1004 return err;
1005
1006 err = snd_ftu_create_effect_send_ctls(mixer);
1007 if (err < 0)
1008 return err;
1009
8a4d1d39 1010 return 0;
7536c301
MH
1011}
1012
7b1eda22
DM
1013void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
1014 unsigned char samplerate_id)
1015{
1016 struct usb_mixer_interface *mixer;
1017 struct usb_mixer_elem_info *cval;
1018 int unitid = 12; /* SamleRate ExtensionUnit ID */
1019
1020 list_for_each_entry(mixer, &chip->mixer_list, list) {
1021 cval = mixer->id_elems[unitid];
1022 if (cval) {
1023 snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
1024 cval->control << 8,
1025 samplerate_id);
1026 snd_usb_mixer_notify_id(mixer, unitid);
1027 }
1028 break;
1029 }
1030}
1031
09d8e3a7
EZ
1032/* M-Audio Fast Track C400 */
1033/* C400 volume controls, this control needs a volume quirk, see mixer.c */
1034static int snd_c400_create_vol_ctls(struct usb_mixer_interface *mixer)
1035{
1036 char name[64];
1037 unsigned int cmask, offset;
1038 int out, chan, err;
1039
1040 const unsigned int id = 0x40;
1041 const int val_type = USB_MIXER_S16;
1042 const int control = 1;
1043
1044 for (chan = 0; chan < 10; chan++) {
1045 for (out = 0; out < 6; out++) {
1046 if (chan < 6) {
1047 snprintf(name, sizeof(name),
1048 "PCM%d-Out%d Playback Volume",
1049 chan + 1, out + 1);
1050 } else {
1051 snprintf(name, sizeof(name),
1052 "In%d-Out%d Playback Volume",
1053 chan - 5, out + 1);
1054 }
1055
1056 cmask = (out == 0) ? 0 : 1 << (out - 1);
1057 offset = chan * 6;
1058 err = snd_create_std_mono_ctl_offset(mixer, id, control,
1059 cmask, val_type, offset, name,
1060 &snd_usb_mixer_vol_tlv);
1061 if (err < 0)
1062 return err;
1063 }
1064 }
1065
1066 return 0;
1067}
1068
1069/* This control needs a volume quirk, see mixer.c */
1070static int snd_c400_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
1071{
1072 static const char name[] = "Effect Volume";
1073 const unsigned int id = 0x43;
1074 const int val_type = USB_MIXER_U8;
1075 const unsigned int control = 3;
1076 const unsigned int cmask = 0;
1077
1078 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
1079 name, snd_usb_mixer_vol_tlv);
1080}
1081
1082/* This control needs a volume quirk, see mixer.c */
1083static int snd_c400_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
1084{
1085 static const char name[] = "Effect Duration";
1086 const unsigned int id = 0x43;
1087 const int val_type = USB_MIXER_S16;
1088 const unsigned int control = 4;
1089 const unsigned int cmask = 0;
1090
1091 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
1092 name, snd_usb_mixer_vol_tlv);
1093}
1094
1095/* This control needs a volume quirk, see mixer.c */
1096static int snd_c400_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
1097{
1098 static const char name[] = "Effect Feedback Volume";
1099 const unsigned int id = 0x43;
1100 const int val_type = USB_MIXER_U8;
1101 const unsigned int control = 5;
1102 const unsigned int cmask = 0;
1103
1104 return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
1105 name, NULL);
1106}
1107
1108static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface *mixer)
1109{
1110 char name[64];
1111 unsigned int cmask;
1112 int chan, err;
1113
1114 const unsigned int id = 0x42;
1115 const int val_type = USB_MIXER_S16;
1116 const int control = 1;
1117
1118 for (chan = 0; chan < 10; chan++) {
1119 if (chan < 6) {
1120 snprintf(name, sizeof(name),
1121 "Effect Send DOut%d",
1122 chan + 1);
1123 } else {
1124 snprintf(name, sizeof(name),
1125 "Effect Send AIn%d",
1126 chan - 5);
1127 }
1128
1129 cmask = (chan == 0) ? 0 : 1 << (chan - 1);
1130 err = snd_create_std_mono_ctl(mixer, id, control,
1131 cmask, val_type, name,
1132 &snd_usb_mixer_vol_tlv);
1133 if (err < 0)
1134 return err;
1135 }
1136
1137 return 0;
1138}
1139
1140static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface *mixer)
1141{
1142 char name[64];
1143 unsigned int cmask;
1144 int chan, err;
1145
1146 const unsigned int id = 0x40;
1147 const int val_type = USB_MIXER_S16;
1148 const int control = 1;
1149 const int chan_id[6] = { 0, 7, 2, 9, 4, 0xb };
1150 const unsigned int offset = 0x3c;
1151 /* { 0x3c, 0x43, 0x3e, 0x45, 0x40, 0x47 } */
1152
1153 for (chan = 0; chan < 6; chan++) {
1154 snprintf(name, sizeof(name),
1155 "Effect Return %d",
1156 chan + 1);
1157
1158 cmask = (chan_id[chan] == 0) ? 0 : 1 << (chan_id[chan] - 1);
1159 err = snd_create_std_mono_ctl_offset(mixer, id, control,
1160 cmask, val_type, offset, name,
1161 &snd_usb_mixer_vol_tlv);
1162 if (err < 0)
1163 return err;
1164 }
1165
1166 return 0;
1167}
1168
1169static int snd_c400_create_mixer(struct usb_mixer_interface *mixer)
1170{
1171 int err;
1172
1173 err = snd_c400_create_vol_ctls(mixer);
1174 if (err < 0)
1175 return err;
1176
1177 err = snd_c400_create_effect_vol_ctls(mixer);
1178 if (err < 0)
1179 return err;
1180
1181 err = snd_c400_create_effect_ret_vol_ctls(mixer);
1182 if (err < 0)
1183 return err;
1184
1185 err = snd_ftu_create_effect_switch(mixer, 2, 0x43);
1186 if (err < 0)
1187 return err;
1188
1189 err = snd_c400_create_effect_volume_ctl(mixer);
1190 if (err < 0)
1191 return err;
1192
1193 err = snd_c400_create_effect_duration_ctl(mixer);
1194 if (err < 0)
1195 return err;
1196
1197 err = snd_c400_create_effect_feedback_ctl(mixer);
1198 if (err < 0)
1199 return err;
1200
1201 return 0;
1202}
1203
b71dad18
MH
1204/*
1205 * The mixer units for Ebox-44 are corrupt, and even where they
1206 * are valid they presents mono controls as L and R channels of
1207 * stereo. So we provide a good mixer here.
1208 */
e8e7da23 1209static struct std_mono_table ebox44_table[] = {
989b0138
MH
1210 {
1211 .unitid = 4,
1212 .control = 1,
1213 .cmask = 0x0,
1214 .val_type = USB_MIXER_INV_BOOLEAN,
1215 .name = "Headphone Playback Switch"
1216 },
1217 {
1218 .unitid = 4,
1219 .control = 2,
1220 .cmask = 0x1,
1221 .val_type = USB_MIXER_S16,
1222 .name = "Headphone A Mix Playback Volume"
1223 },
1224 {
1225 .unitid = 4,
1226 .control = 2,
1227 .cmask = 0x2,
1228 .val_type = USB_MIXER_S16,
1229 .name = "Headphone B Mix Playback Volume"
1230 },
b71dad18 1231
989b0138
MH
1232 {
1233 .unitid = 7,
1234 .control = 1,
1235 .cmask = 0x0,
1236 .val_type = USB_MIXER_INV_BOOLEAN,
1237 .name = "Output Playback Switch"
1238 },
1239 {
1240 .unitid = 7,
1241 .control = 2,
1242 .cmask = 0x1,
1243 .val_type = USB_MIXER_S16,
1244 .name = "Output A Playback Volume"
1245 },
1246 {
1247 .unitid = 7,
1248 .control = 2,
1249 .cmask = 0x2,
1250 .val_type = USB_MIXER_S16,
1251 .name = "Output B Playback Volume"
1252 },
b71dad18 1253
989b0138
MH
1254 {
1255 .unitid = 10,
1256 .control = 1,
1257 .cmask = 0x0,
1258 .val_type = USB_MIXER_INV_BOOLEAN,
1259 .name = "Input Capture Switch"
1260 },
1261 {
1262 .unitid = 10,
1263 .control = 2,
1264 .cmask = 0x1,
1265 .val_type = USB_MIXER_S16,
1266 .name = "Input A Capture Volume"
1267 },
1268 {
1269 .unitid = 10,
1270 .control = 2,
1271 .cmask = 0x2,
1272 .val_type = USB_MIXER_S16,
1273 .name = "Input B Capture Volume"
1274 },
b71dad18 1275
989b0138 1276 {}
b71dad18
MH
1277};
1278
7b1eda22
DM
1279int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
1280{
3347b26c 1281 int err = 0;
7b1eda22
DM
1282 struct snd_info_entry *entry;
1283
1284 if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
1285 return err;
1286
3347b26c
DM
1287 switch (mixer->chip->usb_id) {
1288 case USB_ID(0x041e, 0x3020):
1289 case USB_ID(0x041e, 0x3040):
1290 case USB_ID(0x041e, 0x3042):
7cdd8d73 1291 case USB_ID(0x041e, 0x30df):
3347b26c
DM
1292 case USB_ID(0x041e, 0x3048):
1293 err = snd_audigy2nx_controls_create(mixer);
1294 if (err < 0)
1295 break;
7b1eda22
DM
1296 if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
1297 snd_info_set_text_ops(entry, mixer,
1298 snd_audigy2nx_proc_read);
3347b26c 1299 break;
7b1eda22 1300
09d8e3a7
EZ
1301 case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
1302 err = snd_c400_create_mixer(mixer);
1303 break;
1304
d5a0bf6c
DM
1305 case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
1306 case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
cfe8f97c 1307 err = snd_ftu_create_mixer(mixer);
d5a0bf6c
DM
1308 break;
1309
1d31affb
DW
1310 case USB_ID(0x0b05, 0x1739): /* ASUS Xonar U1 */
1311 case USB_ID(0x0b05, 0x1743): /* ASUS Xonar U1 (2) */
1312 case USB_ID(0x0b05, 0x17a0): /* ASUS Xonar U3 */
7b1eda22 1313 err = snd_xonar_u1_controls_create(mixer);
3347b26c 1314 break;
7b1eda22 1315
3347b26c 1316 case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
54a8c500
DM
1317 err = snd_nativeinstruments_create_mixer(mixer,
1318 snd_nativeinstruments_ta6_mixers,
1319 ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
3347b26c 1320 break;
54a8c500 1321
3347b26c 1322 case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
54a8c500
DM
1323 err = snd_nativeinstruments_create_mixer(mixer,
1324 snd_nativeinstruments_ta10_mixers,
1325 ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
3347b26c 1326 break;
7536c301
MH
1327
1328 case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
b71dad18
MH
1329 /* detection is disabled in mixer_maps.c */
1330 err = snd_create_std_mono_table(mixer, ebox44_table);
7536c301 1331 break;
54a8c500
DM
1332 }
1333
3347b26c 1334 return err;
7b1eda22
DM
1335}
1336
1337void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
1338 int unitid)
1339{
1340 if (!mixer->rc_cfg)
1341 return;
1342 /* unit ids specific to Extigy/Audigy 2 NX: */
1343 switch (unitid) {
1344 case 0: /* remote control */
1345 mixer->rc_urb->dev = mixer->chip->dev;
1346 usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
1347 break;
1348 case 4: /* digital in jack */
1349 case 7: /* line in jacks */
1350 case 19: /* speaker out jacks */
1351 case 20: /* headphones out jack */
1352 break;
1353 /* live24ext: 4 = line-in jack */
1354 case 3: /* hp-out jack (may actuate Mute) */
1355 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1356 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1357 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
1358 break;
1359 default:
1360 snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid);
1361 break;
1362 }
1363}
1364