From 822f5c874f99909a9e91e264ad0f71daf54ce01c Mon Sep 17 00:00:00 2001 From: Holger Waechtler Date: Mon, 26 Jan 2004 10:25:05 +0000 Subject: don't send zero-byte messages when probing the PLL type --- linux/drivers/media/dvb/frontends/nxt6000.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'linux/drivers/media/dvb/frontends/nxt6000.c') diff --git a/linux/drivers/media/dvb/frontends/nxt6000.c b/linux/drivers/media/dvb/frontends/nxt6000.c index c8164ff2d..0e8706cd0 100644 --- a/linux/drivers/media/dvb/frontends/nxt6000.c +++ b/linux/drivers/media/dvb/frontends/nxt6000.c @@ -115,6 +115,19 @@ static u8 nxt6000_readreg(struct dvb_frontend *fe, u8 reg) return nxt6000_read(fe->i2c, nxt->demod_addr, reg); } +static int pll_test(struct dvb_i2c_bus *i2c, u8 demod_addr, u8 tuner_addr) +{ + u8 buf [1]; + struct i2c_msg msg = {.addr = tuner_addr >> 1,.flags = I2C_M_RD,.buf = buf,.len = 1 }; + int ret; + + nxt6000_write(i2c, demod_addr, ENABLE_TUNER_IIC, 0x01); /* open i2c bus switch */ + ret = i2c->xfer(i2c, &msg, 1); + nxt6000_write(i2c, demod_addr, ENABLE_TUNER_IIC, 0x00); /* close i2c bus switch */ + + return (ret != 1) ? -EFAULT : 0; +} + static int pll_write(struct dvb_i2c_bus *i2c, u8 demod_addr, u8 tuner_addr, u8 * buf, u8 len) { struct i2c_msg msg = {.addr = tuner_addr >> 1,.flags = 0,.buf = buf,.len = len }; @@ -717,21 +730,21 @@ static int nxt6000_attach(struct dvb_i2c_bus *i2c, void **data) if (nxt6000_read(i2c, demod_addr_tbl[addr_nr], OFDM_MSC_REV) != NXT6000ASICDEVICE) continue; - if (pll_write(i2c, demod_addr_tbl[addr_nr], 0xC0, NULL, 0) == 0) { + if (pll_test(i2c, demod_addr_tbl[addr_nr], 0xC0) == 0) { nxt->tuner_addr = 0xC0; nxt->tuner_type = TUNER_TYPE_ALP510; nxt->clock_inversion = 1; dprintk("nxt6000: detected TI ALP510 tuner at 0x%02X\n", nxt->tuner_addr); - } else if (pll_write(i2c, demod_addr_tbl[addr_nr], 0xC2, NULL, 0) == 0) { + } else if (pll_test(i2c, demod_addr_tbl[addr_nr], 0xC2) == 0) { nxt->tuner_addr = 0xC2; nxt->tuner_type = TUNER_TYPE_SP5659; nxt->clock_inversion = 0; dprintk("nxt6000: detected MITEL SP5659 tuner at 0x%02X\n", nxt->tuner_addr); - } else if (pll_write(i2c, demod_addr_tbl[addr_nr], 0xC0, NULL, 0) == 0) { + } else if (pll_test(i2c, demod_addr_tbl[addr_nr], 0xC0) == 0) { nxt->tuner_addr = 0xC0; nxt->tuner_type = TUNER_TYPE_SP5730; nxt->clock_inversion = 0; -- cgit v1.2.3