Lines Matching full:s
108 struct cx18_stream *s = vb2_get_drv_priv(vq); in cx18_queue_setup() local
109 struct cx18 *cx = s->cx; in cx18_queue_setup()
116 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_queue_setup()
122 * Let's request at least three buffers: two for the in cx18_queue_setup()
141 struct cx18_stream *s = vb2_get_drv_priv(vb->vb2_queue); in cx18_buf_queue() local
147 spin_lock_irqsave(&s->vb_lock, flags); in cx18_buf_queue()
148 list_add_tail(&buf->list, &s->vb_capture); in cx18_buf_queue()
149 spin_unlock_irqrestore(&s->vb_lock, flags); in cx18_buf_queue()
155 struct cx18_stream *s = vb2_get_drv_priv(vb->vb2_queue); in cx18_buf_prepare() local
156 struct cx18 *cx = s->cx; in cx18_buf_prepare()
163 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_buf_prepare()
175 void cx18_clear_queue(struct cx18_stream *s, enum vb2_buffer_state state) in cx18_clear_queue() argument
177 while (!list_empty(&s->vb_capture)) { in cx18_clear_queue()
180 buf = list_first_entry(&s->vb_capture, in cx18_clear_queue()
190 struct cx18_stream *s = vb2_get_drv_priv(vq); in cx18_start_streaming() local
199 s->sequence = 0; in cx18_start_streaming()
203 mod_timer(&s->vb_timeout, msecs_to_jiffies(2000) + jiffies); in cx18_start_streaming()
208 spin_lock_irqsave(&s->vb_lock, flags); in cx18_start_streaming()
209 cx18_clear_queue(s, VB2_BUF_STATE_QUEUED); in cx18_start_streaming()
210 spin_unlock_irqrestore(&s->vb_lock, flags); in cx18_start_streaming()
216 struct cx18_stream *s = vb2_get_drv_priv(vq); in cx18_stop_streaming() local
219 cx18_stop_capture(s, 0); in cx18_stop_streaming()
220 timer_delete_sync(&s->vb_timeout); in cx18_stop_streaming()
221 spin_lock_irqsave(&s->vb_lock, flags); in cx18_stop_streaming()
222 cx18_clear_queue(s, VB2_BUF_STATE_ERROR); in cx18_stop_streaming()
223 spin_unlock_irqrestore(&s->vb_lock, flags); in cx18_stop_streaming()
238 struct cx18_stream *s = &cx->streams[type]; in cx18_stream_init() local
241 memset(s, 0, sizeof(*s)); in cx18_stream_init()
244 s->dvb = NULL; in cx18_stream_init()
245 s->cx = cx; in cx18_stream_init()
246 s->type = type; in cx18_stream_init()
247 s->name = cx18_stream_info[type].name; in cx18_stream_init()
248 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_stream_init()
250 s->dma = cx18_stream_info[type].dma; in cx18_stream_init()
251 s->v4l2_dev_caps = cx18_stream_info[type].caps; in cx18_stream_init()
252 s->buffers = cx->stream_buffers[type]; in cx18_stream_init()
253 s->buf_size = cx->stream_buf_size[type]; in cx18_stream_init()
254 INIT_LIST_HEAD(&s->buf_pool); in cx18_stream_init()
255 s->bufs_per_mdl = 1; in cx18_stream_init()
256 s->mdl_size = s->buf_size * s->bufs_per_mdl; in cx18_stream_init()
258 init_waitqueue_head(&s->waitq); in cx18_stream_init()
259 s->id = -1; in cx18_stream_init()
260 spin_lock_init(&s->q_free.lock); in cx18_stream_init()
261 cx18_queue_init(&s->q_free); in cx18_stream_init()
262 spin_lock_init(&s->q_busy.lock); in cx18_stream_init()
263 cx18_queue_init(&s->q_busy); in cx18_stream_init()
264 spin_lock_init(&s->q_full.lock); in cx18_stream_init()
265 cx18_queue_init(&s->q_full); in cx18_stream_init()
266 spin_lock_init(&s->q_idle.lock); in cx18_stream_init()
267 cx18_queue_init(&s->q_idle); in cx18_stream_init()
269 INIT_WORK(&s->out_work_order, cx18_out_work_handler); in cx18_stream_init()
271 INIT_LIST_HEAD(&s->vb_capture); in cx18_stream_init()
272 timer_setup(&s->vb_timeout, cx18_vb_timeout, 0); in cx18_stream_init()
273 spin_lock_init(&s->vb_lock); in cx18_stream_init()
276 s->vb_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx18_stream_init()
279 s->pixelformat = V4L2_PIX_FMT_NV12_16L16; in cx18_stream_init()
280 s->vb_bytes_per_frame = cx->cxhdl.height * 720 * 3 / 2; in cx18_stream_init()
281 s->vb_bytes_per_line = 720; in cx18_stream_init()
283 s->vidq.io_modes = VB2_READ | VB2_MMAP | VB2_DMABUF; in cx18_stream_init()
284 s->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx18_stream_init()
285 s->vidq.drv_priv = s; in cx18_stream_init()
286 s->vidq.buf_struct_size = sizeof(struct cx18_vb2_buffer); in cx18_stream_init()
287 s->vidq.ops = &cx18_vb2_qops; in cx18_stream_init()
288 s->vidq.mem_ops = &vb2_vmalloc_memops; in cx18_stream_init()
289 s->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx18_stream_init()
290 s->vidq.min_queued_buffers = 2; in cx18_stream_init()
291 s->vidq.gfp_flags = GFP_DMA32; in cx18_stream_init()
292 s->vidq.dev = &cx->pci_dev->dev; in cx18_stream_init()
293 s->vidq.lock = &cx->serialize_lock; in cx18_stream_init()
295 err = vb2_queue_init(&s->vidq); in cx18_stream_init()
298 s->video_dev.queue = &s->vidq; in cx18_stream_init()
305 struct cx18_stream *s = &cx->streams[type]; in cx18_prep_dev() local
318 s->video_dev.v4l2_dev = NULL; in cx18_prep_dev()
319 s->dvb = NULL; in cx18_prep_dev()
320 s->cx = cx; in cx18_prep_dev()
321 s->type = type; in cx18_prep_dev()
322 s->name = cx18_stream_info[type].name; in cx18_prep_dev()
337 CX18_INFO("Disabled %s device\n", cx18_stream_info[type].name); in cx18_prep_dev()
348 s->dvb = kzalloc(sizeof(struct cx18_dvb), GFP_KERNEL); in cx18_prep_dev()
349 if (s->dvb == NULL) { in cx18_prep_dev()
350 CX18_ERR("Couldn't allocate cx18_dvb structure for %s\n", in cx18_prep_dev()
351 s->name); in cx18_prep_dev()
356 s->buffers = 0; in cx18_prep_dev()
364 snprintf(s->video_dev.name, sizeof(s->video_dev.name), "%s %s", in cx18_prep_dev()
365 cx->v4l2_dev.name, s->name); in cx18_prep_dev()
367 s->video_dev.num = num; in cx18_prep_dev()
368 s->video_dev.v4l2_dev = &cx->v4l2_dev; in cx18_prep_dev()
370 s->video_dev.fops = &cx18_v4l2_enc_yuv_fops; in cx18_prep_dev()
372 s->video_dev.fops = &cx18_v4l2_enc_fops; in cx18_prep_dev()
373 s->video_dev.release = video_device_release_empty; in cx18_prep_dev()
375 s->video_dev.tvnorms = cx->tuner_std; in cx18_prep_dev()
377 s->video_dev.tvnorms = V4L2_STD_ALL; in cx18_prep_dev()
378 s->video_dev.lock = &cx->serialize_lock; in cx18_prep_dev()
379 cx18_set_funcs(&s->video_dev); in cx18_prep_dev()
410 struct cx18_stream *s = &cx->streams[type]; in cx18_reg_dev() local
415 if (type == CX18_ENC_STREAM_TYPE_TS && s->dvb != NULL) { in cx18_reg_dev()
416 ret = cx18_dvb_register(s); in cx18_reg_dev()
423 if (s->video_dev.v4l2_dev == NULL) in cx18_reg_dev()
426 num = s->video_dev.num; in cx18_reg_dev()
427 s->video_dev.device_caps = s->v4l2_dev_caps; /* device capabilities */ in cx18_reg_dev()
436 video_set_drvdata(&s->video_dev, s); in cx18_reg_dev()
439 ret = video_register_device_no_warn(&s->video_dev, vfl_type, num); in cx18_reg_dev()
441 CX18_ERR("Couldn't register v4l2 device for %s (device node number %d)\n", in cx18_reg_dev()
442 s->name, num); in cx18_reg_dev()
443 s->video_dev.v4l2_dev = NULL; in cx18_reg_dev()
447 name = video_device_node_name(&s->video_dev); in cx18_reg_dev()
451 CX18_INFO("Registered device %s for %s (%d x %d.%02d kB)\n", in cx18_reg_dev()
452 name, s->name, cx->stream_buffers[type], in cx18_reg_dev()
458 CX18_INFO("Registered device %s for %s\n", name, s->name); in cx18_reg_dev()
463 CX18_INFO("Registered device %s for %s (%d x %d bytes)\n", in cx18_reg_dev()
464 name, s->name, cx->stream_buffers[type], in cx18_reg_dev()
467 CX18_INFO("Registered device %s for %s\n", in cx18_reg_dev()
468 name, s->name); in cx18_reg_dev()
550 static void cx18_vbi_setup(struct cx18_stream *s) in cx18_vbi_setup() argument
552 struct cx18 *cx = s->cx; in cx18_vbi_setup()
586 * The EAV RP code's Field bit toggles on line 4, a few lines in cx18_vbi_setup()
592 * The EAV RP code's Field bit toggles on line 1, a few lines in cx18_vbi_setup()
601 data[0] = s->handle; in cx18_vbi_setup()
662 struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; in cx18_stream_rotate_idx_mdls() local
665 if (!cx18_stream_enabled(s)) in cx18_stream_rotate_idx_mdls()
669 if ((atomic_read(&s->q_free.depth) + atomic_read(&s->q_busy.depth)) >= in cx18_stream_rotate_idx_mdls()
674 if (atomic_read(&s->q_full.depth) < 2) in cx18_stream_rotate_idx_mdls()
681 mdl = cx18_dequeue(s, &s->q_full); in cx18_stream_rotate_idx_mdls()
683 cx18_enqueue(s, mdl, &s->q_free); in cx18_stream_rotate_idx_mdls()
687 struct cx18_queue *_cx18_stream_put_mdl_fw(struct cx18_stream *s, in _cx18_stream_put_mdl_fw() argument
690 struct cx18 *cx = s->cx; in _cx18_stream_put_mdl_fw()
694 if (s->handle == CX18_INVALID_TASK_HANDLE || in _cx18_stream_put_mdl_fw()
695 test_bit(CX18_F_S_STOPPING, &s->s_flags) || in _cx18_stream_put_mdl_fw()
696 !test_bit(CX18_F_S_STREAMING, &s->s_flags)) in _cx18_stream_put_mdl_fw()
697 return cx18_enqueue(s, mdl, &s->q_free); in _cx18_stream_put_mdl_fw()
699 q = cx18_enqueue(s, mdl, &s->q_busy); in _cx18_stream_put_mdl_fw()
700 if (q != &s->q_busy) in _cx18_stream_put_mdl_fw()
703 cx18_mdl_sync_for_device(s, mdl); in _cx18_stream_put_mdl_fw()
704 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, in _cx18_stream_put_mdl_fw()
706 s->bufs_per_mdl, mdl->id, s->mdl_size); in _cx18_stream_put_mdl_fw()
711 void _cx18_stream_load_fw_queue(struct cx18_stream *s) in _cx18_stream_load_fw_queue() argument
716 if (atomic_read(&s->q_free.depth) == 0 || in _cx18_stream_load_fw_queue()
717 atomic_read(&s->q_busy.depth) >= CX18_MAX_FW_MDLS_PER_STREAM) in _cx18_stream_load_fw_queue()
722 mdl = cx18_dequeue(s, &s->q_free); in _cx18_stream_load_fw_queue()
725 q = _cx18_stream_put_mdl_fw(s, mdl); in _cx18_stream_load_fw_queue()
726 } while (atomic_read(&s->q_busy.depth) < CX18_MAX_FW_MDLS_PER_STREAM in _cx18_stream_load_fw_queue()
727 && q == &s->q_busy); in _cx18_stream_load_fw_queue()
732 struct cx18_stream *s = in cx18_out_work_handler() local
735 _cx18_stream_load_fw_queue(s); in cx18_out_work_handler()
738 static void cx18_stream_configure_mdls(struct cx18_stream *s) in cx18_stream_configure_mdls() argument
740 cx18_unload_queues(s); in cx18_stream_configure_mdls()
742 switch (s->type) { in cx18_stream_configure_mdls()
749 if (s->pixelformat == V4L2_PIX_FMT_NV12_16L16) in cx18_stream_configure_mdls()
750 s->mdl_size = 720 * s->cx->cxhdl.height * 3 / 2; in cx18_stream_configure_mdls()
752 s->mdl_size = 720 * s->cx->cxhdl.height * 2; in cx18_stream_configure_mdls()
753 s->bufs_per_mdl = s->mdl_size / s->buf_size; in cx18_stream_configure_mdls()
754 if (s->mdl_size % s->buf_size) in cx18_stream_configure_mdls()
755 s->bufs_per_mdl++; in cx18_stream_configure_mdls()
758 s->bufs_per_mdl = 1; in cx18_stream_configure_mdls()
759 if (cx18_raw_vbi(s->cx)) { in cx18_stream_configure_mdls()
760 s->mdl_size = (s->cx->is_60hz ? 12 : 18) in cx18_stream_configure_mdls()
768 s->mdl_size = s->cx->is_60hz in cx18_stream_configure_mdls()
774 s->bufs_per_mdl = 1; in cx18_stream_configure_mdls()
775 s->mdl_size = s->buf_size * s->bufs_per_mdl; in cx18_stream_configure_mdls()
779 cx18_load_queues(s); in cx18_stream_configure_mdls()
782 int cx18_start_v4l2_encode_stream(struct cx18_stream *s) in cx18_start_v4l2_encode_stream() argument
785 struct cx18 *cx = s->cx; in cx18_start_v4l2_encode_stream()
789 if (!cx18_stream_enabled(s)) in cx18_start_v4l2_encode_stream()
792 CX18_DEBUG_INFO("Start encoder stream %s\n", s->name); in cx18_start_v4l2_encode_stream()
794 switch (s->type) { in cx18_start_v4l2_encode_stream()
836 clear_bit(CX18_F_S_STREAMOFF, &s->s_flags); in cx18_start_v4l2_encode_stream()
839 s->handle = data[0]; in cx18_start_v4l2_encode_stream()
840 cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype); in cx18_start_v4l2_encode_stream()
848 * channel types. We're hoping there's no harm in calling most of them in cx18_start_v4l2_encode_stream()
854 cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0); in cx18_start_v4l2_encode_stream()
855 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1); in cx18_start_v4l2_encode_stream()
856 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 8, 0); in cx18_start_v4l2_encode_stream()
857 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 4, 1); in cx18_start_v4l2_encode_stream()
865 s->handle, 12); in cx18_start_v4l2_encode_stream()
874 s->handle, 312, 313); in cx18_start_v4l2_encode_stream()
877 cx18_vbi_setup(s); in cx18_start_v4l2_encode_stream()
886 s->handle, cx18_stream_enabled(s_idx) ? 7 : 0); in cx18_start_v4l2_encode_stream()
889 cx->cxhdl.priv = s; in cx18_start_v4l2_encode_stream()
898 cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, in cx18_start_v4l2_encode_stream()
905 if (s->pixelformat == V4L2_PIX_FMT_UYVY) in cx18_start_v4l2_encode_stream()
907 s->handle, 1); in cx18_start_v4l2_encode_stream()
911 s->handle, 0); in cx18_start_v4l2_encode_stream()
921 cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle, in cx18_start_v4l2_encode_stream()
922 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem, in cx18_start_v4l2_encode_stream()
923 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem); in cx18_start_v4l2_encode_stream()
926 cx18_stream_configure_mdls(s); in cx18_start_v4l2_encode_stream()
927 _cx18_stream_load_fw_queue(s); in cx18_start_v4l2_encode_stream()
930 if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) { in cx18_start_v4l2_encode_stream()
933 set_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_start_v4l2_encode_stream()
934 if (s->type == CX18_ENC_STREAM_TYPE_MPG) in cx18_start_v4l2_encode_stream()
935 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, 1); in cx18_start_v4l2_encode_stream()
937 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 1, s->handle); in cx18_start_v4l2_encode_stream()
938 clear_bit(CX18_F_S_STREAMING, &s->s_flags); in cx18_start_v4l2_encode_stream()
940 cx18_vapi(cx, CX18_CPU_DE_RELEASE_MDL, 1, s->handle); in cx18_start_v4l2_encode_stream()
941 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); in cx18_start_v4l2_encode_stream()
942 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_start_v4l2_encode_stream()
943 clear_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_start_v4l2_encode_stream()
964 struct cx18_stream *s = &cx->streams[i]; in cx18_stop_all_captures() local
966 if (!cx18_stream_enabled(s)) in cx18_stop_all_captures()
968 if (test_bit(CX18_F_S_STREAMING, &s->s_flags)) in cx18_stop_all_captures()
969 cx18_stop_v4l2_encode_stream(s, 0); in cx18_stop_all_captures()
973 int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end) in cx18_stop_v4l2_encode_stream() argument
975 struct cx18 *cx = s->cx; in cx18_stop_v4l2_encode_stream()
977 if (!cx18_stream_enabled(s)) in cx18_stop_v4l2_encode_stream()
988 set_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
989 if (s->type == CX18_ENC_STREAM_TYPE_MPG) in cx18_stop_v4l2_encode_stream()
990 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, !gop_end); in cx18_stop_v4l2_encode_stream()
992 cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 1, s->handle); in cx18_stop_v4l2_encode_stream()
994 if (s->type == CX18_ENC_STREAM_TYPE_MPG && gop_end) { in cx18_stop_v4l2_encode_stream()
998 if (s->type != CX18_ENC_STREAM_TYPE_TS) in cx18_stop_v4l2_encode_stream()
1003 clear_bit(CX18_F_S_STREAMING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
1006 cx18_vapi(cx, CX18_CPU_DE_RELEASE_MDL, 1, s->handle); in cx18_stop_v4l2_encode_stream()
1008 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); in cx18_stop_v4l2_encode_stream()
1009 s->handle = CX18_INVALID_TASK_HANDLE; in cx18_stop_v4l2_encode_stream()
1010 clear_bit(CX18_F_S_STOPPING, &s->s_flags); in cx18_stop_v4l2_encode_stream()
1017 wake_up(&s->waitq); in cx18_stop_v4l2_encode_stream()
1029 struct cx18_stream *s = &cx->streams[i]; in cx18_find_handle() local
1031 if (s->video_dev.v4l2_dev && (s->handle != CX18_INVALID_TASK_HANDLE)) in cx18_find_handle()
1032 return s->handle; in cx18_find_handle()
1040 struct cx18_stream *s; in cx18_handle_to_stream() local
1046 s = &cx->streams[i]; in cx18_handle_to_stream()
1047 if (s->handle != handle) in cx18_handle_to_stream()
1049 if (cx18_stream_enabled(s)) in cx18_handle_to_stream()
1050 return s; in cx18_handle_to_stream()