1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * USB Audio Driver for ALSA
5 * Quirks and vendor-specific extensions for mixer interfaces
7 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
9 * Many codes borrowed from audio.c by
10 * Alan Cox (alan@lxorguk.ukuu.org.uk)
11 * Thomas Sailer (sailer@ife.ee.ethz.ch)
13 * Audio Advantage Micro II support added by:
14 * Przemek Rudy (prudy1@o2.pl)
17 #include <linux/hid.h>
18 #include <linux/init.h>
19 #include <linux/math64.h>
20 #include <linux/slab.h>
21 #include <linux/usb.h>
22 #include <linux/usb/audio.h>
24 #include <sound/asoundef.h>
25 #include <sound/core.h>
26 #include <sound/control.h>
27 #include <sound/hwdep.h>
28 #include <sound/info.h>
29 #include <sound/tlv.h>
33 #include "mixer_quirks.h"
34 #include "mixer_scarlett.h"
35 #include "mixer_us16x08.h"
38 struct std_mono_table
{
39 unsigned int unitid
, control
, cmask
;
42 snd_kcontrol_tlv_rw_t
*tlv_callback
;
45 /* This function allows for the creation of standard UAC controls.
46 * See the quirks for M-Audio FTUs or Ebox-44.
47 * If you don't want to set a TLV callback pass NULL.
49 * Since there doesn't seem to be a devices that needs a multichannel
50 * version, we keep it mono for simplicity.
52 static int snd_create_std_mono_ctl_offset(struct usb_mixer_interface
*mixer
,
59 snd_kcontrol_tlv_rw_t
*tlv_callback
)
61 struct usb_mixer_elem_info
*cval
;
62 struct snd_kcontrol
*kctl
;
64 cval
= kzalloc(sizeof(*cval
), GFP_KERNEL
);
68 snd_usb_mixer_elem_init_std(&cval
->head
, mixer
, unitid
);
69 cval
->val_type
= val_type
;
71 cval
->control
= control
;
73 cval
->idx_off
= idx_off
;
75 /* get_min_max() is called only for integer volumes later,
76 * so provide a short-cut for booleans */
84 kctl
= snd_ctl_new1(snd_usb_feature_unit_ctl
, cval
);
91 snprintf(kctl
->id
.name
, sizeof(kctl
->id
.name
), name
);
92 kctl
->private_free
= snd_usb_mixer_elem_free
;
96 kctl
->tlv
.c
= tlv_callback
;
98 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
99 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
;
101 /* Add control to mixer */
102 return snd_usb_mixer_add_control(&cval
->head
, kctl
);
105 static int snd_create_std_mono_ctl(struct usb_mixer_interface
*mixer
,
107 unsigned int control
,
111 snd_kcontrol_tlv_rw_t
*tlv_callback
)
113 return snd_create_std_mono_ctl_offset(mixer
, unitid
, control
, cmask
,
114 val_type
, 0 /* Offset */, name
, tlv_callback
);
118 * Create a set of standard UAC controls from a table
120 static int snd_create_std_mono_table(struct usb_mixer_interface
*mixer
,
121 struct std_mono_table
*t
)
125 while (t
->name
!= NULL
) {
126 err
= snd_create_std_mono_ctl(mixer
, t
->unitid
, t
->control
,
127 t
->cmask
, t
->val_type
, t
->name
, t
->tlv_callback
);
136 static int add_single_ctl_with_resume(struct usb_mixer_interface
*mixer
,
138 usb_mixer_elem_resume_func_t resume
,
139 const struct snd_kcontrol_new
*knew
,
140 struct usb_mixer_elem_list
**listp
)
142 struct usb_mixer_elem_list
*list
;
143 struct snd_kcontrol
*kctl
;
145 list
= kzalloc(sizeof(*list
), GFP_KERNEL
);
152 list
->resume
= resume
;
153 kctl
= snd_ctl_new1(knew
, list
);
158 kctl
->private_free
= snd_usb_mixer_elem_free
;
159 return snd_usb_mixer_add_control(list
, kctl
);
163 * Sound Blaster remote control configuration
165 * format of remote control data:
167 * Audigy 2 NX: 06 80 xx 00 00 00
168 * Live! 24-bit: 06 80 xx yy 22 83
170 static const struct rc_config
{
175 u8 min_packet_length
; /* minimum accepted length of the URB result */
179 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
180 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
181 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
182 { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
183 { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
184 { USB_ID(0x041e, 0x3237), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
185 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
188 static void snd_usb_soundblaster_remote_complete(struct urb
*urb
)
190 struct usb_mixer_interface
*mixer
= urb
->context
;
191 const struct rc_config
*rc
= mixer
->rc_cfg
;
194 if (urb
->status
< 0 || urb
->actual_length
< rc
->min_packet_length
)
197 code
= mixer
->rc_buffer
[rc
->offset
];
199 code
|= mixer
->rc_buffer
[rc
->offset
+ 1] << 8;
201 /* the Mute button actually changes the mixer control */
202 if (code
== rc
->mute_code
)
203 snd_usb_mixer_notify_id(mixer
, rc
->mute_mixer_id
);
204 mixer
->rc_code
= code
;
206 wake_up(&mixer
->rc_waitq
);
209 static long snd_usb_sbrc_hwdep_read(struct snd_hwdep
*hw
, char __user
*buf
,
210 long count
, loff_t
*offset
)
212 struct usb_mixer_interface
*mixer
= hw
->private_data
;
216 if (count
!= 1 && count
!= 4)
218 err
= wait_event_interruptible(mixer
->rc_waitq
,
219 (rc_code
= xchg(&mixer
->rc_code
, 0)) != 0);
222 err
= put_user(rc_code
, buf
);
224 err
= put_user(rc_code
, (u32 __user
*)buf
);
226 return err
< 0 ? err
: count
;
229 static __poll_t
snd_usb_sbrc_hwdep_poll(struct snd_hwdep
*hw
, struct file
*file
,
232 struct usb_mixer_interface
*mixer
= hw
->private_data
;
234 poll_wait(file
, &mixer
->rc_waitq
, wait
);
235 return mixer
->rc_code
? EPOLLIN
| EPOLLRDNORM
: 0;
238 static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface
*mixer
)
240 struct snd_hwdep
*hwdep
;
243 for (i
= 0; i
< ARRAY_SIZE(rc_configs
); ++i
)
244 if (rc_configs
[i
].usb_id
== mixer
->chip
->usb_id
)
246 if (i
>= ARRAY_SIZE(rc_configs
))
248 mixer
->rc_cfg
= &rc_configs
[i
];
250 len
= mixer
->rc_cfg
->packet_length
;
252 init_waitqueue_head(&mixer
->rc_waitq
);
253 err
= snd_hwdep_new(mixer
->chip
->card
, "SB remote control", 0, &hwdep
);
256 snprintf(hwdep
->name
, sizeof(hwdep
->name
),
257 "%s remote control", mixer
->chip
->card
->shortname
);
258 hwdep
->iface
= SNDRV_HWDEP_IFACE_SB_RC
;
259 hwdep
->private_data
= mixer
;
260 hwdep
->ops
.read
= snd_usb_sbrc_hwdep_read
;
261 hwdep
->ops
.poll
= snd_usb_sbrc_hwdep_poll
;
262 hwdep
->exclusive
= 1;
264 mixer
->rc_urb
= usb_alloc_urb(0, GFP_KERNEL
);
267 mixer
->rc_setup_packet
= kmalloc(sizeof(*mixer
->rc_setup_packet
), GFP_KERNEL
);
268 if (!mixer
->rc_setup_packet
) {
269 usb_free_urb(mixer
->rc_urb
);
270 mixer
->rc_urb
= NULL
;
273 mixer
->rc_setup_packet
->bRequestType
=
274 USB_DIR_IN
| USB_TYPE_CLASS
| USB_RECIP_INTERFACE
;
275 mixer
->rc_setup_packet
->bRequest
= UAC_GET_MEM
;
276 mixer
->rc_setup_packet
->wValue
= cpu_to_le16(0);
277 mixer
->rc_setup_packet
->wIndex
= cpu_to_le16(0);
278 mixer
->rc_setup_packet
->wLength
= cpu_to_le16(len
);
279 usb_fill_control_urb(mixer
->rc_urb
, mixer
->chip
->dev
,
280 usb_rcvctrlpipe(mixer
->chip
->dev
, 0),
281 (u8
*)mixer
->rc_setup_packet
, mixer
->rc_buffer
, len
,
282 snd_usb_soundblaster_remote_complete
, mixer
);
286 #define snd_audigy2nx_led_info snd_ctl_boolean_mono_info
288 static int snd_audigy2nx_led_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
290 ucontrol
->value
.integer
.value
[0] = kcontrol
->private_value
>> 8;
294 static int snd_audigy2nx_led_update(struct usb_mixer_interface
*mixer
,
295 int value
, int index
)
297 struct snd_usb_audio
*chip
= mixer
->chip
;
300 err
= snd_usb_lock_shutdown(chip
);
304 if (chip
->usb_id
== USB_ID(0x041e, 0x3042))
305 err
= snd_usb_ctl_msg(chip
->dev
,
306 usb_sndctrlpipe(chip
->dev
, 0), 0x24,
307 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
309 /* USB X-Fi S51 Pro */
310 if (chip
->usb_id
== USB_ID(0x041e, 0x30df))
311 err
= snd_usb_ctl_msg(chip
->dev
,
312 usb_sndctrlpipe(chip
->dev
, 0), 0x24,
313 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
316 err
= snd_usb_ctl_msg(chip
->dev
,
317 usb_sndctrlpipe(chip
->dev
, 0), 0x24,
318 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
319 value
, index
+ 2, NULL
, 0);
320 snd_usb_unlock_shutdown(chip
);
324 static int snd_audigy2nx_led_put(struct snd_kcontrol
*kcontrol
,
325 struct snd_ctl_elem_value
*ucontrol
)
327 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
328 struct usb_mixer_interface
*mixer
= list
->mixer
;
329 int index
= kcontrol
->private_value
& 0xff;
330 unsigned int value
= ucontrol
->value
.integer
.value
[0];
331 int old_value
= kcontrol
->private_value
>> 8;
336 if (value
== old_value
)
338 kcontrol
->private_value
= (value
<< 8) | index
;
339 err
= snd_audigy2nx_led_update(mixer
, value
, index
);
340 return err
< 0 ? err
: 1;
343 static int snd_audigy2nx_led_resume(struct usb_mixer_elem_list
*list
)
345 int priv_value
= list
->kctl
->private_value
;
347 return snd_audigy2nx_led_update(list
->mixer
, priv_value
>> 8,
351 /* name and private_value are set dynamically */
352 static const struct snd_kcontrol_new snd_audigy2nx_control
= {
353 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
354 .info
= snd_audigy2nx_led_info
,
355 .get
= snd_audigy2nx_led_get
,
356 .put
= snd_audigy2nx_led_put
,
359 static const char * const snd_audigy2nx_led_names
[] = {
362 "Dolby Digital LED Switch",
365 static int snd_audigy2nx_controls_create(struct usb_mixer_interface
*mixer
)
369 for (i
= 0; i
< ARRAY_SIZE(snd_audigy2nx_led_names
); ++i
) {
370 struct snd_kcontrol_new knew
;
372 /* USB X-Fi S51 doesn't have a CMSS LED */
373 if ((mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3042)) && i
== 0)
375 /* USB X-Fi S51 Pro doesn't have one either */
376 if ((mixer
->chip
->usb_id
== USB_ID(0x041e, 0x30df)) && i
== 0)
378 if (i
> 1 && /* Live24ext has 2 LEDs only */
379 (mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3040) ||
380 mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3042) ||
381 mixer
->chip
->usb_id
== USB_ID(0x041e, 0x30df) ||
382 mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3048)))
385 knew
= snd_audigy2nx_control
;
386 knew
.name
= snd_audigy2nx_led_names
[i
];
387 knew
.private_value
= (1 << 8) | i
; /* LED on as default */
388 err
= add_single_ctl_with_resume(mixer
, 0,
389 snd_audigy2nx_led_resume
,
397 static void snd_audigy2nx_proc_read(struct snd_info_entry
*entry
,
398 struct snd_info_buffer
*buffer
)
400 static const struct sb_jack
{
403 } jacks_audigy2nx
[] = {
409 }, jacks_live24ext
[] = {
410 {4, "line in"}, /* &1=Line, &2=Mic*/
411 {3, "hph out"}, /* headphones */
412 {0, "RC "}, /* last command, 6 bytes see rc_config above */
415 const struct sb_jack
*jacks
;
416 struct usb_mixer_interface
*mixer
= entry
->private_data
;
420 snd_iprintf(buffer
, "%s jacks\n\n", mixer
->chip
->card
->shortname
);
421 if (mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3020))
422 jacks
= jacks_audigy2nx
;
423 else if (mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3040) ||
424 mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3048))
425 jacks
= jacks_live24ext
;
429 for (i
= 0; jacks
[i
].name
; ++i
) {
430 snd_iprintf(buffer
, "%s: ", jacks
[i
].name
);
431 err
= snd_usb_lock_shutdown(mixer
->chip
);
434 err
= snd_usb_ctl_msg(mixer
->chip
->dev
,
435 usb_rcvctrlpipe(mixer
->chip
->dev
, 0),
436 UAC_GET_MEM
, USB_DIR_IN
| USB_TYPE_CLASS
|
437 USB_RECIP_INTERFACE
, 0,
438 jacks
[i
].unitid
<< 8, buf
, 3);
439 snd_usb_unlock_shutdown(mixer
->chip
);
440 if (err
== 3 && (buf
[0] == 3 || buf
[0] == 6))
441 snd_iprintf(buffer
, "%02x %02x\n", buf
[1], buf
[2]);
443 snd_iprintf(buffer
, "?\n");
448 static int snd_emu0204_ch_switch_info(struct snd_kcontrol
*kcontrol
,
449 struct snd_ctl_elem_info
*uinfo
)
451 static const char * const texts
[2] = {"1/2", "3/4"};
453 return snd_ctl_enum_info(uinfo
, 1, ARRAY_SIZE(texts
), texts
);
456 static int snd_emu0204_ch_switch_get(struct snd_kcontrol
*kcontrol
,
457 struct snd_ctl_elem_value
*ucontrol
)
459 ucontrol
->value
.enumerated
.item
[0] = kcontrol
->private_value
;
463 static int snd_emu0204_ch_switch_update(struct usb_mixer_interface
*mixer
,
466 struct snd_usb_audio
*chip
= mixer
->chip
;
468 unsigned char buf
[2];
470 err
= snd_usb_lock_shutdown(chip
);
475 buf
[1] = value
? 0x02 : 0x01;
476 err
= snd_usb_ctl_msg(chip
->dev
,
477 usb_sndctrlpipe(chip
->dev
, 0), UAC_SET_CUR
,
478 USB_RECIP_INTERFACE
| USB_TYPE_CLASS
| USB_DIR_OUT
,
479 0x0400, 0x0e00, buf
, 2);
480 snd_usb_unlock_shutdown(chip
);
484 static int snd_emu0204_ch_switch_put(struct snd_kcontrol
*kcontrol
,
485 struct snd_ctl_elem_value
*ucontrol
)
487 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
488 struct usb_mixer_interface
*mixer
= list
->mixer
;
489 unsigned int value
= ucontrol
->value
.enumerated
.item
[0];
495 if (value
== kcontrol
->private_value
)
498 kcontrol
->private_value
= value
;
499 err
= snd_emu0204_ch_switch_update(mixer
, value
);
500 return err
< 0 ? err
: 1;
503 static int snd_emu0204_ch_switch_resume(struct usb_mixer_elem_list
*list
)
505 return snd_emu0204_ch_switch_update(list
->mixer
,
506 list
->kctl
->private_value
);
509 static struct snd_kcontrol_new snd_emu0204_control
= {
510 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
511 .name
= "Front Jack Channels",
512 .info
= snd_emu0204_ch_switch_info
,
513 .get
= snd_emu0204_ch_switch_get
,
514 .put
= snd_emu0204_ch_switch_put
,
518 static int snd_emu0204_controls_create(struct usb_mixer_interface
*mixer
)
520 return add_single_ctl_with_resume(mixer
, 0,
521 snd_emu0204_ch_switch_resume
,
522 &snd_emu0204_control
, NULL
);
525 /* ASUS Xonar U1 / U3 controls */
527 static int snd_xonar_u1_switch_get(struct snd_kcontrol
*kcontrol
,
528 struct snd_ctl_elem_value
*ucontrol
)
530 ucontrol
->value
.integer
.value
[0] = !!(kcontrol
->private_value
& 0x02);
534 static int snd_xonar_u1_switch_update(struct usb_mixer_interface
*mixer
,
535 unsigned char status
)
537 struct snd_usb_audio
*chip
= mixer
->chip
;
540 err
= snd_usb_lock_shutdown(chip
);
543 err
= snd_usb_ctl_msg(chip
->dev
,
544 usb_sndctrlpipe(chip
->dev
, 0), 0x08,
545 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
547 snd_usb_unlock_shutdown(chip
);
551 static int snd_xonar_u1_switch_put(struct snd_kcontrol
*kcontrol
,
552 struct snd_ctl_elem_value
*ucontrol
)
554 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
555 u8 old_status
, new_status
;
558 old_status
= kcontrol
->private_value
;
559 if (ucontrol
->value
.integer
.value
[0])
560 new_status
= old_status
| 0x02;
562 new_status
= old_status
& ~0x02;
563 if (new_status
== old_status
)
566 kcontrol
->private_value
= new_status
;
567 err
= snd_xonar_u1_switch_update(list
->mixer
, new_status
);
568 return err
< 0 ? err
: 1;
571 static int snd_xonar_u1_switch_resume(struct usb_mixer_elem_list
*list
)
573 return snd_xonar_u1_switch_update(list
->mixer
,
574 list
->kctl
->private_value
);
577 static struct snd_kcontrol_new snd_xonar_u1_output_switch
= {
578 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
579 .name
= "Digital Playback Switch",
580 .info
= snd_ctl_boolean_mono_info
,
581 .get
= snd_xonar_u1_switch_get
,
582 .put
= snd_xonar_u1_switch_put
,
583 .private_value
= 0x05,
586 static int snd_xonar_u1_controls_create(struct usb_mixer_interface
*mixer
)
588 return add_single_ctl_with_resume(mixer
, 0,
589 snd_xonar_u1_switch_resume
,
590 &snd_xonar_u1_output_switch
, NULL
);
593 /* Digidesign Mbox 1 clock source switch (internal/spdif) */
595 static int snd_mbox1_switch_get(struct snd_kcontrol
*kctl
,
596 struct snd_ctl_elem_value
*ucontrol
)
598 ucontrol
->value
.enumerated
.item
[0] = kctl
->private_value
;
602 static int snd_mbox1_switch_update(struct usb_mixer_interface
*mixer
, int val
)
604 struct snd_usb_audio
*chip
= mixer
->chip
;
606 unsigned char buff
[3];
608 err
= snd_usb_lock_shutdown(chip
);
612 /* Prepare for magic command to toggle clock source */
613 err
= snd_usb_ctl_msg(chip
->dev
,
614 usb_rcvctrlpipe(chip
->dev
, 0), 0x81,
617 USB_RECIP_INTERFACE
, 0x00, 0x500, buff
, 1);
620 err
= snd_usb_ctl_msg(chip
->dev
,
621 usb_rcvctrlpipe(chip
->dev
, 0), 0x81,
624 USB_RECIP_ENDPOINT
, 0x100, 0x81, buff
, 3);
628 /* 2 possibilities: Internal -> send sample rate
629 * S/PDIF sync -> send zeroes
630 * NB: Sample rate locked to 48kHz on purpose to
631 * prevent user from resetting the sample rate
632 * while S/PDIF sync is enabled and confusing
633 * this configuration.
640 buff
[0] = buff
[1] = buff
[2] = 0x00;
643 /* Send the magic command to toggle the clock source */
644 err
= snd_usb_ctl_msg(chip
->dev
,
645 usb_sndctrlpipe(chip
->dev
, 0), 0x1,
647 USB_RECIP_ENDPOINT
, 0x100, 0x81, buff
, 3);
650 err
= snd_usb_ctl_msg(chip
->dev
,
651 usb_rcvctrlpipe(chip
->dev
, 0), 0x81,
654 USB_RECIP_ENDPOINT
, 0x100, 0x81, buff
, 3);
657 err
= snd_usb_ctl_msg(chip
->dev
,
658 usb_rcvctrlpipe(chip
->dev
, 0), 0x81,
661 USB_RECIP_ENDPOINT
, 0x100, 0x2, buff
, 3);
666 snd_usb_unlock_shutdown(chip
);
670 static int snd_mbox1_switch_put(struct snd_kcontrol
*kctl
,
671 struct snd_ctl_elem_value
*ucontrol
)
673 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kctl
);
674 struct usb_mixer_interface
*mixer
= list
->mixer
;
676 bool cur_val
, new_val
;
678 cur_val
= kctl
->private_value
;
679 new_val
= ucontrol
->value
.enumerated
.item
[0];
680 if (cur_val
== new_val
)
683 kctl
->private_value
= new_val
;
684 err
= snd_mbox1_switch_update(mixer
, new_val
);
685 return err
< 0 ? err
: 1;
688 static int snd_mbox1_switch_info(struct snd_kcontrol
*kcontrol
,
689 struct snd_ctl_elem_info
*uinfo
)
691 static const char *const texts
[2] = {
696 return snd_ctl_enum_info(uinfo
, 1, ARRAY_SIZE(texts
), texts
);
699 static int snd_mbox1_switch_resume(struct usb_mixer_elem_list
*list
)
701 return snd_mbox1_switch_update(list
->mixer
, list
->kctl
->private_value
);
704 static struct snd_kcontrol_new snd_mbox1_switch
= {
705 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
706 .name
= "Clock Source",
708 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
,
709 .info
= snd_mbox1_switch_info
,
710 .get
= snd_mbox1_switch_get
,
711 .put
= snd_mbox1_switch_put
,
715 static int snd_mbox1_create_sync_switch(struct usb_mixer_interface
*mixer
)
717 return add_single_ctl_with_resume(mixer
, 0,
718 snd_mbox1_switch_resume
,
719 &snd_mbox1_switch
, NULL
);
722 /* Native Instruments device quirks */
724 #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
726 static int snd_ni_control_init_val(struct usb_mixer_interface
*mixer
,
727 struct snd_kcontrol
*kctl
)
729 struct usb_device
*dev
= mixer
->chip
->dev
;
730 unsigned int pval
= kctl
->private_value
;
734 err
= snd_usb_ctl_msg(dev
, usb_rcvctrlpipe(dev
, 0),
736 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_IN
,
737 0, pval
& 0xffff, &value
, 1);
740 "unable to issue vendor read request (ret = %d)", err
);
744 kctl
->private_value
|= ((unsigned int)value
<< 24);
748 static int snd_nativeinstruments_control_get(struct snd_kcontrol
*kcontrol
,
749 struct snd_ctl_elem_value
*ucontrol
)
751 ucontrol
->value
.integer
.value
[0] = kcontrol
->private_value
>> 24;
755 static int snd_ni_update_cur_val(struct usb_mixer_elem_list
*list
)
757 struct snd_usb_audio
*chip
= list
->mixer
->chip
;
758 unsigned int pval
= list
->kctl
->private_value
;
761 err
= snd_usb_lock_shutdown(chip
);
764 err
= usb_control_msg(chip
->dev
, usb_sndctrlpipe(chip
->dev
, 0),
766 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_OUT
,
767 pval
>> 24, pval
& 0xffff, NULL
, 0, 1000);
768 snd_usb_unlock_shutdown(chip
);
772 static int snd_nativeinstruments_control_put(struct snd_kcontrol
*kcontrol
,
773 struct snd_ctl_elem_value
*ucontrol
)
775 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
776 u8 oldval
= (kcontrol
->private_value
>> 24) & 0xff;
777 u8 newval
= ucontrol
->value
.integer
.value
[0];
780 if (oldval
== newval
)
783 kcontrol
->private_value
&= ~(0xff << 24);
784 kcontrol
->private_value
|= (unsigned int)newval
<< 24;
785 err
= snd_ni_update_cur_val(list
);
786 return err
< 0 ? err
: 1;
789 static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers
[] = {
791 .name
= "Direct Thru Channel A",
792 .private_value
= _MAKE_NI_CONTROL(0x01, 0x03),
795 .name
= "Direct Thru Channel B",
796 .private_value
= _MAKE_NI_CONTROL(0x01, 0x05),
799 .name
= "Phono Input Channel A",
800 .private_value
= _MAKE_NI_CONTROL(0x02, 0x03),
803 .name
= "Phono Input Channel B",
804 .private_value
= _MAKE_NI_CONTROL(0x02, 0x05),
808 static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers
[] = {
810 .name
= "Direct Thru Channel A",
811 .private_value
= _MAKE_NI_CONTROL(0x01, 0x03),
814 .name
= "Direct Thru Channel B",
815 .private_value
= _MAKE_NI_CONTROL(0x01, 0x05),
818 .name
= "Direct Thru Channel C",
819 .private_value
= _MAKE_NI_CONTROL(0x01, 0x07),
822 .name
= "Direct Thru Channel D",
823 .private_value
= _MAKE_NI_CONTROL(0x01, 0x09),
826 .name
= "Phono Input Channel A",
827 .private_value
= _MAKE_NI_CONTROL(0x02, 0x03),
830 .name
= "Phono Input Channel B",
831 .private_value
= _MAKE_NI_CONTROL(0x02, 0x05),
834 .name
= "Phono Input Channel C",
835 .private_value
= _MAKE_NI_CONTROL(0x02, 0x07),
838 .name
= "Phono Input Channel D",
839 .private_value
= _MAKE_NI_CONTROL(0x02, 0x09),
843 static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface
*mixer
,
844 const struct snd_kcontrol_new
*kc
,
848 struct snd_kcontrol_new
template = {
849 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
850 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
,
851 .get
= snd_nativeinstruments_control_get
,
852 .put
= snd_nativeinstruments_control_put
,
853 .info
= snd_ctl_boolean_mono_info
,
856 for (i
= 0; i
< count
; i
++) {
857 struct usb_mixer_elem_list
*list
;
859 template.name
= kc
[i
].name
;
860 template.private_value
= kc
[i
].private_value
;
862 err
= add_single_ctl_with_resume(mixer
, 0,
863 snd_ni_update_cur_val
,
867 snd_ni_control_init_val(mixer
, list
->kctl
);
873 /* M-Audio FastTrack Ultra quirks */
874 /* FTU Effect switch (also used by C400/C600) */
875 static int snd_ftu_eff_switch_info(struct snd_kcontrol
*kcontrol
,
876 struct snd_ctl_elem_info
*uinfo
)
878 static const char *const texts
[8] = {
879 "Room 1", "Room 2", "Room 3", "Hall 1",
880 "Hall 2", "Plate", "Delay", "Echo"
883 return snd_ctl_enum_info(uinfo
, 1, ARRAY_SIZE(texts
), texts
);
886 static int snd_ftu_eff_switch_init(struct usb_mixer_interface
*mixer
,
887 struct snd_kcontrol
*kctl
)
889 struct usb_device
*dev
= mixer
->chip
->dev
;
890 unsigned int pval
= kctl
->private_value
;
892 unsigned char value
[2];
897 err
= snd_usb_ctl_msg(dev
, usb_rcvctrlpipe(dev
, 0), UAC_GET_CUR
,
898 USB_RECIP_INTERFACE
| USB_TYPE_CLASS
| USB_DIR_IN
,
900 snd_usb_ctrl_intf(mixer
->chip
) | ((pval
& 0xff) << 8),
905 kctl
->private_value
|= (unsigned int)value
[0] << 24;
909 static int snd_ftu_eff_switch_get(struct snd_kcontrol
*kctl
,
910 struct snd_ctl_elem_value
*ucontrol
)
912 ucontrol
->value
.enumerated
.item
[0] = kctl
->private_value
>> 24;
916 static int snd_ftu_eff_switch_update(struct usb_mixer_elem_list
*list
)
918 struct snd_usb_audio
*chip
= list
->mixer
->chip
;
919 unsigned int pval
= list
->kctl
->private_value
;
920 unsigned char value
[2];
923 value
[0] = pval
>> 24;
926 err
= snd_usb_lock_shutdown(chip
);
929 err
= snd_usb_ctl_msg(chip
->dev
,
930 usb_sndctrlpipe(chip
->dev
, 0),
932 USB_RECIP_INTERFACE
| USB_TYPE_CLASS
| USB_DIR_OUT
,
934 snd_usb_ctrl_intf(chip
) | ((pval
& 0xff) << 8),
936 snd_usb_unlock_shutdown(chip
);
940 static int snd_ftu_eff_switch_put(struct snd_kcontrol
*kctl
,
941 struct snd_ctl_elem_value
*ucontrol
)
943 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kctl
);
944 unsigned int pval
= list
->kctl
->private_value
;
945 int cur_val
, err
, new_val
;
947 cur_val
= pval
>> 24;
948 new_val
= ucontrol
->value
.enumerated
.item
[0];
949 if (cur_val
== new_val
)
952 kctl
->private_value
&= ~(0xff << 24);
953 kctl
->private_value
|= new_val
<< 24;
954 err
= snd_ftu_eff_switch_update(list
);
955 return err
< 0 ? err
: 1;
958 static int snd_ftu_create_effect_switch(struct usb_mixer_interface
*mixer
,
959 int validx
, int bUnitID
)
961 static struct snd_kcontrol_new
template = {
962 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
963 .name
= "Effect Program Switch",
965 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
,
966 .info
= snd_ftu_eff_switch_info
,
967 .get
= snd_ftu_eff_switch_get
,
968 .put
= snd_ftu_eff_switch_put
970 struct usb_mixer_elem_list
*list
;
973 err
= add_single_ctl_with_resume(mixer
, bUnitID
,
974 snd_ftu_eff_switch_update
,
978 list
->kctl
->private_value
= (validx
<< 8) | bUnitID
;
979 snd_ftu_eff_switch_init(mixer
, list
->kctl
);
983 /* Create volume controls for FTU devices*/
984 static int snd_ftu_create_volume_ctls(struct usb_mixer_interface
*mixer
)
987 unsigned int control
, cmask
;
990 const unsigned int id
= 5;
991 const int val_type
= USB_MIXER_S16
;
993 for (out
= 0; out
< 8; out
++) {
995 for (in
= 0; in
< 8; in
++) {
997 snprintf(name
, sizeof(name
),
998 "AIn%d - Out%d Capture Volume",
1000 err
= snd_create_std_mono_ctl(mixer
, id
, control
,
1001 cmask
, val_type
, name
,
1002 &snd_usb_mixer_vol_tlv
);
1006 for (in
= 8; in
< 16; in
++) {
1008 snprintf(name
, sizeof(name
),
1009 "DIn%d - Out%d Playback Volume",
1011 err
= snd_create_std_mono_ctl(mixer
, id
, control
,
1012 cmask
, val_type
, name
,
1013 &snd_usb_mixer_vol_tlv
);
1022 /* This control needs a volume quirk, see mixer.c */
1023 static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface
*mixer
)
1025 static const char name
[] = "Effect Volume";
1026 const unsigned int id
= 6;
1027 const int val_type
= USB_MIXER_U8
;
1028 const unsigned int control
= 2;
1029 const unsigned int cmask
= 0;
1031 return snd_create_std_mono_ctl(mixer
, id
, control
, cmask
, val_type
,
1032 name
, snd_usb_mixer_vol_tlv
);
1035 /* This control needs a volume quirk, see mixer.c */
1036 static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface
*mixer
)
1038 static const char name
[] = "Effect Duration";
1039 const unsigned int id
= 6;
1040 const int val_type
= USB_MIXER_S16
;
1041 const unsigned int control
= 3;
1042 const unsigned int cmask
= 0;
1044 return snd_create_std_mono_ctl(mixer
, id
, control
, cmask
, val_type
,
1045 name
, snd_usb_mixer_vol_tlv
);
1048 /* This control needs a volume quirk, see mixer.c */
1049 static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface
*mixer
)
1051 static const char name
[] = "Effect Feedback Volume";
1052 const unsigned int id
= 6;
1053 const int val_type
= USB_MIXER_U8
;
1054 const unsigned int control
= 4;
1055 const unsigned int cmask
= 0;
1057 return snd_create_std_mono_ctl(mixer
, id
, control
, cmask
, val_type
,
1061 static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface
*mixer
)
1067 const unsigned int id
= 7;
1068 const int val_type
= USB_MIXER_S16
;
1069 const unsigned int control
= 7;
1071 for (ch
= 0; ch
< 4; ++ch
) {
1073 snprintf(name
, sizeof(name
),
1074 "Effect Return %d Volume", ch
+ 1);
1075 err
= snd_create_std_mono_ctl(mixer
, id
, control
,
1076 cmask
, val_type
, name
,
1077 snd_usb_mixer_vol_tlv
);
1085 static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface
*mixer
)
1091 const unsigned int id
= 5;
1092 const int val_type
= USB_MIXER_S16
;
1093 const unsigned int control
= 9;
1095 for (ch
= 0; ch
< 8; ++ch
) {
1097 snprintf(name
, sizeof(name
),
1098 "Effect Send AIn%d Volume", ch
+ 1);
1099 err
= snd_create_std_mono_ctl(mixer
, id
, control
, cmask
,
1101 snd_usb_mixer_vol_tlv
);
1105 for (ch
= 8; ch
< 16; ++ch
) {
1107 snprintf(name
, sizeof(name
),
1108 "Effect Send DIn%d Volume", ch
- 7);
1109 err
= snd_create_std_mono_ctl(mixer
, id
, control
, cmask
,
1111 snd_usb_mixer_vol_tlv
);
1118 static int snd_ftu_create_mixer(struct usb_mixer_interface
*mixer
)
1122 err
= snd_ftu_create_volume_ctls(mixer
);
1126 err
= snd_ftu_create_effect_switch(mixer
, 1, 6);
1130 err
= snd_ftu_create_effect_volume_ctl(mixer
);
1134 err
= snd_ftu_create_effect_duration_ctl(mixer
);
1138 err
= snd_ftu_create_effect_feedback_ctl(mixer
);
1142 err
= snd_ftu_create_effect_return_ctls(mixer
);
1146 err
= snd_ftu_create_effect_send_ctls(mixer
);
1153 void snd_emuusb_set_samplerate(struct snd_usb_audio
*chip
,
1154 unsigned char samplerate_id
)
1156 struct usb_mixer_interface
*mixer
;
1157 struct usb_mixer_elem_info
*cval
;
1158 int unitid
= 12; /* SampleRate ExtensionUnit ID */
1160 list_for_each_entry(mixer
, &chip
->mixer_list
, list
) {
1161 if (mixer
->id_elems
[unitid
]) {
1162 cval
= mixer_elem_list_to_info(mixer
->id_elems
[unitid
]);
1163 snd_usb_mixer_set_ctl_value(cval
, UAC_SET_CUR
,
1166 snd_usb_mixer_notify_id(mixer
, unitid
);
1172 /* M-Audio Fast Track C400/C600 */
1173 /* C400/C600 volume controls, this control needs a volume quirk, see mixer.c */
1174 static int snd_c400_create_vol_ctls(struct usb_mixer_interface
*mixer
)
1177 unsigned int cmask
, offset
;
1182 const unsigned int id
= 0x40;
1183 const int val_type
= USB_MIXER_S16
;
1184 const int control
= 1;
1186 switch (mixer
->chip
->usb_id
) {
1187 case USB_ID(0x0763, 0x2030):
1191 case USB_ID(0x0763, 0x2031):
1197 for (chan
= 0; chan
< num_outs
+ num_ins
; chan
++) {
1198 for (out
= 0; out
< num_outs
; out
++) {
1199 if (chan
< num_outs
) {
1200 snprintf(name
, sizeof(name
),
1201 "PCM%d-Out%d Playback Volume",
1204 snprintf(name
, sizeof(name
),
1205 "In%d-Out%d Playback Volume",
1206 chan
- num_outs
+ 1, out
+ 1);
1209 cmask
= (out
== 0) ? 0 : 1 << (out
- 1);
1210 offset
= chan
* num_outs
;
1211 err
= snd_create_std_mono_ctl_offset(mixer
, id
, control
,
1212 cmask
, val_type
, offset
, name
,
1213 &snd_usb_mixer_vol_tlv
);
1222 /* This control needs a volume quirk, see mixer.c */
1223 static int snd_c400_create_effect_volume_ctl(struct usb_mixer_interface
*mixer
)
1225 static const char name
[] = "Effect Volume";
1226 const unsigned int id
= 0x43;
1227 const int val_type
= USB_MIXER_U8
;
1228 const unsigned int control
= 3;
1229 const unsigned int cmask
= 0;
1231 return snd_create_std_mono_ctl(mixer
, id
, control
, cmask
, val_type
,
1232 name
, snd_usb_mixer_vol_tlv
);
1235 /* This control needs a volume quirk, see mixer.c */
1236 static int snd_c400_create_effect_duration_ctl(struct usb_mixer_interface
*mixer
)
1238 static const char name
[] = "Effect Duration";
1239 const unsigned int id
= 0x43;
1240 const int val_type
= USB_MIXER_S16
;
1241 const unsigned int control
= 4;
1242 const unsigned int cmask
= 0;
1244 return snd_create_std_mono_ctl(mixer
, id
, control
, cmask
, val_type
,
1245 name
, snd_usb_mixer_vol_tlv
);
1248 /* This control needs a volume quirk, see mixer.c */
1249 static int snd_c400_create_effect_feedback_ctl(struct usb_mixer_interface
*mixer
)
1251 static const char name
[] = "Effect Feedback Volume";
1252 const unsigned int id
= 0x43;
1253 const int val_type
= USB_MIXER_U8
;
1254 const unsigned int control
= 5;
1255 const unsigned int cmask
= 0;
1257 return snd_create_std_mono_ctl(mixer
, id
, control
, cmask
, val_type
,
1261 static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface
*mixer
)
1269 const unsigned int id
= 0x42;
1270 const int val_type
= USB_MIXER_S16
;
1271 const int control
= 1;
1273 switch (mixer
->chip
->usb_id
) {
1274 case USB_ID(0x0763, 0x2030):
1278 case USB_ID(0x0763, 0x2031):
1284 for (chan
= 0; chan
< num_outs
+ num_ins
; chan
++) {
1285 if (chan
< num_outs
) {
1286 snprintf(name
, sizeof(name
),
1287 "Effect Send DOut%d",
1290 snprintf(name
, sizeof(name
),
1291 "Effect Send AIn%d",
1292 chan
- num_outs
+ 1);
1295 cmask
= (chan
== 0) ? 0 : 1 << (chan
- 1);
1296 err
= snd_create_std_mono_ctl(mixer
, id
, control
,
1297 cmask
, val_type
, name
,
1298 &snd_usb_mixer_vol_tlv
);
1306 static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface
*mixer
)
1314 const unsigned int id
= 0x40;
1315 const int val_type
= USB_MIXER_S16
;
1316 const int control
= 1;
1318 switch (mixer
->chip
->usb_id
) {
1319 case USB_ID(0x0763, 0x2030):
1322 /* { 0x3c, 0x43, 0x3e, 0x45, 0x40, 0x47 } */
1324 case USB_ID(0x0763, 0x2031):
1327 /* { 0x70, 0x79, 0x72, 0x7b, 0x74, 0x7d, 0x76, 0x7f } */
1331 for (chan
= 0; chan
< num_outs
; chan
++) {
1332 snprintf(name
, sizeof(name
),
1336 cmask
= (chan
== 0) ? 0 :
1337 1 << (chan
+ (chan
% 2) * num_outs
- 1);
1338 err
= snd_create_std_mono_ctl_offset(mixer
, id
, control
,
1339 cmask
, val_type
, offset
, name
,
1340 &snd_usb_mixer_vol_tlv
);
1348 static int snd_c400_create_mixer(struct usb_mixer_interface
*mixer
)
1352 err
= snd_c400_create_vol_ctls(mixer
);
1356 err
= snd_c400_create_effect_vol_ctls(mixer
);
1360 err
= snd_c400_create_effect_ret_vol_ctls(mixer
);
1364 err
= snd_ftu_create_effect_switch(mixer
, 2, 0x43);
1368 err
= snd_c400_create_effect_volume_ctl(mixer
);
1372 err
= snd_c400_create_effect_duration_ctl(mixer
);
1376 err
= snd_c400_create_effect_feedback_ctl(mixer
);
1384 * The mixer units for Ebox-44 are corrupt, and even where they
1385 * are valid they presents mono controls as L and R channels of
1386 * stereo. So we provide a good mixer here.
1388 static struct std_mono_table ebox44_table
[] = {
1393 .val_type
= USB_MIXER_INV_BOOLEAN
,
1394 .name
= "Headphone Playback Switch"
1400 .val_type
= USB_MIXER_S16
,
1401 .name
= "Headphone A Mix Playback Volume"
1407 .val_type
= USB_MIXER_S16
,
1408 .name
= "Headphone B Mix Playback Volume"
1415 .val_type
= USB_MIXER_INV_BOOLEAN
,
1416 .name
= "Output Playback Switch"
1422 .val_type
= USB_MIXER_S16
,
1423 .name
= "Output A Playback Volume"
1429 .val_type
= USB_MIXER_S16
,
1430 .name
= "Output B Playback Volume"
1437 .val_type
= USB_MIXER_INV_BOOLEAN
,
1438 .name
= "Input Capture Switch"
1444 .val_type
= USB_MIXER_S16
,
1445 .name
= "Input A Capture Volume"
1451 .val_type
= USB_MIXER_S16
,
1452 .name
= "Input B Capture Volume"
1458 /* Audio Advantage Micro II findings:
1460 * Mapping spdif AES bits to vendor register.bit:
1461 * AES0: [0 0 0 0 2.3 2.2 2.1 2.0] - default 0x00
1462 * AES1: [3.3 3.2.3.1.3.0 2.7 2.6 2.5 2.4] - default: 0x01
1463 * AES2: [0 0 0 0 0 0 0 0]
1464 * AES3: [0 0 0 0 0 0 x 0] - 'x' bit is set basing on standard usb request
1465 * (UAC_EP_CS_ATTR_SAMPLE_RATE) for Audio Devices
1469 * r3: 0x20 (b7 is zeroed just before playback (except IEC61937) and set
1470 * just after it to 0xa0, presumably it disables/mutes some analog
1471 * parts when there is no audio.)
1474 * Optical transmitter on/off:
1475 * vendor register.bit: 9.1
1476 * 0 - on (0x28 register value)
1477 * 1 - off (0x2a register value)
1480 static int snd_microii_spdif_info(struct snd_kcontrol
*kcontrol
,
1481 struct snd_ctl_elem_info
*uinfo
)
1483 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
1488 static int snd_microii_spdif_default_get(struct snd_kcontrol
*kcontrol
,
1489 struct snd_ctl_elem_value
*ucontrol
)
1491 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
1492 struct snd_usb_audio
*chip
= list
->mixer
->chip
;
1494 struct usb_interface
*iface
;
1495 struct usb_host_interface
*alts
;
1497 unsigned char data
[3];
1500 err
= snd_usb_lock_shutdown(chip
);
1504 ucontrol
->value
.iec958
.status
[0] = kcontrol
->private_value
& 0xff;
1505 ucontrol
->value
.iec958
.status
[1] = (kcontrol
->private_value
>> 8) & 0xff;
1506 ucontrol
->value
.iec958
.status
[2] = 0x00;
1508 /* use known values for that card: interface#1 altsetting#1 */
1509 iface
= usb_ifnum_to_if(chip
->dev
, 1);
1510 if (!iface
|| iface
->num_altsetting
< 2)
1512 alts
= &iface
->altsetting
[1];
1513 if (get_iface_desc(alts
)->bNumEndpoints
< 1)
1515 ep
= get_endpoint(alts
, 0)->bEndpointAddress
;
1517 err
= snd_usb_ctl_msg(chip
->dev
,
1518 usb_rcvctrlpipe(chip
->dev
, 0),
1520 USB_TYPE_CLASS
| USB_RECIP_ENDPOINT
| USB_DIR_IN
,
1521 UAC_EP_CS_ATTR_SAMPLE_RATE
<< 8,
1528 rate
= data
[0] | (data
[1] << 8) | (data
[2] << 16);
1529 ucontrol
->value
.iec958
.status
[3] = (rate
== 48000) ?
1530 IEC958_AES3_CON_FS_48000
: IEC958_AES3_CON_FS_44100
;
1534 snd_usb_unlock_shutdown(chip
);
1538 static int snd_microii_spdif_default_update(struct usb_mixer_elem_list
*list
)
1540 struct snd_usb_audio
*chip
= list
->mixer
->chip
;
1541 unsigned int pval
= list
->kctl
->private_value
;
1545 err
= snd_usb_lock_shutdown(chip
);
1549 reg
= ((pval
>> 4) & 0xf0) | (pval
& 0x0f);
1550 err
= snd_usb_ctl_msg(chip
->dev
,
1551 usb_sndctrlpipe(chip
->dev
, 0),
1553 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
1561 reg
= (pval
& IEC958_AES0_NONAUDIO
) ? 0xa0 : 0x20;
1562 reg
|= (pval
>> 12) & 0x0f;
1563 err
= snd_usb_ctl_msg(chip
->dev
,
1564 usb_sndctrlpipe(chip
->dev
, 0),
1566 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
1575 snd_usb_unlock_shutdown(chip
);
1579 static int snd_microii_spdif_default_put(struct snd_kcontrol
*kcontrol
,
1580 struct snd_ctl_elem_value
*ucontrol
)
1582 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
1583 unsigned int pval
, pval_old
;
1586 pval
= pval_old
= kcontrol
->private_value
;
1588 pval
|= (ucontrol
->value
.iec958
.status
[1] & 0x0f) << 8;
1589 pval
|= (ucontrol
->value
.iec958
.status
[0] & 0x0f);
1592 pval
|= (ucontrol
->value
.iec958
.status
[1] & 0xf0) << 8;
1594 /* The frequency bits in AES3 cannot be set via register access. */
1596 /* Silently ignore any bits from the request that cannot be set. */
1598 if (pval
== pval_old
)
1601 kcontrol
->private_value
= pval
;
1602 err
= snd_microii_spdif_default_update(list
);
1603 return err
< 0 ? err
: 1;
1606 static int snd_microii_spdif_mask_get(struct snd_kcontrol
*kcontrol
,
1607 struct snd_ctl_elem_value
*ucontrol
)
1609 ucontrol
->value
.iec958
.status
[0] = 0x0f;
1610 ucontrol
->value
.iec958
.status
[1] = 0xff;
1611 ucontrol
->value
.iec958
.status
[2] = 0x00;
1612 ucontrol
->value
.iec958
.status
[3] = 0x00;
1617 static int snd_microii_spdif_switch_get(struct snd_kcontrol
*kcontrol
,
1618 struct snd_ctl_elem_value
*ucontrol
)
1620 ucontrol
->value
.integer
.value
[0] = !(kcontrol
->private_value
& 0x02);
1625 static int snd_microii_spdif_switch_update(struct usb_mixer_elem_list
*list
)
1627 struct snd_usb_audio
*chip
= list
->mixer
->chip
;
1628 u8 reg
= list
->kctl
->private_value
;
1631 err
= snd_usb_lock_shutdown(chip
);
1635 err
= snd_usb_ctl_msg(chip
->dev
,
1636 usb_sndctrlpipe(chip
->dev
, 0),
1638 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
1644 snd_usb_unlock_shutdown(chip
);
1648 static int snd_microii_spdif_switch_put(struct snd_kcontrol
*kcontrol
,
1649 struct snd_ctl_elem_value
*ucontrol
)
1651 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
1655 reg
= ucontrol
->value
.integer
.value
[0] ? 0x28 : 0x2a;
1656 if (reg
!= list
->kctl
->private_value
)
1659 kcontrol
->private_value
= reg
;
1660 err
= snd_microii_spdif_switch_update(list
);
1661 return err
< 0 ? err
: 1;
1664 static struct snd_kcontrol_new snd_microii_mixer_spdif
[] = {
1666 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1667 .name
= SNDRV_CTL_NAME_IEC958("", PLAYBACK
, DEFAULT
),
1668 .info
= snd_microii_spdif_info
,
1669 .get
= snd_microii_spdif_default_get
,
1670 .put
= snd_microii_spdif_default_put
,
1671 .private_value
= 0x00000100UL
,/* reset value */
1674 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
1675 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1676 .name
= SNDRV_CTL_NAME_IEC958("", PLAYBACK
, MASK
),
1677 .info
= snd_microii_spdif_info
,
1678 .get
= snd_microii_spdif_mask_get
,
1681 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1682 .name
= SNDRV_CTL_NAME_IEC958("", PLAYBACK
, SWITCH
),
1683 .info
= snd_ctl_boolean_mono_info
,
1684 .get
= snd_microii_spdif_switch_get
,
1685 .put
= snd_microii_spdif_switch_put
,
1686 .private_value
= 0x00000028UL
,/* reset value */
1690 static int snd_microii_controls_create(struct usb_mixer_interface
*mixer
)
1693 static usb_mixer_elem_resume_func_t resume_funcs
[] = {
1694 snd_microii_spdif_default_update
,
1696 snd_microii_spdif_switch_update
1699 for (i
= 0; i
< ARRAY_SIZE(snd_microii_mixer_spdif
); ++i
) {
1700 err
= add_single_ctl_with_resume(mixer
, 0,
1702 &snd_microii_mixer_spdif
[i
],
1711 /* Creative Sound Blaster E1 */
1713 static int snd_soundblaster_e1_switch_get(struct snd_kcontrol
*kcontrol
,
1714 struct snd_ctl_elem_value
*ucontrol
)
1716 ucontrol
->value
.integer
.value
[0] = kcontrol
->private_value
;
1720 static int snd_soundblaster_e1_switch_update(struct usb_mixer_interface
*mixer
,
1721 unsigned char state
)
1723 struct snd_usb_audio
*chip
= mixer
->chip
;
1725 unsigned char buff
[2];
1728 buff
[1] = state
? 0x02 : 0x00;
1730 err
= snd_usb_lock_shutdown(chip
);
1733 err
= snd_usb_ctl_msg(chip
->dev
,
1734 usb_sndctrlpipe(chip
->dev
, 0), HID_REQ_SET_REPORT
,
1735 USB_TYPE_CLASS
| USB_RECIP_INTERFACE
| USB_DIR_OUT
,
1736 0x0202, 3, buff
, 2);
1737 snd_usb_unlock_shutdown(chip
);
1741 static int snd_soundblaster_e1_switch_put(struct snd_kcontrol
*kcontrol
,
1742 struct snd_ctl_elem_value
*ucontrol
)
1744 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
1745 unsigned char value
= !!ucontrol
->value
.integer
.value
[0];
1748 if (kcontrol
->private_value
== value
)
1750 kcontrol
->private_value
= value
;
1751 err
= snd_soundblaster_e1_switch_update(list
->mixer
, value
);
1752 return err
< 0 ? err
: 1;
1755 static int snd_soundblaster_e1_switch_resume(struct usb_mixer_elem_list
*list
)
1757 return snd_soundblaster_e1_switch_update(list
->mixer
,
1758 list
->kctl
->private_value
);
1761 static int snd_soundblaster_e1_switch_info(struct snd_kcontrol
*kcontrol
,
1762 struct snd_ctl_elem_info
*uinfo
)
1764 static const char *const texts
[2] = {
1768 return snd_ctl_enum_info(uinfo
, 1, ARRAY_SIZE(texts
), texts
);
1771 static struct snd_kcontrol_new snd_soundblaster_e1_input_switch
= {
1772 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1773 .name
= "Input Source",
1774 .info
= snd_soundblaster_e1_switch_info
,
1775 .get
= snd_soundblaster_e1_switch_get
,
1776 .put
= snd_soundblaster_e1_switch_put
,
1780 static int snd_soundblaster_e1_switch_create(struct usb_mixer_interface
*mixer
)
1782 return add_single_ctl_with_resume(mixer
, 0,
1783 snd_soundblaster_e1_switch_resume
,
1784 &snd_soundblaster_e1_input_switch
,
1788 static void dell_dock_init_vol(struct snd_usb_audio
*chip
, int ch
, int id
)
1792 snd_usb_ctl_msg(chip
->dev
, usb_sndctrlpipe(chip
->dev
, 0), UAC_SET_CUR
,
1793 USB_RECIP_INTERFACE
| USB_TYPE_CLASS
| USB_DIR_OUT
,
1794 ch
, snd_usb_ctrl_intf(chip
) | (id
<< 8),
1798 static int dell_dock_mixer_init(struct usb_mixer_interface
*mixer
)
1800 /* fix to 0dB playback volumes */
1801 dell_dock_init_vol(mixer
->chip
, 1, 16);
1802 dell_dock_init_vol(mixer
->chip
, 2, 16);
1803 dell_dock_init_vol(mixer
->chip
, 1, 19);
1804 dell_dock_init_vol(mixer
->chip
, 2, 19);
1808 /* RME Class Compliant device quirks */
1810 #define SND_RME_GET_STATUS1 23
1811 #define SND_RME_GET_CURRENT_FREQ 17
1812 #define SND_RME_CLK_SYSTEM_SHIFT 16
1813 #define SND_RME_CLK_SYSTEM_MASK 0x1f
1814 #define SND_RME_CLK_AES_SHIFT 8
1815 #define SND_RME_CLK_SPDIF_SHIFT 12
1816 #define SND_RME_CLK_AES_SPDIF_MASK 0xf
1817 #define SND_RME_CLK_SYNC_SHIFT 6
1818 #define SND_RME_CLK_SYNC_MASK 0x3
1819 #define SND_RME_CLK_FREQMUL_SHIFT 18
1820 #define SND_RME_CLK_FREQMUL_MASK 0x7
1821 #define SND_RME_CLK_SYSTEM(x) \
1822 ((x >> SND_RME_CLK_SYSTEM_SHIFT) & SND_RME_CLK_SYSTEM_MASK)
1823 #define SND_RME_CLK_AES(x) \
1824 ((x >> SND_RME_CLK_AES_SHIFT) & SND_RME_CLK_AES_SPDIF_MASK)
1825 #define SND_RME_CLK_SPDIF(x) \
1826 ((x >> SND_RME_CLK_SPDIF_SHIFT) & SND_RME_CLK_AES_SPDIF_MASK)
1827 #define SND_RME_CLK_SYNC(x) \
1828 ((x >> SND_RME_CLK_SYNC_SHIFT) & SND_RME_CLK_SYNC_MASK)
1829 #define SND_RME_CLK_FREQMUL(x) \
1830 ((x >> SND_RME_CLK_FREQMUL_SHIFT) & SND_RME_CLK_FREQMUL_MASK)
1831 #define SND_RME_CLK_AES_LOCK 0x1
1832 #define SND_RME_CLK_AES_SYNC 0x4
1833 #define SND_RME_CLK_SPDIF_LOCK 0x2
1834 #define SND_RME_CLK_SPDIF_SYNC 0x8
1835 #define SND_RME_SPDIF_IF_SHIFT 4
1836 #define SND_RME_SPDIF_FORMAT_SHIFT 5
1837 #define SND_RME_BINARY_MASK 0x1
1838 #define SND_RME_SPDIF_IF(x) \
1839 ((x >> SND_RME_SPDIF_IF_SHIFT) & SND_RME_BINARY_MASK)
1840 #define SND_RME_SPDIF_FORMAT(x) \
1841 ((x >> SND_RME_SPDIF_FORMAT_SHIFT) & SND_RME_BINARY_MASK)
1843 static const u32 snd_rme_rate_table
[] = {
1844 32000, 44100, 48000, 50000,
1845 64000, 88200, 96000, 100000,
1846 128000, 176400, 192000, 200000,
1847 256000, 352800, 384000, 400000,
1848 512000, 705600, 768000, 800000
1850 /* maximum number of items for AES and S/PDIF rates for above table */
1851 #define SND_RME_RATE_IDX_AES_SPDIF_NUM 12
1853 enum snd_rme_domain
{
1854 SND_RME_DOMAIN_SYSTEM
,
1856 SND_RME_DOMAIN_SPDIF
1859 enum snd_rme_clock_status
{
1860 SND_RME_CLOCK_NOLOCK
,
1865 static int snd_rme_read_value(struct snd_usb_audio
*chip
,
1869 struct usb_device
*dev
= chip
->dev
;
1872 err
= snd_usb_ctl_msg(dev
, usb_rcvctrlpipe(dev
, 0),
1874 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
1876 value
, sizeof(*value
));
1879 "unable to issue vendor read request %d (ret = %d)",
1884 static int snd_rme_get_status1(struct snd_kcontrol
*kcontrol
,
1887 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
1888 struct snd_usb_audio
*chip
= list
->mixer
->chip
;
1891 err
= snd_usb_lock_shutdown(chip
);
1894 err
= snd_rme_read_value(chip
, SND_RME_GET_STATUS1
, status1
);
1895 snd_usb_unlock_shutdown(chip
);
1899 static int snd_rme_rate_get(struct snd_kcontrol
*kcontrol
,
1900 struct snd_ctl_elem_value
*ucontrol
)
1907 err
= snd_rme_get_status1(kcontrol
, &status1
);
1910 switch (kcontrol
->private_value
) {
1911 case SND_RME_DOMAIN_SYSTEM
:
1912 idx
= SND_RME_CLK_SYSTEM(status1
);
1913 if (idx
< ARRAY_SIZE(snd_rme_rate_table
))
1914 rate
= snd_rme_rate_table
[idx
];
1916 case SND_RME_DOMAIN_AES
:
1917 idx
= SND_RME_CLK_AES(status1
);
1918 if (idx
< SND_RME_RATE_IDX_AES_SPDIF_NUM
)
1919 rate
= snd_rme_rate_table
[idx
];
1921 case SND_RME_DOMAIN_SPDIF
:
1922 idx
= SND_RME_CLK_SPDIF(status1
);
1923 if (idx
< SND_RME_RATE_IDX_AES_SPDIF_NUM
)
1924 rate
= snd_rme_rate_table
[idx
];
1929 ucontrol
->value
.integer
.value
[0] = rate
;
1933 static int snd_rme_sync_state_get(struct snd_kcontrol
*kcontrol
,
1934 struct snd_ctl_elem_value
*ucontrol
)
1937 int idx
= SND_RME_CLOCK_NOLOCK
;
1940 err
= snd_rme_get_status1(kcontrol
, &status1
);
1943 switch (kcontrol
->private_value
) {
1944 case SND_RME_DOMAIN_AES
: /* AES */
1945 if (status1
& SND_RME_CLK_AES_SYNC
)
1946 idx
= SND_RME_CLOCK_SYNC
;
1947 else if (status1
& SND_RME_CLK_AES_LOCK
)
1948 idx
= SND_RME_CLOCK_LOCK
;
1950 case SND_RME_DOMAIN_SPDIF
: /* SPDIF */
1951 if (status1
& SND_RME_CLK_SPDIF_SYNC
)
1952 idx
= SND_RME_CLOCK_SYNC
;
1953 else if (status1
& SND_RME_CLK_SPDIF_LOCK
)
1954 idx
= SND_RME_CLOCK_LOCK
;
1959 ucontrol
->value
.enumerated
.item
[0] = idx
;
1963 static int snd_rme_spdif_if_get(struct snd_kcontrol
*kcontrol
,
1964 struct snd_ctl_elem_value
*ucontrol
)
1969 err
= snd_rme_get_status1(kcontrol
, &status1
);
1972 ucontrol
->value
.enumerated
.item
[0] = SND_RME_SPDIF_IF(status1
);
1976 static int snd_rme_spdif_format_get(struct snd_kcontrol
*kcontrol
,
1977 struct snd_ctl_elem_value
*ucontrol
)
1982 err
= snd_rme_get_status1(kcontrol
, &status1
);
1985 ucontrol
->value
.enumerated
.item
[0] = SND_RME_SPDIF_FORMAT(status1
);
1989 static int snd_rme_sync_source_get(struct snd_kcontrol
*kcontrol
,
1990 struct snd_ctl_elem_value
*ucontrol
)
1995 err
= snd_rme_get_status1(kcontrol
, &status1
);
1998 ucontrol
->value
.enumerated
.item
[0] = SND_RME_CLK_SYNC(status1
);
2002 static int snd_rme_current_freq_get(struct snd_kcontrol
*kcontrol
,
2003 struct snd_ctl_elem_value
*ucontrol
)
2005 struct usb_mixer_elem_list
*list
= snd_kcontrol_chip(kcontrol
);
2006 struct snd_usb_audio
*chip
= list
->mixer
->chip
;
2008 const u64 num
= 104857600000000ULL;
2013 err
= snd_usb_lock_shutdown(chip
);
2016 err
= snd_rme_read_value(chip
, SND_RME_GET_STATUS1
, &status1
);
2019 err
= snd_rme_read_value(chip
, SND_RME_GET_CURRENT_FREQ
, &den
);
2022 freq
= (den
== 0) ? 0 : div64_u64(num
, den
);
2023 freq
<<= SND_RME_CLK_FREQMUL(status1
);
2024 ucontrol
->value
.integer
.value
[0] = freq
;
2027 snd_usb_unlock_shutdown(chip
);
2031 static int snd_rme_rate_info(struct snd_kcontrol
*kcontrol
,
2032 struct snd_ctl_elem_info
*uinfo
)
2034 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
2036 switch (kcontrol
->private_value
) {
2037 case SND_RME_DOMAIN_SYSTEM
:
2038 uinfo
->value
.integer
.min
= 32000;
2039 uinfo
->value
.integer
.max
= 800000;
2041 case SND_RME_DOMAIN_AES
:
2042 case SND_RME_DOMAIN_SPDIF
:
2044 uinfo
->value
.integer
.min
= 0;
2045 uinfo
->value
.integer
.max
= 200000;
2047 uinfo
->value
.integer
.step
= 0;
2051 static int snd_rme_sync_state_info(struct snd_kcontrol
*kcontrol
,
2052 struct snd_ctl_elem_info
*uinfo
)
2054 static const char *const sync_states
[] = {
2055 "No Lock", "Lock", "Sync"
2058 return snd_ctl_enum_info(uinfo
, 1,
2059 ARRAY_SIZE(sync_states
), sync_states
);
2062 static int snd_rme_spdif_if_info(struct snd_kcontrol
*kcontrol
,
2063 struct snd_ctl_elem_info
*uinfo
)
2065 static const char *const spdif_if
[] = {
2066 "Coaxial", "Optical"
2069 return snd_ctl_enum_info(uinfo
, 1,
2070 ARRAY_SIZE(spdif_if
), spdif_if
);
2073 static int snd_rme_spdif_format_info(struct snd_kcontrol
*kcontrol
,
2074 struct snd_ctl_elem_info
*uinfo
)
2076 static const char *const optical_type
[] = {
2077 "Consumer", "Professional"
2080 return snd_ctl_enum_info(uinfo
, 1,
2081 ARRAY_SIZE(optical_type
), optical_type
);
2084 static int snd_rme_sync_source_info(struct snd_kcontrol
*kcontrol
,
2085 struct snd_ctl_elem_info
*uinfo
)
2087 static const char *const sync_sources
[] = {
2088 "Internal", "AES", "SPDIF", "Internal"
2091 return snd_ctl_enum_info(uinfo
, 1,
2092 ARRAY_SIZE(sync_sources
), sync_sources
);
2095 static struct snd_kcontrol_new snd_rme_controls
[] = {
2097 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2099 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2100 .info
= snd_rme_rate_info
,
2101 .get
= snd_rme_rate_get
,
2102 .private_value
= SND_RME_DOMAIN_AES
2105 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2107 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2108 .info
= snd_rme_sync_state_info
,
2109 .get
= snd_rme_sync_state_get
,
2110 .private_value
= SND_RME_DOMAIN_AES
2113 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2114 .name
= "SPDIF Rate",
2115 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2116 .info
= snd_rme_rate_info
,
2117 .get
= snd_rme_rate_get
,
2118 .private_value
= SND_RME_DOMAIN_SPDIF
2121 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2122 .name
= "SPDIF Sync",
2123 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2124 .info
= snd_rme_sync_state_info
,
2125 .get
= snd_rme_sync_state_get
,
2126 .private_value
= SND_RME_DOMAIN_SPDIF
2129 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2130 .name
= "SPDIF Interface",
2131 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2132 .info
= snd_rme_spdif_if_info
,
2133 .get
= snd_rme_spdif_if_get
,
2136 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2137 .name
= "SPDIF Format",
2138 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2139 .info
= snd_rme_spdif_format_info
,
2140 .get
= snd_rme_spdif_format_get
,
2143 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2144 .name
= "Sync Source",
2145 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2146 .info
= snd_rme_sync_source_info
,
2147 .get
= snd_rme_sync_source_get
2150 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2151 .name
= "System Rate",
2152 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2153 .info
= snd_rme_rate_info
,
2154 .get
= snd_rme_rate_get
,
2155 .private_value
= SND_RME_DOMAIN_SYSTEM
2158 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2159 .name
= "Current Frequency",
2160 .access
= SNDRV_CTL_ELEM_ACCESS_READ
| SNDRV_CTL_ELEM_ACCESS_VOLATILE
,
2161 .info
= snd_rme_rate_info
,
2162 .get
= snd_rme_current_freq_get
2166 static int snd_rme_controls_create(struct usb_mixer_interface
*mixer
)
2170 for (i
= 0; i
< ARRAY_SIZE(snd_rme_controls
); ++i
) {
2171 err
= add_single_ctl_with_resume(mixer
, 0,
2173 &snd_rme_controls
[i
],
2182 int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface
*mixer
)
2186 err
= snd_usb_soundblaster_remote_init(mixer
);
2190 switch (mixer
->chip
->usb_id
) {
2191 /* Tascam US-16x08 */
2192 case USB_ID(0x0644, 0x8047):
2193 err
= snd_us16x08_controls_create(mixer
);
2195 case USB_ID(0x041e, 0x3020):
2196 case USB_ID(0x041e, 0x3040):
2197 case USB_ID(0x041e, 0x3042):
2198 case USB_ID(0x041e, 0x30df):
2199 case USB_ID(0x041e, 0x3048):
2200 err
= snd_audigy2nx_controls_create(mixer
);
2203 snd_card_ro_proc_new(mixer
->chip
->card
, "audigy2nx",
2204 mixer
, snd_audigy2nx_proc_read
);
2208 case USB_ID(0x041e, 0x3f19):
2209 err
= snd_emu0204_controls_create(mixer
);
2212 case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
2213 case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C400 */
2214 err
= snd_c400_create_mixer(mixer
);
2217 case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
2218 case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
2219 err
= snd_ftu_create_mixer(mixer
);
2222 case USB_ID(0x0b05, 0x1739): /* ASUS Xonar U1 */
2223 case USB_ID(0x0b05, 0x1743): /* ASUS Xonar U1 (2) */
2224 case USB_ID(0x0b05, 0x17a0): /* ASUS Xonar U3 */
2225 err
= snd_xonar_u1_controls_create(mixer
);
2228 case USB_ID(0x0d8c, 0x0103): /* Audio Advantage Micro II */
2229 err
= snd_microii_controls_create(mixer
);
2232 case USB_ID(0x0dba, 0x1000): /* Digidesign Mbox 1 */
2233 err
= snd_mbox1_create_sync_switch(mixer
);
2236 case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
2237 err
= snd_nativeinstruments_create_mixer(mixer
,
2238 snd_nativeinstruments_ta6_mixers
,
2239 ARRAY_SIZE(snd_nativeinstruments_ta6_mixers
));
2242 case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
2243 err
= snd_nativeinstruments_create_mixer(mixer
,
2244 snd_nativeinstruments_ta10_mixers
,
2245 ARRAY_SIZE(snd_nativeinstruments_ta10_mixers
));
2248 case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
2249 /* detection is disabled in mixer_maps.c */
2250 err
= snd_create_std_mono_table(mixer
, ebox44_table
);
2253 case USB_ID(0x1235, 0x8012): /* Focusrite Scarlett 6i6 */
2254 case USB_ID(0x1235, 0x8002): /* Focusrite Scarlett 8i6 */
2255 case USB_ID(0x1235, 0x8004): /* Focusrite Scarlett 18i6 */
2256 case USB_ID(0x1235, 0x8014): /* Focusrite Scarlett 18i8 */
2257 case USB_ID(0x1235, 0x800c): /* Focusrite Scarlett 18i20 */
2258 err
= snd_scarlett_controls_create(mixer
);
2261 case USB_ID(0x041e, 0x323b): /* Creative Sound Blaster E1 */
2262 err
= snd_soundblaster_e1_switch_create(mixer
);
2264 case USB_ID(0x0bda, 0x4014): /* Dell WD15 dock */
2265 err
= dell_dock_mixer_init(mixer
);
2268 case USB_ID(0x2a39, 0x3fd2): /* RME ADI-2 Pro */
2269 case USB_ID(0x2a39, 0x3fd3): /* RME ADI-2 DAC */
2270 case USB_ID(0x2a39, 0x3fd4): /* RME */
2271 err
= snd_rme_controls_create(mixer
);
2279 void snd_usb_mixer_resume_quirk(struct usb_mixer_interface
*mixer
)
2281 switch (mixer
->chip
->usb_id
) {
2282 case USB_ID(0x0bda, 0x4014): /* Dell WD15 dock */
2283 dell_dock_mixer_init(mixer
);
2289 void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface
*mixer
,
2294 /* unit ids specific to Extigy/Audigy 2 NX: */
2296 case 0: /* remote control */
2297 mixer
->rc_urb
->dev
= mixer
->chip
->dev
;
2298 usb_submit_urb(mixer
->rc_urb
, GFP_ATOMIC
);
2300 case 4: /* digital in jack */
2301 case 7: /* line in jacks */
2302 case 19: /* speaker out jacks */
2303 case 20: /* headphones out jack */
2305 /* live24ext: 4 = line-in jack */
2306 case 3: /* hp-out jack (may actuate Mute) */
2307 if (mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3040) ||
2308 mixer
->chip
->usb_id
== USB_ID(0x041e, 0x3048))
2309 snd_usb_mixer_notify_id(mixer
, mixer
->rc_cfg
->mute_mixer_id
);
2312 usb_audio_dbg(mixer
->chip
, "memory change in unknown unit %d\n", unitid
);
2317 static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface
*mixer
,
2318 struct usb_mixer_elem_info
*cval
,
2319 struct snd_kcontrol
*kctl
)
2321 /* Approximation using 10 ranges based on output measurement on hw v1.2.
2322 * This seems close to the cubic mapping e.g. alsamixer uses. */
2323 static const DECLARE_TLV_DB_RANGE(scale
,
2324 0, 1, TLV_DB_MINMAX_ITEM(-5300, -4970),
2325 2, 5, TLV_DB_MINMAX_ITEM(-4710, -4160),
2326 6, 7, TLV_DB_MINMAX_ITEM(-3884, -3710),
2327 8, 14, TLV_DB_MINMAX_ITEM(-3443, -2560),
2328 15, 16, TLV_DB_MINMAX_ITEM(-2475, -2324),
2329 17, 19, TLV_DB_MINMAX_ITEM(-2228, -2031),
2330 20, 26, TLV_DB_MINMAX_ITEM(-1910, -1393),
2331 27, 31, TLV_DB_MINMAX_ITEM(-1322, -1032),
2332 32, 40, TLV_DB_MINMAX_ITEM(-968, -490),
2333 41, 50, TLV_DB_MINMAX_ITEM(-441, 0),
2336 if (cval
->min
== 0 && cval
->max
== 50) {
2337 usb_audio_info(mixer
->chip
, "applying DragonFly dB scale quirk (0-50 variant)\n");
2338 kctl
->tlv
.p
= scale
;
2339 kctl
->vd
[0].access
|= SNDRV_CTL_ELEM_ACCESS_TLV_READ
;
2340 kctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
;
2342 } else if (cval
->min
== 0 && cval
->max
<= 1000) {
2343 /* Some other clearly broken DragonFly variant.
2344 * At least a 0..53 variant (hw v1.0) exists.
2346 usb_audio_info(mixer
->chip
, "ignoring too narrow dB range on a DragonFly device");
2347 kctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
;
2351 void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface
*mixer
,
2352 struct usb_mixer_elem_info
*cval
, int unitid
,
2353 struct snd_kcontrol
*kctl
)
2355 switch (mixer
->chip
->usb_id
) {
2356 case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */
2357 if (unitid
== 7 && cval
->control
== UAC_FU_VOLUME
)
2358 snd_dragonfly_quirk_db_scale(mixer
, cval
, kctl
);
2360 /* lowest playback value is muted on C-Media devices */
2361 case USB_ID(0x0d8c, 0x000c):
2362 case USB_ID(0x0d8c, 0x0014):
2363 if (strstr(kctl
->id
.name
, "Playback"))