Blame view
sound/usb/quirks.c
22.2 KB
e5779998b ALSA: usb-audio: ... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/init.h> |
36db04565 ALSA: usb - use o... |
18 |
#include <linux/slab.h> |
e5779998b ALSA: usb-audio: ... |
19 20 |
#include <linux/usb.h> #include <linux/usb/audio.h> |
9e38658f7 ALSA: usb-audio: ... |
21 |
#include <sound/control.h> |
e5779998b ALSA: usb-audio: ... |
22 23 24 25 26 27 |
#include <sound/core.h> #include <sound/info.h> #include <sound/pcm.h> #include "usbaudio.h" #include "card.h" |
f0b5e634f ALSA: usbmixer: r... |
28 |
#include "mixer.h" |
7b1eda223 ALSA: usb-mixer: ... |
29 |
#include "mixer_quirks.h" |
e5779998b ALSA: usb-audio: ... |
30 31 32 33 34 |
#include "midi.h" #include "quirks.h" #include "helper.h" #include "endpoint.h" #include "pcm.h" |
3d8d4dcfd ALSA: usb-audio: ... |
35 |
#include "clock.h" |
e8e8babf5 ALSA: snd-usb: re... |
36 |
#include "stream.h" |
e5779998b ALSA: usb-audio: ... |
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
/* * handle the quirks for the contained interfaces */ static int create_composite_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber; int err; for (quirk = quirk->data; quirk->ifnum >= 0; ++quirk) { iface = usb_ifnum_to_if(chip->dev, quirk->ifnum); if (!iface) continue; if (quirk->ifnum != probed_ifnum && usb_interface_claimed(iface)) continue; err = snd_usb_create_quirk(chip, iface, driver, quirk); if (err < 0) return err; if (quirk->ifnum != probed_ifnum) usb_driver_claim_interface(driver, iface, (void *)-1L); } return 0; } static int ignore_interface_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { return 0; } /* * Allow alignment on audio sub-slot (channel samples) rather than * on audio slots (audio frames) */ static int create_align_transfer_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { chip->txfr_quirk = 1; return 1; /* Continue with creating streams and mixer */ } static int create_any_midi_quirk(struct snd_usb_audio *chip, struct usb_interface *intf, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { return snd_usbmidi_create(chip->card, intf, &chip->midi_list, quirk); } /* * create a stream for an interface with proper descriptors */ static int create_standard_audio_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { struct usb_host_interface *alts; struct usb_interface_descriptor *altsd; int err; alts = &iface->altsetting[0]; altsd = get_iface_desc(alts); |
e8e8babf5 ALSA: snd-usb: re... |
109 |
err = snd_usb_parse_audio_interface(chip, altsd->bInterfaceNumber); |
e5779998b ALSA: usb-audio: ... |
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
if (err < 0) { snd_printk(KERN_ERR "cannot setup if %d: error %d ", altsd->bInterfaceNumber, err); return err; } /* reset the current interface */ usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0); return 0; } /* * create a stream for an endpoint/altsetting without proper descriptors */ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { struct audioformat *fp; struct usb_host_interface *alts; int stream, err; unsigned *rate_table = NULL; fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL); if (! fp) { snd_printk(KERN_ERR "cannot memdup "); return -ENOMEM; } if (fp->nr_rates > 0) { |
43df2a57b ALSA: usb-audio: ... |
141 142 |
rate_table = kmemdup(fp->rate_table, sizeof(int) * fp->nr_rates, GFP_KERNEL); |
e5779998b ALSA: usb-audio: ... |
143 144 145 146 |
if (!rate_table) { kfree(fp); return -ENOMEM; } |
e5779998b ALSA: usb-audio: ... |
147 148 149 150 151 |
fp->rate_table = rate_table; } stream = (fp->endpoint & USB_DIR_IN) ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; |
e8e8babf5 ALSA: snd-usb: re... |
152 |
err = snd_usb_add_audio_stream(chip, stream, fp); |
e5779998b ALSA: usb-audio: ... |
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
if (err < 0) { kfree(fp); kfree(rate_table); return err; } if (fp->iface != get_iface_desc(&iface->altsetting[0])->bInterfaceNumber || fp->altset_idx >= iface->num_altsetting) { kfree(fp); kfree(rate_table); return -EINVAL; } alts = &iface->altsetting[fp->altset_idx]; fp->datainterval = snd_usb_parse_datainterval(chip, alts); fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); usb_set_interface(chip->dev, fp->iface, 0); |
767d75ad1 ALSA: usb-audio: ... |
168 169 |
snd_usb_init_pitch(chip, fp->iface, alts, fp); snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max); |
e5779998b ALSA: usb-audio: ... |
170 171 172 173 174 175 176 177 178 179 180 181 182 |
return 0; } /* * Create a stream for an Edirol UA-700/UA-25/UA-4FX interface. * The only way to detect the sample rate is by looking at wMaxPacketSize. */ static int create_uaxx_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { static const struct audioformat ua_format = { |
015eb0b08 ALSA: usb-audio: ... |
183 |
.formats = SNDRV_PCM_FMTBIT_S24_3LE, |
e5779998b ALSA: usb-audio: ... |
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
.channels = 2, .fmt_type = UAC_FORMAT_TYPE_I, .altsetting = 1, .altset_idx = 1, .rates = SNDRV_PCM_RATE_CONTINUOUS, }; struct usb_host_interface *alts; struct usb_interface_descriptor *altsd; struct audioformat *fp; int stream, err; /* both PCM and MIDI interfaces have 2 or more altsettings */ if (iface->num_altsetting < 2) return -ENXIO; alts = &iface->altsetting[1]; altsd = get_iface_desc(alts); if (altsd->bNumEndpoints == 2) { static const struct snd_usb_midi_endpoint_info ua700_ep = { .out_cables = 0x0003, .in_cables = 0x0003 }; static const struct snd_usb_audio_quirk ua700_quirk = { .type = QUIRK_MIDI_FIXED_ENDPOINT, .data = &ua700_ep }; static const struct snd_usb_midi_endpoint_info uaxx_ep = { .out_cables = 0x0001, .in_cables = 0x0001 }; static const struct snd_usb_audio_quirk uaxx_quirk = { .type = QUIRK_MIDI_FIXED_ENDPOINT, .data = &uaxx_ep }; const struct snd_usb_audio_quirk *quirk = chip->usb_id == USB_ID(0x0582, 0x002b) ? &ua700_quirk : &uaxx_quirk; return snd_usbmidi_create(chip->card, iface, &chip->midi_list, quirk); } if (altsd->bNumEndpoints != 1) return -ENXIO; |
43df2a57b ALSA: usb-audio: ... |
227 |
fp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL); |
e5779998b ALSA: usb-audio: ... |
228 229 |
if (!fp) return -ENOMEM; |
e5779998b ALSA: usb-audio: ... |
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
fp->iface = altsd->bInterfaceNumber; fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; fp->datainterval = 0; fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); switch (fp->maxpacksize) { case 0x120: fp->rate_max = fp->rate_min = 44100; break; case 0x138: case 0x140: fp->rate_max = fp->rate_min = 48000; break; case 0x258: case 0x260: fp->rate_max = fp->rate_min = 96000; break; default: snd_printk(KERN_ERR "unknown sample rate "); kfree(fp); return -ENXIO; } stream = (fp->endpoint & USB_DIR_IN) ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; |
e8e8babf5 ALSA: snd-usb: re... |
258 |
err = snd_usb_add_audio_stream(chip, stream, fp); |
e5779998b ALSA: usb-audio: ... |
259 260 261 262 263 264 265 266 267 |
if (err < 0) { kfree(fp); return err; } usb_set_interface(chip->dev, fp->iface, 0); return 0; } /* |
014950b01 ALSA: usb-audio: ... |
268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
* Create a standard mixer for the specified interface. */ static int create_standard_mixer_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { if (quirk->ifnum < 0) return 0; return snd_usb_create_mixer(chip, quirk->ifnum, 0); } /* |
e5779998b ALSA: usb-audio: ... |
282 283 284 |
* audio-interface quirks * * returns zero if no standard audio/MIDI parsing is needed. |
25985edce Fix common misspe... |
285 |
* returns a positive value if standard audio/midi interfaces are parsed |
e5779998b ALSA: usb-audio: ... |
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
* after this. * returns a negative value at error. */ int snd_usb_create_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver, const struct snd_usb_audio_quirk *quirk) { typedef int (*quirk_func_t)(struct snd_usb_audio *, struct usb_interface *, struct usb_driver *, const struct snd_usb_audio_quirk *); static const quirk_func_t quirk_funcs[] = { [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk, [QUIRK_COMPOSITE] = create_composite_quirk, [QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk, [QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk, [QUIRK_MIDI_YAMAHA] = create_any_midi_quirk, [QUIRK_MIDI_MIDIMAN] = create_any_midi_quirk, [QUIRK_MIDI_NOVATION] = create_any_midi_quirk, |
c7f572168 ALSA: usb-audio: ... |
306 |
[QUIRK_MIDI_RAW_BYTES] = create_any_midi_quirk, |
e5779998b ALSA: usb-audio: ... |
307 308 |
[QUIRK_MIDI_EMAGIC] = create_any_midi_quirk, [QUIRK_MIDI_CME] = create_any_midi_quirk, |
4434ade8c ALSA: usb-audio: ... |
309 |
[QUIRK_MIDI_AKAI] = create_any_midi_quirk, |
1ef0e0a05 ALSA: usb-audio: ... |
310 |
[QUIRK_MIDI_FTDI] = create_any_midi_quirk, |
e5779998b ALSA: usb-audio: ... |
311 312 313 |
[QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk, |
014950b01 ALSA: usb-audio: ... |
314 315 |
[QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk, [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk, |
e5779998b ALSA: usb-audio: ... |
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
}; if (quirk->type < QUIRK_TYPE_COUNT) { return quirk_funcs[quirk->type](chip, iface, driver, quirk); } else { snd_printd(KERN_ERR "invalid quirk type %d ", quirk->type); return -ENXIO; } } /* * boot quirks */ #define EXTIGY_FIRMWARE_SIZE_OLD 794 #define EXTIGY_FIRMWARE_SIZE_NEW 483 static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf) { struct usb_host_config *config = dev->actconfig; int err; if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD || le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) { snd_printdd("sending Extigy boot sequence... "); /* Send message to force it to reconnect with full interface. */ err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0), |
17d900c4a ALSA: usb-audio: ... |
345 |
0x10, 0x43, 0x0001, 0x000a, NULL, 0); |
e5779998b ALSA: usb-audio: ... |
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
if (err < 0) snd_printdd("error sending boot message: %d ", err); err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, sizeof(dev->descriptor)); config = dev->actconfig; if (err < 0) snd_printdd("error usb_get_descriptor: %d ", err); err = usb_reset_configuration(dev); if (err < 0) snd_printdd("error usb_reset_configuration: %d ", err); snd_printdd("extigy_boot: new boot length = %d ", le16_to_cpu(get_cfg_desc(config)->wTotalLength)); return -ENODEV; /* quit this anyway */ } return 0; } static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev) { u8 buf = 1; snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
17d900c4a ALSA: usb-audio: ... |
370 |
0, 0, &buf, 1); |
e5779998b ALSA: usb-audio: ... |
371 372 373 |
if (buf == 0) { snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0x29, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
17d900c4a ALSA: usb-audio: ... |
374 |
1, 2000, NULL, 0); |
e5779998b ALSA: usb-audio: ... |
375 376 377 378 |
return -ENODEV; } return 0; } |
0f5733b0c ALSA: usb-audio -... |
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev) { int err; if (dev->actconfig->desc.bConfigurationValue == 1) { snd_printk(KERN_INFO "usb-audio: " "Fast Track Pro switching to config #2 "); /* This function has to be available by the usb core module. * if it is not avialable the boot quirk has to be left out * and the configuration has to be set by udev or hotplug * rules */ err = usb_driver_set_configuration(dev, 2); if (err < 0) { snd_printdd("error usb_driver_set_configuration: %d ", err); return -ENODEV; } } else snd_printk(KERN_INFO "usb-audio: Fast Track Pro config OK "); return 0; } |
e5779998b ALSA: usb-audio: ... |
405 406 407 408 409 410 411 412 413 414 415 416 417 |
/* * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely * documented in the device's data sheet. */ static int snd_usb_cm106_write_int_reg(struct usb_device *dev, int reg, u16 value) { u8 buf[4]; buf[0] = 0x20; buf[1] = value & 0xff; buf[2] = (value >> 8) & 0xff; buf[3] = reg; return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT, |
17d900c4a ALSA: usb-audio: ... |
418 |
0, 0, &buf, 4); |
e5779998b ALSA: usb-audio: ... |
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
} static int snd_usb_cm106_boot_quirk(struct usb_device *dev) { /* * Enable line-out driver mode, set headphone source to front * channels, enable stereo mic. */ return snd_usb_cm106_write_int_reg(dev, 2, 0x8004); } /* * C-Media CM6206 is based on CM106 with two additional * registers that are not documented in the data sheet. * Values here are chosen based on sniffing USB traffic * under Windows. */ static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) { |
dac8f847c ALSA: snd-usb: Fi... |
438 |
int err = 0, reg; |
157186bc1 ALSA: usb - turn ... |
439 |
int val[] = {0x2004, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000}; |
e5779998b ALSA: usb-audio: ... |
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
for (reg = 0; reg < ARRAY_SIZE(val); reg++) { err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]); if (err < 0) return err; } return err; } /* * This call will put the synth in "USB send" mode, i.e it will send MIDI * messages through USB (this is disabled at startup). The synth will * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB * sign on its LCD. Values here are chosen based on sniffing USB traffic * under Windows. */ static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) { int err, actual_length; /* "midi send" enable */ static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; void *buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); if (!buf) return -ENOMEM; err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf, ARRAY_SIZE(seq), &actual_length, 1000); kfree(buf); if (err < 0) return err; return 0; } /* |
54a8c500d ALSA: usb-audio: ... |
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
* Some sound cards from Native Instruments are in fact compliant to the USB * audio standard of version 2 and other approved USB standards, even though * they come up as vendor-specific device when first connected. * * However, they can be told to come up with a new set of descriptors * upon their next enumeration, and the interfaces announced by the new * descriptors will then be handled by the kernel's class drivers. As the * product ID will also change, no further checks are required. */ static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) { int ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, cpu_to_le16(1), 0, NULL, 0, 1000); if (ret < 0) return ret; usb_reset_device(dev); /* return -EAGAIN, so the creation of an audio interface for this * temporary device is aborted. The device will reconnect with a * new product ID */ return -EAGAIN; } /* |
e5779998b ALSA: usb-audio: ... |
505 506 |
* Setup quirks */ |
0f5733b0c ALSA: usb-audio -... |
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
#define MAUDIO_SET 0x01 /* parse device_setup */ #define MAUDIO_SET_COMPATIBLE 0x80 /* use only "win-compatible" interfaces */ #define MAUDIO_SET_DTS 0x02 /* enable DTS Digital Output */ #define MAUDIO_SET_96K 0x04 /* 48-96KHz rate if set, 8-48KHz otherwise */ #define MAUDIO_SET_24B 0x08 /* 24bits sample if set, 16bits otherwise */ #define MAUDIO_SET_DI 0x10 /* enable Digital Input */ #define MAUDIO_SET_MASK 0x1f /* bit mask for setup value */ #define MAUDIO_SET_24B_48K_DI 0x19 /* 24bits+48KHz+Digital Input */ #define MAUDIO_SET_24B_48K_NOTDI 0x09 /* 24bits+48KHz+No Digital Input */ #define MAUDIO_SET_16B_48K_DI 0x11 /* 16bits+48KHz+Digital Input */ #define MAUDIO_SET_16B_48K_NOTDI 0x01 /* 16bits+48KHz+No Digital Input */ static int quattro_skip_setting_quirk(struct snd_usb_audio *chip, int iface, int altno) { /* Reset ALL ifaces to 0 altsetting. * Call it for every possible altsetting of every interface. */ usb_set_interface(chip->dev, iface, 0); if (chip->setup & MAUDIO_SET) { if (chip->setup & MAUDIO_SET_COMPATIBLE) { if (iface != 1 && iface != 2) return 1; /* skip all interfaces but 1 and 2 */ } else { unsigned int mask; if (iface == 1 || iface == 2) return 1; /* skip interfaces 1 and 2 */ if ((chip->setup & MAUDIO_SET_96K) && altno != 1) return 1; /* skip this altsetting */ mask = chip->setup & MAUDIO_SET_MASK; if (mask == MAUDIO_SET_24B_48K_DI && altno != 2) return 1; /* skip this altsetting */ if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3) return 1; /* skip this altsetting */ if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 4) return 1; /* skip this altsetting */ } } snd_printdd(KERN_INFO "using altsetting %d for interface %d config %d ", altno, iface, chip->setup); return 0; /* keep this altsetting */ } |
e5779998b ALSA: usb-audio: ... |
551 552 553 554 555 556 557 558 559 |
static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, int iface, int altno) { /* Reset ALL ifaces to 0 altsetting. * Call it for every possible altsetting of every interface. */ usb_set_interface(chip->dev, iface, 0); |
0f5733b0c ALSA: usb-audio -... |
560 561 562 |
if (chip->setup & MAUDIO_SET) { unsigned int mask; if ((chip->setup & MAUDIO_SET_DTS) && altno != 6) |
e5779998b ALSA: usb-audio: ... |
563 |
return 1; /* skip this altsetting */ |
0f5733b0c ALSA: usb-audio -... |
564 |
if ((chip->setup & MAUDIO_SET_96K) && altno != 1) |
e5779998b ALSA: usb-audio: ... |
565 |
return 1; /* skip this altsetting */ |
0f5733b0c ALSA: usb-audio -... |
566 567 |
mask = chip->setup & MAUDIO_SET_MASK; if (mask == MAUDIO_SET_24B_48K_DI && altno != 2) |
e5779998b ALSA: usb-audio: ... |
568 |
return 1; /* skip this altsetting */ |
0f5733b0c ALSA: usb-audio -... |
569 |
if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3) |
e5779998b ALSA: usb-audio: ... |
570 |
return 1; /* skip this altsetting */ |
0f5733b0c ALSA: usb-audio -... |
571 |
if (mask == MAUDIO_SET_16B_48K_DI && altno != 4) |
e5779998b ALSA: usb-audio: ... |
572 |
return 1; /* skip this altsetting */ |
0f5733b0c ALSA: usb-audio -... |
573 |
if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 5) |
e5779998b ALSA: usb-audio: ... |
574 575 576 577 578 |
return 1; /* skip this altsetting */ } return 0; /* keep this altsetting */ } |
0f5733b0c ALSA: usb-audio -... |
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip, int iface, int altno) { /* Reset ALL ifaces to 0 altsetting. * Call it for every possible altsetting of every interface. */ usb_set_interface(chip->dev, iface, 0); /* possible configuration where both inputs and only one output is *used is not supported by the current setup */ if (chip->setup & (MAUDIO_SET | MAUDIO_SET_24B)) { if (chip->setup & MAUDIO_SET_96K) { if (altno != 3 && altno != 6) return 1; } else if (chip->setup & MAUDIO_SET_DI) { if (iface == 4) return 1; /* no analog input */ if (altno != 2 && altno != 5) return 1; /* enable only altsets 2 and 5 */ } else { if (iface == 5) return 1; /* disable digialt input */ if (altno != 2 && altno != 5) return 1; /* enalbe only altsets 2 and 5 */ } } else { /* keep only 16-Bit mode */ if (altno != 1) return 1; } snd_printdd(KERN_INFO "using altsetting %d for interface %d config %d ", altno, iface, chip->setup); return 0; /* keep this altsetting */ } |
e5779998b ALSA: usb-audio: ... |
618 619 620 621 622 623 624 |
int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip, int iface, int altno) { /* audiophile usb: skip altsets incompatible with device_setup */ if (chip->usb_id == USB_ID(0x0763, 0x2003)) return audiophile_skip_setting_quirk(chip, iface, altno); |
0f5733b0c ALSA: usb-audio -... |
625 626 627 628 629 630 |
/* quattro usb: skip altsets incompatible with device_setup */ if (chip->usb_id == USB_ID(0x0763, 0x2001)) return quattro_skip_setting_quirk(chip, iface, altno); /* fasttrackpro usb: skip altsets incompatible with device_setup */ if (chip->usb_id == USB_ID(0x0763, 0x2012)) return fasttrackpro_skip_setting_quirk(chip, iface, altno); |
e5779998b ALSA: usb-audio: ... |
631 632 633 634 635 636 637 638 639 640 |
return 0; } int snd_usb_apply_boot_quirk(struct usb_device *dev, struct usb_interface *intf, const struct snd_usb_audio_quirk *quirk) { u32 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idProduct)); |
3347b26ca ALSA: usb-audio: ... |
641 642 643 644 |
switch (id) { case USB_ID(0x041e, 0x3000): /* SB Extigy needs special boot-up sequence */ /* if more models come, this will go to the quirk list. */ |
e5779998b ALSA: usb-audio: ... |
645 |
return snd_usb_extigy_boot_quirk(dev, intf); |
3347b26ca ALSA: usb-audio: ... |
646 647 |
case USB_ID(0x041e, 0x3020): /* SB Audigy 2 NX needs its own boot-up magic, too */ |
e5779998b ALSA: usb-audio: ... |
648 |
return snd_usb_audigy2nx_boot_quirk(dev); |
3347b26ca ALSA: usb-audio: ... |
649 650 |
case USB_ID(0x10f5, 0x0200): /* C-Media CM106 / Turtle Beach Audio Advantage Roadie */ |
e5779998b ALSA: usb-audio: ... |
651 |
return snd_usb_cm106_boot_quirk(dev); |
3347b26ca ALSA: usb-audio: ... |
652 653 |
case USB_ID(0x0d8c, 0x0102): /* C-Media CM6206 / CM106-Like Sound Device */ |
8129e79ed ALSA: usb-audio -... |
654 |
case USB_ID(0x0ccd, 0x00b1): /* Terratec Aureon 7.1 USB */ |
e5779998b ALSA: usb-audio: ... |
655 |
return snd_usb_cm6206_boot_quirk(dev); |
3347b26ca ALSA: usb-audio: ... |
656 657 |
case USB_ID(0x133e, 0x0815): /* Access Music VirusTI Desktop */ |
e5779998b ALSA: usb-audio: ... |
658 |
return snd_usb_accessmusic_boot_quirk(dev); |
759e890f5 ALSA: usb-audio: ... |
659 |
case USB_ID(0x17cc, 0x1000): /* Komplete Audio 6 */ |
3347b26ca ALSA: usb-audio: ... |
660 661 |
case USB_ID(0x17cc, 0x1010): /* Traktor Audio 6 */ case USB_ID(0x17cc, 0x1020): /* Traktor Audio 10 */ |
54a8c500d ALSA: usb-audio: ... |
662 |
return snd_usb_nativeinstruments_boot_quirk(dev); |
0f5733b0c ALSA: usb-audio -... |
663 664 |
case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */ return snd_usb_fasttrackpro_boot_quirk(dev); |
3347b26ca ALSA: usb-audio: ... |
665 |
} |
54a8c500d ALSA: usb-audio: ... |
666 |
|
e5779998b ALSA: usb-audio: ... |
667 668 669 670 671 672 673 674 |
return 0; } /* * check if the device uses big-endian samples */ int snd_usb_is_big_endian_format(struct snd_usb_audio *chip, struct audioformat *fp) { |
0f5733b0c ALSA: usb-audio -... |
675 |
/* it depends on altsetting wether the device is big-endian or not */ |
e5779998b ALSA: usb-audio: ... |
676 677 |
switch (chip->usb_id) { case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */ |
0f5733b0c ALSA: usb-audio -... |
678 679 |
if (fp->altsetting == 2 || fp->altsetting == 3 || fp->altsetting == 5 || fp->altsetting == 6) |
e5779998b ALSA: usb-audio: ... |
680 681 682 683 |
return 1; break; case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ if (chip->setup == 0x00 || |
0f5733b0c ALSA: usb-audio -... |
684 685 686 687 688 689 690 |
fp->altsetting == 1 || fp->altsetting == 2 || fp->altsetting == 3) return 1; break; case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro */ if (fp->altsetting == 2 || fp->altsetting == 3 || fp->altsetting == 5 || fp->altsetting == 6) |
e5779998b ALSA: usb-audio: ... |
691 |
return 1; |
0f5733b0c ALSA: usb-audio -... |
692 |
break; |
e5779998b ALSA: usb-audio: ... |
693 694 695 696 697 |
} return 0; } /* |
1cdfa9f34 ALSA: usbaudio - ... |
698 |
* For E-Mu 0404USB/0202USB/TrackerPre/0204 sample rate should be set for device, |
e5779998b ALSA: usb-audio: ... |
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 |
* not for interface. */ enum { EMU_QUIRK_SR_44100HZ = 0, EMU_QUIRK_SR_48000HZ, EMU_QUIRK_SR_88200HZ, EMU_QUIRK_SR_96000HZ, EMU_QUIRK_SR_176400HZ, EMU_QUIRK_SR_192000HZ }; static void set_format_emu_quirk(struct snd_usb_substream *subs, struct audioformat *fmt) { unsigned char emu_samplerate_id = 0; /* When capture is active * sample rate shouldn't be changed * by playback substream */ if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) { if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].interface != -1) return; } switch (fmt->rate_min) { case 48000: emu_samplerate_id = EMU_QUIRK_SR_48000HZ; break; case 88200: emu_samplerate_id = EMU_QUIRK_SR_88200HZ; break; case 96000: emu_samplerate_id = EMU_QUIRK_SR_96000HZ; break; case 176400: emu_samplerate_id = EMU_QUIRK_SR_176400HZ; break; case 192000: emu_samplerate_id = EMU_QUIRK_SR_192000HZ; break; default: emu_samplerate_id = EMU_QUIRK_SR_44100HZ; break; } snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id); } void snd_usb_set_format_quirk(struct snd_usb_substream *subs, struct audioformat *fmt) { switch (subs->stream->chip->usb_id) { case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */ case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */ case USB_ID(0x041e, 0x3f0a): /* E-Mu Tracker Pre */ |
1cdfa9f34 ALSA: usbaudio - ... |
755 |
case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */ |
e5779998b ALSA: usb-audio: ... |
756 757 758 759 |
set_format_emu_quirk(subs, fmt); break; } } |