ALSA: snd-usb-audio: support for Edirol UA-4FX device
authorPedro Lopez-Cabanillas <pedro.lopez.cabanillas@gmail.com>
Sat, 4 Oct 2008 14:27:36 +0000 (16:27 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 10 Oct 2008 11:41:48 +0000 (13:41 +0200)
Renamed the old quirk function for ua-700/ua-25 to become more
generic, moving the MIDI interfaces to the quirk data header.
Added a new quirk for the Edirol UA-4FX.

Signed-off-by: Pedro Lopez-Cabanillas <pedro.lopez.cabanillas@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
sound/usb/usbaudio.c
sound/usb/usbaudio.h
sound/usb/usbquirks.h

index 8af12b680e12e58b90994cb9f1f23b1636b0c9c9..6e70ba4ee21f2edffaf29d558e0b5543c7c7d8da 100644 (file)
@@ -2997,12 +2997,12 @@ static int create_standard_audio_quirk(struct snd_usb_audio *chip,
 }
 
 /*
- * Create a stream for an Edirol UA-700/UA-25 interface.  The only way
- * to detect the sample rate is by looking at wMaxPacketSize.
+ * Create a stream for an Edirol UA-700/UA-25/UA-4FX interface.  
+ * The only way to detect the sample rate is by looking at wMaxPacketSize.
  */
-static int create_ua700_ua25_quirk(struct snd_usb_audio *chip,
-                                  struct usb_interface *iface,
-                                  const struct snd_usb_audio_quirk *quirk)
+static int create_uaxx_quirk(struct snd_usb_audio *chip,
+                             struct usb_interface *iface,
+                             const struct snd_usb_audio_quirk *quirk)
 {
        static const struct audioformat ua_format = {
                .format = SNDRV_PCM_FORMAT_S24_3LE,
@@ -3017,37 +3017,12 @@ static int create_ua700_ua25_quirk(struct snd_usb_audio *chip,
        struct audioformat *fp;
        int stream, err;
 
-       /* both PCM and MIDI interfaces have 2 altsettings */
-       if (iface->num_altsetting != 2)
+       /* both PCM and MIDI interfaces have 2 or more altsettings */
+       if (iface->num_altsetting < 2)
                return -ENXIO;
        alts = &iface->altsetting[1];
        altsd = get_iface_desc(alts);
 
-       if (altsd->bNumEndpoints == 2) {
-               static const struct snd_usb_midi_endpoint_info ua700_ep = {
-                       .out_cables = 0x0003,
-                       .in_cables  = 0x0003
-               };
-               static const struct snd_usb_audio_quirk ua700_quirk = {
-                       .type = QUIRK_MIDI_FIXED_ENDPOINT,
-                       .data = &ua700_ep
-               };
-               static const struct snd_usb_midi_endpoint_info ua25_ep = {
-                       .out_cables = 0x0001,
-                       .in_cables  = 0x0001
-               };
-               static const struct snd_usb_audio_quirk ua25_quirk = {
-                       .type = QUIRK_MIDI_FIXED_ENDPOINT,
-                       .data = &ua25_ep
-               };
-               if (chip->usb_id == USB_ID(0x0582, 0x002b))
-                       return snd_usb_create_midi_interface(chip, iface,
-                                                            &ua700_quirk);
-               else
-                       return snd_usb_create_midi_interface(chip, iface,
-                                                            &ua25_quirk);
-       }
-
        if (altsd->bNumEndpoints != 1)
                return -ENXIO;
 
@@ -3377,9 +3352,9 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip,
                [QUIRK_MIDI_CME] = snd_usb_create_midi_interface,
                [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,
                [QUIRK_AUDIO_EDIROL_UA101] = create_ua101_quirk,
+               [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk
        };
 
        if (quirk->type < QUIRK_TYPE_COUNT) {
index f3ca77f08eacc740c737ee80576ba185f6d8a459..36e4f7a29adc5548b05b5366fa0191f13466145b 100644 (file)
@@ -159,9 +159,9 @@ enum quirk_type {
        QUIRK_MIDI_US122L,
        QUIRK_AUDIO_STANDARD_INTERFACE,
        QUIRK_AUDIO_FIXED_ENDPOINT,
-       QUIRK_AUDIO_EDIROL_UA700_UA25,
        QUIRK_AUDIO_EDIROL_UA1000,
        QUIRK_AUDIO_EDIROL_UA101,
+       QUIRK_AUDIO_EDIROL_UAXX,
 
        QUIRK_TYPE_COUNT
 };
index d96bf8b2b94b6020bedfe86d997997ef368cdb31..85532cf9dbf6f83d5427cd510a3fa49a116e440a 100644 (file)
@@ -862,15 +862,19 @@ YAMAHA_DEVICE(0x7010, "UB99"),
                .data = (const struct snd_usb_audio_quirk[]) {
                        {
                                .ifnum = 1,
-                               .type = QUIRK_AUDIO_EDIROL_UA700_UA25
+                               .type = QUIRK_AUDIO_EDIROL_UAXX
                        },
                        {
                                .ifnum = 2,
-                               .type = QUIRK_AUDIO_EDIROL_UA700_UA25
+                               .type = QUIRK_AUDIO_EDIROL_UAXX
                        },
                        {
                                .ifnum = 3,
-                               .type = QUIRK_AUDIO_EDIROL_UA700_UA25
+                               .type = QUIRK_MIDI_FIXED_ENDPOINT,
+                               .data = & (const struct snd_usb_midi_endpoint_info) {
+                                       .out_cables = 0x0003,
+                                       .in_cables  = 0x0003
+                               }
                        },
                        {
                                .ifnum = -1
@@ -1204,15 +1208,19 @@ YAMAHA_DEVICE(0x7010, "UB99"),
                .data = (const struct snd_usb_audio_quirk[]) {
                        {
                                .ifnum = 0,
-                               .type = QUIRK_AUDIO_EDIROL_UA700_UA25
+                               .type = QUIRK_AUDIO_EDIROL_UAXX
                        },
                        {
                                .ifnum = 1,
-                               .type = QUIRK_AUDIO_EDIROL_UA700_UA25
+                               .type = QUIRK_AUDIO_EDIROL_UAXX
                        },
                        {
                                .ifnum = 2,
-                               .type = QUIRK_AUDIO_EDIROL_UA700_UA25
+                               .type = QUIRK_MIDI_FIXED_ENDPOINT,
+                               .data = & (const struct snd_usb_midi_endpoint_info) {
+                                       .out_cables = 0x0001,
+                                       .in_cables  = 0x0001
+                               }
                        },
                        {
                                .ifnum = -1
@@ -1344,6 +1352,40 @@ YAMAHA_DEVICE(0x7010, "UB99"),
                        .in_cables  = 0x000f
                }
        }
+},
+{
+       /*
+        * This quirk is for the "Advanced Driver" mode. If off, the UA-4FX
+        * is standard compliant, but has only 16-bit PCM and no MIDI.
+        */
+       USB_DEVICE(0x0582, 0x00a3),
+       .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
+               .vendor_name = "EDIROL",
+               .product_name = "UA-4FX",
+               .ifnum = QUIRK_ANY_INTERFACE,
+               .type = QUIRK_COMPOSITE,
+               .data = (const struct snd_usb_audio_quirk[]) {
+                       {
+                               .ifnum = 0,
+                               .type = QUIRK_AUDIO_EDIROL_UAXX
+                       },
+                       {
+                               .ifnum = 1,
+                               .type = QUIRK_AUDIO_EDIROL_UAXX
+                       },
+                       {
+                               .ifnum = 2,
+                               .type = QUIRK_MIDI_FIXED_ENDPOINT,
+                               .data = & (const struct snd_usb_midi_endpoint_info) {
+                                       .out_cables = 0x0001,
+                                       .in_cables  = 0x0001
+                               }
+                       },
+                       {
+                               .ifnum = -1
+                       }
+               }
+       }
 },
        /* TODO: add Edirol MD-P1 support */
 {