Lines Matching +full:dual +full:- +full:radio

3     Copyright (C) 2003-2004  Kevin Thayer <nufan_wfk at yahoo.com>
5 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 * -----
29 * MPG600/MPG160 support by T.Adachi <tadachi@tadachi-net.com>
33 * using information provided by Jiun-Kuei Jung @ AVerMedia.
36 #include "ivtv-driver.h"
37 #include "ivtv-fileops.h"
38 #include "ivtv-queue.h"
39 #include "ivtv-mailbox.h"
40 #include "ivtv-ioctl.h"
41 #include "ivtv-irq.h"
42 #include "ivtv-yuv.h"
43 #include "ivtv-cards.h"
44 #include "ivtv-streams.h"
45 #include "ivtv-firmware.h"
46 #include <media/v4l2-event.h>
132 "encoder radio",
170 struct ivtv_stream *s = &itv->streams[type]; in ivtv_stream_init()
176 s->itv = itv; in ivtv_stream_init()
177 s->type = type; in ivtv_stream_init()
178 s->name = ivtv_stream_info[type].name; in ivtv_stream_init()
179 s->vdev.device_caps = ivtv_stream_info[type].v4l2_caps; in ivtv_stream_init()
182 s->dma = DMA_NONE; in ivtv_stream_init()
184 s->dma = ivtv_stream_info[type].dma; in ivtv_stream_init()
185 s->buf_size = itv->stream_buf_size[type]; in ivtv_stream_init()
186 if (s->buf_size) in ivtv_stream_init()
187 s->buffers = (itv->options.kilobytes[type] * 1024 + s->buf_size - 1) / s->buf_size; in ivtv_stream_init()
188 spin_lock_init(&s->qlock); in ivtv_stream_init()
189 init_waitqueue_head(&s->waitq); in ivtv_stream_init()
190 s->sg_handle = IVTV_DMA_UNMAPPED; in ivtv_stream_init()
191 ivtv_queue_init(&s->q_free); in ivtv_stream_init()
192 ivtv_queue_init(&s->q_full); in ivtv_stream_init()
193 ivtv_queue_init(&s->q_dma); in ivtv_stream_init()
194 ivtv_queue_init(&s->q_predma); in ivtv_stream_init()
195 ivtv_queue_init(&s->q_io); in ivtv_stream_init()
200 struct ivtv_stream *s = &itv->streams[type]; in ivtv_prep_dev()
202 int num = itv->instance + ivtv_first_minor + num_offset; in ivtv_prep_dev()
207 s->vdev.v4l2_dev = NULL; in ivtv_prep_dev()
208 s->itv = itv; in ivtv_prep_dev()
209 s->type = type; in ivtv_prep_dev()
210 s->name = ivtv_stream_info[type].name; in ivtv_prep_dev()
212 /* Check whether the radio is supported */ in ivtv_prep_dev()
213 if (type == IVTV_ENC_STREAM_TYPE_RAD && !(itv->v4l2_cap & V4L2_CAP_RADIO)) in ivtv_prep_dev()
215 if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_prep_dev()
221 itv->options.kilobytes[type] == 0) { in ivtv_prep_dev()
228 snprintf(s->vdev.name, sizeof(s->vdev.name), "%s %s", in ivtv_prep_dev()
229 itv->v4l2_dev.name, s->name); in ivtv_prep_dev()
231 s->vdev.num = num; in ivtv_prep_dev()
232 s->vdev.v4l2_dev = &itv->v4l2_dev; in ivtv_prep_dev()
235 s->vdev.vfl_dir = VFL_DIR_TX; in ivtv_prep_dev()
236 s->vdev.fops = ivtv_stream_info[type].fops; in ivtv_prep_dev()
237 s->vdev.ctrl_handler = itv->v4l2_dev.ctrl_handler; in ivtv_prep_dev()
238 s->vdev.release = video_device_release_empty; in ivtv_prep_dev()
239 s->vdev.tvnorms = V4L2_STD_ALL; in ivtv_prep_dev()
240 s->vdev.lock = &itv->serialize_lock; in ivtv_prep_dev()
241 if (s->type == IVTV_DEC_STREAM_TYPE_VBI) { in ivtv_prep_dev()
242 v4l2_disable_ioctl(&s->vdev, VIDIOC_S_AUDIO); in ivtv_prep_dev()
243 v4l2_disable_ioctl(&s->vdev, VIDIOC_G_AUDIO); in ivtv_prep_dev()
244 v4l2_disable_ioctl(&s->vdev, VIDIOC_ENUMAUDIO); in ivtv_prep_dev()
245 v4l2_disable_ioctl(&s->vdev, VIDIOC_ENUMINPUT); in ivtv_prep_dev()
246 v4l2_disable_ioctl(&s->vdev, VIDIOC_S_INPUT); in ivtv_prep_dev()
247 v4l2_disable_ioctl(&s->vdev, VIDIOC_G_INPUT); in ivtv_prep_dev()
248 v4l2_disable_ioctl(&s->vdev, VIDIOC_S_FREQUENCY); in ivtv_prep_dev()
249 v4l2_disable_ioctl(&s->vdev, VIDIOC_G_FREQUENCY); in ivtv_prep_dev()
250 v4l2_disable_ioctl(&s->vdev, VIDIOC_S_TUNER); in ivtv_prep_dev()
251 v4l2_disable_ioctl(&s->vdev, VIDIOC_G_TUNER); in ivtv_prep_dev()
252 v4l2_disable_ioctl(&s->vdev, VIDIOC_S_STD); in ivtv_prep_dev()
254 ivtv_set_funcs(&s->vdev); in ivtv_prep_dev()
269 if (itv->streams[type].vdev.v4l2_dev == NULL) in ivtv_streams_setup()
273 if (ivtv_stream_alloc(&itv->streams[type])) in ivtv_streams_setup()
281 return -ENOMEM; in ivtv_streams_setup()
286 struct ivtv_stream *s = &itv->streams[type]; in ivtv_reg_dev()
291 if (s->vdev.v4l2_dev == NULL) in ivtv_reg_dev()
294 num = s->vdev.num; in ivtv_reg_dev()
297 struct ivtv_stream *s_mpg = &itv->streams[IVTV_ENC_STREAM_TYPE_MPG]; in ivtv_reg_dev()
299 if (s_mpg->vdev.v4l2_dev) in ivtv_reg_dev()
300 num = s_mpg->vdev.num + ivtv_stream_info[type].num_offset; in ivtv_reg_dev()
302 if (itv->osd_video_pbase && (type == IVTV_DEC_STREAM_TYPE_YUV || in ivtv_reg_dev()
304 s->vdev.device_caps |= V4L2_CAP_VIDEO_OUTPUT_OVERLAY; in ivtv_reg_dev()
305 itv->v4l2_cap |= V4L2_CAP_VIDEO_OUTPUT_OVERLAY; in ivtv_reg_dev()
307 video_set_drvdata(&s->vdev, s); in ivtv_reg_dev()
310 if (video_register_device_no_warn(&s->vdev, vfl_type, num)) { in ivtv_reg_dev()
312 s->name, num); in ivtv_reg_dev()
313 return -ENOMEM; in ivtv_reg_dev()
315 name = video_device_node_name(&s->vdev); in ivtv_reg_dev()
320 name, s->name, itv->options.kilobytes[type]); in ivtv_reg_dev()
324 name, s->name); in ivtv_reg_dev()
327 if (itv->options.kilobytes[type]) in ivtv_reg_dev()
329 name, s->name, itv->options.kilobytes[type]); in ivtv_reg_dev()
332 name, s->name); in ivtv_reg_dev()
353 return -ENOMEM; in ivtv_streams_register()
363 struct video_device *vdev = &itv->streams[type].vdev; in ivtv_streams_cleanup()
365 if (vdev->v4l2_dev == NULL) in ivtv_streams_cleanup()
369 ivtv_stream_free(&itv->streams[type]); in ivtv_streams_cleanup()
370 itv->streams[type].vdev.v4l2_dev = NULL; in ivtv_streams_cleanup()
386 v4l2_subdev_call(itv->sd_video, vbi, s_raw_fmt, &itv->vbi.in.fmt.vbi); in ivtv_vbi_setup()
388 v4l2_subdev_call(itv->sd_video, vbi, s_sliced_fmt, &itv->vbi.in.fmt.sliced); in ivtv_vbi_setup()
391 A raw line takes 1443 bytes: 2 * 720 + 4 byte frame header - 1 in ivtv_vbi_setup()
392 The '- 1' byte is probably an unused U or V byte. Or something... in ivtv_vbi_setup()
396 lines = itv->vbi.count * 2; in ivtv_vbi_setup()
398 lines = itv->is_60hz ? 24 : 38; in ivtv_vbi_setup()
399 if (itv->is_60hz && (itv->hw_flags & IVTV_HW_CX25840)) in ivtv_vbi_setup()
403 itv->vbi.enc_size = lines * (raw ? itv->vbi.raw_size : itv->vbi.sliced_size); in ivtv_vbi_setup()
412 data[2] = raw ? 4 : 4 * (itv->vbi.raw_size / itv->vbi.enc_size); in ivtv_vbi_setup()
420 if (itv->hw_flags & IVTV_HW_CX25840) { in ivtv_vbi_setup()
432 data[6] = (raw ? itv->vbi.raw_size : itv->vbi.sliced_size); in ivtv_vbi_setup()
445 data[6] = itv->vbi.enc_size / lines; in ivtv_vbi_setup()
455 itv->vbi.enc_start = data[2]; in ivtv_vbi_setup()
456 itv->vbi.fpi = data[0]; in ivtv_vbi_setup()
457 if (!itv->vbi.fpi) in ivtv_vbi_setup()
458 itv->vbi.fpi = 1; in ivtv_vbi_setup()
461 itv->vbi.enc_start, data[1], itv->vbi.fpi); in ivtv_vbi_setup()
468 if (itv->is_60hz) { in ivtv_vbi_setup()
473 ivtv_vapi(itv, CX2341X_ENC_SET_VBI_LINE, 5, i - 1, in ivtv_vbi_setup()
475 ivtv_vapi(itv, CX2341X_ENC_SET_VBI_LINE, 5, (i - 1) | 0x80000000, in ivtv_vbi_setup()
480 - Is it possible to select particular VBI lines only for inclusion in the MPEG in ivtv_vbi_setup()
482 - Is mixed raw and sliced VBI possible? in ivtv_vbi_setup()
483 - What's the meaning of the raw/sliced flag? in ivtv_vbi_setup()
484 - What's the meaning of params 2, 3 & 4 of the Select VBI command? */ in ivtv_vbi_setup()
490 struct ivtv *itv = s->itv; in ivtv_start_v4l2_encode_stream()
494 if (s->vdev.v4l2_dev == NULL) in ivtv_start_v4l2_encode_stream()
495 return -EINVAL; in ivtv_start_v4l2_encode_stream()
497 IVTV_DEBUG_INFO("Start encoder stream %s\n", s->name); in ivtv_start_v4l2_encode_stream()
499 switch (s->type) { in ivtv_start_v4l2_encode_stream()
505 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_start_v4l2_encode_stream()
509 itv->mpg_data_received = itv->vbi_data_inserted = 0; in ivtv_start_v4l2_encode_stream()
510 itv->dualwatch_jiffies = jiffies; in ivtv_start_v4l2_encode_stream()
511 itv->dualwatch_stereo_mode = v4l2_ctrl_g_ctrl(itv->cxhdl.audio_mode); in ivtv_start_v4l2_encode_stream()
512 itv->search_pack_header = 0; in ivtv_start_v4l2_encode_stream()
516 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_start_v4l2_encode_stream()
532 itv->vbi.frame = 0; in ivtv_start_v4l2_encode_stream()
533 itv->vbi.inserted_frame = 0; in ivtv_start_v4l2_encode_stream()
534 memset(itv->vbi.sliced_mpeg_size, in ivtv_start_v4l2_encode_stream()
535 0, sizeof(itv->vbi.sliced_mpeg_size)); in ivtv_start_v4l2_encode_stream()
538 return -EINVAL; in ivtv_start_v4l2_encode_stream()
540 s->subtype = subtype; in ivtv_start_v4l2_encode_stream()
541 s->buffers_stolen = 0; in ivtv_start_v4l2_encode_stream()
544 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); in ivtv_start_v4l2_encode_stream()
546 if (atomic_read(&itv->capturing) == 0) { in ivtv_start_v4l2_encode_stream()
563 ((itv->hw_flags & IVTV_HW_SAA7114) && itv->is_60hz) ? 10001 : 0); in ivtv_start_v4l2_encode_stream()
565 ivtv_vapi(itv, CX2341X_ENC_MISC, 2, 3, !itv->has_cx23415); in ivtv_start_v4l2_encode_stream()
574 if (itv->card->hw_all & (IVTV_HW_SAA7115 | IVTV_HW_SAA717X)) in ivtv_start_v4l2_encode_stream()
576 else if (itv->card->hw_all & IVTV_HW_SAA7114) in ivtv_start_v4l2_encode_stream()
584 if (itv->v4l2_cap & V4L2_CAP_VBI_CAPTURE) { in ivtv_start_v4l2_encode_stream()
590 itv->pgm_info_offset = data[0]; in ivtv_start_v4l2_encode_stream()
591 itv->pgm_info_num = data[1]; in ivtv_start_v4l2_encode_stream()
592 itv->pgm_info_write_idx = 0; in ivtv_start_v4l2_encode_stream()
593 itv->pgm_info_read_idx = 0; in ivtv_start_v4l2_encode_stream()
596 itv->pgm_info_offset, itv->pgm_info_num); in ivtv_start_v4l2_encode_stream()
599 cx2341x_handler_setup(&itv->cxhdl); in ivtv_start_v4l2_encode_stream()
601 /* mute if capturing radio */ in ivtv_start_v4l2_encode_stream()
602 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) in ivtv_start_v4l2_encode_stream()
604 1 | (v4l2_ctrl_g_ctrl(itv->cxhdl.video_mute_yuv) << 8)); in ivtv_start_v4l2_encode_stream()
608 if (itv->has_cx23415 && !test_and_set_bit(IVTV_F_I_DIG_RST, &itv->i_flags)) { in ivtv_start_v4l2_encode_stream()
610 ivtv_vapi(itv, CX2341X_ENC_SET_EVENT_NOTIFICATION, 4, 0, 1, IVTV_IRQ_ENC_VIM_RST, -1); in ivtv_start_v4l2_encode_stream()
614 if (atomic_read(&itv->capturing) == 0) { in ivtv_start_v4l2_encode_stream()
618 clear_bit(IVTV_F_I_EOS, &itv->i_flags); in ivtv_start_v4l2_encode_stream()
620 cx2341x_handler_set_busy(&itv->cxhdl, 1); in ivtv_start_v4l2_encode_stream()
623 /* Avoid tinny audio problem - ensure audio clocks are going */ in ivtv_start_v4l2_encode_stream()
624 v4l2_subdev_call(itv->sd_audio, audio, s_stream, 1); in ivtv_start_v4l2_encode_stream()
625 /* Avoid unpredictable PCI bus hang - disable video clocks */ in ivtv_start_v4l2_encode_stream()
626 if (itv->sd_video_is_streaming) in ivtv_start_v4l2_encode_stream()
627 v4l2_subdev_call(itv->sd_video, video, s_stream, 0); in ivtv_start_v4l2_encode_stream()
630 v4l2_subdev_call(itv->sd_video, video, s_stream, 1); in ivtv_start_v4l2_encode_stream()
631 itv->sd_video_is_streaming = true; in ivtv_start_v4l2_encode_stream()
638 return -EINVAL; in ivtv_start_v4l2_encode_stream()
646 if (s->type == IVTV_ENC_STREAM_TYPE_VBI) in ivtv_start_v4l2_encode_stream()
652 atomic_inc(&itv->capturing); in ivtv_start_v4l2_encode_stream()
660 struct ivtv *itv = s->itv; in ivtv_setup_v4l2_decode_stream()
665 if (s->vdev.v4l2_dev == NULL) in ivtv_setup_v4l2_decode_stream()
666 return -EINVAL; in ivtv_setup_v4l2_decode_stream()
670 width = itv->cxhdl.width; in ivtv_setup_v4l2_decode_stream()
671 height = itv->cxhdl.height; in ivtv_setup_v4l2_decode_stream()
673 /* set audio mode to left/stereo for dual/stereo mode. */ in ivtv_setup_v4l2_decode_stream()
674 ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode); in ivtv_setup_v4l2_decode_stream()
684 itv->vbi.dec_start = data[0]; in ivtv_setup_v4l2_decode_stream()
686 IVTV_DEBUG_INFO("Decoder VBI RE-Insert start 0x%08x size 0x%08x\n", in ivtv_setup_v4l2_decode_stream()
687 itv->vbi.dec_start, data[1]); in ivtv_setup_v4l2_decode_stream()
693 switch (s->type) { in ivtv_setup_v4l2_decode_stream()
695 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_setup_v4l2_decode_stream()
701 height = itv->is_out_50hz ? 576 : 480; in ivtv_setup_v4l2_decode_stream()
711 width, height, itv->cxhdl.audio_properties)) { in ivtv_setup_v4l2_decode_stream()
724 struct ivtv *itv = s->itv; in ivtv_start_v4l2_decode_stream()
727 if (s->vdev.v4l2_dev == NULL) in ivtv_start_v4l2_decode_stream()
728 return -EINVAL; in ivtv_start_v4l2_decode_stream()
730 if (test_and_set_bit(IVTV_F_S_STREAMING, &s->s_flags)) in ivtv_start_v4l2_decode_stream()
733 IVTV_DEBUG_INFO("Starting decode stream %s (gop_offset %d)\n", s->name, gop_offset); in ivtv_start_v4l2_decode_stream()
737 clear_bit(IVTV_F_S_STREAMING, &s->s_flags); in ivtv_start_v4l2_decode_stream()
745 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); in ivtv_start_v4l2_decode_stream()
748 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[0]); in ivtv_start_v4l2_decode_stream()
749 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[1]); in ivtv_start_v4l2_decode_stream()
750 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[2]); in ivtv_start_v4l2_decode_stream()
751 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[3]); in ivtv_start_v4l2_decode_stream()
752 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[0]); in ivtv_start_v4l2_decode_stream()
753 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[1]); in ivtv_start_v4l2_decode_stream()
754 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[2]); in ivtv_start_v4l2_decode_stream()
755 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[3]); in ivtv_start_v4l2_decode_stream()
757 /* turn on notification of dual/stereo mode change */ in ivtv_start_v4l2_decode_stream()
758 ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 1, IVTV_IRQ_DEC_AUD_MODE_CHG, -1); in ivtv_start_v4l2_decode_stream()
768 IVTV_DEBUG_IRQ("IRQ Mask is now: 0x%08x\n", itv->irqmask); in ivtv_start_v4l2_decode_stream()
771 atomic_inc(&itv->decoding); in ivtv_start_v4l2_decode_stream()
779 for (i = IVTV_MAX_STREAMS - 1; i >= 0; i--) { in ivtv_stop_all_captures()
780 struct ivtv_stream *s = &itv->streams[i]; in ivtv_stop_all_captures()
782 if (s->vdev.v4l2_dev == NULL) in ivtv_stop_all_captures()
784 if (test_bit(IVTV_F_S_STREAMING, &s->s_flags)) { in ivtv_stop_all_captures()
792 struct ivtv *itv = s->itv; in ivtv_stop_v4l2_encode_stream()
797 if (s->vdev.v4l2_dev == NULL) in ivtv_stop_v4l2_encode_stream()
798 return -EINVAL; in ivtv_stop_v4l2_encode_stream()
805 if (s->type == IVTV_DEC_STREAM_TYPE_VOUT) in ivtv_stop_v4l2_encode_stream()
807 if (atomic_read(&itv->capturing) == 0) in ivtv_stop_v4l2_encode_stream()
810 switch (s->type) { in ivtv_stop_v4l2_encode_stream()
827 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && gop_end) { in ivtv_stop_v4l2_encode_stream()
835 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, stopmode, cap_type, s->subtype); in ivtv_stop_v4l2_encode_stream()
837 if (!test_bit(IVTV_F_S_PASSTHROUGH, &s->s_flags)) { in ivtv_stop_v4l2_encode_stream()
838 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && gop_end) { in ivtv_stop_v4l2_encode_stream()
843 add_wait_queue(&itv->eos_waitq, &wait); in ivtv_stop_v4l2_encode_stream()
848 while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && in ivtv_stop_v4l2_encode_stream()
861 duration = ((1000 + HZ / 2) / HZ) * (jiffies - then); in ivtv_stop_v4l2_encode_stream()
863 if (!test_bit(IVTV_F_I_EOS, &itv->i_flags)) { in ivtv_stop_v4l2_encode_stream()
864 IVTV_DEBUG_WARN("%s: EOS interrupt not received! stopping anyway.\n", s->name); in ivtv_stop_v4l2_encode_stream()
865 IVTV_DEBUG_WARN("%s: waited %lu ms.\n", s->name, duration); in ivtv_stop_v4l2_encode_stream()
867 IVTV_DEBUG_INFO("%s: EOS took %lu ms to occur.\n", s->name, duration); in ivtv_stop_v4l2_encode_stream()
870 remove_wait_queue(&itv->eos_waitq, &wait); in ivtv_stop_v4l2_encode_stream()
871 set_bit(IVTV_F_S_STREAMOFF, &s->s_flags); in ivtv_stop_v4l2_encode_stream()
878 atomic_dec(&itv->capturing); in ivtv_stop_v4l2_encode_stream()
880 /* Clear capture and no-read bits */ in ivtv_stop_v4l2_encode_stream()
881 clear_bit(IVTV_F_S_STREAMING, &s->s_flags); in ivtv_stop_v4l2_encode_stream()
883 if (s->type == IVTV_ENC_STREAM_TYPE_VBI) in ivtv_stop_v4l2_encode_stream()
886 if (atomic_read(&itv->capturing) > 0) { in ivtv_stop_v4l2_encode_stream()
890 cx2341x_handler_set_busy(&itv->cxhdl, 0); in ivtv_stop_v4l2_encode_stream()
894 del_timer(&itv->dma_timer); in ivtv_stop_v4l2_encode_stream()
897 if (test_and_clear_bit(IVTV_F_I_DIG_RST, &itv->i_flags)) { in ivtv_stop_v4l2_encode_stream()
899 /* on/off: 0 = off, intr: 0x10000000, mbox_id: -1: none */ in ivtv_stop_v4l2_encode_stream()
900 ivtv_vapi(itv, CX2341X_ENC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_ENC_VIM_RST, -1); in ivtv_stop_v4l2_encode_stream()
904 /* Raw-passthrough is implied on start. Make sure it's stopped so in ivtv_stop_v4l2_encode_stream()
905 the encoder will re-initialize when next started */ in ivtv_stop_v4l2_encode_stream()
908 wake_up(&s->waitq); in ivtv_stop_v4l2_encode_stream()
919 struct ivtv *itv = s->itv; in ivtv_stop_v4l2_decode_stream()
921 if (s->vdev.v4l2_dev == NULL) in ivtv_stop_v4l2_decode_stream()
922 return -EINVAL; in ivtv_stop_v4l2_decode_stream()
924 if (s->type != IVTV_DEC_STREAM_TYPE_YUV && s->type != IVTV_DEC_STREAM_TYPE_MPG) in ivtv_stop_v4l2_decode_stream()
925 return -EINVAL; in ivtv_stop_v4l2_decode_stream()
927 if (!test_bit(IVTV_F_S_STREAMING, &s->s_flags)) in ivtv_stop_v4l2_decode_stream()
944 if (s->q_full.buffers + s->q_dma.buffers == 0) { in ivtv_stop_v4l2_decode_stream()
955 /* turn off notification of dual/stereo mode change */ in ivtv_stop_v4l2_decode_stream()
956 ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_DEC_AUD_MODE_CHG, -1); in ivtv_stop_v4l2_decode_stream()
959 del_timer(&itv->dma_timer); in ivtv_stop_v4l2_decode_stream()
961 clear_bit(IVTV_F_S_NEEDS_DATA, &s->s_flags); in ivtv_stop_v4l2_decode_stream()
962 clear_bit(IVTV_F_S_STREAMING, &s->s_flags); in ivtv_stop_v4l2_decode_stream()
969 atomic_dec(&itv->decoding); in ivtv_stop_v4l2_decode_stream()
971 set_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags); in ivtv_stop_v4l2_decode_stream()
972 wake_up(&itv->event_waitq); in ivtv_stop_v4l2_decode_stream()
973 v4l2_event_queue(&s->vdev, &ev); in ivtv_stop_v4l2_decode_stream()
976 wake_up(&s->waitq); in ivtv_stop_v4l2_decode_stream()
983 struct ivtv_stream *yuv_stream = &itv->streams[IVTV_ENC_STREAM_TYPE_YUV]; in ivtv_passthrough_mode()
984 struct ivtv_stream *dec_stream = &itv->streams[IVTV_DEC_STREAM_TYPE_YUV]; in ivtv_passthrough_mode()
986 if (yuv_stream->vdev.v4l2_dev == NULL || dec_stream->vdev.v4l2_dev == NULL) in ivtv_passthrough_mode()
987 return -EINVAL; in ivtv_passthrough_mode()
994 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_passthrough_mode()
998 return -EBUSY; in ivtv_passthrough_mode()
1001 set_bit(IVTV_F_S_PASSTHROUGH, &dec_stream->s_flags); in ivtv_passthrough_mode()
1002 set_bit(IVTV_F_S_STREAMING, &dec_stream->s_flags); in ivtv_passthrough_mode()
1009 atomic_inc(&itv->decoding); in ivtv_passthrough_mode()
1012 if (atomic_read(&itv->capturing) == 0) { in ivtv_passthrough_mode()
1013 cx2341x_handler_setup(&itv->cxhdl); in ivtv_passthrough_mode()
1014 cx2341x_handler_set_busy(&itv->cxhdl, 1); in ivtv_passthrough_mode()
1019 atomic_inc(&itv->capturing); in ivtv_passthrough_mode()
1023 if (itv->output_mode != OUT_PASSTHROUGH) in ivtv_passthrough_mode()
1030 atomic_dec(&itv->capturing); in ivtv_passthrough_mode()
1031 atomic_dec(&itv->decoding); in ivtv_passthrough_mode()
1032 clear_bit(IVTV_F_S_PASSTHROUGH, &dec_stream->s_flags); in ivtv_passthrough_mode()
1033 clear_bit(IVTV_F_S_STREAMING, &dec_stream->s_flags); in ivtv_passthrough_mode()
1034 itv->output_mode = OUT_NONE; in ivtv_passthrough_mode()
1035 if (atomic_read(&itv->capturing) == 0) in ivtv_passthrough_mode()
1036 cx2341x_handler_set_busy(&itv->cxhdl, 0); in ivtv_passthrough_mode()