Lines Matching full:s
16 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
28 if (s->idle_outsize + lb + l > s->period_size) in playback_prep_freqn()
41 s->idle_outsize += lb - s->period_size; in playback_prep_freqn()
42 snd_printdd(KERN_DEBUG "idle=%i ul=%i ps=%i\n", s->idle_outsize, in playback_prep_freqn()
43 lb, s->period_size); in playback_prep_freqn()
86 struct usb_stream *s = sk->s; in init_urbs() local
87 char *indata = (char *)s + sizeof(*s) + in init_urbs()
89 s->inpackets; in init_urbs()
131 struct usb_stream *s; in usb_stream_free() local
141 s = sk->s; in usb_stream_free()
142 if (!s) in usb_stream_free()
145 free_pages_exact(sk->write_page, s->write_size); in usb_stream_free()
147 free_pages_exact(s, s->read_size); in usb_stream_free()
148 sk->s = NULL; in usb_stream_free()
191 sk->s = alloc_pages_exact(read_size, in usb_stream_new()
193 if (!sk->s) { in usb_stream_new()
197 sk->s->cfg.version = USB_STREAM_INTERFACE_VERSION; in usb_stream_new()
199 sk->s->read_size = read_size; in usb_stream_new()
201 sk->s->cfg.sample_rate = sample_rate; in usb_stream_new()
202 sk->s->cfg.frame_size = frame_size; in usb_stream_new()
204 sk->s->inpackets = packets * USB_STREAM_URBDEPTH; in usb_stream_new()
205 sk->s->cfg.period_frames = period_frames; in usb_stream_new()
206 sk->s->period_size = frame_size * period_frames; in usb_stream_new()
208 sk->s->write_size = write_size; in usb_stream_new()
229 sk->s->state = usb_stream_stopped; in usb_stream_new()
231 return sk->s; in usb_stream_new()
277 struct usb_stream *s = sk->s; in usb_stream_prepare_playback() local
285 for (; s->sync_packet < 0; ++p, ++s->sync_packet) { in usb_stream_prepare_playback()
288 ii->number_of_packets + s->sync_packet; in usb_stream_prepare_playback()
297 s->sync_packet < inurb->number_of_packets && p < sk->n_o_ps; in usb_stream_prepare_playback()
298 ++p, ++s->sync_packet) { in usb_stream_prepare_playback()
299 l = inurb->iso_frame_desc[s->sync_packet].actual_length; in usb_stream_prepare_playback()
301 if (s->idle_outsize + lb + l > s->period_size) in usb_stream_prepare_playback()
310 s->sync_packet -= inurb->number_of_packets; in usb_stream_prepare_playback()
311 if (unlikely(s->sync_packet < -2 || s->sync_packet > 0)) { in usb_stream_prepare_playback()
314 s->sync_packet, p, inurb->number_of_packets, in usb_stream_prepare_playback()
315 s->idle_outsize + lb + l, in usb_stream_prepare_playback()
316 s->idle_outsize, lb, l, in usb_stream_prepare_playback()
317 s->period_size); in usb_stream_prepare_playback()
320 if (unlikely(lb % s->cfg.frame_size)) { in usb_stream_prepare_playback()
325 s->idle_outsize += lb - s->period_size; in usb_stream_prepare_playback()
328 if (s->idle_outsize <= 0) in usb_stream_prepare_playback()
331 snd_printk(KERN_WARNING "idle=%i\n", s->idle_outsize); in usb_stream_prepare_playback()
378 static void loop_back(struct usb_stream *s) in loop_back() argument
385 o = s->playback1st_to; in loop_back()
386 ol = s->playback1st_size; in loop_back()
389 if (s->insplit_pack >= 0) { in loop_back()
392 p = s->insplit_pack; in loop_back()
396 for (; p < iu->number_of_packets && l < s->period_size; ++p) { in loop_back()
399 if (l + il > s->period_size) in loop_back()
400 il = s->period_size - l; in loop_back()
408 o = s->playback_to; in loop_back()
411 ol = s->period_size - s->playback1st_size; in loop_back()
416 if (l != s->period_size) in loop_back()
417 printk(KERN_DEBUG"%s:%i %i\n", __func__, __LINE__, in loop_back()
418 l/(int)s->cfg.frame_size); in loop_back()
430 static void loop_back(struct usb_stream *s) in loop_back() argument
438 struct usb_stream *s = sk->s; in stream_idle() local
440 int insize = s->idle_insize; in stream_idle()
443 s->inpacket_split = s->next_inpacket_split; in stream_idle()
444 s->inpacket_split_at = s->next_inpacket_split_at; in stream_idle()
445 s->next_inpacket_split = -1; in stream_idle()
446 s->next_inpacket_split_at = 0; in stream_idle()
456 s->inpacket_head++; in stream_idle()
457 s->inpacket_head %= s->inpackets; in stream_idle()
458 if (s->inpacket_split == -1) in stream_idle()
459 s->inpacket_split = s->inpacket_head; in stream_idle()
461 s->inpacket[s->inpacket_head].offset = in stream_idle()
462 id[p].offset + (inurb->transfer_buffer - (void *)s); in stream_idle()
463 s->inpacket[s->inpacket_head].length = l; in stream_idle()
464 if (insize + l > s->period_size && in stream_idle()
465 s->next_inpacket_split == -1) { in stream_idle()
466 s->next_inpacket_split = s->inpacket_head; in stream_idle()
467 s->next_inpacket_split_at = s->period_size - insize; in stream_idle()
472 s->idle_insize += urb_size - s->period_size; in stream_idle()
473 if (s->idle_insize < 0) { in stream_idle()
475 (s->idle_insize)/(int)s->cfg.frame_size); in stream_idle()
478 s->insize_done += urb_size; in stream_idle()
480 l = s->idle_outsize; in stream_idle()
481 s->outpacket[0].offset = (sk->idle_outurb->transfer_buffer - in stream_idle()
487 s->outpacket[0].length = sk->idle_outurb->transfer_buffer_length + l; in stream_idle()
488 s->outpacket[1].offset = sk->completed_outurb->transfer_buffer - in stream_idle()
494 loop_back(s); in stream_idle()
495 s->periods_done++; in stream_idle()
499 s->state = usb_stream_xrun; in stream_idle()
520 struct usb_stream *s = sk->s; in stream_start() local
521 if (s->state >= usb_stream_sync1) { in stream_start()
525 frames_per_packet = (s->period_size - s->idle_insize); in stream_start()
528 s->cfg.frame_size * inurb->number_of_packets; in stream_start()
531 max_diff_0 = s->cfg.frame_size; in stream_start()
532 if (s->cfg.period_frames >= 256) in stream_start()
534 if (s->cfg.period_frames >= 1024) in stream_start()
544 (min_frames >> 8) * s->cfg.frame_size; in stream_start()
547 s->insize_done, in stream_start()
548 urb_size / (int)s->cfg.frame_size, in stream_start()
553 s->idle_insize -= max_diff - max_diff_0; in stream_start()
554 s->idle_insize += urb_size - s->period_size; in stream_start()
555 if (s->idle_insize < 0) { in stream_start()
557 s->idle_insize, urb_size, s->period_size); in stream_start()
559 } else if (s->idle_insize == 0) { in stream_start()
560 s->next_inpacket_split = in stream_start()
561 (s->inpacket_head + 1) % s->inpackets; in stream_start()
562 s->next_inpacket_split_at = 0; in stream_start()
564 unsigned split = s->inpacket_head; in stream_start()
565 l = s->idle_insize; in stream_start()
566 while (l > s->inpacket[split].length) { in stream_start()
567 l -= s->inpacket[split].length; in stream_start()
569 split = s->inpackets - 1; in stream_start()
573 s->next_inpacket_split = split; in stream_start()
574 s->next_inpacket_split_at = in stream_start()
575 s->inpacket[split].length - l; in stream_start()
578 s->insize_done += urb_size; in stream_start()
589 if (s->state == usb_stream_sync1 && s->insize_done > 360000) { in stream_start()
591 s->state = usb_stream_ready; in stream_start()
601 struct usb_stream *s = sk->s; in i_capture_start() local
612 if (l < s->cfg.frame_size) { in i_capture_start()
614 if (s->state >= usb_stream_sync0) { in i_capture_start()
619 s->inpacket_head++; in i_capture_start()
620 s->inpacket_head %= s->inpackets; in i_capture_start()
621 s->inpacket[s->inpacket_head].offset = in i_capture_start()
622 id[p].offset + (urb->transfer_buffer - (void *)s); in i_capture_start()
623 s->inpacket[s->inpacket_head].length = l; in i_capture_start()
627 printk(KERN_DEBUG"%s:%i: %i", __func__, __LINE__, in i_capture_start()
636 if (!empty && s->state < usb_stream_sync1) in i_capture_start()
637 ++s->state; in i_capture_start()
652 struct usb_stream *s = sk->s; in usb_stream_start() local
657 if (s->state != usb_stream_stopped) in usb_stream_start()
662 memset(sk->write_page, 0, s->write_size); in usb_stream_start()
664 s->insize_done = 0; in usb_stream_start()
665 s->idle_insize = 0; in usb_stream_start()
666 s->idle_outsize = 0; in usb_stream_start()
667 s->sync_packet = -1; in usb_stream_start()
668 s->inpacket_head = -1; in usb_stream_start()
732 while (s->state != usb_stream_ready && wait_ms > 0) { in usb_stream_start()
733 snd_printdd(KERN_DEBUG "%i\n", s->state); in usb_stream_start()
739 return s->state == usb_stream_ready ? 0 : -EFAULT; in usb_stream_start()
748 if (!sk->s) in usb_stream_stop()
754 sk->s->state = usb_stream_stopped; in usb_stream_stop()