aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-04-21 01:43:10 -0400
committerTakashi Iwai <tiwai@suse.de>2009-04-21 01:43:10 -0400
commita7b554ad7eefdfc9f2955fdba2634e225d761628 (patch)
tree1fd9627d3ba4f512c2fb2b0f7206db12f7dfff5c /sound
parent4262efee8fbbfc083401f22a57d5eca5ba37c2fd (diff)
parent5d4af1be06affa2b42cdf59cd376752be1f934b3 (diff)
Merge branch 'fix/usx2y' into for-linus
* fix/usx2y: ALSA: us122l: add snd_us122l_free() ALSA: us122l: Fix signedness in comparisions
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/usx2y/us122l.c12
-rw-r--r--sound/usb/usx2y/usb_stream.c67
2 files changed, 40 insertions, 39 deletions
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 012ff1f6f8af..a5aae9d67f31 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -474,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card)
474 return true; 474 return true;
475} 475}
476 476
477static void snd_us122l_free(struct snd_card *card)
478{
479 struct us122l *us122l = US122L(card);
480 int index = us122l->chip.index;
481 if (index >= 0 && index < SNDRV_CARDS)
482 snd_us122l_card_used[index] = 0;
483}
484
477static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) 485static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
478{ 486{
479 int dev; 487 int dev;
@@ -490,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
490 if (err < 0) 498 if (err < 0)
491 return err; 499 return err;
492 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 500 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
493 501 card->private_free = snd_us122l_free;
494 US122L(card)->chip.dev = device; 502 US122L(card)->chip.dev = device;
495 US122L(card)->chip.card = card; 503 US122L(card)->chip.card = card;
496 mutex_init(&US122L(card)->mutex); 504 mutex_init(&US122L(card)->mutex);
@@ -584,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
584 } 592 }
585 593
586 usb_put_intf(intf); 594 usb_put_intf(intf);
587 usb_put_dev(US122L(card)->chip.dev); 595 usb_put_dev(us122l->chip.dev);
588 596
589 while (atomic_read(&us122l->mmap_count)) 597 while (atomic_read(&us122l->mmap_count))
590 msleep(500); 598 msleep(500);
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
index 24393dafcb6e..12ae0340adc0 100644
--- a/sound/usb/usx2y/usb_stream.c
+++ b/sound/usb/usx2y/usb_stream.c
@@ -33,32 +33,26 @@ static unsigned usb_stream_next_packet_size(struct usb_stream_kernel *sk)
33static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb) 33static void playback_prep_freqn(struct usb_stream_kernel *sk, struct urb *urb)
34{ 34{
35 struct usb_stream *s = sk->s; 35 struct usb_stream *s = sk->s;
36 unsigned l = 0; 36 int pack, lb = 0;
37 int pack; 37
38 38 for (pack = 0; pack < sk->n_o_ps; pack++) {
39 urb->iso_frame_desc[0].offset = 0; 39 int l = usb_stream_next_packet_size(sk);
40 urb->iso_frame_desc[0].length = usb_stream_next_packet_size(sk); 40 if (s->idle_outsize + lb + l > s->period_size)
41 sk->out_phase = sk->out_phase_peeked;
42 urb->transfer_buffer_length = urb->iso_frame_desc[0].length;
43
44 for (pack = 1; pack < sk->n_o_ps; pack++) {
45 l = usb_stream_next_packet_size(sk);
46 if (s->idle_outsize + urb->transfer_buffer_length + l >
47 s->period_size)
48 goto check; 41 goto check;
49 42
50 sk->out_phase = sk->out_phase_peeked; 43 sk->out_phase = sk->out_phase_peeked;
51 urb->iso_frame_desc[pack].offset = urb->transfer_buffer_length; 44 urb->iso_frame_desc[pack].offset = lb;
52 urb->iso_frame_desc[pack].length = l; 45 urb->iso_frame_desc[pack].length = l;
53 urb->transfer_buffer_length += l; 46 lb += l;
54 } 47 }
55 snd_printdd(KERN_DEBUG "%i\n", urb->transfer_buffer_length); 48 snd_printdd(KERN_DEBUG "%i\n", lb);
56 49
57check: 50check:
58 urb->number_of_packets = pack; 51 urb->number_of_packets = pack;
59 s->idle_outsize += urb->transfer_buffer_length - s->period_size; 52 urb->transfer_buffer_length = lb;
53 s->idle_outsize += lb - s->period_size;
60 snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize, 54 snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize,
61 urb->transfer_buffer_length, s->period_size); 55 lb, s->period_size);
62} 56}
63 57
64static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize, 58static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
@@ -282,21 +276,20 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,
282 struct usb_stream *s = sk->s; 276 struct usb_stream *s = sk->s;
283 struct urb *io; 277 struct urb *io;
284 struct usb_iso_packet_descriptor *id, *od; 278 struct usb_iso_packet_descriptor *id, *od;
285 int p, l = 0; 279 int p = 0, lb = 0, l = 0;
286 280
287 io = sk->idle_outurb; 281 io = sk->idle_outurb;
288 od = io->iso_frame_desc; 282 od = io->iso_frame_desc;
289 io->transfer_buffer_length = 0;
290 283
291 for (p = 0; s->sync_packet < 0; ++p, ++s->sync_packet) { 284 for (; s->sync_packet < 0; ++p, ++s->sync_packet) {
292 struct urb *ii = sk->completed_inurb; 285 struct urb *ii = sk->completed_inurb;
293 id = ii->iso_frame_desc + 286 id = ii->iso_frame_desc +
294 ii->number_of_packets + s->sync_packet; 287 ii->number_of_packets + s->sync_packet;
295 l = id->actual_length; 288 l = id->actual_length;
296 289
297 od[p].length = l; 290 od[p].length = l;
298 od[p].offset = io->transfer_buffer_length; 291 od[p].offset = lb;
299 io->transfer_buffer_length += l; 292 lb += l;
300 } 293 }
301 294
302 for (; 295 for (;
@@ -304,38 +297,38 @@ static int usb_stream_prepare_playback(struct usb_stream_kernel *sk,
304 ++p, ++s->sync_packet) { 297 ++p, ++s->sync_packet) {
305 l = inurb->iso_frame_desc[s->sync_packet].actual_length; 298 l = inurb->iso_frame_desc[s->sync_packet].actual_length;
306 299
307 if (s->idle_outsize + io->transfer_buffer_length + l > 300 if (s->idle_outsize + lb + l > s->period_size)
308 s->period_size)
309 goto check_ok; 301 goto check_ok;
310 302
311 od[p].length = l; 303 od[p].length = l;
312 od[p].offset = io->transfer_buffer_length; 304 od[p].offset = lb;
313 io->transfer_buffer_length += l; 305 lb += l;
314 } 306 }
315 307
316check_ok: 308check_ok:
317 s->sync_packet -= inurb->number_of_packets; 309 s->sync_packet -= inurb->number_of_packets;
318 if (s->sync_packet < -2 || s->sync_packet > 0) { 310 if (unlikely(s->sync_packet < -2 || s->sync_packet > 0)) {
319 snd_printk(KERN_WARNING "invalid sync_packet = %i;" 311 snd_printk(KERN_WARNING "invalid sync_packet = %i;"
320 " p=%i nop=%i %i %x %x %x > %x\n", 312 " p=%i nop=%i %i %x %x %x > %x\n",
321 s->sync_packet, p, inurb->number_of_packets, 313 s->sync_packet, p, inurb->number_of_packets,
322 s->idle_outsize + io->transfer_buffer_length + l, 314 s->idle_outsize + lb + l,
323 s->idle_outsize, io->transfer_buffer_length, l, 315 s->idle_outsize, lb, l,
324 s->period_size); 316 s->period_size);
325 return -1; 317 return -1;
326 } 318 }
327 if (io->transfer_buffer_length % s->cfg.frame_size) { 319 if (unlikely(lb % s->cfg.frame_size)) {
328 snd_printk(KERN_WARNING"invalid outsize = %i\n", 320 snd_printk(KERN_WARNING"invalid outsize = %i\n",
329 io->transfer_buffer_length); 321 lb);
330 return -1; 322 return -1;
331 } 323 }
332 s->idle_outsize += io->transfer_buffer_length - s->period_size; 324 s->idle_outsize += lb - s->period_size;
333 io->number_of_packets = p; 325 io->number_of_packets = p;
334 if (s->idle_outsize > 0) { 326 io->transfer_buffer_length = lb;
335 snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); 327 if (s->idle_outsize <= 0)
336 return -1; 328 return 0;
337 } 329
338 return 0; 330 snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize);
331 return -1;
339} 332}
340 333
341static void prepare_inurb(int number_of_packets, struct urb *iu) 334static void prepare_inurb(int number_of_packets, struct urb *iu)