]> git.karo-electronics.de Git - linux-beck.git/commitdiff
V4L/DVB: Adding support for MT2060 and thus for some DVB-USB-devices based on it
authorOlivier DANET <odanet@caramail.com>
Tue, 8 Aug 2006 18:48:09 +0000 (15:48 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Tue, 26 Sep 2006 14:53:41 +0000 (11:53 -0300)
- MT2060 tuner driver
- Added support for some USB DVB-T devices based on Dib3000P

Signed-off-by: Olivier DANET <odanet@caramail.com>
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/dvb/dvb-usb/dibusb-common.c
drivers/media/dvb/dvb-usb/dibusb-mb.c
drivers/media/dvb/dvb-usb/dibusb-mc.c
drivers/media/dvb/dvb-usb/dibusb.h
drivers/media/dvb/dvb-usb/dvb-usb-ids.h
drivers/media/dvb/frontends/dib3000mc.c
drivers/media/dvb/frontends/dib3000mc_priv.h

index abd75b4a350dab46c2d054d176edb991668f44bf..4d3d0d3dab950641c4837bf6cf48f70b5c8b7fb1 100644 (file)
@@ -168,15 +168,63 @@ int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)
 }
 EXPORT_SYMBOL(dibusb_read_eeprom_byte);
 
+static struct mt2060_config default_mt2060_config = {
+       .i2c_address = 0x60,
+};
+
+static int dibusb_tuner_init(struct dvb_frontend *fe)
+{
+       int ret;
+       struct dvb_usb_device *d = fe->dvb->priv;
+       struct dibusb_state *st = d->priv;
+
+       if (d->tuner_pass_ctrl) {
+               if ((int)d->fe->misc_priv==DIBUSB_TUNER_MT2060) { // Microtune MT2060
+                       d->tuner_pass_ctrl(d->fe,1,default_mt2060_config.i2c_address);
+                       ret=mt2060_init(&st->mt2060);
+               }
+               else { // Panasonic whatever
+                       d->tuner_pass_ctrl(d->fe,1,d->pll_addr);
+                       ret=dvb_usb_pll_init_i2c(fe);
+               }
+               d->tuner_pass_ctrl(d->fe,0,0);
+               return ret;
+       }
+       return -ENODEV;
+}
+
+static int dibusb_tuner_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
+{
+       int ret;
+       struct dvb_usb_device *d = fe->dvb->priv;
+       struct dibusb_state *st = d->priv;
+
+       if (d->tuner_pass_ctrl) {
+               if ((int)d->fe->misc_priv==DIBUSB_TUNER_MT2060) {
+                       d->tuner_pass_ctrl(d->fe,1,default_mt2060_config.i2c_address);
+                       ret=mt2060_set(&st->mt2060,fep);
+               }
+               else {
+                       d->tuner_pass_ctrl(d->fe,1,d->pll_addr);
+                       ret=dvb_usb_pll_set_i2c(fe,fep);
+               }
+               d->tuner_pass_ctrl(d->fe,0,0);
+               return ret;
+       }
+       return -ENODEV;
+}
+
 int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *d)
 {
        struct dib3000_config demod_cfg;
        struct dibusb_state *st = d->priv;
 
+       demod_cfg.pll_set = dibusb_tuner_set;
+       demod_cfg.pll_init = dibusb_tuner_init;
+
        for (demod_cfg.demod_address = 0x8; demod_cfg.demod_address < 0xd; demod_cfg.demod_address++)
                if ((d->fe = dib3000mc_attach(&demod_cfg,&d->i2c_adap,&st->ops)) != NULL) {
-                       d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
-                       d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
+                       d->fe->misc_priv=(void *)DIBUSB_TUNER_DEFAULT;
                        d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
                        return 0;
                }
@@ -187,13 +235,19 @@ EXPORT_SYMBOL(dibusb_dib3000mc_frontend_attach);
 
 int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d)
 {
+       int ret;
        d->pll_addr = 0x60;
        d->pll_desc = &dvb_pll_env57h1xd5;
-
-       d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
-       d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
-
-       return 0;
+       if (d->tuner_pass_ctrl) {
+               struct dibusb_state *st = d->priv;
+               d->tuner_pass_ctrl(d->fe,1,default_mt2060_config.i2c_address);
+               if ((ret = mt2060_attach(&st->mt2060,&default_mt2060_config, &d->i2c_adap)) == 0) {
+                       d->fe->misc_priv=(void *)DIBUSB_TUNER_MT2060;
+               }
+               d->tuner_pass_ctrl(d->fe,0,0);
+               return 0;
+       }
+       return -ENODEV;
 }
 EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach);
 
index f4c45f386ebc693992cb7a165bb76896c1c60086..dd5a131958862a8bd7090dc2328c81fc499bfc1a 100644 (file)
@@ -20,12 +20,11 @@ static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_device *d)
        struct dibusb_state *st = d->priv;
 
        demod_cfg.demod_address = 0x8;
+       demod_cfg.pll_set = dvb_usb_pll_set_i2c;
+       demod_cfg.pll_init = dvb_usb_pll_init_i2c;
 
-       if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL) {
-               d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
-               d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
+       if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL)
                return -ENODEV;
-       }
 
        d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
 
index 55802fba3c29ee71bc320cf056b6fa1a0c665eb7..2ef3d739abba07dc22a54712dcc40d110533cf95 100644 (file)
@@ -28,6 +28,13 @@ static struct usb_device_id dibusb_dib3000mc_table [] = {
 /* 00 */       { USB_DEVICE(USB_VID_DIBCOM,            USB_PID_DIBCOM_MOD3001_COLD) },
 /* 01 */       { USB_DEVICE(USB_VID_DIBCOM,            USB_PID_DIBCOM_MOD3001_WARM) },
 /* 02 */       { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) },
+/* 03 */       { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_WARM) }, // ( ? )
+/* 04 */       { USB_DEVICE(USB_VID_LITEON,            USB_PID_LITEON_DVB_T_COLD) },
+/* 05 */       { USB_DEVICE(USB_VID_LITEON,            USB_PID_LITEON_DVB_T_WARM) },
+/* 06 */       { USB_DEVICE(USB_VID_EMPIA,             USB_PID_DIGIVOX_MINI_SL_COLD) },
+/* 07 */       { USB_DEVICE(USB_VID_EMPIA,             USB_PID_DIGIVOX_MINI_SL_WARM) },
+/* 08 */        { USB_DEVICE(USB_VID_GRANDTEC,          USB_PID_GRANDTEC_DVBT_USB2_COLD) },
+/* 09 */        { USB_DEVICE(USB_VID_GRANDTEC,          USB_PID_GRANDTEC_DVBT_USB2_WARM) },
                        { }             /* Terminating entry */
 };
 MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
@@ -68,16 +75,30 @@ static struct dvb_usb_properties dibusb_mc_properties = {
                }
        },
 
-       .num_device_descs = 2,
+       .num_device_descs = 5,
        .devices = {
                {   "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
                        { &dibusb_dib3000mc_table[0], NULL },
                        { &dibusb_dib3000mc_table[1], NULL },
                },
-               {   "Artec T1 USB2.0 TVBOX (please report the warm ID)",
+               {   "Artec T1 USB2.0 TVBOX (please check the warm ID)",
                        { &dibusb_dib3000mc_table[2], NULL },
-                       { NULL },
+                       { &dibusb_dib3000mc_table[3], NULL },
                },
+               {   "LITE-ON USB2.0 DVB-T Tuner",
+                   /* Also rebranded as Intuix S800, Toshiba */
+                       { &dibusb_dib3000mc_table[4], NULL },
+                       { &dibusb_dib3000mc_table[5], NULL },
+               },
+               {   "MSI Digivox Mini SL",
+                       { &dibusb_dib3000mc_table[6], NULL },
+                       { &dibusb_dib3000mc_table[7], NULL },
+               },
+               {   "GRAND - USB2.0 DVB-T adapter",
+                       { &dibusb_dib3000mc_table[8], NULL },
+                       { &dibusb_dib3000mc_table[9], NULL },
+               },
+               { NULL },
        }
 };
 
index 2d99d05c7eab3c9f7dde14fa17db918d5e56233e..f3e3ea8c8dbba95b47c735729c3aafc29567d104 100644 (file)
@@ -17,6 +17,7 @@
 #include "dvb-usb.h"
 
 #include "dib3000.h"
+#include "mt2060.h"
 
 /*
  * protocol of all dibusb related devices
 #define DIBUSB_IOCTL_CMD_ENABLE_STREAM 0x01
 #define DIBUSB_IOCTL_CMD_DISABLE_STREAM        0x02
 
+/* Tuner types.
+   These constants shall correspond to the proper AGC values in the array
+   dib3000mc_agc_tuner[][12] in dib3000mc_priv.h */
+#define DIBUSB_TUNER_DEFAULT 1 // a.k.a Panasonic
+#define DIBUSB_TUNER_MT2060  4
+
+
 struct dibusb_state {
        struct dib_fe_xfer_ops ops;
+       struct mt2060_state mt2060;
 
        /* for RC5 remote control */
        int old_toggle;
index f10f49ad9b201d51431a602980f6413af6c6fcc0..6039e67425ac7d58a39e2dd9cd62c3c5f9e32451 100644 (file)
@@ -31,7 +31,7 @@
 #define USB_VID_VISIONPLUS                                     0x13d3
 #define USB_VID_TWINHAN                                                0x1822
 #define USB_VID_ULTIMA_ELECTRONIC                      0x05d8
-#define USB_VID_GENPIX                                 0x09c0
+#define USB_VID_LITEON                                 0x04ca
 
 /* Product IDs */
 #define USB_PID_ADSTECH_USB2_COLD                      0xa333
 #define USB_PID_DTT200U_WARM                           0x0301
 #define USB_PID_WT220U_COLD                                    0x0222
 #define USB_PID_WT220U_WARM                                    0x0221
-#define USB_PID_WT220U_FC_COLD                                 0x0225
-#define USB_PID_WT220U_FC_WARM                                 0x0226
-#define USB_PID_WT220U_ZL0353_COLD                     0x022a
-#define USB_PID_WT220U_ZL0353_WARM                     0x022b
 #define USB_PID_WINTV_NOVA_T_USB2_COLD         0x9300
 #define USB_PID_WINTV_NOVA_T_USB2_WARM         0x9301
 #define USB_PID_NEBULA_DIGITV                          0x0201
 #define USB_PID_KYE_DVB_T_WARM                         0x701f
 #define USB_PID_PCTV_200E                                      0x020e
 #define USB_PID_PCTV_400E                                      0x020f
-#define USB_PID_GENPIX_8PSK_COLD                               0x0200
-#define USB_PID_GENPIX_8PSK_WARM                               0x0201
+#define USB_PID_LITEON_DVB_T_COLD                      0xf000
+#define USB_PID_LITEON_DVB_T_WARM                      0xf001
+#define USB_PID_DIGIVOX_MINI_SL_COLD                   0xe360
+#define USB_PID_DIGIVOX_MINI_SL_WARM                   0xe361
+#define USB_PID_GRANDTEC_DVBT_USB2_COLD                        0x0bc6
+#define USB_PID_GRANDTEC_DVBT_USB2_WARM                        0x0bc7
+
 #endif
index 98673474a14021dd551ea887f9867e7b40ad4c79..66b30edad2e4c427940da03d24e89ca51ffcc28a 100644 (file)
@@ -20,6 +20,7 @@
  * see Documentation/dvb/README.dibusb for more information
  *
  */
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -461,9 +462,8 @@ static int dib3000mc_set_frontend(struct dvb_frontend* fe,
        int search_state,auto_val;
        u16 val;
 
-       if (tuner && fe->ops.tuner_ops.set_params) { /* initial call from dvb */
-               fe->ops.tuner_ops.set_params(fe, fep);
-               if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
+       if (tuner && state->config.pll_set) { /* initial call from dvb */
+               state->config.pll_set(fe,fep);
 
                state->last_tuned_freq = fep->frequency;
        //      if (!scanboost) {
@@ -558,6 +558,7 @@ static int dib3000mc_set_frontend(struct dvb_frontend* fe,
 static int dib3000mc_fe_init(struct dvb_frontend* fe, int mobile_mode)
 {
        struct dib3000_state *state = fe->demodulator_priv;
+       int AGCtuner=(int)fe->misc_priv;
        deb_info("init start\n");
 
        state->timing_offset = 0;
@@ -583,10 +584,11 @@ static int dib3000mc_fe_init(struct dvb_frontend* fe, int mobile_mode)
        /* mobile mode - portable reception */
        wr_foreach(dib3000mc_reg_mobile_mode,dib3000mc_mobile_mode[1]);
 
-/* TUNER_PANASONIC_ENV57H12D5: */
+/* TUNER_PANASONIC_ENV57H12D5 or TUNER_MICROTUNE_MT2060. Sets agc_tuner accordingly */
        wr_foreach(dib3000mc_reg_agc_bandwidth,dib3000mc_agc_bandwidth);
        wr_foreach(dib3000mc_reg_agc_bandwidth_general,dib3000mc_agc_bandwidth_general);
-       wr_foreach(dib3000mc_reg_agc,dib3000mc_agc_tuner[1]);
+       if (AGCtuner<0 || AGCtuner>=DIB3000MC_AGC_TUNER_COUNT) AGCtuner=1;
+       wr_foreach(dib3000mc_reg_agc,dib3000mc_agc_tuner[AGCtuner]);
 
        wr(DIB3000MC_REG_UNK_110,DIB3000MC_UNK_110);
        wr(26,0x6680);
@@ -642,6 +644,9 @@ static int dib3000mc_fe_init(struct dvb_frontend* fe, int mobile_mode)
 
        set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_DIV_IN_OFF);
 
+       if (state->config.pll_init)
+               state->config.pll_init(fe);
+
        deb_info("init end\n");
        return 0;
 }
@@ -836,6 +841,7 @@ struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
        /* setup the state */
        state->i2c = i2c;
        memcpy(&state->config,config,sizeof(struct dib3000_config));
+       memcpy(&state->ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops));
 
        /* check for the correct demod */
        if (rd(DIB3000_REG_MANUFACTOR_ID) != DIB3000_I2C_ID_DIBCOM)
@@ -855,7 +861,7 @@ struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
        }
 
        /* create dvb_frontend */
-       memcpy(&state->frontend.ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops));
+       state->frontend.ops = &state->ops;
        state->frontend.demodulator_priv = state;
 
        /* set the xfer operations */
@@ -872,7 +878,6 @@ error:
        kfree(state);
        return NULL;
 }
-EXPORT_SYMBOL(dib3000mc_attach);
 
 static struct dvb_frontend_ops dib3000mc_ops = {
 
@@ -911,3 +916,5 @@ static struct dvb_frontend_ops dib3000mc_ops = {
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(dib3000mc_attach);
index 2930aac7591b71234d00a8fecb232c82a2b6378c..e1d0c98cf914c0197d9bf639e7ab0de37f3c289a 100644 (file)
@@ -159,23 +159,34 @@ static u16 dib3000mc_imp_noise_ctl[][2] = {
 static u16 dib3000mc_reg_agc[] = {
        36,37,38,39,42,43,44,45,46,47,48,49
 };
+/* AGC settings. Don't change the ordering of the entries */
+#define DIB3000MC_AGC_TUNER_COUNT 5
 
 static u16 dib3000mc_agc_tuner[][12] = {
-       {       0x0051, 0x301d, 0x0000, 0x1cc7, 0xcf5c, 0x6666,
+/* 0*/ {       0x0051, 0x301d, 0x0000, 0x1cc7, 0xcf5c, 0x6666,
                0xbae1, 0xa148, 0x3b5e, 0x3c1c, 0x001a, 0x2019
        }, /* TUNER_PANASONIC_ENV77H04D5, */
 
-       {       0x0051, 0x301d, 0x0000, 0x1cc7, 0xdc29, 0x570a,
+/* 1*/ {       0x0051, 0x301d, 0x0000, 0x1cc7, 0xdc29, 0x570a,
                0xbae1, 0x8ccd, 0x3b6d, 0x551d, 0x000a, 0x951e
        }, /* TUNER_PANASONIC_ENV57H13D5, TUNER_PANASONIC_ENV57H12D5 */
 
-       {       0x0051, 0x301d, 0x0000, 0x1cc7, 0xffff, 0xffff,
+/* 2*/ {       0x0051, 0x301d, 0x0000, 0x1cc7, 0xffff, 0xffff,
                0xffff, 0x0000, 0xfdfd, 0x4040, 0x00fd, 0x4040
        }, /* TUNER_SAMSUNG_DTOS333IH102, TUNER_RFAGCIN_UNKNOWN */
 
-       {       0x0196, 0x301d, 0x0000, 0x1cc7, 0xbd71, 0x5c29,
+/* 3*/ {       0x0196, 0x301d, 0x0000, 0x1cc7, 0xbd71, 0x5c29,
                0xb5c3, 0x6148, 0x6569, 0x5127, 0x0033, 0x3537
        }, /* TUNER_PROVIDER_X */
+
+/* 4*/ {       0x0196, 0x301d, 0x0000, 0x1cc7, 0xffff, 0x5c29,
+               0xa8f6, 0x5eb8, 0x65ff, 0x40ff, 0x008a, 0x1114
+       }, /* TUNER_MT2060 ( as in DibCom driver )*/
+
+/*     {       0x0196, 0x301d, 0x0000, 0x1cc7, 0xbd71, 0x5c29,
+               0xb5c3, 0x6148, 0x0045, 0x5127, 0x0033, 0x3437
+       },*//* TUNER_MT2060 ( as in LITE-ON driver )*/
+
        /* TODO TUNER_PANASONIC_ENV57H10D8, TUNER_PANASONIC_ENV57H11D8 */
 };