summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Waechtler <devnull@localhost>2003-06-16 22:56:42 +0000
committerHolger Waechtler <devnull@localhost>2003-06-16 22:56:42 +0000
commite0622e268e489557031a733b25000b81cfc737fa (patch)
treeda494d52ecb55e938d133a7d90fcd44422f4c1e8
parente9fa3995438bfb9e0383faa4b8e9a481863db3de (diff)
downloadmediapointer-dvb-s2-e0622e268e489557031a733b25000b81cfc737fa.tar.gz
mediapointer-dvb-s2-e0622e268e489557031a733b25000b81cfc737fa.tar.bz2
try to make a more specific detection mechanism
-rw-r--r--linux/drivers/media/dvb/frontends/grundig_29504-401.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/linux/drivers/media/dvb/frontends/grundig_29504-401.c b/linux/drivers/media/dvb/frontends/grundig_29504-401.c
index ecf9383e7..d4cbcf8ff 100644
--- a/linux/drivers/media/dvb/frontends/grundig_29504-401.c
+++ b/linux/drivers/media/dvb/frontends/grundig_29504-401.c
@@ -443,30 +443,50 @@ int l64781_attach (struct dvb_i2c_bus *i2c)
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
void l64781_detach (struct dvb_i2c_bus *i2c)
{