aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor M. Liplianin <liplianin@me.by>2009-12-14 18:24:56 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-02-26 13:10:24 -0500
commitcd79d33e168dba0d7de32c5bf010e20cff184b2a (patch)
treea9e40f6281e62f27fc7d36e885416b5fef696c46
parentd41592a2a2b9a27425ade3fc2c8526e9e997acd6 (diff)
V4L/DVB (13818): Add Prof 7500 DVB-S2 USB card
The card based on stv0903 demod, stb6100 tuner. Signed-off-by: Igor M. Liplianin <liplianin@me.by> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.c94
-rw-r--r--drivers/media/dvb/frontends/stv0900.h2
-rw-r--r--drivers/media/dvb/frontends/stv0900_core.c87
-rw-r--r--drivers/media/dvb/frontends/stv0900_priv.h11
-rw-r--r--drivers/media/dvb/frontends/stv0900_reg.h6
-rw-r--r--drivers/media/dvb/frontends/stv0900_sw.c44
6 files changed, 226 insertions, 18 deletions
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
index 64132c0cf80d..83a35524a82a 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -1,6 +1,7 @@
1/* DVB USB framework compliant Linux driver for the 1/* DVB USB framework compliant Linux driver for the
2* DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, 2* DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
3* TeVii S600, S630, S650 Cards 3* TeVii S600, S630, S650,
4* Prof 1100, 7500 Cards
4* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by) 5* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
5* 6*
6* This program is free software; you can redistribute it and/or modify it 7* This program is free software; you can redistribute it and/or modify it
@@ -469,6 +470,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
469 int num) 470 int num)
470{ 471{
471 struct dvb_usb_device *d = i2c_get_adapdata(adap); 472 struct dvb_usb_device *d = i2c_get_adapdata(adap);
473 struct usb_device *udev = d->udev;
472 int ret = 0; 474 int ret = 0;
473 int len, i, j; 475 int len, i, j;
474 476
@@ -488,8 +490,13 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
488 } 490 }
489 case (DW2102_VOLTAGE_CTRL): { 491 case (DW2102_VOLTAGE_CTRL): {
490 u8 obuf[2]; 492 u8 obuf[2];
493
494 obuf[0] = 1;
495 obuf[1] = msg[j].buf[1];/* off-on */
496 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
497 obuf, 2, DW210X_WRITE_MSG);
491 obuf[0] = 3; 498 obuf[0] = 3;
492 obuf[1] = msg[j].buf[0]; 499 obuf[1] = msg[j].buf[0];/* 13v-18v */
493 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0, 500 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
494 obuf, 2, DW210X_WRITE_MSG); 501 obuf, 2, DW210X_WRITE_MSG);
495 break; 502 break;
@@ -527,6 +534,17 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
527 i += 16; 534 i += 16;
528 len -= 16; 535 len -= 16;
529 } while (len > 0); 536 } while (len > 0);
537 } else if ((udev->descriptor.idProduct == 0x7500)
538 && (j < (num - 1))) {
539 /* write register addr before read */
540 u8 obuf[msg[j].len + 2];
541 obuf[0] = msg[j + 1].len;
542 obuf[1] = (msg[j].addr << 1);
543 memcpy(obuf + 2, msg[j].buf, msg[j].len);
544 ret = dw210x_op_rw(d->udev, 0x92, 0, 0,
545 obuf, msg[j].len + 2,
546 DW210X_WRITE_MSG);
547 break;
530 } else { 548 } else {
531 /* write registers */ 549 /* write registers */
532 u8 obuf[msg[j].len + 2]; 550 u8 obuf[msg[j].len + 2];
@@ -651,18 +669,25 @@ static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
651 669
652static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 670static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
653{ 671{
654 static u8 command_13v[1] = {0x00}; 672 static u8 command_13v[] = {0x00, 0x01};
655 static u8 command_18v[1] = {0x01}; 673 static u8 command_18v[] = {0x01, 0x01};
656 struct i2c_msg msg[] = { 674 static u8 command_off[] = {0x00, 0x00};
657 {.addr = DW2102_VOLTAGE_CTRL, .flags = 0, 675 struct i2c_msg msg = {
658 .buf = command_13v, .len = 1}, 676 .addr = DW2102_VOLTAGE_CTRL,
677 .flags = 0,
678 .buf = command_off,
679 .len = 2,
659 }; 680 };
660 681
661 struct dvb_usb_adapter *udev_adap = 682 struct dvb_usb_adapter *udev_adap =
662 (struct dvb_usb_adapter *)(fe->dvb->priv); 683 (struct dvb_usb_adapter *)(fe->dvb->priv);
663 if (voltage == SEC_VOLTAGE_18) 684 if (voltage == SEC_VOLTAGE_18)
664 msg[0].buf = command_18v; 685 msg.buf = command_18v;
665 i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1); 686 else if (voltage == SEC_VOLTAGE_13)
687 msg.buf = command_13v;
688
689 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
690
666 return 0; 691 return 0;
667} 692}
668 693
@@ -735,6 +760,18 @@ static struct stv6110_config dw2104_stv6110_config = {
735 .clk_div = 1, 760 .clk_div = 1,
736}; 761};
737 762
763static struct stv0900_config prof_7500_stv0900_config = {
764 .demod_address = 0x6a,
765 .demod_mode = 0,
766 .xtal = 27000000,
767 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
768 .diseqc_mode = 2,/* 2/3 PWM */
769 .tun1_maddress = 0,/* 0x60 */
770 .tun1_adc = 0,/* 2 Vpp */
771 .path1_mode = 3,
772 .tun1_type = 3,
773};
774
738static int dw2104_frontend_attach(struct dvb_usb_adapter *d) 775static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
739{ 776{
740 struct dvb_tuner_ops *tuner_ops = NULL; 777 struct dvb_tuner_ops *tuner_ops = NULL;
@@ -882,6 +919,19 @@ static int s6x0_frontend_attach(struct dvb_usb_adapter *d)
882 return -EIO; 919 return -EIO;
883} 920}
884 921
922static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
923{
924 d->fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
925 &d->dev->i2c_adap, 0);
926 if (d->fe == NULL)
927 return -EIO;
928 d->fe->ops.set_voltage = dw210x_set_voltage;
929
930 info("Attached STV0900+STB6100A!\n");
931
932 return 0;
933}
934
885static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) 935static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
886{ 936{
887 dvb_attach(dvb_pll_attach, adap->fe, 0x60, 937 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
@@ -1073,6 +1123,7 @@ static struct usb_device_id dw2102_table[] = {
1073 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)}, 1123 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
1074 {USB_DEVICE(0x3011, USB_PID_PROF_1100)}, 1124 {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
1075 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, 1125 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
1126 {USB_DEVICE(0x3034, 0x7500)},
1076 { } 1127 { }
1077}; 1128};
1078 1129
@@ -1387,9 +1438,30 @@ static struct dvb_usb_device_properties s6x0_properties = {
1387 } 1438 }
1388}; 1439};
1389 1440
1441struct dvb_usb_device_properties *p7500;
1442static struct dvb_usb_device_description d7500 = {
1443 "Prof 7500 USB DVB-S2",
1444 {&dw2102_table[9], NULL},
1445 {NULL},
1446};
1447
1390static int dw2102_probe(struct usb_interface *intf, 1448static int dw2102_probe(struct usb_interface *intf,
1391 const struct usb_device_id *id) 1449 const struct usb_device_id *id)
1392{ 1450{
1451
1452 p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
1453 if (!p7500)
1454 return -ENOMEM;
1455 /* copy default structure */
1456 memcpy(p7500, &s6x0_properties,
1457 sizeof(struct dvb_usb_device_properties));
1458 /* fill only different fields */
1459 p7500->firmware = "dvb-usb-p7500.fw";
1460 p7500->devices[0] = d7500;
1461 p7500->rc_key_map = tbs_rc_keys;
1462 p7500->rc_key_map_size = ARRAY_SIZE(tbs_rc_keys);
1463 p7500->adapter->frontend_attach = prof_7500_frontend_attach;
1464
1393 if (0 == dvb_usb_device_init(intf, &dw2102_properties, 1465 if (0 == dvb_usb_device_init(intf, &dw2102_properties,
1394 THIS_MODULE, NULL, adapter_nr) || 1466 THIS_MODULE, NULL, adapter_nr) ||
1395 0 == dvb_usb_device_init(intf, &dw2104_properties, 1467 0 == dvb_usb_device_init(intf, &dw2104_properties,
@@ -1397,6 +1469,8 @@ static int dw2102_probe(struct usb_interface *intf,
1397 0 == dvb_usb_device_init(intf, &dw3101_properties, 1469 0 == dvb_usb_device_init(intf, &dw3101_properties,
1398 THIS_MODULE, NULL, adapter_nr) || 1470 THIS_MODULE, NULL, adapter_nr) ||
1399 0 == dvb_usb_device_init(intf, &s6x0_properties, 1471 0 == dvb_usb_device_init(intf, &s6x0_properties,
1472 THIS_MODULE, NULL, adapter_nr) ||
1473 0 == dvb_usb_device_init(intf, p7500,
1400 THIS_MODULE, NULL, adapter_nr)) 1474 THIS_MODULE, NULL, adapter_nr))
1401 return 0; 1475 return 0;
1402 1476
@@ -1431,6 +1505,6 @@ MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
1431MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," 1505MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1432 " DVB-C 3101 USB2.0," 1506 " DVB-C 3101 USB2.0,"
1433 " TeVii S600, S630, S650, S660 USB2.0," 1507 " TeVii S600, S630, S650, S660 USB2.0,"
1434 " Prof 1100 USB2.0 devices"); 1508 " Prof 1100, 7500 USB2.0 devices");
1435MODULE_VERSION("0.1"); 1509MODULE_VERSION("0.1");
1436MODULE_LICENSE("GPL"); 1510MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/stv0900.h b/drivers/media/dvb/frontends/stv0900.h
index 29c3fa85c227..e3e35d1ce838 100644
--- a/drivers/media/dvb/frontends/stv0900.h
+++ b/drivers/media/dvb/frontends/stv0900.h
@@ -49,6 +49,8 @@ struct stv0900_config {
49 u8 tun2_maddress; 49 u8 tun2_maddress;
50 u8 tun1_adc;/* 1 for stv6110, 2 for stb6100 */ 50 u8 tun1_adc;/* 1 for stv6110, 2 for stb6100 */
51 u8 tun2_adc; 51 u8 tun2_adc;
52 u8 tun1_type;/* for now 3 for stb6100 auto, else - software */
53 u8 tun2_type;
52 /* Set device param to start dma */ 54 /* Set device param to start dma */
53 int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); 55 int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured);
54}; 56};
diff --git a/drivers/media/dvb/frontends/stv0900_core.c b/drivers/media/dvb/frontends/stv0900_core.c
index 8762c86044a5..115dc01c2234 100644
--- a/drivers/media/dvb/frontends/stv0900_core.c
+++ b/drivers/media/dvb/frontends/stv0900_core.c
@@ -567,6 +567,46 @@ void stv0900_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)
567 } 567 }
568} 568}
569 569
570u32 stv0900_get_freq_auto(struct stv0900_internal *intp, int demod)
571{
572 u32 freq, round;
573 /* Formulat :
574 Tuner_Frequency(MHz) = Regs / 64
575 Tuner_granularity(MHz) = Regs / 2048
576 real_Tuner_Frequency = Tuner_Frequency(MHz) - Tuner_granularity(MHz)
577 */
578 freq = (stv0900_get_bits(intp, TUN_RFFREQ2) << 10) +
579 (stv0900_get_bits(intp, TUN_RFFREQ1) << 2) +
580 stv0900_get_bits(intp, TUN_RFFREQ0);
581
582 freq = (freq * 1000) / 64;
583
584 round = (stv0900_get_bits(intp, TUN_RFRESTE1) >> 2) +
585 stv0900_get_bits(intp, TUN_RFRESTE0);
586
587 round = (round * 1000) / 2048;
588
589 return freq + round;
590}
591
592void stv0900_set_tuner_auto(struct stv0900_internal *intp, u32 Frequency,
593 u32 Bandwidth, int demod)
594{
595 u32 tunerFrequency;
596 /* Formulat:
597 Tuner_frequency_reg= Frequency(MHz)*64
598 */
599 tunerFrequency = (Frequency * 64) / 1000;
600
601 stv0900_write_bits(intp, TUN_RFFREQ2, (tunerFrequency >> 10));
602 stv0900_write_bits(intp, TUN_RFFREQ1, (tunerFrequency >> 2) & 0xff);
603 stv0900_write_bits(intp, TUN_RFFREQ0, (tunerFrequency & 0x03));
604 /* Low Pass Filter = BW /2 (MHz)*/
605 stv0900_write_bits(intp, TUN_BW, Bandwidth / 2000000);
606 /* Tuner Write trig */
607 stv0900_write_reg(intp, TNRLD, 1);
608}
609
570static s32 stv0900_get_rf_level(struct stv0900_internal *intp, 610static s32 stv0900_get_rf_level(struct stv0900_internal *intp,
571 const struct stv0900_table *lookup, 611 const struct stv0900_table *lookup,
572 enum fe_stv0900_demod_num demod) 612 enum fe_stv0900_demod_num demod)
@@ -1329,7 +1369,6 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
1329 enum fe_stv0900_error error = STV0900_NO_ERROR; 1369 enum fe_stv0900_error error = STV0900_NO_ERROR;
1330 enum fe_stv0900_error demodError = STV0900_NO_ERROR; 1370 enum fe_stv0900_error demodError = STV0900_NO_ERROR;
1331 struct stv0900_internal *intp = NULL; 1371 struct stv0900_internal *intp = NULL;
1332
1333 int selosci, i; 1372 int selosci, i;
1334 1373
1335 struct stv0900_inode *temp_int = find_inode(state->i2c_adap, 1374 struct stv0900_inode *temp_int = find_inode(state->i2c_adap,
@@ -1404,6 +1443,27 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
1404 stv0900_write_bits(intp, F0900_P1_RST_HWARE, 0); 1443 stv0900_write_bits(intp, F0900_P1_RST_HWARE, 0);
1405 } 1444 }
1406 1445
1446 intp->tuner_type[0] = p_init->tuner1_type;
1447 intp->tuner_type[1] = p_init->tuner2_type;
1448 /* tuner init */
1449 switch (p_init->tuner1_type) {
1450 case 3: /*FE_AUTO_STB6100:*/
1451 stv0900_write_reg(intp, R0900_P1_TNRCFG, 0x3c);
1452 stv0900_write_reg(intp, R0900_P1_TNRCFG2, 0x86);
1453 stv0900_write_reg(intp, R0900_P1_TNRCFG3, 0x18);
1454 stv0900_write_reg(intp, R0900_P1_TNRXTAL, 27); /* 27MHz */
1455 stv0900_write_reg(intp, R0900_P1_TNRSTEPS, 0x05);
1456 stv0900_write_reg(intp, R0900_P1_TNRGAIN, 0x17);
1457 stv0900_write_reg(intp, R0900_P1_TNRADJ, 0x1f);
1458 stv0900_write_reg(intp, R0900_P1_TNRCTL2, 0x0);
1459 stv0900_write_bits(intp, F0900_P1_TUN_TYPE, 3);
1460 break;
1461 /* case FE_SW_TUNER: */
1462 default:
1463 stv0900_write_bits(intp, F0900_P1_TUN_TYPE, 6);
1464 break;
1465 }
1466
1407 stv0900_write_bits(intp, F0900_P1_TUN_MADDRESS, p_init->tun1_maddress); 1467 stv0900_write_bits(intp, F0900_P1_TUN_MADDRESS, p_init->tun1_maddress);
1408 switch (p_init->tuner1_adc) { 1468 switch (p_init->tuner1_adc) {
1409 case 1: 1469 case 1:
@@ -1413,6 +1473,27 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
1413 break; 1473 break;
1414 } 1474 }
1415 1475
1476 stv0900_write_reg(intp, R0900_P1_TNRLD, 1); /* hw tuner */
1477
1478 /* tuner init */
1479 switch (p_init->tuner2_type) {
1480 case 3: /*FE_AUTO_STB6100:*/
1481 stv0900_write_reg(intp, R0900_P2_TNRCFG, 0x3c);
1482 stv0900_write_reg(intp, R0900_P2_TNRCFG2, 0x86);
1483 stv0900_write_reg(intp, R0900_P2_TNRCFG3, 0x18);
1484 stv0900_write_reg(intp, R0900_P2_TNRXTAL, 27); /* 27MHz */
1485 stv0900_write_reg(intp, R0900_P2_TNRSTEPS, 0x05);
1486 stv0900_write_reg(intp, R0900_P2_TNRGAIN, 0x17);
1487 stv0900_write_reg(intp, R0900_P2_TNRADJ, 0x1f);
1488 stv0900_write_reg(intp, R0900_P2_TNRCTL2, 0x0);
1489 stv0900_write_bits(intp, F0900_P2_TUN_TYPE, 3);
1490 break;
1491 /* case FE_SW_TUNER: */
1492 default:
1493 stv0900_write_bits(intp, F0900_P2_TUN_TYPE, 6);
1494 break;
1495 }
1496
1416 stv0900_write_bits(intp, F0900_P2_TUN_MADDRESS, p_init->tun2_maddress); 1497 stv0900_write_bits(intp, F0900_P2_TUN_MADDRESS, p_init->tun2_maddress);
1417 switch (p_init->tuner2_adc) { 1498 switch (p_init->tuner2_adc) {
1418 case 1: 1499 case 1:
@@ -1422,6 +1503,8 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
1422 break; 1503 break;
1423 } 1504 }
1424 1505
1506 stv0900_write_reg(intp, R0900_P2_TNRLD, 1); /* hw tuner */
1507
1425 stv0900_write_bits(intp, F0900_P1_TUN_IQSWAP, p_init->tun1_iq_inv); 1508 stv0900_write_bits(intp, F0900_P1_TUN_IQSWAP, p_init->tun1_iq_inv);
1426 stv0900_write_bits(intp, F0900_P2_TUN_IQSWAP, p_init->tun2_iq_inv); 1509 stv0900_write_bits(intp, F0900_P2_TUN_IQSWAP, p_init->tun2_iq_inv);
1427 stv0900_set_mclk(intp, 135000000); 1510 stv0900_set_mclk(intp, 135000000);
@@ -1824,10 +1907,12 @@ struct dvb_frontend *stv0900_attach(const struct stv0900_config *config,
1824 init_params.tun1_maddress = config->tun1_maddress; 1907 init_params.tun1_maddress = config->tun1_maddress;
1825 init_params.tun1_iq_inv = STV0900_IQ_NORMAL; 1908 init_params.tun1_iq_inv = STV0900_IQ_NORMAL;
1826 init_params.tuner1_adc = config->tun1_adc; 1909 init_params.tuner1_adc = config->tun1_adc;
1910 init_params.tuner1_type = config->tun1_type;
1827 init_params.path2_ts_clock = config->path2_mode; 1911 init_params.path2_ts_clock = config->path2_mode;
1828 init_params.ts_config = config->ts_config_regs; 1912 init_params.ts_config = config->ts_config_regs;
1829 init_params.tun2_maddress = config->tun2_maddress; 1913 init_params.tun2_maddress = config->tun2_maddress;
1830 init_params.tuner2_adc = config->tun2_adc; 1914 init_params.tuner2_adc = config->tun2_adc;
1915 init_params.tuner2_type = config->tun2_type;
1831 init_params.tun2_iq_inv = STV0900_IQ_SWAPPED; 1916 init_params.tun2_iq_inv = STV0900_IQ_SWAPPED;
1832 1917
1833 err_stv0900 = stv0900_init_internal(&state->frontend, 1918 err_stv0900 = stv0900_init_internal(&state->frontend,
diff --git a/drivers/media/dvb/frontends/stv0900_priv.h b/drivers/media/dvb/frontends/stv0900_priv.h
index d8ba8a984abe..b62b0f0a4fef 100644
--- a/drivers/media/dvb/frontends/stv0900_priv.h
+++ b/drivers/media/dvb/frontends/stv0900_priv.h
@@ -247,6 +247,7 @@ struct stv0900_init_params{
247 247
248 u8 tun1_maddress; 248 u8 tun1_maddress;
249 int tuner1_adc; 249 int tuner1_adc;
250 int tuner1_type;
250 251
251 /* IQ from the tuner1 to the demod */ 252 /* IQ from the tuner1 to the demod */
252 enum stv0900_iq_inversion tun1_iq_inv; 253 enum stv0900_iq_inversion tun1_iq_inv;
@@ -254,6 +255,7 @@ struct stv0900_init_params{
254 255
255 u8 tun2_maddress; 256 u8 tun2_maddress;
256 int tuner2_adc; 257 int tuner2_adc;
258 int tuner2_type;
257 259
258 /* IQ from the tuner2 to the demod */ 260 /* IQ from the tuner2 to the demod */
259 enum stv0900_iq_inversion tun2_iq_inv; 261 enum stv0900_iq_inversion tun2_iq_inv;
@@ -309,6 +311,8 @@ struct stv0900_internal{
309 s32 bw[2]; 311 s32 bw[2];
310 s32 symbol_rate[2]; 312 s32 symbol_rate[2];
311 s32 srch_range[2]; 313 s32 srch_range[2];
314 /* for software/auto tuner */
315 int tuner_type[2];
312 316
313 /* algorithm for search Blind, Cold or Warm*/ 317 /* algorithm for search Blind, Cold or Warm*/
314 enum fe_stv0900_search_algo srch_algo[2]; 318 enum fe_stv0900_search_algo srch_algo[2];
@@ -394,4 +398,11 @@ extern enum
394fe_stv0900_tracking_standard stv0900_get_standard(struct dvb_frontend *fe, 398fe_stv0900_tracking_standard stv0900_get_standard(struct dvb_frontend *fe,
395 enum fe_stv0900_demod_num demod); 399 enum fe_stv0900_demod_num demod);
396 400
401extern u32
402stv0900_get_freq_auto(struct stv0900_internal *intp, int demod);
403
404extern void
405stv0900_set_tuner_auto(struct stv0900_internal *intp, u32 Frequency,
406 u32 Bandwidth, int demod);
407
397#endif 408#endif
diff --git a/drivers/media/dvb/frontends/stv0900_reg.h b/drivers/media/dvb/frontends/stv0900_reg.h
index 7b8edf192e97..731afe93a823 100644
--- a/drivers/media/dvb/frontends/stv0900_reg.h
+++ b/drivers/media/dvb/frontends/stv0900_reg.h
@@ -3174,17 +3174,21 @@ extern s32 shiftx(s32 x, int demod, s32 shift);
3174#define R0900_P1_TNRRF1 0xf4e9 3174#define R0900_P1_TNRRF1 0xf4e9
3175#define TNRRF1 REGx(R0900_P1_TNRRF1) 3175#define TNRRF1 REGx(R0900_P1_TNRRF1)
3176#define F0900_P1_TUN_RFFREQ2 0xf4e900ff 3176#define F0900_P1_TUN_RFFREQ2 0xf4e900ff
3177#define TUN_RFFREQ2 FLDx(F0900_P1_TUN_RFFREQ2)
3177 3178
3178/*P1_TNRRF0*/ 3179/*P1_TNRRF0*/
3179#define R0900_P1_TNRRF0 0xf4ea 3180#define R0900_P1_TNRRF0 0xf4ea
3180#define TNRRF0 REGx(R0900_P1_TNRRF0) 3181#define TNRRF0 REGx(R0900_P1_TNRRF0)
3181#define F0900_P1_TUN_RFFREQ1 0xf4ea00ff 3182#define F0900_P1_TUN_RFFREQ1 0xf4ea00ff
3183#define TUN_RFFREQ1 FLDx(F0900_P1_TUN_RFFREQ1)
3182 3184
3183/*P1_TNRBW*/ 3185/*P1_TNRBW*/
3184#define R0900_P1_TNRBW 0xf4eb 3186#define R0900_P1_TNRBW 0xf4eb
3185#define TNRBW REGx(R0900_P1_TNRBW) 3187#define TNRBW REGx(R0900_P1_TNRBW)
3186#define F0900_P1_TUN_RFFREQ0 0xf4eb00c0 3188#define F0900_P1_TUN_RFFREQ0 0xf4eb00c0
3189#define TUN_RFFREQ0 FLDx(F0900_P1_TUN_RFFREQ0)
3187#define F0900_P1_TUN_BW 0xf4eb003f 3190#define F0900_P1_TUN_BW 0xf4eb003f
3191#define TUN_BW FLDx(F0900_P1_TUN_BW)
3188 3192
3189/*P1_TNRADJ*/ 3193/*P1_TNRADJ*/
3190#define R0900_P1_TNRADJ 0xf4ec 3194#define R0900_P1_TNRADJ 0xf4ec
@@ -3234,11 +3238,13 @@ extern s32 shiftx(s32 x, int demod, s32 shift);
3234#define F0900_P1_TUN_I2CLOCKED 0xf4f60010 3238#define F0900_P1_TUN_I2CLOCKED 0xf4f60010
3235#define F0900_P1_TUN_PROGDONE 0xf4f6000c 3239#define F0900_P1_TUN_PROGDONE 0xf4f6000c
3236#define F0900_P1_TUN_RFRESTE1 0xf4f60003 3240#define F0900_P1_TUN_RFRESTE1 0xf4f60003
3241#define TUN_RFRESTE1 FLDx(F0900_P1_TUN_RFRESTE1)
3237 3242
3238/*P1_TNRRESTE*/ 3243/*P1_TNRRESTE*/
3239#define R0900_P1_TNRRESTE 0xf4f7 3244#define R0900_P1_TNRRESTE 0xf4f7
3240#define TNRRESTE REGx(R0900_P1_TNRRESTE) 3245#define TNRRESTE REGx(R0900_P1_TNRRESTE)
3241#define F0900_P1_TUN_RFRESTE0 0xf4f700ff 3246#define F0900_P1_TUN_RFRESTE0 0xf4f700ff
3247#define TUN_RFRESTE0 FLDx(F0900_P1_TUN_RFRESTE0)
3242 3248
3243/*P1_SMAPCOEF7*/ 3249/*P1_SMAPCOEF7*/
3244#define R0900_P1_SMAPCOEF7 0xf500 3250#define R0900_P1_SMAPCOEF7 0xf500
diff --git a/drivers/media/dvb/frontends/stv0900_sw.c b/drivers/media/dvb/frontends/stv0900_sw.c
index b8da87fa637f..5161c2884426 100644
--- a/drivers/media/dvb/frontends/stv0900_sw.c
+++ b/drivers/media/dvb/frontends/stv0900_sw.c
@@ -606,7 +606,12 @@ static int stv0900_get_demod_cold_lock(struct dvb_frontend *fe,
606 tuner_freq -= (current_step * currier_step); 606 tuner_freq -= (current_step * currier_step);
607 607
608 if (intp->chip_id <= 0x20) { 608 if (intp->chip_id <= 0x20) {
609 stv0900_set_tuner(fe, tuner_freq, intp->bw[d]); 609 if (intp->tuner_type[d] == 3)
610 stv0900_set_tuner_auto(intp, tuner_freq,
611 intp->bw[d], demod);
612 else
613 stv0900_set_tuner(fe, tuner_freq, intp->bw[d]);
614
610 stv0900_write_reg(intp, DMDISTATE, 0x1c); 615 stv0900_write_reg(intp, DMDISTATE, 0x1c);
611 stv0900_write_reg(intp, CFRINIT1, 0); 616 stv0900_write_reg(intp, CFRINIT1, 0);
612 stv0900_write_reg(intp, CFRINIT0, 0); 617 stv0900_write_reg(intp, CFRINIT0, 0);
@@ -976,8 +981,16 @@ static void stv0900_track_optimization(struct dvb_frontend *fe)
976 intp->rolloff) + 10000000; 981 intp->rolloff) + 10000000;
977 982
978 if ((intp->chip_id >= 0x20) || (blind_tun_sw == 1)) { 983 if ((intp->chip_id >= 0x20) || (blind_tun_sw == 1)) {
979 if (intp->srch_algo[demod] != STV0900_WARM_START) 984 if (intp->srch_algo[demod] != STV0900_WARM_START) {
980 stv0900_set_bandwidth(fe, intp->bw[demod]); 985 if (intp->tuner_type[demod] == 3)
986 stv0900_set_tuner_auto(intp,
987 intp->freq[demod],
988 intp->bw[demod],
989 demod);
990 else
991 stv0900_set_bandwidth(fe,
992 intp->bw[demod]);
993 }
981 } 994 }
982 995
983 if ((intp->srch_algo[demod] == STV0900_BLIND_SEARCH) || 996 if ((intp->srch_algo[demod] == STV0900_BLIND_SEARCH) ||
@@ -1202,7 +1215,11 @@ fe_stv0900_signal_type stv0900_get_signal_params(struct dvb_frontend *fe)
1202 } 1215 }
1203 1216
1204 result->standard = stv0900_get_standard(fe, d); 1217 result->standard = stv0900_get_standard(fe, d);
1205 result->frequency = stv0900_get_tuner_freq(fe); 1218 if (intp->tuner_type[demod] == 3)
1219 result->frequency = stv0900_get_freq_auto(intp, d);
1220 else
1221 result->frequency = stv0900_get_tuner_freq(fe);
1222
1206 offsetFreq = stv0900_get_carr_freq(intp, intp->mclk, d) / 1000; 1223 offsetFreq = stv0900_get_carr_freq(intp, intp->mclk, d) / 1000;
1207 result->frequency += offsetFreq; 1224 result->frequency += offsetFreq;
1208 result->symbol_rate = stv0900_get_symbol_rate(intp, intp->mclk, d); 1225 result->symbol_rate = stv0900_get_symbol_rate(intp, intp->mclk, d);
@@ -1239,7 +1256,11 @@ fe_stv0900_signal_type stv0900_get_signal_params(struct dvb_frontend *fe)
1239 if ((intp->srch_algo[d] == STV0900_BLIND_SEARCH) || 1256 if ((intp->srch_algo[d] == STV0900_BLIND_SEARCH) ||
1240 (intp->symbol_rate[d] < 10000000)) { 1257 (intp->symbol_rate[d] < 10000000)) {
1241 offsetFreq = result->frequency - intp->freq[d]; 1258 offsetFreq = result->frequency - intp->freq[d];
1242 intp->freq[d] = stv0900_get_tuner_freq(fe); 1259 if (intp->tuner_type[demod] == 3)
1260 intp->freq[d] = stv0900_get_freq_auto(intp, d);
1261 else
1262 intp->freq[d] = stv0900_get_tuner_freq(fe);
1263
1243 if (ABS(offsetFreq) <= ((intp->srch_range[d] / 2000) + 500)) 1264 if (ABS(offsetFreq) <= ((intp->srch_range[d] / 2000) + 500))
1244 range = STV0900_RANGEOK; 1265 range = STV0900_RANGEOK;
1245 else if (ABS(offsetFreq) <= 1266 else if (ABS(offsetFreq) <=
@@ -1481,7 +1502,12 @@ static u32 stv0900_search_srate_coarse(struct dvb_frontend *fe)
1481 else 1502 else
1482 tuner_freq -= (current_step * currier_step); 1503 tuner_freq -= (current_step * currier_step);
1483 1504
1484 stv0900_set_tuner(fe, tuner_freq, intp->bw[demod]); 1505 if (intp->tuner_type[demod] == 3)
1506 stv0900_set_tuner_auto(intp, tuner_freq,
1507 intp->bw[demod], demod);
1508 else
1509 stv0900_set_tuner(fe, tuner_freq,
1510 intp->bw[demod]);
1485 } 1511 }
1486 } 1512 }
1487 1513
@@ -1875,7 +1901,11 @@ enum fe_stv0900_signal_type stv0900_algo(struct dvb_frontend *fe)
1875 1901
1876 } 1902 }
1877 1903
1878 stv0900_set_tuner(fe, intp->freq[demod], intp->bw[demod]); 1904 if (intp->tuner_type[demod] == 3)
1905 stv0900_set_tuner_auto(intp, intp->freq[demod],
1906 intp->bw[demod], demod);
1907 else
1908 stv0900_set_tuner(fe, intp->freq[demod], intp->bw[demod]);
1879 1909
1880 agc1_power = MAKEWORD(stv0900_get_bits(intp, AGCIQ_VALUE1), 1910 agc1_power = MAKEWORD(stv0900_get_bits(intp, AGCIQ_VALUE1),
1881 stv0900_get_bits(intp, AGCIQ_VALUE0)); 1911 stv0900_get_bits(intp, AGCIQ_VALUE0));