[PATCH] m920x for LifeView TV Walker Twin, 2007-03-22

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add support for "LifeView TV Walker Twin" (USB IDs 10fd:0513, 10fd:0514)

Signed-off-by: Nick Andrew <nick@xxxxxxxxxxxxxxx>

Nick.
diff -r 0832954f4b9d linux/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
--- a/linux/drivers/media/dvb/dvb-usb/dvb-usb-ids.h	Sun Mar 18 18:54:07 2007 -0400
+++ b/linux/drivers/media/dvb/dvb-usb/dvb-usb-ids.h	Tue Mar 20 11:49:12 2007 +1100
@@ -142,6 +142,8 @@
 #define USB_PID_GENPIX_8PSK_WARM			0x0201
 #define USB_PID_SIGMATEK_DVB_110			0x6610
 #define USB_PID_MSI_DIGI_VOX_MINI_II			0x1513
+#define USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD		0x0514
+#define USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM		0x0513
 
 
 #endif
diff -r 0832954f4b9d linux/drivers/media/dvb/dvb-usb/m920x.c
--- a/linux/drivers/media/dvb/dvb-usb/m920x.c	Sun Mar 18 18:54:07 2007 -0400
+++ b/linux/drivers/media/dvb/dvb-usb/m920x.c	Thu Mar 22 10:07:02 2007 +1100
@@ -41,6 +41,26 @@ static struct dvb_usb_rc_key megasky_rc_
 	{ 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
 };
 
+static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
+	{ 0x0, 0x01, KEY_ZOOM }, /* Full Screen */
+	{ 0x0, 0x02, KEY_CAMERA }, /* snapshot */
+	{ 0x0, 0x03, KEY_MUTE },
+	{ 0x0, 0x04, KEY_REWIND },
+	{ 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */
+	{ 0x0, 0x06, KEY_FASTFORWARD },
+	{ 0x0, 0x07, KEY_RECORD },
+	{ 0x0, 0x08, KEY_STOP },
+	{ 0x0, 0x09, KEY_TIME }, /* Timeshift */
+	{ 0x0, 0x0c, KEY_COFFEE }, /* Recall */
+	{ 0x0, 0x0e, KEY_CHANNELUP },
+	{ 0x0, 0x12, KEY_POWER },
+	{ 0x0, 0x15, KEY_MENU }, /* source */
+	{ 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */
+	{ 0x0, 0x1a, KEY_CHANNELDOWN },
+	{ 0x0, 0x1b, KEY_VOLUMEDOWN },
+	{ 0x0, 0x1e, KEY_VOLUMEUP },
+};
+
 static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\
 			     u16 index, void *data, int size)
 {
@@ -74,17 +94,23 @@ static inline int m9206_write(struct usb
 	return ret;
 }
 
-static int m9206_init(struct dvb_usb_device *d)
+static int m9206_init(struct dvb_usb_device *d, struct m9206_inits *rc_seq)
 {
 	int ret = 0;
 
 	/* Remote controller init. */
 	if (d->props.rc_query) {
-		if ((ret = m9206_write(d->udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0)
-			return ret;
-
-		if ((ret = m9206_write(d->udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0)
-			return ret;
+		deb_rc("Initialising remote control\n");
+		while (rc_seq->address) {
+			if ((ret = m9206_write(d->udev, M9206_CORE, rc_seq->data, rc_seq->address)) != 0) {
+				deb_rc("Initialising remote control failed\n");
+				return ret;
+			}
+
+			rc_seq++;
+		}
+	
+		deb_rc("Initialising remote control success\n");
 	}
 
 	return ret;
@@ -109,6 +135,14 @@ static int m9206_rc_query(struct dvb_usb
 			switch(rc_state[0]) {
 			case 0x80:
 				*state = REMOTE_NO_KEY_PRESSED;
+				goto unlock;
+
+			case 0x88: /* framing error or "invalid code" */
+			case 0x99:
+			case 0xc0:
+			case 0xd8:
+				*state = REMOTE_NO_KEY_PRESSED;
+				m->rep_count = 0;
 				goto unlock;
 
 			case 0x93:
@@ -118,20 +152,22 @@ static int m9206_rc_query(struct dvb_usb
 				goto unlock;
 
 			case 0x91:
-				/* For comfort. */
+				/* prevent immediate auto-repeat */
 				if (++m->rep_count > 2)
 					*state = REMOTE_KEY_REPEAT;
+				else
+					*state = REMOTE_NO_KEY_PRESSED;
 				goto unlock;
 
 			default:
-				deb_rc("Unexpected rc response %x\n", rc_state[0]);
+				deb_rc("Unexpected rc state %02x\n", rc_state[0]);
 				*state = REMOTE_NO_KEY_PRESSED;
 				goto unlock;
 			}
 		}
 
 	if (rc_state[1] != 0)
-		deb_rc("Unknown rc key %x\n", rc_state[1]);
+		deb_rc("Unknown rc key %02x\n", rc_state[1]);
 
 	*state = REMOTE_NO_KEY_PRESSED;
 
@@ -416,6 +452,12 @@ static int megasky_qt1010_tuner_attach(s
 	return 0;
 }
 
+static struct m9206_inits megasky_rc_init [] = {
+	{ M9206_RC_INIT2, 0xa8 },
+	{ M9206_RC_INIT1, 0x51 },
+	{ } /* terminating entry */
+};
+
 static struct tda1004x_config digivox_tda10046_config = {
 	.demod_address = 0x08,
 	.invert = 0,
@@ -447,9 +489,106 @@ static int digivox_tda8275_tuner_attach(
 	return 0;
 }
 
+/* LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
+ * TDA10046 #0 is located at i2c address 0x08
+ * TDA10046 #1 is located at i2c address 0x0b
+ * TDA8275A #0 is located at i2c address 0x60
+ * TDA8275A #1 is located at i2c address 0x61
+ */
+
+static struct tda1004x_config tvwalkertwin_0_tda10046_config = {
+	.demod_address = 0x08,
+	.invert = 0,
+	.invert_oclk = 0,
+	.ts_mode = TDA10046_TS_SERIAL,
+	.xtal_freq = TDA10046_XTAL_16M,
+	.if_freq = TDA10046_FREQ_045,
+	.agc_config = TDA10046_AGC_TDA827X,
+	.gpio_config = TDA10046_GPTRI,
+	.request_firmware = NULL, /* uses firmware EEPROM */
+};
+
+static struct tda1004x_config tvwalkertwin_1_tda10046_config = {
+	.demod_address = 0x0b,
+	.invert = 0,
+	.invert_oclk = 0,
+	.ts_mode = TDA10046_TS_SERIAL,
+	.xtal_freq = TDA10046_XTAL_16M,
+	.if_freq = TDA10046_FREQ_045,
+	.agc_config = TDA10046_AGC_TDA827X,
+	.gpio_config = TDA10046_GPTRI,
+	.request_firmware = NULL, /* uses firmware EEPROM */
+};
+
+static int tvwalkertwin_0_tda10046_frontend_attach(struct dvb_usb_adapter *adap)
+{
+	deb_rc("tvwalkertwin_0_tda10046_frontend_attach!\n");
+
+	if ((adap->fe = dvb_attach(tda10046_attach, &tvwalkertwin_0_tda10046_config, &adap->dev->i2c_adap)) == NULL)
+		return -EIO;
+
+	deb_rc("Attached demod 0 at address %02x\n", tvwalkertwin_0_tda10046_config.demod_address);
+
+	return 0;
+}
+
+static int tvwalkertwin_1_tda10046_frontend_attach(struct dvb_usb_adapter *adap)
+{
+	deb_rc("tvwalkertwin_1_tda10046_frontend_attach!\n");
+
+	if ((adap->fe = dvb_attach(tda10046_attach, &tvwalkertwin_1_tda10046_config, &adap->dev->i2c_adap)) == NULL)
+		return -EIO;
+
+	deb_rc("Attached demod 1 at address %02x\n", tvwalkertwin_1_tda10046_config.demod_address);
+
+	return 0;
+}
+
+static int tvwalkertwin_0_tda8275_tuner_attach(struct dvb_usb_adapter *adap)
+{
+	int address = 0x60;
+
+	deb_rc("tvwalkertwin_0_tda8275_tuner_attach!\n");
+
+	if (dvb_attach(tda827x_attach, adap->fe, address, &adap->dev->i2c_adap,
+		       NULL) == NULL)
+		return -ENODEV;
+
+	deb_rc("Attached tuner 0 at address %02x\n", address);
+
+	return 0;
+}
+
+static int tvwalkertwin_1_tda8275_tuner_attach(struct dvb_usb_adapter *adap)
+{
+	int address = 0x61;
+
+	deb_rc("tvwalkertwin_1_tda8275_tuner_attach!\n");
+
+	if (dvb_attach(tda827x_attach, adap->fe, address, &adap->dev->i2c_adap,
+		       NULL) == NULL)
+		return -ENODEV;
+
+	deb_rc("Attached tuner 1 at address %02x\n", address);
+
+	return 0;
+}
+
+static struct m9206_inits tvwalkertwin_rc_init [] = {
+	{ M9206_RC_INIT2, 0x00 },
+	{ M9206_RC_INIT1, 0xef },
+	{ 0xff28,         0x00 },
+	{ 0xff23,         0x00 },
+	{ 0xff21,         0x30 },
+	{ } /* terminating entry */
+};
+
 /* DVB USB Driver stuff */
 static struct dvb_usb_device_properties megasky_properties;
 static struct dvb_usb_device_properties digivox_mini_ii_properties;
+static struct dvb_usb_device_properties tvwalkertwin_properties;
+static struct m9206_inits megasky_rc_init [];
+static struct m9206_inits tvwalkertwin_rc_init [];
 
 static int m920x_probe(struct usb_interface *intf,
 		       const struct usb_device_id *id)
@@ -457,14 +596,46 @@ static int m920x_probe(struct usb_interf
 	struct dvb_usb_device *d;
 	struct usb_host_interface *alt;
 	int ret;
-
-	deb_rc("Probed!\n");
-
-	if (((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) ||
-	    ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, THIS_MODULE, &d)) == 0))
-		goto found;
-
-	return ret;
+	struct m9206_inits *rc_init_seq = NULL;
+	int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber;
+
+	deb_rc("Probing for m920x device at interface %d\n", bInterfaceNumber);
+
+	if (bInterfaceNumber == 0) {
+		/* Single-tuner device, or first interface on 
+		 * multi-tuner device
+		 */
+
+		if ((ret = dvb_usb_device_init(intf, &megasky_properties,
+			THIS_MODULE, &d)) == 0) {
+			rc_init_seq = megasky_rc_init;
+			goto found;
+		}
+
+		if ((ret = dvb_usb_device_init(intf,
+			&digivox_mini_ii_properties, THIS_MODULE, &d)) == 0) {
+			/* No remote control, so no rc_init_seq */
+			goto found;
+		}
+
+		/* This configures both tuners on the TV Walker Twin */
+		if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties,
+			THIS_MODULE, &d)) == 0) {
+			rc_init_seq = tvwalkertwin_rc_init;
+			goto found;
+		}
+
+		return ret;
+	} else {
+		/* Another interface on a multi-tuner device */
+
+		/* The LifeView TV Walker Twin gets here, but struct
+		 * tvwalkertwin_properties already configured both
+		 * tuners, so there is nothing for us to do here
+		 */
+
+		return -ENODEV;
+	}
 
 found:
 	alt = usb_altnum_to_altsetting(intf, 1);
@@ -478,7 +649,7 @@ found:
 	if (ret < 0)
 		return ret;
 
-	if ((ret = m9206_init(d)) != 0)
+	if ((ret = m9206_init(d, rc_init_seq)) != 0)
 		return ret;
 
 	return ret;
@@ -488,6 +659,10 @@ static struct usb_device_id m920x_table 
 		{ USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
 		{ USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
 			     USB_PID_MSI_DIGI_VOX_MINI_II) },
+		{ USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
+		             USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) },
+		{ USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
+			     USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) },
 		{ }		/* Terminating entry */
 };
 MODULE_DEVICE_TABLE (usb, m920x_table);
@@ -585,6 +760,81 @@ static struct dvb_usb_device_properties 
 	}
 };
 
+/* LifeView TV Walker Twin support by Nick Andrew <nick@xxxxxxxxxxxxxxx> */
+
+static struct dvb_usb_device_properties tvwalkertwin_properties = {
+	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
+
+	.usb_ctrl = DEVICE_SPECIFIC,
+	.firmware = "dvb-usb-tvwalkert.fw",
+	.download_firmware = m9206_firmware_download,
+
+	.rc_interval      = 100,
+	.rc_key_map       = tvwalkertwin_rc_keys,
+	.rc_key_map_size  = ARRAY_SIZE(tvwalkertwin_rc_keys),
+	.rc_query         = m9206_rc_query,
+
+	.size_of_priv     = sizeof(struct m9206_state),
+
+	.identify_state   = m920x_identify_state,
+	.num_adapters = 2,
+	.adapter = {
+		{
+			.caps = DVB_USB_ADAP_HAS_PID_FILTER |
+				DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
+
+			.pid_filter_count = 8,
+			.pid_filter       = m9206_pid_filter,
+			.pid_filter_ctrl  = m9206_pid_filter_ctrl,
+
+			.frontend_attach  = tvwalkertwin_0_tda10046_frontend_attach,
+			.tuner_attach     = tvwalkertwin_0_tda8275_tuner_attach,
+
+			.stream = {
+				.type = USB_BULK,
+				.count = 8,
+				.endpoint = 0x81,
+				.u = {
+					.bulk = {
+						.buffersize = 512,
+					}
+				}
+			},
+		},
+		{
+			.caps = DVB_USB_ADAP_HAS_PID_FILTER |
+				DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
+
+			.pid_filter_count = 8,
+			.pid_filter       = m9206_pid_filter,
+			.pid_filter_ctrl  = m9206_pid_filter_ctrl,
+
+			.frontend_attach  = tvwalkertwin_1_tda10046_frontend_attach,
+			.tuner_attach     = tvwalkertwin_1_tda8275_tuner_attach,
+
+			.stream = {
+				.type = USB_BULK,
+				.count = 8,
+				.endpoint = 0x82,
+				.u = {
+					.bulk = {
+						.buffersize = 512,
+					}
+				}
+			},
+		}
+	},
+	.i2c_algo         = &m9206_i2c_algo,
+
+	.num_device_descs = 1,
+	.devices = {
+		{   .name = "LifeView TV Walker Twin DVB-T USB2.0",
+		    .cold_ids = { &m920x_table[2], NULL },
+		    .warm_ids = { &m920x_table[3], NULL },
+		},
+	}
+};
+
 static struct usb_driver m920x_driver = {
 #if LINUX_VERSION_CODE <=  KERNEL_VERSION(2,6,15)
 	.owner		= THIS_MODULE,
@@ -618,6 +868,6 @@ module_exit (m920x_module_exit);
 module_exit (m920x_module_exit);
 
 MODULE_AUTHOR("Aapo Tahkola <aet@xxxxxxxxxxxxxx>");
-MODULE_DESCRIPTION("Driver MSI Mega Sky 580 DVB-T USB2.0 / Uli m920x");
+MODULE_DESCRIPTION("DVB Driver for ULI M920x");
 MODULE_VERSION("0.1");
 MODULE_LICENSE("GPL");
diff -r 0832954f4b9d linux/drivers/media/dvb/dvb-usb/m920x.h
--- a/linux/drivers/media/dvb/dvb-usb/m920x.h	Sun Mar 18 18:54:07 2007 -0400
+++ b/linux/drivers/media/dvb/dvb-usb/m920x.h	Tue Mar 20 11:39:12 2007 +1100
@@ -64,4 +64,13 @@ struct m9206_state {
 	int filtering_enabled;
 	int rep_count;
 };
+
+/* Initialisation data for the m920x
+ */
+
+struct m9206_inits {
+	u16 address;
+	u8  data;
+};
+
 #endif

Attachment: signature.asc
Description: Digital signature

_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux