]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[ALSA] usb-audio: simplify MIDI quirk handling
authorClemens Ladisch <clemens@ladisch.de>
Wed, 14 Sep 2005 06:36:03 +0000 (08:36 +0200)
committerJaroslav Kysela <perex@suse.cz>
Fri, 4 Nov 2005 12:15:49 +0000 (13:15 +0100)
Modules: USB generic driver

Simplify the handling of MIDI quirks by treating an interface without
quirks as a QUIRK_MIDI_STANDARD_INTERFACE.

This also fixes the bug where a MIDI_STANDARD quirk would not be
recognized.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
sound/usb/usbaudio.c
sound/usb/usbmidi.c

index 2ead878bcb8f4793113db63a685caa026955b2eb..ea1b1f87c1b656b517c148b87fb0ac3ba86b43ea 100644 (file)
@@ -2755,9 +2755,9 @@ static int create_fixed_stream_quirk(snd_usb_audio_t *chip,
 /*
  * create a stream for an interface with proper descriptors
  */
-static int create_standard_interface_quirk(snd_usb_audio_t *chip,
-                                          struct usb_interface *iface,
-                                          const snd_usb_audio_quirk_t *quirk)
+static int create_standard_audio_quirk(snd_usb_audio_t *chip,
+                                      struct usb_interface *iface,
+                                      const snd_usb_audio_quirk_t *quirk)
 {
        struct usb_host_interface *alts;
        struct usb_interface_descriptor *altsd;
@@ -2765,24 +2765,14 @@ static int create_standard_interface_quirk(snd_usb_audio_t *chip,
 
        alts = &iface->altsetting[0];
        altsd = get_iface_desc(alts);
-       switch (quirk->type) {
-       case QUIRK_AUDIO_STANDARD_INTERFACE:
-               err = parse_audio_endpoints(chip, altsd->bInterfaceNumber);
-               if (!err)
-                       usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0); /* reset the current interface */
-               break;
-       case QUIRK_MIDI_STANDARD_INTERFACE:
-               err = snd_usb_create_midi_interface(chip, iface, NULL);
-               break;
-       default:
-               snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
-               return -ENXIO;
-       }
+       err = parse_audio_endpoints(chip, altsd->bInterfaceNumber);
        if (err < 0) {
                snd_printk(KERN_ERR "cannot setup if %d: error %d\n",
                           altsd->bInterfaceNumber, err);
                return err;
        }
+       /* reset the current interface */
+       usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0);
        return 0;
 }
 
@@ -3044,7 +3034,7 @@ static int snd_usb_create_quirk(snd_usb_audio_t *chip,
                [QUIRK_MIDI_RAW] = snd_usb_create_midi_interface,
                [QUIRK_MIDI_EMAGIC] = snd_usb_create_midi_interface,
                [QUIRK_MIDI_MIDITECH] = snd_usb_create_midi_interface,
-               [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_interface_quirk,
+               [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk,
                [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
                [QUIRK_AUDIO_EDIROL_UA700_UA25] = create_ua700_ua25_quirk,
                [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk,
index f1a2e2c2e02fa8c1b679695fb20d4d5e892c936b..32be9f99c023a90cedbb4f259b26d4d572f6a39a 100644 (file)
@@ -1550,46 +1550,45 @@ int snd_usb_create_midi_interface(snd_usb_audio_t* chip,
 
        /* detect the endpoint(s) to use */
        memset(endpoints, 0, sizeof(endpoints));
-       if (!quirk) {
+       switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) {
+       case QUIRK_MIDI_STANDARD_INTERFACE:
                err = snd_usbmidi_get_ms_info(umidi, endpoints);
-       } else {
-               switch (quirk->type) {
-               case QUIRK_MIDI_FIXED_ENDPOINT:
-                       memcpy(&endpoints[0], quirk->data,
-                              sizeof(snd_usb_midi_endpoint_info_t));
-                       err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1);
-                       break;
-               case QUIRK_MIDI_YAMAHA:
-                       err = snd_usbmidi_detect_yamaha(umidi, &endpoints[0]);
-                       break;
-               case QUIRK_MIDI_MIDIMAN:
-                       umidi->usb_protocol_ops = &snd_usbmidi_midiman_ops;
-                       memcpy(&endpoints[0], quirk->data,
-                              sizeof(snd_usb_midi_endpoint_info_t));
-                       err = 0;
-                       break;
-               case QUIRK_MIDI_NOVATION:
-                       umidi->usb_protocol_ops = &snd_usbmidi_novation_ops;
-                       err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
-                       break;
-               case QUIRK_MIDI_RAW:
-                       umidi->usb_protocol_ops = &snd_usbmidi_raw_ops;
-                       err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
-                       break;
-               case QUIRK_MIDI_EMAGIC:
-                       umidi->usb_protocol_ops = &snd_usbmidi_emagic_ops;
-                       memcpy(&endpoints[0], quirk->data,
-                              sizeof(snd_usb_midi_endpoint_info_t));
-                       err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1);
-                       break;
-               case QUIRK_MIDI_MIDITECH:
-                       err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
-                       break;
-               default:
-                       snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
-                       err = -ENXIO;
-                       break;
-               }
+               break;
+       case QUIRK_MIDI_FIXED_ENDPOINT:
+               memcpy(&endpoints[0], quirk->data,
+                      sizeof(snd_usb_midi_endpoint_info_t));
+               err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1);
+               break;
+       case QUIRK_MIDI_YAMAHA:
+               err = snd_usbmidi_detect_yamaha(umidi, &endpoints[0]);
+               break;
+       case QUIRK_MIDI_MIDIMAN:
+               umidi->usb_protocol_ops = &snd_usbmidi_midiman_ops;
+               memcpy(&endpoints[0], quirk->data,
+                      sizeof(snd_usb_midi_endpoint_info_t));
+               err = 0;
+               break;
+       case QUIRK_MIDI_NOVATION:
+               umidi->usb_protocol_ops = &snd_usbmidi_novation_ops;
+               err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
+               break;
+       case QUIRK_MIDI_RAW:
+               umidi->usb_protocol_ops = &snd_usbmidi_raw_ops;
+               err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
+               break;
+       case QUIRK_MIDI_EMAGIC:
+               umidi->usb_protocol_ops = &snd_usbmidi_emagic_ops;
+               memcpy(&endpoints[0], quirk->data,
+                      sizeof(snd_usb_midi_endpoint_info_t));
+               err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1);
+               break;
+       case QUIRK_MIDI_MIDITECH:
+               err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
+               break;
+       default:
+               snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
+               err = -ENXIO;
+               break;
        }
        if (err < 0) {
                kfree(umidi);