Merge git://git.infradead.org/mtd-2.6
[pandora-kernel.git] / drivers / media / video / ivtv / ivtv-streams.c
index 55df419..512607e 100644 (file)
@@ -210,6 +210,7 @@ static int ivtv_prep_dev(struct ivtv *itv, int type)
 
        s->vdev->num = num;
        s->vdev->v4l2_dev = &itv->v4l2_dev;
+       s->vdev->ctrl_handler = itv->v4l2_dev.ctrl_handler;
        s->vdev->fops = ivtv_stream_info[type].fops;
        s->vdev->release = video_device_release;
        s->vdev->tvnorms = V4L2_STD_ALL;
@@ -451,7 +452,6 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
 {
        u32 data[CX2341X_MBOX_MAX_DATA];
        struct ivtv *itv = s->itv;
-       struct cx2341x_mpeg_params *p = &itv->params;
        int captype = 0, subtype = 0;
        int enable_passthrough = 0;
 
@@ -472,7 +472,7 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
                }
                itv->mpg_data_received = itv->vbi_data_inserted = 0;
                itv->dualwatch_jiffies = jiffies;
-               itv->dualwatch_stereo_mode = p->audio_properties & 0x0300;
+               itv->dualwatch_stereo_mode = v4l2_ctrl_g_ctrl(itv->cxhdl.audio_mode);
                itv->search_pack_header = 0;
                break;
 
@@ -560,12 +560,12 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
                                itv->pgm_info_offset, itv->pgm_info_num);
 
                /* Setup API for Stream */
-               cx2341x_update(itv, ivtv_api_func, NULL, p);
+               cx2341x_handler_setup(&itv->cxhdl);
 
                /* mute if capturing radio */
                if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))
                        ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1,
-                               1 | (p->video_mute_yuv << 8));
+                               1 | (v4l2_ctrl_g_ctrl(itv->cxhdl.video_mute_yuv) << 8));
        }
 
        /* Vsync Setup */
@@ -581,6 +581,8 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
 
                clear_bit(IVTV_F_I_EOS, &itv->i_flags);
 
+               cx2341x_handler_set_busy(&itv->cxhdl, 1);
+
                /* Initialize Digitizer for Capture */
                /* Avoid tinny audio problem - ensure audio clocks are going */
                v4l2_subdev_call(itv->sd_audio, audio, s_stream, 1);
@@ -617,7 +619,6 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s)
 {
        u32 data[CX2341X_MBOX_MAX_DATA];
        struct ivtv *itv = s->itv;
-       struct cx2341x_mpeg_params *p = &itv->params;
        int datatype;
        u16 width;
        u16 height;
@@ -627,8 +628,8 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s)
 
        IVTV_DEBUG_INFO("Setting some initial decoder settings\n");
 
-       width = p->width;
-       height = p->height;
+       width = itv->cxhdl.width;
+       height = itv->cxhdl.height;
 
        /* set audio mode to left/stereo  for dual/stereo mode. */
        ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode);
@@ -668,7 +669,7 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s)
                break;
        }
        if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype,
-                       width, height, p->audio_properties)) {
+                       width, height, itv->cxhdl.audio_properties)) {
                IVTV_DEBUG_WARN("Couldn't initialize decoder source\n");
        }
 
@@ -847,6 +848,8 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
                return 0;
        }
 
+       cx2341x_handler_set_busy(&itv->cxhdl, 0);
+
        /* Set the following Interrupt mask bits for capture */
        ivtv_set_irq_mask(itv, IVTV_IRQ_MASK_CAPTURE);
        del_timer(&itv->dma_timer);
@@ -967,7 +970,8 @@ int ivtv_passthrough_mode(struct ivtv *itv, int enable)
 
                /* Setup capture if not already done */
                if (atomic_read(&itv->capturing) == 0) {
-                       cx2341x_update(itv, ivtv_api_func, NULL, &itv->params);
+                       cx2341x_handler_setup(&itv->cxhdl);
+                       cx2341x_handler_set_busy(&itv->cxhdl, 1);
                }
 
                /* Start Passthrough Mode */
@@ -988,6 +992,8 @@ int ivtv_passthrough_mode(struct ivtv *itv, int enable)
        clear_bit(IVTV_F_S_PASSTHROUGH, &dec_stream->s_flags);
        clear_bit(IVTV_F_S_STREAMING, &dec_stream->s_flags);
        itv->output_mode = OUT_NONE;
+       if (atomic_read(&itv->capturing) == 0)
+               cx2341x_handler_set_busy(&itv->cxhdl, 0);
 
        return 0;
 }