diff options
Diffstat (limited to 'drivers/media/dvb/frontends/stv090x.c')
-rw-r--r-- | drivers/media/dvb/frontends/stv090x.c | 242 |
1 files changed, 144 insertions, 98 deletions
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index 488bdfb34fb..48edd542242 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c | |||
@@ -825,7 +825,7 @@ static int stv090x_set_min_srate(struct stv090x_state *state, u32 clk, u32 srate | |||
825 | sym /= (state->mclk >> 7); | 825 | sym /= (state->mclk >> 7); |
826 | } | 826 | } |
827 | 827 | ||
828 | if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym >> 8) & 0xff)) < 0) /* MSB */ | 828 | if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym >> 8) & 0x7f)) < 0) /* MSB */ |
829 | goto err; | 829 | goto err; |
830 | if (STV090x_WRITE_DEMOD(state, SFRLOW0, (sym & 0xff)) < 0) /* LSB */ | 830 | if (STV090x_WRITE_DEMOD(state, SFRLOW0, (sym & 0xff)) < 0) /* LSB */ |
831 | goto err; | 831 | goto err; |
@@ -1238,6 +1238,8 @@ static int stv090x_delivery_search(struct stv090x_state *state) | |||
1238 | goto err; | 1238 | goto err; |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | if (stv090x_set_vit_thtracq(state) < 0) | ||
1242 | goto err; | ||
1241 | break; | 1243 | break; |
1242 | 1244 | ||
1243 | case STV090x_SEARCH_AUTO: | 1245 | case STV090x_SEARCH_AUTO: |
@@ -1278,17 +1280,8 @@ static int stv090x_delivery_search(struct stv090x_state *state) | |||
1278 | goto err; | 1280 | goto err; |
1279 | } | 1281 | } |
1280 | 1282 | ||
1281 | if (state->srate >= 2000000) { | 1283 | if (stv090x_set_vit_thacq(state) < 0) |
1282 | /* Srate >= 2MSPS, Viterbi threshold to acquire */ | 1284 | goto err; |
1283 | if (stv090x_set_vit_thacq(state) < 0) | ||
1284 | goto err; | ||
1285 | } else { | ||
1286 | /* Srate < 2MSPS, Reset Viterbi thresholdto track | ||
1287 | * and then re-acquire | ||
1288 | */ | ||
1289 | if (stv090x_set_vit_thtracq(state) < 0) | ||
1290 | goto err; | ||
1291 | } | ||
1292 | 1285 | ||
1293 | if (stv090x_set_viterbi(state) < 0) | 1286 | if (stv090x_set_viterbi(state) < 0) |
1294 | goto err; | 1287 | goto err; |
@@ -1317,7 +1310,7 @@ static int stv090x_start_search(struct stv090x_state *state) | |||
1317 | goto err; | 1310 | goto err; |
1318 | if (STV090x_WRITE_DEMOD(state, CFRUP1, 0x0f) < 0) | 1311 | if (STV090x_WRITE_DEMOD(state, CFRUP1, 0x0f) < 0) |
1319 | goto err; | 1312 | goto err; |
1320 | if (STV090x_WRITE_DEMOD(state, CFRUP1, 0xff) < 0) | 1313 | if (STV090x_WRITE_DEMOD(state, CFRUP0, 0xff) < 0) |
1321 | goto err; | 1314 | goto err; |
1322 | if (STV090x_WRITE_DEMOD(state, CFRLOW1, 0xf0) < 0) | 1315 | if (STV090x_WRITE_DEMOD(state, CFRLOW1, 0xf0) < 0) |
1323 | goto err; | 1316 | goto err; |
@@ -1371,7 +1364,7 @@ static int stv090x_start_search(struct stv090x_state *state) | |||
1371 | 1364 | ||
1372 | if (STV090x_WRITE_DEMOD(state, CFRUP1, MSB(freq)) < 0) | 1365 | if (STV090x_WRITE_DEMOD(state, CFRUP1, MSB(freq)) < 0) |
1373 | goto err; | 1366 | goto err; |
1374 | if (STV090x_WRITE_DEMOD(state, CFRUP1, LSB(freq)) < 0) | 1367 | if (STV090x_WRITE_DEMOD(state, CFRUP0, LSB(freq)) < 0) |
1375 | goto err; | 1368 | goto err; |
1376 | 1369 | ||
1377 | freq *= -1; | 1370 | freq *= -1; |
@@ -1422,6 +1415,9 @@ static int stv090x_start_search(struct stv090x_state *state) | |||
1422 | if (STV090x_WRITE_DEMOD(state, DMDCFG2, reg) < 0) | 1415 | if (STV090x_WRITE_DEMOD(state, DMDCFG2, reg) < 0) |
1423 | goto err; | 1416 | goto err; |
1424 | 1417 | ||
1418 | if (STV090x_WRITE_DEMOD(state, RTC, 0x88) < 0) | ||
1419 | goto err; | ||
1420 | |||
1425 | if (state->dev_ver >= 0x20) { | 1421 | if (state->dev_ver >= 0x20) { |
1426 | /*Frequency offset detector setting*/ | 1422 | /*Frequency offset detector setting*/ |
1427 | if (state->srate < 2000000) { | 1423 | if (state->srate < 2000000) { |
@@ -1430,20 +1426,22 @@ static int stv090x_start_search(struct stv090x_state *state) | |||
1430 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x39) < 0) | 1426 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x39) < 0) |
1431 | goto err; | 1427 | goto err; |
1432 | } else { | 1428 | } else { |
1433 | /* Cut 2 */ | 1429 | /* Cut 3 */ |
1434 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x89) < 0) | 1430 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x89) < 0) |
1435 | goto err; | 1431 | goto err; |
1436 | } | 1432 | } |
1437 | if (STV090x_WRITE_DEMOD(state, CARHDR, 0x40) < 0) | 1433 | if (STV090x_WRITE_DEMOD(state, CARHDR, 0x40) < 0) |
1438 | goto err; | 1434 | goto err; |
1439 | } | 1435 | } else if (state->srate < 10000000) { |
1440 | |||
1441 | if (state->srate < 10000000) { | ||
1442 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4c) < 0) | 1436 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4c) < 0) |
1443 | goto err; | 1437 | goto err; |
1438 | if (STV090x_WRITE_DEMOD(state, CARHDR, 0x20) < 0) | ||
1439 | goto err; | ||
1444 | } else { | 1440 | } else { |
1445 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4b) < 0) | 1441 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x4b) < 0) |
1446 | goto err; | 1442 | goto err; |
1443 | if (STV090x_WRITE_DEMOD(state, CARHDR, 0x20) < 0) | ||
1444 | goto err; | ||
1447 | } | 1445 | } |
1448 | } else { | 1446 | } else { |
1449 | if (state->srate < 10000000) { | 1447 | if (state->srate < 10000000) { |
@@ -1485,14 +1483,14 @@ err: | |||
1485 | 1483 | ||
1486 | static int stv090x_get_agc2_min_level(struct stv090x_state *state) | 1484 | static int stv090x_get_agc2_min_level(struct stv090x_state *state) |
1487 | { | 1485 | { |
1488 | u32 agc2_min = 0, agc2 = 0, freq_init, freq_step, reg; | 1486 | u32 agc2_min = 0xffff, agc2 = 0, freq_init, freq_step, reg; |
1489 | s32 i, j, steps, dir; | 1487 | s32 i, j, steps, dir; |
1490 | 1488 | ||
1491 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0) | 1489 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0) |
1492 | goto err; | 1490 | goto err; |
1493 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); | 1491 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); |
1494 | STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1); | 1492 | STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 0); |
1495 | STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 1); | 1493 | STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0); |
1496 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) | 1494 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) |
1497 | goto err; | 1495 | goto err; |
1498 | 1496 | ||
@@ -1509,10 +1507,8 @@ static int stv090x_get_agc2_min_level(struct stv090x_state *state) | |||
1509 | if (stv090x_set_srate(state, 1000000) < 0) | 1507 | if (stv090x_set_srate(state, 1000000) < 0) |
1510 | goto err; | 1508 | goto err; |
1511 | 1509 | ||
1512 | steps = -1 + state->search_range / 1000000; | 1510 | steps = state->search_range / 1000000; |
1513 | steps /= 2; | 1511 | if (steps <= 0) |
1514 | steps = (2 * steps) + 1; | ||
1515 | if (steps < 0) | ||
1516 | steps = 1; | 1512 | steps = 1; |
1517 | 1513 | ||
1518 | dir = 1; | 1514 | dir = 1; |
@@ -1525,7 +1521,7 @@ static int stv090x_get_agc2_min_level(struct stv090x_state *state) | |||
1525 | else | 1521 | else |
1526 | freq_init = freq_init - (freq_step * i); | 1522 | freq_init = freq_init - (freq_step * i); |
1527 | 1523 | ||
1528 | dir = -1; | 1524 | dir *= -1; |
1529 | 1525 | ||
1530 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5c) < 0) /* Demod RESET */ | 1526 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5c) < 0) /* Demod RESET */ |
1531 | goto err; | 1527 | goto err; |
@@ -1536,13 +1532,14 @@ static int stv090x_get_agc2_min_level(struct stv090x_state *state) | |||
1536 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58) < 0) /* Demod RESET */ | 1532 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58) < 0) /* Demod RESET */ |
1537 | goto err; | 1533 | goto err; |
1538 | msleep(10); | 1534 | msleep(10); |
1535 | |||
1536 | agc2 = 0; | ||
1539 | for (j = 0; j < 10; j++) { | 1537 | for (j = 0; j < 10; j++) { |
1540 | agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8; | 1538 | agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | |
1541 | agc2 |= STV090x_READ_DEMOD(state, AGC2I0); | 1539 | STV090x_READ_DEMOD(state, AGC2I0); |
1542 | } | 1540 | } |
1543 | agc2 /= 10; | 1541 | agc2 /= 10; |
1544 | agc2_min = 0xffff; | 1542 | if (agc2 < agc2_min) |
1545 | if (agc2 < 0xffff) | ||
1546 | agc2_min = agc2; | 1543 | agc2_min = agc2; |
1547 | } | 1544 | } |
1548 | 1545 | ||
@@ -1584,6 +1581,12 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) | |||
1584 | int tmg_lock = 0, i; | 1581 | int tmg_lock = 0, i; |
1585 | s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq; | 1582 | s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq; |
1586 | u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg; | 1583 | u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg; |
1584 | u32 agc2th; | ||
1585 | |||
1586 | if (state->dev_ver >= 0x30) | ||
1587 | agc2th = 0x2e00; | ||
1588 | else | ||
1589 | agc2th = 0x1f00; | ||
1587 | 1590 | ||
1588 | reg = STV090x_READ_DEMOD(state, DMDISTATE); | 1591 | reg = STV090x_READ_DEMOD(state, DMDISTATE); |
1589 | STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f); /* Demod RESET */ | 1592 | STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f); /* Demod RESET */ |
@@ -1591,13 +1594,15 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) | |||
1591 | goto err; | 1594 | goto err; |
1592 | if (STV090x_WRITE_DEMOD(state, TMGCFG, 0x12) < 0) | 1595 | if (STV090x_WRITE_DEMOD(state, TMGCFG, 0x12) < 0) |
1593 | goto err; | 1596 | goto err; |
1597 | if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0xc0) < 0) | ||
1598 | goto err; | ||
1594 | if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0xf0) < 0) | 1599 | if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0xf0) < 0) |
1595 | goto err; | 1600 | goto err; |
1596 | if (STV090x_WRITE_DEMOD(state, TMGTHFALL, 0xe0) < 0) | 1601 | if (STV090x_WRITE_DEMOD(state, TMGTHFALL, 0xe0) < 0) |
1597 | goto err; | 1602 | goto err; |
1598 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); | 1603 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); |
1599 | STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1); | 1604 | STV090x_SETFIELD_Px(reg, SCAN_ENABLE_FIELD, 1); |
1600 | STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 1); | 1605 | STV090x_SETFIELD_Px(reg, CFR_AUTOSCAN_FIELD, 0); |
1601 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) | 1606 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) |
1602 | goto err; | 1607 | goto err; |
1603 | 1608 | ||
@@ -1611,13 +1616,13 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) | |||
1611 | goto err; | 1616 | goto err; |
1612 | if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0) | 1617 | if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0) |
1613 | goto err; | 1618 | goto err; |
1614 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x60) < 0) | 1619 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x50) < 0) |
1615 | goto err; | 1620 | goto err; |
1616 | 1621 | ||
1617 | if (state->dev_ver >= 0x30) { | 1622 | if (state->dev_ver >= 0x30) { |
1618 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x99) < 0) | 1623 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x99) < 0) |
1619 | goto err; | 1624 | goto err; |
1620 | if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x95) < 0) | 1625 | if (STV090x_WRITE_DEMOD(state, SFRSTEP, 0x98) < 0) |
1621 | goto err; | 1626 | goto err; |
1622 | 1627 | ||
1623 | } else if (state->dev_ver >= 0x20) { | 1628 | } else if (state->dev_ver >= 0x20) { |
@@ -1652,23 +1657,31 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) | |||
1652 | while ((!tmg_lock) && (cur_step < steps)) { | 1657 | while ((!tmg_lock) && (cur_step < steps)) { |
1653 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5f) < 0) /* Demod RESET */ | 1658 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x5f) < 0) /* Demod RESET */ |
1654 | goto err; | 1659 | goto err; |
1655 | reg = STV090x_READ_DEMOD(state, DMDISTATE); | 1660 | if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) |
1656 | STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x00); /* trigger acquisition */ | 1661 | goto err; |
1657 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, reg) < 0) | 1662 | if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0) |
1663 | goto err; | ||
1664 | if (STV090x_WRITE_DEMOD(state, SFRINIT1, 0x00) < 0) | ||
1665 | goto err; | ||
1666 | if (STV090x_WRITE_DEMOD(state, SFRINIT0, 0x00) < 0) | ||
1667 | goto err; | ||
1668 | /* trigger acquisition */ | ||
1669 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x40) < 0) | ||
1658 | goto err; | 1670 | goto err; |
1659 | msleep(50); | 1671 | msleep(50); |
1660 | for (i = 0; i < 10; i++) { | 1672 | for (i = 0; i < 10; i++) { |
1661 | reg = STV090x_READ_DEMOD(state, DSTATUS); | 1673 | reg = STV090x_READ_DEMOD(state, DSTATUS); |
1662 | if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2) | 1674 | if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2) |
1663 | tmg_cpt++; | 1675 | tmg_cpt++; |
1664 | agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8; | 1676 | agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | |
1665 | agc2 |= STV090x_READ_DEMOD(state, AGC2I0); | 1677 | STV090x_READ_DEMOD(state, AGC2I0); |
1666 | } | 1678 | } |
1667 | agc2 /= 10; | 1679 | agc2 /= 10; |
1668 | srate_coarse = stv090x_get_srate(state, state->mclk); | 1680 | srate_coarse = stv090x_get_srate(state, state->mclk); |
1669 | cur_step++; | 1681 | cur_step++; |
1670 | dir *= -1; | 1682 | dir *= -1; |
1671 | if ((tmg_cpt >= 5) && (agc2 < 0x1f00) && (srate_coarse < 55000000) && (srate_coarse > 850000)) | 1683 | if ((tmg_cpt >= 5) && (agc2 < agc2th) && |
1684 | (srate_coarse < 50000000) && (srate_coarse > 850000)) | ||
1672 | tmg_lock = 1; | 1685 | tmg_lock = 1; |
1673 | else if (cur_step < steps) { | 1686 | else if (cur_step < steps) { |
1674 | if (dir > 0) | 1687 | if (dir > 0) |
@@ -1681,7 +1694,7 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) | |||
1681 | goto err; | 1694 | goto err; |
1682 | 1695 | ||
1683 | if (state->config->tuner_set_frequency) { | 1696 | if (state->config->tuner_set_frequency) { |
1684 | if (state->config->tuner_set_frequency(fe, state->frequency) < 0) | 1697 | if (state->config->tuner_set_frequency(fe, freq) < 0) |
1685 | goto err; | 1698 | goto err; |
1686 | } | 1699 | } |
1687 | 1700 | ||
@@ -1738,7 +1751,7 @@ static u32 stv090x_srate_srch_fine(struct stv090x_state *state) | |||
1738 | else { | 1751 | else { |
1739 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0) /* Demod RESET */ | 1752 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0) /* Demod RESET */ |
1740 | goto err; | 1753 | goto err; |
1741 | if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0x01) < 0) | 1754 | if (STV090x_WRITE_DEMOD(state, TMGCFG2, 0xc1) < 0) |
1742 | goto err; | 1755 | goto err; |
1743 | if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0x20) < 0) | 1756 | if (STV090x_WRITE_DEMOD(state, TMGTHRISE, 0x20) < 0) |
1744 | goto err; | 1757 | goto err; |
@@ -1751,6 +1764,9 @@ static u32 stv090x_srate_srch_fine(struct stv090x_state *state) | |||
1751 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) | 1764 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) |
1752 | goto err; | 1765 | goto err; |
1753 | 1766 | ||
1767 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0) | ||
1768 | goto err; | ||
1769 | |||
1754 | if (state->dev_ver >= 0x30) { | 1770 | if (state->dev_ver >= 0x30) { |
1755 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x79) < 0) | 1771 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x79) < 0) |
1756 | goto err; | 1772 | goto err; |
@@ -1856,12 +1872,12 @@ static int stv090x_get_dmdlock(struct stv090x_state *state, s32 timeout) | |||
1856 | static int stv090x_blind_search(struct stv090x_state *state) | 1872 | static int stv090x_blind_search(struct stv090x_state *state) |
1857 | { | 1873 | { |
1858 | u32 agc2, reg, srate_coarse; | 1874 | u32 agc2, reg, srate_coarse; |
1859 | s32 timeout_dmd = 500, cpt_fail, agc2_ovflw, i; | 1875 | s32 cpt_fail, agc2_ovflw, i; |
1860 | u8 k_ref, k_max, k_min; | 1876 | u8 k_ref, k_max, k_min; |
1861 | int coarse_fail, lock; | 1877 | int coarse_fail, lock; |
1862 | 1878 | ||
1863 | k_max = 120; | 1879 | k_max = 110; |
1864 | k_min = 30; | 1880 | k_min = 10; |
1865 | 1881 | ||
1866 | agc2 = stv090x_get_agc2_min_level(state); | 1882 | agc2 = stv090x_get_agc2_min_level(state); |
1867 | 1883 | ||
@@ -1900,7 +1916,8 @@ static int stv090x_blind_search(struct stv090x_state *state) | |||
1900 | srate_coarse = stv090x_srate_srch_fine(state); | 1916 | srate_coarse = stv090x_srate_srch_fine(state); |
1901 | if (srate_coarse != 0) { | 1917 | if (srate_coarse != 0) { |
1902 | stv090x_get_lock_tmg(state); | 1918 | stv090x_get_lock_tmg(state); |
1903 | lock = stv090x_get_dmdlock(state, timeout_dmd); | 1919 | lock = stv090x_get_dmdlock(state, |
1920 | state->DemodTimeout); | ||
1904 | } else { | 1921 | } else { |
1905 | lock = 0; | 1922 | lock = 0; |
1906 | } | 1923 | } |
@@ -1908,8 +1925,8 @@ static int stv090x_blind_search(struct stv090x_state *state) | |||
1908 | cpt_fail = 0; | 1925 | cpt_fail = 0; |
1909 | agc2_ovflw = 0; | 1926 | agc2_ovflw = 0; |
1910 | for (i = 0; i < 10; i++) { | 1927 | for (i = 0; i < 10; i++) { |
1911 | agc2 = STV090x_READ_DEMOD(state, AGC2I1) << 8; | 1928 | agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | |
1912 | agc2 |= STV090x_READ_DEMOD(state, AGC2I0); | 1929 | STV090x_READ_DEMOD(state, AGC2I0); |
1913 | if (agc2 >= 0xff00) | 1930 | if (agc2 >= 0xff00) |
1914 | agc2_ovflw++; | 1931 | agc2_ovflw++; |
1915 | reg = STV090x_READ_DEMOD(state, DSTATUS2); | 1932 | reg = STV090x_READ_DEMOD(state, DSTATUS2); |
@@ -1923,7 +1940,7 @@ static int stv090x_blind_search(struct stv090x_state *state) | |||
1923 | 1940 | ||
1924 | lock = 0; | 1941 | lock = 0; |
1925 | } | 1942 | } |
1926 | k_ref -= 30; | 1943 | k_ref -= 20; |
1927 | } while ((k_ref >= k_min) && (!lock) && (!coarse_fail)); | 1944 | } while ((k_ref >= k_min) && (!lock) && (!coarse_fail)); |
1928 | } | 1945 | } |
1929 | 1946 | ||
@@ -2062,7 +2079,7 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd) | |||
2062 | goto err; | 2079 | goto err; |
2063 | 2080 | ||
2064 | if (state->config->tuner_set_frequency) { | 2081 | if (state->config->tuner_set_frequency) { |
2065 | if (state->config->tuner_set_frequency(fe, state->frequency) < 0) | 2082 | if (state->config->tuner_set_frequency(fe, freq) < 0) |
2066 | goto err; | 2083 | goto err; |
2067 | } | 2084 | } |
2068 | 2085 | ||
@@ -2093,17 +2110,6 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd) | |||
2093 | goto err; | 2110 | goto err; |
2094 | 2111 | ||
2095 | STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c); | 2112 | STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c); |
2096 | if (state->delsys == STV090x_DVBS2) { | ||
2097 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); | ||
2098 | STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 0); | ||
2099 | STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0); | ||
2100 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) | ||
2101 | goto err; | ||
2102 | STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1); | ||
2103 | STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1); | ||
2104 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) | ||
2105 | goto err; | ||
2106 | } | ||
2107 | if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) | 2113 | if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) |
2108 | goto err; | 2114 | goto err; |
2109 | if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0) | 2115 | if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0) |
@@ -2425,7 +2431,7 @@ static s32 stv090x_get_car_freq(struct stv090x_state *state, u32 mclk) | |||
2425 | 2431 | ||
2426 | derot = (int_1 * int_2) + | 2432 | derot = (int_1 * int_2) + |
2427 | ((int_1 * tmp_2) >> 12) + | 2433 | ((int_1 * tmp_2) >> 12) + |
2428 | ((int_1 * tmp_1) >> 12); | 2434 | ((int_2 * tmp_1) >> 12); |
2429 | 2435 | ||
2430 | return derot; | 2436 | return derot; |
2431 | } | 2437 | } |
@@ -2732,7 +2738,7 @@ static int stv090x_optimize_track(struct stv090x_state *state) | |||
2732 | switch (state->delsys) { | 2738 | switch (state->delsys) { |
2733 | case STV090x_DVBS1: | 2739 | case STV090x_DVBS1: |
2734 | case STV090x_DSS: | 2740 | case STV090x_DSS: |
2735 | if (state->algo == STV090x_SEARCH_AUTO) { | 2741 | if (state->search_mode == STV090x_SEARCH_AUTO) { |
2736 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); | 2742 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); |
2737 | STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1); | 2743 | STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1); |
2738 | STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0); | 2744 | STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0); |
@@ -2857,6 +2863,9 @@ static int stv090x_optimize_track(struct stv090x_state *state) | |||
2857 | if (stv090x_set_srate(state, srate) < 0) | 2863 | if (stv090x_set_srate(state, srate) < 0) |
2858 | goto err; | 2864 | goto err; |
2859 | blind_tune = 1; | 2865 | blind_tune = 1; |
2866 | |||
2867 | if (stv090x_dvbs_track_crl(state) < 0) | ||
2868 | goto err; | ||
2860 | } | 2869 | } |
2861 | 2870 | ||
2862 | if (state->dev_ver >= 0x20) { | 2871 | if (state->dev_ver >= 0x20) { |
@@ -3042,7 +3051,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3042 | struct dvb_frontend *fe = &state->frontend; | 3051 | struct dvb_frontend *fe = &state->frontend; |
3043 | enum stv090x_signal_state signal_state = STV090x_NOCARRIER; | 3052 | enum stv090x_signal_state signal_state = STV090x_NOCARRIER; |
3044 | u32 reg; | 3053 | u32 reg; |
3045 | s32 timeout_dmd = 500, timeout_fec = 50, agc1_power, power_iq = 0, i; | 3054 | s32 agc1_power, power_iq = 0, i; |
3046 | int lock = 0, low_sr = 0, no_signal = 0; | 3055 | int lock = 0, low_sr = 0, no_signal = 0; |
3047 | 3056 | ||
3048 | reg = STV090x_READ_DEMOD(state, TSCFGH); | 3057 | reg = STV090x_READ_DEMOD(state, TSCFGH); |
@@ -3054,8 +3063,13 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3054 | goto err; | 3063 | goto err; |
3055 | 3064 | ||
3056 | if (state->dev_ver >= 0x20) { | 3065 | if (state->dev_ver >= 0x20) { |
3057 | if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x9e) < 0) /* cut 2.0 */ | 3066 | if (state->srate > 5000000) { |
3058 | goto err; | 3067 | if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x9e) < 0) |
3068 | goto err; | ||
3069 | } else { | ||
3070 | if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x82) < 0) | ||
3071 | goto err; | ||
3072 | } | ||
3059 | } | 3073 | } |
3060 | 3074 | ||
3061 | stv090x_get_lock_tmg(state); | 3075 | stv090x_get_lock_tmg(state); |
@@ -3175,7 +3189,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3175 | if ((agc1_power == 0) && (power_iq < STV090x_IQPOWER_THRESHOLD)) { | 3189 | if ((agc1_power == 0) && (power_iq < STV090x_IQPOWER_THRESHOLD)) { |
3176 | dprintk(FE_ERROR, 1, "No Signal: POWER_IQ=0x%02x", power_iq); | 3190 | dprintk(FE_ERROR, 1, "No Signal: POWER_IQ=0x%02x", power_iq); |
3177 | lock = 0; | 3191 | lock = 0; |
3178 | 3192 | signal_state = STV090x_NOAGC1; | |
3179 | } else { | 3193 | } else { |
3180 | reg = STV090x_READ_DEMOD(state, DEMOD); | 3194 | reg = STV090x_READ_DEMOD(state, DEMOD); |
3181 | STV090x_SETFIELD_Px(reg, SPECINV_CONTROL_FIELD, state->inversion); | 3195 | STV090x_SETFIELD_Px(reg, SPECINV_CONTROL_FIELD, state->inversion); |
@@ -3199,18 +3213,17 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3199 | } | 3213 | } |
3200 | } | 3214 | } |
3201 | 3215 | ||
3202 | /* need to check for AGC1 state */ | 3216 | if (signal_state == STV090x_NOAGC1) |
3203 | 3217 | return signal_state; | |
3204 | |||
3205 | 3218 | ||
3206 | if (state->algo == STV090x_BLIND_SEARCH) | 3219 | if (state->algo == STV090x_BLIND_SEARCH) |
3207 | lock = stv090x_blind_search(state); | 3220 | lock = stv090x_blind_search(state); |
3208 | 3221 | ||
3209 | else if (state->algo == STV090x_COLD_SEARCH) | 3222 | else if (state->algo == STV090x_COLD_SEARCH) |
3210 | lock = stv090x_get_coldlock(state, timeout_dmd); | 3223 | lock = stv090x_get_coldlock(state, state->DemodTimeout); |
3211 | 3224 | ||
3212 | else if (state->algo == STV090x_WARM_SEARCH) | 3225 | else if (state->algo == STV090x_WARM_SEARCH) |
3213 | lock = stv090x_get_dmdlock(state, timeout_dmd); | 3226 | lock = stv090x_get_dmdlock(state, state->DemodTimeout); |
3214 | 3227 | ||
3215 | if ((!lock) && (state->algo == STV090x_COLD_SEARCH)) { | 3228 | if ((!lock) && (state->algo == STV090x_COLD_SEARCH)) { |
3216 | if (!low_sr) { | 3229 | if (!low_sr) { |
@@ -3245,8 +3258,9 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3245 | goto err; | 3258 | goto err; |
3246 | } | 3259 | } |
3247 | 3260 | ||
3248 | if (stv090x_get_lock(state, timeout_fec, timeout_fec)) { | 3261 | lock = stv090x_get_lock(state, state->FecTimeout, |
3249 | lock = 1; | 3262 | state->FecTimeout); |
3263 | if (lock) { | ||
3250 | if (state->delsys == STV090x_DVBS2) { | 3264 | if (state->delsys == STV090x_DVBS2) { |
3251 | stv090x_set_s2rolloff(state); | 3265 | stv090x_set_s2rolloff(state); |
3252 | 3266 | ||
@@ -3273,7 +3287,6 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3273 | if (STV090x_WRITE_DEMOD(state, ERRCTRL2, 0xc1) < 0) | 3287 | if (STV090x_WRITE_DEMOD(state, ERRCTRL2, 0xc1) < 0) |
3274 | goto err; | 3288 | goto err; |
3275 | } else { | 3289 | } else { |
3276 | lock = 0; | ||
3277 | signal_state = STV090x_NODATA; | 3290 | signal_state = STV090x_NODATA; |
3278 | no_signal = stv090x_chk_signal(state); | 3291 | no_signal = stv090x_chk_signal(state); |
3279 | } | 3292 | } |
@@ -3296,7 +3309,13 @@ static enum dvbfe_search stv090x_search(struct dvb_frontend *fe, struct dvb_fron | |||
3296 | state->search_mode = STV090x_SEARCH_AUTO; | 3309 | state->search_mode = STV090x_SEARCH_AUTO; |
3297 | state->algo = STV090x_COLD_SEARCH; | 3310 | state->algo = STV090x_COLD_SEARCH; |
3298 | state->fec = STV090x_PRERR; | 3311 | state->fec = STV090x_PRERR; |
3299 | state->search_range = 2000000; | 3312 | if (state->srate > 10000000) { |
3313 | dprintk(FE_DEBUG, 1, "Search range: 10 MHz"); | ||
3314 | state->search_range = 10000000; | ||
3315 | } else { | ||
3316 | dprintk(FE_DEBUG, 1, "Search range: 5 MHz"); | ||
3317 | state->search_range = 5000000; | ||
3318 | } | ||
3300 | 3319 | ||
3301 | if (stv090x_algo(state) == STV090x_RANGEOK) { | 3320 | if (stv090x_algo(state) == STV090x_RANGEOK) { |
3302 | dprintk(FE_DEBUG, 1, "Search success!"); | 3321 | dprintk(FE_DEBUG, 1, "Search success!"); |
@@ -3309,7 +3328,6 @@ static enum dvbfe_search stv090x_search(struct dvb_frontend *fe, struct dvb_fron | |||
3309 | return DVBFE_ALGO_SEARCH_ERROR; | 3328 | return DVBFE_ALGO_SEARCH_ERROR; |
3310 | } | 3329 | } |
3311 | 3330 | ||
3312 | /* FIXME! */ | ||
3313 | static int stv090x_read_status(struct dvb_frontend *fe, enum fe_status *status) | 3331 | static int stv090x_read_status(struct dvb_frontend *fe, enum fe_status *status) |
3314 | { | 3332 | { |
3315 | struct stv090x_state *state = fe->demodulator_priv; | 3333 | struct stv090x_state *state = fe->demodulator_priv; |
@@ -3331,9 +3349,15 @@ static int stv090x_read_status(struct dvb_frontend *fe, enum fe_status *status) | |||
3331 | dprintk(FE_DEBUG, 1, "Delivery system: DVB-S2"); | 3349 | dprintk(FE_DEBUG, 1, "Delivery system: DVB-S2"); |
3332 | reg = STV090x_READ_DEMOD(state, DSTATUS); | 3350 | reg = STV090x_READ_DEMOD(state, DSTATUS); |
3333 | if (STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD)) { | 3351 | if (STV090x_GETFIELD_Px(reg, LOCK_DEFINITIF_FIELD)) { |
3334 | reg = STV090x_READ_DEMOD(state, TSSTATUS); | 3352 | reg = STV090x_READ_DEMOD(state, PDELSTATUS1); |
3335 | if (STV090x_GETFIELD_Px(reg, TSFIFO_LINEOK_FIELD)) { | 3353 | if (STV090x_GETFIELD_Px(reg, PKTDELIN_LOCK_FIELD)) { |
3336 | *status = FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; | 3354 | reg = STV090x_READ_DEMOD(state, TSSTATUS); |
3355 | if (STV090x_GETFIELD_Px(reg, TSFIFO_LINEOK_FIELD)) { | ||
3356 | *status = FE_HAS_CARRIER | | ||
3357 | FE_HAS_VITERBI | | ||
3358 | FE_HAS_SYNC | | ||
3359 | FE_HAS_LOCK; | ||
3360 | } | ||
3337 | } | 3361 | } |
3338 | } | 3362 | } |
3339 | break; | 3363 | break; |
@@ -3412,14 +3436,12 @@ static int stv090x_table_lookup(const struct stv090x_tab *tab, int max, int val) | |||
3412 | int res = 0; | 3436 | int res = 0; |
3413 | int min = 0, med; | 3437 | int min = 0, med; |
3414 | 3438 | ||
3415 | if (val < tab[min].read) | 3439 | if ((val >= tab[min].read && val < tab[max].read) || |
3416 | res = tab[min].real; | 3440 | (val >= tab[max].read && val < tab[min].read)) { |
3417 | else if (val >= tab[max].read) | ||
3418 | res = tab[max].real; | ||
3419 | else { | ||
3420 | while ((max - min) > 1) { | 3441 | while ((max - min) > 1) { |
3421 | med = (max + min) / 2; | 3442 | med = (max + min) / 2; |
3422 | if (val >= tab[min].read && val < tab[med].read) | 3443 | if ((val >= tab[min].read && val < tab[med].read) || |
3444 | (val >= tab[med].read && val < tab[min].read)) | ||
3423 | max = med; | 3445 | max = med; |
3424 | else | 3446 | else |
3425 | min = med; | 3447 | min = med; |
@@ -3428,6 +3450,18 @@ static int stv090x_table_lookup(const struct stv090x_tab *tab, int max, int val) | |||
3428 | (tab[max].real - tab[min].real) / | 3450 | (tab[max].real - tab[min].real) / |
3429 | (tab[max].read - tab[min].read)) + | 3451 | (tab[max].read - tab[min].read)) + |
3430 | tab[min].real; | 3452 | tab[min].real; |
3453 | } else { | ||
3454 | if (tab[min].read < tab[max].read) { | ||
3455 | if (val < tab[min].read) | ||
3456 | res = tab[min].real; | ||
3457 | else if (val >= tab[max].read) | ||
3458 | res = tab[max].real; | ||
3459 | } else { | ||
3460 | if (val >= tab[min].read) | ||
3461 | res = tab[min].real; | ||
3462 | else if (val < tab[max].read) | ||
3463 | res = tab[max].real; | ||
3464 | } | ||
3431 | } | 3465 | } |
3432 | 3466 | ||
3433 | return res; | 3467 | return res; |
@@ -3437,16 +3471,22 @@ static int stv090x_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
3437 | { | 3471 | { |
3438 | struct stv090x_state *state = fe->demodulator_priv; | 3472 | struct stv090x_state *state = fe->demodulator_priv; |
3439 | u32 reg; | 3473 | u32 reg; |
3440 | s32 agc; | 3474 | s32 agc_0, agc_1, agc; |
3475 | s32 str; | ||
3441 | 3476 | ||
3442 | reg = STV090x_READ_DEMOD(state, AGCIQIN1); | 3477 | reg = STV090x_READ_DEMOD(state, AGCIQIN1); |
3443 | agc = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); | 3478 | agc_1 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); |
3479 | reg = STV090x_READ_DEMOD(state, AGCIQIN0); | ||
3480 | agc_0 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); | ||
3481 | agc = MAKEWORD16(agc_1, agc_0); | ||
3444 | 3482 | ||
3445 | *strength = stv090x_table_lookup(stv090x_rf_tab, ARRAY_SIZE(stv090x_rf_tab) - 1, agc); | 3483 | str = stv090x_table_lookup(stv090x_rf_tab, |
3484 | ARRAY_SIZE(stv090x_rf_tab) - 1, agc); | ||
3446 | if (agc > stv090x_rf_tab[0].read) | 3485 | if (agc > stv090x_rf_tab[0].read) |
3447 | *strength = 5; | 3486 | str = 0; |
3448 | else if (agc < stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read) | 3487 | else if (agc < stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read) |
3449 | *strength = -100; | 3488 | str = -100; |
3489 | *strength = (str + 100) * 0xFFFF / 100; | ||
3450 | 3490 | ||
3451 | return 0; | 3491 | return 0; |
3452 | } | 3492 | } |
@@ -3457,6 +3497,8 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) | |||
3457 | u32 reg_0, reg_1, reg, i; | 3497 | u32 reg_0, reg_1, reg, i; |
3458 | s32 val_0, val_1, val = 0; | 3498 | s32 val_0, val_1, val = 0; |
3459 | u8 lock_f; | 3499 | u8 lock_f; |
3500 | s32 div; | ||
3501 | u32 last; | ||
3460 | 3502 | ||
3461 | switch (state->delsys) { | 3503 | switch (state->delsys) { |
3462 | case STV090x_DVBS2: | 3504 | case STV090x_DVBS2: |
@@ -3468,14 +3510,15 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) | |||
3468 | reg_1 = STV090x_READ_DEMOD(state, NNOSPLHT1); | 3510 | reg_1 = STV090x_READ_DEMOD(state, NNOSPLHT1); |
3469 | val_1 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD); | 3511 | val_1 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD); |
3470 | reg_0 = STV090x_READ_DEMOD(state, NNOSPLHT0); | 3512 | reg_0 = STV090x_READ_DEMOD(state, NNOSPLHT0); |
3471 | val_0 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD); | 3513 | val_0 = STV090x_GETFIELD_Px(reg_0, NOSPLHT_NORMED_FIELD); |
3472 | val += MAKEWORD16(val_1, val_0); | 3514 | val += MAKEWORD16(val_1, val_0); |
3473 | msleep(1); | 3515 | msleep(1); |
3474 | } | 3516 | } |
3475 | val /= 16; | 3517 | val /= 16; |
3476 | *cnr = stv090x_table_lookup(stv090x_s2cn_tab, ARRAY_SIZE(stv090x_s2cn_tab) - 1, val); | 3518 | last = ARRAY_SIZE(stv090x_s2cn_tab) - 1; |
3477 | if (val < stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s2cn_tab) - 1].read) | 3519 | div = stv090x_s2cn_tab[0].read - |
3478 | *cnr = 1000; | 3520 | stv090x_s2cn_tab[last].read; |
3521 | *cnr = 0xFFFF - ((val * 0xFFFF) / div); | ||
3479 | } | 3522 | } |
3480 | break; | 3523 | break; |
3481 | 3524 | ||
@@ -3489,14 +3532,15 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) | |||
3489 | reg_1 = STV090x_READ_DEMOD(state, NOSDATAT1); | 3532 | reg_1 = STV090x_READ_DEMOD(state, NOSDATAT1); |
3490 | val_1 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD); | 3533 | val_1 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD); |
3491 | reg_0 = STV090x_READ_DEMOD(state, NOSDATAT0); | 3534 | reg_0 = STV090x_READ_DEMOD(state, NOSDATAT0); |
3492 | val_0 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD); | 3535 | val_0 = STV090x_GETFIELD_Px(reg_0, NOSDATAT_UNNORMED_FIELD); |
3493 | val += MAKEWORD16(val_1, val_0); | 3536 | val += MAKEWORD16(val_1, val_0); |
3494 | msleep(1); | 3537 | msleep(1); |
3495 | } | 3538 | } |
3496 | val /= 16; | 3539 | val /= 16; |
3497 | *cnr = stv090x_table_lookup(stv090x_s1cn_tab, ARRAY_SIZE(stv090x_s1cn_tab) - 1, val); | 3540 | last = ARRAY_SIZE(stv090x_s1cn_tab) - 1; |
3498 | if (val < stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s1cn_tab) - 1].read) | 3541 | div = stv090x_s1cn_tab[0].read - |
3499 | *cnr = 1000; | 3542 | stv090x_s1cn_tab[last].read; |
3543 | *cnr = 0xFFFF - ((val * 0xFFFF) / div); | ||
3500 | } | 3544 | } |
3501 | break; | 3545 | break; |
3502 | default: | 3546 | default: |
@@ -3732,6 +3776,8 @@ static int stv090x_ldpc_mode(struct stv090x_state *state, enum stv090x_mode ldpc | |||
3732 | { | 3776 | { |
3733 | u32 reg = 0; | 3777 | u32 reg = 0; |
3734 | 3778 | ||
3779 | reg = stv090x_read_reg(state, STV090x_GENCFG); | ||
3780 | |||
3735 | switch (ldpc_mode) { | 3781 | switch (ldpc_mode) { |
3736 | case STV090x_DUAL: | 3782 | case STV090x_DUAL: |
3737 | default: | 3783 | default: |