aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa7134-dvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-dvb.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c434
1 files changed, 320 insertions, 114 deletions
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index ea2be9eceeb8..2d16be2259db 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -33,33 +33,40 @@
33#include "saa7134.h" 33#include "saa7134.h"
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35#include "dvb-pll.h" 35#include "dvb-pll.h"
36#include <dvb_frontend.h>
36 37
37#include "mt352.h" 38#include "mt352.h"
38#include "mt352_priv.h" /* FIXME */ 39#include "mt352_priv.h" /* FIXME */
39#include "tda1004x.h" 40#include "tda1004x.h"
40#include "nxt200x.h" 41#include "nxt200x.h"
42#include "tuner-xc2028.h"
41 43
42#include "tda10086.h" 44#include "tda10086.h"
43#include "tda826x.h" 45#include "tda826x.h"
44#include "tda827x.h" 46#include "tda827x.h"
45#include "isl6421.h" 47#include "isl6421.h"
48#include "isl6405.h"
49#include "lnbp21.h"
50#include "tuner-simple.h"
46 51
47MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 52MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
48MODULE_LICENSE("GPL"); 53MODULE_LICENSE("GPL");
49 54
50static unsigned int antenna_pwr = 0; 55static unsigned int antenna_pwr;
51 56
52module_param(antenna_pwr, int, 0444); 57module_param(antenna_pwr, int, 0444);
53MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)"); 58MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
54 59
55static int use_frontend = 0; 60static int use_frontend;
56module_param(use_frontend, int, 0644); 61module_param(use_frontend, int, 0644);
57MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)"); 62MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
58 63
59static int debug = 0; 64static int debug;
60module_param(debug, int, 0644); 65module_param(debug, int, 0644);
61MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off)."); 66MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
62 67
68DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
69
63#define dprintk(fmt, arg...) do { if (debug) \ 70#define dprintk(fmt, arg...) do { if (debug) \
64 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0) 71 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
65 72
@@ -91,7 +98,7 @@ static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
91 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28)); 98 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
92 udelay(10); 99 udelay(10);
93 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27); 100 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
94 dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off"); 101 dprintk("%s %s\n", __func__, ok ? "on" : "off");
95 102
96 if (!ok) 103 if (!ok)
97 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); 104 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
@@ -111,7 +118,7 @@ static int mt352_pinnacle_init(struct dvb_frontend* fe)
111 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 }; 118 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
112 struct saa7134_dev *dev= fe->dvb->priv; 119 struct saa7134_dev *dev= fe->dvb->priv;
113 120
114 dprintk("%s called\n", __FUNCTION__); 121 dprintk("%s called\n", __func__);
115 122
116 mt352_write(fe, clock_config, sizeof(clock_config)); 123 mt352_write(fe, clock_config, sizeof(clock_config));
117 udelay(200); 124 udelay(200);
@@ -146,6 +153,26 @@ static int mt352_aver777_init(struct dvb_frontend* fe)
146 return 0; 153 return 0;
147} 154}
148 155
156static int mt352_aver_a16d_init(struct dvb_frontend *fe)
157{
158 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
159 static u8 reset [] = { RESET, 0x80 };
160 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
161 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
162 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
163
164 mt352_write(fe, clock_config, sizeof(clock_config));
165 udelay(200);
166 mt352_write(fe, reset, sizeof(reset));
167 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
168 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
169 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
170
171 return 0;
172}
173
174
175
149static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, 176static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
150 struct dvb_frontend_parameters* params) 177 struct dvb_frontend_parameters* params)
151{ 178{
@@ -188,6 +215,16 @@ static struct mt352_config avermedia_777 = {
188 .demod_init = mt352_aver777_init, 215 .demod_init = mt352_aver777_init,
189}; 216};
190 217
218static struct mt352_config avermedia_16d = {
219 .demod_address = 0xf,
220 .demod_init = mt352_aver_a16d_init,
221};
222
223static struct mt352_config avermedia_e506r_mt352_dev = {
224 .demod_address = (0x1e >> 1),
225 .no_tuner = 1,
226};
227
191/* ================================================================== 228/* ==================================================================
192 * tda1004x based DVB-T cards, helper functions 229 * tda1004x based DVB-T cards, helper functions
193 */ 230 */
@@ -430,8 +467,6 @@ static struct tda1004x_config philips_europa_config = {
430 .request_firmware = philips_tda1004x_request_firmware 467 .request_firmware = philips_tda1004x_request_firmware
431}; 468};
432 469
433/* ------------------------------------------------------------------ */
434
435static struct tda1004x_config medion_cardbus = { 470static struct tda1004x_config medion_cardbus = {
436 .demod_address = 0x08, 471 .demod_address = 0x08,
437 .invert = 1, 472 .invert = 1,
@@ -447,47 +482,6 @@ static struct tda1004x_config medion_cardbus = {
447 * tda 1004x based cards with philips silicon tuner 482 * tda 1004x based cards with philips silicon tuner
448 */ 483 */
449 484
450static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
451{
452 struct saa7134_dev *dev = fe->dvb->priv;
453 struct tda1004x_state *state = fe->demodulator_priv;
454 u8 addr = state->config->i2c_gate;
455 u8 config = state->config->tuner_config;
456 u8 GP00_CF[] = {0x20, 0x01};
457 u8 GP00_LEV[] = {0x22, 0x00};
458
459 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
460 if (config) {
461 if (high) {
462 dprintk("setting LNA to high gain\n");
463 } else {
464 dprintk("setting LNA to low gain\n");
465 }
466 }
467 switch (config) {
468 case 0: /* no LNA */
469 break;
470 case 1: /* switch is GPIO 0 of tda8290 */
471 case 2:
472 /* turn Vsync off */
473 saa7134_set_gpio(dev, 22, 0);
474 GP00_LEV[1] = high ? 0 : 1;
475 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
476 wprintk("could not access tda8290 at addr: 0x%02x\n",
477 addr << 1);
478 return;
479 }
480 msg.buf = GP00_LEV;
481 if (config == 2)
482 GP00_LEV[1] = high ? 1 : 0;
483 i2c_transfer(&dev->i2c_adap, &msg, 1);
484 break;
485 case 3: /* switch with GPIO of saa713x */
486 saa7134_set_gpio(dev, 22, high);
487 break;
488 }
489}
490
491static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable) 485static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
492{ 486{
493 struct tda1004x_state *state = fe->demodulator_priv; 487 struct tda1004x_state *state = fe->demodulator_priv;
@@ -510,8 +504,6 @@ static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
510 return 0; 504 return 0;
511} 505}
512 506
513/* ------------------------------------------------------------------ */
514
515static int philips_tda827x_tuner_init(struct dvb_frontend *fe) 507static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
516{ 508{
517 struct saa7134_dev *dev = fe->dvb->priv; 509 struct saa7134_dev *dev = fe->dvb->priv;
@@ -546,28 +538,57 @@ static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
546 return 0; 538 return 0;
547} 539}
548 540
549static struct tda827x_config tda827x_cfg = { 541static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *cdec_conf,
550 .lna_gain = philips_tda827x_lna_gain, 542 struct tda827x_config *tuner_conf)
551 .init = philips_tda827x_tuner_init,
552 .sleep = philips_tda827x_tuner_sleep
553};
554
555static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
556{ 543{
557 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap); 544 dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
558 if (dev->dvb.frontend) { 545 if (dev->dvb.frontend) {
559 if (tda_conf->i2c_gate) 546 if (cdec_conf->i2c_gate)
560 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; 547 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
561 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address, 548 if (dvb_attach(tda827x_attach, dev->dvb.frontend, cdec_conf->tuner_address,
562 &dev->i2c_adap,&tda827x_cfg) == NULL) { 549 &dev->i2c_adap, tuner_conf) == NULL) {
563 wprintk("no tda827x tuner found at addr: %02x\n", 550 wprintk("no tda827x tuner found at addr: %02x\n",
564 tda_conf->tuner_address); 551 cdec_conf->tuner_address);
565 } 552 }
566 } 553 }
567} 554}
568 555
569/* ------------------------------------------------------------------ */ 556/* ------------------------------------------------------------------ */
570 557
558static struct tda827x_config tda827x_cfg_0 = {
559 .tuner_callback = saa7134_tuner_callback,
560 .init = philips_tda827x_tuner_init,
561 .sleep = philips_tda827x_tuner_sleep,
562 .config = 0,
563 .switch_addr = 0
564};
565
566static struct tda827x_config tda827x_cfg_1 = {
567 .tuner_callback = saa7134_tuner_callback,
568 .init = philips_tda827x_tuner_init,
569 .sleep = philips_tda827x_tuner_sleep,
570 .config = 1,
571 .switch_addr = 0x4b
572};
573
574static struct tda827x_config tda827x_cfg_2 = {
575 .tuner_callback = saa7134_tuner_callback,
576 .init = philips_tda827x_tuner_init,
577 .sleep = philips_tda827x_tuner_sleep,
578 .config = 2,
579 .switch_addr = 0x4b
580};
581
582static struct tda827x_config tda827x_cfg_2_sw42 = {
583 .tuner_callback = saa7134_tuner_callback,
584 .init = philips_tda827x_tuner_init,
585 .sleep = philips_tda827x_tuner_sleep,
586 .config = 2,
587 .switch_addr = 0x42
588};
589
590/* ------------------------------------------------------------------ */
591
571static struct tda1004x_config tda827x_lifeview_config = { 592static struct tda1004x_config tda827x_lifeview_config = {
572 .demod_address = 0x08, 593 .demod_address = 0x08,
573 .invert = 1, 594 .invert = 1,
@@ -590,7 +611,6 @@ static struct tda1004x_config philips_tiger_config = {
590 .if_freq = TDA10046_FREQ_045, 611 .if_freq = TDA10046_FREQ_045,
591 .i2c_gate = 0x4b, 612 .i2c_gate = 0x4b,
592 .tuner_address = 0x61, 613 .tuner_address = 0x61,
593 .tuner_config = 0,
594 .antenna_switch= 1, 614 .antenna_switch= 1,
595 .request_firmware = philips_tda1004x_request_firmware 615 .request_firmware = philips_tda1004x_request_firmware
596}; 616};
@@ -605,7 +625,6 @@ static struct tda1004x_config cinergy_ht_config = {
605 .if_freq = TDA10046_FREQ_045, 625 .if_freq = TDA10046_FREQ_045,
606 .i2c_gate = 0x4b, 626 .i2c_gate = 0x4b,
607 .tuner_address = 0x61, 627 .tuner_address = 0x61,
608 .tuner_config = 0,
609 .request_firmware = philips_tda1004x_request_firmware 628 .request_firmware = philips_tda1004x_request_firmware
610}; 629};
611 630
@@ -619,7 +638,6 @@ static struct tda1004x_config cinergy_ht_pci_config = {
619 .if_freq = TDA10046_FREQ_045, 638 .if_freq = TDA10046_FREQ_045,
620 .i2c_gate = 0x4b, 639 .i2c_gate = 0x4b,
621 .tuner_address = 0x60, 640 .tuner_address = 0x60,
622 .tuner_config = 0,
623 .request_firmware = philips_tda1004x_request_firmware 641 .request_firmware = philips_tda1004x_request_firmware
624}; 642};
625 643
@@ -633,7 +651,6 @@ static struct tda1004x_config philips_tiger_s_config = {
633 .if_freq = TDA10046_FREQ_045, 651 .if_freq = TDA10046_FREQ_045,
634 .i2c_gate = 0x4b, 652 .i2c_gate = 0x4b,
635 .tuner_address = 0x61, 653 .tuner_address = 0x61,
636 .tuner_config = 2,
637 .antenna_switch= 1, 654 .antenna_switch= 1,
638 .request_firmware = philips_tda1004x_request_firmware 655 .request_firmware = philips_tda1004x_request_firmware
639}; 656};
@@ -648,7 +665,6 @@ static struct tda1004x_config pinnacle_pctv_310i_config = {
648 .if_freq = TDA10046_FREQ_045, 665 .if_freq = TDA10046_FREQ_045,
649 .i2c_gate = 0x4b, 666 .i2c_gate = 0x4b,
650 .tuner_address = 0x61, 667 .tuner_address = 0x61,
651 .tuner_config = 1,
652 .request_firmware = philips_tda1004x_request_firmware 668 .request_firmware = philips_tda1004x_request_firmware
653}; 669};
654 670
@@ -662,7 +678,6 @@ static struct tda1004x_config hauppauge_hvr_1110_config = {
662 .if_freq = TDA10046_FREQ_045, 678 .if_freq = TDA10046_FREQ_045,
663 .i2c_gate = 0x4b, 679 .i2c_gate = 0x4b,
664 .tuner_address = 0x61, 680 .tuner_address = 0x61,
665 .tuner_config = 1,
666 .request_firmware = philips_tda1004x_request_firmware 681 .request_firmware = philips_tda1004x_request_firmware
667}; 682};
668 683
@@ -676,7 +691,6 @@ static struct tda1004x_config asus_p7131_dual_config = {
676 .if_freq = TDA10046_FREQ_045, 691 .if_freq = TDA10046_FREQ_045,
677 .i2c_gate = 0x4b, 692 .i2c_gate = 0x4b,
678 .tuner_address = 0x61, 693 .tuner_address = 0x61,
679 .tuner_config = 0,
680 .antenna_switch= 2, 694 .antenna_switch= 2,
681 .request_firmware = philips_tda1004x_request_firmware 695 .request_firmware = philips_tda1004x_request_firmware
682}; 696};
@@ -715,7 +729,6 @@ static struct tda1004x_config md8800_dvbt_config = {
715 .if_freq = TDA10046_FREQ_045, 729 .if_freq = TDA10046_FREQ_045,
716 .i2c_gate = 0x4b, 730 .i2c_gate = 0x4b,
717 .tuner_address = 0x60, 731 .tuner_address = 0x60,
718 .tuner_config = 0,
719 .request_firmware = philips_tda1004x_request_firmware 732 .request_firmware = philips_tda1004x_request_firmware
720}; 733};
721 734
@@ -729,7 +742,6 @@ static struct tda1004x_config asus_p7131_4871_config = {
729 .if_freq = TDA10046_FREQ_045, 742 .if_freq = TDA10046_FREQ_045,
730 .i2c_gate = 0x4b, 743 .i2c_gate = 0x4b,
731 .tuner_address = 0x61, 744 .tuner_address = 0x61,
732 .tuner_config = 2,
733 .antenna_switch= 2, 745 .antenna_switch= 2,
734 .request_firmware = philips_tda1004x_request_firmware 746 .request_firmware = philips_tda1004x_request_firmware
735}; 747};
@@ -744,7 +756,6 @@ static struct tda1004x_config asus_p7131_hybrid_lna_config = {
744 .if_freq = TDA10046_FREQ_045, 756 .if_freq = TDA10046_FREQ_045,
745 .i2c_gate = 0x4b, 757 .i2c_gate = 0x4b,
746 .tuner_address = 0x61, 758 .tuner_address = 0x61,
747 .tuner_config = 2,
748 .antenna_switch= 2, 759 .antenna_switch= 2,
749 .request_firmware = philips_tda1004x_request_firmware 760 .request_firmware = philips_tda1004x_request_firmware
750}; 761};
@@ -759,7 +770,6 @@ static struct tda1004x_config kworld_dvb_t_210_config = {
759 .if_freq = TDA10046_FREQ_045, 770 .if_freq = TDA10046_FREQ_045,
760 .i2c_gate = 0x4b, 771 .i2c_gate = 0x4b,
761 .tuner_address = 0x61, 772 .tuner_address = 0x61,
762 .tuner_config = 2,
763 .antenna_switch= 1, 773 .antenna_switch= 1,
764 .request_firmware = philips_tda1004x_request_firmware 774 .request_firmware = philips_tda1004x_request_firmware
765}; 775};
@@ -774,7 +784,6 @@ static struct tda1004x_config avermedia_super_007_config = {
774 .if_freq = TDA10046_FREQ_045, 784 .if_freq = TDA10046_FREQ_045,
775 .i2c_gate = 0x4b, 785 .i2c_gate = 0x4b,
776 .tuner_address = 0x60, 786 .tuner_address = 0x60,
777 .tuner_config = 0,
778 .antenna_switch= 1, 787 .antenna_switch= 1,
779 .request_firmware = philips_tda1004x_request_firmware 788 .request_firmware = philips_tda1004x_request_firmware
780}; 789};
@@ -789,7 +798,6 @@ static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
789 .if_freq = TDA10046_FREQ_045, 798 .if_freq = TDA10046_FREQ_045,
790 .i2c_gate = 0x42, 799 .i2c_gate = 0x42,
791 .tuner_address = 0x61, 800 .tuner_address = 0x61,
792 .tuner_config = 2,
793 .antenna_switch = 1, 801 .antenna_switch = 1,
794 .request_firmware = philips_tda1004x_request_firmware 802 .request_firmware = philips_tda1004x_request_firmware
795}; 803};
@@ -817,9 +825,10 @@ static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
817} 825}
818 826
819static struct tda827x_config ads_duo_cfg = { 827static struct tda827x_config ads_duo_cfg = {
820 .lna_gain = philips_tda827x_lna_gain, 828 .tuner_callback = saa7134_tuner_callback,
821 .init = ads_duo_tuner_init, 829 .init = ads_duo_tuner_init,
822 .sleep = ads_duo_tuner_sleep 830 .sleep = ads_duo_tuner_sleep,
831 .config = 0
823}; 832};
824 833
825static struct tda1004x_config ads_tech_duo_config = { 834static struct tda1004x_config ads_tech_duo_config = {
@@ -842,8 +851,73 @@ static struct tda10086_config flydvbs = {
842 .demod_address = 0x0e, 851 .demod_address = 0x0e,
843 .invert = 0, 852 .invert = 0,
844 .diseqc_tone = 0, 853 .diseqc_tone = 0,
854 .xtal_freq = TDA10086_XTAL_16M,
845}; 855};
846 856
857static struct tda10086_config sd1878_4m = {
858 .demod_address = 0x0e,
859 .invert = 0,
860 .diseqc_tone = 0,
861 .xtal_freq = TDA10086_XTAL_4M,
862};
863
864/* ------------------------------------------------------------------
865 * special case: lnb supply is connected to the gated i2c
866 */
867
868static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
869{
870 int res = -EIO;
871 struct saa7134_dev *dev = fe->dvb->priv;
872 if (fe->ops.i2c_gate_ctrl) {
873 fe->ops.i2c_gate_ctrl(fe, 1);
874 if (dev->original_set_voltage)
875 res = dev->original_set_voltage(fe, voltage);
876 fe->ops.i2c_gate_ctrl(fe, 0);
877 }
878 return res;
879};
880
881static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
882{
883 int res = -EIO;
884 struct saa7134_dev *dev = fe->dvb->priv;
885 if (fe->ops.i2c_gate_ctrl) {
886 fe->ops.i2c_gate_ctrl(fe, 1);
887 if (dev->original_set_high_voltage)
888 res = dev->original_set_high_voltage(fe, arg);
889 fe->ops.i2c_gate_ctrl(fe, 0);
890 }
891 return res;
892};
893
894static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
895{
896 struct saa7134_dev *dev = fe->dvb->priv;
897 u8 wbuf[2] = { 0x1f, 00 };
898 u8 rbuf;
899 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
900 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
901
902 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
903 return -EIO;
904 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
905 if (voltage == SEC_VOLTAGE_18)
906 wbuf[1] = rbuf | 0x10;
907 else
908 wbuf[1] = rbuf & 0xef;
909 msg[0].len = 2;
910 i2c_transfer(&dev->i2c_adap, msg, 1);
911 return 0;
912}
913
914static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
915{
916 struct saa7134_dev *dev = fe->dvb->priv;
917 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
918 return -EIO;
919}
920
847/* ================================================================== 921/* ==================================================================
848 * nxt200x based ATSC cards, helper functions 922 * nxt200x based ATSC cards, helper functions
849 */ 923 */
@@ -863,12 +937,14 @@ static struct nxt200x_config kworldatsc110 = {
863static int dvb_init(struct saa7134_dev *dev) 937static int dvb_init(struct saa7134_dev *dev)
864{ 938{
865 int ret; 939 int ret;
940 int attach_xc3028 = 0;
941
866 /* init struct videobuf_dvb */ 942 /* init struct videobuf_dvb */
867 dev->ts.nr_bufs = 32; 943 dev->ts.nr_bufs = 32;
868 dev->ts.nr_packets = 32*4; 944 dev->ts.nr_packets = 32*4;
869 dev->dvb.name = dev->name; 945 dev->dvb.name = dev->name;
870 videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops, 946 videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops,
871 dev->pci, &dev->slock, 947 &dev->pci->dev, &dev->slock,
872 V4L2_BUF_TYPE_VIDEO_CAPTURE, 948 V4L2_BUF_TYPE_VIDEO_CAPTURE,
873 V4L2_FIELD_ALTERNATE, 949 V4L2_FIELD_ALTERNATE,
874 sizeof(struct saa7134_buf), 950 sizeof(struct saa7134_buf),
@@ -889,17 +965,25 @@ static int dvb_init(struct saa7134_dev *dev)
889 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, 965 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
890 &dev->i2c_adap); 966 &dev->i2c_adap);
891 if (dev->dvb.frontend) { 967 if (dev->dvb.frontend) {
892 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 968 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
893 NULL, DVB_PLL_PHILIPS_TD1316); 969 &dev->i2c_adap, 0x61,
970 TUNER_PHILIPS_TD1316);
894 } 971 }
895 break; 972 break;
973 case SAA7134_BOARD_AVERMEDIA_A16D:
974 dprintk("avertv A16D dvb setup\n");
975 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_16d,
976 &dev->i2c_adap);
977 attach_xc3028 = 1;
978 break;
896 case SAA7134_BOARD_MD7134: 979 case SAA7134_BOARD_MD7134:
897 dev->dvb.frontend = dvb_attach(tda10046_attach, 980 dev->dvb.frontend = dvb_attach(tda10046_attach,
898 &medion_cardbus, 981 &medion_cardbus,
899 &dev->i2c_adap); 982 &dev->i2c_adap);
900 if (dev->dvb.frontend) { 983 if (dev->dvb.frontend) {
901 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address, 984 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
902 &dev->i2c_adap, DVB_PLL_FMD1216ME); 985 &dev->i2c_adap, medion_cardbus.tuner_address,
986 TUNER_PHILIPS_FMD1216ME_MK3);
903 } 987 }
904 break; 988 break;
905 case SAA7134_BOARD_PHILIPS_TOUGH: 989 case SAA7134_BOARD_PHILIPS_TOUGH:
@@ -913,7 +997,7 @@ static int dvb_init(struct saa7134_dev *dev)
913 break; 997 break;
914 case SAA7134_BOARD_FLYDVBTDUO: 998 case SAA7134_BOARD_FLYDVBTDUO:
915 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: 999 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
916 configure_tda827x_fe(dev, &tda827x_lifeview_config); 1000 configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0);
917 break; 1001 break;
918 case SAA7134_BOARD_PHILIPS_EUROPA: 1002 case SAA7134_BOARD_PHILIPS_EUROPA:
919 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1003 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
@@ -938,36 +1022,36 @@ static int dvb_init(struct saa7134_dev *dev)
938 } 1022 }
939 break; 1023 break;
940 case SAA7134_BOARD_KWORLD_DVBT_210: 1024 case SAA7134_BOARD_KWORLD_DVBT_210:
941 configure_tda827x_fe(dev, &kworld_dvb_t_210_config); 1025 configure_tda827x_fe(dev, &kworld_dvb_t_210_config, &tda827x_cfg_2);
942 break; 1026 break;
943 case SAA7134_BOARD_PHILIPS_TIGER: 1027 case SAA7134_BOARD_PHILIPS_TIGER:
944 configure_tda827x_fe(dev, &philips_tiger_config); 1028 configure_tda827x_fe(dev, &philips_tiger_config, &tda827x_cfg_0);
945 break; 1029 break;
946 case SAA7134_BOARD_PINNACLE_PCTV_310i: 1030 case SAA7134_BOARD_PINNACLE_PCTV_310i:
947 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config); 1031 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, &tda827x_cfg_1);
948 break; 1032 break;
949 case SAA7134_BOARD_HAUPPAUGE_HVR1110: 1033 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
950 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config); 1034 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, &tda827x_cfg_1);
951 break; 1035 break;
952 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 1036 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
953 configure_tda827x_fe(dev, &asus_p7131_dual_config); 1037 configure_tda827x_fe(dev, &asus_p7131_dual_config, &tda827x_cfg_0);
954 break; 1038 break;
955 case SAA7134_BOARD_FLYDVBT_LR301: 1039 case SAA7134_BOARD_FLYDVBT_LR301:
956 configure_tda827x_fe(dev, &tda827x_lifeview_config); 1040 configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0);
957 break; 1041 break;
958 case SAA7134_BOARD_FLYDVB_TRIO: 1042 case SAA7134_BOARD_FLYDVB_TRIO:
959 if(! use_frontend) { /* terrestrial */ 1043 if(! use_frontend) { /* terrestrial */
960 configure_tda827x_fe(dev, &lifeview_trio_config); 1044 configure_tda827x_fe(dev, &lifeview_trio_config, &tda827x_cfg_0);
961 } else { /* satellite */ 1045 } else { /* satellite */
962 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 1046 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
963 if (dev->dvb.frontend) { 1047 if (dev->dvb.frontend) {
964 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, 1048 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
965 &dev->i2c_adap, 0) == NULL) { 1049 &dev->i2c_adap, 0) == NULL) {
966 wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__); 1050 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
967 } 1051 }
968 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, 1052 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
969 0x08, 0, 0) == NULL) { 1053 0x08, 0, 0) == NULL) {
970 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__); 1054 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
971 } 1055 }
972 } 1056 }
973 } 1057 }
@@ -979,18 +1063,56 @@ static int dvb_init(struct saa7134_dev *dev)
979 &dev->i2c_adap); 1063 &dev->i2c_adap);
980 if (dev->dvb.frontend) { 1064 if (dev->dvb.frontend) {
981 if (dvb_attach(tda827x_attach,dev->dvb.frontend, 1065 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
982 ads_tech_duo_config.tuner_address, 1066 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
983 &dev->i2c_adap,&ads_duo_cfg) == NULL) { 1067 &ads_duo_cfg) == NULL) {
984 wprintk("no tda827x tuner found at addr: %02x\n", 1068 wprintk("no tda827x tuner found at addr: %02x\n",
985 ads_tech_duo_config.tuner_address); 1069 ads_tech_duo_config.tuner_address);
986 } 1070 }
987 } 1071 }
988 break; 1072 break;
989 case SAA7134_BOARD_TEVION_DVBT_220RF: 1073 case SAA7134_BOARD_TEVION_DVBT_220RF:
990 configure_tda827x_fe(dev, &tevion_dvbt220rf_config); 1074 configure_tda827x_fe(dev, &tevion_dvbt220rf_config, &tda827x_cfg_0);
991 break; 1075 break;
992 case SAA7134_BOARD_MEDION_MD8800_QUADRO: 1076 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
993 configure_tda827x_fe(dev, &md8800_dvbt_config); 1077 if (!use_frontend) { /* terrestrial */
1078 configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0);
1079 } else { /* satellite */
1080 dev->dvb.frontend = dvb_attach(tda10086_attach,
1081 &flydvbs, &dev->i2c_adap);
1082 if (dev->dvb.frontend) {
1083 struct dvb_frontend *fe = dev->dvb.frontend;
1084 u8 dev_id = dev->eedata[2];
1085 u8 data = 0xc4;
1086 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1087
1088 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1089 0x60, &dev->i2c_adap, 0) == NULL)
1090 wprintk("%s: Medion Quadro, no tda826x "
1091 "found !\n", __func__);
1092 if (dev_id != 0x08) {
1093 /* we need to open the i2c gate (we know it exists) */
1094 fe->ops.i2c_gate_ctrl(fe, 1);
1095 if (dvb_attach(isl6405_attach, fe,
1096 &dev->i2c_adap, 0x08, 0, 0) == NULL)
1097 wprintk("%s: Medion Quadro, no ISL6405 "
1098 "found !\n", __func__);
1099 if (dev_id == 0x07) {
1100 /* fire up the 2nd section of the LNB supply since
1101 we can't do this from the other section */
1102 msg.buf = &data;
1103 i2c_transfer(&dev->i2c_adap, &msg, 1);
1104 }
1105 fe->ops.i2c_gate_ctrl(fe, 0);
1106 dev->original_set_voltage = fe->ops.set_voltage;
1107 fe->ops.set_voltage = md8800_set_voltage;
1108 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1109 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1110 } else {
1111 fe->ops.set_voltage = md8800_set_voltage2;
1112 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1113 }
1114 }
1115 }
994 break; 1116 break;
995 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1117 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
996 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1118 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
@@ -1004,8 +1126,9 @@ static int dvb_init(struct saa7134_dev *dev)
1004 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, 1126 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1005 &dev->i2c_adap); 1127 &dev->i2c_adap);
1006 if (dev->dvb.frontend) { 1128 if (dev->dvb.frontend) {
1007 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 1129 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1008 NULL, DVB_PLL_TUV1236D); 1130 &dev->i2c_adap, 0x61,
1131 TUNER_PHILIPS_TUV1236D);
1009 } 1132 }
1010 break; 1133 break;
1011 case SAA7134_BOARD_FLYDVBS_LR300: 1134 case SAA7134_BOARD_FLYDVBS_LR300:
@@ -1014,11 +1137,11 @@ static int dvb_init(struct saa7134_dev *dev)
1014 if (dev->dvb.frontend) { 1137 if (dev->dvb.frontend) {
1015 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1138 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1016 &dev->i2c_adap, 0) == NULL) { 1139 &dev->i2c_adap, 0) == NULL) {
1017 wprintk("%s: No tda826x found!\n", __FUNCTION__); 1140 wprintk("%s: No tda826x found!\n", __func__);
1018 } 1141 }
1019 if (dvb_attach(isl6421_attach, dev->dvb.frontend, 1142 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1020 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1143 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1021 wprintk("%s: No ISL6421 found!\n", __FUNCTION__); 1144 wprintk("%s: No ISL6421 found!\n", __func__);
1022 } 1145 }
1023 } 1146 }
1024 break; 1147 break;
@@ -1030,8 +1153,9 @@ static int dvb_init(struct saa7134_dev *dev)
1030 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; 1153 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1031 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; 1154 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1032 1155
1033 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address, 1156 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1034 &dev->i2c_adap, DVB_PLL_FMD1216ME); 1157 &dev->i2c_adap, medion_cardbus.tuner_address,
1158 TUNER_PHILIPS_FMD1216ME_MK3);
1035 } 1159 }
1036 break; 1160 break;
1037 case SAA7134_BOARD_VIDEOMATE_DVBT_200A: 1161 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
@@ -1044,38 +1168,107 @@ static int dvb_init(struct saa7134_dev *dev)
1044 } 1168 }
1045 break; 1169 break;
1046 case SAA7134_BOARD_CINERGY_HT_PCMCIA: 1170 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1047 configure_tda827x_fe(dev, &cinergy_ht_config); 1171 configure_tda827x_fe(dev, &cinergy_ht_config, &tda827x_cfg_0);
1048 break; 1172 break;
1049 case SAA7134_BOARD_CINERGY_HT_PCI: 1173 case SAA7134_BOARD_CINERGY_HT_PCI:
1050 configure_tda827x_fe(dev, &cinergy_ht_pci_config); 1174 configure_tda827x_fe(dev, &cinergy_ht_pci_config, &tda827x_cfg_0);
1051 break; 1175 break;
1052 case SAA7134_BOARD_PHILIPS_TIGER_S: 1176 case SAA7134_BOARD_PHILIPS_TIGER_S:
1053 configure_tda827x_fe(dev, &philips_tiger_s_config); 1177 configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2);
1054 break; 1178 break;
1055 case SAA7134_BOARD_ASUS_P7131_4871: 1179 case SAA7134_BOARD_ASUS_P7131_4871:
1056 configure_tda827x_fe(dev, &asus_p7131_4871_config); 1180 configure_tda827x_fe(dev, &asus_p7131_4871_config, &tda827x_cfg_2);
1057 break; 1181 break;
1058 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 1182 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1059 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config); 1183 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, &tda827x_cfg_2);
1060 break; 1184 break;
1061 case SAA7134_BOARD_AVERMEDIA_SUPER_007: 1185 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1062 configure_tda827x_fe(dev, &avermedia_super_007_config); 1186 configure_tda827x_fe(dev, &avermedia_super_007_config, &tda827x_cfg_0);
1063 break; 1187 break;
1064 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: 1188 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1065 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config); 1189 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, &tda827x_cfg_2_sw42);
1190 break;
1191 case SAA7134_BOARD_PHILIPS_SNAKE:
1192 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1193 &dev->i2c_adap);
1194 if (dev->dvb.frontend) {
1195 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1196 &dev->i2c_adap, 0) == NULL)
1197 wprintk("%s: No tda826x found!\n", __func__);
1198 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1199 &dev->i2c_adap, 0, 0) == NULL)
1200 wprintk("%s: No lnbp21 found!\n", __func__);
1201 }
1202 break;
1203 case SAA7134_BOARD_CREATIX_CTX953:
1204 configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0);
1205 break;
1206 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1207 configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2);
1208 break;
1209 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1210 dev->dvb.frontend = dvb_attach(mt352_attach,
1211 &avermedia_e506r_mt352_dev,
1212 &dev->i2c_adap);
1213 attach_xc3028 = 1;
1214 break;
1215 case SAA7134_BOARD_MD7134_BRIDGE_2:
1216 dev->dvb.frontend = dvb_attach(tda10086_attach,
1217 &sd1878_4m, &dev->i2c_adap);
1218 if (dev->dvb.frontend) {
1219 struct dvb_frontend *fe;
1220 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
1221 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL)
1222 wprintk("%s: MD7134 DVB-S, no SD1878 "
1223 "found !\n", __func__);
1224 /* we need to open the i2c gate (we know it exists) */
1225 fe = dev->dvb.frontend;
1226 fe->ops.i2c_gate_ctrl(fe, 1);
1227 if (dvb_attach(isl6405_attach, fe,
1228 &dev->i2c_adap, 0x08, 0, 0) == NULL)
1229 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1230 "found !\n", __func__);
1231 fe->ops.i2c_gate_ctrl(fe, 0);
1232 dev->original_set_voltage = fe->ops.set_voltage;
1233 fe->ops.set_voltage = md8800_set_voltage;
1234 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1235 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1236 }
1066 break; 1237 break;
1067 default: 1238 default:
1068 wprintk("Huh? unknown DVB card?\n"); 1239 wprintk("Huh? unknown DVB card?\n");
1069 break; 1240 break;
1070 } 1241 }
1071 1242
1243 if (attach_xc3028) {
1244 struct dvb_frontend *fe;
1245 struct xc2028_config cfg = {
1246 .i2c_adap = &dev->i2c_adap,
1247 .i2c_addr = 0x61,
1248 };
1249
1250 if (!dev->dvb.frontend)
1251 return -1;
1252
1253 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
1254 if (!fe) {
1255 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1256 dev->name);
1257 dvb_frontend_detach(dev->dvb.frontend);
1258 dvb_unregister_frontend(dev->dvb.frontend);
1259 dev->dvb.frontend = NULL;
1260 return -1;
1261 }
1262 }
1263
1072 if (NULL == dev->dvb.frontend) { 1264 if (NULL == dev->dvb.frontend) {
1073 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); 1265 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1074 return -1; 1266 return -1;
1075 } 1267 }
1076 1268
1077 /* register everything else */ 1269 /* register everything else */
1078 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev); 1270 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev,
1271 adapter_nr);
1079 1272
1080 /* this sequence is necessary to make the tda1004x load its firmware 1273 /* this sequence is necessary to make the tda1004x load its firmware
1081 * and to enter analog mode of hybrid boards 1274 * and to enter analog mode of hybrid boards
@@ -1106,9 +1299,22 @@ static int dvb_fini(struct saa7134_dev *dev)
1106 1299
1107 /* otherwise we don't detect the tuner on next insmod */ 1300 /* otherwise we don't detect the tuner on next insmod */
1108 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg); 1301 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
1302 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1303 if ((dev->eedata[2] == 0x07) && use_frontend) {
1304 /* turn off the 2nd lnb supply */
1305 u8 data = 0x80;
1306 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1307 struct dvb_frontend *fe;
1308 fe = dev->dvb.frontend;
1309 if (fe->ops.i2c_gate_ctrl) {
1310 fe->ops.i2c_gate_ctrl(fe, 1);
1311 i2c_transfer(&dev->i2c_adap, &msg, 1);
1312 fe->ops.i2c_gate_ctrl(fe, 0);
1313 }
1314 }
1109 } 1315 }
1110 1316 if (dev->dvb.frontend)
1111 videobuf_dvb_unregister(&dev->dvb); 1317 videobuf_dvb_unregister(&dev->dvb);
1112 return 0; 1318 return 0;
1113} 1319}
1114 1320