ALSA: usb: Add quirk for 192KHz recording on E-Mu devices
authorCalvin Owens <jcalvinowens@gmail.com>
Sat, 13 Apr 2013 03:33:59 +0000 (22:33 -0500)
committerTakashi Iwai <tiwai@suse.de>
Sat, 13 Apr 2013 08:58:03 +0000 (10:58 +0200)
When recording at 176.2KHz or 192Khz, the device adds a 32-bit length
header to the capture packets, which obviously needs to be ignored for
recording to work properly.

Userspace expected:  L0 L1 L2 R0 R1 R2
...but actually got: R2 L0 L1 L2 R0 R1

Also, the last byte of the length header being interpreted as L0 of
the first sample caused spikes every 0.5ms, resulting in a loud 16KHz
tone (about the highest 'B' on a piano) being present throughout
captures.

Tested at all sample rates on an E-Mu 0404USB, and tested for
regressions on a generic USB headset.

Signed-off-by: Calvin Owens <jcalvinowens@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/card.h
sound/usb/pcm.c
sound/usb/quirks.c
sound/usb/stream.c

index 8a751b4887ea87043fb34483a652f0d444145d5a..d32ea411545a2ccccccfe100bdebb801c2fa1979 100644 (file)
@@ -116,6 +116,7 @@ struct snd_usb_substream {
        unsigned int altset_idx;     /* USB data format: index of alternate setting */
        unsigned int txfr_quirk:1;      /* allow sub-frame alignment */
        unsigned int fmt_type;          /* USB audio format type (1-3) */
+       unsigned int pkt_offset_adj;    /* Bytes to drop from beginning of packets (for non-compliant devices) */
 
        unsigned int running: 1;        /* running status */
 
index 815a37d2e3e0a7747627d1362f2d1044829999ad..9916c85d8cdb5574516d672614dd401e724c652c 100644 (file)
@@ -1162,7 +1162,7 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
        stride = runtime->frame_bits >> 3;
 
        for (i = 0; i < urb->number_of_packets; i++) {
-               cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
+               cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset + subs->pkt_offset_adj;
                if (urb->iso_frame_desc[i].status && printk_ratelimit()) {
                        snd_printdd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status);
                        // continue;
index 292798185afc76db2c812ab796afd857ab8d5c62..175fbb7d334a5306e449e2ec68233aea02f11d72 100644 (file)
@@ -854,6 +854,7 @@ static void set_format_emu_quirk(struct snd_usb_substream *subs,
                break;
        }
        snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id);
+       subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0;
 }
 
 void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
index 74beea237801f2f6fb4582691a78b4c4b5dd2b0c..8951f77a72012e60d10cd14d8a8b7e8dd10393a4 100644 (file)
@@ -93,6 +93,7 @@ static void snd_usb_init_substream(struct snd_usb_stream *as,
        subs->dev = as->chip->dev;
        subs->txfr_quirk = as->chip->txfr_quirk;
        subs->speed = snd_usb_get_speed(subs->dev);
+       subs->pkt_offset_adj = 0;
 
        snd_usb_set_pcm_ops(as->pcm, stream);