Skip to content

Commit ceb18f5

Browse files
rbilovoltiwai
authored andcommitted
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>
1 parent 4654eba commit ceb18f5

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

sound/usb/quirks.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,3 +1403,37 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
14031403

14041404
return 0;
14051405
}
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+
}

sound/usb/quirks.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
4242
struct audioformat *fp,
4343
unsigned int sample_bytes);
4444

45+
void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
46+
struct audioformat *fp,
47+
int stream);
48+
4549
#endif /* __USBAUDIO_QUIRKS_H */

sound/usb/stream.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -678,35 +678,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no)
678678
INIT_LIST_HEAD(&fp->list);
679679

680680
/* 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);
710682

711683
/* ok, let's parse further... */
712684
if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream) < 0) {

0 commit comments

Comments
 (0)