History

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)

Ruslan Bilovol committed 8 years ago

Commit ceb18f51 parent 4654eba3 files · +39 −29Browse files

Unified · Split

3 files
  1. sound/usb/quirks.c +34 −0
  2. sound/usb/quirks.h +4 −0
  3. sound/usb/stream.c +1 −29
sound/usb/quirks.c+34−0
@@ -1403,3 +1403,37 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · 1402 unmodified lines
1403 1403
1404 return 0;1404 return 0;
1405}1405}
1406
1407void 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+4−0
@@ -42,4 +42,8 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, · 41 unmodified lines
42 struct audioformat *fp,42 struct audioformat *fp,
43 unsigned int sample_bytes);43 unsigned int sample_bytes);
44 44
45void 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 */
sound/usb/stream.c+1−29
@@ -678,35 +678,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) · 677 unmodified lines
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) {