1 // SPDX-License-Identifier: GPL-2.0-or-later
5 #include <linux/init.h>
6 #include <linux/slab.h>
8 #include <linux/usb/audio.h>
9 #include <linux/usb/midi.h>
10 #include <linux/bits.h>
12 #include <sound/control.h>
13 #include <sound/core.h>
14 #include <sound/info.h>
15 #include <sound/pcm.h>
20 #include "mixer_quirks.h"
30 * handle the quirks for the contained interfaces
32 static int create_composite_quirk(struct snd_usb_audio *chip,
33 struct usb_interface *iface,
34 struct usb_driver *driver,
35 const struct snd_usb_audio_quirk *quirk_comp)
37 int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber;
38 const struct snd_usb_audio_quirk *quirk;
41 for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) {
42 iface = usb_ifnum_to_if(chip->dev, quirk->ifnum);
45 if (quirk->ifnum != probed_ifnum &&
46 usb_interface_claimed(iface))
48 err = snd_usb_create_quirk(chip, iface, driver, quirk);
53 for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) {
54 iface = usb_ifnum_to_if(chip->dev, quirk->ifnum);
57 if (quirk->ifnum != probed_ifnum &&
58 !usb_interface_claimed(iface)) {
59 err = usb_driver_claim_interface(driver, iface,
60 USB_AUDIO_IFACE_UNUSED);
69 static int ignore_interface_quirk(struct snd_usb_audio *chip,
70 struct usb_interface *iface,
71 struct usb_driver *driver,
72 const struct snd_usb_audio_quirk *quirk)
78 static int create_any_midi_quirk(struct snd_usb_audio *chip,
79 struct usb_interface *intf,
80 struct usb_driver *driver,
81 const struct snd_usb_audio_quirk *quirk)
83 return snd_usbmidi_create(chip->card, intf, &chip->midi_list, quirk);
87 * create a stream for an interface with proper descriptors
89 static int create_standard_audio_quirk(struct snd_usb_audio *chip,
90 struct usb_interface *iface,
91 struct usb_driver *driver,
92 const struct snd_usb_audio_quirk *quirk)
94 struct usb_host_interface *alts;
95 struct usb_interface_descriptor *altsd;
98 alts = &iface->altsetting[0];
99 altsd = get_iface_desc(alts);
100 err = snd_usb_parse_audio_interface(chip, altsd->bInterfaceNumber);
102 usb_audio_err(chip, "cannot setup if %d: error %d\n",
103 altsd->bInterfaceNumber, err);
106 /* reset the current interface */
107 usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0);
111 /* create the audio stream and the corresponding endpoints from the fixed
112 * audioformat object; this is used for quirks with the fixed EPs
114 static int add_audio_stream_from_fixed_fmt(struct snd_usb_audio *chip,
115 struct audioformat *fp)
119 stream = (fp->endpoint & USB_DIR_IN) ?
120 SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
122 snd_usb_audioformat_set_sync_ep(chip, fp);
124 err = snd_usb_add_audio_stream(chip, stream, fp);
128 err = snd_usb_add_endpoint(chip, fp->endpoint,
129 SND_USB_ENDPOINT_TYPE_DATA);
134 err = snd_usb_add_endpoint(chip, fp->sync_ep,
136 SND_USB_ENDPOINT_TYPE_DATA :
137 SND_USB_ENDPOINT_TYPE_SYNC);
146 * create a stream for an endpoint/altsetting without proper descriptors
148 static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
149 struct usb_interface *iface,
150 struct usb_driver *driver,
151 const struct snd_usb_audio_quirk *quirk)
153 struct audioformat *fp;
154 struct usb_host_interface *alts;
155 struct usb_interface_descriptor *altsd;
156 unsigned *rate_table = NULL;
159 fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL);
163 INIT_LIST_HEAD(&fp->list);
164 if (fp->nr_rates > MAX_NR_RATES) {
168 if (fp->nr_rates > 0) {
169 rate_table = kmemdup(fp->rate_table,
170 sizeof(int) * fp->nr_rates, GFP_KERNEL);
175 fp->rate_table = rate_table;
178 if (fp->iface != get_iface_desc(&iface->altsetting[0])->bInterfaceNumber ||
179 fp->altset_idx >= iface->num_altsetting) {
183 alts = &iface->altsetting[fp->altset_idx];
184 altsd = get_iface_desc(alts);
185 if (altsd->bNumEndpoints <= fp->ep_idx) {
190 fp->protocol = altsd->bInterfaceProtocol;
192 if (fp->datainterval == 0)
193 fp->datainterval = snd_usb_parse_datainterval(chip, alts);
194 if (fp->maxpacksize == 0)
195 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, fp->ep_idx)->wMaxPacketSize);
197 fp->fmt_type = UAC_FORMAT_TYPE_I;
199 err = add_audio_stream_from_fixed_fmt(chip, fp);
203 usb_set_interface(chip->dev, fp->iface, 0);
204 snd_usb_init_pitch(chip, fp);
205 snd_usb_init_sample_rate(chip, fp, fp->rate_max);
209 list_del(&fp->list); /* unlink for avoiding double-free */
215 static int create_auto_pcm_quirk(struct snd_usb_audio *chip,
216 struct usb_interface *iface,
217 struct usb_driver *driver)
219 struct usb_host_interface *alts;
220 struct usb_interface_descriptor *altsd;
221 struct usb_endpoint_descriptor *epd;
222 struct uac1_as_header_descriptor *ashd;
223 struct uac_format_type_i_discrete_descriptor *fmtd;
226 * Most Roland/Yamaha audio streaming interfaces have more or less
227 * standard descriptors, but older devices might lack descriptors, and
228 * future ones might change, so ensure that we fail silently if the
229 * interface doesn't look exactly right.
232 /* must have a non-zero altsetting for streaming */
233 if (iface->num_altsetting < 2)
235 alts = &iface->altsetting[1];
236 altsd = get_iface_desc(alts);
238 /* must have an isochronous endpoint for streaming */
239 if (altsd->bNumEndpoints < 1)
241 epd = get_endpoint(alts, 0);
242 if (!usb_endpoint_xfer_isoc(epd))
245 /* must have format descriptors */
246 ashd = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL,
248 fmtd = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL,
250 if (!ashd || ashd->bLength < 7 ||
251 !fmtd || fmtd->bLength < 8)
254 return create_standard_audio_quirk(chip, iface, driver, NULL);
257 static int create_yamaha_midi_quirk(struct snd_usb_audio *chip,
258 struct usb_interface *iface,
259 struct usb_driver *driver,
260 struct usb_host_interface *alts)
262 static const struct snd_usb_audio_quirk yamaha_midi_quirk = {
263 .type = QUIRK_MIDI_YAMAHA
265 struct usb_midi_in_jack_descriptor *injd;
266 struct usb_midi_out_jack_descriptor *outjd;
268 /* must have some valid jack descriptors */
269 injd = snd_usb_find_csint_desc(alts->extra, alts->extralen,
270 NULL, USB_MS_MIDI_IN_JACK);
271 outjd = snd_usb_find_csint_desc(alts->extra, alts->extralen,
272 NULL, USB_MS_MIDI_OUT_JACK);
275 if ((injd && !snd_usb_validate_midi_desc(injd)) ||
276 (outjd && !snd_usb_validate_midi_desc(outjd)))
278 if (injd && (injd->bLength < 5 ||
279 (injd->bJackType != USB_MS_EMBEDDED &&
280 injd->bJackType != USB_MS_EXTERNAL)))
282 if (outjd && (outjd->bLength < 6 ||
283 (outjd->bJackType != USB_MS_EMBEDDED &&
284 outjd->bJackType != USB_MS_EXTERNAL)))
286 return create_any_midi_quirk(chip, iface, driver, &yamaha_midi_quirk);
289 static int create_roland_midi_quirk(struct snd_usb_audio *chip,
290 struct usb_interface *iface,
291 struct usb_driver *driver,
292 struct usb_host_interface *alts)
294 static const struct snd_usb_audio_quirk roland_midi_quirk = {
295 .type = QUIRK_MIDI_ROLAND
297 u8 *roland_desc = NULL;
299 /* might have a vendor-specific descriptor <06 24 F1 02 ...> */
301 roland_desc = snd_usb_find_csint_desc(alts->extra,
306 if (roland_desc[0] < 6 || roland_desc[3] != 2)
308 return create_any_midi_quirk(chip, iface, driver,
313 static int create_std_midi_quirk(struct snd_usb_audio *chip,
314 struct usb_interface *iface,
315 struct usb_driver *driver,
316 struct usb_host_interface *alts)
318 struct usb_ms_header_descriptor *mshd;
319 struct usb_ms_endpoint_descriptor *msepd;
321 /* must have the MIDIStreaming interface header descriptor*/
322 mshd = (struct usb_ms_header_descriptor *)alts->extra;
323 if (alts->extralen < 7 ||
325 mshd->bDescriptorType != USB_DT_CS_INTERFACE ||
326 mshd->bDescriptorSubtype != USB_MS_HEADER)
328 /* must have the MIDIStreaming endpoint descriptor*/
329 msepd = (struct usb_ms_endpoint_descriptor *)alts->endpoint[0].extra;
330 if (alts->endpoint[0].extralen < 4 ||
331 msepd->bLength < 4 ||
332 msepd->bDescriptorType != USB_DT_CS_ENDPOINT ||
333 msepd->bDescriptorSubtype != UAC_MS_GENERAL ||
334 msepd->bNumEmbMIDIJack < 1 ||
335 msepd->bNumEmbMIDIJack > 16)
338 return create_any_midi_quirk(chip, iface, driver, NULL);
341 static int create_auto_midi_quirk(struct snd_usb_audio *chip,
342 struct usb_interface *iface,
343 struct usb_driver *driver)
345 struct usb_host_interface *alts;
346 struct usb_interface_descriptor *altsd;
347 struct usb_endpoint_descriptor *epd;
350 alts = &iface->altsetting[0];
351 altsd = get_iface_desc(alts);
353 /* must have at least one bulk/interrupt endpoint for streaming */
354 if (altsd->bNumEndpoints < 1)
356 epd = get_endpoint(alts, 0);
357 if (!usb_endpoint_xfer_bulk(epd) &&
358 !usb_endpoint_xfer_int(epd))
361 switch (USB_ID_VENDOR(chip->usb_id)) {
362 case 0x0499: /* Yamaha */
363 err = create_yamaha_midi_quirk(chip, iface, driver, alts);
367 case 0x0582: /* Roland */
368 err = create_roland_midi_quirk(chip, iface, driver, alts);
374 return create_std_midi_quirk(chip, iface, driver, alts);
377 static int create_autodetect_quirk(struct snd_usb_audio *chip,
378 struct usb_interface *iface,
379 struct usb_driver *driver)
383 err = create_auto_pcm_quirk(chip, iface, driver);
385 err = create_auto_midi_quirk(chip, iface, driver);
389 static int create_autodetect_quirks(struct snd_usb_audio *chip,
390 struct usb_interface *iface,
391 struct usb_driver *driver,
392 const struct snd_usb_audio_quirk *quirk)
394 int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber;
395 int ifcount, ifnum, err;
397 err = create_autodetect_quirk(chip, iface, driver);
402 * ALSA PCM playback/capture devices cannot be registered in two steps,
403 * so we have to claim the other corresponding interface here.
405 ifcount = chip->dev->actconfig->desc.bNumInterfaces;
406 for (ifnum = 0; ifnum < ifcount; ifnum++) {
407 if (ifnum == probed_ifnum || quirk->ifnum >= 0)
409 iface = usb_ifnum_to_if(chip->dev, ifnum);
411 usb_interface_claimed(iface) ||
412 get_iface_desc(iface->altsetting)->bInterfaceClass !=
413 USB_CLASS_VENDOR_SPEC)
416 err = create_autodetect_quirk(chip, iface, driver);
418 err = usb_driver_claim_interface(driver, iface,
419 USB_AUDIO_IFACE_UNUSED);
429 * Create a stream for an Edirol UA-700/UA-25/UA-4FX interface.
430 * The only way to detect the sample rate is by looking at wMaxPacketSize.
432 static int create_uaxx_quirk(struct snd_usb_audio *chip,
433 struct usb_interface *iface,
434 struct usb_driver *driver,
435 const struct snd_usb_audio_quirk *quirk)
437 static const struct audioformat ua_format = {
438 .formats = SNDRV_PCM_FMTBIT_S24_3LE,
440 .fmt_type = UAC_FORMAT_TYPE_I,
443 .rates = SNDRV_PCM_RATE_CONTINUOUS,
445 struct usb_host_interface *alts;
446 struct usb_interface_descriptor *altsd;
447 struct audioformat *fp;
450 /* both PCM and MIDI interfaces have 2 or more altsettings */
451 if (iface->num_altsetting < 2)
453 alts = &iface->altsetting[1];
454 altsd = get_iface_desc(alts);
456 if (altsd->bNumEndpoints == 2) {
457 static const struct snd_usb_midi_endpoint_info ua700_ep = {
458 .out_cables = 0x0003,
461 static const struct snd_usb_audio_quirk ua700_quirk = {
462 .type = QUIRK_MIDI_FIXED_ENDPOINT,
465 static const struct snd_usb_midi_endpoint_info uaxx_ep = {
466 .out_cables = 0x0001,
469 static const struct snd_usb_audio_quirk uaxx_quirk = {
470 .type = QUIRK_MIDI_FIXED_ENDPOINT,
473 const struct snd_usb_audio_quirk *quirk =
474 chip->usb_id == USB_ID(0x0582, 0x002b)
475 ? &ua700_quirk : &uaxx_quirk;
476 return __snd_usbmidi_create(chip->card, iface,
477 &chip->midi_list, quirk,
481 if (altsd->bNumEndpoints != 1)
484 fp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL);
488 fp->iface = altsd->bInterfaceNumber;
489 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
490 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
491 fp->datainterval = 0;
492 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
493 INIT_LIST_HEAD(&fp->list);
495 switch (fp->maxpacksize) {
497 fp->rate_max = fp->rate_min = 44100;
501 fp->rate_max = fp->rate_min = 48000;
505 fp->rate_max = fp->rate_min = 96000;
508 usb_audio_err(chip, "unknown sample rate\n");
513 err = add_audio_stream_from_fixed_fmt(chip, fp);
515 list_del(&fp->list); /* unlink for avoiding double-free */
519 usb_set_interface(chip->dev, fp->iface, 0);
524 * Create a standard mixer for the specified interface.
526 static int create_standard_mixer_quirk(struct snd_usb_audio *chip,
527 struct usb_interface *iface,
528 struct usb_driver *driver,
529 const struct snd_usb_audio_quirk *quirk)
531 if (quirk->ifnum < 0)
534 return snd_usb_create_mixer(chip, quirk->ifnum, 0);
537 static int setup_disable_autosuspend(struct snd_usb_audio *chip,
538 struct usb_interface *iface,
539 struct usb_driver *driver,
540 const struct snd_usb_audio_quirk *quirk)
542 usb_disable_autosuspend(interface_to_usbdev(iface));
543 return 1; /* Continue with creating streams and mixer */
547 * audio-interface quirks
549 * returns zero if no standard audio/MIDI parsing is needed.
550 * returns a positive value if standard audio/midi interfaces are parsed
552 * returns a negative value at error.
554 int snd_usb_create_quirk(struct snd_usb_audio *chip,
555 struct usb_interface *iface,
556 struct usb_driver *driver,
557 const struct snd_usb_audio_quirk *quirk)
559 typedef int (*quirk_func_t)(struct snd_usb_audio *,
560 struct usb_interface *,
562 const struct snd_usb_audio_quirk *);
563 static const quirk_func_t quirk_funcs[] = {
564 [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk,
565 [QUIRK_COMPOSITE] = create_composite_quirk,
566 [QUIRK_AUTODETECT] = create_autodetect_quirks,
567 [QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk,
568 [QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk,
569 [QUIRK_MIDI_YAMAHA] = create_any_midi_quirk,
570 [QUIRK_MIDI_ROLAND] = create_any_midi_quirk,
571 [QUIRK_MIDI_MIDIMAN] = create_any_midi_quirk,
572 [QUIRK_MIDI_NOVATION] = create_any_midi_quirk,
573 [QUIRK_MIDI_RAW_BYTES] = create_any_midi_quirk,
574 [QUIRK_MIDI_EMAGIC] = create_any_midi_quirk,
575 [QUIRK_MIDI_CME] = create_any_midi_quirk,
576 [QUIRK_MIDI_AKAI] = create_any_midi_quirk,
577 [QUIRK_MIDI_FTDI] = create_any_midi_quirk,
578 [QUIRK_MIDI_CH345] = create_any_midi_quirk,
579 [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk,
580 [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
581 [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk,
582 [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk,
583 [QUIRK_SETUP_DISABLE_AUTOSUSPEND] = setup_disable_autosuspend,
586 if (quirk->type < QUIRK_TYPE_COUNT) {
587 return quirk_funcs[quirk->type](chip, iface, driver, quirk);
589 usb_audio_err(chip, "invalid quirk type %d\n", quirk->type);
598 #define EXTIGY_FIRMWARE_SIZE_OLD 794
599 #define EXTIGY_FIRMWARE_SIZE_NEW 483
601 static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf)
603 struct usb_host_config *config = dev->actconfig;
606 if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD ||
607 le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) {
608 dev_dbg(&dev->dev, "sending Extigy boot sequence...\n");
609 /* Send message to force it to reconnect with full interface. */
610 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0),
611 0x10, 0x43, 0x0001, 0x000a, NULL, 0);
613 dev_dbg(&dev->dev, "error sending boot message: %d\n", err);
614 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
615 &dev->descriptor, sizeof(dev->descriptor));
616 config = dev->actconfig;
618 dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
619 err = usb_reset_configuration(dev);
621 dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err);
622 dev_dbg(&dev->dev, "extigy_boot: new boot length = %d\n",
623 le16_to_cpu(get_cfg_desc(config)->wTotalLength));
624 return -ENODEV; /* quit this anyway */
629 static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev)
633 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a,
634 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
637 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0x29,
638 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
645 static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
649 if (dev->actconfig->desc.bConfigurationValue == 1) {
651 "Fast Track Pro switching to config #2\n");
652 /* This function has to be available by the usb core module.
653 * if it is not avialable the boot quirk has to be left out
654 * and the configuration has to be set by udev or hotplug
657 err = usb_driver_set_configuration(dev, 2);
660 "error usb_driver_set_configuration: %d\n",
662 /* Always return an error, so that we stop creating a device
663 that will just be destroyed and recreated with a new
667 dev_info(&dev->dev, "Fast Track Pro config OK\n");
673 * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely
674 * documented in the device's data sheet.
676 static int snd_usb_cm106_write_int_reg(struct usb_device *dev, int reg, u16 value)
680 buf[1] = value & 0xff;
681 buf[2] = (value >> 8) & 0xff;
683 return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION,
684 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
688 static int snd_usb_cm106_boot_quirk(struct usb_device *dev)
691 * Enable line-out driver mode, set headphone source to front
692 * channels, enable stereo mic.
694 return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
698 * CM6206 registers from the CM6206 datasheet rev 2.1
700 #define CM6206_REG0_DMA_MASTER BIT(15)
701 #define CM6206_REG0_SPDIFO_RATE_48K (2 << 12)
702 #define CM6206_REG0_SPDIFO_RATE_96K (7 << 12)
703 /* Bit 4 thru 11 is the S/PDIF category code */
704 #define CM6206_REG0_SPDIFO_CAT_CODE_GENERAL (0 << 4)
705 #define CM6206_REG0_SPDIFO_EMPHASIS_CD BIT(3)
706 #define CM6206_REG0_SPDIFO_COPYRIGHT_NA BIT(2)
707 #define CM6206_REG0_SPDIFO_NON_AUDIO BIT(1)
708 #define CM6206_REG0_SPDIFO_PRO_FORMAT BIT(0)
710 #define CM6206_REG1_TEST_SEL_CLK BIT(14)
711 #define CM6206_REG1_PLLBIN_EN BIT(13)
712 #define CM6206_REG1_SOFT_MUTE_EN BIT(12)
713 #define CM6206_REG1_GPIO4_OUT BIT(11)
714 #define CM6206_REG1_GPIO4_OE BIT(10)
715 #define CM6206_REG1_GPIO3_OUT BIT(9)
716 #define CM6206_REG1_GPIO3_OE BIT(8)
717 #define CM6206_REG1_GPIO2_OUT BIT(7)
718 #define CM6206_REG1_GPIO2_OE BIT(6)
719 #define CM6206_REG1_GPIO1_OUT BIT(5)
720 #define CM6206_REG1_GPIO1_OE BIT(4)
721 #define CM6206_REG1_SPDIFO_INVALID BIT(3)
722 #define CM6206_REG1_SPDIF_LOOP_EN BIT(2)
723 #define CM6206_REG1_SPDIFO_DIS BIT(1)
724 #define CM6206_REG1_SPDIFI_MIX BIT(0)
726 #define CM6206_REG2_DRIVER_ON BIT(15)
727 #define CM6206_REG2_HEADP_SEL_SIDE_CHANNELS (0 << 13)
728 #define CM6206_REG2_HEADP_SEL_SURROUND_CHANNELS (1 << 13)
729 #define CM6206_REG2_HEADP_SEL_CENTER_SUBW (2 << 13)
730 #define CM6206_REG2_HEADP_SEL_FRONT_CHANNELS (3 << 13)
731 #define CM6206_REG2_MUTE_HEADPHONE_RIGHT BIT(12)
732 #define CM6206_REG2_MUTE_HEADPHONE_LEFT BIT(11)
733 #define CM6206_REG2_MUTE_REAR_SURROUND_RIGHT BIT(10)
734 #define CM6206_REG2_MUTE_REAR_SURROUND_LEFT BIT(9)
735 #define CM6206_REG2_MUTE_SIDE_SURROUND_RIGHT BIT(8)
736 #define CM6206_REG2_MUTE_SIDE_SURROUND_LEFT BIT(7)
737 #define CM6206_REG2_MUTE_SUBWOOFER BIT(6)
738 #define CM6206_REG2_MUTE_CENTER BIT(5)
739 #define CM6206_REG2_MUTE_RIGHT_FRONT BIT(3)
740 #define CM6206_REG2_MUTE_LEFT_FRONT BIT(3)
741 #define CM6206_REG2_EN_BTL BIT(2)
742 #define CM6206_REG2_MCUCLKSEL_1_5_MHZ (0)
743 #define CM6206_REG2_MCUCLKSEL_3_MHZ (1)
744 #define CM6206_REG2_MCUCLKSEL_6_MHZ (2)
745 #define CM6206_REG2_MCUCLKSEL_12_MHZ (3)
747 /* Bit 11..13 sets the sensitivity to FLY tuner volume control VP/VD signal */
748 #define CM6206_REG3_FLYSPEED_DEFAULT (2 << 11)
749 #define CM6206_REG3_VRAP25EN BIT(10)
750 #define CM6206_REG3_MSEL1 BIT(9)
751 #define CM6206_REG3_SPDIFI_RATE_44_1K BIT(0 << 7)
752 #define CM6206_REG3_SPDIFI_RATE_48K BIT(2 << 7)
753 #define CM6206_REG3_SPDIFI_RATE_32K BIT(3 << 7)
754 #define CM6206_REG3_PINSEL BIT(6)
755 #define CM6206_REG3_FOE BIT(5)
756 #define CM6206_REG3_ROE BIT(4)
757 #define CM6206_REG3_CBOE BIT(3)
758 #define CM6206_REG3_LOSE BIT(2)
759 #define CM6206_REG3_HPOE BIT(1)
760 #define CM6206_REG3_SPDIFI_CANREC BIT(0)
762 #define CM6206_REG5_DA_RSTN BIT(13)
763 #define CM6206_REG5_AD_RSTN BIT(12)
764 #define CM6206_REG5_SPDIFO_AD2SPDO BIT(12)
765 #define CM6206_REG5_SPDIFO_SEL_FRONT (0 << 9)
766 #define CM6206_REG5_SPDIFO_SEL_SIDE_SUR (1 << 9)
767 #define CM6206_REG5_SPDIFO_SEL_CEN_LFE (2 << 9)
768 #define CM6206_REG5_SPDIFO_SEL_REAR_SUR (3 << 9)
769 #define CM6206_REG5_CODECM BIT(8)
770 #define CM6206_REG5_EN_HPF BIT(7)
771 #define CM6206_REG5_T_SEL_DSDA4 BIT(6)
772 #define CM6206_REG5_T_SEL_DSDA3 BIT(5)
773 #define CM6206_REG5_T_SEL_DSDA2 BIT(4)
774 #define CM6206_REG5_T_SEL_DSDA1 BIT(3)
775 #define CM6206_REG5_T_SEL_DSDAD_NORMAL 0
776 #define CM6206_REG5_T_SEL_DSDAD_FRONT 4
777 #define CM6206_REG5_T_SEL_DSDAD_S_SURROUND 5
778 #define CM6206_REG5_T_SEL_DSDAD_CEN_LFE 6
779 #define CM6206_REG5_T_SEL_DSDAD_R_SURROUND 7
781 static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)
786 * Values here are chosen based on sniffing USB traffic
789 * REG0: DAC is master, sample rate 48kHz, no copyright
791 CM6206_REG0_SPDIFO_RATE_48K |
792 CM6206_REG0_SPDIFO_COPYRIGHT_NA,
794 * REG1: PLL binary search enable, soft mute enable.
796 CM6206_REG1_PLLBIN_EN |
797 CM6206_REG1_SOFT_MUTE_EN,
799 * REG2: enable output drivers,
800 * select front channels to the headphone output,
801 * then mute the headphone channels, run the MCU
804 CM6206_REG2_DRIVER_ON |
805 CM6206_REG2_HEADP_SEL_FRONT_CHANNELS |
806 CM6206_REG2_MUTE_HEADPHONE_RIGHT |
807 CM6206_REG2_MUTE_HEADPHONE_LEFT,
809 * REG3: default flyspeed, set 2.5V mic bias
810 * enable all line out ports and enable SPDIF
812 CM6206_REG3_FLYSPEED_DEFAULT |
813 CM6206_REG3_VRAP25EN |
819 CM6206_REG3_SPDIFI_CANREC,
820 /* REG4 is just a bunch of GPIO lines */
822 /* REG5: de-assert AD/DA reset signals */
823 CM6206_REG5_DA_RSTN |
824 CM6206_REG5_AD_RSTN };
826 for (reg = 0; reg < ARRAY_SIZE(val); reg++) {
827 err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]);
835 /* quirk for Plantronics GameCom 780 with CM6302 chip */
836 static int snd_usb_gamecon780_boot_quirk(struct usb_device *dev)
838 /* set the initial volume and don't change; other values are either
839 * too loud or silent due to firmware bug (bko#65251)
841 u8 buf[2] = { 0x74, 0xe3 };
842 return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
843 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
844 UAC_FU_VOLUME << 8, 9 << 8, buf, 2);
848 * Novation Twitch DJ controller
849 * Focusrite Novation Saffire 6 USB audio card
851 static int snd_usb_novation_boot_quirk(struct usb_device *dev)
853 /* preemptively set up the device because otherwise the
854 * raw MIDI endpoints are not active */
855 usb_set_interface(dev, 0, 1);
860 * This call will put the synth in "USB send" mode, i.e it will send MIDI
861 * messages through USB (this is disabled at startup). The synth will
862 * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB
863 * sign on its LCD. Values here are chosen based on sniffing USB traffic
866 static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev)
868 int err, actual_length;
869 /* "midi send" enable */
870 static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 };
873 if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05)))
875 buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL);
878 err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf,
879 ARRAY_SIZE(seq), &actual_length, 1000);
888 * Some sound cards from Native Instruments are in fact compliant to the USB
889 * audio standard of version 2 and other approved USB standards, even though
890 * they come up as vendor-specific device when first connected.
892 * However, they can be told to come up with a new set of descriptors
893 * upon their next enumeration, and the interfaces announced by the new
894 * descriptors will then be handled by the kernel's class drivers. As the
895 * product ID will also change, no further checks are required.
898 static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev)
902 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
903 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE,
904 1, 0, NULL, 0, 1000);
909 usb_reset_device(dev);
911 /* return -EAGAIN, so the creation of an audio interface for this
912 * temporary device is aborted. The device will reconnect with a
917 static void mbox2_setup_48_24_magic(struct usb_device *dev)
922 /* Choose 48000Hz permanently */
927 /* Send the magic! */
928 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0),
929 0x01, 0x22, 0x0100, 0x0085, &temp, 0x0003);
930 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
931 0x81, 0xa2, 0x0100, 0x0085, &srate, 0x0003);
932 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
933 0x81, 0xa2, 0x0100, 0x0086, &srate, 0x0003);
934 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
935 0x81, 0xa2, 0x0100, 0x0003, &srate, 0x0003);
939 /* Digidesign Mbox 2 needs to load firmware onboard
940 * and driver must wait a few seconds for initialisation.
943 #define MBOX2_FIRMWARE_SIZE 646
944 #define MBOX2_BOOT_LOADING 0x01 /* Hard coded into the device */
945 #define MBOX2_BOOT_READY 0x02 /* Hard coded into the device */
947 static int snd_usb_mbox2_boot_quirk(struct usb_device *dev)
949 struct usb_host_config *config = dev->actconfig;
951 u8 bootresponse[0x12];
955 fwsize = le16_to_cpu(get_cfg_desc(config)->wTotalLength);
957 if (fwsize != MBOX2_FIRMWARE_SIZE) {
958 dev_err(&dev->dev, "Invalid firmware size=%d.\n", fwsize);
962 dev_dbg(&dev->dev, "Sending Digidesign Mbox 2 boot sequence...\n");
965 bootresponse[0] = MBOX2_BOOT_LOADING;
966 while ((bootresponse[0] == MBOX2_BOOT_LOADING) && (count < 10)) {
967 msleep(500); /* 0.5 second delay */
968 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0),
969 /* Control magic - load onboard firmware */
970 0x85, 0xc0, 0x0001, 0x0000, &bootresponse, 0x0012);
971 if (bootresponse[0] == MBOX2_BOOT_READY)
973 dev_dbg(&dev->dev, "device not ready, resending boot sequence...\n");
977 if (bootresponse[0] != MBOX2_BOOT_READY) {
978 dev_err(&dev->dev, "Unknown bootresponse=%d, or timed out, ignoring device.\n", bootresponse[0]);
982 dev_dbg(&dev->dev, "device initialised!\n");
984 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
985 &dev->descriptor, sizeof(dev->descriptor));
986 config = dev->actconfig;
988 dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
990 err = usb_reset_configuration(dev);
992 dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err);
993 dev_dbg(&dev->dev, "mbox2_boot: new boot length = %d\n",
994 le16_to_cpu(get_cfg_desc(config)->wTotalLength));
996 mbox2_setup_48_24_magic(dev);
998 dev_info(&dev->dev, "Digidesign Mbox 2: 24bit 48kHz");
1000 return 0; /* Successful boot */
1003 static int snd_usb_axefx3_boot_quirk(struct usb_device *dev)
1007 dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n");
1009 /* If the Axe-Fx III has not fully booted, it will timeout when trying
1010 * to enable the audio streaming interface. A more generous timeout is
1011 * used here to detect when the Axe-Fx III has finished booting as the
1012 * set interface message will be acked once it has
1014 err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1015 USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,
1016 1, 1, NULL, 0, 120000);
1019 "failed waiting for Axe-Fx III to boot: %d\n", err);
1023 dev_dbg(&dev->dev, "Axe-Fx III is now ready\n");
1025 err = usb_set_interface(dev, 1, 0);
1028 "error stopping Axe-Fx III interface: %d\n", err);
1034 #define MICROBOOK_BUF_SIZE 128
1036 static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf,
1037 int buf_size, int *length)
1039 int err, actual_length;
1041 if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01)))
1043 err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length,
1044 &actual_length, 1000);
1048 print_hex_dump(KERN_DEBUG, "MicroBookII snd: ", DUMP_PREFIX_NONE, 16, 1,
1049 buf, actual_length, false);
1051 memset(buf, 0, buf_size);
1053 if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82)))
1055 err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size,
1056 &actual_length, 1000);
1060 print_hex_dump(KERN_DEBUG, "MicroBookII rcv: ", DUMP_PREFIX_NONE, 16, 1,
1061 buf, actual_length, false);
1063 *length = actual_length;
1067 static int snd_usb_motu_microbookii_boot_quirk(struct usb_device *dev)
1069 int err, actual_length, poll_attempts = 0;
1070 static const u8 set_samplerate_seq[] = { 0x00, 0x00, 0x00, 0x00,
1071 0x00, 0x00, 0x0b, 0x14,
1072 0x00, 0x00, 0x00, 0x01 };
1073 static const u8 poll_ready_seq[] = { 0x00, 0x04, 0x00, 0x00,
1074 0x00, 0x00, 0x0b, 0x18 };
1075 u8 *buf = kzalloc(MICROBOOK_BUF_SIZE, GFP_KERNEL);
1080 dev_info(&dev->dev, "Waiting for MOTU Microbook II to boot up...\n");
1082 /* First we tell the device which sample rate to use. */
1083 memcpy(buf, set_samplerate_seq, sizeof(set_samplerate_seq));
1084 actual_length = sizeof(set_samplerate_seq);
1085 err = snd_usb_motu_microbookii_communicate(dev, buf, MICROBOOK_BUF_SIZE,
1090 "failed setting the sample rate for Motu MicroBook II: %d\n",
1095 /* Then we poll every 100 ms until the device informs of its readiness. */
1097 if (++poll_attempts > 100) {
1099 "failed booting Motu MicroBook II: timeout\n");
1104 memset(buf, 0, MICROBOOK_BUF_SIZE);
1105 memcpy(buf, poll_ready_seq, sizeof(poll_ready_seq));
1107 actual_length = sizeof(poll_ready_seq);
1108 err = snd_usb_motu_microbookii_communicate(
1109 dev, buf, MICROBOOK_BUF_SIZE, &actual_length);
1112 "failed booting Motu MicroBook II: communication error %d\n",
1117 /* the device signals its readiness through a message of the
1119 * XX 06 00 00 00 00 0b 18 00 00 00 01
1120 * If the device is not yet ready to accept audio data, the
1121 * last byte of that sequence is 00.
1123 if (actual_length == 12 && buf[actual_length - 1] == 1)
1129 dev_info(&dev->dev, "MOTU MicroBook II ready\n");
1136 static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev)
1146 #define MAUDIO_SET 0x01 /* parse device_setup */
1147 #define MAUDIO_SET_COMPATIBLE 0x80 /* use only "win-compatible" interfaces */
1148 #define MAUDIO_SET_DTS 0x02 /* enable DTS Digital Output */
1149 #define MAUDIO_SET_96K 0x04 /* 48-96kHz rate if set, 8-48kHz otherwise */
1150 #define MAUDIO_SET_24B 0x08 /* 24bits sample if set, 16bits otherwise */
1151 #define MAUDIO_SET_DI 0x10 /* enable Digital Input */
1152 #define MAUDIO_SET_MASK 0x1f /* bit mask for setup value */
1153 #define MAUDIO_SET_24B_48K_DI 0x19 /* 24bits+48kHz+Digital Input */
1154 #define MAUDIO_SET_24B_48K_NOTDI 0x09 /* 24bits+48kHz+No Digital Input */
1155 #define MAUDIO_SET_16B_48K_DI 0x11 /* 16bits+48kHz+Digital Input */
1156 #define MAUDIO_SET_16B_48K_NOTDI 0x01 /* 16bits+48kHz+No Digital Input */
1158 static int quattro_skip_setting_quirk(struct snd_usb_audio *chip,
1159 int iface, int altno)
1161 /* Reset ALL ifaces to 0 altsetting.
1162 * Call it for every possible altsetting of every interface.
1164 usb_set_interface(chip->dev, iface, 0);
1165 if (chip->setup & MAUDIO_SET) {
1166 if (chip->setup & MAUDIO_SET_COMPATIBLE) {
1167 if (iface != 1 && iface != 2)
1168 return 1; /* skip all interfaces but 1 and 2 */
1171 if (iface == 1 || iface == 2)
1172 return 1; /* skip interfaces 1 and 2 */
1173 if ((chip->setup & MAUDIO_SET_96K) && altno != 1)
1174 return 1; /* skip this altsetting */
1175 mask = chip->setup & MAUDIO_SET_MASK;
1176 if (mask == MAUDIO_SET_24B_48K_DI && altno != 2)
1177 return 1; /* skip this altsetting */
1178 if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3)
1179 return 1; /* skip this altsetting */
1180 if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 4)
1181 return 1; /* skip this altsetting */
1185 "using altsetting %d for interface %d config %d\n",
1186 altno, iface, chip->setup);
1187 return 0; /* keep this altsetting */
1190 static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
1194 /* Reset ALL ifaces to 0 altsetting.
1195 * Call it for every possible altsetting of every interface.
1197 usb_set_interface(chip->dev, iface, 0);
1199 if (chip->setup & MAUDIO_SET) {
1201 if ((chip->setup & MAUDIO_SET_DTS) && altno != 6)
1202 return 1; /* skip this altsetting */
1203 if ((chip->setup & MAUDIO_SET_96K) && altno != 1)
1204 return 1; /* skip this altsetting */
1205 mask = chip->setup & MAUDIO_SET_MASK;
1206 if (mask == MAUDIO_SET_24B_48K_DI && altno != 2)
1207 return 1; /* skip this altsetting */
1208 if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3)
1209 return 1; /* skip this altsetting */
1210 if (mask == MAUDIO_SET_16B_48K_DI && altno != 4)
1211 return 1; /* skip this altsetting */
1212 if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 5)
1213 return 1; /* skip this altsetting */
1216 return 0; /* keep this altsetting */
1219 static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip,
1220 int iface, int altno)
1222 /* Reset ALL ifaces to 0 altsetting.
1223 * Call it for every possible altsetting of every interface.
1225 usb_set_interface(chip->dev, iface, 0);
1227 /* possible configuration where both inputs and only one output is
1228 *used is not supported by the current setup
1230 if (chip->setup & (MAUDIO_SET | MAUDIO_SET_24B)) {
1231 if (chip->setup & MAUDIO_SET_96K) {
1232 if (altno != 3 && altno != 6)
1234 } else if (chip->setup & MAUDIO_SET_DI) {
1236 return 1; /* no analog input */
1237 if (altno != 2 && altno != 5)
1238 return 1; /* enable only altsets 2 and 5 */
1241 return 1; /* disable digialt input */
1242 if (altno != 2 && altno != 5)
1243 return 1; /* enalbe only altsets 2 and 5 */
1246 /* keep only 16-Bit mode */
1252 "using altsetting %d for interface %d config %d\n",
1253 altno, iface, chip->setup);
1254 return 0; /* keep this altsetting */
1257 static int s1810c_skip_setting_quirk(struct snd_usb_audio *chip,
1258 int iface, int altno)
1263 * Playback (Interface 1):
1264 * 1: 6 Analog + 2 S/PDIF
1265 * 2: 6 Analog + 2 S/PDIF
1268 * Capture (Interface 2):
1269 * 1: 8 Analog + 2 S/PDIF + 8 ADAT
1270 * 2: 8 Analog + 2 S/PDIF + 4 ADAT
1275 * I'll leave 2 as the default one and
1276 * use device_setup to switch to the
1279 if ((chip->setup == 0 || chip->setup > 2) && altno != 2)
1281 else if (chip->setup == 1 && altno != 1)
1283 else if (chip->setup == 2 && altno != 3)
1289 int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip,
1293 /* audiophile usb: skip altsets incompatible with device_setup */
1294 if (chip->usb_id == USB_ID(0x0763, 0x2003))
1295 return audiophile_skip_setting_quirk(chip, iface, altno);
1296 /* quattro usb: skip altsets incompatible with device_setup */
1297 if (chip->usb_id == USB_ID(0x0763, 0x2001))
1298 return quattro_skip_setting_quirk(chip, iface, altno);
1299 /* fasttrackpro usb: skip altsets incompatible with device_setup */
1300 if (chip->usb_id == USB_ID(0x0763, 0x2012))
1301 return fasttrackpro_skip_setting_quirk(chip, iface, altno);
1302 /* presonus studio 1810c: skip altsets incompatible with device_setup */
1303 if (chip->usb_id == USB_ID(0x0194f, 0x010c))
1304 return s1810c_skip_setting_quirk(chip, iface, altno);
1310 int snd_usb_apply_boot_quirk(struct usb_device *dev,
1311 struct usb_interface *intf,
1312 const struct snd_usb_audio_quirk *quirk,
1316 case USB_ID(0x041e, 0x3000):
1317 /* SB Extigy needs special boot-up sequence */
1318 /* if more models come, this will go to the quirk list. */
1319 return snd_usb_extigy_boot_quirk(dev, intf);
1321 case USB_ID(0x041e, 0x3020):
1322 /* SB Audigy 2 NX needs its own boot-up magic, too */
1323 return snd_usb_audigy2nx_boot_quirk(dev);
1325 case USB_ID(0x10f5, 0x0200):
1326 /* C-Media CM106 / Turtle Beach Audio Advantage Roadie */
1327 return snd_usb_cm106_boot_quirk(dev);
1329 case USB_ID(0x0d8c, 0x0102):
1330 /* C-Media CM6206 / CM106-Like Sound Device */
1331 case USB_ID(0x0ccd, 0x00b1): /* Terratec Aureon 7.1 USB */
1332 return snd_usb_cm6206_boot_quirk(dev);
1334 case USB_ID(0x0dba, 0x3000):
1335 /* Digidesign Mbox 2 */
1336 return snd_usb_mbox2_boot_quirk(dev);
1338 case USB_ID(0x1235, 0x0010): /* Focusrite Novation Saffire 6 USB */
1339 case USB_ID(0x1235, 0x0018): /* Focusrite Novation Twitch */
1340 return snd_usb_novation_boot_quirk(dev);
1342 case USB_ID(0x133e, 0x0815):
1343 /* Access Music VirusTI Desktop */
1344 return snd_usb_accessmusic_boot_quirk(dev);
1346 case USB_ID(0x17cc, 0x1000): /* Komplete Audio 6 */
1347 case USB_ID(0x17cc, 0x1010): /* Traktor Audio 6 */
1348 case USB_ID(0x17cc, 0x1020): /* Traktor Audio 10 */
1349 return snd_usb_nativeinstruments_boot_quirk(dev);
1350 case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */
1351 return snd_usb_fasttrackpro_boot_quirk(dev);
1352 case USB_ID(0x047f, 0xc010): /* Plantronics Gamecom 780 */
1353 return snd_usb_gamecon780_boot_quirk(dev);
1354 case USB_ID(0x2466, 0x8010): /* Fractal Audio Axe-Fx 3 */
1355 return snd_usb_axefx3_boot_quirk(dev);
1356 case USB_ID(0x07fd, 0x0004): /* MOTU MicroBook II */
1358 * For some reason interface 3 with vendor-spec class is
1359 * detected on MicroBook IIc.
1361 if (get_iface_desc(intf->altsetting)->bInterfaceClass ==
1362 USB_CLASS_VENDOR_SPEC &&
1363 get_iface_desc(intf->altsetting)->bInterfaceNumber < 3)
1364 return snd_usb_motu_microbookii_boot_quirk(dev);
1371 int snd_usb_apply_boot_quirk_once(struct usb_device *dev,
1372 struct usb_interface *intf,
1373 const struct snd_usb_audio_quirk *quirk,
1377 case USB_ID(0x07fd, 0x0008): /* MOTU M Series */
1378 return snd_usb_motu_m_series_boot_quirk(dev);
1385 * check if the device uses big-endian samples
1387 int snd_usb_is_big_endian_format(struct snd_usb_audio *chip,
1388 const struct audioformat *fp)
1390 /* it depends on altsetting whether the device is big-endian or not */
1391 switch (chip->usb_id) {
1392 case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */
1393 if (fp->altsetting == 2 || fp->altsetting == 3 ||
1394 fp->altsetting == 5 || fp->altsetting == 6)
1397 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
1398 if (chip->setup == 0x00 ||
1399 fp->altsetting == 1 || fp->altsetting == 2 ||
1400 fp->altsetting == 3)
1403 case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro */
1404 if (fp->altsetting == 2 || fp->altsetting == 3 ||
1405 fp->altsetting == 5 || fp->altsetting == 6)
1413 * For E-Mu 0404USB/0202USB/TrackerPre/0204 sample rate should be set for device,
1414 * not for interface.
1418 EMU_QUIRK_SR_44100HZ = 0,
1419 EMU_QUIRK_SR_48000HZ,
1420 EMU_QUIRK_SR_88200HZ,
1421 EMU_QUIRK_SR_96000HZ,
1422 EMU_QUIRK_SR_176400HZ,
1423 EMU_QUIRK_SR_192000HZ
1426 static void set_format_emu_quirk(struct snd_usb_substream *subs,
1427 const struct audioformat *fmt)
1429 unsigned char emu_samplerate_id = 0;
1431 /* When capture is active
1432 * sample rate shouldn't be changed
1433 * by playback substream
1435 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) {
1436 if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].cur_audiofmt)
1440 switch (fmt->rate_min) {
1442 emu_samplerate_id = EMU_QUIRK_SR_48000HZ;
1445 emu_samplerate_id = EMU_QUIRK_SR_88200HZ;
1448 emu_samplerate_id = EMU_QUIRK_SR_96000HZ;
1451 emu_samplerate_id = EMU_QUIRK_SR_176400HZ;
1454 emu_samplerate_id = EMU_QUIRK_SR_192000HZ;
1457 emu_samplerate_id = EMU_QUIRK_SR_44100HZ;
1460 snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id);
1461 subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0;
1464 static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs,
1467 unsigned int cur_rate = subs->data_endpoint->cur_rate;
1469 // Convert to little endian
1470 sr[0] = cur_rate & 0xff;
1471 sr[1] = (cur_rate >> 8) & 0xff;
1472 sr[2] = (cur_rate >> 16) & 0xff;
1473 usb_set_interface(subs->dev, 0, 1);
1474 // we should derive windex from fmt-sync_ep but it's not set
1475 snd_usb_ctl_msg(subs->stream->chip->dev,
1476 usb_sndctrlpipe(subs->stream->chip->dev, 0),
1477 0x01, 0x22, 0x0100, windex, &sr, 0x0003);
1481 void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
1482 const struct audioformat *fmt)
1484 switch (subs->stream->chip->usb_id) {
1485 case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */
1486 case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */
1487 case USB_ID(0x041e, 0x3f0a): /* E-Mu Tracker Pre */
1488 case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */
1489 set_format_emu_quirk(subs, fmt);
1491 case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */
1492 subs->stream_offset_adj = 2;
1494 case USB_ID(0x2b73, 0x0013): /* Pioneer DJM-450 */
1495 pioneer_djm_set_format_quirk(subs, 0x0082);
1497 case USB_ID(0x08e4, 0x017f): /* Pioneer DJM-750 */
1498 case USB_ID(0x08e4, 0x0163): /* Pioneer DJM-850 */
1499 pioneer_djm_set_format_quirk(subs, 0x0086);
1504 /* ITF-USB DSD based DACs need a vendor cmd to switch
1505 * between PCM and native DSD mode
1507 static bool is_itf_usb_dsd_dac(unsigned int id)
1510 case USB_ID(0x154e, 0x1002): /* Denon DCD-1500RE */
1511 case USB_ID(0x154e, 0x1003): /* Denon DA-300USB */
1512 case USB_ID(0x154e, 0x3005): /* Marantz HD-DAC1 */
1513 case USB_ID(0x154e, 0x3006): /* Marantz SA-14S1 */
1514 case USB_ID(0x1852, 0x5065): /* Luxman DA-06 */
1515 case USB_ID(0x0644, 0x8043): /* TEAC UD-501/UD-501V2/UD-503/NT-503 */
1516 case USB_ID(0x0644, 0x8044): /* Esoteric D-05X */
1517 case USB_ID(0x0644, 0x804a): /* TEAC UD-301 */
1523 int snd_usb_select_mode_quirk(struct snd_usb_audio *chip,
1524 const struct audioformat *fmt)
1526 struct usb_device *dev = chip->dev;
1529 if (is_itf_usb_dsd_dac(chip->usb_id)) {
1530 /* First switch to alt set 0, otherwise the mode switch cmd
1531 * will not be accepted by the DAC
1533 err = usb_set_interface(dev, fmt->iface, 0);
1537 msleep(20); /* Delay needed after setting the interface */
1539 /* Vendor mode switch cmd is required. */
1540 if (fmt->formats & SNDRV_PCM_FMTBIT_DSD_U32_BE) {
1541 /* DSD mode (DSD_U32) requested */
1542 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0,
1543 USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE,
1549 /* PCM or DOP mode (S32) requested */
1550 /* PCM mode (S16) requested */
1551 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0,
1552 USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE,
1563 void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
1566 * "Playback Design" products send bogus feedback data at the start
1567 * of the stream. Ignore them.
1569 if (USB_ID_VENDOR(ep->chip->usb_id) == 0x23ba &&
1570 ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
1571 ep->skip_packets = 4;
1574 * M-Audio Fast Track C400/C600 - when packets are not skipped, real
1575 * world latency varies by approx. +/- 50 frames (at 96kHz) each time
1576 * the stream is (re)started. When skipping packets 16 at endpoint
1577 * start up, the real world latency is stable within +/- 1 frame (also
1578 * across power cycles).
1580 if ((ep->chip->usb_id == USB_ID(0x0763, 0x2030) ||
1581 ep->chip->usb_id == USB_ID(0x0763, 0x2031)) &&
1582 ep->type == SND_USB_ENDPOINT_TYPE_DATA)
1583 ep->skip_packets = 16;
1585 /* Work around devices that report unreasonable feedback data */
1586 if ((ep->chip->usb_id == USB_ID(0x0644, 0x8038) || /* TEAC UD-H01 */
1587 ep->chip->usb_id == USB_ID(0x1852, 0x5034)) && /* T+A Dac8 */
1588 ep->syncmaxsize == 4)
1589 ep->tenor_fb_quirk = 1;
1592 void snd_usb_set_interface_quirk(struct snd_usb_audio *chip)
1597 * "Playback Design" products need a 50ms delay after setting the
1600 switch (USB_ID_VENDOR(chip->usb_id)) {
1601 case 0x23ba: /* Playback Design */
1602 case 0x0644: /* TEAC Corp. */
1608 /* quirk applied after snd_usb_ctl_msg(); not applied during boot quirks */
1609 void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
1610 __u8 request, __u8 requesttype, __u16 value,
1611 __u16 index, void *data, __u16 size)
1613 struct snd_usb_audio *chip = dev_get_drvdata(&dev->dev);
1618 * "Playback Design" products need a 20ms delay after each
1619 * class compliant request
1621 if (USB_ID_VENDOR(chip->usb_id) == 0x23ba &&
1622 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
1626 * "TEAC Corp." products need a 20ms delay after each
1627 * class compliant request
1629 if (USB_ID_VENDOR(chip->usb_id) == 0x0644 &&
1630 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
1633 /* ITF-USB DSD based DACs functionality need a delay
1634 * after each class compliant request
1636 if (is_itf_usb_dsd_dac(chip->usb_id)
1637 && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
1641 * Plantronics headsets (C320, C320-M, etc) need a delay to avoid
1642 * random microhpone failures.
1644 if (USB_ID_VENDOR(chip->usb_id) == 0x047f &&
1645 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
1648 /* Zoom R16/24, many Logitech(at least H650e/H570e/BCC950),
1649 * Jabra 550a, Kingston HyperX needs a tiny delay here,
1650 * otherwise requests like get/set frequency return
1651 * as failed despite actually succeeding.
1653 if ((chip->usb_id == USB_ID(0x1686, 0x00dd) ||
1654 USB_ID_VENDOR(chip->usb_id) == 0x046d || /* Logitech */
1655 chip->usb_id == USB_ID(0x0b0e, 0x0349) ||
1656 chip->usb_id == USB_ID(0x0951, 0x16ad)) &&
1657 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
1658 usleep_range(1000, 2000);
1661 * Samsung USBC Headset (AKG) need a tiny delay after each
1662 * class compliant request. (Model number: AAM625R or AAM627R)
1664 if (chip->usb_id == USB_ID(0x04e8, 0xa051) &&
1665 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
1666 usleep_range(5000, 6000);
1670 * snd_usb_interface_dsd_format_quirks() is called from format.c to
1671 * augment the PCM format bit-field for DSD types. The UAC standards
1672 * don't have a designated bit field to denote DSD-capable interfaces,
1673 * hence all hardware that is known to support this format has to be
1676 u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
1677 struct audioformat *fp,
1678 unsigned int sample_bytes)
1680 struct usb_interface *iface;
1682 /* Playback Designs */
1683 if (USB_ID_VENDOR(chip->usb_id) == 0x23ba &&
1684 USB_ID_PRODUCT(chip->usb_id) < 0x0110) {
1685 switch (fp->altsetting) {
1688 return SNDRV_PCM_FMTBIT_DSD_U16_LE;
1690 fp->dsd_bitrev = true;
1691 return SNDRV_PCM_FMTBIT_DSD_U8;
1693 fp->dsd_bitrev = true;
1694 return SNDRV_PCM_FMTBIT_DSD_U16_LE;
1698 /* XMOS based USB DACs */
1699 switch (chip->usb_id) {
1700 case USB_ID(0x1511, 0x0037): /* AURALiC VEGA */
1701 case USB_ID(0x2522, 0x0012): /* LH Labs VI DAC Infinity */
1702 case USB_ID(0x2772, 0x0230): /* Pro-Ject Pre Box S2 Digital */
1703 if (fp->altsetting == 2)
1704 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1707 case USB_ID(0x0d8c, 0x0316): /* Hegel HD12 DSD */
1708 case USB_ID(0x10cb, 0x0103): /* The Bit Opus #3; with fp->dsd_raw */
1709 case USB_ID(0x16d0, 0x06b2): /* NuPrime DAC-10 */
1710 case USB_ID(0x16d0, 0x09dd): /* Encore mDSD */
1711 case USB_ID(0x16d0, 0x0733): /* Furutech ADL Stratos */
1712 case USB_ID(0x16d0, 0x09db): /* NuPrime Audio DAC-9 */
1713 case USB_ID(0x1db5, 0x0003): /* Bryston BDA3 */
1714 case USB_ID(0x22e1, 0xca01): /* HDTA Serenade DSD */
1715 case USB_ID(0x249c, 0x9326): /* M2Tech Young MkIII */
1716 case USB_ID(0x2616, 0x0106): /* PS Audio NuWave DAC */
1717 case USB_ID(0x2622, 0x0041): /* Audiolab M-DAC+ */
1718 case USB_ID(0x27f7, 0x3002): /* W4S DAC-2v2SE */
1719 case USB_ID(0x29a2, 0x0086): /* Mutec MC3+ USB */
1720 case USB_ID(0x6b42, 0x0042): /* MSB Technology */
1721 if (fp->altsetting == 3)
1722 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1725 /* Amanero Combo384 USB based DACs with native DSD support */
1726 case USB_ID(0x16d0, 0x071a): /* Amanero - Combo384 */
1727 case USB_ID(0x2ab6, 0x0004): /* T+A DAC8DSD-V2.0, MP1000E-V2.0, MP2000R-V2.0, MP2500R-V2.0, MP3100HV-V2.0 */
1728 case USB_ID(0x2ab6, 0x0005): /* T+A USB HD Audio 1 */
1729 case USB_ID(0x2ab6, 0x0006): /* T+A USB HD Audio 2 */
1730 if (fp->altsetting == 2) {
1731 switch (le16_to_cpu(chip->dev->descriptor.bcdDevice)) {
1733 return SNDRV_PCM_FMTBIT_DSD_U32_LE;
1736 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1742 case USB_ID(0x16d0, 0x0a23):
1743 if (fp->altsetting == 2)
1744 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1751 /* ITF-USB DSD based DACs */
1752 if (is_itf_usb_dsd_dac(chip->usb_id)) {
1753 iface = usb_ifnum_to_if(chip->dev, fp->iface);
1755 /* Altsetting 2 support native DSD if the num of altsets is
1757 * Altsetting 3 support native DSD if the num of altsets is
1760 if (fp->altsetting == iface->num_altsetting - 1)
1761 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1764 /* Mostly generic method to detect many DSD-capable implementations -
1765 * from XMOS/Thesycon
1767 switch (USB_ID_VENDOR(chip->usb_id)) {
1768 case 0x152a: /* Thesycon devices */
1769 case 0x20b1: /* XMOS based devices */
1770 case 0x22d9: /* Oppo */
1771 case 0x23ba: /* Playback Designs */
1772 case 0x25ce: /* Mytek devices */
1773 case 0x278b: /* Rotel? */
1774 case 0x292b: /* Gustard/Ess based devices */
1775 case 0x2972: /* FiiO devices */
1776 case 0x2ab6: /* T+A devices */
1777 case 0x3353: /* Khadas devices */
1778 case 0x3842: /* EVGA */
1779 case 0xc502: /* HiBy devices */
1781 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1791 void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
1792 struct audioformat *fp,
1795 switch (chip->usb_id) {
1796 case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */
1797 /* Optoplay sets the sample rate attribute although
1798 * it seems not supporting it in fact.
1800 fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE;
1802 case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
1803 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
1804 /* doesn't set the sample rate attribute, but supports it */
1805 fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
1807 case USB_ID(0x0763, 0x2001): /* M-Audio Quattro USB */
1808 case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */
1809 case USB_ID(0x047f, 0x0ca1): /* plantronics headset */
1810 case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is
1811 an older model 77d:223) */
1813 * plantronics headset and Griffin iMic have set adaptive-in
1814 * although it's really not...
1816 fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE;
1817 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
1818 fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE;
1820 fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC;
1822 case USB_ID(0x07fd, 0x0004): /* MOTU MicroBook IIc */
1824 * MaxPacketsOnly attribute is erroneously set in endpoint
1825 * descriptors. As a result this card produces noise with
1826 * all sample rates other than 96 kHz.
1828 fp->attributes &= ~UAC_EP_CS_ATTR_FILL_MAX;
1834 * registration quirk:
1835 * the registration is skipped if a device matches with the given ID,
1836 * unless the interface reaches to the defined one. This is for delaying
1837 * the registration until the last known interface, so that the card and
1838 * devices appear at the same time.
1841 struct registration_quirk {
1842 unsigned int usb_id; /* composed via USB_ID() */
1843 unsigned int interface; /* the interface to trigger register */
1846 #define REG_QUIRK_ENTRY(vendor, product, iface) \
1847 { .usb_id = USB_ID(vendor, product), .interface = (iface) }
1849 static const struct registration_quirk registration_quirks[] = {
1850 REG_QUIRK_ENTRY(0x0951, 0x16d8, 2), /* Kingston HyperX AMP */
1851 REG_QUIRK_ENTRY(0x0951, 0x16ed, 2), /* Kingston HyperX Cloud Alpha S */
1852 REG_QUIRK_ENTRY(0x0951, 0x16ea, 2), /* Kingston HyperX Cloud Flight S */
1853 REG_QUIRK_ENTRY(0x0ecb, 0x1f46, 2), /* JBL Quantum 600 */
1854 REG_QUIRK_ENTRY(0x0ecb, 0x2039, 2), /* JBL Quantum 400 */
1855 REG_QUIRK_ENTRY(0x0ecb, 0x203c, 2), /* JBL Quantum 600 */
1856 REG_QUIRK_ENTRY(0x0ecb, 0x203e, 2), /* JBL Quantum 800 */
1857 { 0 } /* terminator */
1860 /* return true if skipping registration */
1861 bool snd_usb_registration_quirk(struct snd_usb_audio *chip, int iface)
1863 const struct registration_quirk *q;
1865 for (q = registration_quirks; q->usb_id; q++)
1866 if (chip->usb_id == q->usb_id)
1867 return iface != q->interface;
1869 /* Register as normal */
1874 * driver behavior quirk flags
1876 struct usb_audio_quirk_flags_table {
1881 #define DEVICE_FLG(vid, pid, _flags) \
1882 { .id = USB_ID(vid, pid), .flags = (_flags) }
1883 #define VENDOR_FLG(vid, _flags) DEVICE_FLG(vid, 0, _flags)
1885 static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
1886 /* Device matches */
1887 DEVICE_FLG(0x041e, 0x4080, /* Creative Live Cam VF0610 */
1888 QUIRK_FLAG_GET_SAMPLE_RATE),
1889 DEVICE_FLG(0x046d, 0x084c, /* Logitech ConferenceCam Connect */
1890 QUIRK_FLAG_GET_SAMPLE_RATE),
1891 DEVICE_FLG(0x04d8, 0xfeea, /* Benchmark DAC1 Pre */
1892 QUIRK_FLAG_GET_SAMPLE_RATE),
1893 DEVICE_FLG(0x0556, 0x0014, /* Phoenix Audio TMX320VC */
1894 QUIRK_FLAG_GET_SAMPLE_RATE),
1895 DEVICE_FLG(0x05a3, 0x9420, /* ELP HD USB Camera */
1896 QUIRK_FLAG_GET_SAMPLE_RATE),
1897 DEVICE_FLG(0x05a7, 0x1020, /* Bose Companion 5 */
1898 QUIRK_FLAG_GET_SAMPLE_RATE),
1899 DEVICE_FLG(0x05e1, 0x0408, /* Syntek STK1160 */
1900 QUIRK_FLAG_ALIGN_TRANSFER),
1901 DEVICE_FLG(0x05e1, 0x0480, /* Hauppauge Woodbury */
1902 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1903 DEVICE_FLG(0x074d, 0x3553, /* Outlaw RR2150 (Micronas UAC3553B) */
1904 QUIRK_FLAG_GET_SAMPLE_RATE),
1905 DEVICE_FLG(0x0fd9, 0x0008, /* Hauppauge HVR-950Q */
1906 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1907 DEVICE_FLG(0x1395, 0x740a, /* Sennheiser DECT */
1908 QUIRK_FLAG_GET_SAMPLE_RATE),
1909 DEVICE_FLG(0x1686, 0x00dd, /* Zoom R16/24 */
1910 QUIRK_FLAG_TX_LENGTH),
1911 DEVICE_FLG(0x1901, 0x0191, /* GE B850V3 CP2114 audio interface */
1912 QUIRK_FLAG_GET_SAMPLE_RATE),
1913 DEVICE_FLG(0x2040, 0x7200, /* Hauppauge HVR-950Q */
1914 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1915 DEVICE_FLG(0x2040, 0x7201, /* Hauppauge HVR-950Q-MXL */
1916 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1917 DEVICE_FLG(0x2040, 0x7210, /* Hauppauge HVR-950Q */
1918 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1919 DEVICE_FLG(0x2040, 0x7211, /* Hauppauge HVR-950Q-MXL */
1920 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1921 DEVICE_FLG(0x2040, 0x7213, /* Hauppauge HVR-950Q */
1922 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1923 DEVICE_FLG(0x2040, 0x7217, /* Hauppauge HVR-950Q */
1924 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1925 DEVICE_FLG(0x2040, 0x721b, /* Hauppauge HVR-950Q */
1926 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1927 DEVICE_FLG(0x2040, 0x721e, /* Hauppauge HVR-950Q */
1928 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1929 DEVICE_FLG(0x2040, 0x721f, /* Hauppauge HVR-950Q */
1930 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1931 DEVICE_FLG(0x2040, 0x7240, /* Hauppauge HVR-850 */
1932 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1933 DEVICE_FLG(0x2040, 0x7260, /* Hauppauge HVR-950Q */
1934 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1935 DEVICE_FLG(0x2040, 0x7270, /* Hauppauge HVR-950Q */
1936 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1937 DEVICE_FLG(0x2040, 0x7280, /* Hauppauge HVR-950Q */
1938 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1939 DEVICE_FLG(0x2040, 0x7281, /* Hauppauge HVR-950Q-MXL */
1940 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1941 DEVICE_FLG(0x2040, 0x8200, /* Hauppauge Woodbury */
1942 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1943 DEVICE_FLG(0x21b4, 0x0081, /* AudioQuest DragonFly */
1944 QUIRK_FLAG_GET_SAMPLE_RATE),
1945 DEVICE_FLG(0x2912, 0x30c8, /* Audioengine D1 */
1946 QUIRK_FLAG_GET_SAMPLE_RATE),
1947 DEVICE_FLG(0x413c, 0xa506, /* Dell AE515 sound bar */
1948 QUIRK_FLAG_GET_SAMPLE_RATE),
1949 DEVICE_FLG(0x534d, 0x2109, /* MacroSilicon MS2109 */
1950 QUIRK_FLAG_ALIGN_TRANSFER),
1952 /* Vendor matches */
1953 VENDOR_FLG(0x045e, /* MS Lifecam */
1954 QUIRK_FLAG_GET_SAMPLE_RATE),
1955 VENDOR_FLG(0x047f, /* Plantronics */
1956 QUIRK_FLAG_GET_SAMPLE_RATE),
1957 VENDOR_FLG(0x1de7, /* Phoenix Audio */
1958 QUIRK_FLAG_GET_SAMPLE_RATE),
1963 void snd_usb_init_quirk_flags(struct snd_usb_audio *chip)
1965 const struct usb_audio_quirk_flags_table *p;
1967 for (p = quirk_flags_table; p->id; p++) {
1968 if (chip->usb_id == p->id ||
1969 (!USB_ID_PRODUCT(p->id) &&
1970 USB_ID_VENDOR(chip->usb_id) == USB_ID_VENDOR(p->id))) {
1972 "Set quirk_flags 0x%x for device %04x:%04x\n",
1973 p->flags, USB_ID_VENDOR(chip->usb_id),
1974 USB_ID_PRODUCT(chip->usb_id));
1975 chip->quirk_flags |= p->flags;