60 #include <linux/kernel.h>
62 #include <linux/module.h>
63 #include <linux/string.h>
64 #include <linux/slab.h>
71 #define dprintk(level, arg...) do { \
76 #define TUNER_REGS_NUM 104
77 #define INITCTRL_NUM 40
79 #ifdef _MXL_PRODUCTION
85 #define MXLCTRL_NUM 189
86 #define MASTER_CONTROL_ADDR 9
192 #ifdef _MXL_PRODUCTION
205 #define MXL5005S_REG_WRITING_TABLE_LEN_MAX 104
206 #define MXL5005S_LATCH_BYTE 0xfe
209 #define MXL5005S_BB_IQSWAP_ADDR 59
210 #define MXL5005S_BB_IQSWAP_MSB 0
211 #define MXL5005S_BB_IQSWAP_LSB 0
213 #define MXL5005S_BB_DLPF_BANDSEL_ADDR 53
214 #define MXL5005S_BB_DLPF_BANDSEL_MSB 4
215 #define MXL5005S_BB_DLPF_BANDSEL_LSB 3
222 #define MXL5005S_STANDARD_MODE_NUM 2
230 #define MXL5005S_BANDWIDTH_MODE_NUM 3
298 static u16 MXL_GetMasterControl(
u8 *MasterReg,
int state);
313 static void MXL_SynthIFLO_Calc(
struct dvb_frontend *fe);
314 static void MXL_SynthRFTGLO_Calc(
struct dvb_frontend *fe);
317 static int mxl5005s_writeregs(
struct dvb_frontend *fe,
u8 *addrtable,
318 u8 *datatable,
u8 len);
320 static int mxl5005s_AssignTunerMode(
struct dvb_frontend *fe,
u32 mod_type,
337 static int mxl5005s_SetRfFreqHz(
struct dvb_frontend *fe,
unsigned long RfFreqHz)
345 unsigned char MasterControlByte;
347 dprintk(1,
"%s() freq=%ld\n", __func__, RfFreqHz);
354 ByteTable[0] |= state->
config->AgcMasterByte;
356 mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
359 MXL_TuneRF(fe, RfFreqHz);
361 MXL_ControlRead(fe,
IF_DIVVAL, &IfDivval);
366 MXL_GetCHRegister(fe, AddrTable, ByteTable, &TableLen);
370 ByteTable[TableLen] = MasterControlByte |
371 state->
config->AgcMasterByte;
374 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
381 MXL_ControlWrite(fe,
IF_DIVVAL, IfDivval);
382 MXL_GetCHRegister_ZeroIF(fe, AddrTable, ByteTable, &TableLen);
386 ByteTable[TableLen] = MasterControlByte |
387 state->
config->AgcMasterByte ;
390 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
1182 state->
CH_Ctrl[0].addr[0] = 68;
1185 state->
CH_Ctrl[0].addr[1] = 68;
1191 state->
CH_Ctrl[1].addr[0] = 70;
1194 state->
CH_Ctrl[1].addr[1] = 70;
1200 state->
CH_Ctrl[2].addr[0] = 69;
1203 state->
CH_Ctrl[2].addr[1] = 69;
1206 state->
CH_Ctrl[2].addr[2] = 69;
1209 state->
CH_Ctrl[2].addr[3] = 68;
1212 state->
CH_Ctrl[2].addr[4] = 68;
1215 state->
CH_Ctrl[2].addr[5] = 68;
1218 state->
CH_Ctrl[2].addr[6] = 68;
1221 state->
CH_Ctrl[2].addr[7] = 68;
1224 state->
CH_Ctrl[2].addr[8] = 68;
1230 state->
CH_Ctrl[3].addr[0] = 70;
1236 state->
CH_Ctrl[4].addr[0] = 73;
1239 state->
CH_Ctrl[4].addr[1] = 73;
1242 state->
CH_Ctrl[4].addr[2] = 73;
1248 state->
CH_Ctrl[5].addr[0] = 70;
1251 state->
CH_Ctrl[5].addr[1] = 70;
1254 state->
CH_Ctrl[5].addr[2] = 70;
1257 state->
CH_Ctrl[5].addr[3] = 70;
1263 state->
CH_Ctrl[6].addr[0] = 70;
1269 state->
CH_Ctrl[7].addr[0] = 111;
1275 state->
CH_Ctrl[8].addr[0] = 111;
1281 state->
CH_Ctrl[9].addr[0] = 111;
1287 state->
CH_Ctrl[10].addr[0] = 111;
1288 state->
CH_Ctrl[10].bit[0] = 5;
1289 state->
CH_Ctrl[10].val[0] = 0;
1293 state->
CH_Ctrl[11].addr[0] = 110;
1294 state->
CH_Ctrl[11].bit[0] = 0;
1295 state->
CH_Ctrl[11].val[0] = 1;
1296 state->
CH_Ctrl[11].addr[1] = 110;
1297 state->
CH_Ctrl[11].bit[1] = 1;
1298 state->
CH_Ctrl[11].val[1] = 0;
1302 state->
CH_Ctrl[12].addr[0] = 69;
1303 state->
CH_Ctrl[12].bit[0] = 2;
1304 state->
CH_Ctrl[12].val[0] = 0;
1305 state->
CH_Ctrl[12].addr[1] = 69;
1306 state->
CH_Ctrl[12].bit[1] = 3;
1307 state->
CH_Ctrl[12].val[1] = 0;
1308 state->
CH_Ctrl[12].addr[2] = 69;
1309 state->
CH_Ctrl[12].bit[2] = 4;
1310 state->
CH_Ctrl[12].val[2] = 0;
1314 state->
CH_Ctrl[13].addr[0] = 110;
1315 state->
CH_Ctrl[13].bit[0] = 2;
1316 state->
CH_Ctrl[13].val[0] = 0;
1317 state->
CH_Ctrl[13].addr[1] = 110;
1318 state->
CH_Ctrl[13].bit[1] = 3;
1319 state->
CH_Ctrl[13].val[1] = 0;
1320 state->
CH_Ctrl[13].addr[2] = 110;
1321 state->
CH_Ctrl[13].bit[2] = 4;
1322 state->
CH_Ctrl[13].val[2] = 0;
1323 state->
CH_Ctrl[13].addr[3] = 110;
1324 state->
CH_Ctrl[13].bit[3] = 5;
1325 state->
CH_Ctrl[13].val[3] = 0;
1326 state->
CH_Ctrl[13].addr[4] = 110;
1327 state->
CH_Ctrl[13].bit[4] = 6;
1328 state->
CH_Ctrl[13].val[4] = 0;
1329 state->
CH_Ctrl[13].addr[5] = 110;
1330 state->
CH_Ctrl[13].bit[5] = 7;
1331 state->
CH_Ctrl[13].val[5] = 1;
1335 state->
CH_Ctrl[14].addr[0] = 14;
1336 state->
CH_Ctrl[14].bit[0] = 0;
1337 state->
CH_Ctrl[14].val[0] = 0;
1338 state->
CH_Ctrl[14].addr[1] = 14;
1339 state->
CH_Ctrl[14].bit[1] = 1;
1340 state->
CH_Ctrl[14].val[1] = 0;
1341 state->
CH_Ctrl[14].addr[2] = 14;
1342 state->
CH_Ctrl[14].bit[2] = 2;
1343 state->
CH_Ctrl[14].val[2] = 0;
1344 state->
CH_Ctrl[14].addr[3] = 14;
1345 state->
CH_Ctrl[14].bit[3] = 3;
1346 state->
CH_Ctrl[14].val[3] = 0;
1347 state->
CH_Ctrl[14].addr[4] = 14;
1348 state->
CH_Ctrl[14].bit[4] = 4;
1349 state->
CH_Ctrl[14].val[4] = 0;
1350 state->
CH_Ctrl[14].addr[5] = 14;
1351 state->
CH_Ctrl[14].bit[5] = 5;
1352 state->
CH_Ctrl[14].val[5] = 0;
1353 state->
CH_Ctrl[14].addr[6] = 14;
1354 state->
CH_Ctrl[14].bit[6] = 6;
1355 state->
CH_Ctrl[14].val[6] = 0;
1358 state->
CH_Ctrl[15].size = 18 ;
1359 state->
CH_Ctrl[15].addr[0] = 17;
1360 state->
CH_Ctrl[15].bit[0] = 6;
1361 state->
CH_Ctrl[15].val[0] = 0;
1362 state->
CH_Ctrl[15].addr[1] = 17;
1363 state->
CH_Ctrl[15].bit[1] = 7;
1364 state->
CH_Ctrl[15].val[1] = 0;
1365 state->
CH_Ctrl[15].addr[2] = 16;
1366 state->
CH_Ctrl[15].bit[2] = 0;
1367 state->
CH_Ctrl[15].val[2] = 0;
1368 state->
CH_Ctrl[15].addr[3] = 16;
1369 state->
CH_Ctrl[15].bit[3] = 1;
1370 state->
CH_Ctrl[15].val[3] = 0;
1371 state->
CH_Ctrl[15].addr[4] = 16;
1372 state->
CH_Ctrl[15].bit[4] = 2;
1373 state->
CH_Ctrl[15].val[4] = 0;
1374 state->
CH_Ctrl[15].addr[5] = 16;
1375 state->
CH_Ctrl[15].bit[5] = 3;
1376 state->
CH_Ctrl[15].val[5] = 0;
1377 state->
CH_Ctrl[15].addr[6] = 16;
1378 state->
CH_Ctrl[15].bit[6] = 4;
1379 state->
CH_Ctrl[15].val[6] = 0;
1380 state->
CH_Ctrl[15].addr[7] = 16;
1381 state->
CH_Ctrl[15].bit[7] = 5;
1382 state->
CH_Ctrl[15].val[7] = 0;
1383 state->
CH_Ctrl[15].addr[8] = 16;
1384 state->
CH_Ctrl[15].bit[8] = 6;
1385 state->
CH_Ctrl[15].val[8] = 0;
1386 state->
CH_Ctrl[15].addr[9] = 16;
1387 state->
CH_Ctrl[15].bit[9] = 7;
1388 state->
CH_Ctrl[15].val[9] = 0;
1389 state->
CH_Ctrl[15].addr[10] = 15;
1390 state->
CH_Ctrl[15].bit[10] = 0;
1391 state->
CH_Ctrl[15].val[10] = 0;
1392 state->
CH_Ctrl[15].addr[11] = 15;
1393 state->
CH_Ctrl[15].bit[11] = 1;
1394 state->
CH_Ctrl[15].val[11] = 0;
1395 state->
CH_Ctrl[15].addr[12] = 15;
1396 state->
CH_Ctrl[15].bit[12] = 2;
1397 state->
CH_Ctrl[15].val[12] = 0;
1398 state->
CH_Ctrl[15].addr[13] = 15;
1399 state->
CH_Ctrl[15].bit[13] = 3;
1400 state->
CH_Ctrl[15].val[13] = 0;
1401 state->
CH_Ctrl[15].addr[14] = 15;
1402 state->
CH_Ctrl[15].bit[14] = 4;
1403 state->
CH_Ctrl[15].val[14] = 0;
1404 state->
CH_Ctrl[15].addr[15] = 15;
1405 state->
CH_Ctrl[15].bit[15] = 5;
1406 state->
CH_Ctrl[15].val[15] = 0;
1407 state->
CH_Ctrl[15].addr[16] = 15;
1408 state->
CH_Ctrl[15].bit[16] = 6;
1409 state->
CH_Ctrl[15].val[16] = 1;
1410 state->
CH_Ctrl[15].addr[17] = 15;
1411 state->
CH_Ctrl[15].bit[17] = 7;
1412 state->
CH_Ctrl[15].val[17] = 1;
1416 state->
CH_Ctrl[16].addr[0] = 112;
1417 state->
CH_Ctrl[16].bit[0] = 0;
1418 state->
CH_Ctrl[16].val[0] = 0;
1419 state->
CH_Ctrl[16].addr[1] = 112;
1420 state->
CH_Ctrl[16].bit[1] = 1;
1421 state->
CH_Ctrl[16].val[1] = 0;
1422 state->
CH_Ctrl[16].addr[2] = 112;
1423 state->
CH_Ctrl[16].bit[2] = 2;
1424 state->
CH_Ctrl[16].val[2] = 0;
1425 state->
CH_Ctrl[16].addr[3] = 112;
1426 state->
CH_Ctrl[16].bit[3] = 3;
1427 state->
CH_Ctrl[16].val[3] = 0;
1428 state->
CH_Ctrl[16].addr[4] = 112;
1429 state->
CH_Ctrl[16].bit[4] = 4;
1430 state->
CH_Ctrl[16].val[4] = 1;
1434 state->
CH_Ctrl[17].addr[0] = 14;
1435 state->
CH_Ctrl[17].bit[0] = 7;
1436 state->
CH_Ctrl[17].val[0] = 0;
1440 state->
CH_Ctrl[18].addr[0] = 107;
1441 state->
CH_Ctrl[18].bit[0] = 3;
1442 state->
CH_Ctrl[18].val[0] = 0;
1443 state->
CH_Ctrl[18].addr[1] = 107;
1444 state->
CH_Ctrl[18].bit[1] = 4;
1445 state->
CH_Ctrl[18].val[1] = 0;
1446 state->
CH_Ctrl[18].addr[2] = 107;
1447 state->
CH_Ctrl[18].bit[2] = 5;
1448 state->
CH_Ctrl[18].val[2] = 0;
1449 state->
CH_Ctrl[18].addr[3] = 107;
1450 state->
CH_Ctrl[18].bit[3] = 6;
1451 state->
CH_Ctrl[18].val[3] = 0;
1455 state->
CH_Ctrl[19].addr[0] = 107;
1456 state->
CH_Ctrl[19].bit[0] = 7;
1457 state->
CH_Ctrl[19].val[0] = 1;
1458 state->
CH_Ctrl[19].addr[1] = 106;
1459 state->
CH_Ctrl[19].bit[1] = 0;
1460 state->
CH_Ctrl[19].val[1] = 1;
1461 state->
CH_Ctrl[19].addr[2] = 106;
1462 state->
CH_Ctrl[19].bit[2] = 1;
1463 state->
CH_Ctrl[19].val[2] = 1;
1466 state->
CH_Ctrl[20].size = 11 ;
1467 state->
CH_Ctrl[20].addr[0] = 109;
1468 state->
CH_Ctrl[20].bit[0] = 2;
1469 state->
CH_Ctrl[20].val[0] = 0;
1470 state->
CH_Ctrl[20].addr[1] = 109;
1471 state->
CH_Ctrl[20].bit[1] = 3;
1472 state->
CH_Ctrl[20].val[1] = 0;
1473 state->
CH_Ctrl[20].addr[2] = 109;
1474 state->
CH_Ctrl[20].bit[2] = 4;
1475 state->
CH_Ctrl[20].val[2] = 0;
1476 state->
CH_Ctrl[20].addr[3] = 109;
1477 state->
CH_Ctrl[20].bit[3] = 5;
1478 state->
CH_Ctrl[20].val[3] = 0;
1479 state->
CH_Ctrl[20].addr[4] = 109;
1480 state->
CH_Ctrl[20].bit[4] = 6;
1481 state->
CH_Ctrl[20].val[4] = 0;
1482 state->
CH_Ctrl[20].addr[5] = 109;
1483 state->
CH_Ctrl[20].bit[5] = 7;
1484 state->
CH_Ctrl[20].val[5] = 0;
1485 state->
CH_Ctrl[20].addr[6] = 108;
1486 state->
CH_Ctrl[20].bit[6] = 0;
1487 state->
CH_Ctrl[20].val[6] = 0;
1488 state->
CH_Ctrl[20].addr[7] = 108;
1489 state->
CH_Ctrl[20].bit[7] = 1;
1490 state->
CH_Ctrl[20].val[7] = 0;
1491 state->
CH_Ctrl[20].addr[8] = 108;
1492 state->
CH_Ctrl[20].bit[8] = 2;
1493 state->
CH_Ctrl[20].val[8] = 1;
1494 state->
CH_Ctrl[20].addr[9] = 108;
1495 state->
CH_Ctrl[20].bit[9] = 3;
1496 state->
CH_Ctrl[20].val[9] = 1;
1497 state->
CH_Ctrl[20].addr[10] = 108;
1498 state->
CH_Ctrl[20].bit[10] = 4;
1499 state->
CH_Ctrl[20].val[10] = 1;
1503 state->
CH_Ctrl[21].addr[0] = 106;
1504 state->
CH_Ctrl[21].bit[0] = 2;
1505 state->
CH_Ctrl[21].val[0] = 0;
1506 state->
CH_Ctrl[21].addr[1] = 106;
1507 state->
CH_Ctrl[21].bit[1] = 3;
1508 state->
CH_Ctrl[21].val[1] = 0;
1509 state->
CH_Ctrl[21].addr[2] = 106;
1510 state->
CH_Ctrl[21].bit[2] = 4;
1511 state->
CH_Ctrl[21].val[2] = 0;
1512 state->
CH_Ctrl[21].addr[3] = 106;
1513 state->
CH_Ctrl[21].bit[3] = 5;
1514 state->
CH_Ctrl[21].val[3] = 0;
1515 state->
CH_Ctrl[21].addr[4] = 106;
1516 state->
CH_Ctrl[21].bit[4] = 6;
1517 state->
CH_Ctrl[21].val[4] = 0;
1518 state->
CH_Ctrl[21].addr[5] = 106;
1519 state->
CH_Ctrl[21].bit[5] = 7;
1520 state->
CH_Ctrl[21].val[5] = 1;
1524 state->
CH_Ctrl[22].addr[0] = 138;
1525 state->
CH_Ctrl[22].bit[0] = 4;
1526 state->
CH_Ctrl[22].val[0] = 1;
1530 state->
CH_Ctrl[23].addr[0] = 17;
1531 state->
CH_Ctrl[23].bit[0] = 5;
1532 state->
CH_Ctrl[23].val[0] = 0;
1536 state->
CH_Ctrl[24].addr[0] = 111;
1537 state->
CH_Ctrl[24].bit[0] = 3;
1538 state->
CH_Ctrl[24].val[0] = 0;
1542 state->
CH_Ctrl[25].addr[0] = 112;
1543 state->
CH_Ctrl[25].bit[0] = 7;
1544 state->
CH_Ctrl[25].val[0] = 0;
1548 state->
CH_Ctrl[26].addr[0] = 136;
1549 state->
CH_Ctrl[26].bit[0] = 7;
1550 state->
CH_Ctrl[26].val[0] = 0;
1554 state->
CH_Ctrl[27].addr[0] = 149;
1555 state->
CH_Ctrl[27].bit[0] = 7;
1556 state->
CH_Ctrl[27].val[0] = 0;
1560 state->
CH_Ctrl[28].addr[0] = 149;
1561 state->
CH_Ctrl[28].bit[0] = 6;
1562 state->
CH_Ctrl[28].val[0] = 0;
1566 state->
CH_Ctrl[29].addr[0] = 149;
1567 state->
CH_Ctrl[29].bit[0] = 5;
1568 state->
CH_Ctrl[29].val[0] = 1;
1572 state->
CH_Ctrl[30].addr[0] = 149;
1573 state->
CH_Ctrl[30].bit[0] = 4;
1574 state->
CH_Ctrl[30].val[0] = 1;
1578 state->
CH_Ctrl[31].addr[0] = 149;
1579 state->
CH_Ctrl[31].bit[0] = 3;
1580 state->
CH_Ctrl[31].val[0] = 0;
1584 state->
CH_Ctrl[32].addr[0] = 93;
1585 state->
CH_Ctrl[32].bit[0] = 1;
1586 state->
CH_Ctrl[32].val[0] = 0;
1590 state->
CH_Ctrl[33].addr[0] = 93;
1591 state->
CH_Ctrl[33].bit[0] = 0;
1592 state->
CH_Ctrl[33].val[0] = 0;
1596 state->
CH_Ctrl[34].addr[0] = 92;
1597 state->
CH_Ctrl[34].bit[0] = 2;
1598 state->
CH_Ctrl[34].val[0] = 0;
1599 state->
CH_Ctrl[34].addr[1] = 92;
1600 state->
CH_Ctrl[34].bit[1] = 3;
1601 state->
CH_Ctrl[34].val[1] = 0;
1602 state->
CH_Ctrl[34].addr[2] = 92;
1603 state->
CH_Ctrl[34].bit[2] = 4;
1604 state->
CH_Ctrl[34].val[2] = 0;
1605 state->
CH_Ctrl[34].addr[3] = 92;
1606 state->
CH_Ctrl[34].bit[3] = 5;
1607 state->
CH_Ctrl[34].val[3] = 0;
1608 state->
CH_Ctrl[34].addr[4] = 92;
1609 state->
CH_Ctrl[34].bit[4] = 6;
1610 state->
CH_Ctrl[34].val[4] = 0;
1611 state->
CH_Ctrl[34].addr[5] = 92;
1612 state->
CH_Ctrl[34].bit[5] = 7;
1613 state->
CH_Ctrl[34].val[5] = 0;
1617 state->
CH_Ctrl[35].addr[0] = 93;
1618 state->
CH_Ctrl[35].bit[0] = 2;
1619 state->
CH_Ctrl[35].val[0] = 0;
1620 state->
CH_Ctrl[35].addr[1] = 93;
1621 state->
CH_Ctrl[35].bit[1] = 3;
1622 state->
CH_Ctrl[35].val[1] = 0;
1623 state->
CH_Ctrl[35].addr[2] = 93;
1624 state->
CH_Ctrl[35].bit[2] = 4;
1625 state->
CH_Ctrl[35].val[2] = 0;
1626 state->
CH_Ctrl[35].addr[3] = 93;
1627 state->
CH_Ctrl[35].bit[3] = 5;
1628 state->
CH_Ctrl[35].val[3] = 0;
1629 state->
CH_Ctrl[35].addr[4] = 93;
1630 state->
CH_Ctrl[35].bit[4] = 6;
1631 state->
CH_Ctrl[35].val[4] = 0;
1632 state->
CH_Ctrl[35].addr[5] = 93;
1633 state->
CH_Ctrl[35].bit[5] = 7;
1634 state->
CH_Ctrl[35].val[5] = 0;
1636 #ifdef _MXL_PRODUCTION
1637 state->
CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ;
1639 state->
CH_Ctrl[36].addr[0] = 109;
1640 state->
CH_Ctrl[36].bit[0] = 1;
1641 state->
CH_Ctrl[36].val[0] = 1;
1643 state->
CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ;
1645 state->
CH_Ctrl[37].addr[0] = 112;
1646 state->
CH_Ctrl[37].bit[0] = 5;
1647 state->
CH_Ctrl[37].val[0] = 0;
1648 state->
CH_Ctrl[37].addr[1] = 112;
1649 state->
CH_Ctrl[37].bit[1] = 6;
1650 state->
CH_Ctrl[37].val[1] = 0;
1652 state->
CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ;
1654 state->
CH_Ctrl[38].addr[0] = 65;
1655 state->
CH_Ctrl[38].bit[0] = 1;
1656 state->
CH_Ctrl[38].val[0] = 0;
1664 MXL5005_RegisterInit(fe);
1665 MXL5005_ControlInit(fe);
1666 #ifdef _MXL_INTERNAL
1667 MXL5005_MXLControlInit(fe);
1713 InitTunerControls(fe);
1716 MXL_SynthIFLO_Calc(fe);
1721 static void MXL_SynthIFLO_Calc(
struct dvb_frontend *fe)
1724 if (state->
Mode == 1)
1734 static void MXL_SynthRFTGLO_Calc(
struct dvb_frontend *fe)
1738 if (state->
Mode == 1) {
1759 status += MXL_ControlWrite(fe,
OVERRIDE_1, 1);
1760 status += MXL_ControlWrite(fe,
OVERRIDE_2, 1);
1761 status += MXL_ControlWrite(fe,
OVERRIDE_3, 1);
1762 status += MXL_ControlWrite(fe,
OVERRIDE_4, 1);
1772 status += MXL_OverwriteICDefault(fe);
1778 status += MXL_ControlWrite(fe,
BB_MODE, state->
Mode ? 0 : 1);
1779 status += MXL_ControlWrite(fe,
BB_BUF, state->
Mode ? 3 : 2);
1780 status += MXL_ControlWrite(fe,
BB_BUF_OA, state->
Mode ? 1 : 0);
1781 status += MXL_ControlWrite(fe,
BB_IQSWAP, state->
Mode ? 0 : 1);
1794 status += MXL_ControlWrite(fe,
1817 status += MXL_ControlWrite(fe,
1823 status += MXL_ControlWrite(fe,
AGC_IF, 15);
1824 status += MXL_ControlWrite(fe,
AGC_RF, 15);
1826 status += MXL_ControlWrite(fe,
AGC_RF, state->
Mode ? 15 : 12);
1828 if (state->
TOP == 55)
1829 status += MXL_ControlWrite(fe,
AGC_IF, 0x0);
1831 if (state->
TOP == 72)
1832 status += MXL_ControlWrite(fe,
AGC_IF, 0x1);
1834 if (state->
TOP == 92)
1835 status += MXL_ControlWrite(fe,
AGC_IF, 0x2);
1837 if (state->
TOP == 110)
1838 status += MXL_ControlWrite(fe,
AGC_IF, 0x3);
1840 if (state->
TOP == 129)
1841 status += MXL_ControlWrite(fe,
AGC_IF, 0x4);
1843 if (state->
TOP == 147)
1844 status += MXL_ControlWrite(fe,
AGC_IF, 0x5);
1846 if (state->
TOP == 168)
1847 status += MXL_ControlWrite(fe,
AGC_IF, 0x6);
1849 if (state->
TOP == 194)
1850 status += MXL_ControlWrite(fe,
AGC_IF, 0x7);
1852 if (state->
TOP == 212)
1853 status += MXL_ControlWrite(fe,
AGC_IF, 0x9);
1855 if (state->
TOP == 232)
1856 status += MXL_ControlWrite(fe,
AGC_IF, 0xA);
1858 if (state->
TOP == 252)
1859 status += MXL_ControlWrite(fe,
AGC_IF, 0xB);
1861 if (state->
TOP == 271)
1862 status += MXL_ControlWrite(fe,
AGC_IF, 0xC);
1864 if (state->
TOP == 292)
1865 status += MXL_ControlWrite(fe,
AGC_IF, 0xD);
1867 if (state->
TOP == 317)
1868 status += MXL_ControlWrite(fe,
AGC_IF, 0xE);
1870 if (state->
TOP == 349)
1871 status += MXL_ControlWrite(fe,
AGC_IF, 0xF);
1874 status += MXL_IFSynthInit(fe);
1879 status += MXL_ControlWrite(fe,
I_DRIVER, 2);
1883 status += MXL_ControlWrite(fe,
I_DRIVER, 1);
1891 status += MXL_ControlWrite(fe,
EN_AAF, 1);
1892 status += MXL_ControlWrite(fe,
EN_3P, 1);
1893 status += MXL_ControlWrite(fe,
EN_AUX_3P, 1);
1896 if ((state->
IF_OUT == 36125000
UL) ||
1898 status += MXL_ControlWrite(fe,
EN_AAF, 1);
1899 status += MXL_ControlWrite(fe,
EN_3P, 1);
1900 status += MXL_ControlWrite(fe,
EN_AUX_3P, 1);
1904 status += MXL_ControlWrite(fe,
EN_AAF, 0);
1905 status += MXL_ControlWrite(fe,
EN_3P, 1);
1906 status += MXL_ControlWrite(fe,
EN_AUX_3P, 1);
1911 status += MXL_ControlWrite(fe,
EN_AAF, 1);
1912 status += MXL_ControlWrite(fe,
EN_3P, 1);
1913 status += MXL_ControlWrite(fe,
EN_AUX_3P, 1);
1917 status += MXL_ControlWrite(fe,
EN_AAF, 0);
1918 status += MXL_ControlWrite(fe,
EN_3P, 0);
1919 status += MXL_ControlWrite(fe,
EN_AUX_3P, 0);
1942 status += MXL_ControlWrite(fe,
IF_SEL_DBL, 1);
1944 status += MXL_ControlWrite(fe,
IF_SEL_DBL, 0);
1960 status += MXL_ControlWrite(fe,
TG_R_DIV,
1961 MXL_Ceiling(state->
Fxtal, 1000000));
1978 status += MXL_ControlWrite(fe,
RFA_FLR, 0);
1979 status += MXL_ControlWrite(fe,
RFA_CEIL, 12);
2000 status += MXL_ControlWrite(fe,
RFA_FLR, 2);
2001 status += MXL_ControlWrite(fe,
RFA_CEIL, 13);
2003 status += MXL_ControlWrite(fe,
BB_IQSWAP, 0);
2005 status += MXL_ControlWrite(fe,
BB_IQSWAP, 1);
2023 status += MXL_ControlWrite(fe,
RFA_FLR, 2);
2024 status += MXL_ControlWrite(fe,
RFA_CEIL, 13);
2030 status += MXL_ControlWrite(fe,
BB_IQSWAP, 0);
2032 status += MXL_ControlWrite(fe,
BB_IQSWAP, 1);
2053 status += MXL_ControlWrite(fe,
BB_IQSWAP, 0);
2055 status += MXL_ControlWrite(fe,
BB_IQSWAP, 1);
2071 status += MXL_ControlWrite(fe,
AGC_IF, 1);
2072 status += MXL_ControlWrite(fe,
AGC_RF, 15);
2073 status += MXL_ControlWrite(fe,
BB_IQSWAP, 1);
2091 status += MXL_ControlWrite(fe,
BB_IQSWAP, 1);
2110 u32 Kdbl, intModVal ;
2121 if (state->
IF_LO == 41000000
UL) {
2122 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2123 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x0C);
2124 Fref = 328000000
UL ;
2126 if (state->
IF_LO == 47000000
UL) {
2127 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2128 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2129 Fref = 376000000
UL ;
2131 if (state->
IF_LO == 54000000
UL) {
2132 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x10);
2133 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x0C);
2134 Fref = 324000000
UL ;
2136 if (state->
IF_LO == 60000000
UL) {
2137 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x10);
2138 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2139 Fref = 360000000
UL ;
2141 if (state->
IF_LO == 39250000
UL) {
2142 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2143 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x0C);
2144 Fref = 314000000
UL ;
2146 if (state->
IF_LO == 39650000
UL) {
2147 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2148 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x0C);
2149 Fref = 317200000
UL ;
2151 if (state->
IF_LO == 40150000
UL) {
2152 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2153 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x0C);
2154 Fref = 321200000
UL ;
2156 if (state->
IF_LO == 40650000
UL) {
2157 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2158 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x0C);
2159 Fref = 325200000
UL ;
2164 if (state->
IF_LO == 57000000
UL) {
2165 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x10);
2166 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2167 Fref = 342000000
UL ;
2169 if (state->
IF_LO == 44000000
UL) {
2170 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2171 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2172 Fref = 352000000
UL ;
2174 if (state->
IF_LO == 43750000
UL) {
2175 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2176 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2177 Fref = 350000000
UL ;
2179 if (state->
IF_LO == 36650000
UL) {
2180 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x04);
2181 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2182 Fref = 366500000
UL ;
2184 if (state->
IF_LO == 36150000
UL) {
2185 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x04);
2186 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2187 Fref = 361500000
UL ;
2189 if (state->
IF_LO == 36000000
UL) {
2190 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x04);
2191 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2192 Fref = 360000000
UL ;
2194 if (state->
IF_LO == 35250000
UL) {
2195 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x04);
2196 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2197 Fref = 352500000
UL ;
2199 if (state->
IF_LO == 34750000
UL) {
2200 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x04);
2201 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2202 Fref = 347500000
UL ;
2204 if (state->
IF_LO == 6280000
UL) {
2205 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x07);
2206 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2207 Fref = 376800000
UL ;
2209 if (state->
IF_LO == 5000000
UL) {
2210 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x09);
2211 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2212 Fref = 360000000
UL ;
2214 if (state->
IF_LO == 4500000
UL) {
2215 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x06);
2216 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2217 Fref = 360000000
UL ;
2219 if (state->
IF_LO == 4570000
UL) {
2220 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x06);
2221 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2222 Fref = 365600000
UL ;
2224 if (state->
IF_LO == 4000000
UL) {
2225 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x05);
2226 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2227 Fref = 360000000
UL ;
2229 if (state->
IF_LO == 57400000
UL) {
2230 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x10);
2231 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2232 Fref = 344400000
UL ;
2234 if (state->
IF_LO == 44400000
UL) {
2235 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2236 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2237 Fref = 355200000
UL ;
2239 if (state->
IF_LO == 44150000
UL) {
2240 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x08);
2241 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2242 Fref = 353200000
UL ;
2244 if (state->
IF_LO == 37050000
UL) {
2245 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x04);
2246 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2247 Fref = 370500000
UL ;
2249 if (state->
IF_LO == 36550000
UL) {
2250 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x04);
2251 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2252 Fref = 365500000
UL ;
2254 if (state->
IF_LO == 36125000
UL) {
2255 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x04);
2256 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2257 Fref = 361250000
UL ;
2259 if (state->
IF_LO == 6000000
UL) {
2260 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x07);
2261 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2262 Fref = 360000000
UL ;
2264 if (state->
IF_LO == 5400000
UL) {
2265 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x07);
2266 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x0C);
2267 Fref = 324000000
UL ;
2269 if (state->
IF_LO == 5380000
UL) {
2270 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x07);
2271 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x0C);
2272 Fref = 322800000
UL ;
2274 if (state->
IF_LO == 5200000
UL) {
2275 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x09);
2276 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2277 Fref = 374400000
UL ;
2279 if (state->
IF_LO == 4900000
UL) {
2280 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x09);
2281 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2282 Fref = 352800000
UL ;
2284 if (state->
IF_LO == 4400000
UL) {
2285 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x06);
2286 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2287 Fref = 352000000
UL ;
2289 if (state->
IF_LO == 4063000
UL) {
2290 status += MXL_ControlWrite(fe,
IF_DIVVAL, 0x05);
2291 status += MXL_ControlWrite(fe,
IF_VCO_BIAS, 0x08);
2292 Fref = 365670000
UL ;
2297 intModVal = Fref / (state->
Fxtal * Kdbl/2);
2300 fracModVal = (2<<15)*(Fref/1000 - (state->
Fxtal/1000 * Kdbl/2) *
2303 fracModVal = fracModVal / ((state->
Fxtal * Kdbl/2)/1000);
2313 u32 divider_val,
E3,
E4, E5, E5A;
2314 u32 Fmax, Fmin, FmaxBin, FminBin;
2322 state->
RF_IN = RF_Freq;
2324 MXL_SynthRFTGLO_Calc(fe);
2328 if (state->
Fxtal > 22000000 && state->
Fxtal <= 32000000)
2340 if (state->
RF_LO < 40000000
UL)
2344 status += MXL_ControlWrite(fe,
DN_POLY, 2);
2345 status += MXL_ControlWrite(fe,
DN_RFGAIN, 3);
2351 status += MXL_ControlWrite(fe,
DN_POLY, 3);
2352 status += MXL_ControlWrite(fe,
DN_RFGAIN, 3);
2358 status += MXL_ControlWrite(fe,
DN_POLY, 3);
2359 status += MXL_ControlWrite(fe,
DN_RFGAIN, 3);
2365 status += MXL_ControlWrite(fe,
DN_POLY, 3);
2366 status += MXL_ControlWrite(fe,
DN_RFGAIN, 3);
2372 status += MXL_ControlWrite(fe,
DN_POLY, 3);
2373 status += MXL_ControlWrite(fe,
DN_RFGAIN, 3);
2379 status += MXL_ControlWrite(fe,
DN_POLY, 3);
2380 status += MXL_ControlWrite(fe,
DN_RFGAIN, 1);
2386 status += MXL_ControlWrite(fe,
DN_POLY, 3);
2387 status += MXL_ControlWrite(fe,
DN_RFGAIN, 2);
2392 if (state->
RF_LO > 900000000
UL)
2475 FminBin = 28000000
UL ;
2476 FmaxBin = 42500000
UL ;
2477 if (state->
RF_LO >= 40000000
UL && state->
RF_LO <= FmaxBin) {
2488 FminBin = 42500000
UL ;
2489 FmaxBin = 56000000
UL ;
2490 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2501 FminBin = 56000000
UL ;
2502 FmaxBin = 85000000
UL ;
2503 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2514 FminBin = 85000000
UL ;
2515 FmaxBin = 112000000
UL ;
2516 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2527 FminBin = 112000000
UL ;
2528 FmaxBin = 170000000
UL ;
2529 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2540 FminBin = 170000000
UL ;
2541 FmaxBin = 225000000
UL ;
2542 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2553 FminBin = 225000000
UL ;
2554 FmaxBin = 300000000
UL ;
2555 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2563 Fmax = 340000000
UL ;
2566 FminBin = 300000000
UL ;
2567 FmaxBin = 340000000
UL ;
2568 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2577 Fmin = 225000000
UL ;
2579 FminBin = 340000000
UL ;
2580 FmaxBin = 450000000
UL ;
2581 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2592 FminBin = 450000000
UL ;
2593 FmaxBin = 680000000
UL ;
2594 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2605 FminBin = 680000000
UL ;
2606 FmaxBin = 900000000
UL ;
2607 if (state->
RF_LO > FminBin && state->
RF_LO <= FmaxBin) {
2625 E3 = (((Fmax-state->
RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ;
2629 E4 = (state->
RF_LO*divider_val/1000)/(2*state->
Fxtal*Kdbl_RF/1000);
2633 E5 = ((2<<17)*(state->
RF_LO/10000*divider_val -
2634 (E4*(2*state->
Fxtal*Kdbl_RF)/10000))) /
2635 (2*state->
Fxtal*Kdbl_RF/10000);
2640 E5A = (((Fmax - state->
RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ;
2660 if (state->
TG_LO < 33000000
UL)
2663 FminBin = 33000000
UL ;
2664 FmaxBin = 50000000
UL ;
2665 if (state->
TG_LO >= FminBin && state->
TG_LO <= FmaxBin) {
2672 FminBin = 50000000
UL ;
2673 FmaxBin = 67000000
UL ;
2674 if (state->
TG_LO > FminBin && state->
TG_LO <= FmaxBin) {
2681 FminBin = 67000000
UL ;
2682 FmaxBin = 100000000
UL ;
2683 if (state->
TG_LO > FminBin && state->
TG_LO <= FmaxBin) {
2690 FminBin = 100000000
UL ;
2691 FmaxBin = 150000000
UL ;
2692 if (state->
TG_LO > FminBin && state->
TG_LO <= FmaxBin) {
2699 FminBin = 150000000
UL ;
2700 FmaxBin = 200000000
UL ;
2701 if (state->
TG_LO > FminBin && state->
TG_LO <= FmaxBin) {
2708 FminBin = 200000000
UL ;
2709 FmaxBin = 300000000
UL ;
2710 if (state->
TG_LO > FminBin && state->
TG_LO <= FmaxBin) {
2717 FminBin = 300000000
UL ;
2718 FmaxBin = 400000000
UL ;
2719 if (state->
TG_LO > FminBin && state->
TG_LO <= FmaxBin) {
2726 FminBin = 400000000
UL ;
2727 FmaxBin = 600000000
UL ;
2728 if (state->
TG_LO > FminBin && state->
TG_LO <= FmaxBin) {
2735 FminBin = 600000000
UL ;
2736 FmaxBin = 900000000
UL ;
2737 if (state->
TG_LO > FminBin && state->
TG_LO <= FmaxBin) {
2746 tg_divval = (state->
TG_LO*divider_val/100000) *
2747 (MXL_Ceiling(state->
Fxtal, 1000000) * 100) /
2748 (state->
Fxtal/1000);
2750 status += MXL_ControlWrite(fe,
TG_DIV_VAL, tg_divval);
2752 if (state->
TG_LO > 600000000
UL)
2753 status += MXL_ControlWrite(fe,
TG_DIV_VAL, tg_divval + 1);
2755 Fmax = 1800000000
UL ;
2756 Fmin = 1200000000
UL ;
2762 Fref_TG = (state->
Fxtal/1000) / MXL_Ceiling(state->
Fxtal, 1000000);
2765 Fvco = (state->
TG_LO/10000) * divider_val * Fref_TG;
2767 tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8;
2786 status += MXL_ControlWrite(fe,
TG_VCO_BIAS , tg_lo);
2790 if (state->
config->qam_gain != 0)
2792 state->
config->qam_gain);
2793 else if (state->
RF_IN < 680000000)
2804 status += MXL_SetGPIO(fe, 3, 1);
2805 status += MXL_SetGPIO(fe, 1, 1);
2806 status += MXL_SetGPIO(fe, 4, 1);
2811 status += MXL_ControlWrite(fe,
DAC_DIN_A, 0);
2813 if (state->
RF_IN >= 43000000 && state->
RF_IN < 150000000) {
2815 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
2816 status += MXL_SetGPIO(fe, 3, 0);
2817 status += MXL_SetGPIO(fe, 1, 1);
2818 status += MXL_SetGPIO(fe, 4, 1);
2820 if (state->
RF_IN >= 150000000 && state->
RF_IN < 280000000) {
2822 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
2823 status += MXL_SetGPIO(fe, 3, 1);
2824 status += MXL_SetGPIO(fe, 1, 0);
2825 status += MXL_SetGPIO(fe, 4, 1);
2827 if (state->
RF_IN >= 280000000 && state->
RF_IN < 360000000) {
2829 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
2830 status += MXL_SetGPIO(fe, 3, 1);
2831 status += MXL_SetGPIO(fe, 1, 0);
2832 status += MXL_SetGPIO(fe, 4, 0);
2834 if (state->
RF_IN >= 360000000 && state->
RF_IN < 560000000) {
2836 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
2837 status += MXL_SetGPIO(fe, 3, 1);
2838 status += MXL_SetGPIO(fe, 1, 1);
2839 status += MXL_SetGPIO(fe, 4, 0);
2841 if (state->
RF_IN >= 560000000 && state->
RF_IN < 580000000) {
2843 status += MXL_ControlWrite(fe,
DAC_DIN_B, 29);
2844 status += MXL_SetGPIO(fe, 3, 1);
2845 status += MXL_SetGPIO(fe, 1, 1);
2846 status += MXL_SetGPIO(fe, 4, 0);
2848 if (state->
RF_IN >= 580000000 && state->
RF_IN < 630000000) {
2850 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
2851 status += MXL_SetGPIO(fe, 3, 1);
2852 status += MXL_SetGPIO(fe, 1, 1);
2853 status += MXL_SetGPIO(fe, 4, 0);
2855 if (state->
RF_IN >= 630000000 && state->
RF_IN < 700000000) {
2857 status += MXL_ControlWrite(fe,
DAC_DIN_B, 16);
2858 status += MXL_SetGPIO(fe, 3, 1);
2859 status += MXL_SetGPIO(fe, 1, 1);
2860 status += MXL_SetGPIO(fe, 4, 1);
2862 if (state->
RF_IN >= 700000000 && state->
RF_IN < 760000000) {
2864 status += MXL_ControlWrite(fe,
DAC_DIN_B, 7);
2865 status += MXL_SetGPIO(fe, 3, 1);
2866 status += MXL_SetGPIO(fe, 1, 1);
2867 status += MXL_SetGPIO(fe, 4, 1);
2869 if (state->
RF_IN >= 760000000 && state->
RF_IN <= 900000000) {
2871 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
2872 status += MXL_SetGPIO(fe, 3, 1);
2873 status += MXL_SetGPIO(fe, 1, 1);
2874 status += MXL_SetGPIO(fe, 4, 1);
2881 status += MXL_ControlWrite(fe,
DAC_DIN_A, 0);
2883 if (state->
RF_IN >= 43000000 && state->
RF_IN < 150000000) {
2885 status += MXL_SetGPIO(fe, 4, 0);
2886 status += MXL_SetGPIO(fe, 3, 1);
2887 status += MXL_SetGPIO(fe, 1, 1);
2889 if (state->
RF_IN >= 150000000 && state->
RF_IN < 280000000) {
2891 status += MXL_SetGPIO(fe, 4, 1);
2892 status += MXL_SetGPIO(fe, 3, 0);
2893 status += MXL_SetGPIO(fe, 1, 1);
2895 if (state->
RF_IN >= 280000000 && state->
RF_IN < 360000000) {
2897 status += MXL_SetGPIO(fe, 4, 1);
2898 status += MXL_SetGPIO(fe, 3, 0);
2899 status += MXL_SetGPIO(fe, 1, 0);
2901 if (state->
RF_IN >= 360000000 && state->
RF_IN < 560000000) {
2903 status += MXL_SetGPIO(fe, 4, 1);
2904 status += MXL_SetGPIO(fe, 3, 1);
2905 status += MXL_SetGPIO(fe, 1, 0);
2907 if (state->
RF_IN >= 560000000 && state->
RF_IN < 580000000) {
2909 status += MXL_SetGPIO(fe, 4, 1);
2910 status += MXL_SetGPIO(fe, 3, 1);
2911 status += MXL_SetGPIO(fe, 1, 0);
2913 if (state->
RF_IN >= 580000000 && state->
RF_IN < 630000000) {
2915 status += MXL_SetGPIO(fe, 4, 1);
2916 status += MXL_SetGPIO(fe, 3, 1);
2917 status += MXL_SetGPIO(fe, 1, 0);
2919 if (state->
RF_IN >= 630000000 && state->
RF_IN < 700000000) {
2921 status += MXL_SetGPIO(fe, 4, 1);
2922 status += MXL_SetGPIO(fe, 3, 1);
2923 status += MXL_SetGPIO(fe, 1, 1);
2925 if (state->
RF_IN >= 700000000 && state->
RF_IN < 760000000) {
2927 status += MXL_SetGPIO(fe, 4, 1);
2928 status += MXL_SetGPIO(fe, 3, 1);
2929 status += MXL_SetGPIO(fe, 1, 1);
2931 if (state->
RF_IN >= 760000000 && state->
RF_IN <= 900000000) {
2933 status += MXL_SetGPIO(fe, 4, 1);
2934 status += MXL_SetGPIO(fe, 3, 1);
2935 status += MXL_SetGPIO(fe, 1, 1);
2941 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
2943 if (state->
RF_IN >= 43000000 && state->
RF_IN < 174000000) {
2945 status += MXL_SetGPIO(fe, 4, 0);
2946 status += MXL_SetGPIO(fe, 1, 1);
2947 status += MXL_SetGPIO(fe, 3, 1);
2949 if (state->
RF_IN >= 174000000 && state->
RF_IN < 250000000) {
2951 status += MXL_SetGPIO(fe, 4, 0);
2952 status += MXL_SetGPIO(fe, 1, 0);
2953 status += MXL_SetGPIO(fe, 3, 1);
2955 if (state->
RF_IN >= 250000000 && state->
RF_IN < 310000000) {
2957 status += MXL_SetGPIO(fe, 4, 1);
2958 status += MXL_SetGPIO(fe, 1, 0);
2959 status += MXL_SetGPIO(fe, 3, 1);
2961 if (state->
RF_IN >= 310000000 && state->
RF_IN < 360000000) {
2963 status += MXL_SetGPIO(fe, 4, 1);
2964 status += MXL_SetGPIO(fe, 1, 0);
2965 status += MXL_SetGPIO(fe, 3, 0);
2967 if (state->
RF_IN >= 360000000 && state->
RF_IN < 470000000) {
2969 status += MXL_SetGPIO(fe, 4, 1);
2970 status += MXL_SetGPIO(fe, 1, 1);
2971 status += MXL_SetGPIO(fe, 3, 0);
2973 if (state->
RF_IN >= 470000000 && state->
RF_IN < 640000000) {
2975 status += MXL_SetGPIO(fe, 4, 1);
2976 status += MXL_SetGPIO(fe, 1, 1);
2977 status += MXL_SetGPIO(fe, 3, 0);
2979 if (state->
RF_IN >= 640000000 && state->
RF_IN <= 900000000) {
2981 status += MXL_SetGPIO(fe, 4, 1);
2982 status += MXL_SetGPIO(fe, 1, 1);
2983 status += MXL_SetGPIO(fe, 3, 1);
2990 status += MXL_ControlWrite(fe,
DAC_DIN_A, 0);
2993 if (state->
RF_IN >= 471000000 &&
2994 (state->
RF_IN - 471000000)%6000000 != 0) {
2996 status += MXL_SetGPIO(fe, 3, 1);
2997 status += MXL_SetGPIO(fe, 1, 1);
2998 status += MXL_SetGPIO(fe, 4, 1);
3000 status += MXL_ControlWrite(fe,
AGC_IF, 10);
3003 if (state->
RF_IN >= 43000000 &&
3004 state->
RF_IN < 140000000) {
3007 status += MXL_SetGPIO(fe, 4, 1);
3008 status += MXL_SetGPIO(fe, 1, 1);
3009 status += MXL_SetGPIO(fe, 3, 0);
3011 if (state->
RF_IN >= 140000000 &&
3012 state->
RF_IN < 240000000) {
3014 status += MXL_SetGPIO(fe, 4, 1);
3015 status += MXL_SetGPIO(fe, 1, 0);
3016 status += MXL_SetGPIO(fe, 3, 0);
3018 if (state->
RF_IN >= 240000000 &&
3019 state->
RF_IN < 340000000) {
3021 status += MXL_SetGPIO(fe, 4, 0);
3022 status += MXL_SetGPIO(fe, 1, 1);
3023 status += MXL_SetGPIO(fe, 3, 0);
3025 if (state->
RF_IN >= 340000000 &&
3026 state->
RF_IN < 430000000) {
3028 status += MXL_SetGPIO(fe, 4, 0);
3029 status += MXL_SetGPIO(fe, 1, 0);
3030 status += MXL_SetGPIO(fe, 3, 1);
3032 if (state->
RF_IN >= 430000000 &&
3033 state->
RF_IN < 470000000) {
3035 status += MXL_SetGPIO(fe, 4, 1);
3036 status += MXL_SetGPIO(fe, 1, 0);
3037 status += MXL_SetGPIO(fe, 3, 1);
3039 if (state->
RF_IN >= 470000000 &&
3040 state->
RF_IN < 570000000) {
3042 status += MXL_SetGPIO(fe, 4, 0);
3043 status += MXL_SetGPIO(fe, 1, 0);
3044 status += MXL_SetGPIO(fe, 3, 1);
3046 if (state->
RF_IN >= 570000000 &&
3047 state->
RF_IN < 620000000) {
3049 status += MXL_SetGPIO(fe, 4, 0);
3050 status += MXL_SetGPIO(fe, 1, 1);
3051 status += MXL_SetGPIO(fe, 3, 1);
3053 if (state->
RF_IN >= 620000000 &&
3054 state->
RF_IN < 760000000) {
3056 status += MXL_SetGPIO(fe, 4, 0);
3057 status += MXL_SetGPIO(fe, 1, 1);
3058 status += MXL_SetGPIO(fe, 3, 1);
3060 if (state->
RF_IN >= 760000000 &&
3061 state->
RF_IN <= 900000000) {
3063 status += MXL_SetGPIO(fe, 4, 1);
3064 status += MXL_SetGPIO(fe, 1, 1);
3065 status += MXL_SetGPIO(fe, 3, 1);
3072 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
3074 if (state->
RF_IN >= 43000000 && state->
RF_IN < 174000000) {
3076 status += MXL_SetGPIO(fe, 4, 0);
3077 status += MXL_SetGPIO(fe, 1, 1);
3078 status += MXL_SetGPIO(fe, 3, 1);
3080 if (state->
RF_IN >= 174000000 && state->
RF_IN < 250000000) {
3082 status += MXL_SetGPIO(fe, 4, 0);
3083 status += MXL_SetGPIO(fe, 1, 0);
3084 status += MXL_SetGPIO(fe, 3, 1);
3086 if (state->
RF_IN >= 250000000 && state->
RF_IN < 310000000) {
3088 status += MXL_SetGPIO(fe, 4, 1);
3089 status += MXL_SetGPIO(fe, 1, 0);
3090 status += MXL_SetGPIO(fe, 3, 1);
3092 if (state->
RF_IN >= 310000000 && state->
RF_IN < 360000000) {
3094 status += MXL_SetGPIO(fe, 4, 1);
3095 status += MXL_SetGPIO(fe, 1, 0);
3096 status += MXL_SetGPIO(fe, 3, 0);
3098 if (state->
RF_IN >= 360000000 && state->
RF_IN < 470000000) {
3100 status += MXL_SetGPIO(fe, 4, 1);
3101 status += MXL_SetGPIO(fe, 1, 1);
3102 status += MXL_SetGPIO(fe, 3, 0);
3104 if (state->
RF_IN >= 470000000 && state->
RF_IN < 640000000) {
3106 status += MXL_SetGPIO(fe, 4, 1);
3107 status += MXL_SetGPIO(fe, 1, 1);
3108 status += MXL_SetGPIO(fe, 3, 0);
3110 if (state->
RF_IN >= 640000000 && state->
RF_IN <= 900000000) {
3112 status += MXL_SetGPIO(fe, 4, 1);
3113 status += MXL_SetGPIO(fe, 1, 1);
3114 status += MXL_SetGPIO(fe, 3, 1);
3121 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
3123 if (state->
RF_IN >= 43000000 && state->
RF_IN < 160000000) {
3125 status += MXL_SetGPIO(fe, 4, 0);
3126 status += MXL_SetGPIO(fe, 1, 1);
3127 status += MXL_SetGPIO(fe, 3, 1);
3129 if (state->
RF_IN >= 160000000 && state->
RF_IN < 210000000) {
3131 status += MXL_SetGPIO(fe, 4, 0);
3132 status += MXL_SetGPIO(fe, 1, 0);
3133 status += MXL_SetGPIO(fe, 3, 1);
3135 if (state->
RF_IN >= 210000000 && state->
RF_IN < 300000000) {
3137 status += MXL_SetGPIO(fe, 4, 1);
3138 status += MXL_SetGPIO(fe, 1, 0);
3139 status += MXL_SetGPIO(fe, 3, 1);
3141 if (state->
RF_IN >= 300000000 && state->
RF_IN < 390000000) {
3143 status += MXL_SetGPIO(fe, 4, 1);
3144 status += MXL_SetGPIO(fe, 1, 0);
3145 status += MXL_SetGPIO(fe, 3, 0);
3147 if (state->
RF_IN >= 390000000 && state->
RF_IN < 515000000) {
3149 status += MXL_SetGPIO(fe, 4, 1);
3150 status += MXL_SetGPIO(fe, 1, 1);
3151 status += MXL_SetGPIO(fe, 3, 0);
3153 if (state->
RF_IN >= 515000000 && state->
RF_IN < 650000000) {
3155 status += MXL_SetGPIO(fe, 4, 1);
3156 status += MXL_SetGPIO(fe, 1, 1);
3157 status += MXL_SetGPIO(fe, 3, 0);
3159 if (state->
RF_IN >= 650000000 && state->
RF_IN <= 900000000) {
3161 status += MXL_SetGPIO(fe, 4, 1);
3162 status += MXL_SetGPIO(fe, 1, 1);
3163 status += MXL_SetGPIO(fe, 3, 1);
3170 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
3172 if (state->
RF_IN >= 43000000 && state->
RF_IN < 174000000) {
3174 status += MXL_SetGPIO(fe, 4, 0);
3175 status += MXL_SetGPIO(fe, 1, 1);
3176 status += MXL_SetGPIO(fe, 3, 1);
3178 if (state->
RF_IN >= 174000000 && state->
RF_IN < 250000000) {
3180 status += MXL_SetGPIO(fe, 4, 0);
3181 status += MXL_SetGPIO(fe, 1, 0);
3182 status += MXL_SetGPIO(fe, 3, 1);
3184 if (state->
RF_IN >= 250000000 && state->
RF_IN < 350000000) {
3186 status += MXL_SetGPIO(fe, 4, 1);
3187 status += MXL_SetGPIO(fe, 1, 0);
3188 status += MXL_SetGPIO(fe, 3, 1);
3190 if (state->
RF_IN >= 350000000 && state->
RF_IN < 400000000) {
3192 status += MXL_SetGPIO(fe, 4, 1);
3193 status += MXL_SetGPIO(fe, 1, 0);
3194 status += MXL_SetGPIO(fe, 3, 0);
3196 if (state->
RF_IN >= 400000000 && state->
RF_IN < 570000000) {
3198 status += MXL_SetGPIO(fe, 4, 1);
3199 status += MXL_SetGPIO(fe, 1, 1);
3200 status += MXL_SetGPIO(fe, 3, 0);
3202 if (state->
RF_IN >= 570000000 && state->
RF_IN < 770000000) {
3204 status += MXL_SetGPIO(fe, 4, 1);
3205 status += MXL_SetGPIO(fe, 1, 1);
3206 status += MXL_SetGPIO(fe, 3, 0);
3208 if (state->
RF_IN >= 770000000 && state->
RF_IN <= 900000000) {
3210 status += MXL_SetGPIO(fe, 4, 1);
3211 status += MXL_SetGPIO(fe, 1, 1);
3212 status += MXL_SetGPIO(fe, 3, 1);
3219 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
3221 if (state->
RF_IN >= 50000000 && state->
RF_IN < 190000000) {
3224 status += MXL_SetGPIO(fe, 4, 0);
3225 status += MXL_SetGPIO(fe, 1, 1);
3226 status += MXL_SetGPIO(fe, 3, 1);
3228 if (state->
RF_IN >= 190000000 && state->
RF_IN < 280000000) {
3230 status += MXL_SetGPIO(fe, 4, 0);
3231 status += MXL_SetGPIO(fe, 1, 0);
3232 status += MXL_SetGPIO(fe, 3, 1);
3234 if (state->
RF_IN >= 280000000 && state->
RF_IN < 350000000) {
3236 status += MXL_SetGPIO(fe, 4, 1);
3237 status += MXL_SetGPIO(fe, 1, 0);
3238 status += MXL_SetGPIO(fe, 3, 1);
3240 if (state->
RF_IN >= 350000000 && state->
RF_IN < 400000000) {
3242 status += MXL_SetGPIO(fe, 4, 1);
3243 status += MXL_SetGPIO(fe, 1, 0);
3244 status += MXL_SetGPIO(fe, 3, 0);
3246 if (state->
RF_IN >= 400000000 && state->
RF_IN < 470000000) {
3248 status += MXL_SetGPIO(fe, 4, 1);
3249 status += MXL_SetGPIO(fe, 1, 0);
3250 status += MXL_SetGPIO(fe, 3, 1);
3252 if (state->
RF_IN >= 470000000 && state->
RF_IN < 640000000) {
3254 status += MXL_SetGPIO(fe, 4, 1);
3255 status += MXL_SetGPIO(fe, 1, 1);
3256 status += MXL_SetGPIO(fe, 3, 0);
3258 if (state->
RF_IN >= 640000000 && state->
RF_IN < 820000000) {
3260 status += MXL_SetGPIO(fe, 4, 1);
3261 status += MXL_SetGPIO(fe, 1, 1);
3262 status += MXL_SetGPIO(fe, 3, 0);
3264 if (state->
RF_IN >= 820000000 && state->
RF_IN <= 900000000) {
3266 status += MXL_SetGPIO(fe, 4, 1);
3267 status += MXL_SetGPIO(fe, 1, 1);
3268 status += MXL_SetGPIO(fe, 3, 1);
3275 status += MXL_ControlWrite(fe,
DAC_DIN_B, 0);
3278 if (state->
RF_IN >= 471000000 &&
3279 (state->
RF_IN - 471000000)%6000000 != 0) {
3282 status += MXL_SetGPIO(fe, 3, 1);
3283 status += MXL_SetGPIO(fe, 1, 1);
3284 status += MXL_SetGPIO(fe, 4, 1);
3311 if (state->
RF_IN >= 43000000 && state->
RF_IN < 174000000) {
3314 status += MXL_SetGPIO(fe, 4, 0);
3315 status += MXL_SetGPIO(fe, 1, 1);
3316 status += MXL_SetGPIO(fe, 3, 1);
3318 if (state->
RF_IN >= 174000000 && state->
RF_IN < 250000000) {
3320 status += MXL_SetGPIO(fe, 4, 0);
3321 status += MXL_SetGPIO(fe, 1, 0);
3322 status += MXL_SetGPIO(fe, 3, 1);
3324 if (state->
RF_IN >= 250000000 && state->
RF_IN < 350000000) {
3326 status += MXL_SetGPIO(fe, 4, 1);
3327 status += MXL_SetGPIO(fe, 1, 0);
3328 status += MXL_SetGPIO(fe, 3, 1);
3330 if (state->
RF_IN >= 350000000 && state->
RF_IN < 400000000) {
3332 status += MXL_SetGPIO(fe, 4, 1);
3333 status += MXL_SetGPIO(fe, 1, 0);
3334 status += MXL_SetGPIO(fe, 3, 0);
3336 if (state->
RF_IN >= 400000000 && state->
RF_IN < 570000000) {
3338 status += MXL_SetGPIO(fe, 4, 1);
3339 status += MXL_SetGPIO(fe, 1, 1);
3340 status += MXL_SetGPIO(fe, 3, 0);
3342 if (state->
RF_IN >= 570000000 && state->
RF_IN < 770000000) {
3344 status += MXL_SetGPIO(fe, 4, 1);
3345 status += MXL_SetGPIO(fe, 1, 1);
3346 status += MXL_SetGPIO(fe, 3, 0);
3348 if (state->
RF_IN >= 770000000 && state->
RF_IN <= 900000000) {
3350 status += MXL_SetGPIO(fe, 4, 1);
3351 status += MXL_SetGPIO(fe, 1, 1);
3352 status += MXL_SetGPIO(fe, 3, 1);
3364 status += MXL_ControlWrite(fe,
GPIO_1B, GPIO_Val ? 0 : 1);
3368 if (GPIO_Num == 3) {
3369 if (GPIO_Val == 1) {
3370 status += MXL_ControlWrite(fe,
GPIO_3, 0);
3371 status += MXL_ControlWrite(fe,
GPIO_3B, 0);
3373 if (GPIO_Val == 0) {
3374 status += MXL_ControlWrite(fe,
GPIO_3, 1);
3375 status += MXL_ControlWrite(fe,
GPIO_3B, 1);
3377 if (GPIO_Val == 3) {
3378 status += MXL_ControlWrite(fe,
GPIO_3, 0);
3379 status += MXL_ControlWrite(fe,
GPIO_3B, 1);
3382 if (GPIO_Num == 4) {
3383 if (GPIO_Val == 1) {
3384 status += MXL_ControlWrite(fe,
GPIO_4, 0);
3385 status += MXL_ControlWrite(fe,
GPIO_4B, 0);
3387 if (GPIO_Val == 0) {
3388 status += MXL_ControlWrite(fe,
GPIO_4, 1);
3389 status += MXL_ControlWrite(fe,
GPIO_4B, 1);
3391 if (GPIO_Val == 3) {
3392 status += MXL_ControlWrite(fe,
GPIO_4, 0);
3393 status += MXL_ControlWrite(fe,
GPIO_4B, 1);
3406 status += MXL_ControlWrite_Group(fe, ControlNum, value, 1);
3408 status += MXL_ControlWrite_Group(fe, ControlNum, value, 2);
3409 #ifdef _MXL_INTERNAL
3411 status += MXL_ControlWrite_Group(fe, ControlNum, value, 3);
3424 if (controlGroup == 1) {
3428 if (controlNum == state->
Init_Ctrl[i].Ctrl_Num) {
3431 if (value < highLimit) {
3432 for (j = 0; j < state->
Init_Ctrl[
i].size; j++) {
3434 MXL_RegWriteBit(fe, (
u8)(state->
Init_Ctrl[i].addr[j]),
3436 (
u8)((value>>j) & 0x01));
3439 for (k = 0; k < state->
Init_Ctrl[
i].size; k++)
3440 ctrlVal += state->
Init_Ctrl[i].val[k] * (1 << k);
3446 if (controlGroup == 2) {
3450 if (controlNum == state->
CH_Ctrl[i].Ctrl_Num) {
3452 highLimit = 1 << state->
CH_Ctrl[
i].size;
3453 if (value < highLimit) {
3454 for (j = 0; j < state->
CH_Ctrl[
i].size; j++) {
3455 state->
CH_Ctrl[
i].val[
j] = (
u8)((value >> j) & 0x01);
3456 MXL_RegWriteBit(fe, (
u8)(state->
CH_Ctrl[i].addr[j]),
3458 (
u8)((value>>j) & 0x01));
3461 for (k = 0; k < state->
CH_Ctrl[
i].size; k++)
3462 ctrlVal += state->
CH_Ctrl[i].val[k] * (1 << k);
3468 #ifdef _MXL_INTERNAL
3469 if (controlGroup == 3) {
3473 if (controlNum == state->
MXL_Ctrl[i].Ctrl_Num) {
3475 highLimit = (1 << state->
MXL_Ctrl[
i].size);
3476 if (value < highLimit) {
3477 for (j = 0; j < state->
MXL_Ctrl[
i].size; j++) {
3479 MXL_RegWriteBit(fe, (
u8)(state->
MXL_Ctrl[i].addr[j]),
3481 (
u8)((value>>j) & 0x01));
3484 for (k = 0; k < state->
MXL_Ctrl[
i].size; k++)
3502 for (i = 0; i < 104; i++) {
3503 if (RegNum == state->
TunerRegs[i].Reg_Num) {
3520 if (controlNum == state->
Init_Ctrl[i].Ctrl_Num) {
3523 for (k = 0; k < state->
Init_Ctrl[
i].size; k++)
3524 ctrlVal += state->
Init_Ctrl[i].val[k] * (1<<k);
3532 if (controlNum == state->
CH_Ctrl[i].Ctrl_Num) {
3535 for (k = 0; k < state->
CH_Ctrl[
i].size; k++)
3536 ctrlVal += state->
CH_Ctrl[i].val[k] * (1 << k);
3543 #ifdef _MXL_INTERNAL
3546 if (controlNum == state->
MXL_Ctrl[i].Ctrl_Num) {
3549 for (k = 0; k < state->
MXL_Ctrl[
i].size; k++)
3550 ctrlVal += state->
MXL_Ctrl[i].val[k] * (1<<k);
3566 const u8 AND_MAP[8] = {
3567 0xFE, 0xFD, 0xFB, 0xF7,
3568 0xEF, 0xDF, 0xBF, 0x7F } ;
3570 const u8 OR_MAP[8] = {
3571 0x01, 0x02, 0x04, 0x08,
3572 0x10, 0x20, 0x40, 0x80 } ;
3575 if (state->
TunerRegs[i].Reg_Num == address) {
3585 static u32 MXL_Ceiling(
u32 value,
u32 resolution)
3587 return value / resolution + (value % resolution > 0 ? 1 : 0);
3598 11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73,
3599 76, 77, 91, 134, 135, 137, 147,
3600 156, 166, 167, 168, 25 };
3604 status += MXL_BlockInit(fe);
3606 for (i = 0 ; i < *
count; i++) {
3607 RegNum[
i] = RegAddr[
i];
3608 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3621 #ifdef _MXL_PRODUCTION
3622 u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106,
3623 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
3625 u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106,
3626 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
3636 for (i = 0 ; i < *
count; i++) {
3637 RegNum[
i] = RegAddr[
i];
3638 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3645 u8 *RegVal,
int *count)
3650 u8 RegAddr[] = {43, 136};
3654 for (i = 0; i < *
count; i++) {
3655 RegNum[
i] = RegAddr[
i];
3656 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3662 static u16 MXL_GetMasterControl(
u8 *MasterReg,
int state)
3676 #ifdef _MXL_PRODUCTION
3682 if (VCO_Range == 1) {
3683 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3686 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3695 status += MXL_ControlWrite(fe,
3703 status += MXL_ControlWrite(fe,
3706 if (state->
Mode == 1) {
3710 status += MXL_ControlWrite(fe,
3715 if (VCO_Range == 2) {
3716 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3719 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3731 status += MXL_ControlWrite(fe,
3739 status += MXL_ControlWrite(fe,
3742 if (state->
Mode == 1) {
3746 status += MXL_ControlWrite(fe,
3751 if (VCO_Range == 3) {
3752 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3755 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3767 status += MXL_ControlWrite(fe,
3775 status += MXL_ControlWrite(fe,
3778 if (state->
Mode == 1) {
3782 status += MXL_ControlWrite(fe,
3787 if (VCO_Range == 4) {
3788 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3791 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3803 status += MXL_ControlWrite(fe,
3811 status += MXL_ControlWrite(fe,
3814 if (state->
Mode == 1) {
3818 status += MXL_ControlWrite(fe,
3832 status += MXL_ControlWrite(fe, DN_BYPASS_AGC_I2C, 1);
3850 u8 buf[2] = { 0xff, 0x00 };
3852 .buf =
buf, .len = 2 };
3854 dprintk(2,
"%s()\n", __func__);
3856 if (fe->
ops.i2c_gate_ctrl)
3857 fe->
ops.i2c_gate_ctrl(fe, 1);
3864 if (fe->
ops.i2c_gate_ctrl)
3865 fe->
ops.i2c_gate_ctrl(fe, 0);
3878 .buf =
buf, .len = 3 };
3883 dprintk(2,
"%s(0x%x, 0x%x, 0x%x)\n", __func__, reg, val, msg.
addr);
3892 static int mxl5005s_writeregs(
struct dvb_frontend *fe,
u8 *addrtable,
3897 if (fe->
ops.i2c_gate_ctrl)
3898 fe->
ops.i2c_gate_ctrl(fe, 1);
3900 for (i = 0 ; i < len-1; i++) {
3901 ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 0);
3906 ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 1);
3908 if (fe->
ops.i2c_gate_ctrl)
3909 fe->
ops.i2c_gate_ctrl(fe, 0);
3918 dprintk(1,
"%s()\n", __func__);
3923 static int mxl5005s_reconfigure(
struct dvb_frontend *fe,
u32 mod_type,
3932 dprintk(1,
"%s(type=%d, bw=%d)\n", __func__, mod_type, bandwidth);
3939 ByteTable[0] |= state->
config->AgcMasterByte;
3941 mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
3943 mxl5005s_AssignTunerMode(fe, mod_type, bandwidth);
3946 MXL_GetInitRegister(fe, AddrTable, ByteTable, &TableLen);
3948 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
3953 static int mxl5005s_AssignTunerMode(
struct dvb_frontend *fe,
u32 mod_type,
3959 InitTunerControls(fe);
3962 MXL5005_TunerConfig(
3982 static int mxl5005s_set_params(
struct dvb_frontend *fe)
3988 u32 req_mode, req_bw = 0;
3991 dprintk(1,
"%s()\n", __func__);
4024 ret = mxl5005s_reconfigure(fe, req_mode, req_bw);
4031 ret = mxl5005s_SetRfFreqHz(fe, c->
frequency);
4040 dprintk(1,
"%s()\n", __func__);
4042 *frequency = state->
RF_IN;
4050 dprintk(1,
"%s()\n", __func__);
4060 dprintk(1,
"%s()\n", __func__);
4062 *frequency = state->
IF_OUT;
4069 dprintk(1,
"%s()\n", __func__);
4077 .name =
"MaxLinear MXL5005S",
4078 .frequency_min = 48000000,
4079 .frequency_max = 860000000,
4080 .frequency_step = 50000,
4083 .release = mxl5005s_release,
4084 .init = mxl5005s_init,
4086 .set_params = mxl5005s_set_params,
4087 .get_frequency = mxl5005s_get_frequency,
4088 .get_bandwidth = mxl5005s_get_bandwidth,
4089 .get_if_frequency = mxl5005s_get_if_frequency,
4097 dprintk(1,
"%s()\n", __func__);
4110 memcpy(&fe->
ops.tuner_ops, &mxl5005s_tuner_ops,