[PATCH] dvb: determine tuner write method based on nxt chip
- Add support for AVerTVHD MCE a180. - Instead of determining how to write to the tuner based on which NIM is being used, make this determination based on whether the chip is a NXT2002 or NXT2004. - If NXT2004, write directly to tuner. If NXT2002, write through NXT chip. Signed-off-by: Michael Krufky <mkrufky@m1k.net> Cc: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
6d35ae3d11
commit
f0fa86a574
@@ -342,50 +342,56 @@ static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
|
|||||||
|
|
||||||
dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
|
dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
|
||||||
|
|
||||||
/* if pll is a Philips TUV1236D then write directly to tuner */
|
/* if NXT2004, write directly to tuner. if NXT2002, write through NXT chip.
|
||||||
if (strcmp(state->config->pll_desc->name, "Philips TUV1236D") == 0) {
|
* direct write is required for Philips TUV1236D and ALPS TDHU2 */
|
||||||
if (i2c_writebytes(state, state->config->pll_address, data, 4))
|
switch (state->demod_chip) {
|
||||||
printk(KERN_WARNING "nxt200x: error writing to tuner\n");
|
case NXT2004:
|
||||||
/* wait until we have a lock */
|
if (i2c_writebytes(state, state->config->pll_address, data, 4))
|
||||||
while (count < 20) {
|
printk(KERN_WARNING "nxt200x: error writing to tuner\n");
|
||||||
i2c_readbytes(state, state->config->pll_address, &buf, 1);
|
/* wait until we have a lock */
|
||||||
if (buf & 0x40)
|
while (count < 20) {
|
||||||
return 0;
|
i2c_readbytes(state, state->config->pll_address, &buf, 1);
|
||||||
msleep(100);
|
if (buf & 0x40)
|
||||||
count++;
|
return 0;
|
||||||
}
|
msleep(100);
|
||||||
printk("nxt200x: timeout waiting for tuner lock\n");
|
count++;
|
||||||
return 0;
|
}
|
||||||
} else {
|
printk("nxt2004: timeout waiting for tuner lock\n");
|
||||||
/* set the i2c transfer speed to the tuner */
|
break;
|
||||||
buf = 0x03;
|
case NXT2002:
|
||||||
nxt200x_writebytes(state, 0x20, &buf, 1);
|
/* set the i2c transfer speed to the tuner */
|
||||||
|
buf = 0x03;
|
||||||
|
nxt200x_writebytes(state, 0x20, &buf, 1);
|
||||||
|
|
||||||
/* setup to transfer 4 bytes via i2c */
|
/* setup to transfer 4 bytes via i2c */
|
||||||
buf = 0x04;
|
buf = 0x04;
|
||||||
nxt200x_writebytes(state, 0x34, &buf, 1);
|
nxt200x_writebytes(state, 0x34, &buf, 1);
|
||||||
|
|
||||||
/* write actual tuner bytes */
|
/* write actual tuner bytes */
|
||||||
nxt200x_writebytes(state, 0x36, data, 4);
|
nxt200x_writebytes(state, 0x36, data, 4);
|
||||||
|
|
||||||
/* set tuner i2c address */
|
/* set tuner i2c address */
|
||||||
buf = state->config->pll_address;
|
buf = state->config->pll_address;
|
||||||
nxt200x_writebytes(state, 0x35, &buf, 1);
|
nxt200x_writebytes(state, 0x35, &buf, 1);
|
||||||
|
|
||||||
/* write UC Opmode to begin transfer */
|
/* write UC Opmode to begin transfer */
|
||||||
buf = 0x80;
|
buf = 0x80;
|
||||||
nxt200x_writebytes(state, 0x21, &buf, 1);
|
nxt200x_writebytes(state, 0x21, &buf, 1);
|
||||||
|
|
||||||
while (count < 20) {
|
while (count < 20) {
|
||||||
nxt200x_readbytes(state, 0x21, &buf, 1);
|
nxt200x_readbytes(state, 0x21, &buf, 1);
|
||||||
if ((buf & 0x80)== 0x00)
|
if ((buf & 0x80)== 0x00)
|
||||||
return 0;
|
return 0;
|
||||||
msleep(100);
|
msleep(100);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
printk("nxt200x: timeout error writing tuner\n");
|
printk("nxt2002: timeout error writing tuner\n");
|
||||||
return 0;
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nxt200x_agc_reset(struct nxt200x_state* state)
|
static void nxt200x_agc_reset(struct nxt200x_state* state)
|
||||||
|
Reference in New Issue
Block a user