V4L/DVB (10442): cx18: Fixes for enforcing when Encoder Raw VBI params can be set

The Encoder will only allow the Raw VBI parameters, along with a number of
other API parameters, to take effect when no analog captures are in
progress.  These parameters must be set before the first analog capture starts,
be it MPEG, VBI, YUV, etc., and cannot be changed until the last one stops.  It
is not obvious to me what capture channel API parameters are shared and which
ones must be set per capture channel, so set them all for every analog
capture channel start up.  This fixes the driver so that VBI capture can be
started up after the MPEG capture is going.

Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index a454ede..0f0cd56 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -42,13 +42,6 @@
 #include <media/v4l2-chip-ident.h>
 #include <linux/i2c-id.h>
 
-static int cx18_vbi_streaming(struct cx18 *cx)
-{
-	struct cx18_stream *s_vbi = &cx->streams[CX18_ENC_STREAM_TYPE_VBI];
-	return (s_vbi->handle != CX18_INVALID_TASK_HANDLE) &&
-		test_bit(CX18_F_S_STREAMING, &s_vbi->s_flags);
-}
-
 u16 cx18_service2vbi(int type)
 {
 	switch (type) {
@@ -312,7 +305,11 @@
 	if (ret)
 		return ret;
 
-	if (!cx18_raw_vbi(cx) && cx18_vbi_streaming(cx))
+	/*
+	 * Changing the Encoder's Raw VBI parameters won't have any effect
+	 * if any analog capture is ongoing
+	 */
+	if (!cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0)
 		return -EBUSY;
 
 	/*
@@ -345,8 +342,13 @@
 
 	cx18_try_fmt_sliced_vbi_cap(file, fh, fmt);
 
-	if (cx18_raw_vbi(cx) && cx18_vbi_streaming(cx))
+	/*
+	 * Changing the Encoder's Raw VBI parameters won't have any effect
+	 * if any analog capture is ongoing
+	 */
+	if (cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0)
 		return -EBUSY;
+
 	/*
 	 * Set the service_lines requested in the digitizer/slicer registers.
 	 * Note, cx18_av_vbi() wipes some "impossible" service lines in the