aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2013-08-08 05:24:55 -0400
committerTakashi Iwai <tiwai@suse.de>2013-08-08 05:37:34 -0400
commit57e6dae1087bbaa6b33d3dd8a8e90b63888939a3 (patch)
tree3f96789f16329d9053f02c0699a3eb48b4f28e62 /sound
parentddb6b5a964371e8e52e696b2b258bda144c8bd3f (diff)
ALSA: usb-audio: do not trust too-big wMaxPacketSize values
The driver used to assume that the streaming endpoint's wMaxPacketSize value would be an indication of how much data the endpoint expects or sends, and compute the number of packets per URB using this value. However, the Focusrite Scarlett 2i4 declares a value of 1024 bytes, while only about 88 or 44 bytes are be actually used. This discrepancy would result in URBs with far too few packets, which would not work correctly on the EHCI driver. To get correct URBs, use wMaxPacketSize only as an upper limit on the packet size. Reported-by: James Stone <jamesmstone@gmail.com> Tested-by: James Stone <jamesmstone@gmail.com> Cc: <stable@vger.kernel.org> # 2.6.35+ Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/endpoint.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 7a444b5501d9..659950e5b94f 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -591,17 +591,16 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
591 ep->stride = frame_bits >> 3; 591 ep->stride = frame_bits >> 3;
592 ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0; 592 ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0;
593 593
594 /* calculate max. frequency */ 594 /* assume max. frequency is 25% higher than nominal */
595 if (ep->maxpacksize) { 595 ep->freqmax = ep->freqn + (ep->freqn >> 2);
596 maxsize = ((ep->freqmax + 0xffff) * (frame_bits >> 3))
597 >> (16 - ep->datainterval);
598 /* but wMaxPacketSize might reduce this */
599 if (ep->maxpacksize && ep->maxpacksize < maxsize) {
596 /* whatever fits into a max. size packet */ 600 /* whatever fits into a max. size packet */
597 maxsize = ep->maxpacksize; 601 maxsize = ep->maxpacksize;
598 ep->freqmax = (maxsize / (frame_bits >> 3)) 602 ep->freqmax = (maxsize / (frame_bits >> 3))
599 << (16 - ep->datainterval); 603 << (16 - ep->datainterval);
600 } else {
601 /* no max. packet size: just take 25% higher than nominal */
602 ep->freqmax = ep->freqn + (ep->freqn >> 2);
603 maxsize = ((ep->freqmax + 0xffff) * (frame_bits >> 3))
604 >> (16 - ep->datainterval);
605 } 604 }
606 605
607 if (ep->fill_max) 606 if (ep->fill_max)