Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: [PATCH] Make grundig_29504-401 tuner work onmodule re-insertion
Holger Waechtler wrote:
synchronized, I'll fix that. Can you please update your CVS and then
take the new grundig_29504-401.c as reference?
OK, I've been trying this out over the weekend and found that the chip
power control doesn't behave quite as you would expect. When the chip is
powered down it returns 0 from all reads not the 0x5A which your code
expects. I did a one line patch which fixes this.
As an alternative I rewrote this section of the code to try to make a
more specific detection mechanism based on the behaviour of my board. It
turns the chip off, verifies the expected behaviour, then turns it on
again and again veries it behaves as expected. You might like to
consider this instead of the patch above.
Jon
Index: grundig_29504-401.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/grundig_29504-401.c,v
retrieving revision 1.16
diff -u -w -r1.16 grundig_29504-401.c
--- grundig_29504-401.c 12 Jun 2003 11:15:27 -0000 1.16
+++ grundig_29504-401.c 16 Jun 2003 18:40:43 -0000
@@ -448,7 +448,7 @@
/**
* if we see a powered down L64781 we wake it up...
*/
- if (reg0x3e == 0x5a) {
+ if (reg0x3e == 0x00) {
dprintk("waking up sleeping L64781...\n");
l64781_writereg (i2c, 0x3e, 0xa5);
}
Index: grundig_29504-401.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/grundig_29504-401.c,v
retrieving revision 1.16
diff -u -w -r1.16 grundig_29504-401.c
--- grundig_29504-401.c 12 Jun 2003 11:15:27 -0000 1.16
+++ grundig_29504-401.c 16 Jun 2003 18:41:06 -0000
@@ -443,28 +443,48 @@
return -ENODEV;
}
+ /* The chip always responds to reads */
+ if (i2c->xfer(i2c, msg, 2) != 2) {
+ dprintk("no response to read on I2C bus\n");
+ return -ENODEV;
+ }
+
+ /* Save current register contents for bailout */
reg0x3e = l64781_readreg(i2c, 0x3e);
- /**
- * if we see a powered down L64781 we wake it up...
- */
- if (reg0x3e == 0x5a) {
- dprintk("waking up sleeping L64781...\n");
- l64781_writereg (i2c, 0x3e, 0xa5);
+ /* Reading the POWER_DOWN register always returns 0 */
+ if (reg0x3e != 0) {
+ dprintk("Device doesn't look like L64781\n");
+ return -ENODEV;
}
- if (i2c->xfer(i2c, msg, 2) != 2) /* nothing... */
- return -ENODEV;
+ /* Turn the chip off */
+ l64781_writereg (i2c, 0x3e, 0x5a);
- if (b1[0] != 0xa1) { /* oops, we're tried to talk to an EEPROM...*/
- l64781_writereg (i2c, 0x3e, reg0x3e); /* restore reg 0x3e */
- return -ENODEV;
+ /* Responds to all reads with 0 */
+ if (l64781_readreg(i2c, 0x1a) != 0) {
+ dprintk("Read 1 returned unexpcted value\n");
+ goto bailout;
+ }
+
+ /* Turn the chip on */
+ l64781_writereg (i2c, 0x3e, 0xa5);
+
+ /* Responds with register default value */
+ if (l64781_readreg(i2c, 0x1a) != 0xa1) {
+ dprintk("Read 2 returned unexpcted value\n");
+ goto bailout;
}
dvb_register_frontend (grundig_29504_401_ioctl, i2c, NULL,
&grundig_29504_401_info);
return 0;
+
+ bailout:
+ l64781_writereg (i2c, 0x3e, reg0x3e); /* restore reg 0x3e */
+ return -ENODEV;
}
+
static
Home |
Main Index |
Thread Index