diff options
author | Patrick Boettcher <pboettcher@dibcom.fr> | 2009-09-16 08:51:30 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:14:31 -0400 |
commit | ba3fe3a96374ff209f532a4924743bb1fa4d57f6 (patch) | |
tree | 2b02a0b59cfc1bbdb6f2ee9a228da8207b9411ef /drivers/media/dvb/dvb-usb/dib0700_devices.c | |
parent | 77e2c0f5d471e2b14140f0695a1b6a718f318dd7 (diff) |
V4L/DVB (12901): DiB0700: add support for STK807XP and STK807XPVR
This patchs adds support for the DiB8000 based devices STK807xP and
STK807xPVR to the dib0700-device-tree.
[mchehab@redhat.com: Fix merge conflicts]
Signed-off-by: Olivier Grenie <Olivier.Grenie@dibcom.fr>
Signed-off-by: Patrick Boettcher <pboettcher@dibcom.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dib0700_devices.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/dib0700_devices.c | 367 |
1 files changed, 366 insertions, 1 deletions
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index 10ade261b0ab..442afbaabeef 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
@@ -4,13 +4,14 @@ | |||
4 | * under the terms of the GNU General Public License as published by the Free | 4 | * under the terms of the GNU General Public License as published by the Free |
5 | * Software Foundation, version 2. | 5 | * Software Foundation, version 2. |
6 | * | 6 | * |
7 | * Copyright (C) 2005-7 DiBcom, SA | 7 | * Copyright (C) 2005-9 DiBcom, SA et al |
8 | */ | 8 | */ |
9 | #include "dib0700.h" | 9 | #include "dib0700.h" |
10 | 10 | ||
11 | #include "dib3000mc.h" | 11 | #include "dib3000mc.h" |
12 | #include "dib7000m.h" | 12 | #include "dib7000m.h" |
13 | #include "dib7000p.h" | 13 | #include "dib7000p.h" |
14 | #include "dib8000.h" | ||
14 | #include "mt2060.h" | 15 | #include "mt2060.h" |
15 | #include "mt2266.h" | 16 | #include "mt2266.h" |
16 | #include "tuner-xc2028.h" | 17 | #include "tuner-xc2028.h" |
@@ -1268,6 +1269,306 @@ static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap) | |||
1268 | return adap->fe == NULL ? -ENODEV : 0; | 1269 | return adap->fe == NULL ? -ENODEV : 0; |
1269 | } | 1270 | } |
1270 | 1271 | ||
1272 | /* DIB807x generic */ | ||
1273 | static struct dibx000_agc_config dib807x_agc_config[2] = { | ||
1274 | { | ||
1275 | BAND_VHF, | ||
1276 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, | ||
1277 | * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, | ||
1278 | * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0, | ||
1279 | * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, | ||
1280 | * P_agc_write=0 */ | ||
1281 | (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) | | ||
1282 | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | | ||
1283 | (0 << 0), /* setup*/ | ||
1284 | |||
1285 | 600, /* inv_gain*/ | ||
1286 | 10, /* time_stabiliz*/ | ||
1287 | |||
1288 | 0, /* alpha_level*/ | ||
1289 | 118, /* thlock*/ | ||
1290 | |||
1291 | 0, /* wbd_inv*/ | ||
1292 | 3530, /* wbd_ref*/ | ||
1293 | 1, /* wbd_sel*/ | ||
1294 | 5, /* wbd_alpha*/ | ||
1295 | |||
1296 | 65535, /* agc1_max*/ | ||
1297 | 0, /* agc1_min*/ | ||
1298 | |||
1299 | 65535, /* agc2_max*/ | ||
1300 | 0, /* agc2_min*/ | ||
1301 | |||
1302 | 0, /* agc1_pt1*/ | ||
1303 | 40, /* agc1_pt2*/ | ||
1304 | 183, /* agc1_pt3*/ | ||
1305 | 206, /* agc1_slope1*/ | ||
1306 | 255, /* agc1_slope2*/ | ||
1307 | 72, /* agc2_pt1*/ | ||
1308 | 152, /* agc2_pt2*/ | ||
1309 | 88, /* agc2_slope1*/ | ||
1310 | 90, /* agc2_slope2*/ | ||
1311 | |||
1312 | 17, /* alpha_mant*/ | ||
1313 | 27, /* alpha_exp*/ | ||
1314 | 23, /* beta_mant*/ | ||
1315 | 51, /* beta_exp*/ | ||
1316 | |||
1317 | 0, /* perform_agc_softsplit*/ | ||
1318 | }, { | ||
1319 | BAND_UHF, | ||
1320 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, | ||
1321 | * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, | ||
1322 | * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, | ||
1323 | * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, | ||
1324 | * P_agc_write=0 */ | ||
1325 | (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) | | ||
1326 | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | | ||
1327 | (0 << 0), /* setup */ | ||
1328 | |||
1329 | 600, /* inv_gain*/ | ||
1330 | 10, /* time_stabiliz*/ | ||
1331 | |||
1332 | 0, /* alpha_level*/ | ||
1333 | 118, /* thlock*/ | ||
1334 | |||
1335 | 0, /* wbd_inv*/ | ||
1336 | 3530, /* wbd_ref*/ | ||
1337 | 1, /* wbd_sel*/ | ||
1338 | 5, /* wbd_alpha*/ | ||
1339 | |||
1340 | 65535, /* agc1_max*/ | ||
1341 | 0, /* agc1_min*/ | ||
1342 | |||
1343 | 65535, /* agc2_max*/ | ||
1344 | 0, /* agc2_min*/ | ||
1345 | |||
1346 | 0, /* agc1_pt1*/ | ||
1347 | 40, /* agc1_pt2*/ | ||
1348 | 183, /* agc1_pt3*/ | ||
1349 | 206, /* agc1_slope1*/ | ||
1350 | 255, /* agc1_slope2*/ | ||
1351 | 72, /* agc2_pt1*/ | ||
1352 | 152, /* agc2_pt2*/ | ||
1353 | 88, /* agc2_slope1*/ | ||
1354 | 90, /* agc2_slope2*/ | ||
1355 | |||
1356 | 17, /* alpha_mant*/ | ||
1357 | 27, /* alpha_exp*/ | ||
1358 | 23, /* beta_mant*/ | ||
1359 | 51, /* beta_exp*/ | ||
1360 | |||
1361 | 0, /* perform_agc_softsplit*/ | ||
1362 | } | ||
1363 | }; | ||
1364 | |||
1365 | static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = { | ||
1366 | 60000, 15000, /* internal, sampling*/ | ||
1367 | 1, 20, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass*/ | ||
1368 | 0, 0, 1, 1, 2, /* misc: refdiv, bypclk_div, IO_CLK_en_core, | ||
1369 | ADClkSrc, modulo */ | ||
1370 | (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/ | ||
1371 | (0 << 25) | 0, /* ifreq = 0.000000 MHz*/ | ||
1372 | 18179755, /* timf*/ | ||
1373 | 12000000, /* xtal_hz*/ | ||
1374 | }; | ||
1375 | |||
1376 | static struct dib8000_config dib807x_dib8000_config[2] = { | ||
1377 | { | ||
1378 | .output_mpeg2_in_188_bytes = 1, | ||
1379 | |||
1380 | .agc_config_count = 2, | ||
1381 | .agc = dib807x_agc_config, | ||
1382 | .pll = &dib807x_bw_config_12_mhz, | ||
1383 | .tuner_is_baseband = 1, | ||
1384 | |||
1385 | .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, | ||
1386 | .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, | ||
1387 | .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, | ||
1388 | |||
1389 | .hostbus_diversity = 1, | ||
1390 | .div_cfg = 1, | ||
1391 | .agc_control = &dib0070_ctrl_agc_filter, | ||
1392 | .output_mode = OUTMODE_MPEG2_FIFO, | ||
1393 | .drives = 0x2d98, | ||
1394 | }, { | ||
1395 | .output_mpeg2_in_188_bytes = 1, | ||
1396 | |||
1397 | .agc_config_count = 2, | ||
1398 | .agc = dib807x_agc_config, | ||
1399 | .pll = &dib807x_bw_config_12_mhz, | ||
1400 | .tuner_is_baseband = 1, | ||
1401 | |||
1402 | .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, | ||
1403 | .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, | ||
1404 | .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, | ||
1405 | |||
1406 | .hostbus_diversity = 1, | ||
1407 | .agc_control = &dib0070_ctrl_agc_filter, | ||
1408 | .output_mode = OUTMODE_MPEG2_FIFO, | ||
1409 | .drives = 0x2d98, | ||
1410 | } | ||
1411 | }; | ||
1412 | |||
1413 | static int dib807x_tuner_reset(struct dvb_frontend *fe, int onoff) | ||
1414 | { | ||
1415 | return dib8000_set_gpio(fe, 5, 0, !onoff); | ||
1416 | } | ||
1417 | |||
1418 | static int dib807x_tuner_sleep(struct dvb_frontend *fe, int onoff) | ||
1419 | { | ||
1420 | return dib8000_set_gpio(fe, 0, 0, onoff); | ||
1421 | } | ||
1422 | |||
1423 | static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = { | ||
1424 | { 240, 7}, | ||
1425 | { 0xffff, 6}, | ||
1426 | }; | ||
1427 | |||
1428 | static struct dib0070_config dib807x_dib0070_config[2] = { | ||
1429 | { | ||
1430 | .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, | ||
1431 | .reset = dib807x_tuner_reset, | ||
1432 | .sleep = dib807x_tuner_sleep, | ||
1433 | .clock_khz = 12000, | ||
1434 | .clock_pad_drive = 4, | ||
1435 | .vga_filter = 1, | ||
1436 | .force_crystal_mode = 1, | ||
1437 | .enable_third_order_filter = 1, | ||
1438 | .charge_pump = 0, | ||
1439 | .wbd_gain = dib8070_wbd_gain_cfg, | ||
1440 | .osc_buffer_state = 0, | ||
1441 | .freq_offset_khz_uhf = -100, | ||
1442 | .freq_offset_khz_vhf = -100, | ||
1443 | }, { | ||
1444 | .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, | ||
1445 | .reset = dib807x_tuner_reset, | ||
1446 | .sleep = dib807x_tuner_sleep, | ||
1447 | .clock_khz = 12000, | ||
1448 | .clock_pad_drive = 2, | ||
1449 | .vga_filter = 1, | ||
1450 | .force_crystal_mode = 1, | ||
1451 | .enable_third_order_filter = 1, | ||
1452 | .charge_pump = 0, | ||
1453 | .wbd_gain = dib8070_wbd_gain_cfg, | ||
1454 | .osc_buffer_state = 0, | ||
1455 | .freq_offset_khz_uhf = -25, | ||
1456 | .freq_offset_khz_vhf = -25, | ||
1457 | } | ||
1458 | }; | ||
1459 | |||
1460 | static int dib807x_set_param_override(struct dvb_frontend *fe, | ||
1461 | struct dvb_frontend_parameters *fep) | ||
1462 | { | ||
1463 | struct dvb_usb_adapter *adap = fe->dvb->priv; | ||
1464 | struct dib0700_adapter_state *state = adap->priv; | ||
1465 | |||
1466 | u16 offset = dib0070_wbd_offset(fe); | ||
1467 | u8 band = BAND_OF_FREQUENCY(fep->frequency/1000); | ||
1468 | switch (band) { | ||
1469 | case BAND_VHF: | ||
1470 | offset += 750; | ||
1471 | break; | ||
1472 | case BAND_UHF: /* fall-thru wanted */ | ||
1473 | default: | ||
1474 | offset += 250; break; | ||
1475 | } | ||
1476 | deb_info("WBD for DiB8000: %d\n", offset); | ||
1477 | dib8000_set_wbd_ref(fe, offset); | ||
1478 | |||
1479 | return state->set_param_save(fe, fep); | ||
1480 | } | ||
1481 | |||
1482 | static int dib807x_tuner_attach(struct dvb_usb_adapter *adap) | ||
1483 | { | ||
1484 | struct dib0700_adapter_state *st = adap->priv; | ||
1485 | struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe, | ||
1486 | DIBX000_I2C_INTERFACE_TUNER, 1); | ||
1487 | |||
1488 | if (adap->id == 0) { | ||
1489 | if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, | ||
1490 | &dib807x_dib0070_config[0]) == NULL) | ||
1491 | return -ENODEV; | ||
1492 | } else { | ||
1493 | if (dvb_attach(dib0070_attach, adap->fe, tun_i2c, | ||
1494 | &dib807x_dib0070_config[1]) == NULL) | ||
1495 | return -ENODEV; | ||
1496 | } | ||
1497 | |||
1498 | st->set_param_save = adap->fe->ops.tuner_ops.set_params; | ||
1499 | adap->fe->ops.tuner_ops.set_params = dib807x_set_param_override; | ||
1500 | return 0; | ||
1501 | } | ||
1502 | |||
1503 | |||
1504 | /* STK807x */ | ||
1505 | static int stk807x_frontend_attach(struct dvb_usb_adapter *adap) | ||
1506 | { | ||
1507 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
1508 | msleep(10); | ||
1509 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
1510 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
1511 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
1512 | |||
1513 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
1514 | |||
1515 | dib0700_ctrl_clock(adap->dev, 72, 1); | ||
1516 | |||
1517 | msleep(10); | ||
1518 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
1519 | msleep(10); | ||
1520 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
1521 | |||
1522 | dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, | ||
1523 | 0x80); | ||
1524 | |||
1525 | adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, | ||
1526 | &dib807x_dib8000_config[0]); | ||
1527 | |||
1528 | return adap->fe == NULL ? -ENODEV : 0; | ||
1529 | } | ||
1530 | |||
1531 | /* STK807xPVR */ | ||
1532 | static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap) | ||
1533 | { | ||
1534 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); | ||
1535 | msleep(30); | ||
1536 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
1537 | msleep(500); | ||
1538 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
1539 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
1540 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
1541 | |||
1542 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
1543 | |||
1544 | dib0700_ctrl_clock(adap->dev, 72, 1); | ||
1545 | |||
1546 | msleep(10); | ||
1547 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
1548 | msleep(10); | ||
1549 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
1550 | |||
1551 | /* initialize IC 0 */ | ||
1552 | dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x80); | ||
1553 | |||
1554 | adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, | ||
1555 | &dib807x_dib8000_config[0]); | ||
1556 | |||
1557 | return adap->fe == NULL ? -ENODEV : 0; | ||
1558 | } | ||
1559 | |||
1560 | static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap) | ||
1561 | { | ||
1562 | /* initialize IC 1 */ | ||
1563 | dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x82); | ||
1564 | |||
1565 | adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82, | ||
1566 | &dib807x_dib8000_config[1]); | ||
1567 | |||
1568 | return adap->fe == NULL ? -ENODEV : 0; | ||
1569 | } | ||
1570 | |||
1571 | |||
1271 | /* STK7070PD */ | 1572 | /* STK7070PD */ |
1272 | static struct dib7000p_config stk7070pd_dib7000p_config[2] = { | 1573 | static struct dib7000p_config stk7070pd_dib7000p_config[2] = { |
1273 | { | 1574 | { |
@@ -1557,6 +1858,8 @@ struct usb_device_id dib0700_usb_id_table[] = { | |||
1557 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, | 1858 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, |
1558 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) }, | 1859 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) }, |
1559 | /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) }, | 1860 | /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) }, |
1861 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) }, | ||
1862 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) }, | ||
1560 | { 0 } /* Terminating entry */ | 1863 | { 0 } /* Terminating entry */ |
1561 | }; | 1864 | }; |
1562 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); | 1865 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); |
@@ -2048,6 +2351,68 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
2048 | .rc_key_map = dib0700_rc_keys, | 2351 | .rc_key_map = dib0700_rc_keys, |
2049 | .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), | 2352 | .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), |
2050 | .rc_query = dib0700_rc_query | 2353 | .rc_query = dib0700_rc_query |
2354 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | ||
2355 | .num_adapters = 1, | ||
2356 | .adapter = { | ||
2357 | { | ||
2358 | .frontend_attach = stk807x_frontend_attach, | ||
2359 | .tuner_attach = dib807x_tuner_attach, | ||
2360 | |||
2361 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | ||
2362 | |||
2363 | .size_of_priv = | ||
2364 | sizeof(struct dib0700_adapter_state), | ||
2365 | }, | ||
2366 | }, | ||
2367 | |||
2368 | .num_device_descs = 1, | ||
2369 | .devices = { | ||
2370 | { "DiBcom STK807xP reference design", | ||
2371 | { &dib0700_usb_id_table[62], NULL }, | ||
2372 | { NULL }, | ||
2373 | }, | ||
2374 | }, | ||
2375 | |||
2376 | .rc_interval = DEFAULT_RC_INTERVAL, | ||
2377 | .rc_key_map = dib0700_rc_keys, | ||
2378 | .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), | ||
2379 | .rc_query = dib0700_rc_query | ||
2380 | |||
2381 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | ||
2382 | .num_adapters = 2, | ||
2383 | .adapter = { | ||
2384 | { | ||
2385 | .frontend_attach = stk807xpvr_frontend_attach0, | ||
2386 | .tuner_attach = dib807x_tuner_attach, | ||
2387 | |||
2388 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | ||
2389 | |||
2390 | .size_of_priv = | ||
2391 | sizeof(struct dib0700_adapter_state), | ||
2392 | }, | ||
2393 | { | ||
2394 | .frontend_attach = stk807xpvr_frontend_attach1, | ||
2395 | .tuner_attach = dib807x_tuner_attach, | ||
2396 | |||
2397 | DIB0700_DEFAULT_STREAMING_CONFIG(0x03), | ||
2398 | |||
2399 | .size_of_priv = | ||
2400 | sizeof(struct dib0700_adapter_state), | ||
2401 | }, | ||
2402 | }, | ||
2403 | |||
2404 | .num_device_descs = 1, | ||
2405 | .devices = { | ||
2406 | { "DiBcom STK807xPVR reference design", | ||
2407 | { &dib0700_usb_id_table[61], NULL }, | ||
2408 | { NULL }, | ||
2409 | }, | ||
2410 | }, | ||
2411 | |||
2412 | .rc_interval = DEFAULT_RC_INTERVAL, | ||
2413 | .rc_key_map = dib0700_rc_keys, | ||
2414 | .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), | ||
2415 | .rc_query = dib0700_rc_query | ||
2051 | }, | 2416 | }, |
2052 | }; | 2417 | }; |
2053 | 2418 | ||