aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usbaudio.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-07-25 10:19:10 -0400
committerJaroslav Kysela <perex@suse.cz>2005-07-28 06:22:41 -0400
commit854af9578cb84e4ca3cb1551a6be40c4e81bb455 (patch)
treefb09d01b0499451e258a71e9a05246c1e08ea301 /sound/usb/usbaudio.c
parentf38275fe994c333b809796230f4f98090f8d919b (diff)
[ALSA] usb-audio - change quirk type handling
USB generic driver Make the quirk type an enum instead of a #defined integer, and use a table for the quirk constructor functions instead of a big switch statement. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/usb/usbaudio.c')
-rw-r--r--sound/usb/usbaudio.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 9a0b0899d156..8298c462c291 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2735,7 +2735,8 @@ static int create_standard_interface_quirk(snd_usb_audio_t *chip,
2735 * to detect the sample rate is by looking at wMaxPacketSize. 2735 * to detect the sample rate is by looking at wMaxPacketSize.
2736 */ 2736 */
2737static int create_ua700_ua25_quirk(snd_usb_audio_t *chip, 2737static int create_ua700_ua25_quirk(snd_usb_audio_t *chip,
2738 struct usb_interface *iface) 2738 struct usb_interface *iface,
2739 const snd_usb_audio_quirk_t *quirk)
2739{ 2740{
2740 static const struct audioformat ua_format = { 2741 static const struct audioformat ua_format = {
2741 .format = SNDRV_PCM_FORMAT_S24_3LE, 2742 .format = SNDRV_PCM_FORMAT_S24_3LE,
@@ -2826,7 +2827,9 @@ static int create_ua700_ua25_quirk(snd_usb_audio_t *chip,
2826/* 2827/*
2827 * Create a stream for an Edirol UA-1000 interface. 2828 * Create a stream for an Edirol UA-1000 interface.
2828 */ 2829 */
2829static int create_ua1000_quirk(snd_usb_audio_t *chip, struct usb_interface *iface) 2830static int create_ua1000_quirk(snd_usb_audio_t *chip,
2831 struct usb_interface *iface,
2832 const snd_usb_audio_quirk_t *quirk)
2830{ 2833{
2831 static const struct audioformat ua1000_format = { 2834 static const struct audioformat ua1000_format = {
2832 .format = SNDRV_PCM_FORMAT_S32_LE, 2835 .format = SNDRV_PCM_FORMAT_S32_LE,
@@ -2903,6 +2906,13 @@ static int create_composite_quirk(snd_usb_audio_t *chip,
2903 return 0; 2906 return 0;
2904} 2907}
2905 2908
2909static int ignore_interface_quirk(snd_usb_audio_t *chip,
2910 struct usb_interface *iface,
2911 const snd_usb_audio_quirk_t *quirk)
2912{
2913 return 0;
2914}
2915
2906 2916
2907/* 2917/*
2908 * boot quirks 2918 * boot quirks
@@ -2965,29 +2975,28 @@ static int snd_usb_create_quirk(snd_usb_audio_t *chip,
2965 struct usb_interface *iface, 2975 struct usb_interface *iface,
2966 const snd_usb_audio_quirk_t *quirk) 2976 const snd_usb_audio_quirk_t *quirk)
2967{ 2977{
2968 switch (quirk->type) { 2978 typedef int (*quirk_func_t)(snd_usb_audio_t *, struct usb_interface *,
2969 case QUIRK_MIDI_FIXED_ENDPOINT: 2979 const snd_usb_audio_quirk_t *);
2970 case QUIRK_MIDI_YAMAHA: 2980 static const quirk_func_t quirk_funcs[] = {
2971 case QUIRK_MIDI_MIDIMAN: 2981 [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk,
2972 case QUIRK_MIDI_NOVATION: 2982 [QUIRK_COMPOSITE] = create_composite_quirk,
2973 case QUIRK_MIDI_RAW: 2983 [QUIRK_MIDI_STANDARD_INTERFACE] = snd_usb_create_midi_interface,
2974 case QUIRK_MIDI_EMAGIC: 2984 [QUIRK_MIDI_FIXED_ENDPOINT] = snd_usb_create_midi_interface,
2975 case QUIRK_MIDI_MIDITECH: 2985 [QUIRK_MIDI_YAMAHA] = snd_usb_create_midi_interface,
2976 return snd_usb_create_midi_interface(chip, iface, quirk); 2986 [QUIRK_MIDI_MIDIMAN] = snd_usb_create_midi_interface,
2977 case QUIRK_COMPOSITE: 2987 [QUIRK_MIDI_NOVATION] = snd_usb_create_midi_interface,
2978 return create_composite_quirk(chip, iface, quirk); 2988 [QUIRK_MIDI_RAW] = snd_usb_create_midi_interface,
2979 case QUIRK_AUDIO_FIXED_ENDPOINT: 2989 [QUIRK_MIDI_EMAGIC] = snd_usb_create_midi_interface,
2980 return create_fixed_stream_quirk(chip, iface, quirk); 2990 [QUIRK_MIDI_MIDITECH] = snd_usb_create_midi_interface,
2981 case QUIRK_AUDIO_STANDARD_INTERFACE: 2991 [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_interface_quirk,
2982 case QUIRK_MIDI_STANDARD_INTERFACE: 2992 [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
2983 return create_standard_interface_quirk(chip, iface, quirk); 2993 [QUIRK_AUDIO_EDIROL_UA700_UA25] = create_ua700_ua25_quirk,
2984 case QUIRK_AUDIO_EDIROL_UA700_UA25: 2994 [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk,
2985 return create_ua700_ua25_quirk(chip, iface); 2995 };
2986 case QUIRK_AUDIO_EDIROL_UA1000: 2996
2987 return create_ua1000_quirk(chip, iface); 2997 if (quirk->type < QUIRK_TYPE_COUNT) {
2988 case QUIRK_IGNORE_INTERFACE: 2998 return quirk_funcs[quirk->type](chip, iface, quirk);
2989 return 0; 2999 } else {
2990 default:
2991 snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type); 3000 snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
2992 return -ENXIO; 3001 return -ENXIO;
2993 } 3002 }