[ALSA] usb-audio: fix packets per URB calculation for playback

```tree 5f17b000a18f476ea296b1387150b7ff92837215
parent 15a24c0778e9bdd48d8e1cf60a263837b5c30ed5
author Clemens Ladisch <[EMAIL PROTECTED]> Fri, 12 Aug 2005 08:28:27 +0200
committer Jaroslav Kysela <[EMAIL PROTECTED]> Tue, 30 Aug 2005 08:45:08 +0200```
```
[ALSA] usb-audio: fix packets per URB calculation for playback

USB generic driver
When determining how many packets are needed for one period, we cannot
assume that all packets have their maximum size -- we always use the
nominal sample rate when sending data, and could use an even lower rate
when the endpoint uses frequency feedback.

sound/usb/usbaudio.c |   10 +++++++++-
1 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -938,7 +938,15 @@ static int init_substream_urbs(snd_usb_s

/* decide how many packets to be used */
if (is_playback) {
-               total_packs = (period_bytes + maxsize - 1) / maxsize;
+               unsigned int minsize;
+               /* determine how small a packet can be */
+               minsize = (subs->freqn >> (16 - subs->datainterval))
+                         * (frame_bits >> 3);
+               /* with sync from device, assume it can be 25% lower */
+               if (subs->syncpipe)
+                       minsize -= minsize >> 2;
+               minsize = max(minsize, 1u);
+               total_packs = (period_bytes + minsize - 1) / minsize;
if (total_packs < 2 * MIN_PACKS_URB)
total_packs = 2 * MIN_PACKS_URB;
} else {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
```