tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / media / video / cx23885 / cx23885-dvb.c
index 45784a3..16c6a92 100644 (file)
 #include "dibx000_common.h"
 #include "zl10353.h"
 #include "stv0900.h"
+#include "stv0900_reg.h"
 #include "stv6110.h"
 #include "lnbh24.h"
 #include "cx24116.h"
 #include "cimax2.h"
+#include "lgs8gxx.h"
 #include "netup-eeprom.h"
 #include "netup-init.h"
 #include "lgdt3305.h"
@@ -241,17 +243,30 @@ static struct tda18271_std_map hauppauge_tda18271_std_map = {
                      .if_lvl = 6, .rfagc_top = 0x37 },
 };
 
+static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
+       .dvbt_6   = { .if_freq = 3300, .agc_mode = 3, .std = 4,
+                     .if_lvl = 1, .rfagc_top = 0x37, },
+       .dvbt_7   = { .if_freq = 3800, .agc_mode = 3, .std = 5,
+                     .if_lvl = 1, .rfagc_top = 0x37, },
+       .dvbt_8   = { .if_freq = 4300, .agc_mode = 3, .std = 6,
+                     .if_lvl = 1, .rfagc_top = 0x37, },
+};
+
 static struct tda18271_config hauppauge_tda18271_config = {
        .std_map = &hauppauge_tda18271_std_map,
        .gate    = TDA18271_GATE_ANALOG,
+       .output_opt = TDA18271_OUTPUT_LT_OFF,
 };
 
 static struct tda18271_config hauppauge_hvr1200_tuner_config = {
+       .std_map = &hauppauge_hvr1200_tda18271_std_map,
        .gate    = TDA18271_GATE_ANALOG,
+       .output_opt = TDA18271_OUTPUT_LT_OFF,
 };
 
 static struct tda18271_config hauppauge_hvr1210_tuner_config = {
        .gate    = TDA18271_GATE_DIGITAL,
+       .output_opt = TDA18271_OUTPUT_LT_OFF,
 };
 
 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
@@ -263,6 +278,7 @@ static struct tda18271_std_map hauppauge_hvr127x_std_map = {
 
 static struct tda18271_config hauppauge_hvr127x_config = {
        .std_map = &hauppauge_hvr127x_std_map,
+       .output_opt = TDA18271_OUTPUT_LT_OFF,
 };
 
 static struct lgdt3305_config hauppauge_lgdt3305_config = {
@@ -369,13 +385,25 @@ static struct zl10353_config dvico_fusionhdtv_xc3028 = {
        .disable_i2c_gate_ctrl = 1,
 };
 
+static struct stv0900_reg stv0900_ts_regs[] = {
+       { R0900_TSGENERAL, 0x00 },
+       { R0900_P1_TSSPEED, 0x40 },
+       { R0900_P2_TSSPEED, 0x40 },
+       { R0900_P1_TSCFGM, 0xc0 },
+       { R0900_P2_TSCFGM, 0xc0 },
+       { R0900_P1_TSCFGH, 0xe0 },
+       { R0900_P2_TSCFGH, 0xe0 },
+       { R0900_P1_TSCFGL, 0x20 },
+       { R0900_P2_TSCFGL, 0x20 },
+       { 0xffff, 0xff }, /* terminate */
+};
+
 static struct stv0900_config netup_stv0900_config = {
        .demod_address = 0x68,
-       .xtal = 27000000,
+       .xtal = 8000000,
        .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
        .diseqc_mode = 2,/* 2/3 PWM */
-       .path1_mode = 2,/*Serial continues clock */
-       .path2_mode = 2,/*Serial continues clock */
+       .ts_config_regs = stv0900_ts_regs,
        .tun1_maddress = 0,/* 0x60 */
        .tun2_maddress = 3,/* 0x63 */
        .tun1_adc = 1,/* 1 Vpp */
@@ -384,14 +412,14 @@ static struct stv0900_config netup_stv0900_config = {
 
 static struct stv6110_config netup_stv6110_tunerconfig_a = {
        .i2c_address = 0x60,
-       .mclk = 27000000,
-       .iq_wiring = 0,
+       .mclk = 16000000,
+       .clk_div = 1,
 };
 
 static struct stv6110_config netup_stv6110_tunerconfig_b = {
        .i2c_address = 0x63,
-       .mclk = 27000000,
-       .iq_wiring = 1,
+       .mclk = 16000000,
+       .clk_div = 1,
 };
 
 static int tbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
@@ -420,10 +448,73 @@ static struct cx24116_config dvbworld_cx24116_config = {
        .demod_address = 0x05,
 };
 
+static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
+       .prod = LGS8GXX_PROD_LGS8GL5,
+       .demod_address = 0x19,
+       .serial_ts = 0,
+       .ts_clk_pol = 1,
+       .ts_clk_gated = 1,
+       .if_clk_freq = 30400, /* 30.4 MHz */
+       .if_freq = 5380, /* 5.38 MHz */
+       .if_neg_center = 1,
+       .ext_adc = 0,
+       .adc_signed = 0,
+       .if_neg_edge = 0,
+};
+
+static struct xc5000_config mygica_x8506_xc5000_config = {
+       .i2c_address = 0x61,
+       .if_khz = 5380,
+};
+
+static int cx23885_dvb_set_frontend(struct dvb_frontend *fe,
+                                   struct dvb_frontend_parameters *param)
+{
+       struct cx23885_tsport *port = fe->dvb->priv;
+       struct cx23885_dev *dev = port->dev;
+
+       switch (dev->board) {
+       case CX23885_BOARD_HAUPPAUGE_HVR1275:
+               switch (param->u.vsb.modulation) {
+               case VSB_8:
+                       cx23885_gpio_clear(dev, GPIO_5);
+                       break;
+               case QAM_64:
+               case QAM_256:
+               default:
+                       cx23885_gpio_set(dev, GPIO_5);
+                       break;
+               }
+               break;
+       }
+       return (port->set_frontend_save) ?
+               port->set_frontend_save(fe, param) : -ENODEV;
+}
+
+static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
+       .prod = LGS8GXX_PROD_LGS8G75,
+       .demod_address = 0x19,
+       .serial_ts = 0,
+       .ts_clk_pol = 1,
+       .ts_clk_gated = 1,
+       .if_clk_freq = 30400, /* 30.4 MHz */
+       .if_freq = 6500, /* 6.50 MHz */
+       .if_neg_center = 1,
+       .ext_adc = 0,
+       .adc_signed = 1,
+       .adc_vpp = 2, /* 1.6 Vpp */
+       .if_neg_edge = 1,
+};
+
+static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
+       .i2c_address = 0x61,
+       .if_khz = 6500,
+};
+
 static int dvb_register(struct cx23885_tsport *port)
 {
        struct cx23885_dev *dev = port->dev;
-       struct cx23885_i2c *i2c_bus = NULL;
+       struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
        struct videobuf_dvb_frontend *fe0;
        int ret;
 
@@ -459,6 +550,12 @@ static int dvb_register(struct cx23885_tsport *port)
                                   0x60, &dev->i2c_bus[1].i2c_adap,
                                   &hauppauge_hvr127x_config);
                }
+
+               /* FIXME: temporary hack */
+               /* define bridge override to set_frontend */
+               port->set_frontend_save = fe0->dvb.frontend->ops.set_frontend;
+               fe0->dvb.frontend->ops.set_frontend = cx23885_dvb_set_frontend;
+
                break;
        case CX23885_BOARD_HAUPPAUGE_HVR1255:
                i2c_bus = &dev->i2c_bus[0];
@@ -650,6 +747,7 @@ static int dvb_register(struct cx23885_tsport *port)
        }
        case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
        case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
+       case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
                i2c_bus = &dev->i2c_bus[0];
 
                fe0->dvb.frontend = dvb_attach(zl10353_attach,
@@ -716,7 +814,8 @@ static int dvb_register(struct cx23885_tsport *port)
                                        if (!dvb_attach(lnbh24_attach,
                                                        fe0->dvb.frontend,
                                                        &i2c_bus->i2c_adap,
-                                                       LNBH24_PCL, 0, 0x09))
+                                                       LNBH24_PCL,
+                                                       LNBH24_TTX, 0x09))
                                                printk(KERN_ERR
                                                        "No LNBH24 found!\n");
 
@@ -736,7 +835,8 @@ static int dvb_register(struct cx23885_tsport *port)
                                        if (!dvb_attach(lnbh24_attach,
                                                        fe0->dvb.frontend,
                                                        &i2c_bus->i2c_adap,
-                                                       LNBH24_PCL, 0, 0x0a))
+                                                       LNBH24_PCL,
+                                                       LNBH24_TTX, 0x0a))
                                                printk(KERN_ERR
                                                        "No LNBH24 found!\n");
 
@@ -745,6 +845,43 @@ static int dvb_register(struct cx23885_tsport *port)
                        break;
                }
                break;
+       case CX23885_BOARD_MYGICA_X8506:
+               i2c_bus = &dev->i2c_bus[0];
+               i2c_bus2 = &dev->i2c_bus[1];
+               fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
+                       &mygica_x8506_lgs8gl5_config,
+                       &i2c_bus->i2c_adap);
+               if (fe0->dvb.frontend != NULL) {
+                       dvb_attach(xc5000_attach,
+                               fe0->dvb.frontend,
+                               &i2c_bus2->i2c_adap,
+                               &mygica_x8506_xc5000_config);
+               }
+               break;
+       case CX23885_BOARD_MAGICPRO_PROHDTVE2:
+               i2c_bus = &dev->i2c_bus[0];
+               i2c_bus2 = &dev->i2c_bus[1];
+               fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
+                       &magicpro_prohdtve2_lgs8g75_config,
+                       &i2c_bus->i2c_adap);
+               if (fe0->dvb.frontend != NULL) {
+                       dvb_attach(xc5000_attach,
+                               fe0->dvb.frontend,
+                               &i2c_bus2->i2c_adap,
+                               &magicpro_prohdtve2_xc5000_config);
+               }
+               break;
+       case CX23885_BOARD_HAUPPAUGE_HVR1850:
+               i2c_bus = &dev->i2c_bus[0];
+               fe0->dvb.frontend = dvb_attach(s5h1411_attach,
+                       &hcw_s5h1411_config,
+                       &i2c_bus->i2c_adap);
+               if (fe0->dvb.frontend != NULL)
+                       dvb_attach(tda18271_attach, fe0->dvb.frontend,
+                               0x60, &dev->i2c_bus[0].i2c_adap,
+                               &hauppauge_tda18271_config);
+               break;
+
        default:
                printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
                        " isn't supported yet\n",
@@ -803,7 +940,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
        int err, i;
 
        /* Here we need to allocate the correct number of frontends,
-        * as reflected in the cards struct. The reality is that currrently
+        * as reflected in the cards struct. The reality is that currently
         * no cx23885 boards support this - yet. But, if we don't modify this
         * code then the second frontend would never be allocated (later)
         * and fail with error before the attach in dvb_register().