aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-dvb.c
diff options
context:
space:
mode:
authorSteven Toth <stoth@linuxtv.org>2008-10-11 10:05:50 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-17 16:23:10 -0400
commit363c35fc448943c3d6121332d28bcda2d2fbf87c (patch)
tree739864d237b7fa60bef51bc510fe55c888b606ca /drivers/media/video/cx88/cx88-dvb.c
parent548da7625c825eccc31b4b3865ae5389c3660486 (diff)
V4L/DVB (9222): S2API: Add Multiple-frontend on a single adapter support.
A detailed description from the original patches 2 years ago: "The WinTV-HVR3000 has a single transport bus which is shared between a DVB-T and DVB-S modulator. These patches build on the bus acquisition cx88 work from a few weeks ago to add support for this. So to applications the HVR3000 looks like this: /dev/dvb/adapter0/fe0 (cx24123 DVB-S demod) /dev/dvb/adapter0/fe1 (cx22702 DVB-T demod) Additional boards continue as before, eg: /dev/dvb/adapter1/fe0 (lgdt3302 ATSC demod) The basic change is removing the single instance of the videobuf_dvb in cx8802_dev and saa7134_dev(?) and replacing it with a list and some supporting functions. *NOTE* This branch was taken before v4l-dvb was closed for 2.6.19 so two or three current cx88 patches appear to be reversed by this tree, this will be cleaned up in the near future. The patches missing change the mutex handing to core->lock, fix an enumeration problem." It should be recognised that a number of people have been maintaining this patchset. Significant levels of Kudos to everyone one involved, including but not limited to: Darron Broad Fabio M. Di Nitto Carlo Scarfoglio Hans Werner Without the work of these people, and countless others, my two year old patches would of died on the Mercurial linuxtv.org vine a long time ago. TODO: Revise these patches a little further so that the need for demux1 and dvr0 is optional, not mandatory on the HVR3000. HISTORY (darron): This is the last update to MFE prepared by Hans which is based upon the `scratchpad' diff created by Carlo. All MFE work prior to that point must be attributed to Fabio who ported and maintained Steve's original patch up to that time. Signed-off-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Darron Broad <darron@kewl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx88/cx88-dvb.c')
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c423
1 files changed, 296 insertions, 127 deletions
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 344ed2626e59..099de66c72c4 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -116,13 +116,24 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
116 struct cx8802_dev *dev= fe->dvb->priv; 116 struct cx8802_dev *dev= fe->dvb->priv;
117 struct cx8802_driver *drv = NULL; 117 struct cx8802_driver *drv = NULL;
118 int ret = 0; 118 int ret = 0;
119 int fe_id;
120
121 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
122 if (!fe_id) {
123 printk(KERN_ERR "%s() No frontend found\n", __FUNCTION__);
124 return -EINVAL;
125 }
126
119 127
120 drv = cx8802_get_driver(dev, CX88_MPEG_DVB); 128 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
121 if (drv) { 129 if (drv) {
122 if (acquire) 130 if (acquire){
131 dev->frontends.active_fe_id = fe_id;
123 ret = drv->request_acquire(drv); 132 ret = drv->request_acquire(drv);
124 else 133 } else {
125 ret = drv->request_release(drv); 134 ret = drv->request_release(drv);
135 dev->frontends.active_fe_id = 0;
136 }
126 } 137 }
127 138
128 return ret; 139 return ret;
@@ -396,7 +407,7 @@ static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
396 cx_write(MO_GP0_IO, 0x00006060); 407 cx_write(MO_GP0_IO, 0x00006060);
397 break; 408 break;
398 case SEC_VOLTAGE_OFF: 409 case SEC_VOLTAGE_OFF:
399 printk("LNB Voltage SEC_VOLTAGE_off\n"); 410 printk("LNB Voltage SEC_VOLTAGE_off\n");
400 break; 411 break;
401 } 412 }
402 413
@@ -483,6 +494,7 @@ static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
483static int attach_xc3028(u8 addr, struct cx8802_dev *dev) 494static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
484{ 495{
485 struct dvb_frontend *fe; 496 struct dvb_frontend *fe;
497 struct videobuf_dvb_frontend *fe0 = NULL;
486 struct xc2028_ctrl ctl; 498 struct xc2028_ctrl ctl;
487 struct xc2028_config cfg = { 499 struct xc2028_config cfg = {
488 .i2c_adap = &dev->core->i2c_adap, 500 .i2c_adap = &dev->core->i2c_adap,
@@ -490,7 +502,12 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
490 .ctrl = &ctl, 502 .ctrl = &ctl,
491 }; 503 };
492 504
493 if (!dev->dvb.frontend) { 505/* Get the first frontend */
506 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
507 if (!fe0)
508 return -EINVAL;
509
510 if (!fe0->dvb.frontend) {
494 printk(KERN_ERR "%s/2: dvb frontend not attached. " 511 printk(KERN_ERR "%s/2: dvb frontend not attached. "
495 "Can't attach xc3028\n", 512 "Can't attach xc3028\n",
496 dev->core->name); 513 dev->core->name);
@@ -504,10 +521,13 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
504 */ 521 */
505 cx88_setup_xc3028(dev->core, &ctl); 522 cx88_setup_xc3028(dev->core, &ctl);
506 523
507 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); 524 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
508 if (!fe) { 525 if (!fe) {
509 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 526 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
510 dev->core->name); 527 dev->core->name);
528 dvb_frontend_detach(fe0->dvb.frontend);
529 dvb_unregister_frontend(fe0->dvb.frontend);
530 fe0->dvb.frontend = NULL;
511 return -EINVAL; 531 return -EINVAL;
512 } 532 }
513 533
@@ -532,8 +552,10 @@ static int cx24116_reset_device(struct dvb_frontend *fe)
532 struct cx88_core *core = dev->core; 552 struct cx88_core *core = dev->core;
533 553
534 /* Reset the part */ 554 /* Reset the part */
555 /* Put the cx24116 into reset */
535 cx_write(MO_SRST_IO, 0); 556 cx_write(MO_SRST_IO, 0);
536 msleep(10); 557 msleep(10);
558 /* Take the cx24116 out of reset */
537 cx_write(MO_SRST_IO, 1); 559 cx_write(MO_SRST_IO, 1);
538 msleep(10); 560 msleep(10);
539 561
@@ -573,20 +595,28 @@ static struct stv0288_config tevii_tuner_earda_config = {
573 595
574static int dvb_register(struct cx8802_dev *dev) 596static int dvb_register(struct cx8802_dev *dev)
575{ 597{
598 //struct cx88_core *core = dev->core;
599
600 ///* init struct videobuf_dvb */
601 //fe->dvb.name = core->name;
602 //dev->ts_gen_cntrl = 0x0c;
603
576 struct cx88_core *core = dev->core; 604 struct cx88_core *core = dev->core;
605 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
577 606
578 /* init struct videobuf_dvb */ 607 /* Get the first frontend */
579 dev->dvb.name = core->name; 608 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
580 dev->ts_gen_cntrl = 0x0c; 609 if (!fe0)
610 return -EINVAL;
581 611
582 /* init frontend */ 612 /* init frontend */
583 switch (core->boardnr) { 613 switch (core->boardnr) {
584 case CX88_BOARD_HAUPPAUGE_DVB_T1: 614 case CX88_BOARD_HAUPPAUGE_DVB_T1:
585 dev->dvb.frontend = dvb_attach(cx22702_attach, 615 fe0->dvb.frontend = dvb_attach(cx22702_attach,
586 &connexant_refboard_config, 616 &connexant_refboard_config,
587 &core->i2c_adap); 617 &core->i2c_adap);
588 if (dev->dvb.frontend != NULL) { 618 if (fe0->dvb.frontend != NULL) {
589 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 619 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
590 0x61, &core->i2c_adap, 620 0x61, &core->i2c_adap,
591 DVB_PLL_THOMSON_DTT759X)) 621 DVB_PLL_THOMSON_DTT759X))
592 goto frontend_detach; 622 goto frontend_detach;
@@ -596,11 +626,11 @@ static int dvb_register(struct cx8802_dev *dev)
596 case CX88_BOARD_CONEXANT_DVB_T1: 626 case CX88_BOARD_CONEXANT_DVB_T1:
597 case CX88_BOARD_KWORLD_DVB_T_CX22702: 627 case CX88_BOARD_KWORLD_DVB_T_CX22702:
598 case CX88_BOARD_WINFAST_DTV1000: 628 case CX88_BOARD_WINFAST_DTV1000:
599 dev->dvb.frontend = dvb_attach(cx22702_attach, 629 fe0->dvb.frontend = dvb_attach(cx22702_attach,
600 &connexant_refboard_config, 630 &connexant_refboard_config,
601 &core->i2c_adap); 631 &core->i2c_adap);
602 if (dev->dvb.frontend != NULL) { 632 if (fe0->dvb.frontend != NULL) {
603 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 633 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
604 0x60, &core->i2c_adap, 634 0x60, &core->i2c_adap,
605 DVB_PLL_THOMSON_DTT7579)) 635 DVB_PLL_THOMSON_DTT7579))
606 goto frontend_detach; 636 goto frontend_detach;
@@ -610,33 +640,65 @@ static int dvb_register(struct cx8802_dev *dev)
610 case CX88_BOARD_HAUPPAUGE_HVR1100: 640 case CX88_BOARD_HAUPPAUGE_HVR1100:
611 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 641 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
612 case CX88_BOARD_HAUPPAUGE_HVR1300: 642 case CX88_BOARD_HAUPPAUGE_HVR1300:
613 case CX88_BOARD_HAUPPAUGE_HVR3000: 643 fe0->dvb.frontend = dvb_attach(cx22702_attach,
614 dev->dvb.frontend = dvb_attach(cx22702_attach,
615 &hauppauge_hvr_config, 644 &hauppauge_hvr_config,
616 &core->i2c_adap); 645 &core->i2c_adap);
617 if (dev->dvb.frontend != NULL) { 646 if (fe0->dvb.frontend != NULL) {
618 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 647 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
619 &core->i2c_adap, 0x61, 648 &core->i2c_adap, 0x61,
620 TUNER_PHILIPS_FMD1216ME_MK3)) 649 TUNER_PHILIPS_FMD1216ME_MK3))
621 goto frontend_detach; 650 goto frontend_detach;
622 } 651 }
623 break; 652 break;
653 case CX88_BOARD_HAUPPAUGE_HVR3000:
654 /* DVB-S init */
655 fe0->dvb.frontend = dvb_attach(cx24123_attach,
656 &hauppauge_novas_config,
657 &dev->core->i2c_adap);
658 if (fe0->dvb.frontend) {
659 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
660 &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) {
661 dprintk( 1, "%s(): HVR3000 - DVB-S LNB Init: failed\n", __FUNCTION__);
662 }
663 } else {
664 dprintk( 1, "%s(): HVR3000 - DVB-S Init: failed\n", __FUNCTION__);
665 }
666 /* DVB-T init */
667 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
668 if (fe1) {
669 fe1->dvb.frontend = dvb_attach(cx22702_attach,
670 &hauppauge_hvr_config,
671 &dev->core->i2c_adap);
672 if (fe1->dvb.frontend) {
673 fe1->dvb.frontend->id = 1;
674 if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend,
675 &dev->core->i2c_adap, 0x61,
676 TUNER_PHILIPS_FMD1216ME_MK3)) {
677 dprintk( 1, "%s(): HVR3000 - DVB-T misc Init: failed\n", __FUNCTION__);
678 }
679 } else {
680 dprintk( 1, "%s(): HVR3000 - DVB-T Init: failed\n", __FUNCTION__);
681 }
682 } else {
683 dprintk( 1, "%s(): HVR3000 - DVB-T Init: can't find frontend 2.\n", __FUNCTION__);
684 }
685 break;
624 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 686 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
625 dev->dvb.frontend = dvb_attach(mt352_attach, 687 fe0->dvb.frontend = dvb_attach(mt352_attach,
626 &dvico_fusionhdtv, 688 &dvico_fusionhdtv,
627 &core->i2c_adap); 689 &core->i2c_adap);
628 if (dev->dvb.frontend != NULL) { 690 if (fe0->dvb.frontend != NULL) {
629 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 691 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
630 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 692 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
631 goto frontend_detach; 693 goto frontend_detach;
632 break; 694 break;
633 } 695 }
634 /* ZL10353 replaces MT352 on later cards */ 696 /* ZL10353 replaces MT352 on later cards */
635 dev->dvb.frontend = dvb_attach(zl10353_attach, 697 fe0->dvb.frontend = dvb_attach(zl10353_attach,
636 &dvico_fusionhdtv_plus_v1_1, 698 &dvico_fusionhdtv_plus_v1_1,
637 &core->i2c_adap); 699 &core->i2c_adap);
638 if (dev->dvb.frontend != NULL) { 700 if (fe0->dvb.frontend != NULL) {
639 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 701 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
640 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) 702 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
641 goto frontend_detach; 703 goto frontend_detach;
642 } 704 }
@@ -644,31 +706,31 @@ static int dvb_register(struct cx8802_dev *dev)
644 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 706 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
645 /* The tin box says DEE1601, but it seems to be DTT7579 707 /* The tin box says DEE1601, but it seems to be DTT7579
646 * compatible, with a slightly different MT352 AGC gain. */ 708 * compatible, with a slightly different MT352 AGC gain. */
647 dev->dvb.frontend = dvb_attach(mt352_attach, 709 fe0->dvb.frontend = dvb_attach(mt352_attach,
648 &dvico_fusionhdtv_dual, 710 &dvico_fusionhdtv_dual,
649 &core->i2c_adap); 711 &core->i2c_adap);
650 if (dev->dvb.frontend != NULL) { 712 if (fe0->dvb.frontend != NULL) {
651 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 713 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
652 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 714 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
653 goto frontend_detach; 715 goto frontend_detach;
654 break; 716 break;
655 } 717 }
656 /* ZL10353 replaces MT352 on later cards */ 718 /* ZL10353 replaces MT352 on later cards */
657 dev->dvb.frontend = dvb_attach(zl10353_attach, 719 fe0->dvb.frontend = dvb_attach(zl10353_attach,
658 &dvico_fusionhdtv_plus_v1_1, 720 &dvico_fusionhdtv_plus_v1_1,
659 &core->i2c_adap); 721 &core->i2c_adap);
660 if (dev->dvb.frontend != NULL) { 722 if (fe0->dvb.frontend != NULL) {
661 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 723 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
662 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) 724 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
663 goto frontend_detach; 725 goto frontend_detach;
664 } 726 }
665 break; 727 break;
666 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 728 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
667 dev->dvb.frontend = dvb_attach(mt352_attach, 729 fe0->dvb.frontend = dvb_attach(mt352_attach,
668 &dvico_fusionhdtv, 730 &dvico_fusionhdtv,
669 &core->i2c_adap); 731 &core->i2c_adap);
670 if (dev->dvb.frontend != NULL) { 732 if (fe0->dvb.frontend != NULL) {
671 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 733 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
672 0x61, NULL, DVB_PLL_LG_Z201)) 734 0x61, NULL, DVB_PLL_LG_Z201))
673 goto frontend_detach; 735 goto frontend_detach;
674 } 736 }
@@ -676,11 +738,11 @@ static int dvb_register(struct cx8802_dev *dev)
676 case CX88_BOARD_KWORLD_DVB_T: 738 case CX88_BOARD_KWORLD_DVB_T:
677 case CX88_BOARD_DNTV_LIVE_DVB_T: 739 case CX88_BOARD_DNTV_LIVE_DVB_T:
678 case CX88_BOARD_ADSTECH_DVB_T_PCI: 740 case CX88_BOARD_ADSTECH_DVB_T_PCI:
679 dev->dvb.frontend = dvb_attach(mt352_attach, 741 fe0->dvb.frontend = dvb_attach(mt352_attach,
680 &dntv_live_dvbt_config, 742 &dntv_live_dvbt_config,
681 &core->i2c_adap); 743 &core->i2c_adap);
682 if (dev->dvb.frontend != NULL) { 744 if (fe0->dvb.frontend != NULL) {
683 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 745 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
684 0x61, NULL, DVB_PLL_UNKNOWN_1)) 746 0x61, NULL, DVB_PLL_UNKNOWN_1))
685 goto frontend_detach; 747 goto frontend_detach;
686 } 748 }
@@ -688,10 +750,10 @@ static int dvb_register(struct cx8802_dev *dev)
688 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 750 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
689#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) 751#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
690 /* MT352 is on a secondary I2C bus made from some GPIO lines */ 752 /* MT352 is on a secondary I2C bus made from some GPIO lines */
691 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 753 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
692 &dev->vp3054->adap); 754 &dev->vp3054->adap);
693 if (dev->dvb.frontend != NULL) { 755 if (fe0->dvb.frontend != NULL) {
694 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 756 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
695 &core->i2c_adap, 0x61, 757 &core->i2c_adap, 0x61,
696 TUNER_PHILIPS_FMD1216ME_MK3)) 758 TUNER_PHILIPS_FMD1216ME_MK3))
697 goto frontend_detach; 759 goto frontend_detach;
@@ -702,22 +764,22 @@ static int dvb_register(struct cx8802_dev *dev)
702#endif 764#endif
703 break; 765 break;
704 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 766 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
705 dev->dvb.frontend = dvb_attach(zl10353_attach, 767 fe0->dvb.frontend = dvb_attach(zl10353_attach,
706 &dvico_fusionhdtv_hybrid, 768 &dvico_fusionhdtv_hybrid,
707 &core->i2c_adap); 769 &core->i2c_adap);
708 if (dev->dvb.frontend != NULL) { 770 if (fe0->dvb.frontend != NULL) {
709 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 771 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
710 &core->i2c_adap, 0x61, 772 &core->i2c_adap, 0x61,
711 TUNER_THOMSON_FE6600)) 773 TUNER_THOMSON_FE6600))
712 goto frontend_detach; 774 goto frontend_detach;
713 } 775 }
714 break; 776 break;
715 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 777 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
716 dev->dvb.frontend = dvb_attach(zl10353_attach, 778 fe0->dvb.frontend = dvb_attach(zl10353_attach,
717 &dvico_fusionhdtv_xc3028, 779 &dvico_fusionhdtv_xc3028,
718 &core->i2c_adap); 780 &core->i2c_adap);
719 if (dev->dvb.frontend == NULL) 781 if (fe0->dvb.frontend == NULL)
720 dev->dvb.frontend = dvb_attach(mt352_attach, 782 fe0->dvb.frontend = dvb_attach(mt352_attach,
721 &dvico_fusionhdtv_mt352_xc3028, 783 &dvico_fusionhdtv_mt352_xc3028,
722 &core->i2c_adap); 784 &core->i2c_adap);
723 /* 785 /*
@@ -725,16 +787,16 @@ static int dvb_register(struct cx8802_dev *dev)
725 * We must not permit gate_ctrl to be performed, or 787 * We must not permit gate_ctrl to be performed, or
726 * the xc3028 cannot communicate on the bus. 788 * the xc3028 cannot communicate on the bus.
727 */ 789 */
728 if (dev->dvb.frontend) 790 if (fe0->dvb.frontend)
729 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; 791 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
730 if (attach_xc3028(0x61, dev) < 0) 792 if (attach_xc3028(0x61, dev) < 0)
731 return -EINVAL; 793 return -EINVAL;
732 break; 794 break;
733 case CX88_BOARD_PCHDTV_HD3000: 795 case CX88_BOARD_PCHDTV_HD3000:
734 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 796 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
735 &core->i2c_adap); 797 &core->i2c_adap);
736 if (dev->dvb.frontend != NULL) { 798 if (fe0->dvb.frontend != NULL) {
737 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 799 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
738 &core->i2c_adap, 0x61, 800 &core->i2c_adap, 0x61,
739 TUNER_THOMSON_DTT761X)) 801 TUNER_THOMSON_DTT761X))
740 goto frontend_detach; 802 goto frontend_detach;
@@ -751,11 +813,11 @@ static int dvb_register(struct cx8802_dev *dev)
751 813
752 /* Select RF connector callback */ 814 /* Select RF connector callback */
753 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 815 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
754 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 816 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
755 &fusionhdtv_3_gold, 817 &fusionhdtv_3_gold,
756 &core->i2c_adap); 818 &core->i2c_adap);
757 if (dev->dvb.frontend != NULL) { 819 if (fe0->dvb.frontend != NULL) {
758 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 820 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
759 &core->i2c_adap, 0x61, 821 &core->i2c_adap, 0x61,
760 TUNER_MICROTUNE_4042FI5)) 822 TUNER_MICROTUNE_4042FI5))
761 goto frontend_detach; 823 goto frontend_detach;
@@ -769,11 +831,11 @@ static int dvb_register(struct cx8802_dev *dev)
769 mdelay(100); 831 mdelay(100);
770 cx_set(MO_GP0_IO, 9); 832 cx_set(MO_GP0_IO, 9);
771 mdelay(200); 833 mdelay(200);
772 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 834 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
773 &fusionhdtv_3_gold, 835 &fusionhdtv_3_gold,
774 &core->i2c_adap); 836 &core->i2c_adap);
775 if (dev->dvb.frontend != NULL) { 837 if (fe0->dvb.frontend != NULL) {
776 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 838 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
777 &core->i2c_adap, 0x61, 839 &core->i2c_adap, 0x61,
778 TUNER_THOMSON_DTT761X)) 840 TUNER_THOMSON_DTT761X))
779 goto frontend_detach; 841 goto frontend_detach;
@@ -787,15 +849,15 @@ static int dvb_register(struct cx8802_dev *dev)
787 mdelay(100); 849 mdelay(100);
788 cx_set(MO_GP0_IO, 1); 850 cx_set(MO_GP0_IO, 1);
789 mdelay(200); 851 mdelay(200);
790 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 852 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
791 &fusionhdtv_5_gold, 853 &fusionhdtv_5_gold,
792 &core->i2c_adap); 854 &core->i2c_adap);
793 if (dev->dvb.frontend != NULL) { 855 if (fe0->dvb.frontend != NULL) {
794 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 856 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
795 &core->i2c_adap, 0x61, 857 &core->i2c_adap, 0x61,
796 TUNER_LG_TDVS_H06XF)) 858 TUNER_LG_TDVS_H06XF))
797 goto frontend_detach; 859 goto frontend_detach;
798 if (!dvb_attach(tda9887_attach, dev->dvb.frontend, 860 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
799 &core->i2c_adap, 0x43)) 861 &core->i2c_adap, 0x43))
800 goto frontend_detach; 862 goto frontend_detach;
801 } 863 }
@@ -808,25 +870,25 @@ static int dvb_register(struct cx8802_dev *dev)
808 mdelay(100); 870 mdelay(100);
809 cx_set(MO_GP0_IO, 1); 871 cx_set(MO_GP0_IO, 1);
810 mdelay(200); 872 mdelay(200);
811 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 873 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
812 &pchdtv_hd5500, 874 &pchdtv_hd5500,
813 &core->i2c_adap); 875 &core->i2c_adap);
814 if (dev->dvb.frontend != NULL) { 876 if (fe0->dvb.frontend != NULL) {
815 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 877 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
816 &core->i2c_adap, 0x61, 878 &core->i2c_adap, 0x61,
817 TUNER_LG_TDVS_H06XF)) 879 TUNER_LG_TDVS_H06XF))
818 goto frontend_detach; 880 goto frontend_detach;
819 if (!dvb_attach(tda9887_attach, dev->dvb.frontend, 881 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
820 &core->i2c_adap, 0x43)) 882 &core->i2c_adap, 0x43))
821 goto frontend_detach; 883 goto frontend_detach;
822 } 884 }
823 break; 885 break;
824 case CX88_BOARD_ATI_HDTVWONDER: 886 case CX88_BOARD_ATI_HDTVWONDER:
825 dev->dvb.frontend = dvb_attach(nxt200x_attach, 887 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
826 &ati_hdtvwonder, 888 &ati_hdtvwonder,
827 &core->i2c_adap); 889 &core->i2c_adap);
828 if (dev->dvb.frontend != NULL) { 890 if (fe0->dvb.frontend != NULL) {
829 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, 891 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
830 &core->i2c_adap, 0x61, 892 &core->i2c_adap, 0x61,
831 TUNER_PHILIPS_TUV1236D)) 893 TUNER_PHILIPS_TUV1236D))
832 goto frontend_detach; 894 goto frontend_detach;
@@ -834,49 +896,49 @@ static int dvb_register(struct cx8802_dev *dev)
834 break; 896 break;
835 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 897 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
836 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 898 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
837 dev->dvb.frontend = dvb_attach(cx24123_attach, 899 fe0->dvb.frontend = dvb_attach(cx24123_attach,
838 &hauppauge_novas_config, 900 &hauppauge_novas_config,
839 &core->i2c_adap); 901 &core->i2c_adap);
840 if (dev->dvb.frontend) { 902 if (fe0->dvb.frontend) {
841 if (!dvb_attach(isl6421_attach, dev->dvb.frontend, 903 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
842 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) 904 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
843 goto frontend_detach; 905 goto frontend_detach;
844 } 906 }
845 break; 907 break;
846 case CX88_BOARD_KWORLD_DVBS_100: 908 case CX88_BOARD_KWORLD_DVBS_100:
847 dev->dvb.frontend = dvb_attach(cx24123_attach, 909 fe0->dvb.frontend = dvb_attach(cx24123_attach,
848 &kworld_dvbs_100_config, 910 &kworld_dvbs_100_config,
849 &core->i2c_adap); 911 &core->i2c_adap);
850 if (dev->dvb.frontend) { 912 if (fe0->dvb.frontend) {
851 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 913 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
852 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; 914 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
853 } 915 }
854 break; 916 break;
855 case CX88_BOARD_GENIATECH_DVBS: 917 case CX88_BOARD_GENIATECH_DVBS:
856 dev->dvb.frontend = dvb_attach(cx24123_attach, 918 fe0->dvb.frontend = dvb_attach(cx24123_attach,
857 &geniatech_dvbs_config, 919 &geniatech_dvbs_config,
858 &core->i2c_adap); 920 &core->i2c_adap);
859 if (dev->dvb.frontend) { 921 if (fe0->dvb.frontend) {
860 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 922 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
861 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; 923 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
862 } 924 }
863 break; 925 break;
864 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 926 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
865 dev->dvb.frontend = dvb_attach(s5h1409_attach, 927 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
866 &pinnacle_pctv_hd_800i_config, 928 &pinnacle_pctv_hd_800i_config,
867 &core->i2c_adap); 929 &core->i2c_adap);
868 if (dev->dvb.frontend != NULL) { 930 if (fe0->dvb.frontend != NULL) {
869 if (!dvb_attach(xc5000_attach, dev->dvb.frontend, 931 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
870 &core->i2c_adap, 932 &core->i2c_adap,
871 &pinnacle_pctv_hd_800i_tuner_config)) 933 &pinnacle_pctv_hd_800i_tuner_config))
872 goto frontend_detach; 934 goto frontend_detach;
873 } 935 }
874 break; 936 break;
875 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 937 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
876 dev->dvb.frontend = dvb_attach(s5h1409_attach, 938 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
877 &dvico_hdtv5_pci_nano_config, 939 &dvico_hdtv5_pci_nano_config,
878 &core->i2c_adap); 940 &core->i2c_adap);
879 if (dev->dvb.frontend != NULL) { 941 if (fe0->dvb.frontend != NULL) {
880 struct dvb_frontend *fe; 942 struct dvb_frontend *fe;
881 struct xc2028_config cfg = { 943 struct xc2028_config cfg = {
882 .i2c_adap = &core->i2c_adap, 944 .i2c_adap = &core->i2c_adap,
@@ -889,17 +951,17 @@ static int dvb_register(struct cx8802_dev *dev)
889 }; 951 };
890 952
891 fe = dvb_attach(xc2028_attach, 953 fe = dvb_attach(xc2028_attach,
892 dev->dvb.frontend, &cfg); 954 fe0->dvb.frontend, &cfg);
893 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 955 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
894 fe->ops.tuner_ops.set_config(fe, &ctl); 956 fe->ops.tuner_ops.set_config(fe, &ctl);
895 } 957 }
896 break; 958 break;
897 case CX88_BOARD_PINNACLE_HYBRID_PCTV: 959 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
898 dev->dvb.frontend = dvb_attach(zl10353_attach, 960 fe0->dvb.frontend = dvb_attach(zl10353_attach,
899 &cx88_pinnacle_hybrid_pctv, 961 &cx88_pinnacle_hybrid_pctv,
900 &core->i2c_adap); 962 &core->i2c_adap);
901 if (dev->dvb.frontend) { 963 if (fe0->dvb.frontend) {
902 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; 964 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
903 if (attach_xc3028(0x61, dev) < 0) 965 if (attach_xc3028(0x61, dev) < 0)
904 goto frontend_detach; 966 goto frontend_detach;
905 } 967 }
@@ -907,85 +969,116 @@ static int dvb_register(struct cx8802_dev *dev)
907 case CX88_BOARD_GENIATECH_X8000_MT: 969 case CX88_BOARD_GENIATECH_X8000_MT:
908 dev->ts_gen_cntrl = 0x00; 970 dev->ts_gen_cntrl = 0x00;
909 971
910 dev->dvb.frontend = dvb_attach(zl10353_attach, 972 fe0->dvb.frontend = dvb_attach(zl10353_attach,
911 &cx88_geniatech_x8000_mt, 973 &cx88_geniatech_x8000_mt,
912 &core->i2c_adap); 974 &core->i2c_adap);
913 if (attach_xc3028(0x61, dev) < 0) 975 if (attach_xc3028(0x61, dev) < 0)
914 goto frontend_detach; 976 goto frontend_detach;
915 break; 977 break;
916 case CX88_BOARD_KWORLD_ATSC_120: 978 case CX88_BOARD_KWORLD_ATSC_120:
917 dev->dvb.frontend = dvb_attach(s5h1409_attach, 979 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
918 &kworld_atsc_120_config, 980 &kworld_atsc_120_config,
919 &core->i2c_adap); 981 &core->i2c_adap);
920 if (attach_xc3028(0x61, dev) < 0) 982 if (attach_xc3028(0x61, dev) < 0)
921 goto frontend_detach; 983 goto frontend_detach;
922 break; 984 break;
923 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 985 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
924 dev->dvb.frontend = dvb_attach(s5h1411_attach, 986 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
925 &dvico_fusionhdtv7_config, 987 &dvico_fusionhdtv7_config,
926 &core->i2c_adap); 988 &core->i2c_adap);
927 if (dev->dvb.frontend != NULL) { 989 if (fe0->dvb.frontend != NULL) {
928 if (!dvb_attach(xc5000_attach, dev->dvb.frontend, 990 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
929 &core->i2c_adap, 991 &core->i2c_adap,
930 &dvico_fusionhdtv7_tuner_config)) 992 &dvico_fusionhdtv7_tuner_config))
931 goto frontend_detach; 993 goto frontend_detach;
932 } 994 }
933 break; 995 break;
934 case CX88_BOARD_HAUPPAUGE_HVR4000: 996 case CX88_BOARD_HAUPPAUGE_HVR4000:
997 /* DVB-S/S2 Init */
998 fe0->dvb.frontend = dvb_attach(cx24116_attach,
999 &hauppauge_hvr4000_config,
1000 &dev->core->i2c_adap);
1001 if (fe0->dvb.frontend) {
1002 if(!dvb_attach(isl6421_attach, fe0->dvb.frontend,
1003 &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) {
1004 dprintk( 1, "%s(): HVR4000 - DVB-S LNB Init: failed\n", __FUNCTION__);
1005 }
1006 } else {
1007 dprintk( 1, "%s(): HVR4000 - DVB-S Init: failed\n", __FUNCTION__);
1008 }
1009 /* DVB-T Init */
1010 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
1011 if (fe1) {
1012 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1013 &hauppauge_hvr_config,
1014 &dev->core->i2c_adap);
1015 if (fe1->dvb.frontend) {
1016 fe1->dvb.frontend->id = 1;
1017 if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend,
1018 &dev->core->i2c_adap, 0x61,
1019 TUNER_PHILIPS_FMD1216ME_MK3)) {
1020 dprintk( 1, "%s(): HVR4000 - DVB-T misc Init: failed\n", __FUNCTION__);
1021 }
1022 } else {
1023 dprintk( 1, "%s(): HVR4000 - DVB-T Init: failed\n", __FUNCTION__);
1024 }
1025 } else {
1026 dprintk( 1, "%s(): HVR4000 - DVB-T Init: can't find frontend 2.\n", __FUNCTION__);
1027 }
1028 break;
935 case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 1029 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
936 /* Support for DVB-S only, not DVB-T support */ 1030 fe0->dvb.frontend = dvb_attach(cx24116_attach,
937 dev->dvb.frontend = dvb_attach(cx24116_attach,
938 &hauppauge_hvr4000_config, 1031 &hauppauge_hvr4000_config,
939 &dev->core->i2c_adap); 1032 &dev->core->i2c_adap);
940 if (dev->dvb.frontend) { 1033 if (fe0->dvb.frontend) {
941 dvb_attach(isl6421_attach, dev->dvb.frontend, 1034 dvb_attach(isl6421_attach, fe0->dvb.frontend,
942 &dev->core->i2c_adap, 1035 &dev->core->i2c_adap,
943 0x08, ISL6421_DCL, 0x00); 1036 0x08, ISL6421_DCL, 0x00);
944 } 1037 }
945 break; 1038 break;
946 case CX88_BOARD_TEVII_S420: 1039 case CX88_BOARD_TEVII_S420:
947 dev->dvb.frontend = dvb_attach(stv0299_attach, 1040 fe0->dvb.frontend = dvb_attach(stv0299_attach,
948 &tevii_tuner_sharp_config, 1041 &tevii_tuner_sharp_config,
949 &core->i2c_adap); 1042 &core->i2c_adap);
950 if (dev->dvb.frontend != NULL) { 1043 if (fe0->dvb.frontend != NULL) {
951 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 1044 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
952 &core->i2c_adap, DVB_PLL_OPERA1)) 1045 &core->i2c_adap, DVB_PLL_OPERA1))
953 goto frontend_detach; 1046 goto frontend_detach;
954 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 1047 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
955 dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1048 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
956 1049
957 } else { 1050 } else {
958 dev->dvb.frontend = dvb_attach(stv0288_attach, 1051 fe0->dvb.frontend = dvb_attach(stv0288_attach,
959 &tevii_tuner_earda_config, 1052 &tevii_tuner_earda_config,
960 &core->i2c_adap); 1053 &core->i2c_adap);
961 if (dev->dvb.frontend != NULL) { 1054 if (fe0->dvb.frontend != NULL) {
962 if (!dvb_attach(stb6000_attach, dev->dvb.frontend, 0x61, 1055 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
963 &core->i2c_adap)) 1056 &core->i2c_adap))
964 goto frontend_detach; 1057 goto frontend_detach;
965 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 1058 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
966 dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1059 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
967 1060
968 } 1061 }
969 } 1062 }
970 break; 1063 break;
971 case CX88_BOARD_TEVII_S460: 1064 case CX88_BOARD_TEVII_S460:
972 dev->dvb.frontend = dvb_attach(cx24116_attach, 1065 fe0->dvb.frontend = dvb_attach(cx24116_attach,
973 &tevii_s460_config, 1066 &tevii_s460_config,
974 &core->i2c_adap); 1067 &core->i2c_adap);
975 if (dev->dvb.frontend != NULL) { 1068 if (fe0->dvb.frontend != NULL) {
976 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 1069 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
977 dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1070 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
978 } 1071 }
979 break; 1072 break;
980 case CX88_BOARD_OMICOM_SS4_PCI: 1073 case CX88_BOARD_OMICOM_SS4_PCI:
981 case CX88_BOARD_TBS_8920: 1074 case CX88_BOARD_TBS_8920:
982 case CX88_BOARD_PROF_7300: 1075 case CX88_BOARD_PROF_7300:
983 dev->dvb.frontend = dvb_attach(cx24116_attach, 1076 fe0->dvb.frontend = dvb_attach(cx24116_attach,
984 &hauppauge_hvr4000_config, 1077 &hauppauge_hvr4000_config,
985 &core->i2c_adap); 1078 &core->i2c_adap);
986 if (dev->dvb.frontend != NULL) { 1079 if (fe0->dvb.frontend != NULL) {
987 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 1080 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
988 dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1081 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
989 } 1082 }
990 break; 1083 break;
991 default: 1084 default:
@@ -993,29 +1086,32 @@ static int dvb_register(struct cx8802_dev *dev)
993 core->name); 1086 core->name);
994 break; 1087 break;
995 } 1088 }
996 if (NULL == dev->dvb.frontend) { 1089
1090 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
997 printk(KERN_ERR 1091 printk(KERN_ERR
998 "%s/2: frontend initialization failed\n", 1092 "%s/2: frontend initialization failed\n",
999 core->name); 1093 core->name);
1000 return -EINVAL; 1094 return -EINVAL;
1001 } 1095 }
1002 /* define general-purpose callback pointer */ 1096 /* define general-purpose callback pointer */
1003 dev->dvb.frontend->callback = cx88_tuner_callback; 1097 fe0->dvb.frontend->callback = cx88_tuner_callback;
1004 1098
1005 /* Ensure all frontends negotiate bus access */ 1099 /* Ensure all frontends negotiate bus access */
1006 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; 1100 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1101 if (fe1)
1102 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1007 1103
1008 /* Put the analog decoder in standby to keep it quiet */ 1104 /* Put the analog decoder in standby to keep it quiet */
1009 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL); 1105 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
1010 1106
1011 /* register everything */ 1107 /* register everything */
1012 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, 1108 return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1013 &dev->pci->dev, adapter_nr); 1109 &dev->pci->dev, adapter_nr);
1014 1110
1015frontend_detach: 1111frontend_detach:
1016 if (dev->dvb.frontend) { 1112 if (fe0->dvb.frontend) {
1017 dvb_frontend_detach(dev->dvb.frontend); 1113 dvb_frontend_detach(fe0->dvb.frontend);
1018 dev->dvb.frontend = NULL; 1114 fe0->dvb.frontend = NULL;
1019 } 1115 }
1020 return -EINVAL; 1116 return -EINVAL;
1021} 1117}
@@ -1039,6 +1135,66 @@ static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
1039 cx_clear(MO_GP0_IO, 0x00000004); 1135 cx_clear(MO_GP0_IO, 0x00000004);
1040 udelay(1000); 1136 udelay(1000);
1041 break; 1137 break;
1138
1139 case CX88_BOARD_HAUPPAUGE_HVR3000: /* ? */
1140 if(core->dvbdev->frontends.active_fe_id == 1) {
1141 /* DVB-S/S2 Enabled */
1142
1143 /* Toggle reset on cx22702 leaving i2c active */
1144 cx_write(MO_GP0_IO, core->board.input[0].gpio0);
1145 udelay(1000);
1146 cx_clear(MO_GP0_IO, 0x00000080);
1147 udelay(50);
1148 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset */
1149 cx_set(MO_GP0_IO, 0x00000004); /* tri-state the cx22702 pins */
1150 udelay(1000);
1151
1152 cx_write(MO_SRST_IO, 1); /* Take the cx24116/cx24123 out of reset */
1153 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
1154 } else
1155 if (core->dvbdev->frontends.active_fe_id == 2) {
1156 /* DVB-T Enabled */
1157
1158 /* Put the cx24116/cx24123 into reset */
1159 cx_write(MO_SRST_IO, 0);
1160
1161 /* cx22702 out of reset and enable it */
1162 cx_set(MO_GP0_IO, 0x00000080);
1163 cx_clear(MO_GP0_IO, 0x00000004);
1164 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
1165 udelay(1000);
1166 }
1167 break;
1168 case CX88_BOARD_HAUPPAUGE_HVR4000:
1169 if(core->dvbdev->frontends.active_fe_id == 1) {
1170 /* DVB-S/S2 Enabled */
1171
1172 /* Toggle reset on cx22702 leaving i2c active */
1173 cx_write(MO_GP0_IO, (core->board.input[0].gpio0 & 0x0000ff00) | 0x00000080);
1174 udelay(1000);
1175 cx_clear(MO_GP0_IO, 0x00000080);
1176 udelay(50);
1177 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset */
1178 cx_set(MO_GP0_IO, 0x00000004); /* tri-state the cx22702 pins */
1179 udelay(1000);
1180
1181 cx_write(MO_SRST_IO, 1); /* Take the cx24116/cx24123 out of reset */
1182 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
1183 } else
1184 if (core->dvbdev->frontends.active_fe_id == 2) {
1185 /* DVB-T Enabled */
1186
1187 /* Put the cx24116/cx24123 into reset */
1188 cx_write(MO_SRST_IO, 0);
1189
1190 /* cx22702 out of reset and enable it */
1191 cx_set(MO_GP0_IO, 0x00000080);
1192 cx_clear(MO_GP0_IO, 0x00000004);
1193 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
1194 udelay(1000);
1195 }
1196 break;
1197
1042 default: 1198 default:
1043 err = -ENODEV; 1199 err = -ENODEV;
1044 } 1200 }
@@ -1056,6 +1212,9 @@ static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1056 case CX88_BOARD_HAUPPAUGE_HVR1300: 1212 case CX88_BOARD_HAUPPAUGE_HVR1300:
1057 /* Do Nothing, leave the cx22702 on the bus. */ 1213 /* Do Nothing, leave the cx22702 on the bus. */
1058 break; 1214 break;
1215 case CX88_BOARD_HAUPPAUGE_HVR3000:
1216 case CX88_BOARD_HAUPPAUGE_HVR4000:
1217 break;
1059 default: 1218 default:
1060 err = -ENODEV; 1219 err = -ENODEV;
1061 } 1220 }
@@ -1066,7 +1225,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1066{ 1225{
1067 struct cx88_core *core = drv->core; 1226 struct cx88_core *core = drv->core;
1068 struct cx8802_dev *dev = drv->core->dvbdev; 1227 struct cx8802_dev *dev = drv->core->dvbdev;
1069 int err; 1228 int err,i;
1229 struct videobuf_dvb_frontend *fe;
1070 1230
1071 dprintk( 1, "%s\n", __func__); 1231 dprintk( 1, "%s\n", __func__);
1072 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", 1232 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
@@ -1086,12 +1246,23 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1086 1246
1087 /* dvb stuff */ 1247 /* dvb stuff */
1088 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); 1248 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
1089 videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops, 1249 dev->ts_gen_cntrl = 0x0c;
1250
1251 for (i = 1; i <= core->board.num_frontends; i++) {
1252 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1253 if (!fe) {
1254 printk(KERN_ERR "%s() failed to get frontend(%d)\n", __FUNCTION__, i);
1255 continue;
1256 }
1257 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
1090 &dev->pci->dev, &dev->slock, 1258 &dev->pci->dev, &dev->slock,
1091 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1259 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1092 V4L2_FIELD_TOP, 1260 V4L2_FIELD_TOP,
1093 sizeof(struct cx88_buffer), 1261 sizeof(struct cx88_buffer),
1094 dev); 1262 dev);
1263 /* init struct videobuf_dvb */
1264 fe->dvb.name = dev->core->name;
1265 }
1095 err = dvb_register(dev); 1266 err = dvb_register(dev);
1096 if (err != 0) 1267 if (err != 0)
1097 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n", 1268 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
@@ -1105,9 +1276,7 @@ static int cx8802_dvb_remove(struct cx8802_driver *drv)
1105{ 1276{
1106 struct cx8802_dev *dev = drv->core->dvbdev; 1277 struct cx8802_dev *dev = drv->core->dvbdev;
1107 1278
1108 /* dvb */ 1279 videobuf_dvb_unregister_bus(&dev->frontends);
1109 if (dev->dvb.frontend)
1110 videobuf_dvb_unregister(&dev->dvb);
1111 1280
1112 vp3054_i2c_remove(dev); 1281 vp3054_i2c_remove(dev);
1113 1282