Merge branch 'drm-intel-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ickle...
[pandora-kernel.git] / drivers / media / video / cx88 / cx88-dvb.c
index faa8e81..367a653 100644 (file)
@@ -56,6 +56,7 @@
 #include "stv0900.h"
 #include "stb6100.h"
 #include "stb6100_proc.h"
+#include "mb86a16.h"
 
 MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
@@ -105,7 +106,7 @@ static void dvb_buf_release(struct videobuf_queue *q,
        cx88_free_buffer(q, (struct cx88_buffer*)vb);
 }
 
-static struct videobuf_queue_ops dvb_qops = {
+static const struct videobuf_queue_ops dvb_qops = {
        .buf_setup    = dvb_buf_setup,
        .buf_prepare  = dvb_buf_prepare,
        .buf_queue    = dvb_buf_queue,
@@ -167,12 +168,12 @@ static void cx88_dvb_gate_ctrl(struct cx88_core  *core, int open)
 
 static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
 {
-       static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x39 };
-       static u8 reset []         = { RESET,      0x80 };
-       static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
-       static u8 agc_cfg []       = { AGC_TARGET, 0x24, 0x20 };
-       static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
-       static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
+       static const u8 clock_config []  = { CLOCK_CTL,  0x38, 0x39 };
+       static const u8 reset []         = { RESET,      0x80 };
+       static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
+       static const u8 agc_cfg []       = { AGC_TARGET, 0x24, 0x20 };
+       static const u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
+       static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
 
        mt352_write(fe, clock_config,   sizeof(clock_config));
        udelay(200);
@@ -187,12 +188,12 @@ static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
 
 static int dvico_dual_demod_init(struct dvb_frontend *fe)
 {
-       static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x38 };
-       static u8 reset []         = { RESET,      0x80 };
-       static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
-       static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0x20 };
-       static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
-       static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
+       static const u8 clock_config []  = { CLOCK_CTL,  0x38, 0x38 };
+       static const u8 reset []         = { RESET,      0x80 };
+       static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
+       static const u8 agc_cfg []       = { AGC_TARGET, 0x28, 0x20 };
+       static const u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
+       static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
 
        mt352_write(fe, clock_config,   sizeof(clock_config));
        udelay(200);
@@ -208,13 +209,13 @@ static int dvico_dual_demod_init(struct dvb_frontend *fe)
 
 static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
 {
-       static u8 clock_config []  = { 0x89, 0x38, 0x39 };
-       static u8 reset []         = { 0x50, 0x80 };
-       static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
-       static u8 agc_cfg []       = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
+       static const u8 clock_config []  = { 0x89, 0x38, 0x39 };
+       static const u8 reset []         = { 0x50, 0x80 };
+       static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+       static const u8 agc_cfg []       = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
                                       0x00, 0xFF, 0x00, 0x40, 0x40 };
-       static u8 dntv_extra[]     = { 0xB5, 0x7A };
-       static u8 capt_range_cfg[] = { 0x75, 0x32 };
+       static const u8 dntv_extra[]     = { 0xB5, 0x7A };
+       static const u8 capt_range_cfg[] = { 0x75, 0x32 };
 
        mt352_write(fe, clock_config,   sizeof(clock_config));
        udelay(2000);
@@ -229,37 +230,41 @@ static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
        return 0;
 }
 
-static struct mt352_config dvico_fusionhdtv = {
+static const struct mt352_config dvico_fusionhdtv = {
        .demod_address = 0x0f,
        .demod_init    = dvico_fusionhdtv_demod_init,
 };
 
-static struct mt352_config dntv_live_dvbt_config = {
+static const struct mt352_config dntv_live_dvbt_config = {
        .demod_address = 0x0f,
        .demod_init    = dntv_live_dvbt_demod_init,
 };
 
-static struct mt352_config dvico_fusionhdtv_dual = {
+static const struct mt352_config dvico_fusionhdtv_dual = {
        .demod_address = 0x0f,
        .demod_init    = dvico_dual_demod_init,
 };
 
-static struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
+static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
        .demod_address = (0x1e >> 1),
        .no_tuner      = 1,
        .if2           = 45600,
 };
 
+static struct mb86a16_config twinhan_vp1027 = {
+       .demod_address  = 0x08,
+};
+
 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
 static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
 {
-       static u8 clock_config []  = { 0x89, 0x38, 0x38 };
-       static u8 reset []         = { 0x50, 0x80 };
-       static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
-       static u8 agc_cfg []       = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
+       static const u8 clock_config []  = { 0x89, 0x38, 0x38 };
+       static const u8 reset []         = { 0x50, 0x80 };
+       static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+       static const u8 agc_cfg []       = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
                                       0x00, 0xFF, 0x00, 0x40, 0x40 };
-       static u8 dntv_extra[]     = { 0xB5, 0x7A };
-       static u8 capt_range_cfg[] = { 0x75, 0x32 };
+       static const u8 dntv_extra[]     = { 0xB5, 0x7A };
+       static const u8 capt_range_cfg[] = { 0x75, 0x32 };
 
        mt352_write(fe, clock_config,   sizeof(clock_config));
        udelay(2000);
@@ -274,41 +279,41 @@ static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
        return 0;
 }
 
-static struct mt352_config dntv_live_dvbt_pro_config = {
+static const struct mt352_config dntv_live_dvbt_pro_config = {
        .demod_address = 0x0f,
        .no_tuner      = 1,
        .demod_init    = dntv_live_dvbt_pro_demod_init,
 };
 #endif
 
-static struct zl10353_config dvico_fusionhdtv_hybrid = {
+static const struct zl10353_config dvico_fusionhdtv_hybrid = {
        .demod_address = 0x0f,
        .no_tuner      = 1,
 };
 
-static struct zl10353_config dvico_fusionhdtv_xc3028 = {
+static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
        .demod_address = 0x0f,
        .if2           = 45600,
        .no_tuner      = 1,
 };
 
-static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
+static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
        .demod_address = 0x0f,
        .if2 = 4560,
        .no_tuner = 1,
        .demod_init = dvico_fusionhdtv_demod_init,
 };
 
-static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
+static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
        .demod_address = 0x0f,
 };
 
-static struct cx22702_config connexant_refboard_config = {
+static const struct cx22702_config connexant_refboard_config = {
        .demod_address = 0x43,
        .output_mode   = CX22702_SERIAL_OUTPUT,
 };
 
-static struct cx22702_config hauppauge_hvr_config = {
+static const struct cx22702_config hauppauge_hvr_config = {
        .demod_address = 0x63,
        .output_mode   = CX22702_SERIAL_OUTPUT,
 };
@@ -320,7 +325,7 @@ static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
        return 0;
 }
 
-static struct or51132_config pchdtv_hd3000 = {
+static const struct or51132_config pchdtv_hd3000 = {
        .demod_address = 0x15,
        .set_ts_params = or51132_set_ts_param,
 };
@@ -355,14 +360,14 @@ static struct lgdt330x_config fusionhdtv_3_gold = {
        .set_ts_params = lgdt330x_set_ts_param,
 };
 
-static struct lgdt330x_config fusionhdtv_5_gold = {
+static const struct lgdt330x_config fusionhdtv_5_gold = {
        .demod_address = 0x0e,
        .demod_chip    = LGDT3303,
        .serial_mpeg   = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
        .set_ts_params = lgdt330x_set_ts_param,
 };
 
-static struct lgdt330x_config pchdtv_hd5500 = {
+static const struct lgdt330x_config pchdtv_hd5500 = {
        .demod_address = 0x59,
        .demod_chip    = LGDT3303,
        .serial_mpeg   = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
@@ -376,7 +381,7 @@ static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
        return 0;
 }
 
-static struct nxt200x_config ati_hdtvwonder = {
+static const struct nxt200x_config ati_hdtvwonder = {
        .demod_address = 0x0a,
        .set_ts_params = nxt200x_set_ts_param,
 };
@@ -429,15 +434,15 @@ static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
 
        cx_set(MO_GP0_IO, 0x6040);
        switch (voltage) {
-               case SEC_VOLTAGE_13:
-                       cx_clear(MO_GP0_IO, 0x20);
-                       break;
-               case SEC_VOLTAGE_18:
-                       cx_set(MO_GP0_IO, 0x20);
-                       break;
-               case SEC_VOLTAGE_OFF:
-                       cx_clear(MO_GP0_IO, 0x20);
-                       break;
+       case SEC_VOLTAGE_13:
+               cx_clear(MO_GP0_IO, 0x20);
+               break;
+       case SEC_VOLTAGE_18:
+               cx_set(MO_GP0_IO, 0x20);
+               break;
+       case SEC_VOLTAGE_OFF:
+               cx_clear(MO_GP0_IO, 0x20);
+               break;
        }
 
        if (core->prev_set_voltage)
@@ -445,23 +450,49 @@ static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
        return 0;
 }
 
-static struct cx24123_config geniatech_dvbs_config = {
+static int vp1027_set_voltage(struct dvb_frontend *fe,
+                                   fe_sec_voltage_t voltage)
+{
+       struct cx8802_dev *dev = fe->dvb->priv;
+       struct cx88_core *core = dev->core;
+
+       switch (voltage) {
+       case SEC_VOLTAGE_13:
+               dprintk(1, "LNB SEC Voltage=13\n");
+               cx_write(MO_GP0_IO, 0x00001220);
+               break;
+       case SEC_VOLTAGE_18:
+               dprintk(1, "LNB SEC Voltage=18\n");
+               cx_write(MO_GP0_IO, 0x00001222);
+               break;
+       case SEC_VOLTAGE_OFF:
+               dprintk(1, "LNB Voltage OFF\n");
+               cx_write(MO_GP0_IO, 0x00001230);
+               break;
+       }
+
+       if (core->prev_set_voltage)
+               return core->prev_set_voltage(fe, voltage);
+       return 0;
+}
+
+static const struct cx24123_config geniatech_dvbs_config = {
        .demod_address = 0x55,
        .set_ts_params = cx24123_set_ts_param,
 };
 
-static struct cx24123_config hauppauge_novas_config = {
+static const struct cx24123_config hauppauge_novas_config = {
        .demod_address = 0x55,
        .set_ts_params = cx24123_set_ts_param,
 };
 
-static struct cx24123_config kworld_dvbs_100_config = {
+static const struct cx24123_config kworld_dvbs_100_config = {
        .demod_address = 0x15,
        .set_ts_params = cx24123_set_ts_param,
        .lnb_polarity  = 1,
 };
 
-static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
+static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
        .demod_address = 0x32 >> 1,
        .output_mode   = S5H1409_PARALLEL_OUTPUT,
        .gpio          = S5H1409_GPIO_ON,
@@ -471,7 +502,7 @@ static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
        .mpeg_timing   = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
 };
 
-static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
+static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
        .demod_address = 0x32 >> 1,
        .output_mode   = S5H1409_SERIAL_OUTPUT,
        .gpio          = S5H1409_GPIO_OFF,
@@ -480,7 +511,7 @@ static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
        .mpeg_timing   = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
 };
 
-static struct s5h1409_config kworld_atsc_120_config = {
+static const struct s5h1409_config kworld_atsc_120_config = {
        .demod_address = 0x32 >> 1,
        .output_mode   = S5H1409_SERIAL_OUTPUT,
        .gpio          = S5H1409_GPIO_OFF,
@@ -489,24 +520,24 @@ static struct s5h1409_config kworld_atsc_120_config = {
        .mpeg_timing   = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
 };
 
-static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
+static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
        .i2c_address    = 0x64,
        .if_khz         = 5380,
 };
 
-static struct zl10353_config cx88_pinnacle_hybrid_pctv = {
+static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
        .demod_address = (0x1e >> 1),
        .no_tuner      = 1,
        .if2           = 45600,
 };
 
-static struct zl10353_config cx88_geniatech_x8000_mt = {
+static const struct zl10353_config cx88_geniatech_x8000_mt = {
        .demod_address = (0x1e >> 1),
        .no_tuner = 1,
        .disable_i2c_gate_ctrl = 1,
 };
 
-static struct s5h1411_config dvico_fusionhdtv7_config = {
+static const struct s5h1411_config dvico_fusionhdtv7_config = {
        .output_mode   = S5H1411_SERIAL_OUTPUT,
        .gpio          = S5H1411_GPIO_ON,
        .mpeg_timing   = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
@@ -516,7 +547,7 @@ static struct s5h1411_config dvico_fusionhdtv7_config = {
        .status_mode   = S5H1411_DEMODLOCKING
 };
 
-static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
+static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
        .i2c_address    = 0xc2 >> 1,
        .if_khz         = 5380,
 };
@@ -601,19 +632,19 @@ static int cx24116_reset_device(struct dvb_frontend *fe)
        return 0;
 }
 
-static struct cx24116_config hauppauge_hvr4000_config = {
+static const struct cx24116_config hauppauge_hvr4000_config = {
        .demod_address          = 0x05,
        .set_ts_params          = cx24116_set_ts_param,
        .reset_device           = cx24116_reset_device,
 };
 
-static struct cx24116_config tevii_s460_config = {
+static const struct cx24116_config tevii_s460_config = {
        .demod_address = 0x55,
        .set_ts_params = cx24116_set_ts_param,
        .reset_device  = cx24116_reset_device,
 };
 
-static struct stv0900_config prof_7301_stv0900_config = {
+static const struct stv0900_config prof_7301_stv0900_config = {
        .demod_address = 0x6a,
 /*     demod_mode = 0,*/
        .xtal = 27000000,
@@ -625,12 +656,12 @@ static struct stv0900_config prof_7301_stv0900_config = {
        .set_ts_params = stv0900_set_ts_param,
 };
 
-static struct stb6100_config prof_7301_stb6100_config = {
+static const struct stb6100_config prof_7301_stb6100_config = {
        .tuner_address = 0x60,
        .refclock = 27000000,
 };
 
-static struct stv0299_config tevii_tuner_sharp_config = {
+static const struct stv0299_config tevii_tuner_sharp_config = {
        .demod_address = 0x68,
        .inittab = sharp_z0194a_inittab,
        .mclk = 88000000UL,
@@ -643,7 +674,7 @@ static struct stv0299_config tevii_tuner_sharp_config = {
        .set_ts_params = cx24116_set_ts_param,
 };
 
-static struct stv0288_config tevii_tuner_earda_config = {
+static const struct stv0288_config tevii_tuner_earda_config = {
        .demod_address = 0x68,
        .min_delay_ms = 100,
        .set_ts_params = cx24116_set_ts_param,
@@ -676,7 +707,7 @@ static int cx8802_alloc_frontends(struct cx8802_dev *dev)
 
 
 
-static u8 samsung_smt_7020_inittab[] = {
+static const u8 samsung_smt_7020_inittab[] = {
             0x01, 0x15,
             0x02, 0x00,
             0x03, 0x00,
@@ -850,7 +881,7 @@ static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
 }
 
 
-static struct stv0299_config samsung_stv0299_config = {
+static const struct stv0299_config samsung_stv0299_config = {
        .demod_address = 0x68,
        .inittab = samsung_smt_7020_inittab,
        .mclk = 88000000UL,
@@ -1416,6 +1447,18 @@ static int dvb_register(struct cx8802_dev *dev)
                }
 
                break;
+       case CX88_BOARD_TWINHAN_VP1027_DVBS:
+               dev->ts_gen_cntrl = 0x00;
+               fe0->dvb.frontend = dvb_attach(mb86a16_attach,
+                                               &twinhan_vp1027,
+                                               &core->i2c_adap);
+               if (fe0->dvb.frontend) {
+                       core->prev_set_voltage =
+                                       fe0->dvb.frontend->ops.set_voltage;
+                       fe0->dvb.frontend->ops.set_voltage =
+                                       vp1027_set_voltage;
+               }
+               break;
 
        default:
                printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
@@ -1576,7 +1619,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
                                    V4L2_BUF_TYPE_VIDEO_CAPTURE,
                                    V4L2_FIELD_TOP,
                                    sizeof(struct cx88_buffer),
-                                   dev);
+                                   dev, NULL);
                /* init struct videobuf_dvb */
                fe->dvb.name = dev->core->name;
        }