diff options
Diffstat (limited to 'linux/drivers/media/video/cx88/cx88-dvb.c')
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-dvb.c | 151 |
1 files changed, 28 insertions, 123 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-dvb.c b/linux/drivers/media/video/cx88/cx88-dvb.c index 25632897c..b467c9b75 100644 --- a/linux/drivers/media/video/cx88/cx88-dvb.c +++ b/linux/drivers/media/video/cx88/cx88-dvb.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-dvb.c,v 1.20 2004/11/30 17:00:13 kraxel Exp $ + * $Id: cx88-dvb.c,v 1.21 2004/12/09 12:51:35 kraxel Exp $ * * device driver for Conexant 2388x based TV cards * MPEG Transport Stream (DVB) routines @@ -31,6 +31,7 @@ #include <linux/suspend.h> #include "cx88.h" +#include "dvb-pll.h" #include "cx22702.h" #include "mt352.h" #include "mt352_priv.h" /* FIXME */ @@ -110,74 +111,6 @@ static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) return 0; } -#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ - -static int lg_z201_pll_set(struct dvb_frontend* fe, - struct dvb_frontend_parameters* params, u8* pllbuf) -{ - u32 div; - unsigned char cp = 0; - unsigned char bs = 0; - - div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - - if (params->frequency < 542000000) cp = 0xbc; - else if (params->frequency < 830000000) cp = 0xf4; - else cp = 0xfc; - - if (params->frequency == 0) bs = 0x03; - else if (params->frequency < 157500000) bs = 0x01; - else if (params->frequency < 443250000) bs = 0x02; - else bs = 0x04; - - pllbuf[0] = 0xC2; /* Note: non-linux standard PLL I2C address */ - pllbuf[1] = div >> 8; - pllbuf[2] = div & 0xff; - pllbuf[3] = cp; - pllbuf[4] = bs; - - return 0; -} - -static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, - struct dvb_frontend_parameters* params, - u8* pllbuf) -{ - u32 div; - unsigned char cp = 0; - unsigned char bs = 0; - - div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - - if (params->frequency < 542000000) cp = 0xb4; - else if (params->frequency < 771000000) cp = 0xbc; - else cp = 0xf4; - - if (params->frequency == 0) bs = 0x03; - else if (params->frequency < 443250000) bs = 0x02; - else bs = 0x08; - - pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address - pllbuf[1] = div >> 8; - pllbuf[2] = div & 0xff; - pllbuf[3] = cp; - pllbuf[4] = bs; - - return 0; -} - -struct mt352_config dvico_fusionhdtv_dvbt1 = { - .demod_address = 0x0F, - .demod_init = dvico_fusionhdtv_demod_init, - .pll_set = lg_z201_pll_set, -}; - -struct mt352_config dvico_fusionhdtv_dvbt_plus = { - .demod_address = 0x0F, - .demod_init = dvico_fusionhdtv_demod_init, - .pll_set = thomson_dtt7579_pll_set, -}; - static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe) { static u8 clock_config [] = { 0x89, 0x38, 0x39 }; @@ -201,49 +134,29 @@ static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe) return 0; } -static int dntv_live_dvbt_pll_set(struct dvb_frontend* fe, - struct dvb_frontend_parameters* params, - u8* pllbuf) +static int mt352_pll_set(struct dvb_frontend* fe, + struct dvb_frontend_parameters* params, + u8* pllbuf) { - u32 div; - unsigned char bs = 0; - unsigned char cp = 0; - - div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; - - if (params->frequency < 150000000) cp = 0xB4; - else if (params->frequency < 173000000) cp = 0xBC; - else if (params->frequency < 250000000) cp = 0xB4; - else if (params->frequency < 400000000) cp = 0xBC; - else if (params->frequency < 420000000) cp = 0xF4; - else if (params->frequency < 470000000) cp = 0xFC; - else if (params->frequency < 600000000) cp = 0xBC; - else if (params->frequency < 730000000) cp = 0xF4; - else cp = 0xFC; - - if (params->frequency < 150000000) bs = 0x01; - else if (params->frequency < 173000000) bs = 0x01; - else if (params->frequency < 250000000) bs = 0x02; - else if (params->frequency < 400000000) bs = 0x02; - else if (params->frequency < 420000000) bs = 0x02; - else if (params->frequency < 470000000) bs = 0x02; - else if (params->frequency < 600000000) bs = 0x08; - else if (params->frequency < 730000000) bs = 0x08; - else bs = 0x08; - - pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address - pllbuf[1] = div >> 8; - pllbuf[2] = div & 0xff; - pllbuf[3] = cp; - pllbuf[4] = bs; + struct cx8802_dev *dev= fe->dvb->priv; + pllbuf[0] = dev->core->pll_addr << 1; + dvb_pll_configure(dev->core->pll_desc, pllbuf+1, + params->frequency, + params->u.ofdm.bandwidth); return 0; } +static struct mt352_config dvico_fusionhdtv = { + .demod_address = 0x0F, + .demod_init = dvico_fusionhdtv_demod_init, + .pll_set = mt352_pll_set, +}; + static struct mt352_config dntv_live_dvbt_config = { .demod_address = 0x0f, .demod_init = dntv_live_dvbt_demod_init, - .pll_set = dntv_live_dvbt_pll_set, + .pll_set = mt352_pll_set, }; static int dvb_register(struct cx8802_dev *dev) @@ -257,40 +170,32 @@ static int dvb_register(struct cx8802_dev *dev) case CX88_BOARD_CONEXANT_DVB_T1: dev->dvb.frontend = cx22702_create(&dev->core->i2c_adap, dev->core->pll_addr, - dev->core->pll_type, + dev->core->pll_desc, dev->core->demod_addr); break; case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: - dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt1, - &dev->core->i2c_adap); - if (dev->dvb.frontend) { - dev->dvb.frontend->ops->info.frequency_min = 174000000; - dev->dvb.frontend->ops->info.frequency_max = 862000000; - } - break; case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: - dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dvbt_plus, + dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, &dev->core->i2c_adap); - if (dev->dvb.frontend) { - dev->dvb.frontend->ops->info.frequency_min = 174000000; - dev->dvb.frontend->ops->info.frequency_max = 862000000; - } break; case CX88_BOARD_DNTV_LIVE_DVB_T: dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config, &dev->core->i2c_adap); - if (dev->dvb.frontend) { - dev->dvb.frontend->ops->info.frequency_min = 174000000; - dev->dvb.frontend->ops->info.frequency_max = 862000000; - } break; default: printk("%s: FIXME: frontend handling not here yet ...\n", dev->core->name); break; } - if (NULL == dev->dvb.frontend) + if (NULL == dev->dvb.frontend) { + printk("%s: frontend initialization failed\n",dev->core->name); return -1; + } + + if (dev->core->pll_desc) { + dev->dvb.frontend->ops->info.frequency_min = dev->core->pll_desc->min; + dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max; + } /* Copy the board name into the DVB structure */ strlcpy(dev->dvb.frontend->ops->info.name, @@ -298,7 +203,7 @@ static int dvb_register(struct cx8802_dev *dev) sizeof(dev->dvb.frontend->ops->info.name)); /* register everything */ - return videobuf_dvb_register(&dev->dvb); + return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); } /* ----------------------------------------------------------- */ |