aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Johnson <dj@david-web.co.uk>2005-09-09 16:02:55 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-09 16:57:42 -0400
commit05ade5a5cd32f8393c22fc454b0546df2ed497c5 (patch)
treecdff7e0bc84ead4b258138fa6bc529d494558fcc /drivers
parent1f15ddd0b79d1722049952b7359533a18a72f106 (diff)
[PATCH] dvb: bt8xx: Nebula DigiTV mt352 support
Add support for Nebula DigiTV PCI cards with the MT352 frontend. Signed-off-by: David Johnson <dj@david-web.co.uk> Signed-off-by: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c141
1 files changed, 108 insertions, 33 deletions
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index b29b0f558c70..514dff36e6eb 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -45,6 +45,8 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
45 if (debug) printk(KERN_DEBUG args); \ 45 if (debug) printk(KERN_DEBUG args); \
46 while (0) 46 while (0)
47 47
48#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
49
48static void dvb_bt8xx_task(unsigned long data) 50static void dvb_bt8xx_task(unsigned long data)
49{ 51{
50 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data; 52 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data;
@@ -150,7 +152,6 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_
150 unsigned char bs = 0; 152 unsigned char bs = 0;
151 unsigned char cp = 0; 153 unsigned char cp = 0;
152 154
153 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
154 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; 155 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
155 156
156 if (params->frequency < 542000000) 157 if (params->frequency < 542000000)
@@ -326,7 +327,6 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct
326 unsigned char bs = 0; 327 unsigned char bs = 0;
327 unsigned char cp = 0; 328 unsigned char cp = 0;
328 329
329 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
330 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; 330 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
331 331
332 if (params->frequency < 150000000) 332 if (params->frequency < 150000000)
@@ -416,8 +416,7 @@ static void or51211_reset(struct dvb_frontend * fe)
416 /* reset & PRM1,2&4 are outputs */ 416 /* reset & PRM1,2&4 are outputs */
417 int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); 417 int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F);
418 if (ret != 0) 418 if (ret != 0)
419 printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " 419 printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret);
420 "(%i)\n", ret);
421 bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ 420 bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */
422 msleep(20); 421 msleep(20);
423 /* Now set for normal operation */ 422 /* Now set for normal operation */
@@ -473,6 +472,80 @@ static struct nxt6000_config vp3021_alps_tded4_config = {
473 .pll_set = vp3021_alps_tded4_pll_set, 472 .pll_set = vp3021_alps_tded4_pll_set,
474}; 473};
475 474
475static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe)
476{
477 static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
478 static u8 mt352_reset [] = { 0x50, 0x80 };
479 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
480 static u8 mt352_agc_cfg [] = { 0x67, 0x20, 0xa0 };
481 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
482
483 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
484 udelay(2000);
485 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
486 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
487 mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg));
488 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
489
490 return 0;
491}
492
493static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
494{
495 u32 div;
496 struct dvb_ofdm_parameters *op = &params->u.ofdm;
497
498 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
499
500 pllbuf[0] = 0xc2;
501 pllbuf[1] = (div >> 8) & 0x7F;
502 pllbuf[2] = div & 0xFF;
503 pllbuf[3] = 0x85;
504
505 dprintk("frequency %u, div %u\n", params->frequency, div);
506
507 if (params->frequency < 470000000)
508 pllbuf[4] = 0x02;
509 else if (params->frequency > 823000000)
510 pllbuf[4] = 0x88;
511 else
512 pllbuf[4] = 0x08;
513
514 if (op->bandwidth == 8)
515 pllbuf[4] |= 0x04;
516
517 return 0;
518}
519
520static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt)
521{
522 /*
523 * Reset the frontend, must be called before trying
524 * to initialise the MT352 or mt352_attach
525 * will fail.
526 *
527 * Presumably not required for the NXT6000 frontend.
528 *
529 */
530
531 int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08);
532 if (ret != 0)
533 printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret);
534
535 /* Pulse the reset line */
536 bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
537 bttv_write_gpio(bt->bttv_nr, 0x08, 0x00); /* Low */
538 msleep(100);
539
540 bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
541}
542
543static struct mt352_config digitv_alps_tded4_config = {
544 .demod_address = 0x0a,
545 .demod_init = digitv_alps_tded4_demod_init,
546 .pll_set = digitv_alps_tded4_pll_set,
547};
548
476static void frontend_init(struct dvb_bt8xx_card *card, u32 type) 549static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
477{ 550{
478 int ret; 551 int ret;
@@ -480,42 +553,51 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
480 553
481 switch(type) { 554 switch(type) {
482#ifdef BTTV_DVICO_DVBT_LITE 555#ifdef BTTV_DVICO_DVBT_LITE
483 case BTTV_DVICO_DVBT_LITE: 556 case BTTV_DVICO_DVBT_LITE:
484 card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter); 557 card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter);
485 if (card->fe != NULL) { 558 if (card->fe != NULL) {
486 card->fe->ops->info.frequency_min = 174000000; 559 card->fe->ops->info.frequency_min = 174000000;
487 card->fe->ops->info.frequency_max = 862000000; 560 card->fe->ops->info.frequency_max = 862000000;
488 break;
489 } 561 }
490 break; 562 break;
491#endif 563#endif
492 564
493#ifdef BTTV_TWINHAN_VP3021 565#ifdef BTTV_TWINHAN_VP3021
494 case BTTV_TWINHAN_VP3021: 566 case BTTV_TWINHAN_VP3021:
495#else 567#else
496 case BTTV_NEBULA_DIGITV: 568 case BTTV_NEBULA_DIGITV:
497#endif 569#endif
570 /*
571 * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK);
572 * this would be a cleaner solution than trying each frontend in turn.
573 */
574
575 /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */
498 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); 576 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
499 if (card->fe != NULL) 577 if (card->fe != NULL)
500 break; 578 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
579
580 /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */
581 digitv_alps_tded4_reset(card);
582 card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter);
583
584 if (card->fe != NULL)
585 dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n");
501 break; 586 break;
502 587
503 case BTTV_AVDVBT_761: 588 case BTTV_AVDVBT_761:
504 card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter); 589 card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
505 if (card->fe != NULL)
506 break;
507 break; 590 break;
508 591
509 case BTTV_AVDVBT_771: 592 case BTTV_AVDVBT_771:
510 card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); 593 card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
511 if (card->fe != NULL) { 594 if (card->fe != NULL) {
512 card->fe->ops->info.frequency_min = 174000000; 595 card->fe->ops->info.frequency_min = 174000000;
513 card->fe->ops->info.frequency_max = 862000000; 596 card->fe->ops->info.frequency_max = 862000000;
514 break;
515 } 597 }
516 break; 598 break;
517 599
518 case BTTV_TWINHAN_DST: 600 case BTTV_TWINHAN_DST:
519 /* DST is not a frontend driver !!! */ 601 /* DST is not a frontend driver !!! */
520 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); 602 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
521 /* Setup the Card */ 603 /* Setup the Card */
@@ -534,21 +616,14 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
534 /* Conditional Access device */ 616 /* Conditional Access device */
535 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 617 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
536 ret = dst_ca_attach(state, &card->dvb_adapter); 618 ret = dst_ca_attach(state, &card->dvb_adapter);
537
538 if (card->fe != NULL)
539 break;
540 break; 619 break;
541 620
542 case BTTV_PINNACLESAT: 621 case BTTV_PINNACLESAT:
543 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); 622 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
544 if (card->fe != NULL)
545 break;
546 break; 623 break;
547 624
548 case BTTV_PC_HDTV: 625 case BTTV_PC_HDTV:
549 card->fe = or51211_attach(&or51211_config, card->i2c_adapter); 626 card->fe = or51211_attach(&or51211_config, card->i2c_adapter);
550 if (card->fe != NULL)
551 break;
552 break; 627 break;
553 } 628 }
554 629
@@ -669,7 +744,7 @@ static int dvb_bt8xx_probe(struct device *dev)
669 card->i2c_adapter = &sub->core->i2c_adap; 744 card->i2c_adapter = &sub->core->i2c_adap;
670 745
671 switch(sub->core->type) { 746 switch(sub->core->type) {
672 case BTTV_PINNACLESAT: 747 case BTTV_PINNACLESAT:
673 card->gpio_mode = 0x0400c060; 748 card->gpio_mode = 0x0400c060;
674 /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR, 749 /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
675 BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */ 750 BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */
@@ -678,7 +753,7 @@ static int dvb_bt8xx_probe(struct device *dev)
678 break; 753 break;
679 754
680#ifdef BTTV_DVICO_DVBT_LITE 755#ifdef BTTV_DVICO_DVBT_LITE
681 case BTTV_DVICO_DVBT_LITE: 756 case BTTV_DVICO_DVBT_LITE:
682#endif 757#endif
683 card->gpio_mode = 0x0400C060; 758 card->gpio_mode = 0x0400C060;
684 card->op_sync_orin = 0; 759 card->op_sync_orin = 0;
@@ -689,25 +764,25 @@ static int dvb_bt8xx_probe(struct device *dev)
689 break; 764 break;
690 765
691#ifdef BTTV_TWINHAN_VP3021 766#ifdef BTTV_TWINHAN_VP3021
692 case BTTV_TWINHAN_VP3021: 767 case BTTV_TWINHAN_VP3021:
693#else 768#else
694 case BTTV_NEBULA_DIGITV: 769 case BTTV_NEBULA_DIGITV:
695#endif 770#endif
696 case BTTV_AVDVBT_761: 771 case BTTV_AVDVBT_761:
697 card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5); 772 card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);
698 card->op_sync_orin = 0; 773 card->op_sync_orin = 0;
699 card->irq_err_ignore = 0; 774 card->irq_err_ignore = 0;
700 /* A_PWRDN DA_SBR DA_APP (high speed serial) */ 775 /* A_PWRDN DA_SBR DA_APP (high speed serial) */
701 break; 776 break;
702 777
703 case BTTV_AVDVBT_771: //case 0x07711461: 778 case BTTV_AVDVBT_771: //case 0x07711461:
704 card->gpio_mode = 0x0400402B; 779 card->gpio_mode = 0x0400402B;
705 card->op_sync_orin = BT878_RISC_SYNC_MASK; 780 card->op_sync_orin = BT878_RISC_SYNC_MASK;
706 card->irq_err_ignore = 0; 781 card->irq_err_ignore = 0;
707 /* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/ 782 /* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/
708 break; 783 break;
709 784
710 case BTTV_TWINHAN_DST: 785 case BTTV_TWINHAN_DST:
711 card->gpio_mode = 0x2204f2c; 786 card->gpio_mode = 0x2204f2c;
712 card->op_sync_orin = BT878_RISC_SYNC_MASK; 787 card->op_sync_orin = BT878_RISC_SYNC_MASK;
713 card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR | 788 card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR |
@@ -725,13 +800,13 @@ static int dvb_bt8xx_probe(struct device *dev)
725 * RISC+FIFO ENABLE */ 800 * RISC+FIFO ENABLE */
726 break; 801 break;
727 802
728 case BTTV_PC_HDTV: 803 case BTTV_PC_HDTV:
729 card->gpio_mode = 0x0100EC7B; 804 card->gpio_mode = 0x0100EC7B;
730 card->op_sync_orin = 0; 805 card->op_sync_orin = 0;
731 card->irq_err_ignore = 0; 806 card->irq_err_ignore = 0;
732 break; 807 break;
733 808
734 default: 809 default:
735 printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n", 810 printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n",
736 sub->core->type); 811 sub->core->type);
737 kfree(card); 812 kfree(card);