Skip to contentSkip to conversation

Factor out common cx23885 tuner callback

PATCH New Anton Blanchard 1 participant 4 messages Aug 1, 2008 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Factor out common cx23885 tuner callback

Tuners currently hook different things to the private pointer in their callback function. Longer term we should make that private pointer consistent, but for now separate out the guts of the cx23885 tuner callback so we can reuse it.

---

linux/drivers/media/video/cx23885/cx23885-cards.c +12 -8
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885-cards.c
===================================================================
@@ -320,13 +320,9 @@
 			dev->name, tv.model);
 }
 
-/* Tuner callback function for cx23885 boards. Currently only needed
- * for HVR1500Q, which has an xc5000 tuner.
- */
-int cx23885_tuner_callback(void *priv, int command, int arg)
+static int cx23885_tuner_callback(struct cx23885_dev *dev, int port,
+				  int command, int arg)
 {
-	struct cx23885_i2c *bus = priv;
-	struct cx23885_dev *dev = bus->dev;
 	u32 bitmask = 0;
 
 	if (command != 0) {
@@ -346,9 +342,9 @@
 
 			/* Two identical tuners on two different i2c buses,
 			 * we need to reset the correct gpio. */
-			if (bus->nr == 0)
+			if (port == 0)
 				bitmask = 0x01;
-			else if (bus->nr == 1)
+			else if (port == 1)
 				bitmask = 0x04;
 		}
 		break;
@@ -364,6 +360,14 @@
 	return 0;
 }
 
+int cx23885_xc5000_tuner_callback(void *priv, int command, int arg)
+{
+	struct cx23885_i2c *bus = priv;
+	struct cx23885_dev *dev = bus->dev;
+
+	return cx23885_tuner_callback(dev, bus->nr, command, arg);
+}
+
 void cx23885_gpio_setup(struct cx23885_dev *dev)
 {
 	switch(dev->board) {
linux/drivers/media/video/cx23885/cx23885-dvb.c +2 -2
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885-dvb.c
===================================================================
@@ -189,13 +189,13 @@
 static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
 	.i2c_address      = 0x61,
 	.if_khz           = 5380,
-	.tuner_callback   = cx23885_tuner_callback
+	.tuner_callback   = cx23885_xc5000_tuner_callback,
 };
 
 static struct xc5000_config dvico_xc5000_tunerconfig = {
 	.i2c_address      = 0x64,
 	.if_khz           = 5380,
-	.tuner_callback   = cx23885_tuner_callback
+	.tuner_callback   = cx23885_xc5000_tuner_callback,
 };
 
 static struct tda829x_config tda829x_no_probe = {
linux/drivers/media/video/cx23885/cx23885.h +1 -1
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885.h
===================================================================
@@ -410,7 +410,7 @@
 extern struct cx23885_subid cx23885_subids[];
 extern const unsigned int cx23885_idcount;
 
-extern int cx23885_tuner_callback(void *priv, int command, int arg);
+extern int cx23885_xc5000_tuner_callback(void *priv, int command, int arg);
 extern void cx23885_card_list(struct cx23885_dev *dev);
 extern int  cx23885_ir_init(struct cx23885_dev *dev);
 extern void cx23885_gpio_setup(struct cx23885_dev *dev);

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#1 lore raw

PATCH 2/4 Switch Hauppauge HVR1400 and HVR1500 to common cx23885 tuner callback

The Hauppauge HVR1400 and HVR1500 can now use the common cx23885 tuner callback.

---
Note: There are no in tree users of XC2028_RESET_CLK, I wonder if we should just remove it.

linux/drivers/media/video/cx23885/cx23885-cards.c +15 -1
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885-cards.c
===================================================================
@@ -27,6 +27,7 @@
 
 #include "compat.h"
 #include "cx23885.h"
+#include "tuner-xc2028.h"
 
 /* ------------------------------------------------------------------ */
 /* board config info                                                  */
@@ -332,8 +333,10 @@
 	}
 
 	switch(dev->board) {
+	case CX23885_BOARD_HAUPPAUGE_HVR1400:
+	case CX23885_BOARD_HAUPPAUGE_HVR1500:
 	case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
-		/* Tuner Reset Command from xc5000 */
+		/* Tuner Reset Command */
 		if (command == 0)
 			bitmask = 0x04;
 		break;
@@ -368,6 +371,17 @@
 	return cx23885_tuner_callback(dev, bus->nr, command, arg);
 }
 
+int cx23885_xc3028_tuner_callback(void *priv, int command, int arg)
+{
+	struct cx23885_tsport *port = priv;
+	struct cx23885_dev *dev = port->dev;
+
+	if (command == XC2028_RESET_CLK)
+		return 0;
+
+	return cx23885_tuner_callback(dev, port->nr, command, arg);
+}
+
 void cx23885_gpio_setup(struct cx23885_dev *dev)
 {
 	switch(dev->board) {
linux/drivers/media/video/cx23885/cx23885-dvb.c +2 -32
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885-dvb.c
===================================================================
@@ -304,36 +304,6 @@
 	.output_mode = OUTMODE_MPEG2_SERIAL,
 };
 
-static int cx23885_hvr1500_xc3028_callback(void *ptr, int command, int arg)
-{
-	struct cx23885_tsport *port = ptr;
-	struct cx23885_dev *dev = port->dev;
-
-	switch (command) {
-	case XC2028_TUNER_RESET:
-		/* Send the tuner in then out of reset */
-		/* GPIO-2 xc3028 tuner */
-		dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __func__, arg);
-
-		cx_set(GP0_IO, 0x00040000);
-		cx_clear(GP0_IO, 0x00000004);
-		msleep(5);
-
-		cx_set(GP0_IO, 0x00040004);
-		msleep(5);
-		break;
-	case XC2028_RESET_CLK:
-		dprintk(1, "%s: XC2028_RESET_CLK %d\n", __func__, arg);
-		break;
-	default:
-		dprintk(1, "%s: unknown command %d, arg %d\n", __func__,
-			command, arg);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
 static int dvb_register(struct cx23885_tsport *port)
 {
 	struct cx23885_dev *dev = port->dev;
@@ -427,7 +397,7 @@
 			struct xc2028_config cfg = {
 				.i2c_adap  = &i2c_bus->i2c_adap,
 				.i2c_addr  = 0x61,
-				.callback  = cx23885_hvr1500_xc3028_callback,
+				.callback  = cx23885_xc3028_tuner_callback,
 			};
 			static struct xc2028_ctrl ctl = {
 				.fname       = "xc3028-v27.fw",
@@ -466,7 +436,7 @@
 			struct xc2028_config cfg = {
 				.i2c_adap  = &dev->i2c_bus[1].i2c_adap,
 				.i2c_addr  = 0x64,
-				.callback  = cx23885_hvr1500_xc3028_callback,
+				.callback  = cx23885_xc3028_tuner_callback,
 			};
 			static struct xc2028_ctrl ctl = {
 				.fname   = "xc3028L-v36.fw",
linux/drivers/media/video/cx23885/cx23885.h +1 -0
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885.h
===================================================================
@@ -411,6 +411,7 @@
 extern const unsigned int cx23885_idcount;
 
 extern int cx23885_xc5000_tuner_callback(void *priv, int command, int arg);
+extern int cx23885_xc3028_tuner_callback(void *priv, int command, int arg);
 extern void cx23885_card_list(struct cx23885_dev *dev);
 extern int  cx23885_ir_init(struct cx23885_dev *dev);
 extern void cx23885_gpio_setup(struct cx23885_dev *dev);

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#2 lore raw

PATCH 3/4 Add support for DViCO FusionHDTV DVB-T Dual Express

Add support for the DViCO FusionHDTV DVB-T Dual Express card, based on work by Chris Pascoe and Stephen Backway.

---

linux/Documentation/video4linux/CARDLIST.cx23885 +1 -0
Index: v4l-dvb/linux/Documentation/video4linux/CARDLIST.cx23885
===================================================================
@@ -9,3 +9,4 @@
   8 -> Hauppauge WinTV-HVR1700                             [0070:8101]
   9 -> Hauppauge WinTV-HVR1400                             [0070:8010]
  10 -> DViCO FusionHDTV7 Dual Express                      [18ac:d618]
+ 11 -> DViCO FusionHDTV DVB-T Dual Express                 [18ac:db78]
linux/drivers/media/video/cx23885/cx23885-cards.c +24 -0
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885-cards.c
===================================================================
@@ -150,6 +150,11 @@
 		.portb		= CX23885_MPEG_DVB,
 		.portc		= CX23885_MPEG_DVB,
 	},
+	[CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP] = {
+		.name		= "DViCO FusionHDTV DVB-T Dual Express",
+		.portb		= CX23885_MPEG_DVB,
+		.portc		= CX23885_MPEG_DVB,
+	},
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -221,6 +226,10 @@
 		.subvendor = 0x18ac,
 		.subdevice = 0xd618,
 		.card      = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP,
+	},{
+		.subvendor = 0x18ac,
+		.subdevice = 0xdb78,
+		.card      = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP,
 	},
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -341,6 +350,7 @@
 			bitmask = 0x04;
 		break;
 	case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
+	case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
 		if (command == 0) {
 
 			/* Two identical tuners on two different i2c buses,
@@ -484,6 +494,19 @@
 		mdelay(20);
 		cx_set(GP0_IO, 0x000f000f);
 		break;
+	case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
+		/* GPIO-0 portb xc3028 reset */
+		/* GPIO-1 portb zl10353 reset */
+		/* GPIO-2 portc xc3028 reset */
+		/* GPIO-3 portc zl10353 reset */
+
+		/* Put the parts into reset and back */
+		cx_set(GP0_IO, 0x000f0000);
+		mdelay(20);
+		cx_clear(GP0_IO, 0x0000000f);
+		mdelay(20);
+		cx_set(GP0_IO, 0x000f000f);
+		break;
 	}
 }
 
@@ -535,6 +558,7 @@
 
 	switch (dev->board) {
 	case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
+	case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
 		ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
 		ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
 		ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
linux/drivers/media/video/cx23885/cx23885-dvb.c +34 -0
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885-dvb.c
===================================================================
@@ -43,6 +43,7 @@
 #include "tuner-simple.h"
 #include "dib7000p.h"
 #include "dibx000_common.h"
+#include "zl10353.h"
 
 static unsigned int debug;
 
@@ -304,6 +305,12 @@
 	.output_mode = OUTMODE_MPEG2_SERIAL,
 };
 
+static struct zl10353_config dvico_fusionhdtv_xc3028 = {
+	.demod_address = 0x0f,
+	.if2           = 45600,
+	.no_tuner      = 1,
+};
+
 static int dvb_register(struct cx23885_tsport *port)
 {
 	struct cx23885_dev *dev = port->dev;
@@ -466,6 +473,33 @@
 				&i2c_bus->i2c_adap,
 				&dvico_xc5000_tunerconfig, i2c_bus);
 		break;
+	case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
+		i2c_bus = &dev->i2c_bus[port->nr - 1];
+
+		port->dvb.frontend = dvb_attach(zl10353_attach,
+					       &dvico_fusionhdtv_xc3028,
+					       &i2c_bus->i2c_adap);
+		if (port->dvb.frontend != NULL) {
+			struct dvb_frontend      *fe;
+			struct xc2028_config	  cfg = {
+				.i2c_adap  = &i2c_bus->i2c_adap,
+				.i2c_addr  = 0x61,
+				.video_dev = port,
+				.callback  = cx23885_xc3028_tuner_callback,
+			};
+			static struct xc2028_ctrl ctl = {
+				.fname       = "xc3028-v27.fw",
+				.max_len     = 64,
+				.demod       = XC3028_FE_ZARLINK456,
+			};
+
+			fe = dvb_attach(xc2028_attach, port->dvb.frontend,
+					&cfg);
+			if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
+				fe->ops.tuner_ops.set_config(fe, &ctl);
+		}
+		break;
+	}
 	default:
 		printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
 		       dev->name);
linux/drivers/media/video/cx23885/cx23885.h +1 -0
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885.h
===================================================================
@@ -65,6 +65,7 @@
 #define CX23885_BOARD_HAUPPAUGE_HVR1700        8
 #define CX23885_BOARD_HAUPPAUGE_HVR1400        9
 #define CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP 10
+#define CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP 11
 
 /* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */
 #define CX23885_NORMS (\

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#3 lore raw

PATCH 4/4 Support IR remote on FusionHDTV DVB-T Dual Express

From: Chris Pascoe <[email protected]>

Support IR remote on FusionHDTV DVB-T Dual Express

---

linux/drivers/media/video/cx23885/cx23885-cards.c +3 -0
Index: v4l-dvb/linux/drivers/media/video/cx23885/cx23885-cards.c
===================================================================
@@ -521,6 +521,9 @@
 	case CX23885_BOARD_HAUPPAUGE_HVR1400:
 		/* FIXME: Implement me */
 		break;
+	case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
+		request_module("ir-kbd-i2c");
+		break;
 	}
 
 	return 0;

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb