From: Thibault Le Meur <Thibault.LeMeur@supelec.fr>
To: "Lasse Kärkkäinen" <tronic+8nhy@trn.iki.fi>
Cc: peter.oehry@gmx.li, alsa-devel@alsa-project.org
Subject: Re: [usb-audio] M-Audio FastTrack Pro giving invalid sample rates
Date: Wed, 28 Nov 2007 10:33:57 +0100 [thread overview]
Message-ID: <474D3605.5010800@supelec.fr> (raw)
In-Reply-To: <474CBC60.9090408@trn.iki.fi>
[-- Attachment #1: Type: text/plain, Size: 6572 bytes --]
Lasse Kärkkäinen a écrit :
> Resending because nobody reacted the last time. This is still broken
> with 2.6.23.1, except for the fact that it doesn't seem to be possible
> to adjust bConfigurationValue anymore (this is not exposed under sysfs
> at least on my system), so I am stuck with configuration 1.
>
Peter Oehry once proposed a fix for this device and I think it is not
applied to HG yet (but I may be wrong): see thread "snd-usb-audio -
Driver for M-Audio Fast Track Pro".
The proposed patch is attached: I don't know if it would fix the issue
you're describing.
But one interesting comment may explain why it may have not been applied:
<quote>
+» » » /*·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);
</quote>
I don't have this device and can't help more than that, sorry.
HTH,
Thibault
> Original message follows:
>
>
> This bug has been around for years...
>
> ALSA seems to think that the card supports a wide range of sampling
> rates, but it does not manage to set them in practice. I do not know
> which is faulty, ALSA rate setting or the USB info sent by the device,
> but the problem needs to be fixed.
>
> I did some measurements with the alsarate program, attached to my other
> post (subject: ALSA C++ API).
>
> Using bConfigurationValue=1 and measuring the actual rate with alsarate,
> I get
>
>
>>>> Testing playback
>>>>
> Opening ALSA device hw:0,1 at 44100 Hz.
> Got 44100 Hz, 2 channels, period 1.02 ms.
> 96.27 seconds, measured rate 45807 Hz.
>
>>>> Testing capture
>>>>
> Opening ALSA device hw:0,1 at 44100 Hz.
> Got 44100 Hz, 2 channels, period 1.02 ms.
> 97.29 seconds, measured rate 45330 Hz.
>
> As expected, 44.1 kHz works. The measured rate seems a bit higher than
> it should be, but I assume that this is an alsarate inaccuracy rather
> than an actual phenomenon.
>
>
>>>> Testing playback
>>>>
> Opening ALSA device hw:0,1 at 48000 Hz.
> Got 44100 Hz, 2 channels, period 1 ms.
> 96.27 seconds, measured rate 45808 Hz.
>
>>>> Testing capture
>>>>
> Opening ALSA device hw:0,1 at 48000 Hz.
> Got 48000 Hz, 2 channels, period 1 ms.
> 105.89 seconds, measured rate 45330 Hz.
>
> Using 48 kHz for playback is not possible, the
> snd_pcm_hw_params_rate_near returns a new rate of 44.1 kHz. This is all
> fine and the measured rate still is around 44.1 kHz as it should.
>
> In the capture part, we see the first problem: rate_near returned 48
> kHz, but the measured value hasn't changed. So, the application thinks
> that it is recording at 48 kHz, but ALSA only gives it data at 44.1 kHz.
> This is a bug in ALSA.
>
>
>>>> Testing playback
>>>>
> Opening ALSA device hw:0,1 at 8000 Hz.
> Got 44100 Hz, 2 channels, period 1.02 ms.
> 96.27 seconds, measured rate 45808 Hz.
>
>>>> Testing capture
>>>>
> Opening ALSA device hw:0,1 at 8000 Hz.
> Got 8000 Hz, 2 channels, period 2 ms.
> 17.66 seconds, measured rate 45309 Hz.
>
> Trying to use 8 kHz yields similar results to the 48 kHz test. No
> problems with playback, but the capture part reports that it is using 8
> kHz, even though it really uses 44.1 kHz.
>
>
>>>> Testing playback
>>>>
> Opening ALSA device hw:0,1 at 96000 Hz.
> Got 44100 Hz, 2 channels, period 1.02 ms.
> 96.27 seconds, measured rate 45808 Hz.
>
>>>> Testing capture
>>>>
> Opening ALSA device hw:0,1 at 96000 Hz.
> Got 48000 Hz, 2 channels, period 1 ms.
> 105.89 seconds, measured rate 45330 Hz.
>
> 96 kHz makes little difference. Now the capture rate is reported to be
> 48 kHz, but the actual rates are still always 44.1 kHz.
>
>
> That was all done using the default configuration. When using the other
> configuration, bConfigurationValue=2, the following results are gathered:
>
>
>>>> Testing playback
>>>>
> Opening ALSA device hw:0,1 at 44100 Hz.
> Got 44100 Hz, 2 channels, period 1.02 ms.
> 96.27 seconds, measured rate 45808 Hz.
>
>>>> Testing capture
>>>>
> Opening ALSA device hw:0,1 at 44100 Hz.
> Got 44100 Hz, 2 channels, period 1.02 ms.
> 97.29 seconds, measured rate 45330 Hz.
>
> 44.1 kHz is identical to that in the other configuration.
>
>
>>>> Testing playback
>>>>
> Opening ALSA device hw:0,1 at 48000 Hz.
> Got 48000 Hz, 2 channels, period 1 ms.
> 96.29 seconds, measured rate 49849 Hz.
>
>>>> Testing capture
>>>>
> Opening ALSA device hw:0,1 at 48000 Hz.
> Got 48000 Hz, 2 channels, period 1 ms.
> 97.29 seconds, measured rate 49339 Hz.
>
> 48 kHz now works properly for both playback and capture (note: measured
> rate over 49 kHz, but the measurements displaying about 1.5 kHz too high
> is consistent).
>
>
>>>> Testing playback
>>>>
> Opening ALSA device hw:0,1 at 8000 Hz.
> Got 8000 Hz, 2 channels, period 2 ms.
> 15.89 seconds, measured rate 50336 Hz.
>
>>>> Testing capture
>>>>
> Opening ALSA device hw:0,1 at 8000 Hz.
> Got 8000 Hz, 2 channels, period 2 ms.
> 16.22 seconds, measured rate 49313 Hz.
>
> 8 kHz still doesn't work. ALSA reports that it does, but in reality
> gives 48 kHz (within the bounds of the measurement accuracy).
>
>
>>>> Testing playback
>>>>
> Opening ALSA device hw:0,1 at 96000 Hz.
> Got 48000 Hz, 2 channels, period 1 ms.
> 96.29 seconds, measured rate 49849 Hz.
>
>>>> Testing capture
>>>>
> Opening ALSA device hw:0,1 at 96000 Hz.
> Got 48000 Hz, 2 channels, period 1 ms.
> 97.29 seconds, measured rate 49339 Hz.
>
> 96 kHz works kinda like it should, except for the fact that the hardware
> should support that rate as well.
>
>
> Summa summarum:
>
> Config 1 only uses 44.1 kHz, but claims to support 8-48 kHz on capture.
> Config 2 only uses 44.1 and 48 kHz, but claims to support 8-48 kHz on
> both capture and playback.
>
> The card in reality, according to specs, supports up to 96 kHz.
> According to lspci (attached), it supports everything within the 8-96
> kHz range.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
[-- Attachment #2: FastTrackPro.patch --]
[-- Type: text/x-patch, Size: 3530 bytes --]
diff -urN alsa-driver-1.0.12rc3/alsa-kernel/usb/usbaudio.c alsa-driver-1.0.12rc3_patch/alsa-kernel/usb/usbaudio.c
--- alsa-driver-1.0.12rc3/alsa-kernel/usb/usbaudio.c 2006-08-14 12:55:28.000000000 +0200
+++ alsa-driver-1.0.12rc3_patch/alsa-kernel/usb/usbaudio.c 2006-08-20 12:46:30.000000000 +0200
@@ -2306,7 +2306,15 @@
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;
}
@@ -2551,6 +2559,8 @@
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;
@@ -2592,6 +2602,11 @@
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 */
fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, AS_GENERAL);
if (!fmt) {
@@ -3118,6 +3133,28 @@
return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
}
+static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev, int ifnum)
+{
+ 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");
+ }
+
+ return 0;
+}
/*
* Setup quirks
@@ -3159,6 +3196,39 @@
return 0; /* keep this altsetting */
}
+static int fasttrackpro_skip_setting_quirk(struct snd_usb_audio *chip,
+ int iface, int altno)
+{
+
+ /* possible configuration where both inputs and only one output is
+ used is not supported by the current setup */
+
+ if (device_setup[chip->index] & (AUDIOPHILE_SET | AUDIOPHILE_SET_24B)) {
+ if(device_setup[chip->index] & AUDIOPHILE_SET_96K){
+ if((altno != 3) && (altno != 6))
+ return 1;
+ }else if(device_setup[chip->index] & AUDIOPHILE_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;
+ }
+
+ return 0; /* keep this altsetting */
+}
+
/*
* audio-interface quirks
*
@@ -3394,6 +3464,12 @@
if (snd_usb_cm106_boot_quirk(dev) < 0)
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: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2007-11-28 9:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-28 0:54 [usb-audio] M-Audio FastTrack Pro giving invalid sample rates Lasse Kärkkäinen
2007-11-28 9:27 ` Clemens Ladisch
2007-11-28 9:33 ` Thibault Le Meur [this message]
2007-11-28 23:01 ` Peter Oehry
-- strict thread matches above, loose matches on Subject: below --
2007-09-09 6:21 Lasse Kärkkäinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=474D3605.5010800@supelec.fr \
--to=thibault.lemeur@supelec.fr \
--cc=alsa-devel@alsa-project.org \
--cc=peter.oehry@gmx.li \
--cc=tronic+8nhy@trn.iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.