summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2004-10-28 17:37:07 +0000
committerAndrew de Quincy <devnull@localhost>2004-10-28 17:37:07 +0000
commit25da23146538519f0f644671c49868bfb560740a (patch)
tree7987970be2d5e86492325711d234ff59319f2685 /linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c
parentdcc0614123e60b1b01ed67850ebd22a517d8c086 (diff)
downloadmediapointer-dvb-s2-25da23146538519f0f644671c49868bfb560740a.tar.gz
mediapointer-dvb-s2-25da23146538519f0f644671c49868bfb560740a.tar.bz2
Imported FE_REFACTORING to HEAD
Diffstat (limited to 'linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c')
-rw-r--r--linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c269
1 files changed, 244 insertions, 25 deletions
diff --git a/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index c12c11ec4..3e81996f6 100644
--- a/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -126,7 +126,242 @@ static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci
return NULL;
}
-static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card)
+
+static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
+{
+ static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 };
+ static u8 mt352_reset [] = { 0x50, 0x80 };
+ static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+ static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0x20 };
+ static u8 mt352_gpp_ctl_cfg [] = { 0x75, 0x33 };
+ static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
+
+ mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
+ udelay(2000);
+ mt352_write(fe, mt352_reset, sizeof(mt352_reset));
+ mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
+
+ mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
+ mt352_write(fe, mt352_gpp_ctl_cfg, sizeof(mt352_gpp_ctl_cfg));
+ mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
+
+ return 0;
+}
+
+static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
+{
+ u32 div;
+ unsigned char bs = 0;
+ unsigned char cp = 0;
+
+ #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
+ 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;
+}
+
+static struct mt352_config thomson_dtt7579_config = {
+
+ .demod_address = 0x0f,
+ .demod_init = thomson_dtt7579_demod_init,
+ .pll_set = thomson_dtt7579_pll_set,
+};
+
+
+
+static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+{
+ struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
+ u8 cfg, cpump, band_select;
+ u8 data[4];
+ u32 div;
+ struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = sizeof(data) };
+
+ div = (36000000 + params->frequency + 83333) / 166666;
+ cfg = 0x88;
+
+ if (params->frequency < 175000000) cpump = 2;
+ else if (params->frequency < 390000000) cpump = 1;
+ else if (params->frequency < 470000000) cpump = 2;
+ else if (params->frequency < 750000000) cpump = 2;
+ else cpump = 3;
+
+ if (params->frequency < 175000000) band_select = 0x0e;
+ else if (params->frequency < 470000000) band_select = 0x05;
+ else band_select = 0x03;
+
+ data[0] = (div >> 8) & 0x7f;
+ data[1] = div & 0xff;
+ data[2] = ((div >> 10) & 0x60) | cfg;
+ data[3] = cpump | band_select;
+
+ i2c_transfer(card->i2c_adapter, &msg, 1);
+ return (div * 166666 - 36000000);
+}
+
+static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
+{
+ struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv;
+
+ return request_firmware(fw, name, &bt->bt->dev->dev);
+}
+
+struct sp887x_config microtune_mt7202dtf_config = {
+
+ .demod_address = 0x70,
+ .pll_set = microtune_mt7202dtf_pll_set,
+ .request_firmware = microtune_mt7202dtf_request_firmware,
+};
+
+
+
+
+static int advbt771_demod_init(struct dvb_frontend* fe)
+{
+ static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
+ static u8 mt352_reset [] = { 0x50, 0x80 };
+ static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
+ static u8 mt352_agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
+ 0x00, 0xFF, 0x00, 0x40, 0x40 };
+ static u8 mt352_av771_extra[] = { 0xB5, 0x7A };
+ static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
+
+
+ mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
+ udelay(2000);
+ mt352_write(fe, mt352_reset, sizeof(mt352_reset));
+ mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
+
+ mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg));
+ udelay(2000);
+ mt352_write(fe, mt352_av771_extra,sizeof(mt352_av771_extra));
+ mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
+
+ return 0;
+}
+
+static int advbt771_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
+{
+ u32 div;
+ unsigned char bs = 0;
+ unsigned char cp = 0;
+
+ #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
+ 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;
+
+ return 0;
+}
+
+static struct mt352_config advbt771_config = {
+
+ .demod_address = 0x0f,
+ .demod_init = advbt771_demod_init,
+ .pll_set = advbt771_pll_set,
+};
+
+
+static struct dst_config dst_config = {
+
+ .demod_address = 0x55,
+};
+
+
+
+static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
+{
+ switch(type) {
+#ifdef BTTV_DVICO_DVBT_LITE
+ case BTTV_DVICO_DVBT_LITE:
+ card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter, card->dvb_adapter);
+ if (card->fe != NULL) {
+ card->fe->ops->info.frequency_min = 174000000;
+ card->fe->ops->info.frequency_max = 862000000;
+ break;
+ }
+ break;
+#endif
+
+ case BTTV_AVDVBT_761:
+ card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
+ if (card->fe != NULL) {
+ break;
+ }
+ break;
+
+ case BTTV_AVDVBT_771:
+ card->fe = mt352_attach(&advbt771_config, card->i2c_adapter);
+ if (card->fe != NULL) {
+ card->fe->ops->info.frequency_min = 174000000;
+ card->fe->ops->info.frequency_max = 862000000;
+ break;
+ }
+ break;
+
+ case BTTV_TWINHAN_DST:
+ card->fe = dst_attach(&dst_config, card->i2c_adapter, card->bt);
+ if (card->fe != NULL) {
+ break;
+ }
+ break;
+ }
+
+ if (card->fe == NULL) {
+ printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
+ card->bt->dev->vendor,
+ card->bt->dev->device,
+ card->bt->dev->subsystem_vendor,
+ card->bt->dev->subsystem_device);
+ } else {
+ if (dvb_register_frontend(card->dvb_adapter, card->fe)) {
+ printk("dvb-bt8xx: Frontend registration failed!\n");
+ if (card->fe->ops->release)
+ card->fe->ops->release(card->fe);
+ card->fe = NULL;
+ }
+ }
+}
+
+static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
{
int result;
@@ -136,6 +371,7 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card)
return result;
}
+ card->dvb_adapter->priv = card;
card->bt->adapter = card->i2c_adapter;
@@ -206,7 +442,9 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card)
dvb_net_init(card->dvb_adapter, &card->dvbnet, &card->demux.dmx);
tasklet_init(&card->bt->tasklet, dvb_bt8xx_task, (unsigned long) card);
-
+
+ frontend_init(card, type);
+
return 0;
}
@@ -228,7 +466,7 @@ static int dvb_bt8xx_probe(struct device *dev)
switch(sub->core->type)
{
- case BTTV_PINNACLESAT:
+/* case BTTV_PINNACLESAT: UNDEFINED HARDWARE */
#ifdef BTTV_DVICO_DVBT_LITE
case BTTV_DVICO_DVBT_LITE:
#endif
@@ -239,8 +477,7 @@ static int dvb_bt8xx_probe(struct device *dev)
* A_PWRDN DA_DPM DA_SBR DA_IOM_DA
* DA_APP(parallel) */
break;
-
- case BTTV_NEBULA_DIGITV:
+/* case BTTV_NEBULA_DIGITV: UNDEFINED HARDWARE */
case BTTV_AVDVBT_761:
card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);
card->op_sync_orin = 0;
@@ -302,7 +539,7 @@ static int dvb_bt8xx_probe(struct device *dev)
init_MUTEX(&card->bt->gpio_lock);
card->bt->bttv_nr = sub->core->nr;
- if ( (ret = dvb_bt8xx_load_card(card)) ) {
+ if ( (ret = dvb_bt8xx_load_card(card, sub->core->type)) ) {
kfree(card);
return ret;
}
@@ -324,6 +561,7 @@ static int dvb_bt8xx_remove(struct device *dev)
card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
dvb_dmxdev_release(&card->dmxdev);
dvb_dmx_release(&card->demux);
+ if (card->fe) dvb_unregister_frontend(card->fe);
dvb_unregister_adapter(card->dvb_adapter);
kfree(card);
@@ -331,24 +569,6 @@ static int dvb_bt8xx_remove(struct device *dev)
return 0;
}
-static void dvb_bt8xx_i2c_info(struct bttv_sub_device *sub,
- struct i2c_client *client, int attach)
-{
- struct dvb_bt8xx_card *card = dev_get_drvdata(&sub->dev);
-
- if (attach) {
- printk("xxx attach\n");
- if (client->driver->command)
- client->driver->command(client, FE_REGISTER,
- card->dvb_adapter);
- } else {
- printk("xxx detach\n");
- if (client->driver->command)
- client->driver->command(client, FE_UNREGISTER,
- card->dvb_adapter);
- }
-}
-
static struct bttv_sub_driver driver = {
.drv = {
.name = "dvb-bt8xx",
@@ -360,7 +580,6 @@ static struct bttv_sub_driver driver = {
* .resume = dvb_bt8xx_resume,
*/
},
- .i2c_info = dvb_bt8xx_i2c_info,
};
static int __init dvb_bt8xx_init(void)