2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #include <linux/init.h>
18 #include <linux/slab.h>
19 #include <linux/usb.h>
20 #include <linux/usb/audio.h>
22 #include <sound/control.h>
23 #include <sound/core.h>
24 #include <sound/info.h>
25 #include <sound/pcm.h>
30 #include "mixer_quirks.h"
40 * handle the quirks for the contained interfaces
42 static int create_composite_quirk(struct snd_usb_audio *chip,
43 struct usb_interface *iface,
44 struct usb_driver *driver,
45 const struct snd_usb_audio_quirk *quirk)
47 int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber;
50 for (quirk = quirk->data; quirk->ifnum >= 0; ++quirk) {
51 iface = usb_ifnum_to_if(chip->dev, quirk->ifnum);
54 if (quirk->ifnum != probed_ifnum &&
55 usb_interface_claimed(iface))
57 err = snd_usb_create_quirk(chip, iface, driver, quirk);
60 if (quirk->ifnum != probed_ifnum)
61 usb_driver_claim_interface(driver, iface, (void *)-1L);
66 static int ignore_interface_quirk(struct snd_usb_audio *chip,
67 struct usb_interface *iface,
68 struct usb_driver *driver,
69 const struct snd_usb_audio_quirk *quirk)
76 * Allow alignment on audio sub-slot (channel samples) rather than
77 * on audio slots (audio frames)
79 static int create_align_transfer_quirk(struct snd_usb_audio *chip,
80 struct usb_interface *iface,
81 struct usb_driver *driver,
82 const struct snd_usb_audio_quirk *quirk)
85 return 1; /* Continue with creating streams and mixer */
88 static int create_any_midi_quirk(struct snd_usb_audio *chip,
89 struct usb_interface *intf,
90 struct usb_driver *driver,
91 const struct snd_usb_audio_quirk *quirk)
93 return snd_usbmidi_create(chip->card, intf, &chip->midi_list, quirk);
97 * create a stream for an interface with proper descriptors
99 static int create_standard_audio_quirk(struct snd_usb_audio *chip,
100 struct usb_interface *iface,
101 struct usb_driver *driver,
102 const struct snd_usb_audio_quirk *quirk)
104 struct usb_host_interface *alts;
105 struct usb_interface_descriptor *altsd;
108 alts = &iface->altsetting[0];
109 altsd = get_iface_desc(alts);
110 err = snd_usb_parse_audio_interface(chip, altsd->bInterfaceNumber);
112 snd_printk(KERN_ERR "cannot setup if %d: error %d\n",
113 altsd->bInterfaceNumber, err);
116 /* reset the current interface */
117 usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0);
122 * create a stream for an endpoint/altsetting without proper descriptors
124 static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
125 struct usb_interface *iface,
126 struct usb_driver *driver,
127 const struct snd_usb_audio_quirk *quirk)
129 struct audioformat *fp;
130 struct usb_host_interface *alts;
132 unsigned *rate_table = NULL;
134 fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL);
136 snd_printk(KERN_ERR "cannot memdup\n");
139 if (fp->nr_rates > MAX_NR_RATES) {
143 if (fp->nr_rates > 0) {
144 rate_table = kmemdup(fp->rate_table,
145 sizeof(int) * fp->nr_rates, GFP_KERNEL);
150 fp->rate_table = rate_table;
153 stream = (fp->endpoint & USB_DIR_IN)
154 ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
155 err = snd_usb_add_audio_stream(chip, stream, fp);
158 if (fp->iface != get_iface_desc(&iface->altsetting[0])->bInterfaceNumber ||
159 fp->altset_idx >= iface->num_altsetting) {
163 alts = &iface->altsetting[fp->altset_idx];
164 if (get_iface_desc(alts)->bNumEndpoints < 1) {
169 fp->datainterval = snd_usb_parse_datainterval(chip, alts);
170 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
171 usb_set_interface(chip->dev, fp->iface, 0);
172 snd_usb_init_pitch(chip, fp->iface, alts, fp);
173 snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max);
183 * Create a stream for an Edirol UA-700/UA-25/UA-4FX interface.
184 * The only way to detect the sample rate is by looking at wMaxPacketSize.
186 static int create_uaxx_quirk(struct snd_usb_audio *chip,
187 struct usb_interface *iface,
188 struct usb_driver *driver,
189 const struct snd_usb_audio_quirk *quirk)
191 static const struct audioformat ua_format = {
192 .formats = SNDRV_PCM_FMTBIT_S24_3LE,
194 .fmt_type = UAC_FORMAT_TYPE_I,
197 .rates = SNDRV_PCM_RATE_CONTINUOUS,
199 struct usb_host_interface *alts;
200 struct usb_interface_descriptor *altsd;
201 struct audioformat *fp;
204 /* both PCM and MIDI interfaces have 2 or more altsettings */
205 if (iface->num_altsetting < 2)
207 alts = &iface->altsetting[1];
208 altsd = get_iface_desc(alts);
210 if (altsd->bNumEndpoints == 2) {
211 static const struct snd_usb_midi_endpoint_info ua700_ep = {
212 .out_cables = 0x0003,
215 static const struct snd_usb_audio_quirk ua700_quirk = {
216 .type = QUIRK_MIDI_FIXED_ENDPOINT,
219 static const struct snd_usb_midi_endpoint_info uaxx_ep = {
220 .out_cables = 0x0001,
223 static const struct snd_usb_audio_quirk uaxx_quirk = {
224 .type = QUIRK_MIDI_FIXED_ENDPOINT,
227 const struct snd_usb_audio_quirk *quirk =
228 chip->usb_id == USB_ID(0x0582, 0x002b)
229 ? &ua700_quirk : &uaxx_quirk;
230 return snd_usbmidi_create(chip->card, iface,
231 &chip->midi_list, quirk);
234 if (altsd->bNumEndpoints != 1)
237 fp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL);
241 fp->iface = altsd->bInterfaceNumber;
242 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
243 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
244 fp->datainterval = 0;
245 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
247 switch (fp->maxpacksize) {
249 fp->rate_max = fp->rate_min = 44100;
253 fp->rate_max = fp->rate_min = 48000;
257 fp->rate_max = fp->rate_min = 96000;
260 snd_printk(KERN_ERR "unknown sample rate\n");
265 stream = (fp->endpoint & USB_DIR_IN)
266 ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
267 err = snd_usb_add_audio_stream(chip, stream, fp);
272 usb_set_interface(chip->dev, fp->iface, 0);
277 * Create a standard mixer for the specified interface.
279 static int create_standard_mixer_quirk(struct snd_usb_audio *chip,
280 struct usb_interface *iface,
281 struct usb_driver *driver,
282 const struct snd_usb_audio_quirk *quirk)
284 if (quirk->ifnum < 0)
287 return snd_usb_create_mixer(chip, quirk->ifnum, 0);
291 * audio-interface quirks
293 * returns zero if no standard audio/MIDI parsing is needed.
294 * returns a positive value if standard audio/midi interfaces are parsed
296 * returns a negative value at error.
298 int snd_usb_create_quirk(struct snd_usb_audio *chip,
299 struct usb_interface *iface,
300 struct usb_driver *driver,
301 const struct snd_usb_audio_quirk *quirk)
303 typedef int (*quirk_func_t)(struct snd_usb_audio *,
304 struct usb_interface *,
306 const struct snd_usb_audio_quirk *);
307 static const quirk_func_t quirk_funcs[] = {
308 [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk,
309 [QUIRK_COMPOSITE] = create_composite_quirk,
310 [QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk,
311 [QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk,
312 [QUIRK_MIDI_YAMAHA] = create_any_midi_quirk,
313 [QUIRK_MIDI_MIDIMAN] = create_any_midi_quirk,
314 [QUIRK_MIDI_NOVATION] = create_any_midi_quirk,
315 [QUIRK_MIDI_RAW_BYTES] = create_any_midi_quirk,
316 [QUIRK_MIDI_EMAGIC] = create_any_midi_quirk,
317 [QUIRK_MIDI_CME] = create_any_midi_quirk,
318 [QUIRK_MIDI_AKAI] = create_any_midi_quirk,
319 [QUIRK_MIDI_FTDI] = create_any_midi_quirk,
320 [QUIRK_MIDI_CH345] = create_any_midi_quirk,
321 [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk,
322 [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
323 [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk,
324 [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk,
325 [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk,
328 if (quirk->type < QUIRK_TYPE_COUNT) {
329 return quirk_funcs[quirk->type](chip, iface, driver, quirk);
331 snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
340 #define EXTIGY_FIRMWARE_SIZE_OLD 794
341 #define EXTIGY_FIRMWARE_SIZE_NEW 483
343 static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf)
345 struct usb_host_config *config = dev->actconfig;
348 if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD ||
349 le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) {
350 snd_printdd("sending Extigy boot sequence...\n");
351 /* Send message to force it to reconnect with full interface. */
352 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0),
353 0x10, 0x43, 0x0001, 0x000a, NULL, 0);
354 if (err < 0) snd_printdd("error sending boot message: %d\n", err);
355 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
356 &dev->descriptor, sizeof(dev->descriptor));
357 config = dev->actconfig;
358 if (err < 0) snd_printdd("error usb_get_descriptor: %d\n", err);
359 err = usb_reset_configuration(dev);
360 if (err < 0) snd_printdd("error usb_reset_configuration: %d\n", err);
361 snd_printdd("extigy_boot: new boot length = %d\n",
362 le16_to_cpu(get_cfg_desc(config)->wTotalLength));
363 return -ENODEV; /* quit this anyway */
368 static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev)
372 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a,
373 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
376 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0x29,
377 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
384 static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
388 if (dev->actconfig->desc.bConfigurationValue == 1) {
389 snd_printk(KERN_INFO "usb-audio: "
390 "Fast Track Pro switching to config #2\n");
391 /* This function has to be available by the usb core module.
392 * if it is not avialable the boot quirk has to be left out
393 * and the configuration has to be set by udev or hotplug
396 err = usb_driver_set_configuration(dev, 2);
398 snd_printdd("error usb_driver_set_configuration: %d\n",
400 /* Always return an error, so that we stop creating a device
401 that will just be destroyed and recreated with a new
405 snd_printk(KERN_INFO "usb-audio: Fast Track Pro config OK\n");
411 * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely
412 * documented in the device's data sheet.
414 static int snd_usb_cm106_write_int_reg(struct usb_device *dev, int reg, u16 value)
418 buf[1] = value & 0xff;
419 buf[2] = (value >> 8) & 0xff;
421 return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION,
422 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT,
426 static int snd_usb_cm106_boot_quirk(struct usb_device *dev)
429 * Enable line-out driver mode, set headphone source to front
430 * channels, enable stereo mic.
432 return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
436 * C-Media CM6206 is based on CM106 with two additional
437 * registers that are not documented in the data sheet.
438 * Values here are chosen based on sniffing USB traffic
441 static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)
444 int val[] = {0x2004, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000};
446 for (reg = 0; reg < ARRAY_SIZE(val); reg++) {
447 err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]);
456 * This call will put the synth in "USB send" mode, i.e it will send MIDI
457 * messages through USB (this is disabled at startup). The synth will
458 * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB
459 * sign on its LCD. Values here are chosen based on sniffing USB traffic
462 static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev)
464 int err, actual_length;
466 /* "midi send" enable */
467 static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 };
469 void *buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL);
472 err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf,
473 ARRAY_SIZE(seq), &actual_length, 1000);
482 * Some sound cards from Native Instruments are in fact compliant to the USB
483 * audio standard of version 2 and other approved USB standards, even though
484 * they come up as vendor-specific device when first connected.
486 * However, they can be told to come up with a new set of descriptors
487 * upon their next enumeration, and the interfaces announced by the new
488 * descriptors will then be handled by the kernel's class drivers. As the
489 * product ID will also change, no further checks are required.
492 static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev)
494 int ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
495 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE,
496 1, 0, NULL, 0, 1000);
501 usb_reset_device(dev);
503 /* return -EAGAIN, so the creation of an audio interface for this
504 * temporary device is aborted. The device will reconnect with a
512 #define MAUDIO_SET 0x01 /* parse device_setup */
513 #define MAUDIO_SET_COMPATIBLE 0x80 /* use only "win-compatible" interfaces */
514 #define MAUDIO_SET_DTS 0x02 /* enable DTS Digital Output */
515 #define MAUDIO_SET_96K 0x04 /* 48-96KHz rate if set, 8-48KHz otherwise */
516 #define MAUDIO_SET_24B 0x08 /* 24bits sample if set, 16bits otherwise */
517 #define MAUDIO_SET_DI 0x10 /* enable Digital Input */
518 #define MAUDIO_SET_MASK 0x1f /* bit mask for setup value */
519 #define MAUDIO_SET_24B_48K_DI 0x19 /* 24bits+48KHz+Digital Input */
520 #define MAUDIO_SET_24B_48K_NOTDI 0x09 /* 24bits+48KHz+No Digital Input */
521 #define MAUDIO_SET_16B_48K_DI 0x11 /* 16bits+48KHz+Digital Input */
522 #define MAUDIO_SET_16B_48K_NOTDI 0x01 /* 16bits+48KHz+No Digital Input */
524 static int quattro_skip_setting_quirk(struct snd_usb_audio *chip,
525 int iface, int altno)
527 /* Reset ALL ifaces to 0 altsetting.
528 * Call it for every possible altsetting of every interface.
530 usb_set_interface(chip->dev, iface, 0);
531 if (chip->setup & MAUDIO_SET) {
532 if (chip->setup & MAUDIO_SET_COMPATIBLE) {
533 if (iface != 1 && iface != 2)
534 return 1; /* skip all interfaces but 1 and 2 */
537 if (iface == 1 || iface == 2)
538 return 1; /* skip interfaces 1 and 2 */
539 if ((chip->setup & MAUDIO_SET_96K) && altno != 1)
540 return 1; /* skip this altsetting */
541 mask = chip->setup & MAUDIO_SET_MASK;
542 if (mask == MAUDIO_SET_24B_48K_DI && altno != 2)
543 return 1; /* skip this altsetting */
544 if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3)
545 return 1; /* skip this altsetting */
546 if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 4)
547 return 1; /* skip this altsetting */
550 snd_printdd(KERN_INFO
551 "using altsetting %d for interface %d config %d\n",
552 altno, iface, chip->setup);
553 return 0; /* keep this altsetting */
556 static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
560 /* Reset ALL ifaces to 0 altsetting.
561 * Call it for every possible altsetting of every interface.
563 usb_set_interface(chip->dev, iface, 0);
565 if (chip->setup & MAUDIO_SET) {
567 if ((chip->setup & MAUDIO_SET_DTS) && altno != 6)
568 return 1; /* skip this altsetting */
569 if ((chip->setup & MAUDIO_SET_96K) && altno != 1)
570 return 1; /* skip this altsetting */
571 mask = chip->setup & MAUDIO_SET_MASK;
572 if (mask == MAUDIO_SET_24B_48K_DI && altno != 2)
573 return 1; /* skip this altsetting */
574 if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3)
575 return 1; /* skip this altsetting */
576 if (mask == MAUDIO_SET_16B_48K_DI && altno != 4)
577 return 1; /* skip this altsetting */
578 if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 5)
579 return 1; /* skip this altsetting */
582 return 0; /* keep this altsetting */
586 static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip,
587 int iface, int altno)
589 /* Reset ALL ifaces to 0 altsetting.
590 * Call it for every possible altsetting of every interface.
592 usb_set_interface(chip->dev, iface, 0);
594 /* possible configuration where both inputs and only one output is
595 *used is not supported by the current setup
597 if (chip->setup & (MAUDIO_SET | MAUDIO_SET_24B)) {
598 if (chip->setup & MAUDIO_SET_96K) {
599 if (altno != 3 && altno != 6)
601 } else if (chip->setup & MAUDIO_SET_DI) {
603 return 1; /* no analog input */
604 if (altno != 2 && altno != 5)
605 return 1; /* enable only altsets 2 and 5 */
608 return 1; /* disable digialt input */
609 if (altno != 2 && altno != 5)
610 return 1; /* enalbe only altsets 2 and 5 */
613 /* keep only 16-Bit mode */
618 snd_printdd(KERN_INFO
619 "using altsetting %d for interface %d config %d\n",
620 altno, iface, chip->setup);
621 return 0; /* keep this altsetting */
624 int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip,
628 /* audiophile usb: skip altsets incompatible with device_setup */
629 if (chip->usb_id == USB_ID(0x0763, 0x2003))
630 return audiophile_skip_setting_quirk(chip, iface, altno);
631 /* quattro usb: skip altsets incompatible with device_setup */
632 if (chip->usb_id == USB_ID(0x0763, 0x2001))
633 return quattro_skip_setting_quirk(chip, iface, altno);
634 /* fasttrackpro usb: skip altsets incompatible with device_setup */
635 if (chip->usb_id == USB_ID(0x0763, 0x2012))
636 return fasttrackpro_skip_setting_quirk(chip, iface, altno);
641 int snd_usb_apply_boot_quirk(struct usb_device *dev,
642 struct usb_interface *intf,
643 const struct snd_usb_audio_quirk *quirk)
645 u32 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
646 le16_to_cpu(dev->descriptor.idProduct));
649 case USB_ID(0x041e, 0x3000):
650 /* SB Extigy needs special boot-up sequence */
651 /* if more models come, this will go to the quirk list. */
652 return snd_usb_extigy_boot_quirk(dev, intf);
654 case USB_ID(0x041e, 0x3020):
655 /* SB Audigy 2 NX needs its own boot-up magic, too */
656 return snd_usb_audigy2nx_boot_quirk(dev);
658 case USB_ID(0x10f5, 0x0200):
659 /* C-Media CM106 / Turtle Beach Audio Advantage Roadie */
660 return snd_usb_cm106_boot_quirk(dev);
662 case USB_ID(0x0d8c, 0x0102):
663 /* C-Media CM6206 / CM106-Like Sound Device */
664 case USB_ID(0x0ccd, 0x00b1): /* Terratec Aureon 7.1 USB */
665 return snd_usb_cm6206_boot_quirk(dev);
667 case USB_ID(0x133e, 0x0815):
668 /* Access Music VirusTI Desktop */
669 return snd_usb_accessmusic_boot_quirk(dev);
671 case USB_ID(0x17cc, 0x1000): /* Komplete Audio 6 */
672 case USB_ID(0x17cc, 0x1010): /* Traktor Audio 6 */
673 case USB_ID(0x17cc, 0x1020): /* Traktor Audio 10 */
674 return snd_usb_nativeinstruments_boot_quirk(dev);
675 case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */
676 return snd_usb_fasttrackpro_boot_quirk(dev);
683 * check if the device uses big-endian samples
685 int snd_usb_is_big_endian_format(struct snd_usb_audio *chip, struct audioformat *fp)
687 /* it depends on altsetting wether the device is big-endian or not */
688 switch (chip->usb_id) {
689 case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */
690 if (fp->altsetting == 2 || fp->altsetting == 3 ||
691 fp->altsetting == 5 || fp->altsetting == 6)
694 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
695 if (chip->setup == 0x00 ||
696 fp->altsetting == 1 || fp->altsetting == 2 ||
700 case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro */
701 if (fp->altsetting == 2 || fp->altsetting == 3 ||
702 fp->altsetting == 5 || fp->altsetting == 6)
710 * For E-Mu 0404USB/0202USB/TrackerPre/0204 sample rate should be set for device,
715 EMU_QUIRK_SR_44100HZ = 0,
716 EMU_QUIRK_SR_48000HZ,
717 EMU_QUIRK_SR_88200HZ,
718 EMU_QUIRK_SR_96000HZ,
719 EMU_QUIRK_SR_176400HZ,
720 EMU_QUIRK_SR_192000HZ
723 static void set_format_emu_quirk(struct snd_usb_substream *subs,
724 struct audioformat *fmt)
726 unsigned char emu_samplerate_id = 0;
728 /* When capture is active
729 * sample rate shouldn't be changed
730 * by playback substream
732 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) {
733 if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].interface != -1)
737 switch (fmt->rate_min) {
739 emu_samplerate_id = EMU_QUIRK_SR_48000HZ;
742 emu_samplerate_id = EMU_QUIRK_SR_88200HZ;
745 emu_samplerate_id = EMU_QUIRK_SR_96000HZ;
748 emu_samplerate_id = EMU_QUIRK_SR_176400HZ;
751 emu_samplerate_id = EMU_QUIRK_SR_192000HZ;
754 emu_samplerate_id = EMU_QUIRK_SR_44100HZ;
757 snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id);
758 subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0;
761 void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
762 struct audioformat *fmt)
764 switch (subs->stream->chip->usb_id) {
765 case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */
766 case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */
767 case USB_ID(0x041e, 0x3f0a): /* E-Mu Tracker Pre */
768 case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */
769 set_format_emu_quirk(subs, fmt);