aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/dib0700_devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dib0700_devices.c')
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c325
1 files changed, 299 insertions, 26 deletions
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 923fa157aa51..80a126354477 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -18,6 +18,7 @@
18#include "xc5000.h" 18#include "xc5000.h"
19#include "s5h1411.h" 19#include "s5h1411.h"
20#include "dib0070.h" 20#include "dib0070.h"
21#include "dib0090.h"
21#include "lgdt3305.h" 22#include "lgdt3305.h"
22#include "mxl5007t.h" 23#include "mxl5007t.h"
23 24
@@ -605,17 +606,17 @@ static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
605 } 606 }
606 break; 607 break;
607 default: 608 default:
608 if (actlen != sizeof(buf)) { 609 if (actlen != sizeof(buf)) {
609 /* We didn't get back the 6 byte message we expected */ 610 /* We didn't get back the 6 byte message we expected */
610 err("Unexpected RC response size [%d]", actlen); 611 err("Unexpected RC response size [%d]", actlen);
611 return -1; 612 return -1;
612 } 613 }
613 614
614 poll_reply.report_id = buf[0]; 615 poll_reply.report_id = buf[0];
615 poll_reply.data_state = buf[1]; 616 poll_reply.data_state = buf[1];
616 poll_reply.system = (buf[2] << 8) | buf[3]; 617 poll_reply.system = (buf[2] << 8) | buf[3];
617 poll_reply.data = buf[4]; 618 poll_reply.data = buf[4];
618 poll_reply.not_data = buf[5]; 619 poll_reply.not_data = buf[5];
619 620
620 break; 621 break;
621 } 622 }
@@ -632,7 +633,7 @@ static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
632 /* Find the key in the map */ 633 /* Find the key in the map */
633 for (i = 0; i < d->props.rc_key_map_size; i++) { 634 for (i = 0; i < d->props.rc_key_map_size; i++) {
634 if (rc5_custom(&keymap[i]) == (poll_reply.system & 0xff) && 635 if (rc5_custom(&keymap[i]) == (poll_reply.system & 0xff) &&
635 rc5_data(&keymap[i]) == poll_reply.data) { 636 rc5_data(&keymap[i]) == poll_reply.data) {
636 *event = keymap[i].event; 637 *event = keymap[i].event;
637 found = 1; 638 found = 1;
638 break; 639 break;
@@ -641,8 +642,8 @@ static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
641 642
642 if (found == 0) { 643 if (found == 0) {
643 err("Unknown remote controller key: %04x %02x %02x", 644 err("Unknown remote controller key: %04x %02x %02x",
644 poll_reply.system, 645 poll_reply.system,
645 poll_reply.data, poll_reply.not_data); 646 poll_reply.data, poll_reply.not_data);
646 d->last_event = 0; 647 d->last_event = 0;
647 return 0; 648 return 0;
648 } 649 }
@@ -1476,12 +1477,12 @@ static struct dib8000_config dib807x_dib8000_config[2] = {
1476 } 1477 }
1477}; 1478};
1478 1479
1479static int dib807x_tuner_reset(struct dvb_frontend *fe, int onoff) 1480static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
1480{ 1481{
1481 return dib8000_set_gpio(fe, 5, 0, !onoff); 1482 return dib8000_set_gpio(fe, 5, 0, !onoff);
1482} 1483}
1483 1484
1484static int dib807x_tuner_sleep(struct dvb_frontend *fe, int onoff) 1485static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
1485{ 1486{
1486 return dib8000_set_gpio(fe, 0, 0, onoff); 1487 return dib8000_set_gpio(fe, 0, 0, onoff);
1487} 1488}
@@ -1494,8 +1495,8 @@ static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
1494static struct dib0070_config dib807x_dib0070_config[2] = { 1495static struct dib0070_config dib807x_dib0070_config[2] = {
1495 { 1496 {
1496 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 1497 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1497 .reset = dib807x_tuner_reset, 1498 .reset = dib80xx_tuner_reset,
1498 .sleep = dib807x_tuner_sleep, 1499 .sleep = dib80xx_tuner_sleep,
1499 .clock_khz = 12000, 1500 .clock_khz = 12000,
1500 .clock_pad_drive = 4, 1501 .clock_pad_drive = 4,
1501 .vga_filter = 1, 1502 .vga_filter = 1,
@@ -1508,8 +1509,8 @@ static struct dib0070_config dib807x_dib0070_config[2] = {
1508 .freq_offset_khz_vhf = -100, 1509 .freq_offset_khz_vhf = -100,
1509 }, { 1510 }, {
1510 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 1511 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1511 .reset = dib807x_tuner_reset, 1512 .reset = dib80xx_tuner_reset,
1512 .sleep = dib807x_tuner_sleep, 1513 .sleep = dib80xx_tuner_sleep,
1513 .clock_khz = 12000, 1514 .clock_khz = 12000,
1514 .clock_pad_drive = 2, 1515 .clock_pad_drive = 2,
1515 .vga_filter = 1, 1516 .vga_filter = 1,
@@ -1566,12 +1567,12 @@ static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
1566 return 0; 1567 return 0;
1567} 1568}
1568 1569
1569static int stk807x_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff) 1570static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
1570{ 1571{
1571 return dib8000_pid_filter(adapter->fe, index, pid, onoff); 1572 return dib8000_pid_filter(adapter->fe, index, pid, onoff);
1572} 1573}
1573 1574
1574static int stk807x_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff) 1575static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
1575{ 1576{
1576 return dib8000_pid_filter_ctrl(adapter->fe, onoff); 1577 return dib8000_pid_filter_ctrl(adapter->fe, onoff);
1577} 1578}
@@ -1643,6 +1644,246 @@ static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
1643 return adap->fe == NULL ? -ENODEV : 0; 1644 return adap->fe == NULL ? -ENODEV : 0;
1644} 1645}
1645 1646
1647/* STK8096GP */
1648struct dibx000_agc_config dib8090_agc_config[2] = {
1649 {
1650 BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
1651 /* 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,
1652 * 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 */
1653 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
1654
1655 787,// inv_gain = 1/ 90.4dB // no boost, lower gain due to ramp quantification
1656 10, // time_stabiliz
1657
1658 0, // alpha_level
1659 118, // thlock
1660
1661 0, // wbd_inv
1662 3530, // wbd_ref
1663 1, // wbd_sel
1664 5, // wbd_alpha
1665
1666 65535, // agc1_max
1667 0, // agc1_min
1668
1669 65535, // agc2_max
1670 0, // agc2_min
1671
1672 0, // agc1_pt1
1673 32, // agc1_pt2
1674 114, // agc1_pt3 // 40.4dB
1675 143, // agc1_slope1
1676 144, // agc1_slope2
1677 114, // agc2_pt1
1678 227, // agc2_pt2
1679 116, // agc2_slope1
1680 117, // agc2_slope2
1681
1682 28, // alpha_mant // 5Hz with 90.2dB
1683 26, // alpha_exp
1684 31, // beta_mant
1685 51, // beta_exp
1686
1687 0, // perform_agc_softsplit
1688 },
1689 {
1690 BAND_CBAND,
1691 /* 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,
1692 * 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 */
1693 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
1694
1695 787,// inv_gain = 1/ 90.4dB // no boost, lower gain due to ramp quantification
1696 10, // time_stabiliz
1697
1698 0, // alpha_level
1699 118, // thlock
1700
1701 0, // wbd_inv
1702 3530, // wbd_ref
1703 1, // wbd_sel
1704 5, // wbd_alpha
1705
1706 0, // agc1_max
1707 0, // agc1_min
1708
1709 65535, // agc2_max
1710 0, // agc2_min
1711
1712 0, // agc1_pt1
1713 32, // agc1_pt2
1714 114, // agc1_pt3 // 40.4dB
1715 143, // agc1_slope1
1716 144, // agc1_slope2
1717 114, // agc2_pt1
1718 227, // agc2_pt2
1719 116, // agc2_slope1
1720 117, // agc2_slope2
1721
1722 28, // alpha_mant // 5Hz with 90.2dB
1723 26, // alpha_exp
1724 31, // beta_mant
1725 51, // beta_exp
1726
1727 0, // perform_agc_softsplit
1728 }
1729};
1730
1731static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
1732 54000, 13500, // internal, sampling
1733 1, 18, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
1734 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
1735 (3 << 14) | (1 << 12) | (599 << 0), // sad_cfg: refsel, sel, freq_15k
1736 (0 << 25) | 0, // ifreq = 0 MHz
1737 20199727, // timf
1738 12000000, // xtal_hz
1739};
1740
1741static int dib8090_get_adc_power(struct dvb_frontend *fe)
1742{
1743 return dib8000_get_adc_power(fe, 1);
1744}
1745
1746static struct dib8000_config dib809x_dib8000_config = {
1747 .output_mpeg2_in_188_bytes = 1,
1748
1749 .agc_config_count = 2,
1750 .agc = dib8090_agc_config,
1751 .agc_control = dib0090_dcc_freq,
1752 .pll = &dib8090_pll_config_12mhz,
1753 .tuner_is_baseband = 1,
1754
1755 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
1756 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
1757 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
1758
1759 .hostbus_diversity = 1,
1760 .div_cfg = 0x31,
1761 .output_mode = OUTMODE_MPEG2_FIFO,
1762 .drives = 0x2d98,
1763 .diversity_delay = 144,
1764 .refclksel = 3,
1765};
1766
1767static struct dib0090_config dib809x_dib0090_config = {
1768 .io.pll_bypass = 1,
1769 .io.pll_range = 1,
1770 .io.pll_prediv = 1,
1771 .io.pll_loopdiv = 20,
1772 .io.adc_clock_ratio = 8,
1773 .io.pll_int_loop_filt = 0,
1774 .io.clock_khz = 12000,
1775 .reset = dib80xx_tuner_reset,
1776 .sleep = dib80xx_tuner_sleep,
1777 .clkouttobamse = 1,
1778 .analog_output = 1,
1779 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
1780 .wbd_vhf_offset = 100,
1781 .wbd_cband_offset = 450,
1782 .use_pwm_agc = 1,
1783 .clkoutdrive = 1,
1784 .get_adc_power = dib8090_get_adc_power,
1785 .freq_offset_khz_uhf = 0,
1786 .freq_offset_khz_vhf = -143,
1787};
1788
1789static int dib8096_set_param_override(struct dvb_frontend *fe,
1790 struct dvb_frontend_parameters *fep)
1791{
1792 struct dvb_usb_adapter *adap = fe->dvb->priv;
1793 struct dib0700_adapter_state *state = adap->priv;
1794 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1795 u16 offset;
1796 int ret = 0;
1797 enum frontend_tune_state tune_state = CT_SHUTDOWN;
1798 u16 ltgain, rf_gain_limit;
1799
1800 ret = state->set_param_save(fe, fep);
1801 if (ret < 0)
1802 return ret;
1803
1804 switch (band) {
1805 case BAND_VHF:
1806 offset = 100;
1807 break;
1808 case BAND_UHF:
1809 offset = 550;
1810 break;
1811 default:
1812 offset = 0;
1813 break;
1814 }
1815 offset += (dib0090_get_wbd_offset(fe) * 8 * 18 / 33 + 1) / 2;
1816 dib8000_set_wbd_ref(fe, offset);
1817
1818
1819 if (band == BAND_CBAND)
1820 {
1821 deb_info("tuning in CBAND - soft-AGC startup\n");
1822 /* TODO specific wbd target for dib0090 - needed for startup ? */
1823 dib0090_set_tune_state(fe, CT_AGC_START);
1824 do
1825 {
1826 ret = dib0090_gain_control(fe);
1827 msleep(ret);
1828 tune_state = dib0090_get_tune_state(fe);
1829 if (tune_state == CT_AGC_STEP_0)
1830 dib8000_set_gpio(fe, 6, 0, 1);
1831 else if (tune_state == CT_AGC_STEP_1)
1832 {
1833 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
1834 if (rf_gain_limit == 0)
1835 dib8000_set_gpio(fe, 6, 0, 0);
1836 }
1837 }
1838 while(tune_state<CT_AGC_STOP);
1839 dib0090_pwm_gain_reset(fe);
1840 dib8000_pwm_agc_reset(fe);
1841 dib8000_set_tune_state(fe, CT_DEMOD_START);
1842 }
1843 else {
1844 deb_info("not tuning in CBAND - standard AGC startup\n");
1845 dib0090_pwm_gain_reset(fe);
1846 }
1847
1848 return 0;
1849}
1850
1851static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
1852{
1853 struct dib0700_adapter_state *st = adap->priv;
1854 struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
1855
1856 if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &dib809x_dib0090_config) == NULL)
1857 return -ENODEV;
1858
1859 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1860 adap->fe->ops.tuner_ops.set_params = dib8096_set_param_override;
1861 return 0;
1862}
1863
1864static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
1865{
1866 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
1867 msleep(10);
1868 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1869 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
1870 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
1871
1872 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
1873
1874 dib0700_ctrl_clock(adap->dev, 72, 1);
1875
1876 msleep(10);
1877 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
1878 msleep(10);
1879 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
1880
1881 dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80);
1882
1883 adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config);
1884
1885 return adap->fe == NULL ? -ENODEV : 0;
1886}
1646 1887
1647/* STK7070PD */ 1888/* STK7070PD */
1648static struct dib7000p_config stk7070pd_dib7000p_config[2] = { 1889static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
@@ -1939,6 +2180,7 @@ struct usb_device_id dib0700_usb_id_table[] = {
1939 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) }, 2180 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
1940/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) }, 2181/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
1941 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, 2182 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) },
2183 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) },
1942 { 0 } /* Terminating entry */ 2184 { 0 } /* Terminating entry */
1943}; 2185};
1944MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 2186MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -2473,8 +2715,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2473 { 2715 {
2474 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 2716 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2475 .pid_filter_count = 32, 2717 .pid_filter_count = 32,
2476 .pid_filter = stk807x_pid_filter, 2718 .pid_filter = stk80xx_pid_filter,
2477 .pid_filter_ctrl = stk807x_pid_filter_ctrl, 2719 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
2478 .frontend_attach = stk807x_frontend_attach, 2720 .frontend_attach = stk807x_frontend_attach,
2479 .tuner_attach = dib807x_tuner_attach, 2721 .tuner_attach = dib807x_tuner_attach,
2480 2722
@@ -2512,8 +2754,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2512 { 2754 {
2513 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 2755 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2514 .pid_filter_count = 32, 2756 .pid_filter_count = 32,
2515 .pid_filter = stk807x_pid_filter, 2757 .pid_filter = stk80xx_pid_filter,
2516 .pid_filter_ctrl = stk807x_pid_filter_ctrl, 2758 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
2517 .frontend_attach = stk807xpvr_frontend_attach0, 2759 .frontend_attach = stk807xpvr_frontend_attach0,
2518 .tuner_attach = dib807x_tuner_attach, 2760 .tuner_attach = dib807x_tuner_attach,
2519 2761
@@ -2525,8 +2767,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2525 { 2767 {
2526 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 2768 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2527 .pid_filter_count = 32, 2769 .pid_filter_count = 32,
2528 .pid_filter = stk807x_pid_filter, 2770 .pid_filter = stk80xx_pid_filter,
2529 .pid_filter_ctrl = stk807x_pid_filter_ctrl, 2771 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
2530 .frontend_attach = stk807xpvr_frontend_attach1, 2772 .frontend_attach = stk807xpvr_frontend_attach1,
2531 .tuner_attach = dib807x_tuner_attach, 2773 .tuner_attach = dib807x_tuner_attach,
2532 2774
@@ -2549,6 +2791,37 @@ struct dvb_usb_device_properties dib0700_devices[] = {
2549 .rc_key_map = dib0700_rc_keys, 2791 .rc_key_map = dib0700_rc_keys,
2550 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), 2792 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2551 .rc_query = dib0700_rc_query 2793 .rc_query = dib0700_rc_query
2794 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
2795 .num_adapters = 1,
2796 .adapter = {
2797 {
2798 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
2799 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
2800 .pid_filter_count = 32,
2801 .pid_filter = stk80xx_pid_filter,
2802 .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
2803 .frontend_attach = stk809x_frontend_attach,
2804 .tuner_attach = dib809x_tuner_attach,
2805
2806 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
2807
2808 .size_of_priv =
2809 sizeof(struct dib0700_adapter_state),
2810 },
2811 },
2812
2813 .num_device_descs = 1,
2814 .devices = {
2815 { "DiBcom STK8096GP reference design",
2816 { &dib0700_usb_id_table[67], NULL },
2817 { NULL },
2818 },
2819 },
2820
2821 .rc_interval = DEFAULT_RC_INTERVAL,
2822 .rc_key_map = dib0700_rc_keys,
2823 .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys),
2824 .rc_query = dib0700_rc_query
2552 }, 2825 },
2553}; 2826};
2554 2827