Lines Matching defs: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 if (itv->sd_video_is_streaming)
627 v4l2_subdev_call(itv->sd_video, video, s_stream, 0);
629 ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
630 v4l2_subdev_call(itv->sd_video, video, s_stream, 1);
631 itv->sd_video_is_streaming = true;
635 if (ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, captype, subtype))
643 ivtv_passthrough_mode(itv, 1);
647 ivtv_clear_irq_mask(itv, IVTV_IRQ_ENC_VBI_CAP);
649 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
652 atomic_inc(&itv->capturing);
660 struct ivtv *itv = s->itv;
670 width = itv->cxhdl.width;
671 height = itv->cxhdl.height;
674 ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode);
677 ivtv_vapi(itv, CX2341X_DEC_SET_DISPLAY_BUFFERS, 1, 0);
680 ivtv_vapi(itv, CX2341X_DEC_SET_PREBUFFERING, 1, 1);
683 ivtv_vapi_result(itv, data, CX2341X_DEC_EXTRACT_VBI, 1, 1);
684 itv->vbi.dec_start = data[0];
687 itv->vbi.dec_start, data[1]);
695 if (itv->output_mode == OUT_PASSTHROUGH) {
701 height = itv->is_out_50hz ? 576 : 480;
710 if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype,
711 width, height, itv->cxhdl.audio_properties)) {
719 return ivtv_firmware_check(itv, "ivtv_setup_v4l2_decode_stream");
724 struct ivtv *itv = s->itv;
742 ivtv_vapi(itv, CX2341X_DEC_SET_DMA_BLOCK_SIZE, 1, 65536);
748 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[0]);
749 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[1]);
750 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[2]);
751 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA_END].data[3]);
752 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[0]);
753 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[1]);
754 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[2]);
755 writel(0, &itv->dec_mbox.mbox[IVTV_MBOX_DMA].data[3]);
758 ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 1, IVTV_IRQ_DEC_AUD_MODE_CHG, -1);
761 ivtv_vapi(itv, CX2341X_DEC_START_PLAYBACK, 2, gop_offset, 0);
767 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_DECODE);
768 IVTV_DEBUG_IRQ("IRQ Mask is now: 0x%08x\n", itv->irqmask);
771 atomic_inc(&itv->decoding);
775 void ivtv_stop_all_captures(struct ivtv *itv)
780 struct ivtv_stream *s = &itv->streams[i];
792 struct ivtv *itv = s->itv;
807 if (atomic_read(&itv->capturing) == 0)
835 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, stopmode, cap_type, s->subtype);
843 add_wait_queue(&itv->eos_waitq, &wait);
848 while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) &&
863 if (!test_bit(IVTV_F_I_EOS, &itv->i_flags)) {
870 remove_wait_queue(&itv->eos_waitq, &wait);
878 atomic_dec(&itv->capturing);
884 ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VBI_CAP);
886 if (atomic_read(&itv->capturing) > 0) {
890 cx2341x_handler_set_busy(&itv->cxhdl, 0);
893 ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
894 del_timer(&itv->dma_timer);
897 if (test_and_clear_bit(IVTV_F_I_DIG_RST, &itv->i_flags)) {
900 ivtv_vapi(itv, CX2341X_ENC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_ENC_VIM_RST, -1);
901 ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VIM_RST);
906 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, 1, 2, 7);
919 struct ivtv *itv = s->itv;
938 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3,
943 ivtv_vapi_result(itv, data, CX2341X_DEC_GET_XFER_INFO, 0);
953 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, flags & V4L2_DEC_CMD_STOP_TO_BLACK, 0, 0);
956 ivtv_vapi(itv, CX2341X_DEC_SET_EVENT_NOTIFICATION, 4, 0, 0, IVTV_IRQ_DEC_AUD_MODE_CHG, -1);
958 ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_DECODE);
959 del_timer(&itv->dma_timer);
969 atomic_dec(&itv->decoding);
971 set_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags);
972 wake_up(&itv->event_waitq);
981 int ivtv_passthrough_mode(struct ivtv *itv, int enable)
983 struct ivtv_stream *yuv_stream = &itv->streams[IVTV_ENC_STREAM_TYPE_YUV];
984 struct ivtv_stream *dec_stream = &itv->streams[IVTV_DEC_STREAM_TYPE_YUV];
994 if (itv->output_mode == OUT_PASSTHROUGH) {
997 if (ivtv_set_output_mode(itv, OUT_PASSTHROUGH) != OUT_PASSTHROUGH)
1008 ivtv_vapi(itv, CX2341X_DEC_START_PLAYBACK, 2, 0, 1);
1009 atomic_inc(&itv->decoding);
1012 if (atomic_read(&itv->capturing) == 0) {
1013 cx2341x_handler_setup(&itv->cxhdl);
1014 cx2341x_handler_set_busy(&itv->cxhdl, 1);
1018 ivtv_vapi(itv, CX2341X_ENC_START_CAPTURE, 2, 2, 11);
1019 atomic_inc(&itv->capturing);
1023 if (itv->output_mode != OUT_PASSTHROUGH)
1027 ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, 1, 2, 11);
1028 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 3, 1, 0, 0);
1030 atomic_dec(&itv->capturing);
1031 atomic_dec(&itv->decoding);
1034 itv->output_mode = OUT_NONE;
1035 if (atomic_read(&itv->capturing) == 0)
1036 cx2341x_handler_set_busy(&itv->cxhdl, 0);