aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@m1k.net>2005-11-09 00:35:49 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:05 -0500
commitf0fa86a574843264bdcbed4c84b41a2778861fde (patch)
treef3974c580155375183ef8283620d89b40462d39f /drivers/media/dvb
parent6d35ae3d1137c92a315b7ff10aecd45b1f37d99e (diff)
[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>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c82
1 files changed, 44 insertions, 38 deletions
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
index 97ee8017dac8..aee170805caf 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -342,50 +342,56 @@ static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
342 342
343 dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]); 343 dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]);
344 344
345 /* if pll is a Philips TUV1236D then write directly to tuner */ 345 /* if NXT2004, write directly to tuner. if NXT2002, write through NXT chip.
346 if (strcmp(state->config->pll_desc->name, "Philips TUV1236D") == 0) { 346 * direct write is required for Philips TUV1236D and ALPS TDHU2 */
347 if (i2c_writebytes(state, state->config->pll_address, data, 4)) 347 switch (state->demod_chip) {
348 printk(KERN_WARNING "nxt200x: error writing to tuner\n"); 348 case NXT2004:
349 /* wait until we have a lock */ 349 if (i2c_writebytes(state, state->config->pll_address, data, 4))
350 while (count < 20) { 350 printk(KERN_WARNING "nxt200x: error writing to tuner\n");
351 i2c_readbytes(state, state->config->pll_address, &buf, 1); 351 /* wait until we have a lock */
352 if (buf & 0x40) 352 while (count < 20) {
353 return 0; 353 i2c_readbytes(state, state->config->pll_address, &buf, 1);
354 msleep(100); 354 if (buf & 0x40)
355 count++; 355 return 0;
356 } 356 msleep(100);
357 printk("nxt200x: timeout waiting for tuner lock\n"); 357 count++;
358 return 0; 358 }
359 } else { 359 printk("nxt2004: timeout waiting for tuner lock\n");
360 /* set the i2c transfer speed to the tuner */ 360 break;
361 buf = 0x03; 361 case NXT2002:
362 nxt200x_writebytes(state, 0x20, &buf, 1); 362 /* set the i2c transfer speed to the tuner */
363 buf = 0x03;
364 nxt200x_writebytes(state, 0x20, &buf, 1);
363 365
364 /* setup to transfer 4 bytes via i2c */ 366 /* setup to transfer 4 bytes via i2c */
365 buf = 0x04; 367 buf = 0x04;
366 nxt200x_writebytes(state, 0x34, &buf, 1); 368 nxt200x_writebytes(state, 0x34, &buf, 1);
367 369
368 /* write actual tuner bytes */ 370 /* write actual tuner bytes */
369 nxt200x_writebytes(state, 0x36, data, 4); 371 nxt200x_writebytes(state, 0x36, data, 4);
370 372
371 /* set tuner i2c address */ 373 /* set tuner i2c address */
372 buf = state->config->pll_address; 374 buf = state->config->pll_address;
373 nxt200x_writebytes(state, 0x35, &buf, 1); 375 nxt200x_writebytes(state, 0x35, &buf, 1);
374 376
375 /* write UC Opmode to begin transfer */ 377 /* write UC Opmode to begin transfer */
376 buf = 0x80; 378 buf = 0x80;
377 nxt200x_writebytes(state, 0x21, &buf, 1); 379 nxt200x_writebytes(state, 0x21, &buf, 1);
378 380
379 while (count < 20) { 381 while (count < 20) {
380 nxt200x_readbytes(state, 0x21, &buf, 1); 382 nxt200x_readbytes(state, 0x21, &buf, 1);
381 if ((buf & 0x80)== 0x00) 383 if ((buf & 0x80)== 0x00)
382 return 0; 384 return 0;
383 msleep(100); 385 msleep(100);
384 count++; 386 count++;
385 } 387 }
386 printk("nxt200x: timeout error writing tuner\n"); 388 printk("nxt2002: timeout error writing tuner\n");
387 return 0; 389 break;
390 default:
391 return -EINVAL;
392 break;
388 } 393 }
394 return 0;
389} 395}
390 396
391static void nxt200x_agc_reset(struct nxt200x_state* state) 397static void nxt200x_agc_reset(struct nxt200x_state* state)