diff options
author | Olivier Grenie <olivier.grenie@dibcom.fr> | 2011-01-04 03:42:19 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 19:31:43 -0400 |
commit | be9bae10ffa5aeeef051e893c3b15a5d10eb657d (patch) | |
tree | 2e7821fc885fe081bbc9b2f49673f5dfad67fe2b /drivers/media/dvb | |
parent | 713d54a8bd812229410a1902cd9b332a2a27af9f (diff) |
[media] DiB0700: add support for several board-layouts
This patchs adds support for DiBcom's NIM8096MD, NIM9090M, NIM9090MD,
NIM7090, TFE7090PVR (no diversity) reference designs.
Signed-off-by: Olivier Grenie <olivier.grenie@dibcom.fr>
Signed-off-by: Patrick Boettcher <patrick.boettcher@dibcom.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/dib0700_core.c | 4 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dib0700_devices.c | 1335 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 5 |
3 files changed, 1247 insertions, 97 deletions
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c index ebda77dde97e..9ab57132b444 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_core.c +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c | |||
@@ -186,7 +186,7 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg, | |||
186 | msg[i].len, | 186 | msg[i].len, |
187 | USB_CTRL_GET_TIMEOUT); | 187 | USB_CTRL_GET_TIMEOUT); |
188 | if (result < 0) { | 188 | if (result < 0) { |
189 | err("i2c read error (status = %d)\n", result); | 189 | deb_info("i2c read error (status = %d)\n", result); |
190 | break; | 190 | break; |
191 | } | 191 | } |
192 | 192 | ||
@@ -215,7 +215,7 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg, | |||
215 | 0, 0, buf, msg[i].len + 4, | 215 | 0, 0, buf, msg[i].len + 4, |
216 | USB_CTRL_GET_TIMEOUT); | 216 | USB_CTRL_GET_TIMEOUT); |
217 | if (result < 0) { | 217 | if (result < 0) { |
218 | err("i2c write error (status = %d)\n", result); | 218 | deb_info("i2c write error (status = %d)\n", result); |
219 | break; | 219 | break; |
220 | } | 220 | } |
221 | } | 221 | } |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index 193cdb77b76a..2b919034db87 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "dib7000m.h" | 12 | #include "dib7000m.h" |
13 | #include "dib7000p.h" | 13 | #include "dib7000p.h" |
14 | #include "dib8000.h" | 14 | #include "dib8000.h" |
15 | #include "dib9000.h" | ||
15 | #include "mt2060.h" | 16 | #include "mt2060.h" |
16 | #include "mt2266.h" | 17 | #include "mt2266.h" |
17 | #include "tuner-xc2028.h" | 18 | #include "tuner-xc2028.h" |
@@ -29,6 +30,7 @@ MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplif | |||
29 | 30 | ||
30 | struct dib0700_adapter_state { | 31 | struct dib0700_adapter_state { |
31 | int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *); | 32 | int (*set_param_save) (struct dvb_frontend *, struct dvb_frontend_parameters *); |
33 | const struct firmware *frontend_firmware; | ||
32 | }; | 34 | }; |
33 | 35 | ||
34 | /* Hauppauge Nova-T 500 (aka Bristol) | 36 | /* Hauppauge Nova-T 500 (aka Bristol) |
@@ -1243,13 +1245,13 @@ static int dib807x_tuner_attach(struct dvb_usb_adapter *adap) | |||
1243 | static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index, | 1245 | static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index, |
1244 | u16 pid, int onoff) | 1246 | u16 pid, int onoff) |
1245 | { | 1247 | { |
1246 | return dib8000_pid_filter(adapter->fe, index, pid, onoff); | 1248 | return dib8000_pid_filter(adapter->fe, index, pid, onoff); |
1247 | } | 1249 | } |
1248 | 1250 | ||
1249 | static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter, | 1251 | static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter, |
1250 | int onoff) | 1252 | int onoff) |
1251 | { | 1253 | { |
1252 | return dib8000_pid_filter_ctrl(adapter->fe, onoff); | 1254 | return dib8000_pid_filter_ctrl(adapter->fe, onoff); |
1253 | } | 1255 | } |
1254 | 1256 | ||
1255 | /* STK807x */ | 1257 | /* STK807x */ |
@@ -1321,11 +1323,11 @@ static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap) | |||
1321 | 1323 | ||
1322 | /* STK8096GP */ | 1324 | /* STK8096GP */ |
1323 | struct dibx000_agc_config dib8090_agc_config[2] = { | 1325 | struct dibx000_agc_config dib8090_agc_config[2] = { |
1324 | { | 1326 | { |
1325 | BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND, | 1327 | BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND, |
1326 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, | 1328 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, |
1327 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, | 1329 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, |
1328 | * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ | 1330 | * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ |
1329 | (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | 1331 | (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
1330 | | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), | 1332 | | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), |
1331 | 1333 | ||
@@ -1362,12 +1364,12 @@ struct dibx000_agc_config dib8090_agc_config[2] = { | |||
1362 | 51, | 1364 | 51, |
1363 | 1365 | ||
1364 | 0, | 1366 | 0, |
1365 | }, | 1367 | }, |
1366 | { | 1368 | { |
1367 | BAND_CBAND, | 1369 | BAND_CBAND, |
1368 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, | 1370 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, |
1369 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, | 1371 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, |
1370 | * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ | 1372 | * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ |
1371 | (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | 1373 | (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
1372 | | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), | 1374 | | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), |
1373 | 1375 | ||
@@ -1404,98 +1406,117 @@ struct dibx000_agc_config dib8090_agc_config[2] = { | |||
1404 | 51, | 1406 | 51, |
1405 | 1407 | ||
1406 | 0, | 1408 | 0, |
1407 | } | 1409 | } |
1408 | }; | 1410 | }; |
1409 | 1411 | ||
1410 | static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = { | 1412 | static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = { |
1411 | 54000, 13500, | 1413 | 54000, 13500, |
1412 | 1, 18, 3, 1, 0, | 1414 | 1, 18, 3, 1, 0, |
1413 | 0, 0, 1, 1, 2, | 1415 | 0, 0, 1, 1, 2, |
1414 | (3 << 14) | (1 << 12) | (599 << 0), | 1416 | (3 << 14) | (1 << 12) | (599 << 0), |
1415 | (0 << 25) | 0, | 1417 | (0 << 25) | 0, |
1416 | 20199727, | 1418 | 20199727, |
1417 | 12000000, | 1419 | 12000000, |
1418 | }; | 1420 | }; |
1419 | 1421 | ||
1420 | static int dib8090_get_adc_power(struct dvb_frontend *fe) | 1422 | static int dib8090_get_adc_power(struct dvb_frontend *fe) |
1421 | { | 1423 | { |
1422 | return dib8000_get_adc_power(fe, 1); | 1424 | return dib8000_get_adc_power(fe, 1); |
1423 | } | 1425 | } |
1424 | 1426 | ||
1425 | static struct dib8000_config dib809x_dib8000_config = { | 1427 | static struct dib8000_config dib809x_dib8000_config[2] = { |
1426 | .output_mpeg2_in_188_bytes = 1, | 1428 | { |
1427 | 1429 | .output_mpeg2_in_188_bytes = 1, | |
1428 | .agc_config_count = 2, | 1430 | |
1429 | .agc = dib8090_agc_config, | 1431 | .agc_config_count = 2, |
1430 | .agc_control = dib0090_dcc_freq, | 1432 | .agc = dib8090_agc_config, |
1431 | .pll = &dib8090_pll_config_12mhz, | 1433 | .agc_control = dib0090_dcc_freq, |
1432 | .tuner_is_baseband = 1, | 1434 | .pll = &dib8090_pll_config_12mhz, |
1433 | 1435 | .tuner_is_baseband = 1, | |
1434 | .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, | 1436 | |
1435 | .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, | 1437 | .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, |
1436 | .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, | 1438 | .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, |
1437 | 1439 | .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, | |
1438 | .hostbus_diversity = 1, | 1440 | |
1439 | .div_cfg = 0x31, | 1441 | .hostbus_diversity = 1, |
1440 | .output_mode = OUTMODE_MPEG2_FIFO, | 1442 | .div_cfg = 0x31, |
1441 | .drives = 0x2d98, | 1443 | .output_mode = OUTMODE_MPEG2_FIFO, |
1442 | .diversity_delay = 144, | 1444 | .drives = 0x2d98, |
1443 | .refclksel = 3, | 1445 | .diversity_delay = 48, |
1446 | .refclksel = 3, | ||
1447 | },{ | ||
1448 | .output_mpeg2_in_188_bytes = 1, | ||
1449 | |||
1450 | .agc_config_count = 2, | ||
1451 | .agc = dib8090_agc_config, | ||
1452 | .agc_control = dib0090_dcc_freq, | ||
1453 | .pll = &dib8090_pll_config_12mhz, | ||
1454 | .tuner_is_baseband = 1, | ||
1455 | |||
1456 | .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, | ||
1457 | .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, | ||
1458 | .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, | ||
1459 | |||
1460 | .hostbus_diversity = 1, | ||
1461 | .div_cfg = 0x31, | ||
1462 | .output_mode = OUTMODE_DIVERSITY, | ||
1463 | .drives = 0x2d08, | ||
1464 | .diversity_delay = 1, | ||
1465 | .refclksel = 3, | ||
1466 | } | ||
1467 | }; | ||
1468 | |||
1469 | static struct dib0090_wbd_slope dib8090_wbd_table[] = { | ||
1470 | /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */ | ||
1471 | { 120, 0, 500, 0, 500, 4 }, /* CBAND */ | ||
1472 | { 170, 0, 450, 0, 450, 4 }, /* CBAND */ | ||
1473 | { 380, 48, 373, 28, 259, 6 }, /* VHF */ | ||
1474 | { 860, 34, 700, 36, 616, 6 }, /* high UHF */ | ||
1475 | { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */ | ||
1444 | }; | 1476 | }; |
1445 | 1477 | ||
1446 | static struct dib0090_config dib809x_dib0090_config = { | 1478 | static struct dib0090_config dib809x_dib0090_config = { |
1447 | .io.pll_bypass = 1, | 1479 | .io.pll_bypass = 1, |
1448 | .io.pll_range = 1, | 1480 | .io.pll_range = 1, |
1449 | .io.pll_prediv = 1, | 1481 | .io.pll_prediv = 1, |
1450 | .io.pll_loopdiv = 20, | 1482 | .io.pll_loopdiv = 20, |
1451 | .io.adc_clock_ratio = 8, | 1483 | .io.adc_clock_ratio = 8, |
1452 | .io.pll_int_loop_filt = 0, | 1484 | .io.pll_int_loop_filt = 0, |
1453 | .io.clock_khz = 12000, | 1485 | .io.clock_khz = 12000, |
1454 | .reset = dib80xx_tuner_reset, | 1486 | .reset = dib80xx_tuner_reset, |
1455 | .sleep = dib80xx_tuner_sleep, | 1487 | .sleep = dib80xx_tuner_sleep, |
1456 | .clkouttobamse = 1, | 1488 | .clkouttobamse = 1, |
1457 | .analog_output = 1, | 1489 | .analog_output = 1, |
1458 | .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS, | 1490 | .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS, |
1459 | .wbd_vhf_offset = 100, | 1491 | .use_pwm_agc = 1, |
1460 | .wbd_cband_offset = 450, | 1492 | .clkoutdrive = 1, |
1461 | .use_pwm_agc = 1, | 1493 | .get_adc_power = dib8090_get_adc_power, |
1462 | .clkoutdrive = 1, | 1494 | .freq_offset_khz_uhf = -63, |
1463 | .get_adc_power = dib8090_get_adc_power, | ||
1464 | .freq_offset_khz_uhf = 0, | ||
1465 | .freq_offset_khz_vhf = -143, | 1495 | .freq_offset_khz_vhf = -143, |
1496 | .wbd = dib8090_wbd_table, | ||
1497 | .fref_clock_ratio = 6, | ||
1466 | }; | 1498 | }; |
1467 | 1499 | ||
1468 | static int dib8096_set_param_override(struct dvb_frontend *fe, | 1500 | static int dib8096_set_param_override(struct dvb_frontend *fe, |
1469 | struct dvb_frontend_parameters *fep) | 1501 | struct dvb_frontend_parameters *fep) |
1470 | { | 1502 | { |
1471 | struct dvb_usb_adapter *adap = fe->dvb->priv; | 1503 | struct dvb_usb_adapter *adap = fe->dvb->priv; |
1472 | struct dib0700_adapter_state *state = adap->priv; | 1504 | struct dib0700_adapter_state *state = adap->priv; |
1473 | u8 band = BAND_OF_FREQUENCY(fep->frequency/1000); | 1505 | u8 band = BAND_OF_FREQUENCY(fep->frequency/1000); |
1474 | u16 offset; | 1506 | u16 target; |
1475 | int ret = 0; | 1507 | int ret = 0; |
1476 | enum frontend_tune_state tune_state = CT_SHUTDOWN; | 1508 | enum frontend_tune_state tune_state = CT_SHUTDOWN; |
1477 | u16 ltgain, rf_gain_limit; | 1509 | u16 ltgain, rf_gain_limit; |
1478 | 1510 | ||
1479 | ret = state->set_param_save(fe, fep); | 1511 | ret = state->set_param_save(fe, fep); |
1480 | if (ret < 0) | 1512 | if (ret < 0) |
1481 | return ret; | 1513 | return ret; |
1482 | 1514 | ||
1483 | switch (band) { | 1515 | target = (dib0090_get_wbd_offset(fe) * 8 * 18 / 33 + 1) / 2; |
1484 | case BAND_VHF: | 1516 | dib8000_set_wbd_ref(fe, target); |
1485 | offset = 100; | 1517 | |
1486 | break; | 1518 | |
1487 | case BAND_UHF: | 1519 | if (band == BAND_CBAND) { |
1488 | offset = 550; | ||
1489 | break; | ||
1490 | default: | ||
1491 | offset = 0; | ||
1492 | break; | ||
1493 | } | ||
1494 | offset += (dib0090_get_wbd_offset(fe) * 8 * 18 / 33 + 1) / 2; | ||
1495 | dib8000_set_wbd_ref(fe, offset); | ||
1496 | |||
1497 | |||
1498 | if (band == BAND_CBAND) { | ||
1499 | deb_info("tuning in CBAND - soft-AGC startup\n"); | 1520 | deb_info("tuning in CBAND - soft-AGC startup\n"); |
1500 | /* TODO specific wbd target for dib0090 - needed for startup ? */ | 1521 | /* TODO specific wbd target for dib0090 - needed for startup ? */ |
1501 | dib0090_set_tune_state(fe, CT_AGC_START); | 1522 | dib0090_set_tune_state(fe, CT_AGC_START); |
@@ -1514,25 +1535,25 @@ static int dib8096_set_param_override(struct dvb_frontend *fe, | |||
1514 | dib0090_pwm_gain_reset(fe); | 1535 | dib0090_pwm_gain_reset(fe); |
1515 | dib8000_pwm_agc_reset(fe); | 1536 | dib8000_pwm_agc_reset(fe); |
1516 | dib8000_set_tune_state(fe, CT_DEMOD_START); | 1537 | dib8000_set_tune_state(fe, CT_DEMOD_START); |
1517 | } else { | 1538 | } else { |
1518 | deb_info("not tuning in CBAND - standard AGC startup\n"); | 1539 | deb_info("not tuning in CBAND - standard AGC startup\n"); |
1519 | dib0090_pwm_gain_reset(fe); | 1540 | dib0090_pwm_gain_reset(fe); |
1520 | } | 1541 | } |
1521 | 1542 | ||
1522 | return 0; | 1543 | return 0; |
1523 | } | 1544 | } |
1524 | 1545 | ||
1525 | static int dib809x_tuner_attach(struct dvb_usb_adapter *adap) | 1546 | static int dib809x_tuner_attach(struct dvb_usb_adapter *adap) |
1526 | { | 1547 | { |
1527 | struct dib0700_adapter_state *st = adap->priv; | 1548 | struct dib0700_adapter_state *st = adap->priv; |
1528 | struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1); | 1549 | struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1); |
1529 | 1550 | ||
1530 | if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &dib809x_dib0090_config) == NULL) | 1551 | if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &dib809x_dib0090_config) == NULL) |
1531 | return -ENODEV; | 1552 | return -ENODEV; |
1532 | 1553 | ||
1533 | st->set_param_save = adap->fe->ops.tuner_ops.set_params; | 1554 | st->set_param_save = adap->fe->ops.tuner_ops.set_params; |
1534 | adap->fe->ops.tuner_ops.set_params = dib8096_set_param_override; | 1555 | adap->fe->ops.tuner_ops.set_params = dib8096_set_param_override; |
1535 | return 0; | 1556 | return 0; |
1536 | } | 1557 | } |
1537 | 1558 | ||
1538 | static int stk809x_frontend_attach(struct dvb_usb_adapter *adap) | 1559 | static int stk809x_frontend_attach(struct dvb_usb_adapter *adap) |
@@ -1554,11 +1575,931 @@ static int stk809x_frontend_attach(struct dvb_usb_adapter *adap) | |||
1554 | 1575 | ||
1555 | dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80); | 1576 | dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80); |
1556 | 1577 | ||
1557 | adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config); | 1578 | adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]); |
1579 | |||
1580 | return adap->fe == NULL ? -ENODEV : 0; | ||
1581 | } | ||
1582 | |||
1583 | static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap) | ||
1584 | { | ||
1585 | struct dib0700_adapter_state *st = adap->priv; | ||
1586 | struct i2c_adapter *tun_i2c; | ||
1587 | struct dvb_frontend *fe_slave = dib8000_get_slave_frontend(adap->fe, 1); | ||
1588 | |||
1589 | if (fe_slave) { | ||
1590 | tun_i2c = dib8000_get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1); | ||
1591 | if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL) | ||
1592 | return -ENODEV; | ||
1593 | fe_slave->dvb = adap->fe->dvb; | ||
1594 | fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override; | ||
1595 | } | ||
1596 | tun_i2c = dib8000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1); | ||
1597 | if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &dib809x_dib0090_config) == NULL) | ||
1598 | return -ENODEV; | ||
1599 | |||
1600 | st->set_param_save = adap->fe->ops.tuner_ops.set_params; | ||
1601 | adap->fe->ops.tuner_ops.set_params = dib8096_set_param_override; | ||
1602 | |||
1603 | return 0; | ||
1604 | } | ||
1605 | |||
1606 | static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap) | ||
1607 | { | ||
1608 | struct dvb_frontend *fe_slave; | ||
1609 | |||
1610 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); | ||
1611 | msleep(10); | ||
1612 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
1613 | msleep(1000); | ||
1614 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
1615 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
1616 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
1617 | |||
1618 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
1619 | |||
1620 | dib0700_ctrl_clock(adap->dev, 72, 1); | ||
1621 | |||
1622 | msleep(10); | ||
1623 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
1624 | msleep(10); | ||
1625 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
1626 | |||
1627 | dib8000_i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80); | ||
1628 | |||
1629 | adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]); | ||
1630 | if (adap->fe == NULL) | ||
1631 | return -ENODEV; | ||
1632 | |||
1633 | fe_slave = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]); | ||
1634 | dib8000_set_slave_frontend(adap->fe, fe_slave); | ||
1635 | |||
1636 | return fe_slave == NULL ? -ENODEV : 0; | ||
1637 | } | ||
1638 | |||
1639 | /* STK9090M */ | ||
1640 | static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff) | ||
1641 | { | ||
1642 | return dib9000_fw_pid_filter(adapter->fe, index, pid, onoff); | ||
1643 | } | ||
1644 | |||
1645 | static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff) | ||
1646 | { | ||
1647 | return dib9000_fw_pid_filter_ctrl(adapter->fe, onoff); | ||
1648 | } | ||
1649 | |||
1650 | static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff) | ||
1651 | { | ||
1652 | return dib9000_set_gpio(fe, 5, 0, !onoff); | ||
1653 | } | ||
1654 | |||
1655 | static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff) | ||
1656 | { | ||
1657 | return dib9000_set_gpio(fe, 0, 0, onoff); | ||
1658 | } | ||
1659 | |||
1660 | static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len) | ||
1661 | { | ||
1662 | u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 }; | ||
1663 | u8 rb[2]; | ||
1664 | struct i2c_msg msg[2] = { | ||
1665 | {.addr = 0x1e >> 1,.flags = 0,.buf = wb,.len = 2}, | ||
1666 | {.addr = 0x1e >> 1,.flags = I2C_M_RD,.buf = rb,.len = 2}, | ||
1667 | }; | ||
1668 | u8 index_data; | ||
1669 | |||
1670 | dibx000_i2c_set_speed(i2c, 250); | ||
1671 | |||
1672 | if (i2c_transfer(i2c, msg, 2) != 2) | ||
1673 | return -EIO; | ||
1674 | |||
1675 | switch (rb[0] << 8 | rb[1]) { | ||
1676 | case 0: | ||
1677 | deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n"); | ||
1678 | return -EIO; | ||
1679 | case 1: | ||
1680 | deb_info("Found DiB0170 rev2"); | ||
1681 | break; | ||
1682 | case 2: | ||
1683 | deb_info("Found DiB0190 rev2"); | ||
1684 | break; | ||
1685 | default: | ||
1686 | deb_info("DiB01x0 not found"); | ||
1687 | return -EIO; | ||
1688 | } | ||
1689 | |||
1690 | for (index_data = 0; index_data < len; index_data += 2) { | ||
1691 | wb[2] = (data[index_data + 1] >> 8) & 0xff; | ||
1692 | wb[3] = (data[index_data + 1]) & 0xff; | ||
1693 | |||
1694 | if (data[index_data] == 0) { | ||
1695 | wb[0] = (data[index_data] >> 8) & 0xff; | ||
1696 | wb[1] = (data[index_data]) & 0xff; | ||
1697 | msg[0].len = 2; | ||
1698 | if (i2c_transfer(i2c, msg, 2) != 2) | ||
1699 | return -EIO; | ||
1700 | wb[2] |= rb[0]; | ||
1701 | wb[3] |= rb[1] & ~(3 << 4); | ||
1702 | } | ||
1703 | |||
1704 | wb[0] = (data[index_data ] >> 8)&0xff; | ||
1705 | wb[1] = (data[index_data ] )&0xff; | ||
1706 | msg[0].len = 4; | ||
1707 | if (i2c_transfer(i2c, &msg[0], 1) != 1) | ||
1708 | return -EIO; | ||
1709 | } | ||
1710 | return 0; | ||
1711 | } | ||
1712 | |||
1713 | static struct dib9000_config stk9090m_config = { | ||
1714 | .output_mpeg2_in_188_bytes = 1, | ||
1715 | .output_mode = OUTMODE_MPEG2_FIFO, | ||
1716 | .vcxo_timer = 279620, | ||
1717 | .timing_frequency = 20452225, | ||
1718 | .demod_clock_khz = 60000, | ||
1719 | .xtal_clock_khz = 30000, | ||
1720 | .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0), | ||
1721 | .subband = { | ||
1722 | 2, | ||
1723 | { | ||
1724 | { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */ | ||
1725 | { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */ | ||
1726 | { 0 }, | ||
1727 | }, | ||
1728 | }, | ||
1729 | .gpio_function = { | ||
1730 | { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 }, | ||
1731 | { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 }, | ||
1732 | }, | ||
1733 | }; | ||
1734 | |||
1735 | static struct dib9000_config nim9090md_config[2] = { | ||
1736 | { | ||
1737 | .output_mpeg2_in_188_bytes = 1, | ||
1738 | .output_mode = OUTMODE_MPEG2_FIFO, | ||
1739 | .vcxo_timer = 279620, | ||
1740 | .timing_frequency = 20452225, | ||
1741 | .demod_clock_khz = 60000, | ||
1742 | .xtal_clock_khz = 30000, | ||
1743 | .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0), | ||
1744 | }, { | ||
1745 | .output_mpeg2_in_188_bytes = 1, | ||
1746 | .output_mode = OUTMODE_DIVERSITY, | ||
1747 | .vcxo_timer = 279620, | ||
1748 | .timing_frequency = 20452225, | ||
1749 | .demod_clock_khz = 60000, | ||
1750 | .xtal_clock_khz = 30000, | ||
1751 | .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0), | ||
1752 | .subband = { | ||
1753 | 2, | ||
1754 | { | ||
1755 | { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */ | ||
1756 | { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */ | ||
1757 | { 0 }, | ||
1758 | }, | ||
1759 | }, | ||
1760 | .gpio_function = { | ||
1761 | { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 }, | ||
1762 | { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 }, | ||
1763 | }, | ||
1764 | } | ||
1765 | }; | ||
1766 | |||
1767 | static struct dib0090_config dib9090_dib0090_config = { | ||
1768 | .io.pll_bypass = 0, | ||
1769 | .io.pll_range = 1, | ||
1770 | .io.pll_prediv = 1, | ||
1771 | .io.pll_loopdiv = 8, | ||
1772 | .io.adc_clock_ratio = 8, | ||
1773 | .io.pll_int_loop_filt = 0, | ||
1774 | .io.clock_khz = 30000, | ||
1775 | .reset = dib90x0_tuner_reset, | ||
1776 | .sleep = dib90x0_tuner_sleep, | ||
1777 | .clkouttobamse = 0, | ||
1778 | .analog_output = 0, | ||
1779 | .use_pwm_agc = 0, | ||
1780 | .clkoutdrive = 0, | ||
1781 | .freq_offset_khz_uhf = 0, | ||
1782 | .freq_offset_khz_vhf = 0, | ||
1783 | }; | ||
1784 | |||
1785 | static struct dib0090_config nim9090md_dib0090_config[2] = { | ||
1786 | { | ||
1787 | .io.pll_bypass = 0, | ||
1788 | .io.pll_range = 1, | ||
1789 | .io.pll_prediv = 1, | ||
1790 | .io.pll_loopdiv = 8, | ||
1791 | .io.adc_clock_ratio = 8, | ||
1792 | .io.pll_int_loop_filt = 0, | ||
1793 | .io.clock_khz = 30000, | ||
1794 | .reset = dib90x0_tuner_reset, | ||
1795 | .sleep = dib90x0_tuner_sleep, | ||
1796 | .clkouttobamse = 1, | ||
1797 | .analog_output = 0, | ||
1798 | .use_pwm_agc = 0, | ||
1799 | .clkoutdrive = 0, | ||
1800 | .freq_offset_khz_uhf = 0, | ||
1801 | .freq_offset_khz_vhf = 0, | ||
1802 | },{ | ||
1803 | .io.pll_bypass = 0, | ||
1804 | .io.pll_range = 1, | ||
1805 | .io.pll_prediv = 1, | ||
1806 | .io.pll_loopdiv = 8, | ||
1807 | .io.adc_clock_ratio = 8, | ||
1808 | .io.pll_int_loop_filt = 0, | ||
1809 | .io.clock_khz = 30000, | ||
1810 | .reset = dib90x0_tuner_reset, | ||
1811 | .sleep = dib90x0_tuner_sleep, | ||
1812 | .clkouttobamse = 0, | ||
1813 | .analog_output = 0, | ||
1814 | .use_pwm_agc = 0, | ||
1815 | .clkoutdrive = 0, | ||
1816 | .freq_offset_khz_uhf = 0, | ||
1817 | .freq_offset_khz_vhf = 0, | ||
1818 | } | ||
1819 | }; | ||
1820 | |||
1821 | |||
1822 | static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap) | ||
1823 | { | ||
1824 | struct dib0700_adapter_state *state = adap->priv; | ||
1825 | struct dib0700_state *st = adap->dev->priv; | ||
1826 | u32 fw_version; | ||
1827 | |||
1828 | /* Make use of the new i2c functions from FW 1.20 */ | ||
1829 | dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL); | ||
1830 | if (fw_version >= 0x10200) | ||
1831 | st->fw_use_new_i2c_api = 1; | ||
1832 | dib0700_set_i2c_speed(adap->dev, 340); | ||
1833 | |||
1834 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
1835 | msleep(10); | ||
1836 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
1837 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
1838 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
1839 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
1840 | |||
1841 | dib0700_ctrl_clock(adap->dev, 72, 1); | ||
1842 | |||
1843 | msleep(10); | ||
1844 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
1845 | msleep(10); | ||
1846 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
1847 | |||
1848 | dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80); | ||
1849 | |||
1850 | if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) { | ||
1851 | deb_info("%s: Upload failed. (file not found?)\n", __func__); | ||
1852 | return -ENODEV; | ||
1853 | } else { | ||
1854 | deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size); | ||
1855 | } | ||
1856 | stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size; | ||
1857 | stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data; | ||
1858 | |||
1859 | adap->fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config); | ||
1860 | |||
1861 | return adap->fe == NULL ? -ENODEV : 0; | ||
1862 | } | ||
1863 | |||
1864 | static int dib9090_tuner_attach(struct dvb_usb_adapter *adap) | ||
1865 | { | ||
1866 | struct dib0700_adapter_state *state = adap->priv; | ||
1867 | struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe); | ||
1868 | u16 data_dib190[10] = { | ||
1869 | 1, 0x1374, | ||
1870 | 2, 0x01a2, | ||
1871 | 7, 0x0020, | ||
1872 | 0, 0x00ef, | ||
1873 | 8, 0x0486, | ||
1874 | }; | ||
1875 | |||
1876 | if (dvb_attach(dib0090_fw_register, adap->fe, i2c, &dib9090_dib0090_config) == NULL) | ||
1877 | return -ENODEV; | ||
1878 | i2c = dib9000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0); | ||
1879 | if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0) | ||
1880 | return -ENODEV; | ||
1881 | dib0700_set_i2c_speed(adap->dev, 2000); | ||
1882 | if (dib9000_firmware_post_pll_init(adap->fe) < 0) | ||
1883 | return -ENODEV; | ||
1884 | release_firmware(state->frontend_firmware); | ||
1885 | return 0; | ||
1886 | } | ||
1887 | |||
1888 | static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap) | ||
1889 | { | ||
1890 | struct dib0700_adapter_state *state = adap->priv; | ||
1891 | struct dib0700_state *st = adap->dev->priv; | ||
1892 | struct i2c_adapter *i2c; | ||
1893 | struct dvb_frontend *fe_slave; | ||
1894 | u32 fw_version; | ||
1895 | |||
1896 | /* Make use of the new i2c functions from FW 1.20 */ | ||
1897 | dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL); | ||
1898 | if (fw_version >= 0x10200) | ||
1899 | st->fw_use_new_i2c_api = 1; | ||
1900 | dib0700_set_i2c_speed(adap->dev, 340); | ||
1901 | |||
1902 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
1903 | msleep(10); | ||
1904 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
1905 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
1906 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
1907 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
1908 | |||
1909 | dib0700_ctrl_clock(adap->dev, 72, 1); | ||
1910 | |||
1911 | msleep(10); | ||
1912 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
1913 | msleep(10); | ||
1914 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
1915 | |||
1916 | if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) { | ||
1917 | deb_info("%s: Upload failed. (file not found?)\n", __func__); | ||
1918 | return -EIO; | ||
1919 | } else { | ||
1920 | deb_info("%s: firmware read %Zu bytes.\n", __func__, state->frontend_firmware->size); | ||
1921 | } | ||
1922 | nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size; | ||
1923 | nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data; | ||
1924 | nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size; | ||
1925 | nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data; | ||
1926 | |||
1927 | dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80); | ||
1928 | adap->fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]); | ||
1929 | |||
1930 | if (adap->fe == NULL) | ||
1931 | return -ENODEV; | ||
1932 | |||
1933 | i2c = dib9000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0); | ||
1934 | dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82); | ||
1935 | |||
1936 | fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]); | ||
1937 | dib9000_set_slave_frontend(adap->fe, fe_slave); | ||
1938 | |||
1939 | return fe_slave == NULL ? -ENODEV : 0; | ||
1940 | } | ||
1941 | |||
1942 | static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap) | ||
1943 | { | ||
1944 | struct dib0700_adapter_state *state = adap->priv; | ||
1945 | struct i2c_adapter *i2c; | ||
1946 | struct dvb_frontend *fe_slave; | ||
1947 | u16 data_dib190[10] = { | ||
1948 | 1, 0x5374, | ||
1949 | 2, 0x01ae, | ||
1950 | 7, 0x0020, | ||
1951 | 0, 0x00ef, | ||
1952 | 8, 0x0406, | ||
1953 | }; | ||
1954 | i2c = dib9000_get_tuner_interface(adap->fe); | ||
1955 | if (dvb_attach(dib0090_fw_register, adap->fe, i2c, &nim9090md_dib0090_config[0]) == NULL) | ||
1956 | return -ENODEV; | ||
1957 | i2c = dib9000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0); | ||
1958 | if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0) | ||
1959 | return -ENODEV; | ||
1960 | dib0700_set_i2c_speed(adap->dev, 2000); | ||
1961 | if (dib9000_firmware_post_pll_init(adap->fe) < 0) | ||
1962 | return -ENODEV; | ||
1963 | |||
1964 | fe_slave = dib9000_get_slave_frontend(adap->fe, 1); | ||
1965 | if (fe_slave != NULL) { | ||
1966 | i2c = dib9000_get_component_bus_interface(adap->fe); | ||
1967 | dib9000_set_i2c_adapter(fe_slave, i2c); | ||
1968 | |||
1969 | i2c = dib9000_get_tuner_interface(fe_slave); | ||
1970 | if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL) | ||
1971 | return -ENODEV; | ||
1972 | fe_slave->dvb = adap->fe->dvb; | ||
1973 | dib9000_fw_set_component_bus_speed(adap->fe, 2000); | ||
1974 | if (dib9000_firmware_post_pll_init(fe_slave) < 0) | ||
1975 | return -ENODEV; | ||
1976 | } | ||
1977 | release_firmware(state->frontend_firmware); | ||
1978 | |||
1979 | return 0; | ||
1980 | } | ||
1981 | |||
1982 | /* NIM7090 */ | ||
1983 | struct dib7090p_best_adc { | ||
1984 | u32 timf; | ||
1985 | u32 pll_loopdiv; | ||
1986 | u32 pll_prediv; | ||
1987 | }; | ||
1988 | |||
1989 | static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dib7090p_best_adc *adc) | ||
1990 | { | ||
1991 | u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1; | ||
1992 | |||
1993 | u16 xtal = 12000; | ||
1994 | u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */ | ||
1995 | u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */ | ||
1996 | u32 fdem_max = 76000; | ||
1997 | u32 fdem_min = 69500; | ||
1998 | u32 fcp = 0, fs = 0, fdem = 0; | ||
1999 | u32 harmonic_id = 0; | ||
2000 | |||
2001 | adc->pll_loopdiv = loopdiv; | ||
2002 | adc->pll_prediv = prediv; | ||
2003 | adc->timf = 0; | ||
2004 | |||
2005 | deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min); | ||
2006 | |||
2007 | /* Find Min and Max prediv */ | ||
2008 | while((xtal/max_prediv) >= fcp_min) | ||
2009 | max_prediv++; | ||
2010 | |||
2011 | max_prediv--; | ||
2012 | min_prediv = max_prediv; | ||
2013 | while((xtal/min_prediv) <= fcp_max) { | ||
2014 | min_prediv--; | ||
2015 | if(min_prediv == 1) | ||
2016 | break; | ||
2017 | } | ||
2018 | deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv); | ||
2019 | |||
2020 | min_prediv = 2; | ||
2021 | |||
2022 | for(prediv = min_prediv ; prediv < max_prediv; prediv ++) { | ||
2023 | fcp = xtal / prediv; | ||
2024 | if(fcp > fcp_min && fcp < fcp_max) { | ||
2025 | for(loopdiv = 1 ; loopdiv < 64 ; loopdiv++) { | ||
2026 | fdem = ((xtal/prediv) * loopdiv); | ||
2027 | fs = fdem / 4; | ||
2028 | /* test min/max system restrictions */ | ||
2029 | |||
2030 | if((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) { | ||
2031 | spur = 0; | ||
2032 | /* test fs harmonics positions */ | ||
2033 | for(harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) { | ||
2034 | if(((fs*harmonic_id) >= ((fe->dtv_property_cache.frequency/1000) - (fe->dtv_property_cache.bandwidth_hz/2000))) && ((fs*harmonic_id) <= ((fe->dtv_property_cache.frequency/1000) + (fe->dtv_property_cache.bandwidth_hz/2000)))) { | ||
2035 | spur = 1; | ||
2036 | break; | ||
2037 | } | ||
2038 | } | ||
2039 | |||
2040 | if(!spur) { | ||
2041 | adc->pll_loopdiv = loopdiv; | ||
2042 | adc->pll_prediv = prediv; | ||
2043 | adc->timf = 2396745143UL/fdem*(1<<9); | ||
2044 | adc->timf+= ((2396745143UL%fdem)<< 9)/fdem; | ||
2045 | deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf); | ||
2046 | break; | ||
2047 | } | ||
2048 | } | ||
2049 | } | ||
2050 | } | ||
2051 | if (!spur) | ||
2052 | break; | ||
2053 | } | ||
2054 | |||
2055 | |||
2056 | if(adc->pll_loopdiv == 0 && adc->pll_prediv == 0) { | ||
2057 | return -EINVAL; | ||
2058 | } else | ||
2059 | return 0; | ||
2060 | } | ||
2061 | |||
2062 | static int dib7090_agc_startup(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) | ||
2063 | { | ||
2064 | struct dvb_usb_adapter *adap = fe->dvb->priv; | ||
2065 | struct dib0700_adapter_state *state = adap->priv; | ||
2066 | struct dibx000_bandwidth_config pll; | ||
2067 | u16 target; | ||
2068 | struct dib7090p_best_adc adc; | ||
2069 | int ret; | ||
2070 | |||
2071 | ret = state->set_param_save(fe, fep); | ||
2072 | if (ret < 0) | ||
2073 | return ret; | ||
2074 | |||
2075 | memset(&pll, 0, sizeof(struct dibx000_bandwidth_config)); | ||
2076 | dib0090_pwm_gain_reset(fe); | ||
2077 | target = (dib0090_get_wbd_offset(fe) * 8 + 1) / 2; | ||
2078 | dib7000p_set_wbd_ref(fe, target); | ||
2079 | |||
2080 | if(dib7090p_get_best_sampling(fe, &adc) == 0) { | ||
2081 | pll.pll_ratio = adc.pll_loopdiv; | ||
2082 | pll.pll_prediv = adc.pll_prediv; | ||
2083 | |||
2084 | dib7000p_update_pll(fe, &pll); | ||
2085 | dib7000p_ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf); | ||
2086 | } | ||
2087 | return 0; | ||
2088 | } | ||
2089 | |||
2090 | static struct dib0090_wbd_slope dib7090_wbd_table[] = { | ||
2091 | { 380, 81, 850, 64, 540 ,4}, | ||
2092 | { 860, 51, 866, 21, 375 ,4}, | ||
2093 | {1700, 0, 250, 0, 100, 6}, //LBAND Predefinition , NOT tested Yet | ||
2094 | {2600, 0, 250, 0, 100, 6}, //SBAND Predefinition , NOT tested Yet | ||
2095 | { 0xFFFF, 0, 0, 0, 0 ,0}, | ||
2096 | }; | ||
2097 | |||
2098 | struct dibx000_agc_config dib7090_agc_config[2] = { | ||
2099 | { | ||
2100 | .band_caps = BAND_UHF, | ||
2101 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, | ||
2102 | * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ | ||
2103 | .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup | ||
2104 | |||
2105 | .inv_gain = 687,// inv_gain = 1/ 95.4dB // no boost, lower gain due to ramp quantification | ||
2106 | .time_stabiliz = 10, // time_stabiliz | ||
2107 | |||
2108 | .alpha_level = 0, // alpha_level | ||
2109 | .thlock = 118, // thlock | ||
2110 | |||
2111 | .wbd_inv = 0, // wbd_inv | ||
2112 | .wbd_ref = 1200, // wbd_ref | ||
2113 | .wbd_sel = 3, // wbd_sel | ||
2114 | .wbd_alpha = 5, // wbd_alpha | ||
2115 | |||
2116 | .agc1_max = 65535, // agc1_max | ||
2117 | .agc1_min = 0, // agc1_min | ||
2118 | |||
2119 | .agc2_max = 65535, // agc2_max | ||
2120 | .agc2_min = 0, // agc2_min | ||
2121 | |||
2122 | .agc1_pt1 = 0, // agc1_pt1 | ||
2123 | .agc1_pt2 = 32, // agc1_pt2 | ||
2124 | .agc1_pt3 = 114, // agc1_pt3 // 40.4dB | ||
2125 | .agc1_slope1 = 143, // agc1_slope1 | ||
2126 | .agc1_slope2 = 144, // agc1_slope2 | ||
2127 | .agc2_pt1 = 114, // agc2_pt1 | ||
2128 | .agc2_pt2 = 227, // agc2_pt2 | ||
2129 | .agc2_slope1 = 116, // agc2_slope1 | ||
2130 | .agc2_slope2 = 117, // agc2_slope2 | ||
2131 | |||
2132 | .alpha_mant = 18, // alpha_mant // 5Hz with 95.4dB | ||
2133 | .alpha_exp = 0, // alpha_exp | ||
2134 | .beta_mant = 20, // beta_mant | ||
2135 | .beta_exp = 59, // beta_exp | ||
2136 | |||
2137 | .perform_agc_softsplit = 0, // perform_agc_softsplit | ||
2138 | } , { | ||
2139 | .band_caps = BAND_FM | BAND_VHF | BAND_CBAND, | ||
2140 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, | ||
2141 | * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ | ||
2142 | .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup | ||
2143 | |||
2144 | .inv_gain = 732,// inv_gain = 1/ 89.5dB // no boost, lower gain due to ramp quantification | ||
2145 | .time_stabiliz = 10, // time_stabiliz | ||
2146 | |||
2147 | .alpha_level = 0, // alpha_level | ||
2148 | .thlock = 118, // thlock | ||
2149 | |||
2150 | .wbd_inv = 0, // wbd_inv | ||
2151 | .wbd_ref = 1200, // wbd_ref | ||
2152 | .wbd_sel = 3, // wbd_sel | ||
2153 | .wbd_alpha = 5, // wbd_alpha | ||
2154 | |||
2155 | .agc1_max = 65535, // agc1_max : 1 | ||
2156 | .agc1_min = 0, // agc1_min | ||
2157 | |||
2158 | .agc2_max = 65535, // agc2_max | ||
2159 | .agc2_min = 0, // agc2_min | ||
2160 | |||
2161 | .agc1_pt1 = 0, // agc1_pt1 | ||
2162 | .agc1_pt2 = 0, // agc1_pt2 | ||
2163 | .agc1_pt3 = 98, // agc1_pt3 // 34.5dB CBAND P1G + 55dB BB boost = 89.5dB | ||
2164 | .agc1_slope1 = 0, // agc1_slope1 | ||
2165 | .agc1_slope2 = 167, // agc1_slope2 = Dy/Dx * 2**6 * 2**8 = 1/98 * 2**6 *2**8 : Dy = 1 | ||
2166 | .agc1_pt1 = 98, // agc2_pt1 | ||
2167 | .agc2_pt2 = 255, // agc2_pt2 | ||
2168 | .agc2_slope1 = 104, // agc2_slope1 = Dy/Dx * 2**6 * 2**8 = 1/(255-98) * 2**6 *2**8 | ||
2169 | .agc2_slope2 = 0, // agc2_slope2 | ||
2170 | |||
2171 | .alpha_mant = 18, // alpha_mant // 5Hz with 95.4dB | ||
2172 | .alpha_exp = 0, // alpha_exp | ||
2173 | .beta_mant = 20, // beta_mant | ||
2174 | .beta_exp = 59, // beta_exp | ||
2175 | |||
2176 | .perform_agc_softsplit = 0, // perform_agc_softsplit | ||
2177 | } | ||
2178 | }; | ||
2179 | |||
2180 | static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = { | ||
2181 | 60000, 15000, // internal, sampling | ||
2182 | 1, 5, 0, 0, 0, // pll_cfg: prediv, ratio, range, reset, bypass | ||
2183 | 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo | ||
2184 | (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k | ||
2185 | (0 << 25) | 0, // ifreq = 0.000000 MHz | ||
2186 | 20452225, // timf | ||
2187 | 15000000, // xtal_hz | ||
2188 | }; | ||
2189 | |||
2190 | static struct dib7000p_config nim7090_dib7000p_config = { | ||
2191 | .output_mpeg2_in_188_bytes = 1, | ||
2192 | .hostbus_diversity = 1, | ||
2193 | .tuner_is_baseband = 1, | ||
2194 | .update_lna = NULL, | ||
2195 | |||
2196 | .agc_config_count = 2, | ||
2197 | .agc = dib7090_agc_config, | ||
2198 | |||
2199 | .bw = &dib7090_clock_config_12_mhz, | ||
2200 | |||
2201 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, | ||
2202 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, | ||
2203 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, | ||
2204 | |||
2205 | .pwm_freq_div = 0, | ||
2206 | |||
2207 | .agc_control = dib7090_agc_restart, | ||
2208 | |||
2209 | .spur_protect = 0, | ||
2210 | .disable_sample_and_hold = 0, | ||
2211 | .enable_current_mirror = 0, | ||
2212 | .diversity_delay = 0, | ||
2213 | |||
2214 | .output_mode = OUTMODE_MPEG2_FIFO, | ||
2215 | .enMpegOutput = 1, | ||
2216 | }; | ||
2217 | |||
2218 | static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = { | ||
2219 | { | ||
2220 | .output_mpeg2_in_188_bytes = 1, | ||
2221 | .hostbus_diversity = 1, | ||
2222 | .tuner_is_baseband = 1, | ||
2223 | .update_lna = NULL, | ||
2224 | |||
2225 | .agc_config_count = 2, | ||
2226 | .agc = dib7090_agc_config, | ||
2227 | |||
2228 | .bw = &dib7090_clock_config_12_mhz, | ||
2229 | |||
2230 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, | ||
2231 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, | ||
2232 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, | ||
2233 | |||
2234 | .pwm_freq_div = 0, | ||
2235 | |||
2236 | .agc_control = dib7090_agc_restart, | ||
2237 | |||
2238 | .spur_protect = 0, | ||
2239 | .disable_sample_and_hold = 0, | ||
2240 | .enable_current_mirror = 0, | ||
2241 | .diversity_delay = 0, | ||
2242 | |||
2243 | .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, | ||
2244 | .default_i2c_addr = 0x90, | ||
2245 | .enMpegOutput = 1, | ||
2246 | },{ | ||
2247 | .output_mpeg2_in_188_bytes = 1, | ||
2248 | .hostbus_diversity = 1, | ||
2249 | .tuner_is_baseband = 1, | ||
2250 | .update_lna = NULL, | ||
2251 | |||
2252 | .agc_config_count = 2, | ||
2253 | .agc = dib7090_agc_config, | ||
2254 | |||
2255 | .bw = &dib7090_clock_config_12_mhz, | ||
2256 | |||
2257 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, | ||
2258 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, | ||
2259 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, | ||
2260 | |||
2261 | .pwm_freq_div = 0, | ||
2262 | |||
2263 | .agc_control = dib7090_agc_restart, | ||
2264 | |||
2265 | .spur_protect = 0, | ||
2266 | .disable_sample_and_hold = 0, | ||
2267 | .enable_current_mirror = 0, | ||
2268 | .diversity_delay = 0, | ||
2269 | |||
2270 | .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, | ||
2271 | .default_i2c_addr = 0x92, | ||
2272 | .enMpegOutput = 0, | ||
2273 | } | ||
2274 | }; | ||
2275 | |||
2276 | static const struct dib0090_config nim7090_dib0090_config = { | ||
2277 | .io.clock_khz = 12000, | ||
2278 | .io.pll_bypass = 0, | ||
2279 | .io.pll_range = 0, | ||
2280 | .io.pll_prediv = 3, | ||
2281 | .io.pll_loopdiv = 6, | ||
2282 | .io.adc_clock_ratio = 0, | ||
2283 | .io.pll_int_loop_filt = 0, | ||
2284 | .reset = dib7090_tuner_sleep, | ||
2285 | .sleep = dib7090_tuner_sleep, | ||
2286 | |||
2287 | .freq_offset_khz_uhf = 0, | ||
2288 | .freq_offset_khz_vhf = 0, | ||
2289 | |||
2290 | .get_adc_power = dib7090_get_adc_power, | ||
2291 | |||
2292 | .clkouttobamse = 1, | ||
2293 | .analog_output = 0, | ||
2294 | |||
2295 | .wbd_vhf_offset = 0, | ||
2296 | .wbd_cband_offset = 0, | ||
2297 | .use_pwm_agc = 1, | ||
2298 | .clkoutdrive = 0, | ||
2299 | |||
2300 | .fref_clock_ratio = 0, | ||
2301 | |||
2302 | .wbd = dib7090_wbd_table, | ||
2303 | |||
2304 | .ls_cfg_pad_drv = 0, | ||
2305 | .data_tx_drv = 0, | ||
2306 | .low_if = NULL, | ||
2307 | .in_soc = 1, | ||
2308 | }; | ||
2309 | |||
2310 | static const struct dib0090_config tfe7090pvr_dib0090_config[2] = { | ||
2311 | { | ||
2312 | .io.clock_khz = 12000, | ||
2313 | .io.pll_bypass = 0, | ||
2314 | .io.pll_range = 0, | ||
2315 | .io.pll_prediv = 3, | ||
2316 | .io.pll_loopdiv = 6, | ||
2317 | .io.adc_clock_ratio = 0, | ||
2318 | .io.pll_int_loop_filt = 0, | ||
2319 | .reset = dib7090_tuner_sleep, | ||
2320 | .sleep = dib7090_tuner_sleep, | ||
2321 | |||
2322 | .freq_offset_khz_uhf = 50, | ||
2323 | .freq_offset_khz_vhf = 70, | ||
2324 | |||
2325 | .get_adc_power = dib7090_get_adc_power, | ||
2326 | |||
2327 | .clkouttobamse = 1, | ||
2328 | .analog_output = 0, | ||
2329 | |||
2330 | .wbd_vhf_offset = 0, | ||
2331 | .wbd_cband_offset = 0, | ||
2332 | .use_pwm_agc = 1, | ||
2333 | .clkoutdrive = 0, | ||
2334 | |||
2335 | .fref_clock_ratio = 0, | ||
2336 | |||
2337 | .wbd = dib7090_wbd_table, | ||
2338 | |||
2339 | .ls_cfg_pad_drv = 0, | ||
2340 | .data_tx_drv = 0, | ||
2341 | .low_if = NULL, | ||
2342 | .in_soc = 1, | ||
2343 | },{ | ||
2344 | .io.clock_khz = 12000, | ||
2345 | .io.pll_bypass = 0, | ||
2346 | .io.pll_range = 0, | ||
2347 | .io.pll_prediv = 3, | ||
2348 | .io.pll_loopdiv = 6, | ||
2349 | .io.adc_clock_ratio = 0, | ||
2350 | .io.pll_int_loop_filt = 0, | ||
2351 | .reset = dib7090_tuner_sleep, | ||
2352 | .sleep = dib7090_tuner_sleep, | ||
2353 | |||
2354 | .freq_offset_khz_uhf = -50, | ||
2355 | .freq_offset_khz_vhf = -70, | ||
2356 | |||
2357 | .get_adc_power = dib7090_get_adc_power, | ||
2358 | |||
2359 | .clkouttobamse = 1, | ||
2360 | .analog_output = 0, | ||
2361 | |||
2362 | .wbd_vhf_offset = 0, | ||
2363 | .wbd_cband_offset = 0, | ||
2364 | .use_pwm_agc = 1, | ||
2365 | .clkoutdrive = 0, | ||
2366 | |||
2367 | .fref_clock_ratio = 0, | ||
2368 | |||
2369 | .wbd = dib7090_wbd_table, | ||
2370 | |||
2371 | .ls_cfg_pad_drv = 0, | ||
2372 | .data_tx_drv = 0, | ||
2373 | .low_if = NULL, | ||
2374 | .in_soc = 1, | ||
2375 | } | ||
2376 | }; | ||
2377 | |||
2378 | static int nim7090_frontend_attach(struct dvb_usb_adapter *adap) | ||
2379 | { | ||
2380 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
2381 | msleep(10); | ||
2382 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
2383 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
2384 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
2385 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
2386 | |||
2387 | msleep(10); | ||
2388 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
2389 | msleep(10); | ||
2390 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
2391 | |||
2392 | if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) { | ||
2393 | err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__); | ||
2394 | return -ENODEV; | ||
2395 | } | ||
2396 | adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config); | ||
1558 | 2397 | ||
1559 | return adap->fe == NULL ? -ENODEV : 0; | 2398 | return adap->fe == NULL ? -ENODEV : 0; |
1560 | } | 2399 | } |
1561 | 2400 | ||
2401 | static int nim7090_tuner_attach(struct dvb_usb_adapter *adap) | ||
2402 | { | ||
2403 | struct dib0700_adapter_state *st = adap->priv; | ||
2404 | struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe); | ||
2405 | |||
2406 | if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &nim7090_dib0090_config) == NULL) | ||
2407 | return -ENODEV; | ||
2408 | |||
2409 | dib7000p_set_gpio(adap->fe, 8, 0, 1); | ||
2410 | |||
2411 | st->set_param_save = adap->fe->ops.tuner_ops.set_params; | ||
2412 | adap->fe->ops.tuner_ops.set_params = dib7090_agc_startup; | ||
2413 | return 0; | ||
2414 | } | ||
2415 | |||
2416 | static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap) | ||
2417 | { | ||
2418 | struct dib0700_state *st = adap->dev->priv; | ||
2419 | |||
2420 | /* The TFE7090 requires the dib0700 to not be in master mode */ | ||
2421 | st->disable_streaming_master_mode = 1; | ||
2422 | |||
2423 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
2424 | msleep(10); | ||
2425 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
2426 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
2427 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
2428 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
2429 | |||
2430 | msleep(10); | ||
2431 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
2432 | msleep(10); | ||
2433 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
2434 | |||
2435 | /* initialize IC 0 */ | ||
2436 | if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) { | ||
2437 | err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__); | ||
2438 | return -ENODEV; | ||
2439 | } | ||
2440 | |||
2441 | dib0700_set_i2c_speed(adap->dev, 340); | ||
2442 | adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]); | ||
2443 | |||
2444 | dib7090_slave_reset(adap->fe); | ||
2445 | |||
2446 | if (adap->fe == NULL) | ||
2447 | return -ENODEV; | ||
2448 | |||
2449 | return 0; | ||
2450 | } | ||
2451 | |||
2452 | static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap) | ||
2453 | { | ||
2454 | struct i2c_adapter *i2c; | ||
2455 | |||
2456 | if (adap->dev->adapter[0].fe == NULL) { | ||
2457 | err("the master dib7090 has to be initialized first"); | ||
2458 | return -ENODEV; /* the master device has not been initialized */ | ||
2459 | } | ||
2460 | |||
2461 | i2c = dib7000p_get_i2c_master(adap->dev->adapter[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1); | ||
2462 | if (dib7000p_i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) { | ||
2463 | err("%s: dib7000p_i2c_enumeration failed. Cannot continue\n", __func__); | ||
2464 | return -ENODEV; | ||
2465 | } | ||
2466 | |||
2467 | adap->fe = dvb_attach(dib7000p_attach, i2c, 0x92, &tfe7090pvr_dib7000p_config[1]); | ||
2468 | dib0700_set_i2c_speed(adap->dev, 200); | ||
2469 | |||
2470 | return adap->fe == NULL ? -ENODEV : 0; | ||
2471 | } | ||
2472 | |||
2473 | static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap) | ||
2474 | { | ||
2475 | struct dib0700_adapter_state *st = adap->priv; | ||
2476 | struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe); | ||
2477 | |||
2478 | if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL) | ||
2479 | return -ENODEV; | ||
2480 | |||
2481 | dib7000p_set_gpio(adap->fe, 8, 0, 1); | ||
2482 | |||
2483 | st->set_param_save = adap->fe->ops.tuner_ops.set_params; | ||
2484 | adap->fe->ops.tuner_ops.set_params = dib7090_agc_startup; | ||
2485 | return 0; | ||
2486 | } | ||
2487 | |||
2488 | static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap) | ||
2489 | { | ||
2490 | struct dib0700_adapter_state *st = adap->priv; | ||
2491 | struct i2c_adapter *tun_i2c = dib7090_get_i2c_tuner(adap->fe); | ||
2492 | |||
2493 | if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL) | ||
2494 | return -ENODEV; | ||
2495 | |||
2496 | dib7000p_set_gpio(adap->fe, 8, 0, 1); | ||
2497 | |||
2498 | st->set_param_save = adap->fe->ops.tuner_ops.set_params; | ||
2499 | adap->fe->ops.tuner_ops.set_params = dib7090_agc_startup; | ||
2500 | return 0; | ||
2501 | } | ||
2502 | |||
1562 | /* STK7070PD */ | 2503 | /* STK7070PD */ |
1563 | static struct dib7000p_config stk7070pd_dib7000p_config[2] = { | 2504 | static struct dib7000p_config stk7070pd_dib7000p_config[2] = { |
1564 | { | 2505 | { |
@@ -1856,6 +2797,11 @@ struct usb_device_id dib0700_usb_id_table[] = { | |||
1856 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, | 2797 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, |
1857 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) }, | 2798 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) }, |
1858 | { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) }, | 2799 | { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) }, |
2800 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) }, | ||
2801 | /* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) }, | ||
2802 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) }, | ||
2803 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) }, | ||
2804 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) }, | ||
1859 | { 0 } /* Terminating entry */ | 2805 | { 0 } /* Terminating entry */ |
1860 | }; | 2806 | }; |
1861 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); | 2807 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); |
@@ -2619,6 +3565,205 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
2619 | RC_TYPE_NEC, | 3565 | RC_TYPE_NEC, |
2620 | .change_protocol = dib0700_change_protocol, | 3566 | .change_protocol = dib0700_change_protocol, |
2621 | }, | 3567 | }, |
3568 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | ||
3569 | .num_adapters = 1, | ||
3570 | .adapter = { | ||
3571 | { | ||
3572 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
3573 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
3574 | .pid_filter_count = 32, | ||
3575 | .pid_filter = dib90x0_pid_filter, | ||
3576 | .pid_filter_ctrl = dib90x0_pid_filter_ctrl, | ||
3577 | .frontend_attach = stk9090m_frontend_attach, | ||
3578 | .tuner_attach = dib9090_tuner_attach, | ||
3579 | |||
3580 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | ||
3581 | |||
3582 | .size_of_priv = | ||
3583 | sizeof(struct dib0700_adapter_state), | ||
3584 | }, | ||
3585 | }, | ||
3586 | |||
3587 | .num_device_descs = 1, | ||
3588 | .devices = { | ||
3589 | { "DiBcom STK9090M reference design", | ||
3590 | { &dib0700_usb_id_table[69], NULL }, | ||
3591 | { NULL }, | ||
3592 | }, | ||
3593 | }, | ||
3594 | |||
3595 | .rc.core = { | ||
3596 | .rc_interval = DEFAULT_RC_INTERVAL, | ||
3597 | .rc_codes = RC_MAP_DIB0700_RC5_TABLE, | ||
3598 | .module_name = "dib0700", | ||
3599 | .rc_query = dib0700_rc_query_old_firmware, | ||
3600 | .allowed_protos = RC_TYPE_RC5 | | ||
3601 | RC_TYPE_RC6 | | ||
3602 | RC_TYPE_NEC, | ||
3603 | .change_protocol = dib0700_change_protocol, | ||
3604 | }, | ||
3605 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | ||
3606 | .num_adapters = 1, | ||
3607 | .adapter = { | ||
3608 | { | ||
3609 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
3610 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
3611 | .pid_filter_count = 32, | ||
3612 | .pid_filter = stk80xx_pid_filter, | ||
3613 | .pid_filter_ctrl = stk80xx_pid_filter_ctrl, | ||
3614 | .frontend_attach = nim8096md_frontend_attach, | ||
3615 | .tuner_attach = nim8096md_tuner_attach, | ||
3616 | |||
3617 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | ||
3618 | |||
3619 | .size_of_priv = | ||
3620 | sizeof(struct dib0700_adapter_state), | ||
3621 | }, | ||
3622 | }, | ||
3623 | |||
3624 | .num_device_descs = 1, | ||
3625 | .devices = { | ||
3626 | { "DiBcom NIM8096MD reference design", | ||
3627 | { &dib0700_usb_id_table[70], NULL }, | ||
3628 | { NULL }, | ||
3629 | }, | ||
3630 | }, | ||
3631 | |||
3632 | .rc.core = { | ||
3633 | .rc_interval = DEFAULT_RC_INTERVAL, | ||
3634 | .rc_codes = RC_MAP_DIB0700_RC5_TABLE, | ||
3635 | .module_name = "dib0700", | ||
3636 | .rc_query = dib0700_rc_query_old_firmware, | ||
3637 | .allowed_protos = RC_TYPE_RC5 | | ||
3638 | RC_TYPE_RC6 | | ||
3639 | RC_TYPE_NEC, | ||
3640 | .change_protocol = dib0700_change_protocol, | ||
3641 | }, | ||
3642 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | ||
3643 | .num_adapters = 1, | ||
3644 | .adapter = { | ||
3645 | { | ||
3646 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
3647 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
3648 | .pid_filter_count = 32, | ||
3649 | .pid_filter = dib90x0_pid_filter, | ||
3650 | .pid_filter_ctrl = dib90x0_pid_filter_ctrl, | ||
3651 | .frontend_attach = nim9090md_frontend_attach, | ||
3652 | .tuner_attach = nim9090md_tuner_attach, | ||
3653 | |||
3654 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | ||
3655 | |||
3656 | .size_of_priv = | ||
3657 | sizeof(struct dib0700_adapter_state), | ||
3658 | }, | ||
3659 | }, | ||
3660 | |||
3661 | .num_device_descs = 1, | ||
3662 | .devices = { | ||
3663 | { "DiBcom NIM9090MD reference design", | ||
3664 | { &dib0700_usb_id_table[71], NULL }, | ||
3665 | { NULL }, | ||
3666 | }, | ||
3667 | }, | ||
3668 | |||
3669 | .rc.core = { | ||
3670 | .rc_interval = DEFAULT_RC_INTERVAL, | ||
3671 | .rc_codes = RC_MAP_DIB0700_RC5_TABLE, | ||
3672 | .module_name = "dib0700", | ||
3673 | .rc_query = dib0700_rc_query_old_firmware, | ||
3674 | .allowed_protos = RC_TYPE_RC5 | | ||
3675 | RC_TYPE_RC6 | | ||
3676 | RC_TYPE_NEC, | ||
3677 | .change_protocol = dib0700_change_protocol, | ||
3678 | }, | ||
3679 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | ||
3680 | .num_adapters = 1, | ||
3681 | .adapter = { | ||
3682 | { | ||
3683 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
3684 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
3685 | .pid_filter_count = 32, | ||
3686 | .pid_filter = stk70x0p_pid_filter, | ||
3687 | .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, | ||
3688 | .frontend_attach = nim7090_frontend_attach, | ||
3689 | .tuner_attach = nim7090_tuner_attach, | ||
3690 | |||
3691 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | ||
3692 | |||
3693 | .size_of_priv = | ||
3694 | sizeof(struct dib0700_adapter_state), | ||
3695 | }, | ||
3696 | }, | ||
3697 | |||
3698 | .num_device_descs = 1, | ||
3699 | .devices = { | ||
3700 | { "DiBcom NIM7090 reference design", | ||
3701 | { &dib0700_usb_id_table[72], NULL }, | ||
3702 | { NULL }, | ||
3703 | }, | ||
3704 | }, | ||
3705 | |||
3706 | .rc.core = { | ||
3707 | .rc_interval = DEFAULT_RC_INTERVAL, | ||
3708 | .rc_codes = RC_MAP_DIB0700_RC5_TABLE, | ||
3709 | .module_name = "dib0700", | ||
3710 | .rc_query = dib0700_rc_query_old_firmware, | ||
3711 | .allowed_protos = RC_TYPE_RC5 | | ||
3712 | RC_TYPE_RC6 | | ||
3713 | RC_TYPE_NEC, | ||
3714 | .change_protocol = dib0700_change_protocol, | ||
3715 | }, | ||
3716 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | ||
3717 | .num_adapters = 2, | ||
3718 | .adapter = { | ||
3719 | { | ||
3720 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
3721 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
3722 | .pid_filter_count = 32, | ||
3723 | .pid_filter = stk70x0p_pid_filter, | ||
3724 | .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, | ||
3725 | .frontend_attach = tfe7090pvr_frontend0_attach, | ||
3726 | .tuner_attach = tfe7090pvr_tuner0_attach, | ||
3727 | |||
3728 | DIB0700_DEFAULT_STREAMING_CONFIG(0x03), | ||
3729 | |||
3730 | .size_of_priv = | ||
3731 | sizeof(struct dib0700_adapter_state), | ||
3732 | }, | ||
3733 | { | ||
3734 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
3735 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
3736 | .pid_filter_count = 32, | ||
3737 | .pid_filter = stk70x0p_pid_filter, | ||
3738 | .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, | ||
3739 | .frontend_attach = tfe7090pvr_frontend1_attach, | ||
3740 | .tuner_attach = tfe7090pvr_tuner1_attach, | ||
3741 | |||
3742 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | ||
3743 | |||
3744 | .size_of_priv = | ||
3745 | sizeof(struct dib0700_adapter_state), | ||
3746 | }, | ||
3747 | }, | ||
3748 | |||
3749 | .num_device_descs = 1, | ||
3750 | .devices = { | ||
3751 | { "DiBcom TFE7090PVR reference design", | ||
3752 | { &dib0700_usb_id_table[73], NULL }, | ||
3753 | { NULL }, | ||
3754 | }, | ||
3755 | }, | ||
3756 | |||
3757 | .rc.core = { | ||
3758 | .rc_interval = DEFAULT_RC_INTERVAL, | ||
3759 | .rc_codes = RC_MAP_DIB0700_RC5_TABLE, | ||
3760 | .module_name = "dib0700", | ||
3761 | .rc_query = dib0700_rc_query_old_firmware, | ||
3762 | .allowed_protos = RC_TYPE_RC5 | | ||
3763 | RC_TYPE_RC6 | | ||
3764 | RC_TYPE_NEC, | ||
3765 | .change_protocol = dib0700_change_protocol, | ||
3766 | }, | ||
2622 | }, | 3767 | }, |
2623 | }; | 3768 | }; |
2624 | 3769 | ||
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index d0bce0445cc7..b71540d7e070 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -106,8 +106,13 @@ | |||
106 | #define USB_PID_DIBCOM_STK807XP 0x1f90 | 106 | #define USB_PID_DIBCOM_STK807XP 0x1f90 |
107 | #define USB_PID_DIBCOM_STK807XPVR 0x1f98 | 107 | #define USB_PID_DIBCOM_STK807XPVR 0x1f98 |
108 | #define USB_PID_DIBCOM_STK8096GP 0x1fa0 | 108 | #define USB_PID_DIBCOM_STK8096GP 0x1fa0 |
109 | #define USB_PID_DIBCOM_NIM8096MD 0x1fa8 | ||
109 | #define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 | 110 | #define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 |
110 | #define USB_PID_DIBCOM_STK7770P 0x1e80 | 111 | #define USB_PID_DIBCOM_STK7770P 0x1e80 |
112 | #define USB_PID_DIBCOM_NIM7090 0x1bb2 | ||
113 | #define USB_PID_DIBCOM_TFE7090PVR 0x1bb4 | ||
114 | #define USB_PID_DIBCOM_NIM9090M 0x2383 | ||
115 | #define USB_PID_DIBCOM_NIM9090MD 0x2384 | ||
111 | #define USB_PID_DPOSH_M9206_COLD 0x9206 | 116 | #define USB_PID_DPOSH_M9206_COLD 0x9206 |
112 | #define USB_PID_DPOSH_M9206_WARM 0xa090 | 117 | #define USB_PID_DPOSH_M9206_WARM 0xa090 |
113 | #define USB_PID_E3C_EC168 0x1689 | 118 | #define USB_PID_E3C_EC168 0x1689 |