Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: usb-audio: move audioformat quirks to quirks.c

Offload USB audio interface parsing function by
moving quirks to a specially designed location (quirks.c)

Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Ruslan Bilovol and committed by
Takashi Iwai
ceb18f51 4654eba8

+39 -29
+34
sound/usb/quirks.c
··· 1403 1403 1404 1404 return 0; 1405 1405 } 1406 + 1407 + void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip, 1408 + struct audioformat *fp, 1409 + int stream) 1410 + { 1411 + switch (chip->usb_id) { 1412 + case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */ 1413 + /* Optoplay sets the sample rate attribute although 1414 + * it seems not supporting it in fact. 1415 + */ 1416 + fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE; 1417 + break; 1418 + case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ 1419 + case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ 1420 + /* doesn't set the sample rate attribute, but supports it */ 1421 + fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE; 1422 + break; 1423 + case USB_ID(0x0763, 0x2001): /* M-Audio Quattro USB */ 1424 + case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */ 1425 + case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ 1426 + case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is 1427 + an older model 77d:223) */ 1428 + /* 1429 + * plantronics headset and Griffin iMic have set adaptive-in 1430 + * although it's really not... 1431 + */ 1432 + fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE; 1433 + if (stream == SNDRV_PCM_STREAM_PLAYBACK) 1434 + fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE; 1435 + else 1436 + fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC; 1437 + break; 1438 + } 1439 + }
+4
sound/usb/quirks.h
··· 42 42 struct audioformat *fp, 43 43 unsigned int sample_bytes); 44 44 45 + void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip, 46 + struct audioformat *fp, 47 + int stream); 48 + 45 49 #endif /* __USBAUDIO_QUIRKS_H */
+1 -29
sound/usb/stream.c
··· 678 678 INIT_LIST_HEAD(&fp->list); 679 679 680 680 /* some quirks for attributes here */ 681 - 682 - switch (chip->usb_id) { 683 - case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */ 684 - /* Optoplay sets the sample rate attribute although 685 - * it seems not supporting it in fact. 686 - */ 687 - fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE; 688 - break; 689 - case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ 690 - case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ 691 - /* doesn't set the sample rate attribute, but supports it */ 692 - fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE; 693 - break; 694 - case USB_ID(0x0763, 0x2001): /* M-Audio Quattro USB */ 695 - case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */ 696 - case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ 697 - case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is 698 - an older model 77d:223) */ 699 - /* 700 - * plantronics headset and Griffin iMic have set adaptive-in 701 - * although it's really not... 702 - */ 703 - fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE; 704 - if (stream == SNDRV_PCM_STREAM_PLAYBACK) 705 - fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE; 706 - else 707 - fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC; 708 - break; 709 - } 681 + snd_usb_audioformat_attributes_quirk(chip, fp, stream); 710 682 711 683 /* ok, let's parse further... */ 712 684 if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream) < 0) {