[PATCH] i2c_gate_ctrl QT1010, ZL10353 (and GL861 AU6610)

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

 



moro!
This patch adds i2c_gate_ctrl to QT1010-tuner and ZL10353-demodulator.

Tested successfully against fi-Oulu frequencies with following hw: MSI Megasky 580 GL861 and Sigmatek DVB-110 AU6610.

changes:
QT1010:
- use i2c_gate_ctrl when accessing to tuner

ZL10353:
- implement i2c_gate_ctrl
- change one reset_attach register to same as main v4l-dvb tree
- leave registers 0x65 and 0x66 to chipset default one... This change could *break* some other devices using ZL10353 module! Testing needed! This change is needed to get Megasky GL861 and Sigmatek AU6610 working.

AU6610:
- remove unneeded code due to proper i2c_gate_ctrl

GL861:
- remove unneeded code due to proper i2c_gate_ctrl

Regards Antti Palosaari

--
              |||
             (0-0)
---------oOO--(_)--OOo--------------------------------------------
tel. +358 40 535 7322 | MSN Messenger crope@xxxxxx | www.palosaari.fi
-Kahta asiaa en ymmärrä.. C-kielen syntaksi ja naisten logiikka.."

diff -r 2417cff7cf81 linux/drivers/media/dvb/dvb-usb/au6610.c
--- a/linux/drivers/media/dvb/dvb-usb/au6610.c	Tue Oct 03 16:10:21 2006 -0400
+++ b/linux/drivers/media/dvb/dvb-usb/au6610.c	Wed Jan 24 01:06:11 2007 +0200
@@ -145,19 +145,6 @@ static struct qt1010_config au6610_qt101
 
 static int au6610_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
 {
-	/* TODO FIXME; probably I2C gate.
-	QT1010 tuner does not respond before we write 0x1a to ZL10353 demod
-	register 0x62. This ought to be done somewhere in demod initialization.
-	This solution is temporary hack. */
-
-	u8 buf[2] = { 0x62, 0x1a };
-	struct i2c_msg msg = { .addr = au6610_zl10353_config.demod_address,
-			       .flags = 0, .buf = buf, .len = 2	};
-
-	if (i2c_transfer(&adap->dev->i2c_adap, &msg, 1) != 1) {
-		printk(KERN_WARNING "au6610 tuner attach failed\n");
-		return -EREMOTEIO;
-	}
 	return dvb_attach(qt1010_attach,
 			  adap->fe, &adap->dev->i2c_adap,
 			  &au6610_qt1010_config) == NULL ? -ENODEV : 0;
diff -r 2417cff7cf81 linux/drivers/media/dvb/dvb-usb/gl861.c
--- a/linux/drivers/media/dvb/dvb-usb/gl861.c	Tue Oct 03 16:10:21 2006 -0400
+++ b/linux/drivers/media/dvb/dvb-usb/gl861.c	Wed Jan 24 02:40:36 2007 +0200
@@ -122,19 +122,6 @@ static struct qt1010_config gl861_qt1010
 
 static int gl861_tuner_attach(struct dvb_usb_adapter *adap)
 {
-	/* TODO FIXME; probably I2C gate.
-	QT1010 tuner does not respond before we write 0x1a to ZL10353 demod
-	register 0x62. This ought to be done somewhere in demod initialization.
-	This solution is temporary hack. */
-
-	u8 buf[2] = { 0x62, 0x1a };
-	struct i2c_msg msg = { .addr = gl861_zl10353_config.demod_address,
-			       .flags = 0, .buf = buf, .len = 2	};
-
-	if (i2c_transfer(&adap->dev->i2c_adap, &msg, 1) != 1) {
-		printk(KERN_WARNING "gl861 tuner attach failed\n");
-		return -EREMOTEIO;
-	}
 	return dvb_attach(qt1010_attach,
 			  adap->fe, &adap->dev->i2c_adap,
 			  &gl861_qt1010_config) == NULL ? -ENODEV : 0;
diff -r 2417cff7cf81 linux/drivers/media/dvb/frontends/qt1010.c
--- a/linux/drivers/media/dvb/frontends/qt1010.c	Tue Oct 03 16:10:21 2006 -0400
+++ b/linux/drivers/media/dvb/frontends/qt1010.c	Wed Jan 24 02:39:24 2007 +0200
@@ -149,6 +149,9 @@ static int qt1010_set_params(struct dvb_
 	priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0;
 	priv->frequency = freq;
 
+	if (fe->ops.i2c_gate_ctrl)
+		fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */
+
 	/* reg 05 base value */
 	if      (freq < 290000000) reg05 = 0x14; /* 290 MHz */
 	else if (freq < 610000000) reg05 = 0x34; /* 610 MHz */
@@ -242,6 +245,9 @@ static int qt1010_set_params(struct dvb_
 	if (debug)
 		qt1010_dump_regs(priv);
 
+	if (fe->ops.i2c_gate_ctrl)
+		fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */
+
 	return 0;
 }
 
@@ -276,7 +282,6 @@ static int qt1010_init_meas1(struct qt10
 
 	return qt1010_writereg(priv, 0x1e, 0x00);
 }
-
 
 static u8 qt1010_init_meas2(struct qt1010_priv *priv, u8 reg_init_val, u8 *retval)
 {
@@ -347,6 +352,9 @@ static int qt1010_init(struct dvb_fronte
 		{ QT1010_WR, 0x08, 0x08 }
 	};
 
+	if (fe->ops.i2c_gate_ctrl)
+		fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */
+
 	for (i = 0; i < sizeof(i2c_data) / sizeof(*i2c_data); i++) {
 		switch (i2c_data[i].oper) {
 		case QT1010_WR:
@@ -430,6 +438,9 @@ struct dvb_frontend * qt1010_attach(stru
 	priv->cfg      = cfg;
 	priv->i2c      = i2c;
 
+	if (fe->ops.i2c_gate_ctrl)
+		fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */
+
 #if 0
 	qt1010_dump_regs(priv);
 #endif
@@ -439,6 +450,9 @@ struct dvb_frontend * qt1010_attach(stru
 		kfree(priv);
 		return NULL;
 	}
+
+	if (fe->ops.i2c_gate_ctrl)
+		fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */
 
 	printk(KERN_INFO "Quantek QT1010 successfully identified.\n");
 	memcpy(&fe->ops.tuner_ops, &qt1010_tuner_ops, sizeof(struct dvb_tuner_ops));
diff -r 2417cff7cf81 linux/drivers/media/dvb/frontends/zl10353.c
--- a/linux/drivers/media/dvb/frontends/zl10353.c	Tue Oct 03 16:10:21 2006 -0400
+++ b/linux/drivers/media/dvb/frontends/zl10353.c	Wed Jan 24 02:36:41 2007 +0200
@@ -142,14 +142,9 @@ static int zl10353_set_parameters(struct
 	zl10353_single_write(fe, 0x56, 0x28);
 	zl10353_single_write(fe, 0x89, 0x20);
 	zl10353_single_write(fe, 0x5E, 0x00);
-	zl10353_single_write(fe, 0x65, 0x5A);
-	zl10353_single_write(fe, 0x66, 0xE9);
 	zl10353_single_write(fe, 0x6C, 0xCD);
 	zl10353_single_write(fe, 0x6D, 0x7E);
-	zl10353_single_write(fe, 0x62, 0x0A);
-
-	zl10353_single_write(fe, 0x65, 0x67);
-	zl10353_single_write(fe, 0x62, 0x1A);
+	fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */
 
 	// if there is no attached secondary tuner, we call set_params to program
 	// a potential tuner attached somewhere else
@@ -250,7 +245,7 @@ static int zl10353_init(struct dvb_front
 static int zl10353_init(struct dvb_frontend *fe)
 {
 	struct zl10353_state *state = fe->demodulator_priv;
-	u8 zl10353_reset_attach[6] = { 0x50, 0x0B, 0x64, 0x46, 0x15, 0x0F };
+	u8 zl10353_reset_attach[6] = { 0x50, 0x03, 0x64, 0x46, 0x15, 0x0F };
 	int rc = 0;
 
 #if 1
@@ -272,6 +267,13 @@ static int zl10353_init(struct dvb_front
 	}
 
 	return 0;
+}
+
+static int zl10353_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
+{
+	u8 val = 0x0a;
+	if (enable) val |= 0x10;
+	return zl10353_single_write(fe, 0x62, val);
 }
 
 static void zl10353_release(struct dvb_frontend *fe)
@@ -332,6 +334,7 @@ static struct dvb_frontend_ops zl10353_o
 
 	.init = zl10353_init,
 	.sleep = zl10353_sleep,
+	.i2c_gate_ctrl = zl10353_i2c_gate_ctrl,
 	.write = zl10353_write,
 
 	.set_frontend = zl10353_set_parameters,

_______________________________________________
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