Skip to contentSkip to conversation

M-Audio USB

PATCH In review Pavel Polischouk 5 participants 10 messages Nov 24, 2006 – Dec 15, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 M-Audio USB

Re-send, "hg export" format

# HG changeset patch
# User Pavel Polischouk <[email protected]>
# Date 1164392350 18000
# Node ID d447f5a178f0d40ec98c4cde2e3d6e4d012a7f65
# Parent 6f81f7397f82b392e40c582e48a02a7c1cbd7c3e
This patch adds the following capabilities to usbaudio.c:
- Merges support for M-Audio FastTrack USB
- Adds proper support for M-Audio Quattro USB
- Adds hot-reload support for all Audiophile, FastTrack and Quattro.
- FastTrack "select configuration #2" quirk is present but #ifdef'd out pending inclusion of "usb_driver_set_configuration" function in mainline kernel. This quirk could possibly be handled in user space anyway.

usb/usbaudio.c +147 -25
diff -r 6f81f7397f82 -r d447f5a178f0 usb/usbaudio.c
@@ -2346,11 +2346,16 @@ static int is_big_endian_format(struct s
 {
 	switch (chip->usb_id) {
 	case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */
-		if (fp->endpoint & USB_DIR_IN)
-			return 1;
-		break;
 	case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
 		return 1;
+
+ 	case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro */
+ 		/* it depends on altsetting wether the device is big-endian or not */
+ 		if(fp->altsetting==2 || fp->altsetting==3 ||
+ 		   fp->altsetting==5 || fp->altsetting==6)
+ 			return 1;
+ 		break;
+
 	}
 	return 0;
 }
@@ -2608,8 +2613,12 @@ static int parse_audio_format(struct snd
 	return 0;
 }
 
+static int quattro_skip_setting_quirk(struct snd_usb_audio *chip,
+					 int iface, int altno);
 static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
 					 int iface, int altno);
+static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip,
+ int iface, int altno);
 static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 {
 	struct usb_device *dev;
@@ -2645,10 +2654,21 @@ static int parse_audio_endpoints(struct 
 			SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
 		altno = altsd->bAlternateSetting;
 	
+		/* quattro usb: skip altsets incompatible with device_setup
+		 */
+		if (chip->usb_id == USB_ID(0x0763, 0x2001) && 
+		    quattro_skip_setting_quirk(chip, iface_no, altno))
+			continue;
+
 		/* audiophile usb: skip altsets incompatible with device_setup
 		 */
 		if (chip->usb_id == USB_ID(0x0763, 0x2003) && 
 		    audiophile_skip_setting_quirk(chip, iface_no, altno))
+			continue;
+
+		/* M-Audio Fast Track Pro: skip alsets incompatible with device_setup */
+		if (chip->usb_id == USB_ID(0x0763, 0x2012) &&
+		    fasttrackpro_skip_setting_quirk(chip, iface_no, altno))
 			continue;
 
 		/* get audio formats */
@@ -3175,44 +3195,140 @@ static int snd_usb_cm106_boot_quirk(stru
 	return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
 }
 
+static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev, int ifnum)
+{
+#if 0
+    int err;
+
+    if(dev->actconfig->desc.bConfigurationValue==1) {
+	if(ifnum==0) {
+	    snd_printk(KERN_INFO "Switching to config #2\n");
+	    /* This function has to be available by the usb core module.
+	       if it is not avialable the boot quirk has to be left out and the
+	       configuration has to be set by udev or hotplug rules */
+	    err=usb_driver_set_configuration(dev,2);
+	    if(err < 0) {
+		snd_printdd("error usb_driver_set_configuration: %d\n", err);
+		return -ENODEV;
+	    }
+	}
+    } else {
+	snd_printk(KERN_INFO "Fast Track Pro config OK\n");
+    }
+#endif
+
+    return 0;
+}
 
 /*
  * Setup quirks
  */
-#define AUDIOPHILE_SET			0x01 /* if set, parse device_setup */
-#define AUDIOPHILE_SET_DTS              0x02 /* if set, enable DTS Digital Output */
-#define AUDIOPHILE_SET_96K              0x04 /* 48-96KHz rate if set, 8-48KHz otherwise */
-#define AUDIOPHILE_SET_24B		0x08 /* 24bits sample if set, 16bits otherwise */
-#define AUDIOPHILE_SET_DI		0x10 /* if set, enable Digital Input */
-#define AUDIOPHILE_SET_MASK		0x1F /* bit mask for setup value */
-#define AUDIOPHILE_SET_24B_48K_DI	0x19 /* value for 24bits+48KHz+Digital Input */
-#define AUDIOPHILE_SET_24B_48K_NOTDI	0x09 /* value for 24bits+48KHz+No Digital Input */
-#define AUDIOPHILE_SET_16B_48K_DI	0x11 /* value for 16bits+48KHz+Digital Input */
-#define AUDIOPHILE_SET_16B_48K_NOTDI	0x01 /* value for 16bits+48KHz+No Digital Input */
-
+#define MAUDIO_SET			0x01 /* if set, parse device_setup */
+#define MAUDIO_SET_COMPATIBLE		0x80 /* if set, use only "win-compatible" interfaces */
+#define MAUDIO_SET_DTS              0x02 /* if set, enable DTS Digital Output */
+#define MAUDIO_SET_96K              0x04 /* 48-96KHz rate if set, 8-48KHz otherwise */
+#define MAUDIO_SET_24B		0x08 /* 24bits sample if set, 16bits otherwise */
+#define MAUDIO_SET_DI		0x10 /* if set, enable Digital Input */
+#define MAUDIO_SET_MASK		0x1F /* bit mask for setup value */
+#define MAUDIO_SET_24B_48K_DI	0x19 /* value for 24bits+48KHz+Digital Input */
+#define MAUDIO_SET_24B_48K_NOTDI	0x09 /* value for 24bits+48KHz+No Digital Input */
+#define MAUDIO_SET_16B_48K_DI	0x11 /* value for 16bits+48KHz+Digital Input */
+#define MAUDIO_SET_16B_48K_NOTDI	0x01 /* value for 16bits+48KHz+No Digital Input */
+
+static int quattro_skip_setting_quirk(struct snd_usb_audio *chip,
+					 int iface, int altno)
+{
+	/* Reset ALL ifaces to 0 altsetting. 
+	   Call it for every possible altsetting of every interface. */
+	usb_set_interface(chip->dev, iface, 0); 
+	if (device_setup[chip->index] & MAUDIO_SET) {
+		if ((device_setup[chip->index] & MAUDIO_SET_COMPATIBLE)) {
+			if((iface != 1) && (iface != 2)) 
+				return 1; /* skip all interfaces but 1 and 2 */
+		} else {
+			if ((iface == 1) || (iface == 2))
+				return 1; /* skip interfaces 1 and 2 */
+			if ((device_setup[chip->index] & MAUDIO_SET_96K)
+			    && altno != 1)
+				return 1; /* skip this altsetting */
+			if ((device_setup[chip->index] & MAUDIO_SET_MASK) ==
+			    MAUDIO_SET_24B_48K_DI && altno != 2)
+				return 1; /* skip this altsetting */
+			if ((device_setup[chip->index] & MAUDIO_SET_MASK) ==
+			    MAUDIO_SET_24B_48K_NOTDI && altno != 3)
+				return 1; /* skip this altsetting */
+			if ((device_setup[chip->index] & MAUDIO_SET_MASK) ==
+			    MAUDIO_SET_16B_48K_NOTDI && altno != 4)
+				return 1; /* skip this altsetting */
+		}
+	}	
+	snd_printdd(KERN_INFO "using altsetting %d for interface %d config %d\n", altno, iface, device_setup[chip->index]);
+	return 0; /* keep this altsetting */
+}
 static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
 					 int iface, int altno)
 {
-	if (device_setup[chip->index] & AUDIOPHILE_SET) {
-		if ((device_setup[chip->index] & AUDIOPHILE_SET_DTS)
+	/* Reset ALL ifaces to 0 altsetting. 
+	   Call it for every possible altsetting of every interface. */
+	usb_set_interface(chip->dev, iface, 0); 
+	if (device_setup[chip->index] & MAUDIO_SET) {
+		if ((device_setup[chip->index] & MAUDIO_SET_DTS)
 		    && altno != 6)
 			return 1; /* skip this altsetting */
-		if ((device_setup[chip->index] & AUDIOPHILE_SET_96K)
+		if ((device_setup[chip->index] & MAUDIO_SET_96K)
 		    && altno != 1)
 			return 1; /* skip this altsetting */
-		if ((device_setup[chip->index] & AUDIOPHILE_SET_MASK) ==
-		    AUDIOPHILE_SET_24B_48K_DI && altno != 2)
+		if ((device_setup[chip->index] & MAUDIO_SET_MASK) ==
+		    MAUDIO_SET_24B_48K_DI && altno != 2)
 			return 1; /* skip this altsetting */
-		if ((device_setup[chip->index] & AUDIOPHILE_SET_MASK) ==
-		    AUDIOPHILE_SET_24B_48K_NOTDI && altno != 3)
+		if ((device_setup[chip->index] & MAUDIO_SET_MASK) ==
+		    MAUDIO_SET_24B_48K_NOTDI && altno != 3)
 			return 1; /* skip this altsetting */
-		if ((device_setup[chip->index] & AUDIOPHILE_SET_MASK) ==
-		    AUDIOPHILE_SET_16B_48K_DI && altno != 4)
+		if ((device_setup[chip->index] & MAUDIO_SET_MASK) ==
+		    MAUDIO_SET_16B_48K_DI && altno != 4)
 			return 1; /* skip this altsetting */
-		if ((device_setup[chip->index] & AUDIOPHILE_SET_MASK) ==
-		    AUDIOPHILE_SET_16B_48K_NOTDI && altno != 5)
+		if ((device_setup[chip->index] & MAUDIO_SET_MASK) ==
+		    MAUDIO_SET_16B_48K_NOTDI && altno != 5)
 			return 1; /* skip this altsetting */
 	}	
+	snd_printdd(KERN_INFO "using altsetting %d for interface %d config %d\n", altno, iface, device_setup[chip->index]);
+	return 0; /* keep this altsetting */
+}
+
+static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip,
+		int iface, int altno)
+{
+
+	/* Reset ALL ifaces to 0 altsetting. 
+           Call it for every possible altsetting of every interface. */
+	usb_set_interface(chip->dev, iface, 0); 
+	/* possible configuration where both inputs and only one output is
+	   used is not supported by the current setup */
+
+	if (device_setup[chip->index] & (MAUDIO_SET | MAUDIO_SET_24B)) {
+		if(device_setup[chip->index] & MAUDIO_SET_96K){
+			if((altno != 3) && (altno != 6))
+				return 1;
+		} else if(device_setup[chip->index] & MAUDIO_SET_DI){
+			if(iface == 4)
+				return 1; /* no analog input */
+
+			if((altno != 2) && (altno != 5))
+				return 1; /* enable only altsets 2 and 5 */
+		} else {
+			if(iface == 5)
+				return 1; /* disable digialt input */
+
+			if((altno != 2) && (altno != 5))
+				return 1; /* enalbe only altsets 2 and 5 */
+		}
+	} else {
+		/* keep only 16-Bit mode */
+		if(altno !=1)
+			return 1;
+	}
+
+	snd_printdd(KERN_INFO "using altsetting %d for interface %d config %d\n", altno, iface, device_setup[chip->index]);
 	return 0; /* keep this altsetting */
 }
 
@@ -3452,6 +3568,12 @@ static void *snd_usb_audio_probe(struct 
 			goto __err_val;
 	}
 
+	/* M-Audio Fast Track Pro */
+	if (id == USB_ID(0x0763, 0x2012)) {
+		if (snd_usb_fasttrackpro_boot_quirk(dev, ifnum) < 0)
+			goto __err_val;
+	}
+
 	/*
 	 * found a config.  now register to ALSA
 	 */

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#1 lore raw

At Fri, 24 Nov 2006 15:26:42 -0500,

Quoted 2 lines · Pavel Polischouk

Re-send, "hg export" format

Thanks, this time the patch is intact.

Quoted 5 lines

[2 maudio.patch <text/plain (7bit)>]
# HG changeset patch
# User Pavel Polischouk <[email protected]> # Date 1164392350 18000
# Node ID d447f5a178f0d40ec98c4cde2e3d6e4d012a7f65

Quoted 8 lines

# Parent 6f81f7397f82b392e40c582e48a02a7c1cbd7c3e
This patch adds the following capabilities to usbaudio.c:
- Merges support for M-Audio FastTrack USB
- Adds proper support for M-Audio Quattro USB
- Adds hot-reload support for all Audiophile, FastTrack and Quattro.
- FastTrack "select configuration #2" quirk is present but #ifdef'd out pending inclusion of "usb_driver_set_configuration" function in mainline kernel. This quirk could possibly be handled in user space anyway.

usb_driver_set_configuration() is already in mainline (2.6.19). So, no need to disable it. If you need to disable it for older version, modify usbaudio.patch in alsa-driver tree, or add a dummy wrapper in alsa-driver/include/adriver.h.

Quoted 8 lines

diff -r 6f81f7397f82 -r d447f5a178f0 usb/usbaudio.c

usb/usbaudio.c +0 -1
@@ -2346,11 +2346,16 @@ static int is_big_endian_format(struct s
 {
 	switch (chip->usb_id) {
 	case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */
-		if (fp->endpoint & USB_DIR_IN)

usb/usbaudio.c static int is_big_endian_format(struct s · line 2356

Quoted 10 lines
usb/usbaudio.c +6 -2
-			return 1;
-		break;
 	case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
 		return 1;
+
+ 	case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro */
+ 		/* it depends on altsetting wether the device is big-endian or not */
+ 		if(fp->altsetting==2 || fp->altsetting==3 ||
+ 		   fp->altsetting==5 || fp->altsetting==6)
+ 			return 1;

Minor coding-style fixes:
Put a space between if and (. Also, put spaces around '==', too.

Quoted 14 lines
usb/usbaudio.c +10 -0
@@ -3175,44 +3195,140 @@ static int snd_usb_cm106_boot_quirk(stru
 	return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
 }
 
+static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev, int ifnum)
+{
+#if 0
+    int err;
+
+    if(dev->actconfig->desc.bConfigurationValue==1) {
+	if(ifnum==0) {
+	    snd_printk(KERN_INFO "Switching to config #2\n");
+	    /* This function has to be available by the usb core module.
+	       if it is not avialable the boot quirk has to be left out and the

usb/usbaudio.c static int snd_usb_cm106_boot_quirk(stru · line 3217

Quoted 10 lines
usb/usbaudio.c +10 -0
+	       configuration has to be set by udev or hotplug rules */
+	    err=usb_driver_set_configuration(dev,2);
+	    if(err < 0) {
+		snd_printdd("error usb_driver_set_configuration: %d\n", err);
+		return -ENODEV;
+	    }
+	}
+    } else {
+	snd_printk(KERN_INFO "Fast Track Pro config OK\n");
+    }

Please use indent level 8.

Otherwise, the patch looks fine to me.
Thibault, does it work for your device (at least no regression)?

thanks,

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#2 lore raw

At Mon, 27 Nov 2006 12:15:51 +0100,

Quoted 7 lines · I wrote:

At Fri, 24 Nov 2006 15:26:42 -0500,

Quoted 2 lines · Pavel Polischouk

Re-send, "hg export" format

Thanks, this time the patch is intact.

BTW, please don't forget sign-off, too, for merging to upstream.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#3 lore raw
In reply to Takashi Iwai

Hi Pavel

Finally I had some time to test your patch with my FastTrackPro. I also tested the Boot Quirk to change the configuration automatically. It works out of the box with a 2.6.19 Kernel. Sorry for my bad coding style. It should be a small work to correct.

Back to my tests:
The main functionality of the FastTrack works well as it did with my original patch. There are still some problems with the device I was not able to solve:

- Changing the device_setup without resetting the device will mostly not work.
- Sometimes the device gets messed up. In this state ther is a complete mess in 24-Bit mode and chagned byte-Order for 16-Bit. These problems are not reproduceable.
- The device seems to switch the sampling rate of inputs only after initialising an ouput with the same sampling rate.

To solve these problems I'll need a lot more time. Maybe I have to go back to investigate the behaviour of the windows driver.

Summary:
- The driver works with the FastTrack but is way of to be a stable and final solution.

Peter

Quoted 77 lines · On Mon, 27 Nov 2006 12:15:51 +0100 Takashi Iwai <[email protected]> wrote:

At Fri, 24 Nov 2006 15:26:42 -0500,

Quoted 2 lines · Pavel Polischouk

Re-send, "hg export" format

Thanks, this time the patch is intact.

Quoted 5 lines

[2 maudio.patch <text/plain (7bit)>]
# HG changeset patch
# User Pavel Polischouk <[email protected]> # Date 1164392350 18000
# Node ID d447f5a178f0d40ec98c4cde2e3d6e4d012a7f65

Quoted 8 lines

# Parent 6f81f7397f82b392e40c582e48a02a7c1cbd7c3e
This patch adds the following capabilities to usbaudio.c:
- Merges support for M-Audio FastTrack USB
- Adds proper support for M-Audio Quattro USB
- Adds hot-reload support for all Audiophile, FastTrack and Quattro.
- FastTrack "select configuration #2" quirk is present but #ifdef'd out pending inclusion of "usb_driver_set_configuration" function in mainline kernel. This quirk could possibly be handled in user space anyway.

usb_driver_set_configuration() is already in mainline (2.6.19). So, no need to disable it. If you need to disable it for older version, modify usbaudio.patch in alsa-driver tree, or add a dummy wrapper in alsa-driver/include/adriver.h.

Quoted 8 lines

diff -r 6f81f7397f82 -r d447f5a178f0 usb/usbaudio.c

usb/usbaudio.c +0 -1
@@ -2346,11 +2346,16 @@ static int is_big_endian_format(struct s
 {
 	switch (chip->usb_id) {
 	case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */
-		if (fp->endpoint & USB_DIR_IN)

usb/usbaudio.c static int is_big_endian_format(struct s · line 2356

Quoted 10 lines
usb/usbaudio.c +6 -2
-			return 1;
-		break;
 	case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
 		return 1;
+
+ 	case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro */
+ 		/* it depends on altsetting wether the device is big-endian or not */
+ 		if(fp->altsetting==2 || fp->altsetting==3 ||
+ 		   fp->altsetting==5 || fp->altsetting==6)
+ 			return 1;

Minor coding-style fixes:
Put a space between if and (. Also, put spaces around '==', too.

Quoted 14 lines
usb/usbaudio.c +10 -0
@@ -3175,44 +3195,140 @@ static int snd_usb_cm106_boot_quirk(stru
 	return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
 }
 
+static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev, int ifnum)
+{
+#if 0
+    int err;
+
+    if(dev->actconfig->desc.bConfigurationValue==1) {
+	if(ifnum==0) {
+	    snd_printk(KERN_INFO "Switching to config #2\n");
+	    /* This function has to be available by the usb core module.
+	       if it is not avialable the boot quirk has to be left out and the

usb/usbaudio.c static int snd_usb_cm106_boot_quirk(stru · line 3217

Quoted 10 lines
usb/usbaudio.c +10 -0
+	       configuration has to be set by udev or hotplug rules */
+	    err=usb_driver_set_configuration(dev,2);
+	    if(err < 0) {
+		snd_printdd("error usb_driver_set_configuration: %d\n", err);
+		return -ENODEV;
+	    }
+	}
+    } else {
+	snd_printk(KERN_INFO "Fast Track Pro config OK\n");
+    }

Please use indent level 8.

Quoted 9 lines

Otherwise, the patch looks fine to me.
Thibault, does it work for your device (at least no regression)?

thanks,

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#4 lore raw
Quoted 2 lines · Peter Oehry

- Sometimes the device gets messed up. In this state ther is a complete mess in 24-Bit mode and chagned byte-Order for 16-Bit. These problems are not reproduceable.

This happens if "0" (enable all altsettings) parameter is specified. "Complete mess in 24bit mode" is the state when the driver thinks the device is in 24bit, but it's in fact in 16 bit. The fact that "changed byte-order" happens at all, suggests that the device IS capable of little-endian, but we don't know how to switch it. Must be some undocumented device parameter - it might be possible to reverse-engineer it by monitoring Windows driver, but I don't know how to do it :-(

Quoted 3 lines

- Changing the device_setup without resetting the device will mostly not work.
- The device seems to switch the sampling rate of inputs only after initialising an ouput with the same sampling rate.

These tow seem to be the problem with FastTrack part of the patch ONLY. The reason is very simple: while Omni and Audiophile select only ONE altsetting for each driver configuration, FastTrack selects 2. If the patch is re-worked to only allow ONE altsetting per device_config, these problems will most likely go away.

Why these problems happen: during the init sequence, the driver goes through all altsettings, then SELECTS every one of them. This selection is OK for most USB-Audio devices, but not for M-Audio. Selecting an altsetting for any of its interfaces automatically switches ALL interfaces to this mode, and subsequent selection of another altsetting of a different interface turns the device into a non-working (sometimes recoverable, sometimes not) state.

Quoted 2 lines

To solve these problems I'll need a lot more time. Maybe I have to go back to investigate the behaviour of the windows driver.

Please send me some info how can I log the Windows USB activity, I wanna try to experiment with this

Quoted 3 lines

Summary:
- The driver works with the FastTrack but is way of to be a stable and final solution.

Here's a new proposal.
Retire the "device_setup=MODE", where MODE is a bitmap of available sample rates and/or resolutions. Every device uses DIFFERENT altsettings for different combinations, it would be too burdensome to keep track of all the devices that require this hack and specifically add support for each one of them (and they will NOT work without this!) Instead, add parameter "force_altsetting=NUMBER", which will apply to ANY device if specified. It will skip all altsettings instead of the selected one. It will be a matter of documentation for each M-Audio device to describe what each of these altsettings does. It would be possible to make any other M-Audio device work without patching the driver even further, just an exercise for the user to call the driver with each altsetting separately, figure out what it does and update the documentation. Also, the patch would be rather smaller.

Let me know what you think. I'll make the patch that implements this approach shortly.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#5 lore raw

Hi Pavel,

Quoted 7 lines
Quoted 1 line

To solve these problems I'll need a lot more time. Maybe I

have to go

Quoted 2 lines

back to investigate the behaviour of the windows driver.

Please send me some info how can I log the Windows USB activity, I wanna
try to experiment with this

I've used:
* the trial version of USBmonitor
http://www.hhdsoftware.com/Downloads/usb-monitor.html
* Or the free usbsnoop
http://benoit.papillault.free.fr/usbsnoop/doc.php.en

HTH,
Thibault

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#6 lore raw
In reply to Pavel Polischouk
Quoted 11 lines

Here's a new proposal.
Retire the "device_setup=MODE", where MODE is a bitmap of available sample rates and/or resolutions. Every device uses DIFFERENT altsettings
for different combinations, it would be too burdensome to keep track of
all the devices that require this hack and specifically add support for
each one of them (and they will NOT work without this!)

Disagree on the last sentence (should read "will NOT *completely* work"), but this is a detail ;-) (see my last post)

Quoted 9 lines

Instead, add parameter "force_altsetting=NUMBER", which will apply to ANY device if specified. It will skip all altsettings instead of the selected one. It will be a matter of documentation for each M-Audio device to describe what each of these altsettings does. It would be possible to make any other M-Audio device work without patching the driver even further, just an exercise for the user to call the driver with each altsetting separately, figure out what it does and update the
documentation. Also, the patch would be rather smaller.

Agree, after re-reading the audiophile usb modes and AltSettings, this should work for this device and will, as you said, be easier to implement and maintain.

We would, however, need Clemens Ladisch or Takashi's point of view on this, since we'll add a param that will potentially affect any usb device.

Thibault

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#7 lore raw
In reply to Pavel Polischouk

Re-posting, because I haven't seen my post appear in the list.

Quoted 6 lines
Quoted 6 lines

de Pavel Polischouk
Envoyé : vendredi 24 novembre 2006 05:36
À : [email protected]
Objet : [Alsa-devel] [PATCH 1.0.13 1/2] M-Audio USB

Quoted 6 lines
Quoted 6 lines

This patch adds the following capabilities to usbaudio.c:
- Merges support for M-Audio FastTrack USB
- Adds proper support for M-Audio Quattro USB
- Adds hot-reload support for all Audiophile, FastTrack and Quattro.

Thibault, could you please verify that it works for Audiophile?

Sorry for the delay but I had to re-install my linux system from scratch...

Here is my test report:

Summary
=======

With this patch it is now possible to switch the Sample depth/rate modes without having to turn the device off and then on again.

However, it does not correct the corrupted initialization state that occur when the device is turned on before the snd-usb-audio module is initialized with a valid device_setup parameter (see below).

Tests
=====

A- This test shows that the module must still be correctly initialized
before turning on the device

* turn on the device with no specific snd-usb-audio parameters (equivalent to device_setup = 0x00)
* the sound captured from the Analog interface is corrupted (as described in https://bugtrack.alsa-project.org/alsa-bug/view.php?id=1801)
* unregister the snd-usb-audio interface
* register the snd-usb-audio interface with device_setup=0x09
* the sound captured from the Analog interface is still corrupted
* turning the device off, then on again gets back to a working analog capture interface

B- This test shows that once correctly initialized, it is now possible to switch modes without having to turn off the device

* the device is turned on after having initialized the snd-usb-audio driver with a valid device_setup parameter (for instance 24bits with no digital Input)

    # modprobe -r snd-usb-audio
    # modprobe snd-usb-audio device_setup=0x09

==> arecord and aplay on the analog interface work fine in 24 bits mode.

* It is then possible to switch mode without having to turn off the device. For instance swicthing from 24bits to 16 bits (without Digital Input) with the following commands make the analog capture interface work in 16bits mode.

    # modprobe -r snd-usb-audio
    # modprobe snd-usb-audio device_setup=0x01

==> arecord and aplay on the analog interface work fine in 16 bits mode.

Documentation
=============

As far as the documentation is concerned, shouldn't it be better to keep an Audiophile-USB.txt file with only the following sentence: "Updated documentation on this device can now be found in the M-Audio.txt file" ?

This could be useful for people finding references to the Audiophile-USB.txt file in mailing-lists or forums or Alsa bug-tracker, ...

Regards,
Thibault

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#8 lore raw
Quoted 4 lines · Thibault Le Meur

However, it does not correct the corrupted initialization state that occur when the device is turned on before the snd-usb-audio module is initialized with a valid device_setup parameter (see below).

There are 2 reasons for this:
1. The default setting "0" will immediately make the device stuck in a weird semi-working mode. Avoid. I'll add a check to the next patch revision that will REFUSE to load the driver for M-Audio unless a valid setup parameter is specified. Another approach would be to use a mixer control to select available configuration (with the default of NONE).
2. If you're using a daemon that loads USB drivers automatically, it will always load using "default" setting. If a valid device_setup parameter is added to /etc/modprobe.conf, it will be possible to turn on the device before initializing the driver.

Quoted 5 lines

As far as the documentation is concerned, shouldn't it be better to keep an Audiophile-USB.txt file with only the following sentence: "Updated documentation on this device can now be found in the M-Audio.txt file" ?

Agreed.
Also, I will update the JACK info. Current version can work natively with 24bit big-endian interfaces, and also works fine with Quattro in 4-channel input mode.

Another problem that I found with Quattro. The driver works fine in 24/96k mode, no underruns. But in 44k/48k modes, it's always giving me JACK xruns, or just skips in arecord, even with the most forgiving JACK settings (high realtime priority and big buffers). This looks counter-intuitive, that the slower mode performs worse than faster one. Could it be that the driver reserves not enough USB bandwidth from hardware, or something similar? What settings could be changed to try to correct this?

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#9 lore raw
Quoted 18 lines

-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de Pavel Polischouk
Envoyé : vendredi 15 décembre 2006 04:36
À : [email protected]
Objet : Re: [Alsa-devel] [PATCH 1/2] M-Audio USB

Quoted 1 line · Thibault Le Meur

However, it does not correct the corrupted initialization

state that

Quoted 1 line

occur when the device is turned on before the snd-usb-audio

module is

Quoted 2 lines

initialized with a valid device_setup parameter (see below).

Quoted 7 lines

There are 2 reasons for this:
1. The default setting "0" will immediately make the device stuck in a
weird semi-working mode. Avoid. I'll add a check to the next patch revision that will REFUSE to load the driver for M-Audio unless a valid
setup parameter is specified.

This would break backward compatibility!
I know several current users of M-Audio devices that are happy with the current behaviour of the driver (without any device_setup param): mainly because they are using the SPDIF interface which doesn't have the issues we are dealing with here.
If we do this, the driver upgrade won't be transparent for them!

Quoted 4 lines

Another approach would be to
use a mixer
control to select available configuration (with the default of NONE).

This sounds better, but may require more work.

Quoted 6 lines

2. If you're using a daemon that loads USB drivers automatically, it
will always load using "default" setting. If a valid device_setup parameter is added to /etc/modprobe.conf, it will be possible to turn on
the device before initializing the driver.

Sure, that's what I do, but I wanted to do the tests from a clean system that would reflect most users' setup.

Quoted 7 lines
Quoted 2 lines

As far as the documentation is concerned, shouldn't it be better to keep an Audiophile-USB.txt file with only the following

sentence: "Updated

Quoted 3 lines

documentation on this device can now be found in the M-Audio.txt file" ?

Agreed.

Great.

Quoted 5 lines

Also, I will update the JACK info. Current version can work natively with 24bit big-endian interfaces, and also works fine with Quattro in
4-channel input mode.

Interresting, I wasn't able to have this setup wokring for the Audiophile. Are you using the 4-channel input at the same time as a playback interface (in Full-Duplex) ? Because I think there was a patch to be applied to Alsa to enable Full-Duplex mode with Multi interfaces... Or has it been included in current ALSA release ?

Quoted 6 lines

Another problem that I found with Quattro. The driver works fine in 24/96k mode, no underruns. But in 44k/48k modes, it's always giving me
JACK xruns, or just skips in arecord, even with the most forgiving JACK
settings (high realtime priority and big buffers).

Very strange, I don't think I've seen such issue with teh audiophile usb device.
I'll try to test this.

Quoted 7 lines

This looks
counter-intuitive, that the slower mode performs worse than faster one.
Could it be that the driver reserves not enough USB bandwidth from hardware, or something similar? What settings could be changed to try to
correct this?

No Idea... Sorry.

Thibault

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV