Lines Matching refs:itv
168 static void ivtv_stream_init(struct ivtv *itv, int type) in ivtv_stream_init() argument
170 struct ivtv_stream *s = &itv->streams[type]; in ivtv_stream_init()
176 s->itv = itv; in ivtv_stream_init()
185 s->buf_size = itv->stream_buf_size[type]; in ivtv_stream_init()
187 s->buffers = (itv->options.kilobytes[type] * 1024 + s->buf_size - 1) / s->buf_size; in ivtv_stream_init()
198 static int ivtv_prep_dev(struct ivtv *itv, int type) in ivtv_prep_dev() argument
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()
208 s->itv = itv; 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()
226 ivtv_stream_init(itv, type); in ivtv_prep_dev()
229 itv->v4l2_dev.name, s->name); in ivtv_prep_dev()
232 s->vdev.v4l2_dev = &itv->v4l2_dev; in ivtv_prep_dev()
237 s->vdev.ctrl_handler = itv->v4l2_dev.ctrl_handler; in ivtv_prep_dev()
240 s->vdev.lock = &itv->serialize_lock; in ivtv_prep_dev()
259 int ivtv_streams_setup(struct ivtv *itv) in ivtv_streams_setup() argument
266 if (ivtv_prep_dev(itv, type)) in ivtv_streams_setup()
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()
280 ivtv_streams_cleanup(itv); in ivtv_streams_setup()
284 static int ivtv_reg_dev(struct ivtv *itv, int type) in ivtv_reg_dev() argument
286 struct ivtv_stream *s = &itv->streams[type]; in ivtv_reg_dev()
297 struct ivtv_stream *s_mpg = &itv->streams[IVTV_ENC_STREAM_TYPE_MPG]; in ivtv_reg_dev()
302 if (itv->osd_video_pbase && (type == IVTV_DEC_STREAM_TYPE_YUV || in ivtv_reg_dev()
305 itv->v4l2_cap |= V4L2_CAP_VIDEO_OUTPUT_OVERLAY; in ivtv_reg_dev()
320 name, s->name, itv->options.kilobytes[type]); 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()
339 int ivtv_streams_register(struct ivtv *itv) in ivtv_streams_register() argument
346 err |= ivtv_reg_dev(itv, type); in ivtv_streams_register()
352 ivtv_streams_cleanup(itv); in ivtv_streams_register()
357 void ivtv_streams_cleanup(struct ivtv *itv) in ivtv_streams_cleanup() argument
363 struct video_device *vdev = &itv->streams[type].vdev; 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()
374 static void ivtv_vbi_setup(struct ivtv *itv) in ivtv_vbi_setup() argument
376 int raw = ivtv_raw_vbi(itv); in ivtv_vbi_setup()
382 ivtv_vapi(itv, CX2341X_ENC_SET_VBI_LINE, 5, 0xffff , 0, 0, 0, 0); in ivtv_vbi_setup()
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()
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()
452 ivtv_api(itv, CX2341X_ENC_SET_VBI_CONFIG, 7, data); 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()
490 struct ivtv *itv = s->itv; in ivtv_start_v4l2_encode_stream() local
505 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_start_v4l2_encode_stream()
506 ivtv_passthrough_mode(itv, 0); 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()
546 if (atomic_read(&itv->capturing) == 0) { in ivtv_start_v4l2_encode_stream()
555 ivtv_vapi(itv, CX2341X_ENC_SET_DMA_BLOCK_SIZE, 2, 1, 1); in ivtv_start_v4l2_encode_stream()
558 ivtv_vapi(itv, CX2341X_ENC_SET_VERT_CROP_LINE, 1, 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()
566 ivtv_vapi(itv, CX2341X_ENC_MISC, 2, 8, 0); in ivtv_start_v4l2_encode_stream()
567 ivtv_vapi(itv, CX2341X_ENC_MISC, 2, 4, 1); in ivtv_start_v4l2_encode_stream()
568 ivtv_vapi(itv, CX2341X_ENC_MISC, 1, 12); in ivtv_start_v4l2_encode_stream()
571 ivtv_vapi(itv, CX2341X_ENC_SET_PLACEHOLDER, 12, 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()
581 ivtv_vapi(itv, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, digitizer, digitizer); in ivtv_start_v4l2_encode_stream()
584 if (itv->v4l2_cap & V4L2_CAP_VBI_CAPTURE) { in ivtv_start_v4l2_encode_stream()
585 ivtv_vbi_setup(itv); in ivtv_start_v4l2_encode_stream()
589 ivtv_vapi_result(itv, data, CX2341X_ENC_SET_PGM_INDEX_INFO, 2, 7, 400); 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()
602 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) in ivtv_start_v4l2_encode_stream()
603 ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1, 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()
611 ivtv_clear_irq_mask(itv, IVTV_IRQ_ENC_VIM_RST); in ivtv_start_v4l2_encode_stream()
614 if (atomic_read(&itv->capturing) == 0) { in ivtv_start_v4l2_encode_stream()
616 ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE); 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()
624 v4l2_subdev_call(itv->sd_audio, audio, s_stream, 1); in ivtv_start_v4l2_encode_stream()
626 v4l2_subdev_call(itv->sd_video, video, s_stream, 0); in ivtv_start_v4l2_encode_stream()
628 ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0); in ivtv_start_v4l2_encode_stream()
629 v4l2_subdev_call(itv->sd_video, video, s_stream, 1); in ivtv_start_v4l2_encode_stream()
633 if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype)) in ivtv_start_v4l2_encode_stream()
641 ivtv_passthrough_mode(itv, 1); in ivtv_start_v4l2_encode_stream()
645 ivtv_clear_irq_mask(itv, IVTV_IRQ_ENC_VBI_CAP); in ivtv_start_v4l2_encode_stream()
647 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE); in ivtv_start_v4l2_encode_stream()
650 atomic_inc(&itv->capturing); in ivtv_start_v4l2_encode_stream()
658 struct ivtv *itv = s->itv; in ivtv_setup_v4l2_decode_stream() local
668 width = itv->cxhdl.width; in ivtv_setup_v4l2_decode_stream()
669 height = itv->cxhdl.height; in ivtv_setup_v4l2_decode_stream()
672 ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode); in ivtv_setup_v4l2_decode_stream()
675 ivtv_vapi(itv, CX2341X_DEC_SET_DISPLAY_BUFFERS, 1, 0); in ivtv_setup_v4l2_decode_stream()
678 ivtv_vapi(itv, CX2341X_DEC_SET_PREBUFFERING, 1, 1); in ivtv_setup_v4l2_decode_stream()
681 ivtv_vapi_result(itv, data, CX2341X_DEC_EXTRACT_VBI, 1, 1); in ivtv_setup_v4l2_decode_stream()
682 itv->vbi.dec_start = data[0]; in ivtv_setup_v4l2_decode_stream()
685 itv->vbi.dec_start, data[1]); in ivtv_setup_v4l2_decode_stream()
693 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_setup_v4l2_decode_stream()
699 height = itv->is_out_50hz ? 576 : 480; in ivtv_setup_v4l2_decode_stream()
708 if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype, in ivtv_setup_v4l2_decode_stream()
709 width, height, itv->cxhdl.audio_properties)) { in ivtv_setup_v4l2_decode_stream()
717 return ivtv_firmware_check(itv, "ivtv_setup_v4l2_decode_stream"); in ivtv_setup_v4l2_decode_stream()
722 struct ivtv *itv = s->itv; in ivtv_start_v4l2_decode_stream() local
740 ivtv_vapi(itv, CX2341X_DEC_SET_DMA_BLOCK_SIZE, 1, 65536); in ivtv_start_v4l2_decode_stream()
746 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[0]); in ivtv_start_v4l2_decode_stream()
747 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[1]); in ivtv_start_v4l2_decode_stream()
748 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[2]); in ivtv_start_v4l2_decode_stream()
749 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[3]); in ivtv_start_v4l2_decode_stream()
750 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[0]); in ivtv_start_v4l2_decode_stream()
751 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[1]); in ivtv_start_v4l2_decode_stream()
752 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[2]); in ivtv_start_v4l2_decode_stream()
753 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[3]); in ivtv_start_v4l2_decode_stream()
756 ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 1, IVTV_IRQ_DEC_AUD_MODE_CHG, -1); in ivtv_start_v4l2_decode_stream()
759 ivtv_vapi(itv, CX2341X_DEC_START_PLAYBACK, 2, gop_offset, 0); in ivtv_start_v4l2_decode_stream()
765 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_DECODE); in ivtv_start_v4l2_decode_stream()
766 IVTV_DEBUG_IRQ("IRQ Mask is now: 0x%08x\n", itv->irqmask); in ivtv_start_v4l2_decode_stream()
769 atomic_inc(&itv->decoding); in ivtv_start_v4l2_decode_stream()
773 void ivtv_stop_all_captures(struct ivtv *itv) in ivtv_stop_all_captures() argument
778 struct ivtv_stream *s = &itv->streams[i]; in ivtv_stop_all_captures()
790 struct ivtv *itv = s->itv; in ivtv_stop_v4l2_encode_stream() local
805 if (atomic_read(&itv->capturing) == 0) in ivtv_stop_v4l2_encode_stream()
833 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, stopmode, cap_type, s->subtype); in ivtv_stop_v4l2_encode_stream()
841 add_wait_queue(&itv->eos_waitq, &wait); in ivtv_stop_v4l2_encode_stream()
846 while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && in ivtv_stop_v4l2_encode_stream()
861 if (!test_bit(IVTV_F_I_EOS, &itv->i_flags)) { in ivtv_stop_v4l2_encode_stream()
868 remove_wait_queue(&itv->eos_waitq, &wait); in ivtv_stop_v4l2_encode_stream()
876 atomic_dec(&itv->capturing); in ivtv_stop_v4l2_encode_stream()
882 ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VBI_CAP); in ivtv_stop_v4l2_encode_stream()
884 if (atomic_read(&itv->capturing) > 0) { in ivtv_stop_v4l2_encode_stream()
888 cx2341x_handler_set_busy(&itv->cxhdl, 0); in ivtv_stop_v4l2_encode_stream()
891 ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE); in ivtv_stop_v4l2_encode_stream()
892 del_timer(&itv->dma_timer); in ivtv_stop_v4l2_encode_stream()
895 if (test_and_clear_bit(IVTV_F_I_DIG_RST, &itv->i_flags)) { in ivtv_stop_v4l2_encode_stream()
898 ivtv_vapi(itv, CX2341X_ENC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_ENC_VIM_RST, -1); in ivtv_stop_v4l2_encode_stream()
899 ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VIM_RST); in ivtv_stop_v4l2_encode_stream()
904 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, 1, 2, 7); in ivtv_stop_v4l2_encode_stream()
917 struct ivtv *itv = s->itv; in ivtv_stop_v4l2_decode_stream() local
936 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, in ivtv_stop_v4l2_decode_stream()
941 ivtv_vapi_result(itv, data, CX2341X_DEC_GET_XFER_INFO, 0); in ivtv_stop_v4l2_decode_stream()
951 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, flags & V4L2_DEC_CMD_STOP_TO_BLACK, 0, 0); in ivtv_stop_v4l2_decode_stream()
954 ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_DEC_AUD_MODE_CHG, -1); in ivtv_stop_v4l2_decode_stream()
956 ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_DECODE); in ivtv_stop_v4l2_decode_stream()
957 del_timer(&itv->dma_timer); in ivtv_stop_v4l2_decode_stream()
967 atomic_dec(&itv->decoding); in ivtv_stop_v4l2_decode_stream()
969 set_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags); in ivtv_stop_v4l2_decode_stream()
970 wake_up(&itv->event_waitq); in ivtv_stop_v4l2_decode_stream()
979 int ivtv_passthrough_mode(struct ivtv *itv, int enable) in ivtv_passthrough_mode() argument
981 struct ivtv_stream *yuv_stream = &itv->streams[IVTV_ENC_STREAM_TYPE_YUV]; in ivtv_passthrough_mode()
982 struct ivtv_stream *dec_stream = &itv->streams[IVTV_DEC_STREAM_TYPE_YUV]; in ivtv_passthrough_mode()
992 if (itv->output_mode == OUT_PASSTHROUGH) { in ivtv_passthrough_mode()
995 if (ivtv_set_output_mode(itv, OUT_PASSTHROUGH) != OUT_PASSTHROUGH) in ivtv_passthrough_mode()
1006 ivtv_vapi(itv, CX2341X_DEC_START_PLAYBACK, 2, 0, 1); in ivtv_passthrough_mode()
1007 atomic_inc(&itv->decoding); in ivtv_passthrough_mode()
1010 if (atomic_read(&itv->capturing) == 0) { in ivtv_passthrough_mode()
1011 cx2341x_handler_setup(&itv->cxhdl); in ivtv_passthrough_mode()
1012 cx2341x_handler_set_busy(&itv->cxhdl, 1); in ivtv_passthrough_mode()
1016 ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, 2, 11); in ivtv_passthrough_mode()
1017 atomic_inc(&itv->capturing); in ivtv_passthrough_mode()
1021 if (itv->output_mode != OUT_PASSTHROUGH) in ivtv_passthrough_mode()
1025 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, 1, 2, 11); in ivtv_passthrough_mode()
1026 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, 1, 0, 0); in ivtv_passthrough_mode()
1028 atomic_dec(&itv->capturing); in ivtv_passthrough_mode()
1029 atomic_dec(&itv->decoding); in ivtv_passthrough_mode()
1032 itv->output_mode = OUT_NONE; in ivtv_passthrough_mode()
1033 if (atomic_read(&itv->capturing) == 0) in ivtv_passthrough_mode()
1034 cx2341x_handler_set_busy(&itv->cxhdl, 0); in ivtv_passthrough_mode()