V4L/DVB (5100): Make cx88-blackbird to work again

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 6fd1583..d226eb1 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -86,7 +86,7 @@
 /* ------------------------------------------------------------------- */
 /* static data                                                         */
 
-static struct v4l2_tvnorm tvnorms[] = {
+struct v4l2_tvnorm cx88_tvnorms[] = {
 	{
 		.name      = "NTSC-M",
 		.id        = V4L2_STD_NTSC_M,
@@ -125,6 +125,10 @@
 		.id        = V4L2_STD_SECAM_DK,
 	}
 };
+EXPORT_SYMBOL(cx88_tvnorms);
+
+unsigned int cx88_tvnormsize=ARRAY_SIZE(cx88_tvnorms);
+EXPORT_SYMBOL(cx88_tvnormsize);
 
 static struct v4l2_tvnorm radionorms[] = {
 	{
@@ -932,10 +936,8 @@
 /* ------------------------------------------------------------------ */
 /* VIDEO CTRL IOCTLS                                                  */
 
-static int vidioc_g_ctrl (struct file *file, void *priv,
-				struct v4l2_control *ctl)
+int cx88_get_control (struct cx88_core  *core, struct v4l2_control *ctl)
 {
-	struct cx88_core  *core = ((struct cx8800_fh *)priv)->dev->core;
 	struct cx88_ctrl  *c    = NULL;
 	u32 value;
 	int i;
@@ -964,8 +966,9 @@
 				value,c->mask, c->sreg ? " [shadowed]" : "");
 	return 0;
 }
+EXPORT_SYMBOL(cx88_get_control);
 
-static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
+int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl)
 {
 	struct cx88_ctrl *c = NULL;
 	u32 value,mask;
@@ -1019,6 +1022,7 @@
 	}
 	return 0;
 }
+EXPORT_SYMBOL(cx88_set_control);
 
 static void init_controls(struct cx88_core *core)
 {
@@ -1029,7 +1033,7 @@
 		ctrl.id=cx8800_ctls[i].v.id;
 		ctrl.value=cx8800_ctls[i].v.default_value;
 
-		set_control(core, &ctrl);
+		cx88_set_control(core, &ctrl);
 	}
 }
 
@@ -1179,7 +1183,6 @@
 }
 #endif
 
-
 static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p)
 {
 	struct cx8800_fh  *fh   = priv;
@@ -1244,17 +1247,14 @@
 	struct cx88_core  *core = ((struct cx8800_fh *)priv)->dev->core;
 
 	mutex_lock(&core->lock);
-	cx88_set_tvnorm(core,&tvnorms[i]);
+	cx88_set_tvnorm(core,&cx88_tvnorms[i]);
 	mutex_unlock(&core->lock);
 	return 0;
 }
 
 /* only one input in this sample driver */
-static int vidioc_enum_input (struct file *file, void *priv,
-				struct v4l2_input *i)
+int cx88_enum_input (struct cx88_core  *core,struct v4l2_input *i)
 {
-	struct cx88_core  *core = ((struct cx8800_fh *)priv)->dev->core;
-
 	static const char *iname[] = {
 		[ CX88_VMUX_COMPOSITE1 ] = "Composite1",
 		[ CX88_VMUX_COMPOSITE2 ] = "Composite2",
@@ -1280,10 +1280,18 @@
 	if ((CX88_VMUX_TELEVISION == INPUT(n)->type) ||
 		(CX88_VMUX_CABLE      == INPUT(n)->type))
 		i->type = V4L2_INPUT_TYPE_TUNER;
-	for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
-		i->std |= tvnorms[n].id;
+	for (n = 0; n < ARRAY_SIZE(cx88_tvnorms); n++)
+		i->std |= cx88_tvnorms[n].id;
 	return 0;
 }
+EXPORT_SYMBOL(cx88_enum_input);
+
+static int vidioc_enum_input (struct file *file, void *priv,
+				struct v4l2_input *i)
+{
+	struct cx88_core  *core = ((struct cx8800_fh *)priv)->dev->core;
+	return cx88_enum_input (core,i);
+}
 
 static int vidioc_g_input (struct file *file, void *priv, unsigned int *i)
 {
@@ -1318,13 +1326,20 @@
 	return cx8800_ctrl_query(qctrl);
 }
 
+static int vidioc_g_ctrl (struct file *file, void *priv,
+				struct v4l2_control *ctl)
+{
+	struct cx88_core  *core = ((struct cx8800_fh *)priv)->dev->core;
+	return
+		cx88_get_control(core,ctl);
+}
+
 static int vidioc_s_ctrl (struct file *file, void *priv,
 				struct v4l2_control *ctl)
 {
 	struct cx88_core  *core = ((struct cx8800_fh *)priv)->dev->core;
-
 	return
-		set_control(core,ctl);
+		cx88_set_control(core,ctl);
 }
 
 static int vidioc_g_tuner (struct file *file, void *priv,
@@ -1379,20 +1394,14 @@
 	return 0;
 }
 
-static int vidioc_s_frequency (struct file *file, void *priv,
+int cx88_set_freq (struct cx88_core  *core,
 				struct v4l2_frequency *f)
 {
-	struct cx8800_fh  *fh   = priv;
-	struct cx88_core  *core = fh->dev->core;
-
 	if (unlikely(UNSET == core->tuner_type))
 		return -EINVAL;
 	if (unlikely(f->tuner != 0))
 		return -EINVAL;
-	if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV))
-		return -EINVAL;
-	if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO))
-		return -EINVAL;
+
 	mutex_lock(&core->lock);
 	core->freq = f->frequency;
 	cx88_newstation(core);
@@ -1403,8 +1412,25 @@
 	cx88_set_tvaudio(core);
 
 	mutex_unlock(&core->lock);
+
 	return 0;
 }
+EXPORT_SYMBOL(cx88_set_freq);
+
+static int vidioc_s_frequency (struct file *file, void *priv,
+				struct v4l2_frequency *f)
+{
+	struct cx8800_fh  *fh   = priv;
+	struct cx88_core  *core = fh->dev->core;
+
+	if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV))
+		return -EINVAL;
+	if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO))
+		return -EINVAL;
+
+	return
+		cx88_set_freq (core,f);
+}
 
 
 /* ----------------------------------------------------------- */
@@ -1677,8 +1703,8 @@
 	.vidioc_s_tuner       = vidioc_s_tuner,
 	.vidioc_g_frequency   = vidioc_g_frequency,
 	.vidioc_s_frequency   = vidioc_s_frequency,
-	.tvnorms              = tvnorms,
-	.tvnormsize           = ARRAY_SIZE(tvnorms),
+	.tvnorms              = cx88_tvnorms,
+	.tvnormsize           = ARRAY_SIZE(cx88_tvnorms),
 };
 
 static const struct file_operations radio_fops =
@@ -1789,7 +1815,7 @@
 
 	/* initialize driver struct */
 	spin_lock_init(&dev->slock);
-	core->tvnorm = tvnorms;
+	core->tvnorm = cx88_tvnorms;
 
 	/* init video dma queues */
 	INIT_LIST_HEAD(&dev->vidq.active);
@@ -1870,7 +1896,7 @@
 
 	/* initial device configuration */
 	mutex_lock(&core->lock);
-	cx88_set_tvnorm(core,tvnorms);
+	cx88_set_tvnorm(core,cx88_tvnorms);
 	init_controls(core);
 	video_mux(core,0);
 	mutex_unlock(&core->lock);
@@ -2041,8 +2067,6 @@
 module_init(cx8800_init);
 module_exit(cx8800_fini);
 
-EXPORT_SYMBOL(cx88_do_ioctl);
-
 /* ----------------------------------------------------------- */
 /*
  * Local variables:
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 97177c0..5d2f40f 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -629,12 +629,16 @@
 int cx8802_resume_common(struct pci_dev *pci_dev);
 
 /* ----------------------------------------------------------- */
-/* cx88-video.c                                                */
-extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
-				struct cx88_core *core, unsigned int cmd,
-				void *arg, v4l2_kioctl driver_ioctl);
+/* cx88-video.c*/
+extern unsigned int cx88_tvnormsize;
+extern struct v4l2_tvnorm cx88_tvnorms[];
 extern const u32 cx88_user_ctrls[];
 extern int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl);
+int cx88_enum_input (struct cx88_core  *core,struct v4l2_input *i);
+int cx88_set_freq (struct cx88_core  *core,struct v4l2_frequency *f);
+int cx88_get_control(struct cx88_core *core, struct v4l2_control *ctl);
+int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl);
+int cx88_video_mux(struct cx88_core *core, unsigned int input);
 
 /* ----------------------------------------------------------- */
 /* cx88-blackbird.c                                            */