Lines Matching refs:s
35 struct ivtv_stream *s = &itv->streams[type]; in ivtv_claim_stream() local
39 if (test_and_set_bit(IVTV_F_S_CLAIMED, &s->s_flags)) { in ivtv_claim_stream()
41 if (s->fh == &id->fh) { in ivtv_claim_stream()
45 if (s->fh == NULL && (type == IVTV_DEC_STREAM_TYPE_VBI || in ivtv_claim_stream()
50 s->fh = &id->fh; in ivtv_claim_stream()
58 s->fh = &id->fh; in ivtv_claim_stream()
91 void ivtv_release_stream(struct ivtv_stream *s) in ivtv_release_stream() argument
93 struct ivtv *itv = s->itv; in ivtv_release_stream()
96 s->fh = NULL; in ivtv_release_stream()
97 if ((s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type == IVTV_ENC_STREAM_TYPE_VBI) && in ivtv_release_stream()
98 test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) { in ivtv_release_stream()
102 if (!test_and_clear_bit(IVTV_F_S_CLAIMED, &s->s_flags)) { in ivtv_release_stream()
103 IVTV_DEBUG_WARN("Release stream %s not in use!\n", s->name); in ivtv_release_stream()
107 ivtv_flush_queues(s); in ivtv_release_stream()
110 if (s->type == IVTV_DEC_STREAM_TYPE_VBI) in ivtv_release_stream()
116 if (s->type == IVTV_DEC_STREAM_TYPE_MPG) in ivtv_release_stream()
118 else if (s->type == IVTV_ENC_STREAM_TYPE_MPG) in ivtv_release_stream()
193 static struct ivtv_buffer *ivtv_get_buffer(struct ivtv_stream *s, int non_block, int *err) in ivtv_get_buffer() argument
195 struct ivtv *itv = s->itv; in ivtv_get_buffer()
202 if (s->type == IVTV_ENC_STREAM_TYPE_MPG) { in ivtv_get_buffer()
228 buf = ivtv_dequeue(s, &s->q_io); in ivtv_get_buffer()
233 buf = ivtv_dequeue(s, &s->q_full); in ivtv_get_buffer()
238 if (s->type == IVTV_ENC_STREAM_TYPE_MPG) in ivtv_get_buffer()
241 else if (s->type != IVTV_DEC_STREAM_TYPE_VBI) { in ivtv_get_buffer()
243 ivtv_process_vbi_data(itv, buf, s->dma_pts, s->type); in ivtv_get_buffer()
249 if (s->type != IVTV_DEC_STREAM_TYPE_VBI && !test_bit(IVTV_F_S_STREAMING, &s->s_flags)) { in ivtv_get_buffer()
250 IVTV_DEBUG_INFO("EOS %s\n", s->name); in ivtv_get_buffer()
262 prepare_to_wait(&s->waitq, &wait, TASK_INTERRUPTIBLE); in ivtv_get_buffer()
264 if (!s->q_full.buffers) in ivtv_get_buffer()
266 finish_wait(&s->waitq, &wait); in ivtv_get_buffer()
270 IVTV_DEBUG_INFO("User stopped %s\n", s->name); in ivtv_get_buffer()
286 static size_t ivtv_copy_buf_to_user(struct ivtv_stream *s, struct ivtv_buffer *buf, in ivtv_copy_buf_to_user() argument
289 struct ivtv *itv = s->itv; in ivtv_copy_buf_to_user()
293 if (itv->vbi.insert_mpeg && s->type == IVTV_ENC_STREAM_TYPE_MPG && in ivtv_copy_buf_to_user()
334 IVTV_DEBUG_WARN("copy %zd bytes to user failed for %s\n", len, s->name); in ivtv_copy_buf_to_user()
341 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && buf != &itv->vbi.sliced_mpeg_buf) in ivtv_copy_buf_to_user()
346 static ssize_t ivtv_read(struct ivtv_stream *s, char __user *ubuf, size_t tot_count, int non_block) in ivtv_read() argument
348 struct ivtv *itv = s->itv; in ivtv_read()
352 if (atomic_read(&itv->capturing) == 0 && s->fh == NULL) { in ivtv_read()
354 IVTV_DEBUG_WARN("Stream %s not initialized before read\n", s->name); in ivtv_read()
360 if (s->type == IVTV_DEC_STREAM_TYPE_VBI || in ivtv_read()
361 (s->type == IVTV_ENC_STREAM_TYPE_VBI && !ivtv_raw_vbi(itv))) in ivtv_read()
368 buf = ivtv_get_buffer(s, non_block, &rc); in ivtv_read()
376 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); in ivtv_read()
377 clear_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_read()
378 ivtv_release_stream(s); in ivtv_read()
383 rc = ivtv_copy_buf_to_user(s, buf, ubuf + tot_written, tot_count - tot_written); in ivtv_read()
385 ivtv_enqueue(s, buf, (buf->readpos == buf->bytesused) ? &s->q_free : &s->q_io); in ivtv_read()
403 static ssize_t ivtv_read_pos(struct ivtv_stream *s, char __user *ubuf, size_t count, in ivtv_read_pos() argument
406 ssize_t rc = count ? ivtv_read(s, ubuf, count, non_block) : 0; in ivtv_read_pos()
407 struct ivtv *itv = s->itv; in ivtv_read_pos()
409 IVTV_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc); in ivtv_read_pos()
418 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_start_capture() local
421 if (s->type == IVTV_ENC_STREAM_TYPE_RAD || in ivtv_start_capture()
422 s->type == IVTV_DEC_STREAM_TYPE_MPG || in ivtv_start_capture()
423 s->type == IVTV_DEC_STREAM_TYPE_YUV || in ivtv_start_capture()
424 s->type == IVTV_DEC_STREAM_TYPE_VOUT) { in ivtv_start_capture()
430 if (ivtv_claim_stream(id, s->type)) in ivtv_start_capture()
434 if (s->type == IVTV_DEC_STREAM_TYPE_VBI) { in ivtv_start_capture()
435 set_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_start_capture()
441 …if (test_bit(IVTV_F_S_STREAMOFF, &s->s_flags) || test_and_set_bit(IVTV_F_S_STREAMING, &s->s_flags)… in ivtv_start_capture()
442 set_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_start_capture()
448 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && in ivtv_start_capture()
459 clear_bit(IVTV_F_S_STREAMING, &s->s_flags); in ivtv_start_capture()
461 ivtv_release_stream(s); in ivtv_start_capture()
468 if (!ivtv_start_v4l2_encode_stream(s)) { in ivtv_start_capture()
470 set_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_start_capture()
478 IVTV_DEBUG_WARN("Failed to start capturing for stream %s\n", s->name); in ivtv_start_capture()
483 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && in ivtv_start_capture()
488 clear_bit(IVTV_F_S_STREAMING, &s->s_flags); in ivtv_start_capture()
489 ivtv_release_stream(s); in ivtv_start_capture()
497 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_v4l2_read() local
500 IVTV_DEBUG_HI_FILE("read %zd bytes from %s\n", count, s->name); in ivtv_v4l2_read()
506 rc = ivtv_read_pos(s, buf, count, pos, filp->f_flags & O_NONBLOCK); in ivtv_v4l2_read()
514 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_start_decoding() local
518 if (ivtv_claim_stream(id, s->type)) { in ivtv_start_decoding()
523 rc = ivtv_start_v4l2_decode_stream(s, 0); in ivtv_start_decoding()
526 rc = ivtv_start_v4l2_decode_stream(s, 0); in ivtv_start_decoding()
531 if (s->type == IVTV_DEC_STREAM_TYPE_MPG) in ivtv_start_decoding()
540 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_write() local
549 IVTV_DEBUG_HI_FILE("write %zd bytes to %s\n", count, s->name); in ivtv_write()
551 if (s->type != IVTV_DEC_STREAM_TYPE_MPG && in ivtv_write()
552 s->type != IVTV_DEC_STREAM_TYPE_YUV && in ivtv_write()
553 s->type != IVTV_DEC_STREAM_TYPE_VOUT) in ivtv_write()
558 if (ivtv_claim_stream(id, s->type)) in ivtv_write()
562 if (s->type == IVTV_DEC_STREAM_TYPE_VOUT) { in ivtv_write()
565 set_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_write()
570 mode = s->type == IVTV_DEC_STREAM_TYPE_MPG ? OUT_MPG : OUT_YUV; in ivtv_write()
573 ivtv_release_stream(s); in ivtv_write()
577 set_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_write()
582 IVTV_DEBUG_WARN("Failed start decode stream %s\n", s->name); in ivtv_write()
585 clear_bit(IVTV_F_S_STREAMING, &s->s_flags); in ivtv_write()
586 clear_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_write()
593 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) { in ivtv_write()
605 IVTV_DEBUG_HI_FILE("Wrote %d bytes to %s (%d)\n", bytes_written, s->name, s->q_full.bytesused); in ivtv_write()
612 while (q.length - q.bytesused < count && (buf = ivtv_dequeue(s, &s->q_io))) in ivtv_write()
613 ivtv_enqueue(s, buf, &q); in ivtv_write()
614 while (q.length - q.bytesused < count && (buf = ivtv_dequeue(s, &s->q_free))) { in ivtv_write()
615 ivtv_enqueue(s, buf, &q); in ivtv_write()
622 prepare_to_wait(&s->waitq, &wait, TASK_INTERRUPTIBLE); in ivtv_write()
624 if (!s->q_free.buffers) in ivtv_write()
626 finish_wait(&s->waitq, &wait); in ivtv_write()
629 IVTV_DEBUG_INFO("User stopped %s\n", s->name); in ivtv_write()
635 while ((buf = ivtv_dequeue(s, &q))) { in ivtv_write()
638 if (s->type == IVTV_DEC_STREAM_TYPE_YUV && in ivtv_write()
640 rc = ivtv_buf_copy_from_user(s, buf, user_buf, in ivtv_write()
643 rc = ivtv_buf_copy_from_user(s, buf, user_buf, count); in ivtv_write()
647 ivtv_queue_move(s, &q, NULL, &s->q_free, 0); in ivtv_write()
654 if (s->type == IVTV_DEC_STREAM_TYPE_YUV) { in ivtv_write()
658 ivtv_enqueue(s, buf, &s->q_full); in ivtv_write()
664 if (buf->bytesused != s->buf_size) { in ivtv_write()
666 ivtv_enqueue(s, buf, &s->q_io); in ivtv_write()
670 if (s->type == IVTV_DEC_STREAM_TYPE_MPG) in ivtv_write()
672 ivtv_enqueue(s, buf, &s->q_full); in ivtv_write()
675 if (test_bit(IVTV_F_S_NEEDS_DATA, &s->s_flags)) { in ivtv_write()
676 if (s->q_full.length >= itv->dma_data_req_size) { in ivtv_write()
685 test_bit(IVTV_F_S_DMA_PENDING, &s->s_flags)) { in ivtv_write()
691 IVTV_DEBUG_INFO("User interrupted %s\n", s->name); in ivtv_write()
695 clear_bit(IVTV_F_S_NEEDS_DATA, &s->s_flags); in ivtv_write()
696 ivtv_queue_move(s, &s->q_full, NULL, &s->q_predma, itv->dma_data_req_size); in ivtv_write()
697 ivtv_dma_stream_dec_prepare(s, itv->dma_data_req_offset + IVTV_DECODER_OFFSET, 1); in ivtv_write()
704 IVTV_DEBUG_HI_FILE("Wrote %d bytes to %s (%d)\n", bytes_written, s->name, s->q_full.bytesused); in ivtv_write()
725 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_v4l2_dec_poll() local
742 poll_wait(filp, &s->waitq, wait); in ivtv_v4l2_dec_poll()
750 if (s->q_free.buffers) in ivtv_v4l2_dec_poll()
760 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_v4l2_enc_poll() local
761 int eof = test_bit(IVTV_F_S_STREAMOFF, &s->s_flags); in ivtv_v4l2_enc_poll()
765 if (!eof && !test_bit(IVTV_F_S_STREAMING, &s->s_flags) && in ivtv_v4l2_enc_poll()
766 s->type != IVTV_ENC_STREAM_TYPE_RAD && in ivtv_v4l2_enc_poll()
775 s->name, rc); in ivtv_v4l2_enc_poll()
783 poll_wait(filp, &s->waitq, wait); in ivtv_v4l2_enc_poll()
789 if (s->q_full.length || s->q_io.length) in ivtv_v4l2_enc_poll()
799 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_stop_capture() local
801 IVTV_DEBUG_FILE("close() of %s\n", s->name); in ivtv_stop_capture()
806 if (test_bit(IVTV_F_S_STREAMING, &s->s_flags)) { in ivtv_stop_capture()
820 test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) { in ivtv_stop_capture()
822 s->fh = NULL; in ivtv_stop_capture()
825 ivtv_stop_v4l2_encode_stream(s, gop_end); in ivtv_stop_capture()
829 clear_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_stop_capture()
830 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); in ivtv_stop_capture()
831 ivtv_release_stream(s); in ivtv_stop_capture()
838 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_stop_decoding() local
840 IVTV_DEBUG_FILE("close() of %s\n", s->name); in ivtv_stop_decoding()
849 if (test_bit(IVTV_F_S_STREAMING, &s->s_flags)) { in ivtv_stop_decoding()
852 ivtv_stop_v4l2_decode_stream(s, flags, pts); in ivtv_stop_decoding()
855 clear_bit(IVTV_F_S_APPL_IO, &s->s_flags); in ivtv_stop_decoding()
856 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); in ivtv_stop_decoding()
863 ivtv_release_stream(s); in ivtv_stop_decoding()
871 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_v4l2_close() local
873 IVTV_DEBUG_FILE("close %s\n", s->name); in ivtv_v4l2_close()
906 if (s->fh != &id->fh) in ivtv_v4l2_close()
911 if (s->type >= IVTV_DEC_STREAM_TYPE_MPG) { in ivtv_v4l2_close()
934 struct ivtv_stream *s = video_get_drvdata(vdev); local
935 struct ivtv *itv = s->itv;
939 IVTV_DEBUG_FILE("open %s\n", s->name);
964 if (s->type == IVTV_DEC_STREAM_TYPE_MPG &&
968 if (s->type == IVTV_DEC_STREAM_TYPE_YUV &&
972 if (s->type == IVTV_DEC_STREAM_TYPE_YUV) {
986 v4l2_fh_init(&item->fh, &s->vdev);
988 item->type = s->type;
1022 if (s->type == IVTV_DEC_STREAM_TYPE_MPG) {
1024 } else if (s->type == IVTV_DEC_STREAM_TYPE_YUV) {