Update of /cvsroot/alsa/alsa-kernel/usb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16561
Modified Files: usbaudio.c usbaudio.h usbquirks.h Log Message: Edirol UA-700 advanced modes support Index: usbaudio.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/usb/usbaudio.c,v retrieving revision 1.98 retrieving revision 1.99 diff -u -r1.98 -r1.99 --- usbaudio.c 13 Apr 2004 07:56:23 -0000 1.98 +++ usbaudio.c 14 Apr 2004 17:11:20 -0000 1.99 @@ -2742,6 +2742,83 @@ return 0; } +/* + * Create a stream for an Edirol UA-700 interface. The only way + * to detect the sample rate is by looking at wMaxPacketSize. + */ +static int create_ua700_quirk(snd_usb_audio_t *chip, struct usb_interface *iface) +{ + static const struct audioformat ua700_format = { + .format = SNDRV_PCM_FORMAT_S24_3LE, + .channels = 2, + .fmt_type = USB_FORMAT_TYPE_I, + .altsetting = 1, + .altset_idx = 1, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + }; + struct usb_host_interface *alts; + struct usb_interface_descriptor *altsd; + struct audioformat *fp; + int stream, err; + + /* both PCM and MIDI interfaces have 2 altsettings */ + if (iface->num_altsetting != 2) + return -ENXIO; + alts = &iface->altsetting[1]; + altsd = get_iface_desc(alts); + + if (altsd->bNumEndpoints == 2) { + static const snd_usb_midi_endpoint_info_t ep = { + .out_cables = 0x0003, + .in_cables = 0x0003 + }; + static const snd_usb_audio_quirk_t quirk = { + .type = QUIRK_MIDI_FIXED_ENDPOINT, + .data = &ep + }; + return snd_usb_create_midi_interface(chip, iface, &quirk); + } + + if (altsd->bNumEndpoints != 1) + return -ENXIO; + + fp = kmalloc(sizeof(*fp), GFP_KERNEL); + if (!fp) + return -ENOMEM; + memcpy(fp, &ua700_format, sizeof(*fp)); + + fp->iface = altsd->bInterfaceNumber; + fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; + fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; + fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize; + + switch (fp->maxpacksize) { + case 0x120: + fp->rate_max = fp->rate_min = 44100; + break; + case 0x138: + fp->rate_max = fp->rate_min = 48000; + break; + case 0x258: + fp->rate_max = fp->rate_min = 96000; + break; + default: + snd_printk(KERN_ERR "unknown sample rate\n"); + kfree(fp); + return -ENXIO; + } + + stream = (fp->endpoint & USB_DIR_IN) + ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; + err = add_audio_endpoint(chip, stream, fp); + if (err < 0) { + kfree(fp); + return err; + } + usb_set_interface(chip->dev, fp->iface, 0); + return 0; +} + static int snd_usb_create_quirk(snd_usb_audio_t *chip, struct usb_interface *iface, const snd_usb_audio_quirk_t *quirk); @@ -2829,6 +2906,8 @@ case QUIRK_AUDIO_STANDARD_INTERFACE: case QUIRK_MIDI_STANDARD_INTERFACE: return create_standard_interface_quirk(chip, iface, quirk); + case QUIRK_AUDIO_EDIROL_UA700: + return create_ua700_quirk(chip, iface); default: snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type); return -ENXIO; Index: usbaudio.h =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/usb/usbaudio.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- usbaudio.h 13 Apr 2004 07:56:24 -0000 1.30 +++ usbaudio.h 14 Apr 2004 17:11:21 -0000 1.31 @@ -154,6 +154,7 @@ #define QUIRK_AUDIO_FIXED_ENDPOINT 4 #define QUIRK_AUDIO_STANDARD_INTERFACE 5 #define QUIRK_MIDI_STANDARD_INTERFACE 6 +#define QUIRK_AUDIO_EDIROL_UA700 7 typedef struct snd_usb_audio_quirk snd_usb_audio_quirk_t; typedef struct snd_usb_midi_endpoint_info snd_usb_midi_endpoint_info_t; @@ -185,6 +186,8 @@ /* for QUIRK_AUDIO/MIDI_STANDARD_INTERFACE, data is NULL */ +/* for QUIRK_AUDIO_EDIROL_UA700, data is NULL */ + /* */ Index: usbquirks.h =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/usb/usbquirks.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- usbquirks.h 6 Apr 2004 14:19:00 -0000 1.30 +++ usbquirks.h 14 Apr 2004 17:11:22 -0000 1.31 @@ -488,16 +488,34 @@ } } }, -{ +{ /* + * This quirk is for the "Advanced" modes of the Edirol UA-700. + * If the sample format switch is not in an advanced setting, the + * UA-700 has ID 0x0582/0x002c and is standard compliant (no quirks), + * but offers only 16-bit PCM and no MIDI. + */ USB_DEVICE_VENDOR_SPEC(0x0582, 0x002b), .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { .vendor_name = "EDIROL", .product_name = "UA-700", - .ifnum = 3, - .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { - .out_cables = 0x0003, - .in_cables = 0x0003 + .ifnum = QUIRK_ANY_INTERFACE, + .type = QUIRK_COMPOSITE, + .data = (const snd_usb_audio_quirk_t[]) { + { + .ifnum = 1, + .type = QUIRK_AUDIO_EDIROL_UA700 + }, + { + .ifnum = 2, + .type = QUIRK_AUDIO_EDIROL_UA700 + }, + { + .ifnum = 3, + .type = QUIRK_AUDIO_EDIROL_UA700 + }, + { + .ifnum = -1 + } } } }, ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Alsa-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-cvslog