aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
diff options
context:
space:
mode:
authorThomas Kaiser <linux-dvb AT kaiser-linux.li>2006-04-27 20:45:20 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-25 00:59:46 -0400
commitb8d4c235d50f8512bbc9d67730c24da3309b0307 (patch)
tree9af461a3b198bfd6856ab510044363b34a7d7be4 /drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
parent21c2858235a81ce4fa1862432eb0c98d8dbdee1e (diff)
V4L/DVB (3934): Support new dvb-ttusb-budget boards with stv0297
Added config switch to stv0297 to control i2c STOP during write behaviour. Update frontend init in dvb-ttusb-budget. Enable i2c STOP on other users of stv0297. Signed-off-by: Thomas Kaiser <linux-dvb AT kaiser-linux.li> Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c')
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c175
1 files changed, 175 insertions, 0 deletions
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 71581303b0ea..cf264512d36f 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -30,6 +30,7 @@
30#include "tda1004x.h" 30#include "tda1004x.h"
31#include "stv0299.h" 31#include "stv0299.h"
32#include "tda8083.h" 32#include "tda8083.h"
33#include "stv0297.h"
33#include "lnbp21.h" 34#include "lnbp21.h"
34 35
35#include <linux/dvb/frontend.h> 36#include <linux/dvb/frontend.h>
@@ -1380,6 +1381,174 @@ static u8 read_pwm(struct ttusb* ttusb)
1380} 1381}
1381 1382
1382 1383
1384static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1385{
1386 struct ttusb *ttusb = (struct ttusb *) fe->dvb->priv;
1387 u8 tuner_buf[5];
1388 struct i2c_msg tuner_msg = {.addr = 0x60,
1389 .flags = 0,
1390 .buf = tuner_buf,
1391 .len = sizeof(tuner_buf) };
1392 int tuner_frequency = 0;
1393 u8 band, cp, filter;
1394
1395 // determine charge pump
1396 tuner_frequency = params->frequency;
1397 if (tuner_frequency < 87000000) {return -EINVAL;}
1398 else if (tuner_frequency < 130000000) {cp = 3; band = 1;}
1399 else if (tuner_frequency < 160000000) {cp = 5; band = 1;}
1400 else if (tuner_frequency < 200000000) {cp = 6; band = 1;}
1401 else if (tuner_frequency < 290000000) {cp = 3; band = 2;}
1402 else if (tuner_frequency < 420000000) {cp = 5; band = 2;}
1403 else if (tuner_frequency < 480000000) {cp = 6; band = 2;}
1404 else if (tuner_frequency < 620000000) {cp = 3; band = 4;}
1405 else if (tuner_frequency < 830000000) {cp = 5; band = 4;}
1406 else if (tuner_frequency < 895000000) {cp = 7; band = 4;}
1407 else {return -EINVAL;}
1408
1409 // assume PLL filter should always be 8MHz for the moment.
1410 filter = 1;
1411
1412 // calculate divisor
1413 // (Finput + Fif)/Fref; Fif = 36125000 Hz, Fref = 62500 Hz
1414 tuner_frequency = ((params->frequency + 36125000) / 62500);
1415
1416 // setup tuner buffer
1417 tuner_buf[0] = tuner_frequency >> 8;
1418 tuner_buf[1] = tuner_frequency & 0xff;
1419 tuner_buf[2] = 0xc8;
1420 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
1421 tuner_buf[4] = 0x80;
1422
1423 if (fe->ops->i2c_gate_ctrl)
1424 fe->ops->i2c_gate_ctrl(fe, 1);
1425 if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
1426 printk("dvb-ttusb-budget: dvbc_philips_tdm1316l_pll_set Error 1\n");
1427 return -EIO;
1428 }
1429
1430 msleep(50);
1431
1432 if (fe->ops->i2c_gate_ctrl)
1433 fe->ops->i2c_gate_ctrl(fe, 1);
1434 if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
1435 printk("dvb-ttusb-budget: dvbc_philips_tdm1316l_pll_set Error 2\n");
1436 return -EIO;
1437 }
1438
1439 msleep(1);
1440
1441 return 0;
1442}
1443
1444static u8 dvbc_philips_tdm1316l_inittab[] = {
1445 0x80, 0x21,
1446 0x80, 0x20,
1447 0x81, 0x01,
1448 0x81, 0x00,
1449 0x00, 0x09,
1450 0x01, 0x69,
1451 0x03, 0x00,
1452 0x04, 0x00,
1453 0x07, 0x00,
1454 0x08, 0x00,
1455 0x20, 0x00,
1456 0x21, 0x40,
1457 0x22, 0x00,
1458 0x23, 0x00,
1459 0x24, 0x40,
1460 0x25, 0x88,
1461 0x30, 0xff,
1462 0x31, 0x00,
1463 0x32, 0xff,
1464 0x33, 0x00,
1465 0x34, 0x50,
1466 0x35, 0x7f,
1467 0x36, 0x00,
1468 0x37, 0x20,
1469 0x38, 0x00,
1470 0x40, 0x1c,
1471 0x41, 0xff,
1472 0x42, 0x29,
1473 0x43, 0x20,
1474 0x44, 0xff,
1475 0x45, 0x00,
1476 0x46, 0x00,
1477 0x49, 0x04,
1478 0x4a, 0xff,
1479 0x4b, 0x7f,
1480 0x52, 0x30,
1481 0x55, 0xae,
1482 0x56, 0x47,
1483 0x57, 0xe1,
1484 0x58, 0x3a,
1485 0x5a, 0x1e,
1486 0x5b, 0x34,
1487 0x60, 0x00,
1488 0x63, 0x00,
1489 0x64, 0x00,
1490 0x65, 0x00,
1491 0x66, 0x00,
1492 0x67, 0x00,
1493 0x68, 0x00,
1494 0x69, 0x00,
1495 0x6a, 0x02,
1496 0x6b, 0x00,
1497 0x70, 0xff,
1498 0x71, 0x00,
1499 0x72, 0x00,
1500 0x73, 0x00,
1501 0x74, 0x0c,
1502 0x80, 0x00,
1503 0x81, 0x00,
1504 0x82, 0x00,
1505 0x83, 0x00,
1506 0x84, 0x04,
1507 0x85, 0x80,
1508 0x86, 0x24,
1509 0x87, 0x78,
1510 0x88, 0x00,
1511 0x89, 0x00,
1512 0x90, 0x01,
1513 0x91, 0x01,
1514 0xa0, 0x00,
1515 0xa1, 0x00,
1516 0xa2, 0x00,
1517 0xb0, 0x91,
1518 0xb1, 0x0b,
1519 0xc0, 0x4b,
1520 0xc1, 0x00,
1521 0xc2, 0x00,
1522 0xd0, 0x00,
1523 0xd1, 0x00,
1524 0xd2, 0x00,
1525 0xd3, 0x00,
1526 0xd4, 0x00,
1527 0xd5, 0x00,
1528 0xde, 0x00,
1529 0xdf, 0x00,
1530 0x61, 0x38,
1531 0x62, 0x0a,
1532 0x53, 0x13,
1533 0x59, 0x08,
1534 0x55, 0x00,
1535 0x56, 0x40,
1536 0x57, 0x08,
1537 0x58, 0x3d,
1538 0x88, 0x10,
1539 0xa0, 0x00,
1540 0xa0, 0x00,
1541 0xa0, 0x00,
1542 0xa0, 0x04,
1543 0xff, 0xff,
1544};
1545
1546static struct stv0297_config dvbc_philips_tdm1316l_config = {
1547 .demod_address = 0x1c,
1548 .inittab = dvbc_philips_tdm1316l_inittab,
1549 .invert = 0,
1550};
1551
1383static void frontend_init(struct ttusb* ttusb) 1552static void frontend_init(struct ttusb* ttusb)
1384{ 1553{
1385 switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) { 1554 switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) {
@@ -1413,6 +1582,12 @@ static void frontend_init(struct ttusb* ttusb)
1413 ttusb->fe->ops->tuner_ops.set_params = alps_tdbe2_tuner_set_params; 1582 ttusb->fe->ops->tuner_ops.set_params = alps_tdbe2_tuner_set_params;
1414 break; 1583 break;
1415 } 1584 }
1585
1586 ttusb->fe = stv0297_attach(&dvbc_philips_tdm1316l_config, &ttusb->i2c_adap);
1587 if (ttusb->fe != NULL) {
1588 ttusb->fe->ops->tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
1589 break;
1590 }
1416 break; 1591 break;
1417 1592
1418 case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??)) 1593 case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??))