2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #include <linux/init.h>
18 #include <linux/slab.h>
19 #include <linux/usb.h>
20 #include <linux/usb/audio.h>
21 #include <linux/usb/midi.h>
23 #include <sound/control.h>
24 #include <sound/core.h>
25 #include <sound/info.h>
26 #include <sound/pcm.h>
31 #include "mixer_quirks.h"
41 * handle the quirks for the contained interfaces
43 static int create_composite_quirk(struct snd_usb_audio
*chip
,
44 struct usb_interface
*iface
,
45 struct usb_driver
*driver
,
46 const struct snd_usb_audio_quirk
*quirk_comp
)
48 int probed_ifnum
= get_iface_desc(iface
->altsetting
)->bInterfaceNumber
;
49 const struct snd_usb_audio_quirk
*quirk
;
52 for (quirk
= quirk_comp
->data
; quirk
->ifnum
>= 0; ++quirk
) {
53 iface
= usb_ifnum_to_if(chip
->dev
, quirk
->ifnum
);
56 if (quirk
->ifnum
!= probed_ifnum
&&
57 usb_interface_claimed(iface
))
59 err
= snd_usb_create_quirk(chip
, iface
, driver
, quirk
);
64 for (quirk
= quirk_comp
->data
; quirk
->ifnum
>= 0; ++quirk
) {
65 iface
= usb_ifnum_to_if(chip
->dev
, quirk
->ifnum
);
68 if (quirk
->ifnum
!= probed_ifnum
&&
69 !usb_interface_claimed(iface
))
70 usb_driver_claim_interface(driver
, iface
, (void *)-1L);
76 static int ignore_interface_quirk(struct snd_usb_audio
*chip
,
77 struct usb_interface
*iface
,
78 struct usb_driver
*driver
,
79 const struct snd_usb_audio_quirk
*quirk
)
86 * Allow alignment on audio sub-slot (channel samples) rather than
87 * on audio slots (audio frames)
89 static int create_align_transfer_quirk(struct snd_usb_audio
*chip
,
90 struct usb_interface
*iface
,
91 struct usb_driver
*driver
,
92 const struct snd_usb_audio_quirk
*quirk
)
95 return 1; /* Continue with creating streams and mixer */
98 static int create_any_midi_quirk(struct snd_usb_audio
*chip
,
99 struct usb_interface
*intf
,
100 struct usb_driver
*driver
,
101 const struct snd_usb_audio_quirk
*quirk
)
103 return snd_usbmidi_create(chip
->card
, intf
, &chip
->midi_list
, quirk
);
107 * create a stream for an interface with proper descriptors
109 static int create_standard_audio_quirk(struct snd_usb_audio
*chip
,
110 struct usb_interface
*iface
,
111 struct usb_driver
*driver
,
112 const struct snd_usb_audio_quirk
*quirk
)
114 struct usb_host_interface
*alts
;
115 struct usb_interface_descriptor
*altsd
;
118 if (chip
->usb_id
== USB_ID(0x1686, 0x00dd)) /* Zoom R16/24 */
119 chip
->tx_length_quirk
= 1;
121 alts
= &iface
->altsetting
[0];
122 altsd
= get_iface_desc(alts
);
123 err
= snd_usb_parse_audio_interface(chip
, altsd
->bInterfaceNumber
);
125 usb_audio_err(chip
, "cannot setup if %d: error %d\n",
126 altsd
->bInterfaceNumber
, err
);
129 /* reset the current interface */
130 usb_set_interface(chip
->dev
, altsd
->bInterfaceNumber
, 0);
135 * create a stream for an endpoint/altsetting without proper descriptors
137 static int create_fixed_stream_quirk(struct snd_usb_audio
*chip
,
138 struct usb_interface
*iface
,
139 struct usb_driver
*driver
,
140 const struct snd_usb_audio_quirk
*quirk
)
142 struct audioformat
*fp
;
143 struct usb_host_interface
*alts
;
144 struct usb_interface_descriptor
*altsd
;
146 unsigned *rate_table
= NULL
;
148 fp
= kmemdup(quirk
->data
, sizeof(*fp
), GFP_KERNEL
);
152 INIT_LIST_HEAD(&fp
->list
);
153 if (fp
->nr_rates
> MAX_NR_RATES
) {
157 if (fp
->nr_rates
> 0) {
158 rate_table
= kmemdup(fp
->rate_table
,
159 sizeof(int) * fp
->nr_rates
, GFP_KERNEL
);
164 fp
->rate_table
= rate_table
;
167 stream
= (fp
->endpoint
& USB_DIR_IN
)
168 ? SNDRV_PCM_STREAM_CAPTURE
: SNDRV_PCM_STREAM_PLAYBACK
;
169 err
= snd_usb_add_audio_stream(chip
, stream
, fp
);
172 if (fp
->iface
!= get_iface_desc(&iface
->altsetting
[0])->bInterfaceNumber
||
173 fp
->altset_idx
>= iface
->num_altsetting
) {
177 alts
= &iface
->altsetting
[fp
->altset_idx
];
178 altsd
= get_iface_desc(alts
);
179 if (altsd
->bNumEndpoints
< 1) {
184 fp
->protocol
= altsd
->bInterfaceProtocol
;
186 if (fp
->datainterval
== 0)
187 fp
->datainterval
= snd_usb_parse_datainterval(chip
, alts
);
188 if (fp
->maxpacksize
== 0)
189 fp
->maxpacksize
= le16_to_cpu(get_endpoint(alts
, 0)->wMaxPacketSize
);
190 usb_set_interface(chip
->dev
, fp
->iface
, 0);
191 snd_usb_init_pitch(chip
, fp
->iface
, alts
, fp
);
192 snd_usb_init_sample_rate(chip
, fp
->iface
, alts
, fp
, fp
->rate_max
);
196 list_del(&fp
->list
); /* unlink for avoiding double-free */
202 static int create_auto_pcm_quirk(struct snd_usb_audio
*chip
,
203 struct usb_interface
*iface
,
204 struct usb_driver
*driver
)
206 struct usb_host_interface
*alts
;
207 struct usb_interface_descriptor
*altsd
;
208 struct usb_endpoint_descriptor
*epd
;
209 struct uac1_as_header_descriptor
*ashd
;
210 struct uac_format_type_i_discrete_descriptor
*fmtd
;
213 * Most Roland/Yamaha audio streaming interfaces have more or less
214 * standard descriptors, but older devices might lack descriptors, and
215 * future ones might change, so ensure that we fail silently if the
216 * interface doesn't look exactly right.
219 /* must have a non-zero altsetting for streaming */
220 if (iface
->num_altsetting
< 2)
222 alts
= &iface
->altsetting
[1];
223 altsd
= get_iface_desc(alts
);
225 /* must have an isochronous endpoint for streaming */
226 if (altsd
->bNumEndpoints
< 1)
228 epd
= get_endpoint(alts
, 0);
229 if (!usb_endpoint_xfer_isoc(epd
))
232 /* must have format descriptors */
233 ashd
= snd_usb_find_csint_desc(alts
->extra
, alts
->extralen
, NULL
,
235 fmtd
= snd_usb_find_csint_desc(alts
->extra
, alts
->extralen
, NULL
,
237 if (!ashd
|| ashd
->bLength
< 7 ||
238 !fmtd
|| fmtd
->bLength
< 8)
241 return create_standard_audio_quirk(chip
, iface
, driver
, NULL
);
244 static int create_yamaha_midi_quirk(struct snd_usb_audio
*chip
,
245 struct usb_interface
*iface
,
246 struct usb_driver
*driver
,
247 struct usb_host_interface
*alts
)
249 static const struct snd_usb_audio_quirk yamaha_midi_quirk
= {
250 .type
= QUIRK_MIDI_YAMAHA
252 struct usb_midi_in_jack_descriptor
*injd
;
253 struct usb_midi_out_jack_descriptor
*outjd
;
255 /* must have some valid jack descriptors */
256 injd
= snd_usb_find_csint_desc(alts
->extra
, alts
->extralen
,
257 NULL
, USB_MS_MIDI_IN_JACK
);
258 outjd
= snd_usb_find_csint_desc(alts
->extra
, alts
->extralen
,
259 NULL
, USB_MS_MIDI_OUT_JACK
);
262 if ((injd
&& !snd_usb_validate_midi_desc(injd
)) ||
263 (outjd
&& !snd_usb_validate_midi_desc(outjd
)))
265 if (injd
&& (injd
->bLength
< 5 ||
266 (injd
->bJackType
!= USB_MS_EMBEDDED
&&
267 injd
->bJackType
!= USB_MS_EXTERNAL
)))
269 if (outjd
&& (outjd
->bLength
< 6 ||
270 (outjd
->bJackType
!= USB_MS_EMBEDDED
&&
271 outjd
->bJackType
!= USB_MS_EXTERNAL
)))
273 return create_any_midi_quirk(chip
, iface
, driver
, &yamaha_midi_quirk
);
276 static int create_roland_midi_quirk(struct snd_usb_audio
*chip
,
277 struct usb_interface
*iface
,
278 struct usb_driver
*driver
,
279 struct usb_host_interface
*alts
)
281 static const struct snd_usb_audio_quirk roland_midi_quirk
= {
282 .type
= QUIRK_MIDI_ROLAND
284 u8
*roland_desc
= NULL
;
286 /* might have a vendor-specific descriptor <06 24 F1 02 ...> */
288 roland_desc
= snd_usb_find_csint_desc(alts
->extra
,
293 if (roland_desc
[0] < 6 || roland_desc
[3] != 2)
295 return create_any_midi_quirk(chip
, iface
, driver
,
300 static int create_std_midi_quirk(struct snd_usb_audio
*chip
,
301 struct usb_interface
*iface
,
302 struct usb_driver
*driver
,
303 struct usb_host_interface
*alts
)
305 struct usb_ms_header_descriptor
*mshd
;
306 struct usb_ms_endpoint_descriptor
*msepd
;
308 /* must have the MIDIStreaming interface header descriptor*/
309 mshd
= (struct usb_ms_header_descriptor
*)alts
->extra
;
310 if (alts
->extralen
< 7 ||
312 mshd
->bDescriptorType
!= USB_DT_CS_INTERFACE
||
313 mshd
->bDescriptorSubtype
!= USB_MS_HEADER
)
315 /* must have the MIDIStreaming endpoint descriptor*/
316 msepd
= (struct usb_ms_endpoint_descriptor
*)alts
->endpoint
[0].extra
;
317 if (alts
->endpoint
[0].extralen
< 4 ||
318 msepd
->bLength
< 4 ||
319 msepd
->bDescriptorType
!= USB_DT_CS_ENDPOINT
||
320 msepd
->bDescriptorSubtype
!= UAC_MS_GENERAL
||
321 msepd
->bNumEmbMIDIJack
< 1 ||
322 msepd
->bNumEmbMIDIJack
> 16)
325 return create_any_midi_quirk(chip
, iface
, driver
, NULL
);
328 static int create_auto_midi_quirk(struct snd_usb_audio
*chip
,
329 struct usb_interface
*iface
,
330 struct usb_driver
*driver
)
332 struct usb_host_interface
*alts
;
333 struct usb_interface_descriptor
*altsd
;
334 struct usb_endpoint_descriptor
*epd
;
337 alts
= &iface
->altsetting
[0];
338 altsd
= get_iface_desc(alts
);
340 /* must have at least one bulk/interrupt endpoint for streaming */
341 if (altsd
->bNumEndpoints
< 1)
343 epd
= get_endpoint(alts
, 0);
344 if (!usb_endpoint_xfer_bulk(epd
) &&
345 !usb_endpoint_xfer_int(epd
))
348 switch (USB_ID_VENDOR(chip
->usb_id
)) {
349 case 0x0499: /* Yamaha */
350 err
= create_yamaha_midi_quirk(chip
, iface
, driver
, alts
);
354 case 0x0582: /* Roland */
355 err
= create_roland_midi_quirk(chip
, iface
, driver
, alts
);
361 return create_std_midi_quirk(chip
, iface
, driver
, alts
);
364 static int create_autodetect_quirk(struct snd_usb_audio
*chip
,
365 struct usb_interface
*iface
,
366 struct usb_driver
*driver
)
370 err
= create_auto_pcm_quirk(chip
, iface
, driver
);
372 err
= create_auto_midi_quirk(chip
, iface
, driver
);
376 static int create_autodetect_quirks(struct snd_usb_audio
*chip
,
377 struct usb_interface
*iface
,
378 struct usb_driver
*driver
,
379 const struct snd_usb_audio_quirk
*quirk
)
381 int probed_ifnum
= get_iface_desc(iface
->altsetting
)->bInterfaceNumber
;
382 int ifcount
, ifnum
, err
;
384 err
= create_autodetect_quirk(chip
, iface
, driver
);
389 * ALSA PCM playback/capture devices cannot be registered in two steps,
390 * so we have to claim the other corresponding interface here.
392 ifcount
= chip
->dev
->actconfig
->desc
.bNumInterfaces
;
393 for (ifnum
= 0; ifnum
< ifcount
; ifnum
++) {
394 if (ifnum
== probed_ifnum
|| quirk
->ifnum
>= 0)
396 iface
= usb_ifnum_to_if(chip
->dev
, ifnum
);
398 usb_interface_claimed(iface
) ||
399 get_iface_desc(iface
->altsetting
)->bInterfaceClass
!=
400 USB_CLASS_VENDOR_SPEC
)
403 err
= create_autodetect_quirk(chip
, iface
, driver
);
405 usb_driver_claim_interface(driver
, iface
, (void *)-1L);
412 * Create a stream for an Edirol UA-700/UA-25/UA-4FX interface.
413 * The only way to detect the sample rate is by looking at wMaxPacketSize.
415 static int create_uaxx_quirk(struct snd_usb_audio
*chip
,
416 struct usb_interface
*iface
,
417 struct usb_driver
*driver
,
418 const struct snd_usb_audio_quirk
*quirk
)
420 static const struct audioformat ua_format
= {
421 .formats
= SNDRV_PCM_FMTBIT_S24_3LE
,
423 .fmt_type
= UAC_FORMAT_TYPE_I
,
426 .rates
= SNDRV_PCM_RATE_CONTINUOUS
,
428 struct usb_host_interface
*alts
;
429 struct usb_interface_descriptor
*altsd
;
430 struct audioformat
*fp
;
433 /* both PCM and MIDI interfaces have 2 or more altsettings */
434 if (iface
->num_altsetting
< 2)
436 alts
= &iface
->altsetting
[1];
437 altsd
= get_iface_desc(alts
);
439 if (altsd
->bNumEndpoints
== 2) {
440 static const struct snd_usb_midi_endpoint_info ua700_ep
= {
441 .out_cables
= 0x0003,
444 static const struct snd_usb_audio_quirk ua700_quirk
= {
445 .type
= QUIRK_MIDI_FIXED_ENDPOINT
,
448 static const struct snd_usb_midi_endpoint_info uaxx_ep
= {
449 .out_cables
= 0x0001,
452 static const struct snd_usb_audio_quirk uaxx_quirk
= {
453 .type
= QUIRK_MIDI_FIXED_ENDPOINT
,
456 const struct snd_usb_audio_quirk
*quirk
=
457 chip
->usb_id
== USB_ID(0x0582, 0x002b)
458 ? &ua700_quirk
: &uaxx_quirk
;
459 return __snd_usbmidi_create(chip
->card
, iface
,
460 &chip
->midi_list
, quirk
,
464 if (altsd
->bNumEndpoints
!= 1)
467 fp
= kmemdup(&ua_format
, sizeof(*fp
), GFP_KERNEL
);
471 fp
->iface
= altsd
->bInterfaceNumber
;
472 fp
->endpoint
= get_endpoint(alts
, 0)->bEndpointAddress
;
473 fp
->ep_attr
= get_endpoint(alts
, 0)->bmAttributes
;
474 fp
->datainterval
= 0;
475 fp
->maxpacksize
= le16_to_cpu(get_endpoint(alts
, 0)->wMaxPacketSize
);
476 INIT_LIST_HEAD(&fp
->list
);
478 switch (fp
->maxpacksize
) {
480 fp
->rate_max
= fp
->rate_min
= 44100;
484 fp
->rate_max
= fp
->rate_min
= 48000;
488 fp
->rate_max
= fp
->rate_min
= 96000;
491 usb_audio_err(chip
, "unknown sample rate\n");
496 stream
= (fp
->endpoint
& USB_DIR_IN
)
497 ? SNDRV_PCM_STREAM_CAPTURE
: SNDRV_PCM_STREAM_PLAYBACK
;
498 err
= snd_usb_add_audio_stream(chip
, stream
, fp
);
500 list_del(&fp
->list
); /* unlink for avoiding double-free */
504 usb_set_interface(chip
->dev
, fp
->iface
, 0);
509 * Create a standard mixer for the specified interface.
511 static int create_standard_mixer_quirk(struct snd_usb_audio
*chip
,
512 struct usb_interface
*iface
,
513 struct usb_driver
*driver
,
514 const struct snd_usb_audio_quirk
*quirk
)
516 if (quirk
->ifnum
< 0)
519 return snd_usb_create_mixer(chip
, quirk
->ifnum
, 0);
523 static int setup_fmt_after_resume_quirk(struct snd_usb_audio
*chip
,
524 struct usb_interface
*iface
,
525 struct usb_driver
*driver
,
526 const struct snd_usb_audio_quirk
*quirk
)
528 chip
->setup_fmt_after_resume_quirk
= 1;
529 return 1; /* Continue with creating streams and mixer */
533 * audio-interface quirks
535 * returns zero if no standard audio/MIDI parsing is needed.
536 * returns a positive value if standard audio/midi interfaces are parsed
538 * returns a negative value at error.
540 int snd_usb_create_quirk(struct snd_usb_audio
*chip
,
541 struct usb_interface
*iface
,
542 struct usb_driver
*driver
,
543 const struct snd_usb_audio_quirk
*quirk
)
545 typedef int (*quirk_func_t
)(struct snd_usb_audio
*,
546 struct usb_interface
*,
548 const struct snd_usb_audio_quirk
*);
549 static const quirk_func_t quirk_funcs
[] = {
550 [QUIRK_IGNORE_INTERFACE
] = ignore_interface_quirk
,
551 [QUIRK_COMPOSITE
] = create_composite_quirk
,
552 [QUIRK_AUTODETECT
] = create_autodetect_quirks
,
553 [QUIRK_MIDI_STANDARD_INTERFACE
] = create_any_midi_quirk
,
554 [QUIRK_MIDI_FIXED_ENDPOINT
] = create_any_midi_quirk
,
555 [QUIRK_MIDI_YAMAHA
] = create_any_midi_quirk
,
556 [QUIRK_MIDI_ROLAND
] = create_any_midi_quirk
,
557 [QUIRK_MIDI_MIDIMAN
] = create_any_midi_quirk
,
558 [QUIRK_MIDI_NOVATION
] = create_any_midi_quirk
,
559 [QUIRK_MIDI_RAW_BYTES
] = create_any_midi_quirk
,
560 [QUIRK_MIDI_EMAGIC
] = create_any_midi_quirk
,
561 [QUIRK_MIDI_CME
] = create_any_midi_quirk
,
562 [QUIRK_MIDI_AKAI
] = create_any_midi_quirk
,
563 [QUIRK_MIDI_FTDI
] = create_any_midi_quirk
,
564 [QUIRK_MIDI_CH345
] = create_any_midi_quirk
,
565 [QUIRK_AUDIO_STANDARD_INTERFACE
] = create_standard_audio_quirk
,
566 [QUIRK_AUDIO_FIXED_ENDPOINT
] = create_fixed_stream_quirk
,
567 [QUIRK_AUDIO_EDIROL_UAXX
] = create_uaxx_quirk
,
568 [QUIRK_AUDIO_ALIGN_TRANSFER
] = create_align_transfer_quirk
,
569 [QUIRK_AUDIO_STANDARD_MIXER
] = create_standard_mixer_quirk
,
570 [QUIRK_SETUP_FMT_AFTER_RESUME
] = setup_fmt_after_resume_quirk
,
573 if (quirk
->type
< QUIRK_TYPE_COUNT
) {
574 return quirk_funcs
[quirk
->type
](chip
, iface
, driver
, quirk
);
576 usb_audio_err(chip
, "invalid quirk type %d\n", quirk
->type
);
585 #define EXTIGY_FIRMWARE_SIZE_OLD 794
586 #define EXTIGY_FIRMWARE_SIZE_NEW 483
588 static int snd_usb_extigy_boot_quirk(struct usb_device
*dev
, struct usb_interface
*intf
)
590 struct usb_host_config
*config
= dev
->actconfig
;
593 if (le16_to_cpu(get_cfg_desc(config
)->wTotalLength
) == EXTIGY_FIRMWARE_SIZE_OLD
||
594 le16_to_cpu(get_cfg_desc(config
)->wTotalLength
) == EXTIGY_FIRMWARE_SIZE_NEW
) {
595 dev_dbg(&dev
->dev
, "sending Extigy boot sequence...\n");
596 /* Send message to force it to reconnect with full interface. */
597 err
= snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
,0),
598 0x10, 0x43, 0x0001, 0x000a, NULL
, 0);
600 dev_dbg(&dev
->dev
, "error sending boot message: %d\n", err
);
601 err
= usb_get_descriptor(dev
, USB_DT_DEVICE
, 0,
602 &dev
->descriptor
, sizeof(dev
->descriptor
));
603 config
= dev
->actconfig
;
605 dev_dbg(&dev
->dev
, "error usb_get_descriptor: %d\n", err
);
606 err
= usb_reset_configuration(dev
);
608 dev_dbg(&dev
->dev
, "error usb_reset_configuration: %d\n", err
);
609 dev_dbg(&dev
->dev
, "extigy_boot: new boot length = %d\n",
610 le16_to_cpu(get_cfg_desc(config
)->wTotalLength
));
611 return -ENODEV
; /* quit this anyway */
616 static int snd_usb_audigy2nx_boot_quirk(struct usb_device
*dev
)
620 snd_usb_ctl_msg(dev
, usb_rcvctrlpipe(dev
, 0), 0x2a,
621 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
624 snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
, 0), 0x29,
625 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_OTHER
,
632 static int snd_usb_fasttrackpro_boot_quirk(struct usb_device
*dev
)
636 if (dev
->actconfig
->desc
.bConfigurationValue
== 1) {
638 "Fast Track Pro switching to config #2\n");
639 /* This function has to be available by the usb core module.
640 * if it is not avialable the boot quirk has to be left out
641 * and the configuration has to be set by udev or hotplug
644 err
= usb_driver_set_configuration(dev
, 2);
647 "error usb_driver_set_configuration: %d\n",
649 /* Always return an error, so that we stop creating a device
650 that will just be destroyed and recreated with a new
654 dev_info(&dev
->dev
, "Fast Track Pro config OK\n");
660 * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely
661 * documented in the device's data sheet.
663 static int snd_usb_cm106_write_int_reg(struct usb_device
*dev
, int reg
, u16 value
)
667 buf
[1] = value
& 0xff;
668 buf
[2] = (value
>> 8) & 0xff;
670 return snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
, 0), USB_REQ_SET_CONFIGURATION
,
671 USB_DIR_OUT
| USB_TYPE_CLASS
| USB_RECIP_ENDPOINT
,
675 static int snd_usb_cm106_boot_quirk(struct usb_device
*dev
)
678 * Enable line-out driver mode, set headphone source to front
679 * channels, enable stereo mic.
681 return snd_usb_cm106_write_int_reg(dev
, 2, 0x8004);
685 * C-Media CM6206 is based on CM106 with two additional
686 * registers that are not documented in the data sheet.
687 * Values here are chosen based on sniffing USB traffic
690 static int snd_usb_cm6206_boot_quirk(struct usb_device
*dev
)
693 int val
[] = {0x2004, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000};
695 for (reg
= 0; reg
< ARRAY_SIZE(val
); reg
++) {
696 err
= snd_usb_cm106_write_int_reg(dev
, reg
, val
[reg
]);
704 /* quirk for Plantronics GameCom 780 with CM6302 chip */
705 static int snd_usb_gamecon780_boot_quirk(struct usb_device
*dev
)
707 /* set the initial volume and don't change; other values are either
708 * too loud or silent due to firmware bug (bko#65251)
710 u8 buf
[2] = { 0x74, 0xe3 };
711 return snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
, 0), UAC_SET_CUR
,
712 USB_RECIP_INTERFACE
| USB_TYPE_CLASS
| USB_DIR_OUT
,
713 UAC_FU_VOLUME
<< 8, 9 << 8, buf
, 2);
717 * Novation Twitch DJ controller
718 * Focusrite Novation Saffire 6 USB audio card
720 static int snd_usb_novation_boot_quirk(struct usb_device
*dev
)
722 /* preemptively set up the device because otherwise the
723 * raw MIDI endpoints are not active */
724 usb_set_interface(dev
, 0, 1);
729 * This call will put the synth in "USB send" mode, i.e it will send MIDI
730 * messages through USB (this is disabled at startup). The synth will
731 * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB
732 * sign on its LCD. Values here are chosen based on sniffing USB traffic
735 static int snd_usb_accessmusic_boot_quirk(struct usb_device
*dev
)
737 int err
, actual_length
;
739 /* "midi send" enable */
740 static const u8 seq
[] = { 0x4e, 0x73, 0x52, 0x01 };
742 void *buf
= kmemdup(seq
, ARRAY_SIZE(seq
), GFP_KERNEL
);
745 err
= usb_interrupt_msg(dev
, usb_sndintpipe(dev
, 0x05), buf
,
746 ARRAY_SIZE(seq
), &actual_length
, 1000);
755 * Some sound cards from Native Instruments are in fact compliant to the USB
756 * audio standard of version 2 and other approved USB standards, even though
757 * they come up as vendor-specific device when first connected.
759 * However, they can be told to come up with a new set of descriptors
760 * upon their next enumeration, and the interfaces announced by the new
761 * descriptors will then be handled by the kernel's class drivers. As the
762 * product ID will also change, no further checks are required.
765 static int snd_usb_nativeinstruments_boot_quirk(struct usb_device
*dev
)
767 int ret
= usb_control_msg(dev
, usb_sndctrlpipe(dev
, 0),
768 0xaf, USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
769 1, 0, NULL
, 0, 1000);
774 usb_reset_device(dev
);
776 /* return -EAGAIN, so the creation of an audio interface for this
777 * temporary device is aborted. The device will reconnect with a
782 static void mbox2_setup_48_24_magic(struct usb_device
*dev
)
787 /* Choose 48000Hz permanently */
792 /* Send the magic! */
793 snd_usb_ctl_msg(dev
, usb_rcvctrlpipe(dev
, 0),
794 0x01, 0x22, 0x0100, 0x0085, &temp
, 0x0003);
795 snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
, 0),
796 0x81, 0xa2, 0x0100, 0x0085, &srate
, 0x0003);
797 snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
, 0),
798 0x81, 0xa2, 0x0100, 0x0086, &srate
, 0x0003);
799 snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
, 0),
800 0x81, 0xa2, 0x0100, 0x0003, &srate
, 0x0003);
804 /* Digidesign Mbox 2 needs to load firmware onboard
805 * and driver must wait a few seconds for initialisation.
808 #define MBOX2_FIRMWARE_SIZE 646
809 #define MBOX2_BOOT_LOADING 0x01 /* Hard coded into the device */
810 #define MBOX2_BOOT_READY 0x02 /* Hard coded into the device */
812 static int snd_usb_mbox2_boot_quirk(struct usb_device
*dev
)
814 struct usb_host_config
*config
= dev
->actconfig
;
816 u8 bootresponse
[0x12];
820 fwsize
= le16_to_cpu(get_cfg_desc(config
)->wTotalLength
);
822 if (fwsize
!= MBOX2_FIRMWARE_SIZE
) {
823 dev_err(&dev
->dev
, "Invalid firmware size=%d.\n", fwsize
);
827 dev_dbg(&dev
->dev
, "Sending Digidesign Mbox 2 boot sequence...\n");
830 bootresponse
[0] = MBOX2_BOOT_LOADING
;
831 while ((bootresponse
[0] == MBOX2_BOOT_LOADING
) && (count
< 10)) {
832 msleep(500); /* 0.5 second delay */
833 snd_usb_ctl_msg(dev
, usb_rcvctrlpipe(dev
, 0),
834 /* Control magic - load onboard firmware */
835 0x85, 0xc0, 0x0001, 0x0000, &bootresponse
, 0x0012);
836 if (bootresponse
[0] == MBOX2_BOOT_READY
)
838 dev_dbg(&dev
->dev
, "device not ready, resending boot sequence...\n");
842 if (bootresponse
[0] != MBOX2_BOOT_READY
) {
843 dev_err(&dev
->dev
, "Unknown bootresponse=%d, or timed out, ignoring device.\n", bootresponse
[0]);
847 dev_dbg(&dev
->dev
, "device initialised!\n");
849 err
= usb_get_descriptor(dev
, USB_DT_DEVICE
, 0,
850 &dev
->descriptor
, sizeof(dev
->descriptor
));
851 config
= dev
->actconfig
;
853 dev_dbg(&dev
->dev
, "error usb_get_descriptor: %d\n", err
);
855 err
= usb_reset_configuration(dev
);
857 dev_dbg(&dev
->dev
, "error usb_reset_configuration: %d\n", err
);
858 dev_dbg(&dev
->dev
, "mbox2_boot: new boot length = %d\n",
859 le16_to_cpu(get_cfg_desc(config
)->wTotalLength
));
861 mbox2_setup_48_24_magic(dev
);
863 dev_info(&dev
->dev
, "Digidesign Mbox 2: 24bit 48kHz");
865 return 0; /* Successful boot */
868 static int snd_usb_axefx3_boot_quirk(struct usb_device
*dev
)
872 dev_dbg(&dev
->dev
, "Waiting for Axe-Fx III to boot up...\n");
874 /* If the Axe-Fx III has not fully booted, it will timeout when trying
875 * to enable the audio streaming interface. A more generous timeout is
876 * used here to detect when the Axe-Fx III has finished booting as the
877 * set interface message will be acked once it has
879 err
= usb_control_msg(dev
, usb_sndctrlpipe(dev
, 0),
880 USB_REQ_SET_INTERFACE
, USB_RECIP_INTERFACE
,
881 1, 1, NULL
, 0, 120000);
884 "failed waiting for Axe-Fx III to boot: %d\n", err
);
888 dev_dbg(&dev
->dev
, "Axe-Fx III is now ready\n");
890 err
= usb_set_interface(dev
, 1, 0);
893 "error stopping Axe-Fx III interface: %d\n", err
);
901 #define MAUDIO_SET 0x01 /* parse device_setup */
902 #define MAUDIO_SET_COMPATIBLE 0x80 /* use only "win-compatible" interfaces */
903 #define MAUDIO_SET_DTS 0x02 /* enable DTS Digital Output */
904 #define MAUDIO_SET_96K 0x04 /* 48-96KHz rate if set, 8-48KHz otherwise */
905 #define MAUDIO_SET_24B 0x08 /* 24bits sample if set, 16bits otherwise */
906 #define MAUDIO_SET_DI 0x10 /* enable Digital Input */
907 #define MAUDIO_SET_MASK 0x1f /* bit mask for setup value */
908 #define MAUDIO_SET_24B_48K_DI 0x19 /* 24bits+48KHz+Digital Input */
909 #define MAUDIO_SET_24B_48K_NOTDI 0x09 /* 24bits+48KHz+No Digital Input */
910 #define MAUDIO_SET_16B_48K_DI 0x11 /* 16bits+48KHz+Digital Input */
911 #define MAUDIO_SET_16B_48K_NOTDI 0x01 /* 16bits+48KHz+No Digital Input */
913 static int quattro_skip_setting_quirk(struct snd_usb_audio
*chip
,
914 int iface
, int altno
)
916 /* Reset ALL ifaces to 0 altsetting.
917 * Call it for every possible altsetting of every interface.
919 usb_set_interface(chip
->dev
, iface
, 0);
920 if (chip
->setup
& MAUDIO_SET
) {
921 if (chip
->setup
& MAUDIO_SET_COMPATIBLE
) {
922 if (iface
!= 1 && iface
!= 2)
923 return 1; /* skip all interfaces but 1 and 2 */
926 if (iface
== 1 || iface
== 2)
927 return 1; /* skip interfaces 1 and 2 */
928 if ((chip
->setup
& MAUDIO_SET_96K
) && altno
!= 1)
929 return 1; /* skip this altsetting */
930 mask
= chip
->setup
& MAUDIO_SET_MASK
;
931 if (mask
== MAUDIO_SET_24B_48K_DI
&& altno
!= 2)
932 return 1; /* skip this altsetting */
933 if (mask
== MAUDIO_SET_24B_48K_NOTDI
&& altno
!= 3)
934 return 1; /* skip this altsetting */
935 if (mask
== MAUDIO_SET_16B_48K_NOTDI
&& altno
!= 4)
936 return 1; /* skip this altsetting */
940 "using altsetting %d for interface %d config %d\n",
941 altno
, iface
, chip
->setup
);
942 return 0; /* keep this altsetting */
945 static int audiophile_skip_setting_quirk(struct snd_usb_audio
*chip
,
949 /* Reset ALL ifaces to 0 altsetting.
950 * Call it for every possible altsetting of every interface.
952 usb_set_interface(chip
->dev
, iface
, 0);
954 if (chip
->setup
& MAUDIO_SET
) {
956 if ((chip
->setup
& MAUDIO_SET_DTS
) && altno
!= 6)
957 return 1; /* skip this altsetting */
958 if ((chip
->setup
& MAUDIO_SET_96K
) && altno
!= 1)
959 return 1; /* skip this altsetting */
960 mask
= chip
->setup
& MAUDIO_SET_MASK
;
961 if (mask
== MAUDIO_SET_24B_48K_DI
&& altno
!= 2)
962 return 1; /* skip this altsetting */
963 if (mask
== MAUDIO_SET_24B_48K_NOTDI
&& altno
!= 3)
964 return 1; /* skip this altsetting */
965 if (mask
== MAUDIO_SET_16B_48K_DI
&& altno
!= 4)
966 return 1; /* skip this altsetting */
967 if (mask
== MAUDIO_SET_16B_48K_NOTDI
&& altno
!= 5)
968 return 1; /* skip this altsetting */
971 return 0; /* keep this altsetting */
974 static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio
*chip
,
975 int iface
, int altno
)
977 /* Reset ALL ifaces to 0 altsetting.
978 * Call it for every possible altsetting of every interface.
980 usb_set_interface(chip
->dev
, iface
, 0);
982 /* possible configuration where both inputs and only one output is
983 *used is not supported by the current setup
985 if (chip
->setup
& (MAUDIO_SET
| MAUDIO_SET_24B
)) {
986 if (chip
->setup
& MAUDIO_SET_96K
) {
987 if (altno
!= 3 && altno
!= 6)
989 } else if (chip
->setup
& MAUDIO_SET_DI
) {
991 return 1; /* no analog input */
992 if (altno
!= 2 && altno
!= 5)
993 return 1; /* enable only altsets 2 and 5 */
996 return 1; /* disable digialt input */
997 if (altno
!= 2 && altno
!= 5)
998 return 1; /* enalbe only altsets 2 and 5 */
1001 /* keep only 16-Bit mode */
1007 "using altsetting %d for interface %d config %d\n",
1008 altno
, iface
, chip
->setup
);
1009 return 0; /* keep this altsetting */
1012 int snd_usb_apply_interface_quirk(struct snd_usb_audio
*chip
,
1016 /* audiophile usb: skip altsets incompatible with device_setup */
1017 if (chip
->usb_id
== USB_ID(0x0763, 0x2003))
1018 return audiophile_skip_setting_quirk(chip
, iface
, altno
);
1019 /* quattro usb: skip altsets incompatible with device_setup */
1020 if (chip
->usb_id
== USB_ID(0x0763, 0x2001))
1021 return quattro_skip_setting_quirk(chip
, iface
, altno
);
1022 /* fasttrackpro usb: skip altsets incompatible with device_setup */
1023 if (chip
->usb_id
== USB_ID(0x0763, 0x2012))
1024 return fasttrackpro_skip_setting_quirk(chip
, iface
, altno
);
1029 int snd_usb_apply_boot_quirk(struct usb_device
*dev
,
1030 struct usb_interface
*intf
,
1031 const struct snd_usb_audio_quirk
*quirk
,
1035 case USB_ID(0x041e, 0x3000):
1036 /* SB Extigy needs special boot-up sequence */
1037 /* if more models come, this will go to the quirk list. */
1038 return snd_usb_extigy_boot_quirk(dev
, intf
);
1040 case USB_ID(0x041e, 0x3020):
1041 /* SB Audigy 2 NX needs its own boot-up magic, too */
1042 return snd_usb_audigy2nx_boot_quirk(dev
);
1044 case USB_ID(0x10f5, 0x0200):
1045 /* C-Media CM106 / Turtle Beach Audio Advantage Roadie */
1046 return snd_usb_cm106_boot_quirk(dev
);
1048 case USB_ID(0x0d8c, 0x0102):
1049 /* C-Media CM6206 / CM106-Like Sound Device */
1050 case USB_ID(0x0ccd, 0x00b1): /* Terratec Aureon 7.1 USB */
1051 return snd_usb_cm6206_boot_quirk(dev
);
1053 case USB_ID(0x0dba, 0x3000):
1054 /* Digidesign Mbox 2 */
1055 return snd_usb_mbox2_boot_quirk(dev
);
1057 case USB_ID(0x1235, 0x0010): /* Focusrite Novation Saffire 6 USB */
1058 case USB_ID(0x1235, 0x0018): /* Focusrite Novation Twitch */
1059 return snd_usb_novation_boot_quirk(dev
);
1061 case USB_ID(0x133e, 0x0815):
1062 /* Access Music VirusTI Desktop */
1063 return snd_usb_accessmusic_boot_quirk(dev
);
1065 case USB_ID(0x17cc, 0x1000): /* Komplete Audio 6 */
1066 case USB_ID(0x17cc, 0x1010): /* Traktor Audio 6 */
1067 case USB_ID(0x17cc, 0x1020): /* Traktor Audio 10 */
1068 return snd_usb_nativeinstruments_boot_quirk(dev
);
1069 case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */
1070 return snd_usb_fasttrackpro_boot_quirk(dev
);
1071 case USB_ID(0x047f, 0xc010): /* Plantronics Gamecom 780 */
1072 return snd_usb_gamecon780_boot_quirk(dev
);
1073 case USB_ID(0x2466, 0x8010): /* Fractal Audio Axe-Fx 3 */
1074 return snd_usb_axefx3_boot_quirk(dev
);
1081 * check if the device uses big-endian samples
1083 int snd_usb_is_big_endian_format(struct snd_usb_audio
*chip
, struct audioformat
*fp
)
1085 /* it depends on altsetting whether the device is big-endian or not */
1086 switch (chip
->usb_id
) {
1087 case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */
1088 if (fp
->altsetting
== 2 || fp
->altsetting
== 3 ||
1089 fp
->altsetting
== 5 || fp
->altsetting
== 6)
1092 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
1093 if (chip
->setup
== 0x00 ||
1094 fp
->altsetting
== 1 || fp
->altsetting
== 2 ||
1095 fp
->altsetting
== 3)
1098 case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro */
1099 if (fp
->altsetting
== 2 || fp
->altsetting
== 3 ||
1100 fp
->altsetting
== 5 || fp
->altsetting
== 6)
1108 * For E-Mu 0404USB/0202USB/TrackerPre/0204 sample rate should be set for device,
1109 * not for interface.
1113 EMU_QUIRK_SR_44100HZ
= 0,
1114 EMU_QUIRK_SR_48000HZ
,
1115 EMU_QUIRK_SR_88200HZ
,
1116 EMU_QUIRK_SR_96000HZ
,
1117 EMU_QUIRK_SR_176400HZ
,
1118 EMU_QUIRK_SR_192000HZ
1121 static void set_format_emu_quirk(struct snd_usb_substream
*subs
,
1122 struct audioformat
*fmt
)
1124 unsigned char emu_samplerate_id
= 0;
1126 /* When capture is active
1127 * sample rate shouldn't be changed
1128 * by playback substream
1130 if (subs
->direction
== SNDRV_PCM_STREAM_PLAYBACK
) {
1131 if (subs
->stream
->substream
[SNDRV_PCM_STREAM_CAPTURE
].interface
!= -1)
1135 switch (fmt
->rate_min
) {
1137 emu_samplerate_id
= EMU_QUIRK_SR_48000HZ
;
1140 emu_samplerate_id
= EMU_QUIRK_SR_88200HZ
;
1143 emu_samplerate_id
= EMU_QUIRK_SR_96000HZ
;
1146 emu_samplerate_id
= EMU_QUIRK_SR_176400HZ
;
1149 emu_samplerate_id
= EMU_QUIRK_SR_192000HZ
;
1152 emu_samplerate_id
= EMU_QUIRK_SR_44100HZ
;
1155 snd_emuusb_set_samplerate(subs
->stream
->chip
, emu_samplerate_id
);
1156 subs
->pkt_offset_adj
= (emu_samplerate_id
>= EMU_QUIRK_SR_176400HZ
) ? 4 : 0;
1159 void snd_usb_set_format_quirk(struct snd_usb_substream
*subs
,
1160 struct audioformat
*fmt
)
1162 switch (subs
->stream
->chip
->usb_id
) {
1163 case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */
1164 case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */
1165 case USB_ID(0x041e, 0x3f0a): /* E-Mu Tracker Pre */
1166 case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */
1167 set_format_emu_quirk(subs
, fmt
);
1169 case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */
1170 subs
->stream_offset_adj
= 2;
1175 bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio
*chip
)
1177 /* devices which do not support reading the sample rate. */
1178 switch (chip
->usb_id
) {
1179 case USB_ID(0x041E, 0x4080): /* Creative Live Cam VF0610 */
1180 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
1181 case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */
1182 case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */
1183 case USB_ID(0x05a7, 0x1020): /* Bose Companion 5 */
1184 case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
1185 case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */
1186 case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */
1187 case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */
1188 case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */
1192 /* devices of these vendors don't support reading rate, either */
1193 switch (USB_ID_VENDOR(chip
->usb_id
)) {
1194 case 0x045E: /* MS Lifecam */
1195 case 0x047F: /* Plantronics */
1196 case 0x1de7: /* Phoenix Audio */
1203 /* ITF-USB DSD based DACs need a vendor cmd to switch
1204 * between PCM and native DSD mode
1206 static bool is_itf_usb_dsd_dac(unsigned int id
)
1209 case USB_ID(0x154e, 0x1002): /* Denon DCD-1500RE */
1210 case USB_ID(0x154e, 0x1003): /* Denon DA-300USB */
1211 case USB_ID(0x154e, 0x3005): /* Marantz HD-DAC1 */
1212 case USB_ID(0x154e, 0x3006): /* Marantz SA-14S1 */
1213 case USB_ID(0x1852, 0x5065): /* Luxman DA-06 */
1214 case USB_ID(0x0644, 0x8043): /* TEAC UD-501/UD-501V2/UD-503/NT-503 */
1215 case USB_ID(0x0644, 0x8044): /* Esoteric D-05X */
1216 case USB_ID(0x0644, 0x804a): /* TEAC UD-301 */
1222 int snd_usb_select_mode_quirk(struct snd_usb_substream
*subs
,
1223 struct audioformat
*fmt
)
1225 struct usb_device
*dev
= subs
->dev
;
1228 if (is_itf_usb_dsd_dac(subs
->stream
->chip
->usb_id
)) {
1229 /* First switch to alt set 0, otherwise the mode switch cmd
1230 * will not be accepted by the DAC
1232 err
= usb_set_interface(dev
, fmt
->iface
, 0);
1236 msleep(20); /* Delay needed after setting the interface */
1238 /* Vendor mode switch cmd is required. */
1239 if (fmt
->formats
& SNDRV_PCM_FMTBIT_DSD_U32_BE
) {
1240 /* DSD mode (DSD_U32) requested */
1241 err
= snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
, 0), 0,
1242 USB_DIR_OUT
|USB_TYPE_VENDOR
|USB_RECIP_INTERFACE
,
1248 /* PCM or DOP mode (S32) requested */
1249 /* PCM mode (S16) requested */
1250 err
= snd_usb_ctl_msg(dev
, usb_sndctrlpipe(dev
, 0), 0,
1251 USB_DIR_OUT
|USB_TYPE_VENDOR
|USB_RECIP_INTERFACE
,
1262 void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint
*ep
)
1265 * "Playback Design" products send bogus feedback data at the start
1266 * of the stream. Ignore them.
1268 if (USB_ID_VENDOR(ep
->chip
->usb_id
) == 0x23ba &&
1269 ep
->type
== SND_USB_ENDPOINT_TYPE_SYNC
)
1270 ep
->skip_packets
= 4;
1273 * M-Audio Fast Track C400/C600 - when packets are not skipped, real
1274 * world latency varies by approx. +/- 50 frames (at 96KHz) each time
1275 * the stream is (re)started. When skipping packets 16 at endpoint
1276 * start up, the real world latency is stable within +/- 1 frame (also
1277 * across power cycles).
1279 if ((ep
->chip
->usb_id
== USB_ID(0x0763, 0x2030) ||
1280 ep
->chip
->usb_id
== USB_ID(0x0763, 0x2031)) &&
1281 ep
->type
== SND_USB_ENDPOINT_TYPE_DATA
)
1282 ep
->skip_packets
= 16;
1284 /* Work around devices that report unreasonable feedback data */
1285 if ((ep
->chip
->usb_id
== USB_ID(0x0644, 0x8038) || /* TEAC UD-H01 */
1286 ep
->chip
->usb_id
== USB_ID(0x1852, 0x5034)) && /* T+A Dac8 */
1287 ep
->syncmaxsize
== 4)
1288 ep
->tenor_fb_quirk
= 1;
1291 void snd_usb_set_interface_quirk(struct usb_device
*dev
)
1293 struct snd_usb_audio
*chip
= dev_get_drvdata(&dev
->dev
);
1298 * "Playback Design" products need a 50ms delay after setting the
1301 switch (USB_ID_VENDOR(chip
->usb_id
)) {
1302 case 0x23ba: /* Playback Design */
1303 case 0x0644: /* TEAC Corp. */
1309 /* quirk applied after snd_usb_ctl_msg(); not applied during boot quirks */
1310 void snd_usb_ctl_msg_quirk(struct usb_device
*dev
, unsigned int pipe
,
1311 __u8 request
, __u8 requesttype
, __u16 value
,
1312 __u16 index
, void *data
, __u16 size
)
1314 struct snd_usb_audio
*chip
= dev_get_drvdata(&dev
->dev
);
1319 * "Playback Design" products need a 20ms delay after each
1320 * class compliant request
1322 if (USB_ID_VENDOR(chip
->usb_id
) == 0x23ba &&
1323 (requesttype
& USB_TYPE_MASK
) == USB_TYPE_CLASS
)
1327 * "TEAC Corp." products need a 20ms delay after each
1328 * class compliant request
1330 if (USB_ID_VENDOR(chip
->usb_id
) == 0x0644 &&
1331 (requesttype
& USB_TYPE_MASK
) == USB_TYPE_CLASS
)
1334 /* ITF-USB DSD based DACs functionality need a delay
1335 * after each class compliant request
1337 if (is_itf_usb_dsd_dac(chip
->usb_id
)
1338 && (requesttype
& USB_TYPE_MASK
) == USB_TYPE_CLASS
)
1341 /* Zoom R16/24, Logitech H650e, Jabra 550a, Kingston HyperX needs a tiny
1342 * delay here, otherwise requests like get/set frequency return as
1343 * failed despite actually succeeding.
1345 if ((chip
->usb_id
== USB_ID(0x1686, 0x00dd) ||
1346 chip
->usb_id
== USB_ID(0x046d, 0x0a46) ||
1347 chip
->usb_id
== USB_ID(0x0b0e, 0x0349) ||
1348 chip
->usb_id
== USB_ID(0x0951, 0x16ad)) &&
1349 (requesttype
& USB_TYPE_MASK
) == USB_TYPE_CLASS
)
1350 usleep_range(1000, 2000);
1353 * Samsung USBC Headset (AKG) need a tiny delay after each
1354 * class compliant request. (Model number: AAM625R or AAM627R)
1356 if (chip
->usb_id
== USB_ID(0x04e8, 0xa051) &&
1357 (requesttype
& USB_TYPE_MASK
) == USB_TYPE_CLASS
)
1358 usleep_range(5000, 6000);
1362 * snd_usb_interface_dsd_format_quirks() is called from format.c to
1363 * augment the PCM format bit-field for DSD types. The UAC standards
1364 * don't have a designated bit field to denote DSD-capable interfaces,
1365 * hence all hardware that is known to support this format has to be
1368 u64
snd_usb_interface_dsd_format_quirks(struct snd_usb_audio
*chip
,
1369 struct audioformat
*fp
,
1370 unsigned int sample_bytes
)
1372 struct usb_interface
*iface
;
1374 /* Playback Designs */
1375 if (USB_ID_VENDOR(chip
->usb_id
) == 0x23ba &&
1376 USB_ID_PRODUCT(chip
->usb_id
) < 0x0110) {
1377 switch (fp
->altsetting
) {
1380 return SNDRV_PCM_FMTBIT_DSD_U16_LE
;
1382 fp
->dsd_bitrev
= true;
1383 return SNDRV_PCM_FMTBIT_DSD_U8
;
1385 fp
->dsd_bitrev
= true;
1386 return SNDRV_PCM_FMTBIT_DSD_U16_LE
;
1390 /* XMOS based USB DACs */
1391 switch (chip
->usb_id
) {
1392 case USB_ID(0x1511, 0x0037): /* AURALiC VEGA */
1393 case USB_ID(0x2522, 0x0012): /* LH Labs VI DAC Infinity */
1394 case USB_ID(0x2772, 0x0230): /* Pro-Ject Pre Box S2 Digital */
1395 if (fp
->altsetting
== 2)
1396 return SNDRV_PCM_FMTBIT_DSD_U32_BE
;
1399 case USB_ID(0x0d8c, 0x0316): /* Hegel HD12 DSD */
1400 case USB_ID(0x10cb, 0x0103): /* The Bit Opus #3; with fp->dsd_raw */
1401 case USB_ID(0x16d0, 0x06b2): /* NuPrime DAC-10 */
1402 case USB_ID(0x16d0, 0x09dd): /* Encore mDSD */
1403 case USB_ID(0x16d0, 0x0733): /* Furutech ADL Stratos */
1404 case USB_ID(0x16d0, 0x09db): /* NuPrime Audio DAC-9 */
1405 case USB_ID(0x1db5, 0x0003): /* Bryston BDA3 */
1406 case USB_ID(0x22e1, 0xca01): /* HDTA Serenade DSD */
1407 case USB_ID(0x249c, 0x9326): /* M2Tech Young MkIII */
1408 case USB_ID(0x2616, 0x0106): /* PS Audio NuWave DAC */
1409 case USB_ID(0x2622, 0x0041): /* Audiolab M-DAC+ */
1410 case USB_ID(0x27f7, 0x3002): /* W4S DAC-2v2SE */
1411 case USB_ID(0x29a2, 0x0086): /* Mutec MC3+ USB */
1412 case USB_ID(0x6b42, 0x0042): /* MSB Technology */
1413 if (fp
->altsetting
== 3)
1414 return SNDRV_PCM_FMTBIT_DSD_U32_BE
;
1417 /* Amanero Combo384 USB based DACs with native DSD support */
1418 case USB_ID(0x16d0, 0x071a): /* Amanero - Combo384 */
1419 case USB_ID(0x2ab6, 0x0004): /* T+A DAC8DSD-V2.0, MP1000E-V2.0, MP2000R-V2.0, MP2500R-V2.0, MP3100HV-V2.0 */
1420 case USB_ID(0x2ab6, 0x0005): /* T+A USB HD Audio 1 */
1421 case USB_ID(0x2ab6, 0x0006): /* T+A USB HD Audio 2 */
1422 if (fp
->altsetting
== 2) {
1423 switch (le16_to_cpu(chip
->dev
->descriptor
.bcdDevice
)) {
1425 return SNDRV_PCM_FMTBIT_DSD_U32_LE
;
1428 return SNDRV_PCM_FMTBIT_DSD_U32_BE
;
1434 case USB_ID(0x16d0, 0x0a23):
1435 if (fp
->altsetting
== 2)
1436 return SNDRV_PCM_FMTBIT_DSD_U32_BE
;
1443 /* ITF-USB DSD based DACs */
1444 if (is_itf_usb_dsd_dac(chip
->usb_id
)) {
1445 iface
= usb_ifnum_to_if(chip
->dev
, fp
->iface
);
1447 /* Altsetting 2 support native DSD if the num of altsets is
1449 * Altsetting 3 support native DSD if the num of altsets is
1452 if (fp
->altsetting
== iface
->num_altsetting
- 1)
1453 return SNDRV_PCM_FMTBIT_DSD_U32_BE
;
1456 /* Mostly generic method to detect many DSD-capable implementations -
1457 * from XMOS/Thesycon
1459 switch (USB_ID_VENDOR(chip
->usb_id
)) {
1460 case 0x152a: /* Thesycon devices */
1461 case 0x20b1: /* XMOS based devices */
1462 case 0x22d9: /* Oppo */
1463 case 0x23ba: /* Playback Designs */
1464 case 0x25ce: /* Mytek devices */
1465 case 0x278b: /* Rotel? */
1466 case 0x292b: /* Gustard/Ess based devices */
1467 case 0x2ab6: /* T+A devices */
1468 case 0x3842: /* EVGA */
1469 case 0xc502: /* HiBy devices */
1471 return SNDRV_PCM_FMTBIT_DSD_U32_BE
;
1481 void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio
*chip
,
1482 struct audioformat
*fp
,
1485 switch (chip
->usb_id
) {
1486 case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */
1487 /* Optoplay sets the sample rate attribute although
1488 * it seems not supporting it in fact.
1490 fp
->attributes
&= ~UAC_EP_CS_ATTR_SAMPLE_RATE
;
1492 case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
1493 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
1494 /* doesn't set the sample rate attribute, but supports it */
1495 fp
->attributes
|= UAC_EP_CS_ATTR_SAMPLE_RATE
;
1497 case USB_ID(0x0763, 0x2001): /* M-Audio Quattro USB */
1498 case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */
1499 case USB_ID(0x047f, 0x0ca1): /* plantronics headset */
1500 case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is
1501 an older model 77d:223) */
1503 * plantronics headset and Griffin iMic have set adaptive-in
1504 * although it's really not...
1506 fp
->ep_attr
&= ~USB_ENDPOINT_SYNCTYPE
;
1507 if (stream
== SNDRV_PCM_STREAM_PLAYBACK
)
1508 fp
->ep_attr
|= USB_ENDPOINT_SYNC_ADAPTIVE
;
1510 fp
->ep_attr
|= USB_ENDPOINT_SYNC_SYNC
;
1516 * registration quirk:
1517 * the registration is skipped if a device matches with the given ID,
1518 * unless the interface reaches to the defined one. This is for delaying
1519 * the registration until the last known interface, so that the card and
1520 * devices appear at the same time.
1523 struct registration_quirk
{
1524 unsigned int usb_id
; /* composed via USB_ID() */
1525 unsigned int interface
; /* the interface to trigger register */
1528 #define REG_QUIRK_ENTRY(vendor, product, iface) \
1529 { .usb_id = USB_ID(vendor, product), .interface = (iface) }
1531 static const struct registration_quirk registration_quirks
[] = {
1532 REG_QUIRK_ENTRY(0x0951, 0x16d8, 2), /* Kingston HyperX AMP */
1533 REG_QUIRK_ENTRY(0x0951, 0x16ed, 2), /* Kingston HyperX Cloud Alpha S */
1534 REG_QUIRK_ENTRY(0x0951, 0x16ea, 2), /* Kingston HyperX Cloud Flight S */
1535 { 0 } /* terminator */
1538 /* return true if skipping registration */
1539 bool snd_usb_registration_quirk(struct snd_usb_audio
*chip
, int iface
)
1541 const struct registration_quirk
*q
;
1543 for (q
= registration_quirks
; q
->usb_id
; q
++)
1544 if (chip
->usb_id
== q
->usb_id
)
1545 return iface
!= q
->interface
;
1547 /* Register as normal */