Lines Matching refs:itv

168 static void ivtv_stream_init(struct ivtv *itv, int type)
170 struct ivtv_stream *s = &itv->streams[type];
176 s->itv = itv;
185 s->buf_size = itv->stream_buf_size[type];
187 s->buffers = (itv->options.kilobytes[type] * 1024 + s->buf_size - 1) / s->buf_size;
198 static int ivtv_prep_dev(struct ivtv *itv, int type)
200 struct ivtv_stream *s = &itv->streams[type];
202 int num = itv->instance + ivtv_first_minor + num_offset;
208 s->itv = itv;
213 if (type == IVTV_ENC_STREAM_TYPE_RAD && !(itv->v4l2_cap & V4L2_CAP_RADIO))
215 if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
221 itv->options.kilobytes[type] == 0) {
226 ivtv_stream_init(itv, type);
229 itv->v4l2_dev.name, s->name);
232 s->vdev.v4l2_dev = &itv->v4l2_dev;
237 s->vdev.ctrl_handler = itv->v4l2_dev.ctrl_handler;
240 s->vdev.lock = &itv->serialize_lock;
259 int ivtv_streams_setup(struct ivtv *itv)
266 if (ivtv_prep_dev(itv, type))
269 if (itv->streams[type].vdev.v4l2_dev == NULL)
273 if (ivtv_stream_alloc(&itv->streams[type]))
280 ivtv_streams_cleanup(itv);
284 static int ivtv_reg_dev(struct ivtv *itv, int type)
286 struct ivtv_stream *s = &itv->streams[type];
297 struct ivtv_stream *s_mpg = &itv->streams[IVTV_ENC_STREAM_TYPE_MPG];
302 if (itv->osd_video_pbase && (type == IVTV_DEC_STREAM_TYPE_YUV ||
305 itv->v4l2_cap |= V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
320 name, s->name, itv->options.kilobytes[type]);
327 if (itv->options.kilobytes[type])
329 name, s->name, itv->options.kilobytes[type]);
339 int ivtv_streams_register(struct ivtv *itv)
346 err |= ivtv_reg_dev(itv, type);
352 ivtv_streams_cleanup(itv);
357 void ivtv_streams_cleanup(struct ivtv *itv)
363 struct video_device *vdev = &itv->streams[type].vdev;
369 ivtv_stream_free(&itv->streams[type]);
370 itv->streams[type].vdev.v4l2_dev = NULL;
374 static void ivtv_vbi_setup(struct ivtv *itv)
376 int raw = ivtv_raw_vbi(itv);
382 ivtv_vapi(itv, CX2341X_ENC_SET_VBI_LINE, 5, 0xffff , 0, 0, 0, 0);
386 v4l2_subdev_call(itv->sd_video, vbi, s_raw_fmt, &itv->vbi.in.fmt.vbi);
388 v4l2_subdev_call(itv->sd_video, vbi, s_sliced_fmt, &itv->vbi.in.fmt.sliced);
396 lines = itv->vbi.count * 2;
398 lines = itv->is_60hz ? 24 : 38;
399 if (itv->is_60hz && (itv->hw_flags & IVTV_HW_CX25840))
403 itv->vbi.enc_size = lines * (raw ? itv->vbi.raw_size : itv->vbi.sliced_size);
412 data[2] = raw ? 4 : 4 * (itv->vbi.raw_size / itv->vbi.enc_size);
420 if (itv->hw_flags & IVTV_HW_CX25840) {
432 data[6] = (raw ? itv->vbi.raw_size : itv->vbi.sliced_size);
445 data[6] = itv->vbi.enc_size / lines;
452 ivtv_api(itv, CX2341X_ENC_SET_VBI_CONFIG, 7, data);
455 itv->vbi.enc_start = data[2];
456 itv->vbi.fpi = data[0];
457 if (!itv->vbi.fpi)
458 itv->vbi.fpi = 1;
461 itv->vbi.enc_start, data[1], itv->vbi.fpi);
468 if (itv->is_60hz) {
473 ivtv_vapi(itv, CX2341X_ENC_SET_VBI_LINE, 5, i - 1,
475 ivtv_vapi(itv, CX2341X_ENC_SET_VBI_LINE, 5, (i - 1) | 0x80000000,
490 struct ivtv *itv = s->itv;
505 if (itv->output_mode == OUT_PASSTHROUGH) {
506 ivtv_passthrough_mode(itv, 0);
509 itv->mpg_data_received = itv->vbi_data_inserted = 0;
510 itv->dualwatch_jiffies = jiffies;
511 itv->dualwatch_stereo_mode = v4l2_ctrl_g_ctrl(itv->cxhdl.audio_mode);
512 itv->search_pack_header = 0;
516 if (itv->output_mode == OUT_PASSTHROUGH) {
532 itv->vbi.frame = 0;
533 itv->vbi.inserted_frame = 0;
534 memset(itv->vbi.sliced_mpeg_size,
535 0, sizeof(itv->vbi.sliced_mpeg_size));
546 if (atomic_read(&itv->capturing) == 0) {
554 /*ivtv_vapi(itv, CX2341X_ENC_SET_DMA_BLOCK_SIZE, 2, 128, 0); */
555 ivtv_vapi(itv, CX2341X_ENC_SET_DMA_BLOCK_SIZE, 2, 1, 1);
558 ivtv_vapi(itv, CX2341X_ENC_SET_VERT_CROP_LINE, 1, 0);
562 ivtv_vapi(itv, CX2341X_ENC_SET_VERT_CROP_LINE, 1,
563 ((itv->hw_flags & IVTV_HW_SAA7114) && itv->is_60hz) ? 10001 : 0);
565 ivtv_vapi(itv, CX2341X_ENC_MISC, 2, 3, !itv->has_cx23415);
566 ivtv_vapi(itv, CX2341X_ENC_MISC, 2, 8, 0);
567 ivtv_vapi(itv, CX2341X_ENC_MISC, 2, 4, 1);
568 ivtv_vapi(itv, CX2341X_ENC_MISC, 1, 12);
571 ivtv_vapi(itv, CX2341X_ENC_SET_PLACEHOLDER, 12,
574 if (itv->card->hw_all & (IVTV_HW_SAA7115 | IVTV_HW_SAA717X))
576 else if (itv->card->hw_all & IVTV_HW_SAA7114)
581 ivtv_vapi(itv, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, digitizer, digitizer);
584 if (itv->v4l2_cap & V4L2_CAP_VBI_CAPTURE) {
585 ivtv_vbi_setup(itv);
589 ivtv_vapi_result(itv, data, CX2341X_ENC_SET_PGM_INDEX_INFO, 2, 7, 400);
590 itv->pgm_info_offset = data[0];
591 itv->pgm_info_num = data[1];
592 itv->pgm_info_write_idx = 0;
593 itv->pgm_info_read_idx = 0;
596 itv->pgm_info_offset, itv->pgm_info_num);
599 cx2341x_handler_setup(&itv->cxhdl);
602 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))
603 ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1,
604 1 | (v4l2_ctrl_g_ctrl(itv->cxhdl.video_mute_yuv) << 8));
608 if (itv->has_cx23415 && !test_and_set_bit(IVTV_F_I_DIG_RST, &itv->i_flags)) {
610 ivtv_vapi(itv, CX2341X_ENC_SET_EVENT_NOTIFICATION, 4, 0, 1, IVTV_IRQ_ENC_VIM_RST, -1);
611 ivtv_clear_irq_mask(itv, IVTV_IRQ_ENC_VIM_RST);
614 if (atomic_read(&itv->capturing) == 0) {
616 ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
618 clear_bit(IVTV_F_I_EOS, &itv->i_flags);
620 cx2341x_handler_set_busy(&itv->cxhdl, 1);
624 v4l2_subdev_call(itv->sd_audio, audio, s_stream, 1);
626 v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
628 ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
629 v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
633 if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype))
641 ivtv_passthrough_mode(itv, 1);
645 ivtv_clear_irq_mask(itv, IVTV_IRQ_ENC_VBI_CAP);
647 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
650 atomic_inc(&itv->capturing);
658 struct ivtv *itv = s->itv;
668 width = itv->cxhdl.width;
669 height = itv->cxhdl.height;
672 ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode);
675 ivtv_vapi(itv, CX2341X_DEC_SET_DISPLAY_BUFFERS, 1, 0);
678 ivtv_vapi(itv, CX2341X_DEC_SET_PREBUFFERING, 1, 1);
681 ivtv_vapi_result(itv, data, CX2341X_DEC_EXTRACT_VBI, 1, 1);
682 itv->vbi.dec_start = data[0];
685 itv->vbi.dec_start, data[1]);
693 if (itv->output_mode == OUT_PASSTHROUGH) {
699 height = itv->is_out_50hz ? 576 : 480;
708 if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype,
709 width, height, itv->cxhdl.audio_properties)) {
717 return ivtv_firmware_check(itv, "ivtv_setup_v4l2_decode_stream");
722 struct ivtv *itv = s->itv;
740 ivtv_vapi(itv, CX2341X_DEC_SET_DMA_BLOCK_SIZE, 1, 65536);
746 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[0]);
747 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[1]);
748 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[2]);
749 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[3]);
750 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[0]);
751 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[1]);
752 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[2]);
753 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[3]);
756 ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 1, IVTV_IRQ_DEC_AUD_MODE_CHG, -1);
759 ivtv_vapi(itv, CX2341X_DEC_START_PLAYBACK, 2, gop_offset, 0);
765 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_DECODE);
766 IVTV_DEBUG_IRQ("IRQ Mask is now: 0x%08x\n", itv->irqmask);
769 atomic_inc(&itv->decoding);
773 void ivtv_stop_all_captures(struct ivtv *itv)
778 struct ivtv_stream *s = &itv->streams[i];
790 struct ivtv *itv = s->itv;
805 if (atomic_read(&itv->capturing) == 0)
833 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, stopmode, cap_type, s->subtype);
841 add_wait_queue(&itv->eos_waitq, &wait);
846 while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) &&
861 if (!test_bit(IVTV_F_I_EOS, &itv->i_flags)) {
868 remove_wait_queue(&itv->eos_waitq, &wait);
876 atomic_dec(&itv->capturing);
882 ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VBI_CAP);
884 if (atomic_read(&itv->capturing) > 0) {
888 cx2341x_handler_set_busy(&itv->cxhdl, 0);
891 ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
892 del_timer(&itv->dma_timer);
895 if (test_and_clear_bit(IVTV_F_I_DIG_RST, &itv->i_flags)) {
898 ivtv_vapi(itv, CX2341X_ENC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_ENC_VIM_RST, -1);
899 ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VIM_RST);
904 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, 1, 2, 7);
917 struct ivtv *itv = s->itv;
936 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3,
941 ivtv_vapi_result(itv, data, CX2341X_DEC_GET_XFER_INFO, 0);
951 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, flags & V4L2_DEC_CMD_STOP_TO_BLACK, 0, 0);
954 ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_DEC_AUD_MODE_CHG, -1);
956 ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_DECODE);
957 del_timer(&itv->dma_timer);
967 atomic_dec(&itv->decoding);
969 set_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags);
970 wake_up(&itv->event_waitq);
979 int ivtv_passthrough_mode(struct ivtv *itv, int enable)
981 struct ivtv_stream *yuv_stream = &itv->streams[IVTV_ENC_STREAM_TYPE_YUV];
982 struct ivtv_stream *dec_stream = &itv->streams[IVTV_DEC_STREAM_TYPE_YUV];
992 if (itv->output_mode == OUT_PASSTHROUGH) {
995 if (ivtv_set_output_mode(itv, OUT_PASSTHROUGH) != OUT_PASSTHROUGH)
1006 ivtv_vapi(itv, CX2341X_DEC_START_PLAYBACK, 2, 0, 1);
1007 atomic_inc(&itv->decoding);
1010 if (atomic_read(&itv->capturing) == 0) {
1011 cx2341x_handler_setup(&itv->cxhdl);
1012 cx2341x_handler_set_busy(&itv->cxhdl, 1);
1016 ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, 2, 11);
1017 atomic_inc(&itv->capturing);
1021 if (itv->output_mode != OUT_PASSTHROUGH)
1025 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, 1, 2, 11);
1026 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, 1, 0, 0);
1028 atomic_dec(&itv->capturing);
1029 atomic_dec(&itv->decoding);
1032 itv->output_mode = OUT_NONE;
1033 if (atomic_read(&itv->capturing) == 0)
1034 cx2341x_handler_set_busy(&itv->cxhdl, 0);