Re: Help please; hacking m920x driver

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

 



Here's a diff of my driver against the m920x.c in the v4l-dvb repository...

diff -r beb96321d0ce linux/drivers/media/dvb/dvb-usb/m920x.c
--- a/linux/drivers/media/dvb/dvb-usb/m920x.c	Fri Mar 02 06:27:59 2007 +1100
+++ b/linux/drivers/media/dvb/dvb-usb/m920x.c	Fri Mar 02 11:31:50 2007 +1100
@@ -14,6 +14,8 @@
 #include "mt352.h"
 #include "mt352_priv.h"
 #include "qt1010.h"
+#include "tda1004x.h"
+#include "tda827x.h"
 
 /* debug */
 static int dvb_usb_m920x_debug;
@@ -331,6 +333,7 @@ static int m9206_firmware_download(struc
 			i += size;
 		}
 		if (i != fw->size) {
+			deb_rc("bad firmware file!\n");
 			ret = -EINVAL;
 			goto done;
 		}
@@ -350,6 +353,19 @@ static int m9206_firmware_download(struc
 
 /* Callbacks for DVB USB */
 static int megasky_identify_state(struct usb_device *udev,
+				  struct dvb_usb_device_properties *props,
+				  struct dvb_usb_device_description **desc,
+				  int *cold)
+{
+	struct usb_host_interface *alt;
+
+	alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
+	*cold = (alt == NULL) ? 1 : 0;
+
+	return 0;
+}
+
+static int tvwalkertwin_identify_state(struct usb_device *udev,
 				  struct dvb_usb_device_properties *props,
 				  struct dvb_usb_device_description **desc,
 				  int *cold)
@@ -408,6 +424,47 @@ static int megasky_mt352_frontend_attach
 	return 0;
 }
 
+static struct tda1004x_config tvwalkertwin_tda10046_config1 = {
+	// .no_tuner = 1,
+	.demod_address = 0x10,
+	.invert = 0,
+	.invert_oclk = 0,
+	.xtal_freq = TDA10046_XTAL_16M,
+	.if_freq = TDA10046_FREQ_045,
+	// missing .tuner_address
+	// missing .tuner_config
+};
+
+/* LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
+ * The second tuner is located at address 0x16
+ */
+
+static struct tda1004x_config tvwalkertwin_tda10046_config2 = {
+	// .no_tuner = 1,
+	.demod_address = 0x16,
+	.invert = 0,
+	.invert_oclk = 0,
+	.xtal_freq = TDA10046_XTAL_16M,
+	.if_freq = TDA10046_FREQ_045,
+	// missing .tuner_address
+	// missing .tuner_config
+};
+
+static int tvwalkertwin_tda10046_frontend_attach(struct dvb_usb_adapter *adap)
+{
+	struct m9206_state *m = adap->dev->priv;
+
+	deb_rc("tvwalkertwin_tda10046_frontend_attach!\n");
+
+	m->i2c_r[M9206_I2C_DEMOD].addr = tvwalkertwin_tda10046_config1.demod_address;
+	m->i2c_r[M9206_I2C_DEMOD].magic = 0x11;
+
+	if ((adap->fe = dvb_attach(tda10046_attach, &tvwalkertwin_tda10046_config1, &adap->dev->i2c_adap)) == NULL)
+		return -EIO;
+
+	return 0;
+}
+
 static struct qt1010_config megasky_qt1010_config = {
 	.i2c_address = 0xc4
 };
@@ -426,8 +483,27 @@ static int megasky_qt1010_tuner_attach(s
 	return 0;
 }
 
+static struct tda827x_config tvwalkertwin_tda8275_config = {
+};
+
+static int tvwalkertwin_tda8275_tuner_attach(struct dvb_usb_adapter *adap)
+{
+	struct m9206_state *m = adap->dev->priv;
+	int	address = 0x60;
+
+	m->i2c_r[M9206_I2C_TUNER].addr = address * 2;
+	m->i2c_r[M9206_I2C_TUNER].magic = address * 2 + 1;
+
+	if (dvb_attach(tda827x_attach, adap->fe, address, &adap->dev->i2c_adap,
+		       &tvwalkertwin_tda8275_config) == NULL)
+		return -ENODEV;
+
+	return 0;
+}
+
 /* DVB USB Driver stuff */
 static struct dvb_usb_device_properties megasky_properties;
+static struct dvb_usb_device_properties tvwalkertwin_properties;
 
 static int m920x_probe(struct usb_interface *intf,
 		       const struct usb_device_id *id)
@@ -455,11 +531,20 @@ static int m920x_probe(struct usb_interf
 		if ((ret = m9206_rc_init(d->udev)) != 0)
 			return ret;
 	}
+	else if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties, THIS_MODULE, &d)) == 0) {
+		deb_rc("Successfully probed LifeView TV Walker Twin\n");
+//later		if ((ret = m9206_rc_init(d->udev)) != 0)
+//later			return ret;
+		return ret;
+	}
+
 	return ret;
 }
 
 static struct usb_device_id m920x_table [] = {
 		{ USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
+		{ USB_DEVICE(0x10fd, 0x0514) }, /* cold */
+		{ USB_DEVICE(0x10fd, 0x0513) }, /* warm */
 		{ }		/* Terminating entry */
 };
 MODULE_DEVICE_TABLE (usb, m920x_table);
@@ -513,6 +598,55 @@ static struct dvb_usb_device_properties 
 	}
 };
 
+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   = tvwalkertwin_identify_state,
+	.num_adapters = 1,
+	.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_tda10046_frontend_attach,
+		.tuner_attach     = tvwalkertwin_tda8275_tuner_attach,
+
+		.stream = {
+			.type = USB_BULK,
+			.count = 8,
+			.endpoint = 0x81,
+			.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[1], NULL },
+		    .warm_ids = { &m920x_table[2], NULL },
+		},
+	}
+};
+
 static struct usb_driver m920x_driver = {
 #if LINUX_VERSION_CODE <=  KERNEL_VERSION(2,6,15)
 	.owner		= THIS_MODULE,

_______________________________________________
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