Lines Matching refs:s
47 struct cx18_stream *s = &cx->streams[type]; in cx18_claim_stream() local
57 if (test_and_set_bit(CX18_F_S_CLAIMED, &s->s_flags)) { in cx18_claim_stream()
59 if (s->id == id->open_id) { in cx18_claim_stream()
63 if (s->id == -1 && type == CX18_ENC_STREAM_TYPE_VBI) { in cx18_claim_stream()
67 s->id = id->open_id; in cx18_claim_stream()
75 s->id = id->open_id; in cx18_claim_stream()
104 void cx18_release_stream(struct cx18_stream *s) in cx18_release_stream() argument
106 struct cx18 *cx = s->cx; in cx18_release_stream()
109 s->id = -1; in cx18_release_stream()
110 if (s->type == CX18_ENC_STREAM_TYPE_IDX) { in cx18_release_stream()
118 if (s->type == CX18_ENC_STREAM_TYPE_VBI && in cx18_release_stream()
119 test_bit(CX18_F_S_INTERNAL_USE, &s->s_flags)) { in cx18_release_stream()
123 if (!test_and_clear_bit(CX18_F_S_CLAIMED, &s->s_flags)) { in cx18_release_stream()
124 CX18_DEBUG_WARN("Release stream %s not in use!\n", s->name); in cx18_release_stream()
128 cx18_flush_queues(s); in cx18_release_stream()
136 if (s->type != CX18_ENC_STREAM_TYPE_MPG) in cx18_release_stream()
184 static struct cx18_mdl *cx18_get_mdl(struct cx18_stream *s, int non_block, in cx18_get_mdl() argument
187 struct cx18 *cx = s->cx; in cx18_get_mdl()
194 if (s->type == CX18_ENC_STREAM_TYPE_MPG) { in cx18_get_mdl()
216 mdl = cx18_dequeue(s, &s->q_full); in cx18_get_mdl()
221 if (s->type == CX18_ENC_STREAM_TYPE_MPG) in cx18_get_mdl()
226 cx18_process_vbi_data(cx, mdl, s->type); in cx18_get_mdl()
232 if (!test_bit(CX18_F_S_STREAMING, &s->s_flags)) { in cx18_get_mdl()
233 CX18_DEBUG_INFO("EOS %s\n", s->name); in cx18_get_mdl()
244 prepare_to_wait(&s->waitq, &wait, TASK_INTERRUPTIBLE); in cx18_get_mdl()
247 if (!atomic_read(&s->q_full.depth)) in cx18_get_mdl()
249 finish_wait(&s->waitq, &wait); in cx18_get_mdl()
252 CX18_DEBUG_INFO("User stopped %s\n", s->name); in cx18_get_mdl()
274 static size_t cx18_copy_buf_to_user(struct cx18_stream *s, in cx18_copy_buf_to_user() argument
277 struct cx18 *cx = s->cx; in cx18_copy_buf_to_user()
283 if (cx->vbi.insert_mpeg && s->type == CX18_ENC_STREAM_TYPE_MPG && in cx18_copy_buf_to_user()
368 len, s->name); in cx18_copy_buf_to_user()
372 if (s->type == CX18_ENC_STREAM_TYPE_MPG && in cx18_copy_buf_to_user()
378 static size_t cx18_copy_mdl_to_user(struct cx18_stream *s, in cx18_copy_mdl_to_user() argument
404 rc = cx18_copy_buf_to_user(s, mdl->curr_buf, ubuf + tot_written, in cx18_copy_mdl_to_user()
420 static ssize_t cx18_read(struct cx18_stream *s, char __user *ubuf, in cx18_read() argument
423 struct cx18 *cx = s->cx; in cx18_read()
427 if (atomic_read(&cx->ana_capturing) == 0 && s->id == -1) { in cx18_read()
430 s->name); in cx18_read()
437 if (s->type == CX18_ENC_STREAM_TYPE_VBI && !cx18_raw_vbi(cx)) in cx18_read()
444 mdl = cx18_get_mdl(s, non_block, &rc); in cx18_read()
452 clear_bit(CX18_F_S_STREAMOFF, &s->s_flags); in cx18_read()
453 clear_bit(CX18_F_S_APPL_IO, &s->s_flags); in cx18_read()
454 cx18_release_stream(s); in cx18_read()
460 rc = cx18_copy_mdl_to_user(s, mdl, ubuf + tot_written, in cx18_read()
465 cx18_stream_put_mdl_fw(s, mdl); in cx18_read()
467 cx18_push(s, mdl, &s->q_full); in cx18_read()
485 static ssize_t cx18_read_pos(struct cx18_stream *s, char __user *ubuf, in cx18_read_pos() argument
488 ssize_t rc = count ? cx18_read(s, ubuf, count, non_block) : 0; in cx18_read_pos()
489 struct cx18 *cx = s->cx; in cx18_read_pos()
491 CX18_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc); in cx18_read_pos()
500 struct cx18_stream *s = &cx->streams[id->type]; in cx18_start_capture() local
504 if (s->type == CX18_ENC_STREAM_TYPE_RAD) { in cx18_start_capture()
510 if (cx18_claim_stream(id, s->type)) in cx18_start_capture()
515 if (test_bit(CX18_F_S_STREAMOFF, &s->s_flags) || in cx18_start_capture()
516 test_and_set_bit(CX18_F_S_STREAMING, &s->s_flags)) { in cx18_start_capture()
517 set_bit(CX18_F_S_APPL_IO, &s->s_flags); in cx18_start_capture()
524 if (s->type == CX18_ENC_STREAM_TYPE_MPG) { in cx18_start_capture()
551 if (!cx18_start_v4l2_encode_stream(s)) { in cx18_start_capture()
553 set_bit(CX18_F_S_APPL_IO, &s->s_flags); in cx18_start_capture()
556 cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, s->handle); in cx18_start_capture()
561 CX18_DEBUG_WARN("Failed to start capturing for stream %s\n", s->name); in cx18_start_capture()
568 if (s->type == CX18_ENC_STREAM_TYPE_MPG) { in cx18_start_capture()
581 clear_bit(CX18_F_S_STREAMING, &s->s_flags); in cx18_start_capture()
582 cx18_release_stream(s); /* Also releases associated streams */ in cx18_start_capture()
591 struct cx18_stream *s = &cx->streams[id->type]; in cx18_v4l2_read() local
594 CX18_DEBUG_HI_FILE("read %zd bytes from %s\n", count, s->name); in cx18_v4l2_read()
602 if ((s->vb_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_v4l2_read()
604 return videobuf_read_stream(&s->vbuf_q, buf, count, pos, 0, in cx18_v4l2_read()
608 return cx18_read_pos(s, buf, count, pos, filp->f_flags & O_NONBLOCK); in cx18_v4l2_read()
616 struct cx18_stream *s = &cx->streams[id->type]; in cx18_v4l2_enc_poll() local
617 int eof = test_bit(CX18_F_S_STREAMOFF, &s->s_flags); in cx18_v4l2_enc_poll()
621 if (!eof && !test_bit(CX18_F_S_STREAMING, &s->s_flags) && in cx18_v4l2_enc_poll()
630 s->name, rc); in cx18_v4l2_enc_poll()
636 if ((s->vb_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_v4l2_enc_poll()
638 int videobuf_poll = videobuf_poll_stream(filp, &s->vbuf_q, wait); in cx18_v4l2_enc_poll()
652 poll_wait(filp, &s->waitq, wait); in cx18_v4l2_enc_poll()
654 if (atomic_read(&s->q_full.depth)) in cx18_v4l2_enc_poll()
665 struct cx18_stream *s = &cx->streams[id->type]; in cx18_v4l2_mmap() local
666 int eof = test_bit(CX18_F_S_STREAMOFF, &s->s_flags); in cx18_v4l2_mmap()
668 if ((s->vb_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) && in cx18_v4l2_mmap()
672 if (!eof && !test_bit(CX18_F_S_STREAMING, &s->s_flags)) { in cx18_v4l2_mmap()
681 s->name, rc); in cx18_v4l2_mmap()
687 return videobuf_mmap_mapper(&s->vbuf_q, vma); in cx18_v4l2_mmap()
695 struct cx18_stream *s = (struct cx18_stream *)data; in cx18_vb_timeout() local
702 spin_lock_irqsave(&s->vb_lock, flags); in cx18_vb_timeout()
703 while (!list_empty(&s->vb_capture)) { in cx18_vb_timeout()
704 buf = list_entry(s->vb_capture.next, in cx18_vb_timeout()
710 spin_unlock_irqrestore(&s->vb_lock, flags); in cx18_vb_timeout()
716 struct cx18_stream *s = &cx->streams[id->type]; in cx18_stop_capture() local
720 CX18_DEBUG_IOCTL("close() of %s\n", s->name); in cx18_stop_capture()
725 if (test_bit(CX18_F_S_STREAMING, &s->s_flags)) { in cx18_stop_capture()
741 test_bit(CX18_F_S_INTERNAL_USE, &s->s_flags)) in cx18_stop_capture()
743 s->id = -1; in cx18_stop_capture()
745 cx18_stop_v4l2_encode_stream(s, gop_end); in cx18_stop_capture()
748 clear_bit(CX18_F_S_APPL_IO, &s->s_flags); in cx18_stop_capture()
749 clear_bit(CX18_F_S_STREAMOFF, &s->s_flags); in cx18_stop_capture()
750 cx18_release_stream(s); in cx18_stop_capture()
759 struct cx18_stream *s = &cx->streams[id->type]; in cx18_v4l2_close() local
761 CX18_DEBUG_IOCTL("close() of %s\n", s->name); in cx18_v4l2_close()
777 cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, in cx18_v4l2_close()
789 if (s->id == id->open_id) in cx18_v4l2_close()
796 static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) in cx18_serialized_open() argument
798 struct cx18 *cx = s->cx; in cx18_serialized_open()
801 CX18_DEBUG_FILE("open %s\n", s->name); in cx18_serialized_open()
809 v4l2_fh_init(&item->fh, &s->video_dev); in cx18_serialized_open()
812 item->type = s->type; in cx18_serialized_open()
849 struct cx18_stream *s = video_get_drvdata(video_dev); in cx18_v4l2_open() local
850 struct cx18 *cx = s->cx; in cx18_v4l2_open()
859 res = cx18_serialized_open(s, filp); in cx18_v4l2_open()