[media] media: davinic: vpif_capture: drop started member from struct common_obj

the started member was indicating whether streaming was started
or not, this can be determined by vb2 offering, this patch replaces
the started member from struct common_obj with appropriate vb2 calls.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 6b66f55..b898779 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -73,6 +73,9 @@
 
 static u8 channel_first_int[VPIF_NUMBER_OF_OBJECTS][2] = { {1, 1} };
 
+/* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */
+static int ycmux_mode;
+
 static inline struct vpif_cap_buffer *to_vpif_buffer(struct vb2_buffer *vb)
 {
 	return container_of(vb, struct vpif_cap_buffer, vb);
@@ -194,9 +197,8 @@
 
 	spin_lock_irqsave(&common->irqlock, flags);
 
-	/* Initialize field_id and started member */
+	/* Initialize field_id */
 	ch->field_id = 0;
-	common->started = 1;
 
 	/* configure 1 or 2 channel mode */
 	if (vpif_config_data->setup_input_channel_mode) {
@@ -216,13 +218,12 @@
 
 	/* Call vpif_set_params function to set the parameters and addresses */
 	ret = vpif_set_video_params(vpif, ch->channel_id);
-
 	if (ret < 0) {
 		vpif_dbg(1, debug, "can't set video params\n");
 		goto err;
 	}
 
-	common->started = ret;
+	ycmux_mode = ret;
 	vpif_config_addr(ch, ret);
 
 	/* Get the next frame from the buffer queue */
@@ -252,7 +253,7 @@
 		enable_channel0(1);
 	}
 	if (VPIF_CHANNEL1_VIDEO == ch->channel_id ||
-		common->started == 2) {
+		ycmux_mode == 2) {
 		channel1_intr_assert();
 		channel1_intr_enable(1);
 		enable_channel1(1);
@@ -291,11 +292,12 @@
 		channel0_intr_enable(0);
 	}
 	if (VPIF_CHANNEL1_VIDEO == ch->channel_id ||
-		2 == common->started) {
+		ycmux_mode == 2) {
 		enable_channel1(0);
 		channel1_intr_enable(0);
 	}
-	common->started = 0;
+
+	ycmux_mode = 0;
 
 	ret = v4l2_subdev_call(ch->sd, video, s_stream, 0);
 	if (ret && ret != -ENOIOCTLCMD && ret != -ENODEV)
@@ -404,9 +406,6 @@
 	for (i = 0; i < VPIF_NUMBER_OF_OBJECTS; i++) {
 		common = &ch->common[i];
 		/* skip If streaming is not started in this channel */
-		if (0 == common->started)
-			continue;
-
 		/* Check the field format */
 		if (1 == ch->vpifparams.std_info.frm_fmt) {
 			/* Progressive mode */
@@ -910,10 +909,8 @@
 
 	vpif_dbg(2, debug, "vpif_s_std\n");
 
-	if (common->started) {
-		vpif_err("streaming in progress\n");
+	if (vb2_is_busy(&common->buffer_queue))
 		return -EBUSY;
-	}
 
 	/* Call encoder subdevice function to set the standard */
 	ch->video.stdid = std_id;
@@ -998,10 +995,8 @@
 	if (index >= chan_cfg->input_count)
 		return -EINVAL;
 
-	if (common->started) {
-		vpif_err("Streaming in progress\n");
+	if (vb2_is_busy(&common->buffer_queue))
 		return -EBUSY;
-	}
 
 	return vpif_set_input(config, ch, index);
 }
@@ -1092,11 +1087,8 @@
 
 	vpif_dbg(2, debug, "%s\n", __func__);
 
-	/* If streaming is started, return error */
-	if (common->started) {
-		vpif_dbg(1, debug, "Streaming is started\n");
+	if (vb2_is_busy(&common->buffer_queue))
 		return -EBUSY;
-	}
 
 	pixfmt = &fmt->fmt.pix;
 	/* Check for valid field format */
@@ -1707,7 +1699,7 @@
 				channel0_intr_enable(0);
 			}
 			if (ch->channel_id == VPIF_CHANNEL1_VIDEO ||
-			    common->started == 2) {
+				ycmux_mode == 2) {
 				enable_channel1(0);
 				channel1_intr_enable(0);
 			}
@@ -1739,7 +1731,7 @@
 				channel0_intr_enable(1);
 			}
 			if (ch->channel_id == VPIF_CHANNEL1_VIDEO ||
-			    common->started == 2) {
+				ycmux_mode == 2) {
 				enable_channel1(1);
 				channel1_intr_enable(1);
 			}