Skip to contentSkip to conversation

[PATCH - Fix Fast Track Ultra series: 44.1/88.1 kHz 1/Fix playback/capture issues and related chrashes at 44100 Hz and 88200 Hz for M-Audio Fast Track Ultra series.

PATCH Felix Homann 5 participants 24 messages Jul 6, 2010 – Sep 3, 2010 Sound

lore
Share & tools
lore
#0 lore raw

This fixes issues with M-Audio's Fast Track Ultra series:

* devices now work at 44100 and 88200 Hz
* apparently, fixes some crashes, too

This is based on a patch posted by user 'dhubsith' on the M-Audio user forum.

Sorry for not sending via 'git send-email': I just don't get it...

Kind regards,

Felix

Quoted 1 line

From 57cd7afd0b0fbccd80acab16e617cf8a844e37d1 Mon Sep 17 00:00:00 2001

From: Felix <[email protected]>
Date: Tue, 6 Jul 2010 09:16:17 +0200
Subject: [PATCH - Fix Fast Track Ultra series: 44.1/88.1 kHz 1/Fix playback/capture issues and related chrashes at 44100 Hz and 88200 Hz for M-Audio Fast Track Ultra series.

usb/endpoint.c +0 -2
index 1a701f1..bb9f938 100644
@@ -404,8 +404,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 			break;
 		case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
 		case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
-		case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra 8 */
-		case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
 			/* doesn't set the sample rate attribute, but supports it */
 			fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
 			break;
usb/quirks-table.h +88 -8

127 lines not on this page · raw message

Signature · 1 line
1.7.0.4

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#1 lore raw

Hi,

Here's a slightly updated version of the patch. It does essentially the same as the former one but sets the capture endpoint attribute to 'async' and the playback endpoint to 'adaptive'.

Kind regards,

Felix

Am 06.07.2010 10:05, schrieb Felix Homann:

Quoted 8 lines

This fixes issues with M-Audio's Fast Track Ultra series:

* devices now work at 44100 and 88200 Hz
* apparently, fixes some crashes, too

From 57cd7afd0b0fbccd80acab16e617cf8a844e37d1 Mon Sep 17 00:00:00 2001

From: Felix <[email protected]>
Date: Tue, 6 Jul 2010 09:16:17 +0200
Subject: [PATCH - Fix Fast Track Ultra series: 44.1/88.1 kHz 1/Fix playback/capture issues and related chrashes at 44100 Hz and 88200 Hz for M-Audio Fast Track Ultra series.

usb/endpoint.c +0 -2
index 1a701f1..bb9f938 100644
@@ -404,8 +404,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 			break;
 		case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
 		case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
-		case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra 8 */
-		case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
 			/* doesn't set the sample rate attribute, but supports it */
 			fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
 			break;
usb/quirks-table.h +88 -8

127 lines not on this page · raw message

Signature · 1 line
1.7.0.4

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw
Quoted 3 lines · Felix Homann

This fixes issues with M-Audio's Fast Track Ultra series:

* devices now work at 44100 and 88200 Hz

The descriptors already list these rates, so in theory, the existing code that sets UAC_EP_CS_ATTR_SAMPLE_RATE should already have enabled this. Didn't it? In other words, what is the difference in the explicitly specified audioformat?

(I have the suspicion that we don't actually need a AUDIO_FIXED_ENDPOINT quirk for these devices.)

Quoted 1 line

* apparently, fixes some crashes, too

When do these crashes happen?

Quoted 2 lines

This is based on a patch posted by user 'dhubsith' on the M-Audio user forum.

If you don't have the exclusive copyright for the code in this patch, there needs to be a Signed-off-by line from him, too. OTOH, a table like this probably isn't copyrightable at all.

usb/quirks-table.h YAMAHA_DEVICE(0x7010, "UB99"), · line 1830

Quoted 3 lines
usb/quirks-table.h +1 -1
-	USB_DEVICE(0x0763, 0x2080),
+		USB_DEVICE(0x0763, 0x2081),
...

This replaces the ID of the Ultra 8 ID with that of the Ultra 8R ...

Review

Quoted 3 lines
(quoted diff) +1 -1
 	USB_DEVICE(0x0763, 0x2081),
-	.driver_info = ...
+		.driver_info = ...

... and this just changes the other 8R entry. So now the 8 doesn't have an entry.

Regards,
Clemens

#3 lore raw

Am 07.07.2010 14:44, schrieb Clemens Ladisch:

Quoted 4 lines

The descriptors already list these rates, so in theory, the existing code that sets UAC_EP_CS_ATTR_SAMPLE_RATE should already have enabled this. Didn't it? In other words, what is the difference in the explicitly specified audioformat?

I can only tell you the difference to the behaviour of latest git Alsa before this patch:

44100 and 88200 Hz had already been enabled. But the device could not properly be used at these sampling rates. Everything would sound distorted. After a while of running the device at these sample rates, my systems had a tendency to crash/freeze.

Quoted 4 lines

(I have the suspicion that we don't actually need a AUDIO_FIXED_ENDPOINT quirk for these devices.)

Something must be in this AUDIO_FIXED_ENDPOINT quirk, since the device now works properly and stable @44.1/88.2 kHz. I don't know the exact reason, since I really don't understand all this stuff. I just have this device and try to fix it's behaviour.

Quoted 4 lines
Quoted 2 lines

* apparently, fixes some crashes, too

When do these crashes happen?

See above: System crashes occured when using the device at 44.1/88.2 kHz.

Quoted 4 lines

If you don't have the exclusive copyright for the code in this patch, there needs to be a Signed-off-by line from him, too. OTOH, a table like this probably isn't copyrightable at all.

If the patch is copyrightable then its copyright belongs to you: The patch I send some time ago to enable basic support for these devices was an updated version of *your* patch send some time ago to a mailing list. The patch dhubsith posted was explicitly based on existing code in quirks-table.h and the existing quirk.

Take a look at the entry for the Digidesign Mbox (credited to you): It's essentially the same.

Quoted 6 lines

usb/quirks-table.h YAMAHA_DEVICE(0x7010, "UB99"), · line 1830

Quoted 4 lines
usb/quirks-table.h +1 -1
-	USB_DEVICE(0x0763, 0x2080),
+		USB_DEVICE(0x0763, 0x2081),
...

This replaces the ID of the Ultra 8 ID with that of the Ultra 8R ...

Ooops. I've messed it up... (I've just got the 8R version so I didn't notice...)

Quoted 8 lines

Review

Quoted 4 lines

USB_DEVICE(0x0763, 0x2081),

(quoted diff) +1 -1
-	.driver_info = ...
+		.driver_info = ...

... and this just changes the other 8R entry. So now the 8 doesn't have an entry.

Actually both quirk blocks shoud be the same except for the USB_DEVICE lines:

USB_DEVICE(0x0763, 0x2080) <- Fast Track Ultra
USB_DEVICE(0x0763, 0x2081) <- Fast Track Ultra 8R

(Actually there's no "Fast Track Ultra 8")

Sorry for having messed the patch up and sending it too soon. Shall I send a new patch, or would you consider manually editing it yourself before eventually putting it into git?

Kind regards,

Felix

#4 lore raw

Hi,

here's the hopefully corrected version of the patch.

Furthermore, I got notice from dhubsith that he would sign it of if needed. What do you think?

Kind regards,

Felix

Quoted 1 line

From 1573e7e973e6adcfe39fbfdaae0be2d1a5e01501 Mon Sep 17 00:00:00 2001

From: Felix Homann <[email protected]>
Date: Wed, 7 Jul 2010 15:51:58 +0200
Subject: [PATCH - Fix Fast Track Ultra series 1/1] Fix 44.1/88.1 kHz 1/Fix playback/capture issues and related chrashes at 44100 Hz and 88200 Hz for M-Audio Fast Track Ultra series.

usb/endpoint.c +0 -2
index 1a701f1..bb9f938 100644
@@ -404,8 +404,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 			break;
 		case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
 		case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
-		case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra 8 */
-		case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
 			/* doesn't set the sample rate attribute, but supports it */
 			fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
 			break;
usb/quirks-table.h +88 -8

127 lines not on this page · raw message

Signature · 1 line
1.7.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw
In reply to Felix Homann
Quoted 7 lines · Felix Homann

Am 07.07.2010 14:44, schrieb Clemens Ladisch:

Quoted 2 lines

(I have the suspicion that we don't actually need a AUDIO_FIXED_ENDPOINT quirk for these devices.)

Something must be in this AUDIO_FIXED_ENDPOINT quirk, since the device now works properly and stable @44.1/88.2 kHz. I don't know the exact reason, since I really don't understand all this stuff.

There must be some difference, and I'd really like to know what it is. Please load the driver with the patch below, with and without the AUDIO_FIXED_ENDPOINT patch, and show what it prints to the system log.

Regards,
Clemens

sound/usb/format.c +2 -0
@@ -196,6 +196,7 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
 			hwc_debug("All rates were zero. Skipping format!\n");
 			return -1;
 		}
+		print_hex_dump_bytes("rates ", DUMP_PREFIX_OFFSET, fp->rates, sizeof(int) * nr_rates);
 	} else {
 		/* continuous rates */
 		fp->rates = SNDRV_PCM_RATE_CONTINUOUS;
@@ -480,6 +481,7 @@ int snd_usb_parse_audio_format(struct snd_usb_audio *chip, struct audioformat *f
 	fp->fmt_type = fmt->bFormatType;
 	if (err < 0)
 		return err;
+	print_hex_dump_bytes("format ", DUMP_PREFIX_OFFSET, fp, sizeof(*fp));
 #if 1
 	/* FIXME: temporary hack for extigy/audigy 2 nx/zs */
 	/* extigy apparently supports sample rates other than 48k
sound/usb/quirks.c +2 -0
index 9a9da09..6be2bfc 100644
@@ -142,6 +142,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
 		}
 		memcpy(rate_table, fp->rate_table, sizeof(int) * fp->nr_rates);
 		fp->rate_table = rate_table;
+		print_hex_dump_bytes("rates ", DUMP_PREFIX_OFFSET, fp->rate_table, sizeof(int) * fp->nr_rates);
 	}
 
 	stream = (fp->endpoint & USB_DIR_IN)
@@ -161,6 +162,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
 	alts = &iface->altsetting[fp->altset_idx];
 	fp->datainterval = snd_usb_parse_datainterval(chip, alts);
 	fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
+	print_hex_dump_bytes("format ", DUMP_PREFIX_OFFSET, fp, sizeof(*fp));
 	usb_set_interface(chip->dev, fp->iface, 0);
 	snd_usb_init_pitch(chip, fp->iface, alts, fp);
 	snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max);
#6 lore raw

Building Alsa fails after applying your patch:

[...]
make[2]: Entering directory `/home/felix/workspace/Alsa/Ladisch/alsa-driver/usb'
copying file alsa-kernel/usb/quirks.c
patching file quirks.c
Hunk #2 FAILED at 159.
Hunk #3 succeeded at 235 (offset 5 lines).
Hunk #4 succeeded at 325 (offset 6 lines).
Hunk #5 succeeded at 343 (offset 6 lines).
Hunk #6 succeeded at 357 (offset 6 lines).
Hunk #7 succeeded at 370 (offset 6 lines).
1 out of 7 hunks FAILED -- saving rejects to file quirks.c.rej make[2]: *** [quirks.c] Fehler 1
make[2]: Leaving directory `/home/felix/workspace/Alsa/Ladisch/alsa-driver/usb'
make[1]: *** [dep] Fehler 1
make[1]: Leaving directory `/home/felix/workspace/Alsa/Ladisch/alsa-driver'
make: *** [include/sndversions.h] Fehler 2

Am 07.07.2010 16:23, schrieb Clemens Ladisch:

Quoted 6 lines

There must be some difference, and I'd really like to know what it is. Please load the driver with the patch below, with and without the AUDIO_FIXED_ENDPOINT patch, and show what it prints to the system log.

#7 lore raw
Quoted 4 lines · Felix Homann

Building Alsa fails after applying your patch:

patching file quirks.c
Hunk #2 FAILED at 159.

My patch was against the kernel source; the alsa-driver package needs this additional patch:

usb/quirks.patch +1 -1
@@ -15,9 +15,9 @@
 +#else
 +	fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize;
 +#endif
+ 	print_hex_dump_bytes("format ", DUMP_PREFIX_OFFSET, fp, sizeof(*fp));
  	usb_set_interface(chip->dev, fp->iface, 0);
  	snd_usb_init_pitch(chip, fp->iface, alts, fp);
- 	snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max);
 @@ -228,7 +234,11 @@
  	fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
  	fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
#8 lore raw

I've attached the excerpts from /var/log/syslog with and without the FIXED_ENDPOINT quirk.

Please, let me know if you need further information.

Kind regards,

Felix

Jul  8 10:18:41 yerbouti kernel: [  639.088015] usb 2-3: new high speed USB device using ehci_hcd and address 4
Jul  8 10:18:41 yerbouti kernel: [  639.221630] usb 2-3: config 1 interface 3 altsetting 0 bulk endpoint 0x7 has invalid maxpacket 8
Jul  8 10:18:41 yerbouti kernel: [  639.221635] usb 2-3: config 1 interface 3 altsetting 0 bulk endpoint 0x87 has invalid maxpacket 8
Jul  8 10:18:41 yerbouti kernel: [  639.222494] usb 2-3: New USB device found, idVendor=0763, idProduct=2081
Jul  8 10:18:41 yerbouti kernel: [  639.222497] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Jul  8 10:18:41 yerbouti kernel: [  639.222500] usb 2-3: Product: Fast Track Ultra 8R
Jul  8 10:18:41 yerbouti kernel: [  639.222503] usb 2-3: Manufacturer: M-Audio
Jul  8 10:18:41 yerbouti kernel: [  639.222640] usb 2-3: configuration #1 chosen from 1 choice
Jul  8 10:18:41 yerbouti kernel: [  639.283129] rates 00000000: 44 ac 00 00 80 bb 00 00 88 58 01 00 00 77 01 00  D........X...w..
Jul  8 10:18:41 yerbouti kernel: [  639.283155] format 00000000: 78 aa 7b be 00 88 ff ff 78 aa 7b be 00 88 ff ff  x.{.....x.{.....
Jul  8 10:18:41 yerbouti kernel: [  639.283158] format 00000010: 00 00 00 00 01 00 00 00 08 00 00 00 00 00 00 00  ................
Jul  8 10:18:41 yerbouti kernel: [  639.283161] format 00000020: 00 00 00 00 01 00 00 00 01 01 01 01 01 00 00 00  ................
Jul  8 10:18:41 yerbouti kernel: [  639.283164] format 00000030: 38 01 00 00 c0 06 00 00 44 ac 00 00 00 77 01 00  8.......D....w..
Jul  8 10:18:41 yerbouti kernel: [  639.283167] format 00000040: 04 00 00 00 00 00 00 00 e8 b3 36 74 00 88 ff ff  ..........6t....
Jul  8 10:18:41 yerbouti kernel: [  639.283169] format 00000050: 00 00 00 00 00 00 00 00                          ........
Jul  8 10:18:41 yerbouti kernel: [  639.286004] rates 00000000: 44 ac 00 00 80 bb 00 00 88 58 01 00 00 77 01 00  D........X...w..
Jul  8 10:18:41 yerbouti kernel: [  639.286027] format 00000000: 00 ad 7b be 00 88 ff ff 00 ad 7b be 00 88 ff ff  ..{.......{.....
Jul  8 10:18:41 yerbouti kernel: [  639.286030] format 00000010: 00 00 00 00 01 00 00 00 08 00 00 00 00 00 00 00  ................
Jul  8 10:18:41 yerbouti kernel: [  639.286033] format 00000020: 00 00 00 00 02 00 00 00 01 01 01 81 01 00 00 00  ................
Jul  8 10:18:41 yerbouti kernel: [  639.286036] format 00000030: 38 01 00 00 c0 06 00 00 44 ac 00 00 00 77 01 00  8.......D....w..
Jul  8 10:18:41 yerbouti kernel: [  639.286039] format 00000040: 04 00 00 00 00 00 00 00 a8 bc 36 74 00 88 ff ff  ..........6t....
Jul  8 10:18:41 yerbouti kernel: [  639.286041] format 00000050: 00 00 00 00 00 00 00 00                          ........
Jul  8 10:18:41 yerbouti kernel: [  639.288261] usbcore: registered new interface driver snd-usb-audio
Jul  8 09:56:19 yerbouti kernel: [ 2421.972028] usb 3-3: new high speed USB device using ehci_hcd and address 4
Jul  8 09:56:20 yerbouti kernel: [ 2422.105561] usb 3-3: config 1 interface 3 altsetting 0 bulk endpoint 0x7 has invalid maxpacket 8
Jul  8 09:56:20 yerbouti kernel: [ 2422.105566] usb 3-3: config 1 interface 3 altsetting 0 bulk endpoint 0x87 has invalid maxpacket 8
Jul  8 09:56:20 yerbouti kernel: [ 2422.106425] usb 3-3: New USB device found, idVendor=0763, idProduct=2081
Jul  8 09:56:20 yerbouti kernel: [ 2422.106429] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Jul  8 09:56:20 yerbouti kernel: [ 2422.106432] usb 3-3: Product: Fast Track Ultra 8R
Jul  8 09:56:20 yerbouti kernel: [ 2422.106434] usb 3-3: Manufacturer: M-Audio
Jul  8 09:56:20 yerbouti kernel: [ 2422.106567] usb 3-3: configuration #1 chosen from 1 choice
Jul  8 09:56:20 yerbouti kernel: [ 2422.352132] BUG: unable to handle kernel NULL pointer dereference at 00000000000006c0
Jul  8 09:56:20 yerbouti kernel: [ 2422.352139] IP: [<ffffffff81195868>] hex_dump_to_buffer+0x194/0x26e
Jul  8 09:56:20 yerbouti kernel: [ 2422.352150] PGD 87009067 PUD 96915067 PMD 0 
Jul  8 09:56:20 yerbouti kernel: [ 2422.352154] Oops: 0000 [#1] SMP 
Jul  8 09:56:20 yerbouti kernel: [ 2422.352158] last sysfs file: /sys/devices/pci0000:00/0000:00:1d.7/usb3/3-3/3-3:1.2/bInterfaceProtocol
Jul  8 09:56:20 yerbouti kernel: [ 2422.352166] CPU 1 
Jul  8 09:56:20 yerbouti kernel: [ 2422.352168] Modules linked in: snd_usb_audio(+) snd_usbmidi_lib kvm_intel kvm nfsd lockd nfs_acl auth_rpcgss sunrpc exportfs deflate zlib_deflate ctr twofish twofish_common camellia serpent blowfish cast5 des_generic cbc aes_x86_64 aes_generic xcbc cpufreq_userspace cpufreq_conservative rmd160 cpufreq_powersave sha256_generic cpufreq_stats sha1_generic hmac crypto_null af_key parport_pc ppdev lp parport sco bridge stp bnep rfcomm l2cap crc16 bluetooth rfkill uinput binfmt_misc dlm configfs fuse ide_generic ide_cd_mod ide_core vboxdrv videodev v4l1_compat v4l2_compat_ioctl32 snd_seq_virmidi snd_seq_midi_emul acpi_cpufreq eeprom loop snd_hda_codec_atihdmi snd_hda_codec_idt snd_hda_intel snd_hda_codec snd_hwdep snd_pcm_oss snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer snd_seq_device snd i2c_i801 tpm_tis soundcore fglrx(P) i2c_core usblp psmouse snd_page_alloc evdev button processor tpm tpm_bios dcdbas serio_raw ext3 j
Jul  8 09:56:20 yerbouti kernel: d mbcache dm_mod usb_storage sg sr_mod usbhid sd_mod cdrom crc_t10dif hid ata_generic uhci_hcd thermal thermal_sys ata_piix firewire_ohci firewire_core crc_itu_t e1000e ehci_hcd libata scsi_mod usbcore nls_base [last unloaded: scsi_wait_scan]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] Pid: 8230, comm: modprobe Tainted: P           2.6.32-5-amd64 #1 Dell DM061                   
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] RIP: 0010:[<ffffffff81195868>]  [<ffffffff81195868>] hex_dump_to_buffer+0x194/0x26e
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] RSP: 0018:ffff8800615fb9e8  EFLAGS: 00010203
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] RAX: 00000000000006c0 RBX: 0000000000000000 RCX: 0000000000000000
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000010                                            
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] RBP: 00000000000006c0 R08: 0000000000000003 R09: 00000000000000c8                                            
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] R10: 0000000000000018 R11: dead000000100100 R12: 0000000000000000                                            
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] R13: 0000000000000010 R14: ffff8800615fba78 R15: ffffffff813a2755                                            
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] FS:  00007fcb78068700(0000) GS:ffff880001840000(0000) knlGS:0000000000000000                                 
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b                                                            
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] CR2: 00000000000006c0 CR3: 0000000095236000 CR4: 00000000000026e0                                            
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] Process modprobe (pid: 8230, threadinfo ffff8800615fa000, task ffff88007539a350)
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] Stack:
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  ffff880001855640 ffff880001855640 01ff88007539a350 00000000000000c8
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] <0> 00000000000006c0 0000000000000010 00000000000006c0 0000000000000000
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] <0> 0000000000000000 ffffffffa04f8437 ffffffff813a2755 ffffffff811959dc
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] Call Trace:
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff811959dc>] ? print_hex_dump+0x9a/0x153
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8105a534>] ? try_to_del_timer_sync+0x63/0x6c
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8105a549>] ? del_timer_sync+0xc/0x16
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff812f98ab>] ? schedule_timeout+0xad/0xdd
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8105a5c8>] ? process_timeout+0x0/0x5
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff810e7335>] ? __kmalloc+0x12f/0x141
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff81195ac4>] ? print_hex_dump_bytes+0x2f/0x37

Message from syslogd@yerbouti at Thu Jul 8 09:56:20 2010 ... yerbouti kernel: [ 2422.352254] Call Trace:

Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa04f0b51>] ? parse_audio_format_rates_v1+0x1c1/0x223 [snd_usb_audio]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa04f11ea>] ? snd_usb_parse_audio_format+0x290/0x48a [snd_usb_audio]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa04f1a82>] ? snd_usb_parse_audio_endpoints+0x3b0/0x62e [snd_usb_audio]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa04f1c52>] ? snd_usb_parse_audio_endpoints+0x580/0x62e [snd_usb_audio]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa04f0466>] ? create_standard_audio_quirk+0x13/0x58 [snd_usb_audio]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa04f04ff>] ? create_composite_quirk+0x54/0x87 [snd_usb_audio]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa04ec7ae>] ? usb_audio_probe+0x463/0x661 [snd_usb_audio]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa00107be>] ? usb_match_one_id+0x23/0x7f [usbcore]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa001174d>] ? usb_probe_interface+0x107/0x156 [usbcore]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8121f298>] ? driver_probe_device+0xa3/0x14b
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8121f38f>] ? __driver_attach+0x4f/0x6f

Message from syslogd@yerbouti at Thu Jul 8 09:56:20 2010 ... yerbouti kernel: [ 2422.352254] Stack:

Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8121f340>] ? __driver_attach+0x0/0x6f
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8121eb67>] ? bus_for_each_dev+0x43/0x74
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8121e527>] ? bus_add_driver+0xaf/0x1f8
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8121f647>] ? driver_register+0xa7/0x111
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa0011502>] ? usb_register_driver+0x7e/0xdf [usbcore]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffffa05e5000>] ? snd_usb_audio_init+0x0/0x43 [snd_usb_audio]
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8100a065>] ? do_one_initcall+0x64/0x174
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff8107a4fc>] ? sys_init_module+0xc5/0x21a
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  [<ffffffff81010b42>] ? system_call_fastpath+0x16/0x1b
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] Code: 31 c0 48 29 fe 49 8d 3c 3e ff c5 49 83 c4 02 e8 75 e8 ff ff 01 c3 44 39 fd 7c bd 43 8d 04 bf eb 63 48 8b 44 24 20 48 63 cb ff c6 <8a> 14 10 88 d0 83 e2 0f c0 e8 04 8a 92 60 9f 32 81 0f b6 c0 8a 
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] RIP  [<ffffffff81195868>] hex_dump_to_buffer+0x194/0x26e
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254]  RSP <ffff8800615fb9e8>
Jul  8 09:56:20 yerbouti kernel: [ 2422.352254] CR2: 00000000000006c0
Jul  8 09:56:20 yerbouti kernel: [ 2422.352603] ---[ end trace 83c483e466783985 ]---
Jul  8 09:56:20 yerbouti udevd-work[5315]: '/sbin/modprobe -b usb:v0763p2081d0151dcEFdsc02dp01icFFisc02ip00' unexpected exit with status 0x0009 

Message from syslogd@yerbouti at Thu Jul 8 09:56:20 2010 ...
yerbouti kernel: [ 2422.352158] last sysfs file: /sys/devices/pci0000:00/0000:00:1d.7/usb3/3-3/3-3:1.2/bInterfaceProtocol

Message from syslogd@yerbouti at Thu Jul 8 09:56:20 2010 ... yerbouti kernel: [ 2422.352154] Oops: 0000 [#1] SMP

Message from syslogd@yerbouti at Thu Jul 8 09:56:20 2010 ...
yerbouti kernel: [ 2422.352254] Code: 31 c0 48 29 fe 49 8d 3c 3e ff c5 49 83 c4 02 e8 75 e8 ff ff 01 c3 44 39 fd 7c bd 43 8d 04 bf eb 63 48 8b 44 24 20 48 63 cb ff c6 <8a> 14 10 88 d0 83 e2 0f c0 e8 04 8a 92 60 9f 32 81 0f b6 c0 8a

Message from syslogd@yerbouti at Thu Jul 8 09:56:20 2010 ... yerbouti kernel: [ 2422.352254] CR2: 00000000000006c0

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#9 lore raw
Quoted 4 lines · Felix Homann

I've attached the excerpts from /var/log/syslog with and without the FIXED_ENDPOINT quirk.

BUG: unable to handle kernel NULL pointer dereference

Sorry, the call for the case without the fixed quirk is buggy. In line 199 of format.c, please change "fp->rates" to "fp->rate_table".

Regards,
Clemens

#10 lore raw

Hmm,

I guess there's still something wrong with your debug patch (or me applying it...). Doesn't look like any valuable information in syslog this time (no fixed_endpoint quirk):

Jul  8 17:04:16 yerbouti kernel: [19340.109648] usb 2-3: config 1 
interface 3 altsetting 0 bulk endpoint 0x7 has invalid maxpacket 8
Jul  8 17:04:16 yerbouti kernel: [19340.109653] usb 2-3: config 1 
interface 3 altsetting 0 bulk endpoint 0x87 has invalid maxpacket 8
Jul  8 17:04:16 yerbouti kernel: [19340.110762] usb 2-3: New USB device 
found, idVendor=0763, idProduct=2081
Jul  8 17:04:16 yerbouti kernel: [19340.110765] usb 2-3: New USB device 
strings: Mfr=1, Product=2, SerialNumber=0
Jul  8 17:04:16 yerbouti kernel: [19340.110769] usb 2-3: Product: Fast 
Track Ultra 8R
Jul  8 17:04:16 yerbouti kernel: [19340.110771] usb 2-3: Manufacturer: 
M-Audio
Jul  8 17:04:16 yerbouti kernel: [19340.110916] usb 2-3: configuration 

#1 chosen from 1 choice

Regards,

Felix

Am 08.07.2010 15:10, schrieb Clemens Ladisch:

Quoted 7 lines
BUG: unable to handle kernel NULL pointer dereference

Sorry, the call for the case without the fixed quirk is buggy. In line 199 of format.c, please change "fp->rates" to "fp->rate_table".

#11 lore raw
Quoted 3 lines · Felix Homann

I guess there's still something wrong with your debug patch (or me applying it...). Doesn't look like any valuable information in syslog this time (no fixed_endpoint quirk):

But that part of parse_audio_format_rates_v1 definitely gets executed, or the kernel wouldn't have crashed previously.

Please make sure that the source code (in alsa-kernel) contains the print_hex_dump_bytes call, and that it is this driver that gets loaded.

Regards,
Clemens

#12 lore raw

Sorry, I really thought I had double checked.

Here you go (without fixed endpoint quirk):

Jul  8 17:49:04 yerbouti kernel: [22027.924017] usb 2-3: new high speed 
USB device using ehci_hcd and address 6
Jul  8 17:49:04 yerbouti kernel: [22028.057581] usb 2-3: config 1 
interface 3 altsetting 0 bulk endpoint 0x7 has invalid maxpacket 8
Jul  8 17:49:04 yerbouti kernel: [22028.057586] usb 2-3: config 1 
interface 3 altsetting 0 bulk endpoint 0x87 has invalid maxpacket 8
Jul  8 17:49:04 yerbouti kernel: [22028.058445] usb 2-3: New USB device 
found, idVendor=0763, idProduct=2081
Jul  8 17:49:04 yerbouti kernel: [22028.058449] usb 2-3: New USB device 
strings: Mfr=1, Product=2, SerialNumber=0
Jul  8 17:49:04 yerbouti kernel: [22028.058452] usb 2-3: Product: Fast 
Track Ultra 8R
Jul  8 17:49:04 yerbouti kernel: [22028.058454] usb 2-3: Manufacturer: 
M-Audio
Jul  8 17:49:04 yerbouti kernel: [22028.058594] usb 2-3: configuration 
#1 chosen from 1 choice
Jul  8 17:49:04 yerbouti kernel: [22028.149465] rates 00000000: 44 ac 00 
00 80 bb 00 00 88 58 01 00 00 77 01 00  D........X...w..
Jul  8 17:49:04 yerbouti kernel: [22028.149471] format 00000000: 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.149474] format 00000010: 00 00 
00 00 01 00 00 00 08 00 00 00 01 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.149477] format 00000020: 00 00 
00 00 01 00 00 00 01 01 01 01 05 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.149480] format 00000030: 38 01 
00 00 c0 06 00 00 44 ac 00 00 00 77 01 00  8.......D....w..
Jul  8 17:49:04 yerbouti kernel: [22028.149483] format 00000040: 04 00 
00 00 00 00 00 00 e8 87 61 50 00 88 ff ff  ..........aP....
Jul  8 17:49:04 yerbouti kernel: [22028.149486] format 00000050: 00 00 
00 00 00 00 00 00                          ........
Jul  8 17:49:04 yerbouti kernel: [22028.152636] rates 00000000: 44 ac 00 
00 80 bb 00 00 88 58 01 00 00 77 01 00  D........X...w..
Jul  8 17:49:04 yerbouti kernel: [22028.152640] format 00000000: 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.152644] format 00000010: 00 00 
00 00 01 00 00 00 08 00 00 00 01 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.152646] format 00000020: 00 00 
00 00 02 00 00 00 01 01 01 81 05 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.152649] format 00000030: 38 01 
00 00 c0 06 00 00 44 ac 00 00 00 77 01 00  8.......D....w..
Jul  8 17:49:04 yerbouti kernel: [22028.152652] format 00000040: 04 00 
00 00 00 00 00 00 28 84 61 50 00 88 ff ff  ........(.aP....
Jul  8 17:49:04 yerbouti kernel: [22028.152655] format 00000050: 00 00 
00 00 00 00 00 00                          ........
Jul  8 17:49:04 yerbouti kernel: [22028.154451] rates 00000000: 44 ac 00 
00 80 bb 00 00 88 58 01 00 00 77 01 00  D........X...w..
Jul  8 17:49:04 yerbouti kernel: [22028.154455] format 00000000: 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.154459] format 00000010: 00 00 
00 00 01 00 00 00 08 00 00 00 01 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.154462] format 00000020: 00 00 
00 00 02 00 00 00 02 02 01 81 05 00 00 00  ................
Jul  8 17:49:04 yerbouti kernel: [22028.154465] format 00000030: 38 01 
00 00 c0 06 00 00 44 ac 00 00 00 77 01 00  8.......D....w..
Jul  8 17:49:04 yerbouti kernel: [22028.154468] format 00000040: 04 00 
00 00 00 00 00 00 28 8d 61 50 00 88 ff ff  ........(.aP....
Jul  8 17:49:04 yerbouti kernel: [22028.154472] format 00000050: 00 00 
00 00 00 00 00 00                          ........
Jul  8 17:49:04 yerbouti kernel: [22028.155656] ALSA clock.c:236: 
current rate 48000 is different from the runtime rate 96000
Jul  8 17:49:04 yerbouti kernel: [22028.157664] usbcore: registered new 

interface driver snd-usb-audio

Am 08.07.2010 17:19, schrieb Clemens Ladisch:

Quoted 6 lines
Quoted 3 lines · Felix Homann

I guess there's still something wrong with your debug patch (or me applying it...). Doesn't look like any valuable information in syslog this time (no fixed_endpoint quirk):

#13 lore raw
In reply to Clemens Ladisch

Am 07.07.2010 16:23, schrieb Clemens Ladisch:

Quoted 9 lines

There must be some difference, and I'd really like to know what it is. Please load the driver with the patch below, with and without the AUDIO_FIXED_ENDPOINT patch, and show what it prints to the system log.

Regards,
Clemens

Hi Clemens,

Have you found what's making the AUDIO_FIXED_ENDPOINT necessary? What are the chances for the patch to make it into the git repositories otherwise?

Kind regards,

Felix

#14 lore raw
In reply to Felix Homann

Dear Alsa developers,

almost 2 months ago I send a patch making the M-Audio Fast Track Ultra series audio interfaces work flawlessly in Linux except for missing mixer support:

Am 06.07.2010 10:05, schrieb Felix Homann:

Quoted 4 lines

This fixes issues with M-Audio's Fast Track Ultra series:

* devices now work at 44100 and 88200 Hz
* apparently, fixes some crashes, too

Unfortunately, the patch didn't make it into Alsa so far. Clemens Ladisch seemed reluctant to apply a fixed endpoint quirk since the device should have worked without in his opinion. I gave him all the requested information to see what was happening without the fixed endpoint quirk. I never heard back from him again.

So, could someone in charge kindly tell me why the patch didn't make it into Alsa? What's missing, what's wrong?

If it's just the fact that Clemens doesn't like the fixed endpoint quirk please find attached a different patch yielding the same result. (Against Linux 2.6.35. It's again from dhubsith who posted it on the M-Audio forum. He would sign it off if requested - on the other hand it is already derived work of the Alsa sources).

And please, if it's not going anywhere, please tell us "laymen, volunteer Alsa helpers" about the reasons.

The current situation is most frustrating: We know how to make the device work (much better than in Windows, btw) but we don't know why we have to patch alsa again and again.

Thanks in advance,

Felix

sound/usb/card.c +2 -0
diff -rupN /sound/usb/card.c /sound/usb/card.c
@@ -209,6 +209,8 @@ static int snd_usb_create_streams(struct
 						 NULL, UAC_HEADER);
 	altsd = get_iface_desc(host_iface);
 	protocol = altsd->bInterfaceProtocol;
+                if (chip->usb_id == USB_ID(0x0763, 0x2080) || chip->usb_id == USB_ID(0x0763, 0x2081))
+		protocol = UAC_VERSION_1;
 
 	if (!control_header) {
 		snd_printk(KERN_ERR "cannot find UAC_HEADER\n");
sound/usb/endpoint.c +8 -2
diff -rupN /sound/usb/endpoint.c /sound/usb/endpoint.c
@@ -252,6 +252,8 @@ int snd_usb_parse_audio_endpoints(struct
 		alts = &iface->altsetting[i];
 		altsd = get_iface_desc(alts);
 		protocol = altsd->bInterfaceProtocol;
+                if (chip->usb_id == USB_ID(0x0763, 0x2080) || chip->usb_id == USB_ID(0x0763, 0x2081))
+		protocol = UAC_VERSION_1;
 		/* skip invalid one */
 		if ((altsd->bInterfaceClass != USB_CLASS_AUDIO &&
 		     altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) ||
@@ -403,11 +405,15 @@ int snd_usb_parse_audio_endpoints(struct
 			break;
 		case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
 		case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
-		case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra 8 */
-		case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
 			/* doesn't set the sample rate attribute, but supports it */
 			fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
 			break;
+		case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra   */
+		case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
+			/* force playback sync to adaptive only and turn off async*/
+			if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+				fp->ep_attr = 0x09;
+			break;
 		case USB_ID(0x047f, 0x0ca1): /* plantronics headset */
 		case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is
 						an older model 77d:223) */
sound/usb/format.c +4 -0
diff -rupN /sound/usb/format.c /sound/usb/format.c
@@ -353,6 +353,8 @@ static int parse_audio_format_i(struct s
 	struct usb_interface_descriptor *altsd = get_iface_desc(iface);
 	int protocol = altsd->bInterfaceProtocol;
 	int pcm_format, ret;
+                if (chip->usb_id == USB_ID(0x0763, 0x2080) || chip->usb_id == USB_ID(0x0763, 0x2081))
+		protocol = UAC_VERSION_1;
 
 	if (fmt->bFormatType == UAC_FORMAT_TYPE_III) {
 		/* FIXME: the format type is really IECxxx
@@ -415,6 +417,8 @@ static int parse_audio_format_ii(struct 
 	int brate, framesize, ret;
 	struct usb_interface_descriptor *altsd = get_iface_desc(iface);
 	int protocol = altsd->bInterfaceProtocol;
+                if (chip->usb_id == USB_ID(0x0763, 0x2080) || chip->usb_id == USB_ID(0x0763, 0x2081))
+		protocol = UAC_VERSION_1;
 
 	switch (format) {
 	case UAC_FORMAT_TYPE_II_AC3:

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#15 lore raw

Re: [PATCH] - Fix Fast Track Ultra series: 44.1/88.1 kHz 1/Fix playback/capture issues and related crashes at 44100 Hz and 88200 Hz for M-Audio Fast Track Ultra series.

Dear Felix,

Am Dienstag, den 31.08.2010, 08:39 +0200 schrieb Felix Homann:

Quoted 3 lines

almost 2 months ago I send a patch making the M-Audio Fast Track Ultra series audio interfaces work flawlessly in Linux except for missing mixer support:

for people having subscribe later or deleted the last messages, you can find Felix’s message in the archive [1]. I could not download the attachment though, so please try [2] instead.

Quoted 12 lines

Am 06.07.2010 10:05, schrieb Felix Homann:

Quoted 4 lines

This fixes issues with M-Audio's Fast Track Ultra series:

* devices now work at 44100 and 88200 Hz
* apparently, fixes some crashes, too

Unfortunately, the patch didn't make it into Alsa so far. Clemens Ladisch seemed reluctant to apply a fixed endpoint quirk since the device should have worked without in his opinion. I gave him all the requested information to see what was happening without the fixed endpoint quirk. I never heard back from him again.

Quoted 7 lines

So, could someone in charge kindly tell me why the patch didn't make it into Alsa? What's missing, what's wrong?

If it's just the fact that Clemens doesn't like the fixed endpoint quirk please find attached a different patch yielding the same result. (Against Linux 2.6.35. It's again from dhubsith who posted it on the M-Audio forum.

Could you include the link to the forum post.

Quoted 2 lines

He would sign it off if requested - on the other hand it is already derived work of the Alsa sources).

I guess his signed-off-by line additionally to yours (Tested-by: is also good) would not hurt.

Quoted 6 lines

And please, if it's not going anywhere, please tell us "laymen, volunteer Alsa helpers" about the reasons.

The current situation is most frustrating: We know how to make the device work (much better than in Windows, btw) but we don't know why we have to patch alsa again and again.

Sorry, unfortunately I cannot tell you why your work has not been committed yet and I do understand your frustration. The reasons might be simple, that the developers were caught up by different things and your patch just fall through the cracks. So it is a good thing, that you come back and ask for the status.

So to ease work for the developers, could you please resend your patch. Do you know if it can be split up, so that the controversial parts can be left out at first?

Please use git format-patch with

1. a short commit summary line,
2. links to the respective Web pages where this patch was discussed.

You can just copy the lines from the resulting file into a normal message (delete the header fields and copy the subject manually marking it with [RESENT]). Just make sure the lines do not get wrapped.

Then make sure to CC the maintainers (I think Clemens, Takashi, Jaroslav) too so that they do not miss it.

I hope your patch will be included soon afterward.

Thanks and good luck,

Paul

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2010-July/thread.html#29193
[2] http://www.spinics.net/lists/alsa-devel/msg35372.html

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#16 lore raw
In reply to Felix Homann

Hi,

This is my second try to get support for all supported sample rates for the Fast Track Ultra (FTU) series into mainline alsa.

For clarification: Current Alsa already recognizes the supported sample rates. But it will sound very corrupted at 44.1000 Hz and 88.200 Hz. Without this patch your system will even probably freeze eventually when using the FTU at 44.100/88.200 Hz too long.

So the key idea in this patch is not to get 44.1 kHz and 88.2 kHz listed as supported sample rates (as they already are recognized) but to change the endpoint attributes.

Citing dhubsith on the M-Audio forum:

" The problem with using QUIRK_AUDIO_STANDARD_INTERFACE rather than QUIRK_AUDIO_FIXED_ENDPOINT is that ep_attr does not get set correctly. The device default for synchronization is async (0x05) for both capture and playback, but in fact it should be set to adaptive (0x09) on playback, so that playback follows capture, this way you don't get capture and playback using different sample rates.

Also, the Interface Class protocol for the device defaults to Vendor Specific Class, but the driver only recognizes Class 1 or 2. The device is really Class 1, so we have to force it to reflect this. There are 4 places that we need to set this."

The patch has been discussed starting here:

http://forums.m-audio.com/showthread.php?714-Not-a-problem.-FastTrack-on-linux/page8

The "key" has been found by dhubsith. Please read posts #79, #81, #84, #87, #97.

In post #102 of that forum you can even find an alternate patch by dhubsith which doesn't use a fixed endpoint quirk but sets

     protocol = UAC_VERSION_1;

for the FTU devices in sound/usb/format .c. You might even consider that patch. (I've resend it to alsa-devel yesterday).

After all, either one of the above mentioned patches should go into alsa, as right now we can't use the FTU devices at 44.1 and 88.2 kHz.

Kind regards,

Felix

Quoted 1 line

From 1573e7e973e6adcfe39fbfdaae0be2d1a5e01501 Mon Sep 17 00:00:00 2001

From: Felix Homann <[email protected]>
Date: Wed, 7 Jul 2010 15:51:58 +0200
Subject: [PATCH - Fix Fast Track Ultra series 1/1] Fix 44.1/88.1 kHz 1/Fix playback/capture issues and related chrashes at 44100 Hz and 88200 Hz for M-Audio Fast Track Ultra series.

usb/endpoint.c +0 -2
index 1a701f1..bb9f938 100644
@@ -404,8 +404,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 			break;
 		case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
 		case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
-		case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra 8 */
-		case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
 			/* doesn't set the sample rate attribute, but supports it */
 			fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
 			break;
usb/quirks-table.h +88 -8

127 lines not on this page · raw message

Signature · 1 line
1.7.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#17 lore raw

At Wed, 01 Sep 2010 10:48:54 +0200,

Quoted 42 lines · Felix Homann

Hi,

This is my second try to get support for all supported sample rates for the Fast Track Ultra (FTU) series into mainline alsa.

For clarification: Current Alsa already recognizes the supported sample rates. But it will sound very corrupted at 44.1000 Hz and 88.200 Hz. Without this patch your system will even probably freeze eventually when using the FTU at 44.100/88.200 Hz too long.

So the key idea in this patch is not to get 44.1 kHz and 88.2 kHz listed as supported sample rates (as they already are recognized) but to change the endpoint attributes.

Citing dhubsith on the M-Audio forum:

" The problem with using QUIRK_AUDIO_STANDARD_INTERFACE rather than QUIRK_AUDIO_FIXED_ENDPOINT is that ep_attr does not get set correctly. The device default for synchronization is async (0x05) for both capture and playback, but in fact it should be set to adaptive (0x09) on playback, so that playback follows capture, this way you don't get capture and playback using different sample rates.

Also, the Interface Class protocol for the device defaults to Vendor Specific Class, but the driver only recognizes Class 1 or 2. The device is really Class 1, so we have to force it to reflect this. There are 4 places that we need to set this."

The patch has been discussed starting here:

http://forums.m-audio.com/showthread.php?714-Not-a-problem.-FastTrack-on-linux/page8

The "key" has been found by dhubsith. Please read posts #79, #81, #84, #87, #97.

In post #102 of that forum you can even find an alternate patch by dhubsith which doesn't use a fixed endpoint quirk but sets

Quoted 7 lines
      protocol = UAC_VERSION_1;

for the FTU devices in sound/usb/format .c. You might even consider that patch. (I've resend it to alsa-devel yesterday).

After all, either one of the above mentioned patches should go into alsa, as right now we can't use the FTU devices at 44.1 and 88.2 kHz.

Thanks for the patch (and reposting it).

I myself find it's OK to apply since it's pretty local change. Clemens, what was your objection at that time?

thanks,

Takashi

Quoted 166 lines

Kind regards,

Felix

[2 0001-fix-sample-rates-ftu-v3.patch <text/x-patch (7bit)>]

Quoted 1 line

From 1573e7e973e6adcfe39fbfdaae0be2d1a5e01501 Mon Sep 17 00:00:00 2001

From: Felix Homann <[email protected]>
Date: Wed, 7 Jul 2010 15:51:58 +0200
Subject: [PATCH - Fix Fast Track Ultra series 1/1] Fix 44.1/88.1 kHz 1/Fix playback/capture issues and related chrashes at 44100 Hz and 88200 Hz for M-Audio Fast Track Ultra series.

usb/endpoint.c +0 -2
index 1a701f1..bb9f938 100644
@@ -404,8 +404,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 			break;
 		case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
 		case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
-		case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra 8 */
-		case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
 			/* doesn't set the sample rate attribute, but supports it */
 			fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE;
 			break;
usb/quirks-table.h +88 -8
index f8797f6..4c1dc12 100644
@@ -1827,10 +1827,10 @@ YAMAHA_DEVICE(0x7010, "UB99"),
 	}
 },
 {
-	USB_DEVICE(0x0763, 0x2080),
-	.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
+		USB_DEVICE(0x0763, 0x2080),
+		.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
 		/* .vendor_name = "M-Audio", */
-		/* .product_name = "Fast Track Ultra 8", */
+		/* .product_name = "Fast Track Ultra", */
 		.ifnum = QUIRK_ANY_INTERFACE,
 		.type = QUIRK_COMPOSITE,
 		.data = & (const struct snd_usb_audio_quirk[]) {
@@ -1840,11 +1840,51 @@ YAMAHA_DEVICE(0x7010, "UB99"),
 			},
 			{
 				.ifnum = 1,
-				.type = QUIRK_AUDIO_STANDARD_INTERFACE
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = & (const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S24_3LE,
+					.channels = 8,
+					.iface = 1,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
+					.endpoint = 0x01,
+					.ep_attr = 0x09,
+					.rates = SNDRV_PCM_RATE_44100 |
+						SNDRV_PCM_RATE_48000 |
+						SNDRV_PCM_RATE_88200 |
+						SNDRV_PCM_RATE_96000,
+					.rate_min = 44100,
+					.rate_max = 96000,
+					.nr_rates = 4,
+					.rate_table = (unsigned int[]) {
+						44100, 48000, 88200, 96000
+					}
+				}
 			},
 			{
 				.ifnum = 2,
-				.type = QUIRK_AUDIO_STANDARD_INTERFACE
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = & (const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S24_3LE,
+					.channels = 8,
+					.iface = 2,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
+					.endpoint = 0x81,
+					.ep_attr = 0x05,
+					.rates = SNDRV_PCM_RATE_44100 |
+						SNDRV_PCM_RATE_48000 |
+						SNDRV_PCM_RATE_88200 |
+						SNDRV_PCM_RATE_96000,
+					.rate_min = 44100,
+					.rate_max = 96000,
+					.nr_rates = 4,
+					.rate_table = (unsigned int[]) {
+						44100, 48000, 88200, 96000
+					}
+				}
 			},
 			/* interface 3 (MIDI) is standard compliant */
 			{
@@ -1855,7 +1895,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
 },
 {
 	USB_DEVICE(0x0763, 0x2081),
-	.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
+		.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
 		/* .vendor_name = "M-Audio", */
 		/* .product_name = "Fast Track Ultra 8R", */
 		.ifnum = QUIRK_ANY_INTERFACE,
@@ -1867,11 +1907,51 @@ YAMAHA_DEVICE(0x7010, "UB99"),
 			},
 			{
 				.ifnum = 1,
-				.type = QUIRK_AUDIO_STANDARD_INTERFACE
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = & (const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S24_3LE,
+					.channels = 8,
+					.iface = 1,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
+					.endpoint = 0x01,
+					.ep_attr = 0x09,
+					.rates = SNDRV_PCM_RATE_44100 |
+						SNDRV_PCM_RATE_48000 |
+						SNDRV_PCM_RATE_88200 |
+						SNDRV_PCM_RATE_96000,
+					.rate_min = 44100,
+					.rate_max = 96000,
+					.nr_rates = 4,
+					.rate_table = (unsigned int[]) {
+							44100, 48000, 88200, 96000
+					}
+				}
 			},
 			{
 				.ifnum = 2,
-				.type = QUIRK_AUDIO_STANDARD_INTERFACE
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = & (const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S24_3LE,
+					.channels = 8,
+					.iface = 2,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
+					.endpoint = 0x81,
+					.ep_attr = 0x05,
+					.rates = SNDRV_PCM_RATE_44100 |
+						SNDRV_PCM_RATE_48000 |
+						SNDRV_PCM_RATE_88200 |
+						SNDRV_PCM_RATE_96000,
+					.rate_min = 44100,
+					.rate_max = 96000,
+					.nr_rates = 4,
+					.rate_table = (unsigned int[]) {
+						44100, 48000, 88200, 96000
+					}
+				}
 			},
 			/* interface 3 (MIDI) is standard compliant */
 			{
Signature · 1 line
1.7.1
#18 lore raw
Quoted 2 lines · Takashi Iwai

I myself find it's OK to apply since it's pretty local change. Clemens, what was your objection at that time?

No objection per se, I wanted to find out what descriptor field is changed by the quirk, and where the crashes come from exactly. The latter is still unclear, but it seems a quirk like this is required.

I've committed the patch now.

Quoted 4 lines
Quoted 4 lines

Also, the Interface Class protocol for the device defaults to Vendor Specific Class, but the driver only recognizes Class 1 or 2. The device is really Class 1, so we have to force it to reflect this. There are 4 places that we need to set this."

Daniel, this seems to be a regression introduced with the UAC2 changes. The old driver accepted vendor-specific interfaces, if some quirk forced it to look at them.

Regards,
Clemens

#19 lore raw
Quoted 10 lines · Clemens Ladisch
Quoted 2 lines · Takashi Iwai

I myself find it's OK to apply since it's pretty local change. Clemens, what was your objection at that time?

No objection per se, I wanted to find out what descriptor field is changed by the quirk, and where the crashes come from exactly. The latter is still unclear, but it seems a quirk like this is required.

I've committed the patch now.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

Also, the Interface Class protocol for the device defaults to Vendor Specific Class, but the driver only recognizes Class 1 or 2. The device is really Class 1, so we have to force it to reflect this. There are 4 places that we need to set this."

Daniel, this seems to be a regression introduced with the UAC2 changes. The old driver accepted vendor-specific interfaces, if some quirk forced it to look at them.

Hmm, I don't follow. What's the problem, and why should that be caused by the UAC2 changes? Sorry, but I seem to have missed that thread.

Thanks,
Daniel

#20 lore raw
Quoted 6 lines · Daniel Mack
Quoted 5 lines · Clemens Ladisch
Quoted 4 lines
Quoted 4 lines

Also, the Interface Class protocol for the device defaults to Vendor Specific Class, but the driver only recognizes Class 1 or 2. The device is really Class 1, so we have to force it to reflect this. There are 4 places that we need to set this."

Quoted 6 lines
Quoted 3 lines

Daniel, this seems to be a regression introduced with the UAC2 changes. The old driver accepted vendor-specific interfaces, if some quirk forced it to look at them.

Hmm, I don't follow. What's the problem, and why should that be caused by the UAC2 changes? Sorry, but I seem to have missed that thread.

I've got several reports that devices no longer work since UAC2 support got added. But I've just noticed this is not related to the interface class but to the interface protocol: the new code added checks for UAC_VERSION_1 or _2, but real devices apparently write just random junk into this field. (For vendor-specific interfaces, they are actually justified to do so.)

We need something like the following (untested), unless you have a better idea:

sound/usb/card.c +4 -4
index 9feb00c..d5141a1 100644
@@ -216,6 +216,10 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
 	}
 
 	switch (protocol) {
+	default:
+		snd_printdd(KERN_WARN "unknown interface protocol %#02x, assuming v1\n");
+		/* fall through */
+
 	case UAC_VERSION_1: {
 		struct uac1_ac_header_descriptor *h1 = control_header;
 
@@ -253,10 +257,6 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
 
 		break;
 	}
-
-	default:
-		snd_printk(KERN_ERR "unknown protocol version 0x%02x\n", protocol);
-		return -EINVAL;
 	}
 
 	return 0;
sound/usb/clock.c +1 -2
index b853f8d..7754a10 100644
@@ -295,12 +295,11 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
 
 	switch (altsd->bInterfaceProtocol) {
 	case UAC_VERSION_1:
+	default:
 		return set_sample_rate_v1(chip, iface, alts, fmt, rate);
 
 	case UAC_VERSION_2:
 		return set_sample_rate_v2(chip, iface, alts, fmt, rate);
 	}
-
-	return -EINVAL;
 }
 
sound/usb/endpoint.c +6 -5
index bb9f938..22589b5 100644
@@ -275,6 +275,12 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 
 		/* get audio formats */
 		switch (protocol) {
+		default:
+			snd_printdd(KERN_WARN "%d:%u:%d: unknown interface protocol %#02x, assuming v1\n",
+				    dev->devnum, iface_no, altno, protocol);
+			protocol = UAC_VERSION_1;
+			/* fall through */
+
 		case UAC_VERSION_1: {
 			struct uac1_as_header_descriptor *as =
 				snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
@@ -336,11 +342,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 				   dev->devnum, iface_no, altno, as->bTerminalLink);
 			continue;
 		}
-
-		default:
-			snd_printk(KERN_ERR "%d:%u:%d : unknown interface protocol %04x\n",
-				   dev->devnum, iface_no, altno, protocol);
-			continue;
 		}
 
 		/* get format type */
sound/usb/format.c +5 -5
index 4387f54..2ec73dd 100644
@@ -49,7 +49,8 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
 	u64 pcm_formats;
 
 	switch (protocol) {
-	case UAC_VERSION_1: {
+	case UAC_VERSION_1:
+	default: {
 		struct uac_format_type_i_discrete_descriptor *fmt = _fmt;
 		sample_width = fmt->bBitResolution;
 		sample_bytes = fmt->bSubframeSize;
@@ -64,9 +65,6 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
 		format <<= 1;
 		break;
 	}
-
-	default:
-		return -EINVAL;
 	}
 
 	pcm_formats = 0;
@@ -385,6 +383,7 @@ static int parse_audio_format_i(struct snd_usb_audio *chip,
 	 */
 	switch (protocol) {
 	case UAC_VERSION_1:
+	default:
 		fp->channels = fmt->bNrChannels;
 		ret = parse_audio_format_rates_v1(chip, fp, (unsigned char *) fmt, 7);
 		break;
@@ -434,7 +433,8 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip,
 	fp->channels = 1;
 
 	switch (protocol) {
-	case UAC_VERSION_1: {
+	case UAC_VERSION_1:
+	default: {
 		struct uac_format_type_ii_discrete_descriptor *fmt = _fmt;
 		brate = le16_to_cpu(fmt->wMaxBitRate);
 		framesize = le16_to_cpu(fmt->wSamplesPerFrame);
sound/usb/mixer.c +9 -9
index c166db0..0478fa3 100644
@@ -365,7 +365,7 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
 
 static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
 {
-	return (cval->mixer->protocol == UAC_VERSION_1) ?
+	return (cval->mixer->protocol != UAC_VERSION_2) ?
 		get_ctl_value_v1(cval, request, validx, value_ret) :
 		get_ctl_value_v2(cval, request, validx, value_ret);
 }
@@ -415,7 +415,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
 	unsigned char buf[2];
 	int val_len, timeout = 10;
 
-	if (cval->mixer->protocol == UAC_VERSION_1) {
+	if (cval->mixer->protocol != UAC_VERSION_2) {
 		val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
 	} else { /* UAC_VERSION_2 */
 		/* audio class v2 controls are always 2 bytes in size */
@@ -642,7 +642,7 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
 		term->id = id;
 		switch (hdr[2]) {
 		case UAC_INPUT_TERMINAL:
-			if (state->mixer->protocol == UAC_VERSION_1) {
+			if (state->mixer->protocol != UAC_VERSION_2) {
 				struct uac_input_terminal_descriptor *d = p1;
 				term->type = le16_to_cpu(d->wTerminalType);
 				term->channels = d->bNrChannels;
@@ -1159,7 +1159,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
 	struct uac_feature_unit_descriptor *hdr = _ftr;
 	__u8 *bmaControls;
 
-	if (state->mixer->protocol == UAC_VERSION_1) {
+	if (state->mixer->protocol != UAC_VERSION_2) {
 		csize = hdr->bControlSize;
 		channels = (hdr->bLength - 7) / csize - 1;
 		bmaControls = hdr->bmaControls;
@@ -1198,7 +1198,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
 	else
 		first_ch_bits = 0;
 
-	if (state->mixer->protocol == UAC_VERSION_1) {
+	if (state->mixer->protocol != UAC_VERSION_2) {
 		/* check all control types */
 		for (i = 0; i < 10; i++) {
 			unsigned int ch_bits = 0;
@@ -1865,13 +1865,13 @@ static int parse_audio_unit(struct mixer_build *state, int unitid)
 		return parse_audio_feature_unit(state, unitid, p1);
 	case UAC1_PROCESSING_UNIT:
 	/*   UAC2_EFFECT_UNIT has the same value */
-		if (state->mixer->protocol == UAC_VERSION_1)
+		if (state->mixer->protocol != UAC_VERSION_2)
 			return parse_audio_processing_unit(state, unitid, p1);
 		else
 			return 0; /* FIXME - effect units not implemented yet */
 	case UAC1_EXTENSION_UNIT:
 	/*   UAC2_PROCESSING_UNIT_V2 has the same value */
-		if (state->mixer->protocol == UAC_VERSION_1)
+		if (state->mixer->protocol != UAC_VERSION_2)
 			return parse_audio_extension_unit(state, unitid, p1);
 		else /* UAC_VERSION_2 */
 			return parse_audio_processing_unit(state, unitid, p1);
@@ -1932,7 +1932,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
 
 	p = NULL;
 	while ((p = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, p, UAC_OUTPUT_TERMINAL)) != NULL) {
-		if (mixer->protocol == UAC_VERSION_1) {
+		if (mixer->protocol != UAC_VERSION_2) {
 			struct uac1_output_terminal_descriptor *desc = p;
 
 			if (desc->bLength < sizeof(*desc))
@@ -2070,7 +2070,7 @@ static void snd_usb_mixer_interrupt(struct urb *urb)
 	if (urb->status != 0)
 		goto requeue;
 
-	if (mixer->protocol == UAC_VERSION_1) {
+	if (mixer->protocol != UAC_VERSION_2) {
 		struct uac1_status_word *status;
 
 		for (status = urb->transfer_buffer;
sound/usb/pcm.c +1 -2
index 3634ced..3b5135c 100644
@@ -173,13 +173,12 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
 
 	switch (altsd->bInterfaceProtocol) {
 	case UAC_VERSION_1:
+	default:
 		return init_pitch_v1(chip, iface, alts, fmt);
 
 	case UAC_VERSION_2:
 		return init_pitch_v2(chip, iface, alts, fmt);
 	}
-
-	return -EINVAL;
 }
 
 /*
#21 lore raw
Quoted 11 lines · Clemens Ladisch
Quoted 10 lines · Daniel Mack
Quoted 8 lines · Clemens Ladisch
Quoted 4 lines
Quoted 4 lines

Also, the Interface Class protocol for the device defaults to Vendor Specific Class, but the driver only recognizes Class 1 or 2. The device is really Class 1, so we have to force it to reflect this. There are 4 places that we need to set this."

Daniel, this seems to be a regression introduced with the UAC2 changes. The old driver accepted vendor-specific interfaces, if some quirk forced it to look at them.

Quoted 8 lines
Quoted 2 lines

Hmm, I don't follow. What's the problem, and why should that be caused by the UAC2 changes? Sorry, but I seem to have missed that thread.

I've got several reports that devices no longer work since UAC2 support got added. But I've just noticed this is not related to the interface class but to the interface protocol: the new code added checks for UAC_VERSION_1 or _2, but real devices apparently write just random junk into this field. (For vendor-specific interfaces, they are actually justified to do so.)

Grr. So what about cases where this "random junk" is 0x20 by coincidence?

Quoted 2 lines

We need something like the following (untested), unless you have a better idea:

We could also fix up such devices with quirks tables, but your approach is probably better as it catches all devices right away.

Thanks,
Daniel

Quoted 218 lines
sound/usb/card.c +4 -4
index 9feb00c..d5141a1 100644
@@ -216,6 +216,10 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
 	}
 
 	switch (protocol) {
+	default:
+		snd_printdd(KERN_WARN "unknown interface protocol %#02x, assuming v1\n");
+		/* fall through */
+
 	case UAC_VERSION_1: {
 		struct uac1_ac_header_descriptor *h1 = control_header;
 
@@ -253,10 +257,6 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
 
 		break;
 	}
-
-	default:
-		snd_printk(KERN_ERR "unknown protocol version 0x%02x\n", protocol);
-		return -EINVAL;
 	}
 
 	return 0;
sound/usb/clock.c +1 -2
index b853f8d..7754a10 100644
@@ -295,12 +295,11 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
 
 	switch (altsd->bInterfaceProtocol) {
 	case UAC_VERSION_1:
+	default:
 		return set_sample_rate_v1(chip, iface, alts, fmt, rate);
 
 	case UAC_VERSION_2:
 		return set_sample_rate_v2(chip, iface, alts, fmt, rate);
 	}
-
-	return -EINVAL;
 }
 
sound/usb/endpoint.c +6 -5
index bb9f938..22589b5 100644
@@ -275,6 +275,12 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 
 		/* get audio formats */
 		switch (protocol) {
+		default:
+			snd_printdd(KERN_WARN "%d:%u:%d: unknown interface protocol %#02x, assuming v1\n",
+				    dev->devnum, iface_no, altno, protocol);
+			protocol = UAC_VERSION_1;
+			/* fall through */
+
 		case UAC_VERSION_1: {
 			struct uac1_as_header_descriptor *as =
 				snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL);
@@ -336,11 +342,6 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
 				   dev->devnum, iface_no, altno, as->bTerminalLink);
 			continue;
 		}
-
-		default:
-			snd_printk(KERN_ERR "%d:%u:%d : unknown interface protocol %04x\n",
-				   dev->devnum, iface_no, altno, protocol);
-			continue;
 		}
 
 		/* get format type */
sound/usb/format.c +5 -5
index 4387f54..2ec73dd 100644
@@ -49,7 +49,8 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
 	u64 pcm_formats;
 
 	switch (protocol) {
-	case UAC_VERSION_1: {
+	case UAC_VERSION_1:
+	default: {
 		struct uac_format_type_i_discrete_descriptor *fmt = _fmt;
 		sample_width = fmt->bBitResolution;
 		sample_bytes = fmt->bSubframeSize;
@@ -64,9 +65,6 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
 		format <<= 1;
 		break;
 	}
-
-	default:
-		return -EINVAL;
 	}
 
 	pcm_formats = 0;
@@ -385,6 +383,7 @@ static int parse_audio_format_i(struct snd_usb_audio *chip,
 	 */
 	switch (protocol) {
 	case UAC_VERSION_1:
+	default:
 		fp->channels = fmt->bNrChannels;
 		ret = parse_audio_format_rates_v1(chip, fp, (unsigned char *) fmt, 7);
 		break;
@@ -434,7 +433,8 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip,
 	fp->channels = 1;
 
 	switch (protocol) {
-	case UAC_VERSION_1: {
+	case UAC_VERSION_1:
+	default: {
 		struct uac_format_type_ii_discrete_descriptor *fmt = _fmt;
 		brate = le16_to_cpu(fmt->wMaxBitRate);
 		framesize = le16_to_cpu(fmt->wSamplesPerFrame);
sound/usb/mixer.c +9 -9
index c166db0..0478fa3 100644
@@ -365,7 +365,7 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
 
 static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
 {
-	return (cval->mixer->protocol == UAC_VERSION_1) ?
+	return (cval->mixer->protocol != UAC_VERSION_2) ?
 		get_ctl_value_v1(cval, request, validx, value_ret) :
 		get_ctl_value_v2(cval, request, validx, value_ret);
 }
@@ -415,7 +415,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
 	unsigned char buf[2];
 	int val_len, timeout = 10;
 
-	if (cval->mixer->protocol == UAC_VERSION_1) {
+	if (cval->mixer->protocol != UAC_VERSION_2) {
 		val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
 	} else { /* UAC_VERSION_2 */
 		/* audio class v2 controls are always 2 bytes in size */
@@ -642,7 +642,7 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
 		term->id = id;
 		switch (hdr[2]) {
 		case UAC_INPUT_TERMINAL:
-			if (state->mixer->protocol == UAC_VERSION_1) {
+			if (state->mixer->protocol != UAC_VERSION_2) {
 				struct uac_input_terminal_descriptor *d = p1;
 				term->type = le16_to_cpu(d->wTerminalType);
 				term->channels = d->bNrChannels;
@@ -1159,7 +1159,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
 	struct uac_feature_unit_descriptor *hdr = _ftr;
 	__u8 *bmaControls;
 
-	if (state->mixer->protocol == UAC_VERSION_1) {
+	if (state->mixer->protocol != UAC_VERSION_2) {
 		csize = hdr->bControlSize;
 		channels = (hdr->bLength - 7) / csize - 1;
 		bmaControls = hdr->bmaControls;
@@ -1198,7 +1198,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
 	else
 		first_ch_bits = 0;
 
-	if (state->mixer->protocol == UAC_VERSION_1) {
+	if (state->mixer->protocol != UAC_VERSION_2) {
 		/* check all control types */
 		for (i = 0; i < 10; i++) {
 			unsigned int ch_bits = 0;
@@ -1865,13 +1865,13 @@ static int parse_audio_unit(struct mixer_build *state, int unitid)
 		return parse_audio_feature_unit(state, unitid, p1);
 	case UAC1_PROCESSING_UNIT:
 	/*   UAC2_EFFECT_UNIT has the same value */
-		if (state->mixer->protocol == UAC_VERSION_1)
+		if (state->mixer->protocol != UAC_VERSION_2)
 			return parse_audio_processing_unit(state, unitid, p1);
 		else
 			return 0; /* FIXME - effect units not implemented yet */
 	case UAC1_EXTENSION_UNIT:
 	/*   UAC2_PROCESSING_UNIT_V2 has the same value */
-		if (state->mixer->protocol == UAC_VERSION_1)
+		if (state->mixer->protocol != UAC_VERSION_2)
 			return parse_audio_extension_unit(state, unitid, p1);
 		else /* UAC_VERSION_2 */
 			return parse_audio_processing_unit(state, unitid, p1);
@@ -1932,7 +1932,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
 
 	p = NULL;
 	while ((p = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, p, UAC_OUTPUT_TERMINAL)) != NULL) {
-		if (mixer->protocol == UAC_VERSION_1) {
+		if (mixer->protocol != UAC_VERSION_2) {
 			struct uac1_output_terminal_descriptor *desc = p;
 
 			if (desc->bLength < sizeof(*desc))
@@ -2070,7 +2070,7 @@ static void snd_usb_mixer_interrupt(struct urb *urb)
 	if (urb->status != 0)
 		goto requeue;
 
-	if (mixer->protocol == UAC_VERSION_1) {
+	if (mixer->protocol != UAC_VERSION_2) {
 		struct uac1_status_word *status;
 
 		for (status = urb->transfer_buffer;
sound/usb/pcm.c +1 -2
index 3634ced..3b5135c 100644
@@ -173,13 +173,12 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
 
 	switch (altsd->bInterfaceProtocol) {
 	case UAC_VERSION_1:
+	default:
 		return init_pitch_v1(chip, iface, alts, fmt);
 
 	case UAC_VERSION_2:
 		return init_pitch_v2(chip, iface, alts, fmt);
 	}
-
-	return -EINVAL;
 }
 
 /*
#22 lore raw
Quoted 8 lines · Daniel Mack
Quoted 5 lines · Clemens Ladisch

I've got several reports that devices no longer work since UAC2 support got added. But I've just noticed this is not related to the interface class but to the interface protocol: the new code added checks for UAC_VERSION_1 or _2, but real devices apparently write just random junk into this field. (For vendor-specific interfaces, they are actually justified to do so.)

Grr. So what about cases where this "random junk" is 0x20 by coincidence?

Actually, it isn't too random: I've seen 0xff (obviously "vendor- specific") and 0x01/0x02 (interface subclass moved to protocol).

Regards,
Clemens