All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] M-Audio USB
@ 2006-11-24 20:26 Pavel Polischouk
  2006-11-27 11:15 ` Takashi Iwai
  2006-12-03 20:55 ` Thibault Le Meur
  0 siblings, 2 replies; 10+ messages in thread
From: Pavel Polischouk @ 2006-11-24 20:26 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 29 bytes --]

Re-send, "hg export" format


[-- Attachment #2: maudio.patch --]
[-- Type: text/plain, Size: 9722 bytes --]

# HG changeset patch
# User Pavel Polischouk <pavelvp@inbox.ru>
# 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.

diff -r 6f81f7397f82 -r d447f5a178f0 usb/usbaudio.c
--- a/usb/usbaudio.c	Fri Nov 24 11:50:29 2006 -0500
+++ b/usb/usbaudio.c	Fri Nov 24 13:19:10 2006 -0500
@@ -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
 	 */


[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
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

[-- Attachment #4: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] M-Audio USB
  2006-11-24 20:26 [PATCH 1/2] M-Audio USB Pavel Polischouk
@ 2006-11-27 11:15 ` Takashi Iwai
  2006-11-27 11:18   ` Takashi Iwai
  2006-12-03 22:42   ` Peter Oehry
  2006-12-03 20:55 ` Thibault Le Meur
  1 sibling, 2 replies; 10+ messages in thread
From: Takashi Iwai @ 2006-11-27 11:15 UTC (permalink / raw)
  To: Pavel Polischouk; +Cc: alsa-devel, Thibault Le Meur

At Fri, 24 Nov 2006 15:26:42 -0500,
Pavel Polischouk wrote:
> 
> Re-send, "hg export" format

Thanks, this time the patch is intact.

> [2 maudio.patch <text/plain (7bit)>]
> # HG changeset patch
> # User Pavel Polischouk <pavelvp@inbox.ru>
> # 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_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.


> diff -r 6f81f7397f82 -r d447f5a178f0 usb/usbaudio.c
> --- a/usb/usbaudio.c	Fri Nov 24 11:50:29 2006 -0500
> +++ b/usb/usbaudio.c	Fri Nov 24 13:19:10 2006 -0500
> @@ -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;

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


> @@ -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");
> +    }

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] M-Audio USB
  2006-11-27 11:15 ` Takashi Iwai
@ 2006-11-27 11:18   ` Takashi Iwai
  2006-12-03 22:42   ` Peter Oehry
  1 sibling, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2006-11-27 11:18 UTC (permalink / raw)
  To: Pavel Polischouk; +Cc: alsa-devel

At Mon, 27 Nov 2006 12:15:51 +0100,
I wrote:
> 
> At Fri, 24 Nov 2006 15:26:42 -0500,
> Pavel Polischouk wrote:
> > 
> > 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] M-Audio USB
  2006-11-24 20:26 [PATCH 1/2] M-Audio USB Pavel Polischouk
  2006-11-27 11:15 ` Takashi Iwai
@ 2006-12-03 20:55 ` Thibault Le Meur
  2006-12-15  3:36   ` Pavel Polischouk
  1 sibling, 1 reply; 10+ messages in thread
From: Thibault Le Meur @ 2006-12-03 20:55 UTC (permalink / raw)
  To: alsa-devel

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

>> de Pavel Polischouk
>> Envoyé : vendredi 24 novembre 2006 05:36
>> À : alsa-devel@lists.sourceforge.net
>> Objet : [Alsa-devel] [PATCH 1.0.13 1/2] M-Audio USB
>>
>>
>> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] M-Audio USB
  2006-11-27 11:15 ` Takashi Iwai
  2006-11-27 11:18   ` Takashi Iwai
@ 2006-12-03 22:42   ` Peter Oehry
  2006-12-15  3:10     ` Pavel Polischouk
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Oehry @ 2006-12-03 22:42 UTC (permalink / raw)
  To: Pavel Polischouk; +Cc: alsa-devel

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


On Mon, 27 Nov 2006 12:15:51 +0100
Takashi Iwai <tiwai@suse.de> wrote:

> At Fri, 24 Nov 2006 15:26:42 -0500,
> Pavel Polischouk wrote:
> > 
> > Re-send, "hg export" format
> 
> Thanks, this time the patch is intact.
> 
> > [2 maudio.patch <text/plain (7bit)>]
> > # HG changeset patch
> > # User Pavel Polischouk <pavelvp@inbox.ru>
> > # 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_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.
> 
> 
> > diff -r 6f81f7397f82 -r d447f5a178f0 usb/usbaudio.c
> > --- a/usb/usbaudio.c	Fri Nov 24 11:50:29 2006 -0500
> > +++ b/usb/usbaudio.c	Fri Nov 24 13:19:10 2006 -0500
> > @@ -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;
> 
> Minor coding-style fixes:
>  Put a space between if and (.  Also, put spaces around '==', too.
> 
> 
> > @@ -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");
> > +    }
> 
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] M-Audio USB
  2006-12-03 22:42   ` Peter Oehry
@ 2006-12-15  3:10     ` Pavel Polischouk
  2006-12-15  8:42       ` RE : " Thibault Le Meur
  2006-12-15  9:25       ` Thibault Le Meur
  0 siblings, 2 replies; 10+ messages in thread
From: Pavel Polischouk @ 2006-12-15  3:10 UTC (permalink / raw)
  Cc: alsa-devel

Peter Oehry wrote:
> - 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 :-(
> - 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.

> 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
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] M-Audio USB
  2006-12-03 20:55 ` Thibault Le Meur
@ 2006-12-15  3:36   ` Pavel Polischouk
  2006-12-15  8:55     ` RE : " Thibault Le Meur
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Polischouk @ 2006-12-15  3:36 UTC (permalink / raw)
  To: alsa-devel

Thibault Le Meur wrote:
> 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.
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE :  [PATCH 1/2] M-Audio USB
  2006-12-15  3:10     ` Pavel Polischouk
@ 2006-12-15  8:42       ` Thibault Le Meur
  2006-12-15  9:25       ` Thibault Le Meur
  1 sibling, 0 replies; 10+ messages in thread
From: Thibault Le Meur @ 2006-12-15  8:42 UTC (permalink / raw)
  To: 'Pavel Polischouk'; +Cc: alsa-devel

Hi Pavel,

> > 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

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE :  [PATCH 1/2] M-Audio USB
  2006-12-15  3:36   ` Pavel Polischouk
@ 2006-12-15  8:55     ` Thibault Le Meur
  0 siblings, 0 replies; 10+ messages in thread
From: Thibault Le Meur @ 2006-12-15  8:55 UTC (permalink / raw)
  To: 'Pavel Polischouk', alsa-devel



> -----Message d'origine-----
> De : alsa-devel-bounces@lists.sourceforge.net 
> [mailto:alsa-devel-bounces@lists.sourceforge.net] De la part 
> de Pavel Polischouk
> Envoyé : vendredi 15 décembre 2006 04:36
> À : alsa-devel@lists.sourceforge.net
> Objet : Re: [Alsa-devel] [PATCH 1/2] M-Audio USB
> 
> 
> Thibault Le Meur wrote:
> > 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.

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! 

> 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.

> 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.

> > 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.

Great.

> 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 ?

> 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.

> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE :  [PATCH 1/2] M-Audio USB
  2006-12-15  3:10     ` Pavel Polischouk
  2006-12-15  8:42       ` RE : " Thibault Le Meur
@ 2006-12-15  9:25       ` Thibault Le Meur
  1 sibling, 0 replies; 10+ messages in thread
From: Thibault Le Meur @ 2006-12-15  9:25 UTC (permalink / raw)
  To: 'Pavel Polischouk'; +Cc: alsa-devel


 
> 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)
 
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-12-15  9:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-24 20:26 [PATCH 1/2] M-Audio USB Pavel Polischouk
2006-11-27 11:15 ` Takashi Iwai
2006-11-27 11:18   ` Takashi Iwai
2006-12-03 22:42   ` Peter Oehry
2006-12-15  3:10     ` Pavel Polischouk
2006-12-15  8:42       ` RE : " Thibault Le Meur
2006-12-15  9:25       ` Thibault Le Meur
2006-12-03 20:55 ` Thibault Le Meur
2006-12-15  3:36   ` Pavel Polischouk
2006-12-15  8:55     ` RE : " Thibault Le Meur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.