diff options
author | Ruslan Bilovol <ruslan.bilovol@gmail.com> | 2018-03-18 21:46:02 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-03-19 12:00:12 -0400 |
commit | ceb18f511beeb8b750f027f170eb6d901a082e9a (patch) | |
tree | d6b05240823e2c2d03fcf25973c9993cf5559925 | |
parent | 4654eba8cbb3fcf48c6fc24fbaffa0623d9faea2 (diff) |
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>
-rw-r--r-- | sound/usb/quirks.c | 34 | ||||
-rw-r--r-- | sound/usb/quirks.h | 4 | ||||
-rw-r--r-- | sound/usb/stream.c | 30 |
3 files changed, 39 insertions, 29 deletions
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index ea8f3de92fa4..eeea8e18aea3 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c | |||
@@ -1403,3 +1403,37 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, | |||
1403 | 1403 | ||
1404 | return 0; | 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 | } | ||
diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h index b90c8b7caab5..a80e0ddd0736 100644 --- a/sound/usb/quirks.h +++ b/sound/usb/quirks.h | |||
@@ -42,4 +42,8 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, | |||
42 | struct audioformat *fp, | 42 | struct audioformat *fp, |
43 | unsigned int sample_bytes); | 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 | #endif /* __USBAUDIO_QUIRKS_H */ | 49 | #endif /* __USBAUDIO_QUIRKS_H */ |
diff --git a/sound/usb/stream.c b/sound/usb/stream.c index d1776e5517ff..dbbe854745ab 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c | |||
@@ -678,35 +678,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) | |||
678 | INIT_LIST_HEAD(&fp->list); | 678 | INIT_LIST_HEAD(&fp->list); |
679 | 679 | ||
680 | /* some quirks for attributes here */ | 680 | /* some quirks for attributes here */ |
681 | 681 | snd_usb_audioformat_attributes_quirk(chip, fp, stream); | |
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 | } | ||
710 | 682 | ||
711 | /* ok, let's parse further... */ | 683 | /* ok, let's parse further... */ |
712 | if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream) < 0) { | 684 | if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream) < 0) { |