Skip to contentSkip to conversation

Audiophile USB samplerate workaround

DISCUSSION Ben Saylor 2 participants 8 messages Jul 23, 2003 – Jul 24, 2003

lore
Share & tools
lore

Ben Saylor

author
#0 lore raw

I did some investigation to find out why the sample rate can't be set to anything but 48khz (or rather, remains 48khz even if it is set to something else) on the Audiophile.

In init_usb_sample_rate(),

	if (fmt->attributes & EP_CS_ATTR_SAMPLE_RATE)

is never true, so the sample rate is not set. If I just make it if(1) the sample rate is settable. Is this a hardware bug or something else?

Ben

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

#1 lore raw

At Tue, 22 Jul 2003 22:59:25 -0800,

Quoted 4 lines · Ben Saylor

I did some investigation to find out why the sample rate can't be set to anything but 48khz (or rather, remains 48khz even if it is set to something else) on the Audiophile.

does format descriptor contain other sample rates?

Quoted 4 lines

In init_usb_sample_rate(),

	if (fmt->attributes & EP_CS_ATTR_SAMPLE_RATE)

is never true, so the sample rate is not set. If I just make it if(1) the sample rate is settable. Is this a hardware bug or something else?

then the format descriptor might be bogus.

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

author
#2 lore raw
Quoted 8 lines · you

At Tue, 22 Jul 2003 22:59:25 -0800,

Quoted 3 lines · Ben Saylor

I did some investigation to find out why the sample rate can't be set to anything but 48khz (or rather, remains 48khz even if it is set to something else) on the Audiophile.

does format descriptor contain other sample rates?

In parse_audio_format_rates(), nr_rates is always 0 (continuous). /proc/asound/card0/stream{0,1} reflect the same. Most of the altsets are 8000-48000 continuous. I hope that's a meaningful answer. :)

Quoted 10 lines
Quoted 5 lines

In init_usb_sample_rate(),

	if (fmt->attributes & EP_CS_ATTR_SAMPLE_RATE)

is never true, so the sample rate is not set. If I just make it if(1) the sample rate is settable. Is this a hardware bug or something else?

then the format descriptor might be bogus.

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

#3 lore raw

At Wed, 23 Jul 2003 01:02:19 -0800,

Quoted 9 lines · Ben Saylor
Quoted 7 lines · you

At Tue, 22 Jul 2003 22:59:25 -0800,

Quoted 3 lines · Ben Saylor

I did some investigation to find out why the sample rate can't be set to anything but 48khz (or rather, remains 48khz even if it is set to something else) on the Audiophile.

Quoted 5 lines
Quoted 1 line

does format descriptor contain other sample rates?

In parse_audio_format_rates(), nr_rates is always 0 (continuous). /proc/asound/card0/stream{0,1} reflect the same. Most of the altsets are 8000-48000 continuous. I hope that's a meaningful answer. :)

ok, then it supports other sample rates :)

about the symptom: do you mean that the playback gets too fast with the lower sample rate, or the driver doesn't accept anything else 48k?

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

author
#4 lore raw
Quoted 4 lines

ok, then it supports other sample rates :)

about the symptom: do you mean that the playback gets too fast with the lower sample rate,

Yes. i.e. it will play a 44100 hz or whatever stream, but playback is too fast.

Quoted 5 lines

or the driver doesn't accept anything else
48k?

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

#5 lore raw

At Wed, 23 Jul 2003 02:05:50 -0800,

Quoted 8 lines · Ben Saylor
Quoted 5 lines

ok, then it supports other sample rates :)

about the symptom: do you mean that the playback gets too fast with the lower sample rate,

Yes. i.e. it will play a 44100 hz or whatever stream, but playback is too fast.

so apparently we need some workaround (as found below line 2291 of usbaudio.c).
please try to check the product and vendor id and set

	fp->attribtes |= EP_CS_ATTR_SAMPLERATE

with that condition.
if it works, please give me the patch.

thanks,

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

author
#6 lore raw

That does the trick. Here's a patch against 0.9.5.

I don't know if this is related, but one thing I've been puzzling over is that half the time after I plug in the audiophile I get static instead of sound. I have to unload alsa and plug it in again. (As I mentioned before, I always get static if I load the alsa modules explicitly).

Ben

Quoted 14 lines · Takashi Iwai

At Wed, 23 Jul 2003 02:05:50 -0800,

Quoted 7 lines · Ben Saylor
Quoted 4 lines

ok, then it supports other sample rates :)

about the symptom: do you mean that the playback gets too fast with the lower sample rate,

Yes. i.e. it will play a 44100 hz or whatever stream, but playback is too fast.

so apparently we need some workaround (as found below line 2291 of usbaudio.c).
please try to check the product and vendor id and set

Quoted 8 lines
	fp->attribtes |= EP_CS_ATTR_SAMPLERATE

with that condition.
if it works, please give me the patch.

thanks,

Takashi

alsa-kernel/usb/usbaudio.c +13 -5
@@ -2295,6 +2295,14 @@
 			 */
 			fp->attributes &= ~EP_CS_ATTR_SAMPLE_RATE;
 		}
+
+		/* workaround for M-Audio Audiophile USB */
+		if (dev->descriptor.idVendor == 0x0763 &&
+		    dev->descriptor.idProduct == 0x2003) {
+			/* doesn't set the sample rate attribute, but supports it */
+			fp->attributes |= EP_CS_ATTR_SAMPLE_RATE;
+		}
+
 		/*
 		 * plantronics headset and Griffin iMic have set adaptive-in
 		 * although it's really not...
@@ -2695,11 +2703,6 @@
 	if (quirk && quirk->ifnum != QUIRK_ANY_INTERFACE && ifnum != quirk->ifnum)
 		goto __err_val;
 
-	if (usb_set_configuration(dev, get_cfg_desc(config)->bConfigurationValue) < 0) {
-		snd_printk(KERN_ERR "cannot set configuration (value 0x%x)\n", get_cfg_desc(config)->bConfigurationValue);
-		goto __err_val;
-	}
-
 	/* SB Extigy needs special boot-up sequence */
 	/* if more models come, this will go to the quirk list. */
 	if (dev->descriptor.idVendor == 0x041e && dev->descriptor.idProduct == 0x3000) {
@@ -2729,6 +2732,11 @@
 		/* it's a fresh one.
 		 * now look for an empty slot and create a new card instance
 		 */
+		if (usb_set_configuration(dev, get_cfg_desc(config)->bConfigurationValue) < 0) {
+			snd_printk(KERN_ERR "cannot set configuration (value 0x%x)\n", get_cfg_desc(config)->bConfigurationValue);
+			goto __err_val;
+		}
+
 		for (i = 0; i < SNDRV_CARDS; i++)
 			if (enable[i] && ! usb_chip[i] &&
 			    (vid[i] == -1 || vid[i] == dev->descriptor.idVendor) &&
#7 lore raw

At Wed, 23 Jul 2003 13:14:03 -0800,

Quoted 3 lines · Ben Saylor

[1 <text/plain; iso-8859-1 (7bit)>]
That does the trick. Here's a patch against 0.9.5.

thanks for the patch.
i applied to cvs.

Quoted 5 lines

I don't know if this is related, but one thing I've been puzzling over is that half the time after I plug in the audiophile I get static instead of sound. I have to unload alsa and plug it in again. (As I mentioned before, I always get static if I load the alsa modules explicitly).

i don't know exactly what is the cause here, too...

Takashi

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01