0001
0002
0003
0004
0005 #include <linux/init.h>
0006 #include <linux/slab.h>
0007 #include <linux/usb.h>
0008 #include <linux/usb/audio.h>
0009 #include <linux/usb/midi.h>
0010 #include <linux/bits.h>
0011
0012 #include <sound/control.h>
0013 #include <sound/core.h>
0014 #include <sound/info.h>
0015 #include <sound/pcm.h>
0016
0017 #include "usbaudio.h"
0018 #include "card.h"
0019 #include "mixer.h"
0020 #include "mixer_quirks.h"
0021 #include "midi.h"
0022 #include "quirks.h"
0023 #include "helper.h"
0024 #include "endpoint.h"
0025 #include "pcm.h"
0026 #include "clock.h"
0027 #include "stream.h"
0028
0029
0030
0031
0032 static int create_composite_quirk(struct snd_usb_audio *chip,
0033 struct usb_interface *iface,
0034 struct usb_driver *driver,
0035 const struct snd_usb_audio_quirk *quirk_comp)
0036 {
0037 int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber;
0038 const struct snd_usb_audio_quirk *quirk;
0039 int err;
0040
0041 for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) {
0042 iface = usb_ifnum_to_if(chip->dev, quirk->ifnum);
0043 if (!iface)
0044 continue;
0045 if (quirk->ifnum != probed_ifnum &&
0046 usb_interface_claimed(iface))
0047 continue;
0048 err = snd_usb_create_quirk(chip, iface, driver, quirk);
0049 if (err < 0)
0050 return err;
0051 }
0052
0053 for (quirk = quirk_comp->data; quirk->ifnum >= 0; ++quirk) {
0054 iface = usb_ifnum_to_if(chip->dev, quirk->ifnum);
0055 if (!iface)
0056 continue;
0057 if (quirk->ifnum != probed_ifnum &&
0058 !usb_interface_claimed(iface)) {
0059 err = usb_driver_claim_interface(driver, iface,
0060 USB_AUDIO_IFACE_UNUSED);
0061 if (err < 0)
0062 return err;
0063 }
0064 }
0065
0066 return 0;
0067 }
0068
0069 static int ignore_interface_quirk(struct snd_usb_audio *chip,
0070 struct usb_interface *iface,
0071 struct usb_driver *driver,
0072 const struct snd_usb_audio_quirk *quirk)
0073 {
0074 return 0;
0075 }
0076
0077
0078 static int create_any_midi_quirk(struct snd_usb_audio *chip,
0079 struct usb_interface *intf,
0080 struct usb_driver *driver,
0081 const struct snd_usb_audio_quirk *quirk)
0082 {
0083 return snd_usbmidi_create(chip->card, intf, &chip->midi_list, quirk);
0084 }
0085
0086
0087
0088
0089 static int create_standard_audio_quirk(struct snd_usb_audio *chip,
0090 struct usb_interface *iface,
0091 struct usb_driver *driver,
0092 const struct snd_usb_audio_quirk *quirk)
0093 {
0094 struct usb_host_interface *alts;
0095 struct usb_interface_descriptor *altsd;
0096 int err;
0097
0098 alts = &iface->altsetting[0];
0099 altsd = get_iface_desc(alts);
0100 err = snd_usb_parse_audio_interface(chip, altsd->bInterfaceNumber);
0101 if (err < 0) {
0102 usb_audio_err(chip, "cannot setup if %d: error %d\n",
0103 altsd->bInterfaceNumber, err);
0104 return err;
0105 }
0106
0107 usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0);
0108 return 0;
0109 }
0110
0111
0112
0113
0114 static int add_audio_stream_from_fixed_fmt(struct snd_usb_audio *chip,
0115 struct audioformat *fp)
0116 {
0117 int stream, err;
0118
0119 stream = (fp->endpoint & USB_DIR_IN) ?
0120 SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
0121
0122 snd_usb_audioformat_set_sync_ep(chip, fp);
0123
0124 err = snd_usb_add_audio_stream(chip, stream, fp);
0125 if (err < 0)
0126 return err;
0127
0128 err = snd_usb_add_endpoint(chip, fp->endpoint,
0129 SND_USB_ENDPOINT_TYPE_DATA);
0130 if (err < 0)
0131 return err;
0132
0133 if (fp->sync_ep) {
0134 err = snd_usb_add_endpoint(chip, fp->sync_ep,
0135 fp->implicit_fb ?
0136 SND_USB_ENDPOINT_TYPE_DATA :
0137 SND_USB_ENDPOINT_TYPE_SYNC);
0138 if (err < 0)
0139 return err;
0140 }
0141
0142 return 0;
0143 }
0144
0145
0146
0147
0148 static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
0149 struct usb_interface *iface,
0150 struct usb_driver *driver,
0151 const struct snd_usb_audio_quirk *quirk)
0152 {
0153 struct audioformat *fp;
0154 struct usb_host_interface *alts;
0155 struct usb_interface_descriptor *altsd;
0156 unsigned *rate_table = NULL;
0157 int err;
0158
0159 fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL);
0160 if (!fp)
0161 return -ENOMEM;
0162
0163 INIT_LIST_HEAD(&fp->list);
0164 if (fp->nr_rates > MAX_NR_RATES) {
0165 kfree(fp);
0166 return -EINVAL;
0167 }
0168 if (fp->nr_rates > 0) {
0169 rate_table = kmemdup(fp->rate_table,
0170 sizeof(int) * fp->nr_rates, GFP_KERNEL);
0171 if (!rate_table) {
0172 kfree(fp);
0173 return -ENOMEM;
0174 }
0175 fp->rate_table = rate_table;
0176 }
0177
0178 if (fp->iface != get_iface_desc(&iface->altsetting[0])->bInterfaceNumber ||
0179 fp->altset_idx >= iface->num_altsetting) {
0180 err = -EINVAL;
0181 goto error;
0182 }
0183 alts = &iface->altsetting[fp->altset_idx];
0184 altsd = get_iface_desc(alts);
0185 if (altsd->bNumEndpoints <= fp->ep_idx) {
0186 err = -EINVAL;
0187 goto error;
0188 }
0189
0190 fp->protocol = altsd->bInterfaceProtocol;
0191
0192 if (fp->datainterval == 0)
0193 fp->datainterval = snd_usb_parse_datainterval(chip, alts);
0194 if (fp->maxpacksize == 0)
0195 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, fp->ep_idx)->wMaxPacketSize);
0196 if (!fp->fmt_type)
0197 fp->fmt_type = UAC_FORMAT_TYPE_I;
0198
0199 err = add_audio_stream_from_fixed_fmt(chip, fp);
0200 if (err < 0)
0201 goto error;
0202
0203 usb_set_interface(chip->dev, fp->iface, 0);
0204 snd_usb_init_pitch(chip, fp);
0205 snd_usb_init_sample_rate(chip, fp, fp->rate_max);
0206 return 0;
0207
0208 error:
0209 list_del(&fp->list);
0210 kfree(fp);
0211 kfree(rate_table);
0212 return err;
0213 }
0214
0215 static int create_auto_pcm_quirk(struct snd_usb_audio *chip,
0216 struct usb_interface *iface,
0217 struct usb_driver *driver)
0218 {
0219 struct usb_host_interface *alts;
0220 struct usb_interface_descriptor *altsd;
0221 struct usb_endpoint_descriptor *epd;
0222 struct uac1_as_header_descriptor *ashd;
0223 struct uac_format_type_i_discrete_descriptor *fmtd;
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233 if (iface->num_altsetting < 2)
0234 return -ENODEV;
0235 alts = &iface->altsetting[1];
0236 altsd = get_iface_desc(alts);
0237
0238
0239 if (altsd->bNumEndpoints < 1)
0240 return -ENODEV;
0241 epd = get_endpoint(alts, 0);
0242 if (!usb_endpoint_xfer_isoc(epd))
0243 return -ENODEV;
0244
0245
0246 ashd = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL,
0247 UAC_AS_GENERAL);
0248 fmtd = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL,
0249 UAC_FORMAT_TYPE);
0250 if (!ashd || ashd->bLength < 7 ||
0251 !fmtd || fmtd->bLength < 8)
0252 return -ENODEV;
0253
0254 return create_standard_audio_quirk(chip, iface, driver, NULL);
0255 }
0256
0257 static int create_yamaha_midi_quirk(struct snd_usb_audio *chip,
0258 struct usb_interface *iface,
0259 struct usb_driver *driver,
0260 struct usb_host_interface *alts)
0261 {
0262 static const struct snd_usb_audio_quirk yamaha_midi_quirk = {
0263 .type = QUIRK_MIDI_YAMAHA
0264 };
0265 struct usb_midi_in_jack_descriptor *injd;
0266 struct usb_midi_out_jack_descriptor *outjd;
0267
0268
0269 injd = snd_usb_find_csint_desc(alts->extra, alts->extralen,
0270 NULL, USB_MS_MIDI_IN_JACK);
0271 outjd = snd_usb_find_csint_desc(alts->extra, alts->extralen,
0272 NULL, USB_MS_MIDI_OUT_JACK);
0273 if (!injd && !outjd)
0274 return -ENODEV;
0275 if ((injd && !snd_usb_validate_midi_desc(injd)) ||
0276 (outjd && !snd_usb_validate_midi_desc(outjd)))
0277 return -ENODEV;
0278 if (injd && (injd->bLength < 5 ||
0279 (injd->bJackType != USB_MS_EMBEDDED &&
0280 injd->bJackType != USB_MS_EXTERNAL)))
0281 return -ENODEV;
0282 if (outjd && (outjd->bLength < 6 ||
0283 (outjd->bJackType != USB_MS_EMBEDDED &&
0284 outjd->bJackType != USB_MS_EXTERNAL)))
0285 return -ENODEV;
0286 return create_any_midi_quirk(chip, iface, driver, &yamaha_midi_quirk);
0287 }
0288
0289 static int create_roland_midi_quirk(struct snd_usb_audio *chip,
0290 struct usb_interface *iface,
0291 struct usb_driver *driver,
0292 struct usb_host_interface *alts)
0293 {
0294 static const struct snd_usb_audio_quirk roland_midi_quirk = {
0295 .type = QUIRK_MIDI_ROLAND
0296 };
0297 u8 *roland_desc = NULL;
0298
0299
0300 for (;;) {
0301 roland_desc = snd_usb_find_csint_desc(alts->extra,
0302 alts->extralen,
0303 roland_desc, 0xf1);
0304 if (!roland_desc)
0305 return -ENODEV;
0306 if (roland_desc[0] < 6 || roland_desc[3] != 2)
0307 continue;
0308 return create_any_midi_quirk(chip, iface, driver,
0309 &roland_midi_quirk);
0310 }
0311 }
0312
0313 static int create_std_midi_quirk(struct snd_usb_audio *chip,
0314 struct usb_interface *iface,
0315 struct usb_driver *driver,
0316 struct usb_host_interface *alts)
0317 {
0318 struct usb_ms_header_descriptor *mshd;
0319 struct usb_ms_endpoint_descriptor *msepd;
0320
0321
0322 mshd = (struct usb_ms_header_descriptor *)alts->extra;
0323 if (alts->extralen < 7 ||
0324 mshd->bLength < 7 ||
0325 mshd->bDescriptorType != USB_DT_CS_INTERFACE ||
0326 mshd->bDescriptorSubtype != USB_MS_HEADER)
0327 return -ENODEV;
0328
0329 msepd = (struct usb_ms_endpoint_descriptor *)alts->endpoint[0].extra;
0330 if (alts->endpoint[0].extralen < 4 ||
0331 msepd->bLength < 4 ||
0332 msepd->bDescriptorType != USB_DT_CS_ENDPOINT ||
0333 msepd->bDescriptorSubtype != UAC_MS_GENERAL ||
0334 msepd->bNumEmbMIDIJack < 1 ||
0335 msepd->bNumEmbMIDIJack > 16)
0336 return -ENODEV;
0337
0338 return create_any_midi_quirk(chip, iface, driver, NULL);
0339 }
0340
0341 static int create_auto_midi_quirk(struct snd_usb_audio *chip,
0342 struct usb_interface *iface,
0343 struct usb_driver *driver)
0344 {
0345 struct usb_host_interface *alts;
0346 struct usb_interface_descriptor *altsd;
0347 struct usb_endpoint_descriptor *epd;
0348 int err;
0349
0350 alts = &iface->altsetting[0];
0351 altsd = get_iface_desc(alts);
0352
0353
0354 if (altsd->bNumEndpoints < 1)
0355 return -ENODEV;
0356 epd = get_endpoint(alts, 0);
0357 if (!usb_endpoint_xfer_bulk(epd) &&
0358 !usb_endpoint_xfer_int(epd))
0359 return -ENODEV;
0360
0361 switch (USB_ID_VENDOR(chip->usb_id)) {
0362 case 0x0499:
0363 err = create_yamaha_midi_quirk(chip, iface, driver, alts);
0364 if (err != -ENODEV)
0365 return err;
0366 break;
0367 case 0x0582:
0368 err = create_roland_midi_quirk(chip, iface, driver, alts);
0369 if (err != -ENODEV)
0370 return err;
0371 break;
0372 }
0373
0374 return create_std_midi_quirk(chip, iface, driver, alts);
0375 }
0376
0377 static int create_autodetect_quirk(struct snd_usb_audio *chip,
0378 struct usb_interface *iface,
0379 struct usb_driver *driver)
0380 {
0381 int err;
0382
0383 err = create_auto_pcm_quirk(chip, iface, driver);
0384 if (err == -ENODEV)
0385 err = create_auto_midi_quirk(chip, iface, driver);
0386 return err;
0387 }
0388
0389 static int create_autodetect_quirks(struct snd_usb_audio *chip,
0390 struct usb_interface *iface,
0391 struct usb_driver *driver,
0392 const struct snd_usb_audio_quirk *quirk)
0393 {
0394 int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber;
0395 int ifcount, ifnum, err;
0396
0397 err = create_autodetect_quirk(chip, iface, driver);
0398 if (err < 0)
0399 return err;
0400
0401
0402
0403
0404
0405 ifcount = chip->dev->actconfig->desc.bNumInterfaces;
0406 for (ifnum = 0; ifnum < ifcount; ifnum++) {
0407 if (ifnum == probed_ifnum || quirk->ifnum >= 0)
0408 continue;
0409 iface = usb_ifnum_to_if(chip->dev, ifnum);
0410 if (!iface ||
0411 usb_interface_claimed(iface) ||
0412 get_iface_desc(iface->altsetting)->bInterfaceClass !=
0413 USB_CLASS_VENDOR_SPEC)
0414 continue;
0415
0416 err = create_autodetect_quirk(chip, iface, driver);
0417 if (err >= 0) {
0418 err = usb_driver_claim_interface(driver, iface,
0419 USB_AUDIO_IFACE_UNUSED);
0420 if (err < 0)
0421 return err;
0422 }
0423 }
0424
0425 return 0;
0426 }
0427
0428
0429
0430
0431
0432 static int create_uaxx_quirk(struct snd_usb_audio *chip,
0433 struct usb_interface *iface,
0434 struct usb_driver *driver,
0435 const struct snd_usb_audio_quirk *quirk)
0436 {
0437 static const struct audioformat ua_format = {
0438 .formats = SNDRV_PCM_FMTBIT_S24_3LE,
0439 .channels = 2,
0440 .fmt_type = UAC_FORMAT_TYPE_I,
0441 .altsetting = 1,
0442 .altset_idx = 1,
0443 .rates = SNDRV_PCM_RATE_CONTINUOUS,
0444 };
0445 struct usb_host_interface *alts;
0446 struct usb_interface_descriptor *altsd;
0447 struct audioformat *fp;
0448 int err;
0449
0450
0451 if (iface->num_altsetting < 2)
0452 return -ENXIO;
0453 alts = &iface->altsetting[1];
0454 altsd = get_iface_desc(alts);
0455
0456 if (altsd->bNumEndpoints == 2) {
0457 static const struct snd_usb_midi_endpoint_info ua700_ep = {
0458 .out_cables = 0x0003,
0459 .in_cables = 0x0003
0460 };
0461 static const struct snd_usb_audio_quirk ua700_quirk = {
0462 .type = QUIRK_MIDI_FIXED_ENDPOINT,
0463 .data = &ua700_ep
0464 };
0465 static const struct snd_usb_midi_endpoint_info uaxx_ep = {
0466 .out_cables = 0x0001,
0467 .in_cables = 0x0001
0468 };
0469 static const struct snd_usb_audio_quirk uaxx_quirk = {
0470 .type = QUIRK_MIDI_FIXED_ENDPOINT,
0471 .data = &uaxx_ep
0472 };
0473 const struct snd_usb_audio_quirk *quirk =
0474 chip->usb_id == USB_ID(0x0582, 0x002b)
0475 ? &ua700_quirk : &uaxx_quirk;
0476 return __snd_usbmidi_create(chip->card, iface,
0477 &chip->midi_list, quirk,
0478 chip->usb_id);
0479 }
0480
0481 if (altsd->bNumEndpoints != 1)
0482 return -ENXIO;
0483
0484 fp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL);
0485 if (!fp)
0486 return -ENOMEM;
0487
0488 fp->iface = altsd->bInterfaceNumber;
0489 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
0490 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
0491 fp->datainterval = 0;
0492 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
0493 INIT_LIST_HEAD(&fp->list);
0494
0495 switch (fp->maxpacksize) {
0496 case 0x120:
0497 fp->rate_max = fp->rate_min = 44100;
0498 break;
0499 case 0x138:
0500 case 0x140:
0501 fp->rate_max = fp->rate_min = 48000;
0502 break;
0503 case 0x258:
0504 case 0x260:
0505 fp->rate_max = fp->rate_min = 96000;
0506 break;
0507 default:
0508 usb_audio_err(chip, "unknown sample rate\n");
0509 kfree(fp);
0510 return -ENXIO;
0511 }
0512
0513 err = add_audio_stream_from_fixed_fmt(chip, fp);
0514 if (err < 0) {
0515 list_del(&fp->list);
0516 kfree(fp);
0517 return err;
0518 }
0519 usb_set_interface(chip->dev, fp->iface, 0);
0520 return 0;
0521 }
0522
0523
0524
0525
0526 static int create_standard_mixer_quirk(struct snd_usb_audio *chip,
0527 struct usb_interface *iface,
0528 struct usb_driver *driver,
0529 const struct snd_usb_audio_quirk *quirk)
0530 {
0531 if (quirk->ifnum < 0)
0532 return 0;
0533
0534 return snd_usb_create_mixer(chip, quirk->ifnum);
0535 }
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545 int snd_usb_create_quirk(struct snd_usb_audio *chip,
0546 struct usb_interface *iface,
0547 struct usb_driver *driver,
0548 const struct snd_usb_audio_quirk *quirk)
0549 {
0550 typedef int (*quirk_func_t)(struct snd_usb_audio *,
0551 struct usb_interface *,
0552 struct usb_driver *,
0553 const struct snd_usb_audio_quirk *);
0554 static const quirk_func_t quirk_funcs[] = {
0555 [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk,
0556 [QUIRK_COMPOSITE] = create_composite_quirk,
0557 [QUIRK_AUTODETECT] = create_autodetect_quirks,
0558 [QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk,
0559 [QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk,
0560 [QUIRK_MIDI_YAMAHA] = create_any_midi_quirk,
0561 [QUIRK_MIDI_ROLAND] = create_any_midi_quirk,
0562 [QUIRK_MIDI_MIDIMAN] = create_any_midi_quirk,
0563 [QUIRK_MIDI_NOVATION] = create_any_midi_quirk,
0564 [QUIRK_MIDI_RAW_BYTES] = create_any_midi_quirk,
0565 [QUIRK_MIDI_EMAGIC] = create_any_midi_quirk,
0566 [QUIRK_MIDI_CME] = create_any_midi_quirk,
0567 [QUIRK_MIDI_AKAI] = create_any_midi_quirk,
0568 [QUIRK_MIDI_FTDI] = create_any_midi_quirk,
0569 [QUIRK_MIDI_CH345] = create_any_midi_quirk,
0570 [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk,
0571 [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
0572 [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk,
0573 [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk,
0574 };
0575
0576 if (quirk->type < QUIRK_TYPE_COUNT) {
0577 return quirk_funcs[quirk->type](chip, iface, driver, quirk);
0578 } else {
0579 usb_audio_err(chip, "invalid quirk type %d\n", quirk->type);
0580 return -ENXIO;
0581 }
0582 }
0583
0584
0585
0586
0587
0588 #define EXTIGY_FIRMWARE_SIZE_OLD 794
0589 #define EXTIGY_FIRMWARE_SIZE_NEW 483
0590
0591 static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf)
0592 {
0593 struct usb_host_config *config = dev->actconfig;
0594 int err;
0595
0596 if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD ||
0597 le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) {
0598 dev_dbg(&dev->dev, "sending Extigy boot sequence...\n");
0599
0600 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0),
0601 0x10, 0x43, 0x0001, 0x000a, NULL, 0);
0602 if (err < 0)
0603 dev_dbg(&dev->dev, "error sending boot message: %d\n", err);
0604 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
0605 &dev->descriptor, sizeof(dev->descriptor));
0606 config = dev->actconfig;
0607 if (err < 0)
0608 dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
0609 err = usb_reset_configuration(dev);
0610 if (err < 0)
0611 dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err);
0612 dev_dbg(&dev->dev, "extigy_boot: new boot length = %d\n",
0613 le16_to_cpu(get_cfg_desc(config)->wTotalLength));
0614 return -ENODEV;
0615 }
0616 return 0;
0617 }
0618
0619 static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev)
0620 {
0621 u8 buf = 1;
0622
0623 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a,
0624 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
0625 0, 0, &buf, 1);
0626 if (buf == 0) {
0627 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0x29,
0628 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
0629 1, 2000, NULL, 0);
0630 return -ENODEV;
0631 }
0632 return 0;
0633 }
0634
0635 static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
0636 {
0637 int err;
0638
0639 if (dev->actconfig->desc.bConfigurationValue == 1) {
0640 dev_info(&dev->dev,
0641 "Fast Track Pro switching to config #2\n");
0642
0643
0644
0645
0646
0647 err = usb_driver_set_configuration(dev, 2);
0648 if (err < 0)
0649 dev_dbg(&dev->dev,
0650 "error usb_driver_set_configuration: %d\n",
0651 err);
0652
0653
0654
0655 return -ENODEV;
0656 } else
0657 dev_info(&dev->dev, "Fast Track Pro config OK\n");
0658
0659 return 0;
0660 }
0661
0662
0663
0664
0665
0666 static int snd_usb_cm106_write_int_reg(struct usb_device *dev, int reg, u16 value)
0667 {
0668 u8 buf[4];
0669 buf[0] = 0x20;
0670 buf[1] = value & 0xff;
0671 buf[2] = (value >> 8) & 0xff;
0672 buf[3] = reg;
0673 return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION,
0674 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
0675 0, 0, &buf, 4);
0676 }
0677
0678 static int snd_usb_cm106_boot_quirk(struct usb_device *dev)
0679 {
0680
0681
0682
0683
0684 return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
0685 }
0686
0687
0688
0689
0690 #define CM6206_REG0_DMA_MASTER BIT(15)
0691 #define CM6206_REG0_SPDIFO_RATE_48K (2 << 12)
0692 #define CM6206_REG0_SPDIFO_RATE_96K (7 << 12)
0693
0694 #define CM6206_REG0_SPDIFO_CAT_CODE_GENERAL (0 << 4)
0695 #define CM6206_REG0_SPDIFO_EMPHASIS_CD BIT(3)
0696 #define CM6206_REG0_SPDIFO_COPYRIGHT_NA BIT(2)
0697 #define CM6206_REG0_SPDIFO_NON_AUDIO BIT(1)
0698 #define CM6206_REG0_SPDIFO_PRO_FORMAT BIT(0)
0699
0700 #define CM6206_REG1_TEST_SEL_CLK BIT(14)
0701 #define CM6206_REG1_PLLBIN_EN BIT(13)
0702 #define CM6206_REG1_SOFT_MUTE_EN BIT(12)
0703 #define CM6206_REG1_GPIO4_OUT BIT(11)
0704 #define CM6206_REG1_GPIO4_OE BIT(10)
0705 #define CM6206_REG1_GPIO3_OUT BIT(9)
0706 #define CM6206_REG1_GPIO3_OE BIT(8)
0707 #define CM6206_REG1_GPIO2_OUT BIT(7)
0708 #define CM6206_REG1_GPIO2_OE BIT(6)
0709 #define CM6206_REG1_GPIO1_OUT BIT(5)
0710 #define CM6206_REG1_GPIO1_OE BIT(4)
0711 #define CM6206_REG1_SPDIFO_INVALID BIT(3)
0712 #define CM6206_REG1_SPDIF_LOOP_EN BIT(2)
0713 #define CM6206_REG1_SPDIFO_DIS BIT(1)
0714 #define CM6206_REG1_SPDIFI_MIX BIT(0)
0715
0716 #define CM6206_REG2_DRIVER_ON BIT(15)
0717 #define CM6206_REG2_HEADP_SEL_SIDE_CHANNELS (0 << 13)
0718 #define CM6206_REG2_HEADP_SEL_SURROUND_CHANNELS (1 << 13)
0719 #define CM6206_REG2_HEADP_SEL_CENTER_SUBW (2 << 13)
0720 #define CM6206_REG2_HEADP_SEL_FRONT_CHANNELS (3 << 13)
0721 #define CM6206_REG2_MUTE_HEADPHONE_RIGHT BIT(12)
0722 #define CM6206_REG2_MUTE_HEADPHONE_LEFT BIT(11)
0723 #define CM6206_REG2_MUTE_REAR_SURROUND_RIGHT BIT(10)
0724 #define CM6206_REG2_MUTE_REAR_SURROUND_LEFT BIT(9)
0725 #define CM6206_REG2_MUTE_SIDE_SURROUND_RIGHT BIT(8)
0726 #define CM6206_REG2_MUTE_SIDE_SURROUND_LEFT BIT(7)
0727 #define CM6206_REG2_MUTE_SUBWOOFER BIT(6)
0728 #define CM6206_REG2_MUTE_CENTER BIT(5)
0729 #define CM6206_REG2_MUTE_RIGHT_FRONT BIT(3)
0730 #define CM6206_REG2_MUTE_LEFT_FRONT BIT(3)
0731 #define CM6206_REG2_EN_BTL BIT(2)
0732 #define CM6206_REG2_MCUCLKSEL_1_5_MHZ (0)
0733 #define CM6206_REG2_MCUCLKSEL_3_MHZ (1)
0734 #define CM6206_REG2_MCUCLKSEL_6_MHZ (2)
0735 #define CM6206_REG2_MCUCLKSEL_12_MHZ (3)
0736
0737
0738 #define CM6206_REG3_FLYSPEED_DEFAULT (2 << 11)
0739 #define CM6206_REG3_VRAP25EN BIT(10)
0740 #define CM6206_REG3_MSEL1 BIT(9)
0741 #define CM6206_REG3_SPDIFI_RATE_44_1K BIT(0 << 7)
0742 #define CM6206_REG3_SPDIFI_RATE_48K BIT(2 << 7)
0743 #define CM6206_REG3_SPDIFI_RATE_32K BIT(3 << 7)
0744 #define CM6206_REG3_PINSEL BIT(6)
0745 #define CM6206_REG3_FOE BIT(5)
0746 #define CM6206_REG3_ROE BIT(4)
0747 #define CM6206_REG3_CBOE BIT(3)
0748 #define CM6206_REG3_LOSE BIT(2)
0749 #define CM6206_REG3_HPOE BIT(1)
0750 #define CM6206_REG3_SPDIFI_CANREC BIT(0)
0751
0752 #define CM6206_REG5_DA_RSTN BIT(13)
0753 #define CM6206_REG5_AD_RSTN BIT(12)
0754 #define CM6206_REG5_SPDIFO_AD2SPDO BIT(12)
0755 #define CM6206_REG5_SPDIFO_SEL_FRONT (0 << 9)
0756 #define CM6206_REG5_SPDIFO_SEL_SIDE_SUR (1 << 9)
0757 #define CM6206_REG5_SPDIFO_SEL_CEN_LFE (2 << 9)
0758 #define CM6206_REG5_SPDIFO_SEL_REAR_SUR (3 << 9)
0759 #define CM6206_REG5_CODECM BIT(8)
0760 #define CM6206_REG5_EN_HPF BIT(7)
0761 #define CM6206_REG5_T_SEL_DSDA4 BIT(6)
0762 #define CM6206_REG5_T_SEL_DSDA3 BIT(5)
0763 #define CM6206_REG5_T_SEL_DSDA2 BIT(4)
0764 #define CM6206_REG5_T_SEL_DSDA1 BIT(3)
0765 #define CM6206_REG5_T_SEL_DSDAD_NORMAL 0
0766 #define CM6206_REG5_T_SEL_DSDAD_FRONT 4
0767 #define CM6206_REG5_T_SEL_DSDAD_S_SURROUND 5
0768 #define CM6206_REG5_T_SEL_DSDAD_CEN_LFE 6
0769 #define CM6206_REG5_T_SEL_DSDAD_R_SURROUND 7
0770
0771 static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)
0772 {
0773 int err = 0, reg;
0774 int val[] = {
0775
0776
0777
0778
0779
0780
0781 CM6206_REG0_SPDIFO_RATE_48K |
0782 CM6206_REG0_SPDIFO_COPYRIGHT_NA,
0783
0784
0785
0786 CM6206_REG1_PLLBIN_EN |
0787 CM6206_REG1_SOFT_MUTE_EN,
0788
0789
0790
0791
0792
0793
0794 CM6206_REG2_DRIVER_ON |
0795 CM6206_REG2_HEADP_SEL_FRONT_CHANNELS |
0796 CM6206_REG2_MUTE_HEADPHONE_RIGHT |
0797 CM6206_REG2_MUTE_HEADPHONE_LEFT,
0798
0799
0800
0801
0802 CM6206_REG3_FLYSPEED_DEFAULT |
0803 CM6206_REG3_VRAP25EN |
0804 CM6206_REG3_FOE |
0805 CM6206_REG3_ROE |
0806 CM6206_REG3_CBOE |
0807 CM6206_REG3_LOSE |
0808 CM6206_REG3_HPOE |
0809 CM6206_REG3_SPDIFI_CANREC,
0810
0811 0x0000,
0812
0813 CM6206_REG5_DA_RSTN |
0814 CM6206_REG5_AD_RSTN };
0815
0816 for (reg = 0; reg < ARRAY_SIZE(val); reg++) {
0817 err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]);
0818 if (err < 0)
0819 return err;
0820 }
0821
0822 return err;
0823 }
0824
0825
0826 static int snd_usb_gamecon780_boot_quirk(struct usb_device *dev)
0827 {
0828
0829
0830
0831 u8 buf[2] = { 0x74, 0xe3 };
0832 return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
0833 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
0834 UAC_FU_VOLUME << 8, 9 << 8, buf, 2);
0835 }
0836
0837
0838
0839
0840
0841 static int snd_usb_novation_boot_quirk(struct usb_device *dev)
0842 {
0843
0844
0845 usb_set_interface(dev, 0, 1);
0846 return 0;
0847 }
0848
0849
0850
0851
0852
0853
0854
0855
0856 static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev)
0857 {
0858 int err, actual_length;
0859
0860 static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 };
0861 void *buf;
0862
0863 if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05)))
0864 return -EINVAL;
0865 buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL);
0866 if (!buf)
0867 return -ENOMEM;
0868 err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf,
0869 ARRAY_SIZE(seq), &actual_length, 1000);
0870 kfree(buf);
0871 if (err < 0)
0872 return err;
0873
0874 return 0;
0875 }
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888 static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev)
0889 {
0890 int ret;
0891
0892 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
0893 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0894 1, 0, NULL, 0, 1000);
0895
0896 if (ret < 0)
0897 return ret;
0898
0899 usb_reset_device(dev);
0900
0901
0902
0903
0904 return -EAGAIN;
0905 }
0906
0907 static void mbox2_setup_48_24_magic(struct usb_device *dev)
0908 {
0909 u8 srate[3];
0910 u8 temp[12];
0911
0912
0913 srate[0] = 0x80;
0914 srate[1] = 0xbb;
0915 srate[2] = 0x00;
0916
0917
0918 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0),
0919 0x01, 0x22, 0x0100, 0x0085, &temp, 0x0003);
0920 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
0921 0x81, 0xa2, 0x0100, 0x0085, &srate, 0x0003);
0922 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
0923 0x81, 0xa2, 0x0100, 0x0086, &srate, 0x0003);
0924 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
0925 0x81, 0xa2, 0x0100, 0x0003, &srate, 0x0003);
0926 return;
0927 }
0928
0929
0930
0931
0932
0933 #define MBOX2_FIRMWARE_SIZE 646
0934 #define MBOX2_BOOT_LOADING 0x01
0935 #define MBOX2_BOOT_READY 0x02
0936
0937 static int snd_usb_mbox2_boot_quirk(struct usb_device *dev)
0938 {
0939 struct usb_host_config *config = dev->actconfig;
0940 int err;
0941 u8 bootresponse[0x12];
0942 int fwsize;
0943 int count;
0944
0945 fwsize = le16_to_cpu(get_cfg_desc(config)->wTotalLength);
0946
0947 if (fwsize != MBOX2_FIRMWARE_SIZE) {
0948 dev_err(&dev->dev, "Invalid firmware size=%d.\n", fwsize);
0949 return -ENODEV;
0950 }
0951
0952 dev_dbg(&dev->dev, "Sending Digidesign Mbox 2 boot sequence...\n");
0953
0954 count = 0;
0955 bootresponse[0] = MBOX2_BOOT_LOADING;
0956 while ((bootresponse[0] == MBOX2_BOOT_LOADING) && (count < 10)) {
0957 msleep(500);
0958 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0),
0959
0960 0x85, 0xc0, 0x0001, 0x0000, &bootresponse, 0x0012);
0961 if (bootresponse[0] == MBOX2_BOOT_READY)
0962 break;
0963 dev_dbg(&dev->dev, "device not ready, resending boot sequence...\n");
0964 count++;
0965 }
0966
0967 if (bootresponse[0] != MBOX2_BOOT_READY) {
0968 dev_err(&dev->dev, "Unknown bootresponse=%d, or timed out, ignoring device.\n", bootresponse[0]);
0969 return -ENODEV;
0970 }
0971
0972 dev_dbg(&dev->dev, "device initialised!\n");
0973
0974 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
0975 &dev->descriptor, sizeof(dev->descriptor));
0976 config = dev->actconfig;
0977 if (err < 0)
0978 dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
0979
0980 err = usb_reset_configuration(dev);
0981 if (err < 0)
0982 dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err);
0983 dev_dbg(&dev->dev, "mbox2_boot: new boot length = %d\n",
0984 le16_to_cpu(get_cfg_desc(config)->wTotalLength));
0985
0986 mbox2_setup_48_24_magic(dev);
0987
0988 dev_info(&dev->dev, "Digidesign Mbox 2: 24bit 48kHz");
0989
0990 return 0;
0991 }
0992
0993 static int snd_usb_axefx3_boot_quirk(struct usb_device *dev)
0994 {
0995 int err;
0996
0997 dev_dbg(&dev->dev, "Waiting for Axe-Fx III to boot up...\n");
0998
0999
1000
1001
1002
1003
1004 err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1005 USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,
1006 1, 1, NULL, 0, 120000);
1007 if (err < 0) {
1008 dev_err(&dev->dev,
1009 "failed waiting for Axe-Fx III to boot: %d\n", err);
1010 return err;
1011 }
1012
1013 dev_dbg(&dev->dev, "Axe-Fx III is now ready\n");
1014
1015 err = usb_set_interface(dev, 1, 0);
1016 if (err < 0)
1017 dev_dbg(&dev->dev,
1018 "error stopping Axe-Fx III interface: %d\n", err);
1019
1020 return 0;
1021 }
1022
1023
1024 #define MICROBOOK_BUF_SIZE 128
1025
1026 static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf,
1027 int buf_size, int *length)
1028 {
1029 int err, actual_length;
1030
1031 if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01)))
1032 return -EINVAL;
1033 err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length,
1034 &actual_length, 1000);
1035 if (err < 0)
1036 return err;
1037
1038 print_hex_dump(KERN_DEBUG, "MicroBookII snd: ", DUMP_PREFIX_NONE, 16, 1,
1039 buf, actual_length, false);
1040
1041 memset(buf, 0, buf_size);
1042
1043 if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82)))
1044 return -EINVAL;
1045 err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size,
1046 &actual_length, 1000);
1047 if (err < 0)
1048 return err;
1049
1050 print_hex_dump(KERN_DEBUG, "MicroBookII rcv: ", DUMP_PREFIX_NONE, 16, 1,
1051 buf, actual_length, false);
1052
1053 *length = actual_length;
1054 return 0;
1055 }
1056
1057 static int snd_usb_motu_microbookii_boot_quirk(struct usb_device *dev)
1058 {
1059 int err, actual_length, poll_attempts = 0;
1060 static const u8 set_samplerate_seq[] = { 0x00, 0x00, 0x00, 0x00,
1061 0x00, 0x00, 0x0b, 0x14,
1062 0x00, 0x00, 0x00, 0x01 };
1063 static const u8 poll_ready_seq[] = { 0x00, 0x04, 0x00, 0x00,
1064 0x00, 0x00, 0x0b, 0x18 };
1065 u8 *buf = kzalloc(MICROBOOK_BUF_SIZE, GFP_KERNEL);
1066
1067 if (!buf)
1068 return -ENOMEM;
1069
1070 dev_info(&dev->dev, "Waiting for MOTU Microbook II to boot up...\n");
1071
1072
1073 memcpy(buf, set_samplerate_seq, sizeof(set_samplerate_seq));
1074 actual_length = sizeof(set_samplerate_seq);
1075 err = snd_usb_motu_microbookii_communicate(dev, buf, MICROBOOK_BUF_SIZE,
1076 &actual_length);
1077
1078 if (err < 0) {
1079 dev_err(&dev->dev,
1080 "failed setting the sample rate for Motu MicroBook II: %d\n",
1081 err);
1082 goto free_buf;
1083 }
1084
1085
1086 while (true) {
1087 if (++poll_attempts > 100) {
1088 dev_err(&dev->dev,
1089 "failed booting Motu MicroBook II: timeout\n");
1090 err = -ENODEV;
1091 goto free_buf;
1092 }
1093
1094 memset(buf, 0, MICROBOOK_BUF_SIZE);
1095 memcpy(buf, poll_ready_seq, sizeof(poll_ready_seq));
1096
1097 actual_length = sizeof(poll_ready_seq);
1098 err = snd_usb_motu_microbookii_communicate(
1099 dev, buf, MICROBOOK_BUF_SIZE, &actual_length);
1100 if (err < 0) {
1101 dev_err(&dev->dev,
1102 "failed booting Motu MicroBook II: communication error %d\n",
1103 err);
1104 goto free_buf;
1105 }
1106
1107
1108
1109
1110
1111
1112
1113 if (actual_length == 12 && buf[actual_length - 1] == 1)
1114 break;
1115
1116 msleep(100);
1117 }
1118
1119 dev_info(&dev->dev, "MOTU MicroBook II ready\n");
1120
1121 free_buf:
1122 kfree(buf);
1123 return err;
1124 }
1125
1126 static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev)
1127 {
1128 msleep(2000);
1129
1130 return 0;
1131 }
1132
1133
1134
1135
1136 #define MAUDIO_SET 0x01
1137 #define MAUDIO_SET_COMPATIBLE 0x80
1138 #define MAUDIO_SET_DTS 0x02
1139 #define MAUDIO_SET_96K 0x04
1140 #define MAUDIO_SET_24B 0x08
1141 #define MAUDIO_SET_DI 0x10
1142 #define MAUDIO_SET_MASK 0x1f
1143 #define MAUDIO_SET_24B_48K_DI 0x19
1144 #define MAUDIO_SET_24B_48K_NOTDI 0x09
1145 #define MAUDIO_SET_16B_48K_DI 0x11
1146 #define MAUDIO_SET_16B_48K_NOTDI 0x01
1147
1148 static int quattro_skip_setting_quirk(struct snd_usb_audio *chip,
1149 int iface, int altno)
1150 {
1151
1152
1153
1154 usb_set_interface(chip->dev, iface, 0);
1155 if (chip->setup & MAUDIO_SET) {
1156 if (chip->setup & MAUDIO_SET_COMPATIBLE) {
1157 if (iface != 1 && iface != 2)
1158 return 1;
1159 } else {
1160 unsigned int mask;
1161 if (iface == 1 || iface == 2)
1162 return 1;
1163 if ((chip->setup & MAUDIO_SET_96K) && altno != 1)
1164 return 1;
1165 mask = chip->setup & MAUDIO_SET_MASK;
1166 if (mask == MAUDIO_SET_24B_48K_DI && altno != 2)
1167 return 1;
1168 if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3)
1169 return 1;
1170 if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 4)
1171 return 1;
1172 }
1173 }
1174 usb_audio_dbg(chip,
1175 "using altsetting %d for interface %d config %d\n",
1176 altno, iface, chip->setup);
1177 return 0;
1178 }
1179
1180 static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
1181 int iface,
1182 int altno)
1183 {
1184
1185
1186
1187 usb_set_interface(chip->dev, iface, 0);
1188
1189 if (chip->setup & MAUDIO_SET) {
1190 unsigned int mask;
1191 if ((chip->setup & MAUDIO_SET_DTS) && altno != 6)
1192 return 1;
1193 if ((chip->setup & MAUDIO_SET_96K) && altno != 1)
1194 return 1;
1195 mask = chip->setup & MAUDIO_SET_MASK;
1196 if (mask == MAUDIO_SET_24B_48K_DI && altno != 2)
1197 return 1;
1198 if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3)
1199 return 1;
1200 if (mask == MAUDIO_SET_16B_48K_DI && altno != 4)
1201 return 1;
1202 if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 5)
1203 return 1;
1204 }
1205
1206 return 0;
1207 }
1208
1209 static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip,
1210 int iface, int altno)
1211 {
1212
1213
1214
1215 usb_set_interface(chip->dev, iface, 0);
1216
1217
1218
1219
1220 if (chip->setup & (MAUDIO_SET | MAUDIO_SET_24B)) {
1221 if (chip->setup & MAUDIO_SET_96K) {
1222 if (altno != 3 && altno != 6)
1223 return 1;
1224 } else if (chip->setup & MAUDIO_SET_DI) {
1225 if (iface == 4)
1226 return 1;
1227 if (altno != 2 && altno != 5)
1228 return 1;
1229 } else {
1230 if (iface == 5)
1231 return 1;
1232 if (altno != 2 && altno != 5)
1233 return 1;
1234 }
1235 } else {
1236
1237 if (altno != 1)
1238 return 1;
1239 }
1240
1241 usb_audio_dbg(chip,
1242 "using altsetting %d for interface %d config %d\n",
1243 altno, iface, chip->setup);
1244 return 0;
1245 }
1246
1247 static int s1810c_skip_setting_quirk(struct snd_usb_audio *chip,
1248 int iface, int altno)
1249 {
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269 if ((chip->setup == 0 || chip->setup > 2) && altno != 2)
1270 return 1;
1271 else if (chip->setup == 1 && altno != 1)
1272 return 1;
1273 else if (chip->setup == 2 && altno != 3)
1274 return 1;
1275
1276 return 0;
1277 }
1278
1279 int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip,
1280 int iface,
1281 int altno)
1282 {
1283
1284 if (chip->usb_id == USB_ID(0x0763, 0x2003))
1285 return audiophile_skip_setting_quirk(chip, iface, altno);
1286
1287 if (chip->usb_id == USB_ID(0x0763, 0x2001))
1288 return quattro_skip_setting_quirk(chip, iface, altno);
1289
1290 if (chip->usb_id == USB_ID(0x0763, 0x2012))
1291 return fasttrackpro_skip_setting_quirk(chip, iface, altno);
1292
1293 if (chip->usb_id == USB_ID(0x194f, 0x010c))
1294 return s1810c_skip_setting_quirk(chip, iface, altno);
1295
1296
1297 return 0;
1298 }
1299
1300 int snd_usb_apply_boot_quirk(struct usb_device *dev,
1301 struct usb_interface *intf,
1302 const struct snd_usb_audio_quirk *quirk,
1303 unsigned int id)
1304 {
1305 switch (id) {
1306 case USB_ID(0x041e, 0x3000):
1307
1308
1309 return snd_usb_extigy_boot_quirk(dev, intf);
1310
1311 case USB_ID(0x041e, 0x3020):
1312
1313 return snd_usb_audigy2nx_boot_quirk(dev);
1314
1315 case USB_ID(0x10f5, 0x0200):
1316
1317 return snd_usb_cm106_boot_quirk(dev);
1318
1319 case USB_ID(0x0d8c, 0x0102):
1320
1321 case USB_ID(0x0ccd, 0x00b1):
1322 return snd_usb_cm6206_boot_quirk(dev);
1323
1324 case USB_ID(0x0dba, 0x3000):
1325
1326 return snd_usb_mbox2_boot_quirk(dev);
1327
1328 case USB_ID(0x1235, 0x0010):
1329 case USB_ID(0x1235, 0x0018):
1330 return snd_usb_novation_boot_quirk(dev);
1331
1332 case USB_ID(0x133e, 0x0815):
1333
1334 return snd_usb_accessmusic_boot_quirk(dev);
1335
1336 case USB_ID(0x17cc, 0x1000):
1337 case USB_ID(0x17cc, 0x1010):
1338 case USB_ID(0x17cc, 0x1020):
1339 return snd_usb_nativeinstruments_boot_quirk(dev);
1340 case USB_ID(0x0763, 0x2012):
1341 return snd_usb_fasttrackpro_boot_quirk(dev);
1342 case USB_ID(0x047f, 0xc010):
1343 return snd_usb_gamecon780_boot_quirk(dev);
1344 case USB_ID(0x2466, 0x8010):
1345 return snd_usb_axefx3_boot_quirk(dev);
1346 case USB_ID(0x07fd, 0x0004):
1347
1348
1349
1350
1351 if (get_iface_desc(intf->altsetting)->bInterfaceClass ==
1352 USB_CLASS_VENDOR_SPEC &&
1353 get_iface_desc(intf->altsetting)->bInterfaceNumber < 3)
1354 return snd_usb_motu_microbookii_boot_quirk(dev);
1355 break;
1356 }
1357
1358 return 0;
1359 }
1360
1361 int snd_usb_apply_boot_quirk_once(struct usb_device *dev,
1362 struct usb_interface *intf,
1363 const struct snd_usb_audio_quirk *quirk,
1364 unsigned int id)
1365 {
1366 switch (id) {
1367 case USB_ID(0x07fd, 0x0008):
1368 return snd_usb_motu_m_series_boot_quirk(dev);
1369 }
1370
1371 return 0;
1372 }
1373
1374
1375
1376
1377 int snd_usb_is_big_endian_format(struct snd_usb_audio *chip,
1378 const struct audioformat *fp)
1379 {
1380
1381 switch (chip->usb_id) {
1382 case USB_ID(0x0763, 0x2001):
1383 if (fp->altsetting == 2 || fp->altsetting == 3 ||
1384 fp->altsetting == 5 || fp->altsetting == 6)
1385 return 1;
1386 break;
1387 case USB_ID(0x0763, 0x2003):
1388 if (chip->setup == 0x00 ||
1389 fp->altsetting == 1 || fp->altsetting == 2 ||
1390 fp->altsetting == 3)
1391 return 1;
1392 break;
1393 case USB_ID(0x0763, 0x2012):
1394 if (fp->altsetting == 2 || fp->altsetting == 3 ||
1395 fp->altsetting == 5 || fp->altsetting == 6)
1396 return 1;
1397 break;
1398 }
1399 return 0;
1400 }
1401
1402
1403
1404
1405
1406
1407 enum {
1408 EMU_QUIRK_SR_44100HZ = 0,
1409 EMU_QUIRK_SR_48000HZ,
1410 EMU_QUIRK_SR_88200HZ,
1411 EMU_QUIRK_SR_96000HZ,
1412 EMU_QUIRK_SR_176400HZ,
1413 EMU_QUIRK_SR_192000HZ
1414 };
1415
1416 static void set_format_emu_quirk(struct snd_usb_substream *subs,
1417 const struct audioformat *fmt)
1418 {
1419 unsigned char emu_samplerate_id = 0;
1420
1421
1422
1423
1424
1425 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) {
1426 if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].cur_audiofmt)
1427 return;
1428 }
1429
1430 switch (fmt->rate_min) {
1431 case 48000:
1432 emu_samplerate_id = EMU_QUIRK_SR_48000HZ;
1433 break;
1434 case 88200:
1435 emu_samplerate_id = EMU_QUIRK_SR_88200HZ;
1436 break;
1437 case 96000:
1438 emu_samplerate_id = EMU_QUIRK_SR_96000HZ;
1439 break;
1440 case 176400:
1441 emu_samplerate_id = EMU_QUIRK_SR_176400HZ;
1442 break;
1443 case 192000:
1444 emu_samplerate_id = EMU_QUIRK_SR_192000HZ;
1445 break;
1446 default:
1447 emu_samplerate_id = EMU_QUIRK_SR_44100HZ;
1448 break;
1449 }
1450 snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id);
1451 subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0;
1452 }
1453
1454 static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs,
1455 u16 windex)
1456 {
1457 unsigned int cur_rate = subs->data_endpoint->cur_rate;
1458 u8 sr[3];
1459
1460 sr[0] = cur_rate & 0xff;
1461 sr[1] = (cur_rate >> 8) & 0xff;
1462 sr[2] = (cur_rate >> 16) & 0xff;
1463 usb_set_interface(subs->dev, 0, 1);
1464
1465 snd_usb_ctl_msg(subs->stream->chip->dev,
1466 usb_sndctrlpipe(subs->stream->chip->dev, 0),
1467 0x01, 0x22, 0x0100, windex, &sr, 0x0003);
1468 return 0;
1469 }
1470
1471 void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
1472 const struct audioformat *fmt)
1473 {
1474 switch (subs->stream->chip->usb_id) {
1475 case USB_ID(0x041e, 0x3f02):
1476 case USB_ID(0x041e, 0x3f04):
1477 case USB_ID(0x041e, 0x3f0a):
1478 case USB_ID(0x041e, 0x3f19):
1479 set_format_emu_quirk(subs, fmt);
1480 break;
1481 case USB_ID(0x534d, 0x0021):
1482 case USB_ID(0x534d, 0x2109):
1483 subs->stream_offset_adj = 2;
1484 break;
1485 case USB_ID(0x2b73, 0x0013):
1486 pioneer_djm_set_format_quirk(subs, 0x0082);
1487 break;
1488 case USB_ID(0x08e4, 0x017f):
1489 case USB_ID(0x08e4, 0x0163):
1490 pioneer_djm_set_format_quirk(subs, 0x0086);
1491 break;
1492 }
1493 }
1494
1495 int snd_usb_select_mode_quirk(struct snd_usb_audio *chip,
1496 const struct audioformat *fmt)
1497 {
1498 struct usb_device *dev = chip->dev;
1499 int err;
1500
1501 if (chip->quirk_flags & QUIRK_FLAG_ITF_USB_DSD_DAC) {
1502
1503
1504
1505 err = usb_set_interface(dev, fmt->iface, 0);
1506 if (err < 0)
1507 return err;
1508
1509 msleep(20);
1510
1511
1512 if (fmt->formats & SNDRV_PCM_FMTBIT_DSD_U32_BE) {
1513
1514 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0,
1515 USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE,
1516 1, 1, NULL, 0);
1517 if (err < 0)
1518 return err;
1519
1520 } else {
1521
1522
1523 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0,
1524 USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE,
1525 0, 1, NULL, 0);
1526 if (err < 0)
1527 return err;
1528
1529 }
1530 msleep(20);
1531 }
1532 return 0;
1533 }
1534
1535 void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep)
1536 {
1537
1538
1539
1540
1541 if (USB_ID_VENDOR(ep->chip->usb_id) == 0x23ba &&
1542 ep->type == SND_USB_ENDPOINT_TYPE_SYNC)
1543 ep->skip_packets = 4;
1544
1545
1546
1547
1548
1549
1550
1551
1552 if ((ep->chip->usb_id == USB_ID(0x0763, 0x2030) ||
1553 ep->chip->usb_id == USB_ID(0x0763, 0x2031)) &&
1554 ep->type == SND_USB_ENDPOINT_TYPE_DATA)
1555 ep->skip_packets = 16;
1556
1557
1558 if ((ep->chip->usb_id == USB_ID(0x0644, 0x8038) ||
1559 ep->chip->usb_id == USB_ID(0x1852, 0x5034)) &&
1560 ep->syncmaxsize == 4)
1561 ep->tenor_fb_quirk = 1;
1562 }
1563
1564
1565 void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
1566 __u8 request, __u8 requesttype, __u16 value,
1567 __u16 index, void *data, __u16 size)
1568 {
1569 struct snd_usb_audio *chip = dev_get_drvdata(&dev->dev);
1570
1571 if (!chip || (requesttype & USB_TYPE_MASK) != USB_TYPE_CLASS)
1572 return;
1573
1574 if (chip->quirk_flags & QUIRK_FLAG_CTL_MSG_DELAY)
1575 msleep(20);
1576 else if (chip->quirk_flags & QUIRK_FLAG_CTL_MSG_DELAY_1M)
1577 usleep_range(1000, 2000);
1578 else if (chip->quirk_flags & QUIRK_FLAG_CTL_MSG_DELAY_5M)
1579 usleep_range(5000, 6000);
1580 }
1581
1582
1583
1584
1585
1586
1587
1588
1589 u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
1590 struct audioformat *fp,
1591 unsigned int sample_bytes)
1592 {
1593 struct usb_interface *iface;
1594
1595
1596 if (USB_ID_VENDOR(chip->usb_id) == 0x23ba &&
1597 USB_ID_PRODUCT(chip->usb_id) < 0x0110) {
1598 switch (fp->altsetting) {
1599 case 1:
1600 fp->dsd_dop = true;
1601 return SNDRV_PCM_FMTBIT_DSD_U16_LE;
1602 case 2:
1603 fp->dsd_bitrev = true;
1604 return SNDRV_PCM_FMTBIT_DSD_U8;
1605 case 3:
1606 fp->dsd_bitrev = true;
1607 return SNDRV_PCM_FMTBIT_DSD_U16_LE;
1608 }
1609 }
1610
1611
1612 switch (chip->usb_id) {
1613 case USB_ID(0x1511, 0x0037):
1614 case USB_ID(0x2522, 0x0012):
1615 case USB_ID(0x2772, 0x0230):
1616 if (fp->altsetting == 2)
1617 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1618 break;
1619
1620 case USB_ID(0x0d8c, 0x0316):
1621 case USB_ID(0x10cb, 0x0103):
1622 case USB_ID(0x16d0, 0x06b2):
1623 case USB_ID(0x16d0, 0x09dd):
1624 case USB_ID(0x16d0, 0x0733):
1625 case USB_ID(0x16d0, 0x09db):
1626 case USB_ID(0x1db5, 0x0003):
1627 case USB_ID(0x22e1, 0xca01):
1628 case USB_ID(0x249c, 0x9326):
1629 case USB_ID(0x2616, 0x0106):
1630 case USB_ID(0x2622, 0x0041):
1631 case USB_ID(0x27f7, 0x3002):
1632 case USB_ID(0x29a2, 0x0086):
1633 case USB_ID(0x6b42, 0x0042):
1634 if (fp->altsetting == 3)
1635 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1636 break;
1637
1638
1639 case USB_ID(0x16d0, 0x071a):
1640 case USB_ID(0x2ab6, 0x0004):
1641 case USB_ID(0x2ab6, 0x0005):
1642 case USB_ID(0x2ab6, 0x0006):
1643 if (fp->altsetting == 2) {
1644 switch (le16_to_cpu(chip->dev->descriptor.bcdDevice)) {
1645 case 0x199:
1646 return SNDRV_PCM_FMTBIT_DSD_U32_LE;
1647 case 0x19b:
1648 case 0x203:
1649 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1650 default:
1651 break;
1652 }
1653 }
1654 break;
1655 case USB_ID(0x16d0, 0x0a23):
1656 if (fp->altsetting == 2)
1657 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1658 break;
1659
1660 default:
1661 break;
1662 }
1663
1664
1665 if (chip->quirk_flags & QUIRK_FLAG_ITF_USB_DSD_DAC) {
1666 iface = usb_ifnum_to_if(chip->dev, fp->iface);
1667
1668
1669
1670
1671
1672
1673 if (fp->altsetting == iface->num_altsetting - 1)
1674 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1675 }
1676
1677
1678 if ((chip->quirk_flags & QUIRK_FLAG_DSD_RAW) && fp->dsd_raw)
1679 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1680
1681 return 0;
1682 }
1683
1684 void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
1685 struct audioformat *fp,
1686 int stream)
1687 {
1688 switch (chip->usb_id) {
1689 case USB_ID(0x0a92, 0x0053):
1690
1691
1692
1693 fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE;
1694 break;
1695 case USB_ID(0x041e, 0x3020):
1696 case USB_ID(0x0763, 0x2003):
1697
1698 fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
1699 break;
1700 case USB_ID(0x0763, 0x2001):
1701 case USB_ID(0x0763, 0x2012):
1702 case USB_ID(0x047f, 0x0ca1):
1703 case USB_ID(0x077d, 0x07af):
1704
1705
1706
1707
1708
1709 fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE;
1710 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
1711 fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE;
1712 else
1713 fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC;
1714 break;
1715 case USB_ID(0x07fd, 0x0004):
1716
1717
1718
1719
1720
1721 fp->attributes &= ~UAC_EP_CS_ATTR_FILL_MAX;
1722 break;
1723 case USB_ID(0x1224, 0x2a25):
1724
1725 fp->attributes |= UAC_EP_CS_ATTR_FILL_MAX;
1726 break;
1727
1728 }
1729 }
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739 struct registration_quirk {
1740 unsigned int usb_id;
1741 unsigned int interface;
1742 };
1743
1744 #define REG_QUIRK_ENTRY(vendor, product, iface) \
1745 { .usb_id = USB_ID(vendor, product), .interface = (iface) }
1746
1747 static const struct registration_quirk registration_quirks[] = {
1748 REG_QUIRK_ENTRY(0x0951, 0x16d8, 2),
1749 REG_QUIRK_ENTRY(0x0951, 0x16ed, 2),
1750 REG_QUIRK_ENTRY(0x0951, 0x16ea, 2),
1751 REG_QUIRK_ENTRY(0x0ecb, 0x1f46, 2),
1752 REG_QUIRK_ENTRY(0x0ecb, 0x1f47, 2),
1753 REG_QUIRK_ENTRY(0x0ecb, 0x1f4c, 2),
1754 REG_QUIRK_ENTRY(0x0ecb, 0x2039, 2),
1755 REG_QUIRK_ENTRY(0x0ecb, 0x203c, 2),
1756 REG_QUIRK_ENTRY(0x0ecb, 0x203e, 2),
1757 { 0 }
1758 };
1759
1760
1761 bool snd_usb_registration_quirk(struct snd_usb_audio *chip, int iface)
1762 {
1763 const struct registration_quirk *q;
1764
1765 for (q = registration_quirks; q->usb_id; q++)
1766 if (chip->usb_id == q->usb_id)
1767 return iface < q->interface;
1768
1769
1770 return false;
1771 }
1772
1773
1774
1775
1776 struct usb_audio_quirk_flags_table {
1777 u32 id;
1778 u32 flags;
1779 };
1780
1781 #define DEVICE_FLG(vid, pid, _flags) \
1782 { .id = USB_ID(vid, pid), .flags = (_flags) }
1783 #define VENDOR_FLG(vid, _flags) DEVICE_FLG(vid, 0, _flags)
1784
1785 static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
1786
1787 DEVICE_FLG(0x041e, 0x3000,
1788 QUIRK_FLAG_IGNORE_CTL_ERROR),
1789 DEVICE_FLG(0x041e, 0x4080,
1790 QUIRK_FLAG_GET_SAMPLE_RATE),
1791 DEVICE_FLG(0x046d, 0x084c,
1792 QUIRK_FLAG_GET_SAMPLE_RATE | QUIRK_FLAG_CTL_MSG_DELAY_1M),
1793 DEVICE_FLG(0x046d, 0x0991,
1794 QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_IGNORE_CTL_ERROR),
1795 DEVICE_FLG(0x046d, 0x09a4,
1796 QUIRK_FLAG_CTL_MSG_DELAY_1M | QUIRK_FLAG_IGNORE_CTL_ERROR),
1797 DEVICE_FLG(0x0499, 0x1509,
1798 QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1799 DEVICE_FLG(0x04d8, 0xfeea,
1800 QUIRK_FLAG_GET_SAMPLE_RATE),
1801 DEVICE_FLG(0x04e8, 0xa051,
1802 QUIRK_FLAG_SKIP_CLOCK_SELECTOR | QUIRK_FLAG_CTL_MSG_DELAY_5M),
1803 DEVICE_FLG(0x054c, 0x0b8c,
1804 QUIRK_FLAG_SET_IFACE_FIRST),
1805 DEVICE_FLG(0x0556, 0x0014,
1806 QUIRK_FLAG_GET_SAMPLE_RATE),
1807 DEVICE_FLG(0x05a3, 0x9420,
1808 QUIRK_FLAG_GET_SAMPLE_RATE),
1809 DEVICE_FLG(0x05a7, 0x1020,
1810 QUIRK_FLAG_GET_SAMPLE_RATE),
1811 DEVICE_FLG(0x05e1, 0x0408,
1812 QUIRK_FLAG_ALIGN_TRANSFER),
1813 DEVICE_FLG(0x05e1, 0x0480,
1814 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1815 DEVICE_FLG(0x0644, 0x8043,
1816 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY |
1817 QUIRK_FLAG_IFACE_DELAY),
1818 DEVICE_FLG(0x0644, 0x8044,
1819 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY |
1820 QUIRK_FLAG_IFACE_DELAY),
1821 DEVICE_FLG(0x0644, 0x804a,
1822 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY |
1823 QUIRK_FLAG_IFACE_DELAY),
1824 DEVICE_FLG(0x06f8, 0xb000,
1825 QUIRK_FLAG_IGNORE_CTL_ERROR),
1826 DEVICE_FLG(0x06f8, 0xd002,
1827 QUIRK_FLAG_IGNORE_CTL_ERROR),
1828 DEVICE_FLG(0x0711, 0x5800,
1829 QUIRK_FLAG_GET_SAMPLE_RATE),
1830 DEVICE_FLG(0x074d, 0x3553,
1831 QUIRK_FLAG_GET_SAMPLE_RATE),
1832 DEVICE_FLG(0x0763, 0x2030,
1833 QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1834 DEVICE_FLG(0x0763, 0x2031,
1835 QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1836 DEVICE_FLG(0x08bb, 0x2702,
1837 QUIRK_FLAG_IGNORE_CTL_ERROR),
1838 DEVICE_FLG(0x0951, 0x16ad,
1839 QUIRK_FLAG_CTL_MSG_DELAY_1M),
1840 DEVICE_FLG(0x0b0e, 0x0349,
1841 QUIRK_FLAG_CTL_MSG_DELAY_1M),
1842 DEVICE_FLG(0x0fd9, 0x0008,
1843 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1844 DEVICE_FLG(0x1395, 0x740a,
1845 QUIRK_FLAG_GET_SAMPLE_RATE),
1846 DEVICE_FLG(0x1397, 0x0507,
1847 QUIRK_FLAG_PLAYBACK_FIRST | QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1848 DEVICE_FLG(0x1397, 0x0508,
1849 QUIRK_FLAG_PLAYBACK_FIRST | QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1850 DEVICE_FLG(0x1397, 0x0509,
1851 QUIRK_FLAG_PLAYBACK_FIRST | QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1852 DEVICE_FLG(0x13e5, 0x0001,
1853 QUIRK_FLAG_IGNORE_CTL_ERROR),
1854 DEVICE_FLG(0x154e, 0x1002,
1855 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY),
1856 DEVICE_FLG(0x154e, 0x1003,
1857 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY),
1858 DEVICE_FLG(0x154e, 0x3005,
1859 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY),
1860 DEVICE_FLG(0x154e, 0x3006,
1861 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY),
1862 DEVICE_FLG(0x154e, 0x500e,
1863 QUIRK_FLAG_IGNORE_CLOCK_SOURCE),
1864 DEVICE_FLG(0x1686, 0x00dd,
1865 QUIRK_FLAG_TX_LENGTH | QUIRK_FLAG_CTL_MSG_DELAY_1M),
1866 DEVICE_FLG(0x17aa, 0x1046,
1867 QUIRK_FLAG_DISABLE_AUTOSUSPEND),
1868 DEVICE_FLG(0x17aa, 0x104d,
1869 QUIRK_FLAG_DISABLE_AUTOSUSPEND),
1870 DEVICE_FLG(0x1852, 0x5065,
1871 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY),
1872 DEVICE_FLG(0x1901, 0x0191,
1873 QUIRK_FLAG_GET_SAMPLE_RATE),
1874 DEVICE_FLG(0x2040, 0x7200,
1875 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1876 DEVICE_FLG(0x2040, 0x7201,
1877 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1878 DEVICE_FLG(0x2040, 0x7210,
1879 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1880 DEVICE_FLG(0x2040, 0x7211,
1881 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1882 DEVICE_FLG(0x2040, 0x7213,
1883 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1884 DEVICE_FLG(0x2040, 0x7217,
1885 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1886 DEVICE_FLG(0x2040, 0x721b,
1887 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1888 DEVICE_FLG(0x2040, 0x721e,
1889 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1890 DEVICE_FLG(0x2040, 0x721f,
1891 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1892 DEVICE_FLG(0x2040, 0x7240,
1893 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1894 DEVICE_FLG(0x2040, 0x7260,
1895 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1896 DEVICE_FLG(0x2040, 0x7270,
1897 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1898 DEVICE_FLG(0x2040, 0x7280,
1899 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1900 DEVICE_FLG(0x2040, 0x7281,
1901 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1902 DEVICE_FLG(0x2040, 0x8200,
1903 QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER),
1904 DEVICE_FLG(0x21b4, 0x0081,
1905 QUIRK_FLAG_GET_SAMPLE_RATE),
1906 DEVICE_FLG(0x2522, 0x0007,
1907 QUIRK_FLAG_SET_IFACE_FIRST),
1908 DEVICE_FLG(0x2708, 0x0002,
1909 QUIRK_FLAG_IGNORE_CTL_ERROR),
1910 DEVICE_FLG(0x2912, 0x30c8,
1911 QUIRK_FLAG_GET_SAMPLE_RATE),
1912 DEVICE_FLG(0x30be, 0x0101,
1913 QUIRK_FLAG_IGNORE_CTL_ERROR),
1914 DEVICE_FLG(0x413c, 0xa506,
1915 QUIRK_FLAG_GET_SAMPLE_RATE),
1916 DEVICE_FLG(0x534d, 0x0021,
1917 QUIRK_FLAG_ALIGN_TRANSFER),
1918 DEVICE_FLG(0x534d, 0x2109,
1919 QUIRK_FLAG_ALIGN_TRANSFER),
1920 DEVICE_FLG(0x1224, 0x2a25,
1921 QUIRK_FLAG_GET_SAMPLE_RATE),
1922 DEVICE_FLG(0x2b53, 0x0023,
1923 QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1924 DEVICE_FLG(0x2b53, 0x0024,
1925 QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1926 DEVICE_FLG(0x2b53, 0x0031,
1927 QUIRK_FLAG_GENERIC_IMPLICIT_FB),
1928
1929
1930 VENDOR_FLG(0x045e,
1931 QUIRK_FLAG_GET_SAMPLE_RATE),
1932 VENDOR_FLG(0x046d,
1933 QUIRK_FLAG_CTL_MSG_DELAY_1M),
1934 VENDOR_FLG(0x047f,
1935 QUIRK_FLAG_GET_SAMPLE_RATE | QUIRK_FLAG_CTL_MSG_DELAY),
1936 VENDOR_FLG(0x0644,
1937 QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY),
1938 VENDOR_FLG(0x07fd,
1939 QUIRK_FLAG_VALIDATE_RATES),
1940 VENDOR_FLG(0x1235,
1941 QUIRK_FLAG_VALIDATE_RATES),
1942 VENDOR_FLG(0x152a,
1943 QUIRK_FLAG_DSD_RAW),
1944 VENDOR_FLG(0x1de7,
1945 QUIRK_FLAG_GET_SAMPLE_RATE),
1946 VENDOR_FLG(0x20b1,
1947 QUIRK_FLAG_DSD_RAW),
1948 VENDOR_FLG(0x22d9,
1949 QUIRK_FLAG_DSD_RAW),
1950 VENDOR_FLG(0x23ba,
1951 QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY |
1952 QUIRK_FLAG_DSD_RAW),
1953 VENDOR_FLG(0x25ce,
1954 QUIRK_FLAG_DSD_RAW),
1955 VENDOR_FLG(0x278b,
1956 QUIRK_FLAG_DSD_RAW),
1957 VENDOR_FLG(0x292b,
1958 QUIRK_FLAG_DSD_RAW),
1959 VENDOR_FLG(0x2972,
1960 QUIRK_FLAG_DSD_RAW),
1961 VENDOR_FLG(0x2ab6,
1962 QUIRK_FLAG_DSD_RAW),
1963 VENDOR_FLG(0x3353,
1964 QUIRK_FLAG_DSD_RAW),
1965 VENDOR_FLG(0x3842,
1966 QUIRK_FLAG_DSD_RAW),
1967 VENDOR_FLG(0xc502,
1968 QUIRK_FLAG_DSD_RAW),
1969
1970 {}
1971 };
1972
1973 void snd_usb_init_quirk_flags(struct snd_usb_audio *chip)
1974 {
1975 const struct usb_audio_quirk_flags_table *p;
1976
1977 for (p = quirk_flags_table; p->id; p++) {
1978 if (chip->usb_id == p->id ||
1979 (!USB_ID_PRODUCT(p->id) &&
1980 USB_ID_VENDOR(chip->usb_id) == USB_ID_VENDOR(p->id))) {
1981 usb_audio_dbg(chip,
1982 "Set quirk_flags 0x%x for device %04x:%04x\n",
1983 p->flags, USB_ID_VENDOR(chip->usb_id),
1984 USB_ID_PRODUCT(chip->usb_id));
1985 chip->quirk_flags |= p->flags;
1986 return;
1987 }
1988 }
1989 }