Lines Matching refs:s
15 struct usb_stream *s = sk->s; in usb_stream_next_packet_size() local
18 return (sk->out_phase_peeked >> 16) * s->cfg.frame_size; in usb_stream_next_packet_size()
23 struct usb_stream *s = sk->s; in playback_prep_freqn() local
29 if (s->idle_outsize + lb + l > s->period_size) in playback_prep_freqn()
42 s->idle_outsize += lb - s->period_size; in playback_prep_freqn()
43 snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize, in playback_prep_freqn()
44 lb, s->period_size); in playback_prep_freqn()
89 struct usb_stream *s = sk->s; in init_urbs() local
91 (char *)s + sizeof(*s) + sizeof(struct usb_stream_packet) * s->inpackets; in init_urbs()
132 struct usb_stream *s; in usb_stream_free() local
142 s = sk->s; in usb_stream_free()
143 if (!s) in usb_stream_free()
147 free_pages_exact(sk->write_page, s->write_size); in usb_stream_free()
151 free_pages_exact(s, s->read_size); in usb_stream_free()
152 sk->s = NULL; in usb_stream_free()
198 sk->s = alloc_pages_exact(read_size, in usb_stream_new()
200 if (!sk->s) { in usb_stream_new()
204 sk->s->cfg.version = USB_STREAM_INTERFACE_VERSION; in usb_stream_new()
206 sk->s->read_size = read_size; in usb_stream_new()
208 sk->s->cfg.sample_rate = sample_rate; in usb_stream_new()
209 sk->s->cfg.frame_size = frame_size; in usb_stream_new()
211 sk->s->inpackets = packets * USB_STREAM_URBDEPTH; in usb_stream_new()
212 sk->s->cfg.period_frames = period_frames; in usb_stream_new()
213 sk->s->period_size = frame_size * period_frames; in usb_stream_new()
215 sk->s->write_size = write_size; in usb_stream_new()
236 sk->s->state = usb_stream_stopped; in usb_stream_new()
238 return sk->s; in usb_stream_new()
285 struct usb_stream *s = sk->s; in usb_stream_prepare_playback() local
293 for (; s->sync_packet < 0; ++p, ++s->sync_packet) { in usb_stream_prepare_playback()
297 ii->number_of_packets + s->sync_packet; in usb_stream_prepare_playback()
306 s->sync_packet < inurb->number_of_packets && p < sk->n_o_ps; in usb_stream_prepare_playback()
307 ++p, ++s->sync_packet) { in usb_stream_prepare_playback()
308 l = inurb->iso_frame_desc[s->sync_packet].actual_length; in usb_stream_prepare_playback()
310 if (s->idle_outsize + lb + l > s->period_size) in usb_stream_prepare_playback()
319 s->sync_packet -= inurb->number_of_packets; in usb_stream_prepare_playback()
320 if (unlikely(s->sync_packet < -2 || s->sync_packet > 0)) { in usb_stream_prepare_playback()
323 s->sync_packet, p, inurb->number_of_packets, in usb_stream_prepare_playback()
324 s->idle_outsize + lb + l, in usb_stream_prepare_playback()
325 s->idle_outsize, lb, l, in usb_stream_prepare_playback()
326 s->period_size); in usb_stream_prepare_playback()
329 if (unlikely(lb % s->cfg.frame_size)) { in usb_stream_prepare_playback()
334 s->idle_outsize += lb - s->period_size; in usb_stream_prepare_playback()
337 if (s->idle_outsize <= 0) in usb_stream_prepare_playback()
340 snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); in usb_stream_prepare_playback()
388 static void loop_back(struct usb_stream *s) in loop_back() argument
395 o = s->playback1st_to; in loop_back()
396 ol = s->playback1st_size; in loop_back()
399 if (s->insplit_pack >= 0) { in loop_back()
402 p = s->insplit_pack; in loop_back()
406 for (; p < iu->number_of_packets && l < s->period_size; ++p) { in loop_back()
409 if (l + il > s->period_size) in loop_back()
410 il = s->period_size - l; in loop_back()
418 o = s->playback_to; in loop_back()
421 ol = s->period_size - s->playback1st_size; in loop_back()
426 if (l != s->period_size) in loop_back()
428 l/(int)s->cfg.frame_size); in loop_back()
440 static void loop_back(struct usb_stream *s) in loop_back() argument
448 struct usb_stream *s = sk->s; in stream_idle() local
450 int insize = s->idle_insize; in stream_idle()
453 s->inpacket_split = s->next_inpacket_split; in stream_idle()
454 s->inpacket_split_at = s->next_inpacket_split_at; in stream_idle()
455 s->next_inpacket_split = -1; in stream_idle()
456 s->next_inpacket_split_at = 0; in stream_idle()
467 s->inpacket_head++; in stream_idle()
468 s->inpacket_head %= s->inpackets; in stream_idle()
469 if (s->inpacket_split == -1) in stream_idle()
470 s->inpacket_split = s->inpacket_head; in stream_idle()
472 s->inpacket[s->inpacket_head].offset = in stream_idle()
473 id[p].offset + (inurb->transfer_buffer - (void *)s); in stream_idle()
474 s->inpacket[s->inpacket_head].length = l; in stream_idle()
475 if (insize + l > s->period_size && in stream_idle()
476 s->next_inpacket_split == -1) { in stream_idle()
477 s->next_inpacket_split = s->inpacket_head; in stream_idle()
478 s->next_inpacket_split_at = s->period_size - insize; in stream_idle()
483 s->idle_insize += urb_size - s->period_size; in stream_idle()
484 if (s->idle_insize < 0) { in stream_idle()
486 (s->idle_insize)/(int)s->cfg.frame_size); in stream_idle()
489 s->insize_done += urb_size; in stream_idle()
491 l = s->idle_outsize; in stream_idle()
492 s->outpacket[0].offset = (sk->idle_outurb->transfer_buffer - in stream_idle()
498 s->outpacket[0].length = sk->idle_outurb->transfer_buffer_length + l; in stream_idle()
499 s->outpacket[1].offset = sk->completed_outurb->transfer_buffer - in stream_idle()
505 loop_back(s); in stream_idle()
506 s->periods_done++; in stream_idle()
510 s->state = usb_stream_xrun; in stream_idle()
533 struct usb_stream *s = sk->s; in stream_start() local
535 if (s->state >= usb_stream_sync1) { in stream_start()
540 frames_per_packet = (s->period_size - s->idle_insize); in stream_start()
543 s->cfg.frame_size * inurb->number_of_packets; in stream_start()
546 max_diff_0 = s->cfg.frame_size; in stream_start()
547 if (s->cfg.period_frames >= 256) in stream_start()
549 if (s->cfg.period_frames >= 1024) in stream_start()
560 (min_frames >> 8) * s->cfg.frame_size; in stream_start()
563 s->insize_done, in stream_start()
564 urb_size / (int)s->cfg.frame_size, in stream_start()
569 s->idle_insize -= max_diff - max_diff_0; in stream_start()
570 s->idle_insize += urb_size - s->period_size; in stream_start()
571 if (s->idle_insize < 0) { in stream_start()
573 s->idle_insize, urb_size, s->period_size); in stream_start()
575 } else if (s->idle_insize == 0) { in stream_start()
576 s->next_inpacket_split = in stream_start()
577 (s->inpacket_head + 1) % s->inpackets; in stream_start()
578 s->next_inpacket_split_at = 0; in stream_start()
580 unsigned int split = s->inpacket_head; in stream_start()
582 l = s->idle_insize; in stream_start()
583 while (l > s->inpacket[split].length) { in stream_start()
584 l -= s->inpacket[split].length; in stream_start()
586 split = s->inpackets - 1; in stream_start()
590 s->next_inpacket_split = split; in stream_start()
591 s->next_inpacket_split_at = in stream_start()
592 s->inpacket[split].length - l; in stream_start()
595 s->insize_done += urb_size; in stream_start()
606 if (s->state == usb_stream_sync1 && s->insize_done > 360000) { in stream_start()
608 s->state = usb_stream_ready; in stream_start()
618 struct usb_stream *s = sk->s; in i_capture_start() local
630 if (l < s->cfg.frame_size) { in i_capture_start()
632 if (s->state >= usb_stream_sync0) { in i_capture_start()
637 s->inpacket_head++; in i_capture_start()
638 s->inpacket_head %= s->inpackets; in i_capture_start()
639 s->inpacket[s->inpacket_head].offset = in i_capture_start()
640 id[p].offset + (urb->transfer_buffer - (void *)s); in i_capture_start()
641 s->inpacket[s->inpacket_head].length = l; in i_capture_start()
655 if (!empty && s->state < usb_stream_sync1) in i_capture_start()
656 ++s->state; in i_capture_start()
672 struct usb_stream *s = sk->s; in usb_stream_start() local
677 if (s->state != usb_stream_stopped) in usb_stream_start()
682 memset(sk->write_page, 0, s->write_size); in usb_stream_start()
684 s->insize_done = 0; in usb_stream_start()
685 s->idle_insize = 0; in usb_stream_start()
686 s->idle_outsize = 0; in usb_stream_start()
687 s->sync_packet = -1; in usb_stream_start()
688 s->inpacket_head = -1; in usb_stream_start()
757 while (s->state != usb_stream_ready && wait_ms > 0) { in usb_stream_start()
758 snd_printdd(KERN_DEBUG "%i\n", s->state); in usb_stream_start()
764 return s->state == usb_stream_ready ? 0 : -EFAULT; in usb_stream_start()
774 if (!sk->s) in usb_stream_stop()
780 sk->s->state = usb_stream_stopped; in usb_stream_stop()