aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttpci/budget-av.c
diff options
context:
space:
mode:
authorAndrew de Quincey <adq_dvb@lidskialf.net>2006-01-09 12:25:09 -0500
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-09 12:25:09 -0500
commiteffa791c22ef2f944b4621c94150e129fe1af28b (patch)
tree0c8252490553e100b61631520b6203399d870b6d /drivers/media/dvb/ttpci/budget-av.c
parent1c956a3ac087b7590296f5a0be2cdab2666158cd (diff)
DVB (2454): Port code for SU1278/SH2 (TUA6100) from pre-refactored code
- Port code for SU1278/SH2 (TUA6100) from pre-refactored code Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'drivers/media/dvb/ttpci/budget-av.c')
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c156
1 files changed, 156 insertions, 0 deletions
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 8bc784ab1972..9a33f6d5d923 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -502,6 +502,140 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe,
502 return 0; 502 return 0;
503} 503}
504 504
505#define MIN2(a,b) ((a) < (b) ? (a) : (b))
506#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
507
508static int philips_su1278sh2_tua6100_pll_set(struct dvb_frontend *fe,
509 struct i2c_adapter *i2c,
510 struct dvb_frontend_parameters *params)
511{
512 u8 reg0 [2] = { 0x00, 0x00 };
513 u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 };
514 u8 reg2 [3] = { 0x02, 0x00, 0x00 };
515 int _fband;
516 int first_ZF;
517 int R, A, N, P, M;
518 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 };
519 int freq = params->frequency;
520
521 first_ZF = (freq) / 1000;
522
523 if (abs(MIN2(abs(first_ZF-1190),abs(first_ZF-1790))) <
524 abs(MIN3(abs(first_ZF-1202),abs(first_ZF-1542),abs(first_ZF-1890))))
525 _fband = 2;
526 else
527 _fband = 3;
528
529 if (_fband == 2) {
530 if (((first_ZF >= 950) && (first_ZF < 1350)) ||
531 ((first_ZF >= 1430) && (first_ZF < 1950)))
532 reg0[1] = 0x07;
533 else if (((first_ZF >= 1350) && (first_ZF < 1430)) ||
534 ((first_ZF >= 1950) && (first_ZF < 2150)))
535 reg0[1] = 0x0B;
536 }
537
538 if(_fband == 3) {
539 if (((first_ZF >= 950) && (first_ZF < 1350)) ||
540 ((first_ZF >= 1455) && (first_ZF < 1950)))
541 reg0[1] = 0x07;
542 else if (((first_ZF >= 1350) && (first_ZF < 1420)) ||
543 ((first_ZF >= 1950) && (first_ZF < 2150)))
544 reg0[1] = 0x0B;
545 else if ((first_ZF >= 1420) && (first_ZF < 1455))
546 reg0[1] = 0x0F;
547 }
548
549 if (first_ZF > 1525)
550 reg1[1] |= 0x80;
551 else
552 reg1[1] &= 0x7F;
553
554 if (_fband == 2) {
555 if (first_ZF > 1430) { /* 1430MHZ */
556 reg1[1] &= 0xCF; /* N2 */
557 reg2[1] &= 0xCF; /* R2 */
558 reg2[1] |= 0x10;
559 } else {
560 reg1[1] &= 0xCF; /* N2 */
561 reg1[1] |= 0x20;
562 reg2[1] &= 0xCF; /* R2 */
563 reg2[1] |= 0x10;
564 }
565 }
566
567 if (_fband == 3) {
568 if ((first_ZF >= 1455) &&
569 (first_ZF < 1630)) {
570 reg1[1] &= 0xCF; /* N2 */
571 reg1[1] |= 0x20;
572 reg2[1] &= 0xCF; /* R2 */
573 } else {
574 if (first_ZF < 1455) {
575 reg1[1] &= 0xCF; /* N2 */
576 reg1[1] |= 0x20;
577 reg2[1] &= 0xCF; /* R2 */
578 reg2[1] |= 0x10;
579 } else {
580 if (first_ZF >= 1630) {
581 reg1[1] &= 0xCF; /* N2 */
582 reg2[1] &= 0xCF; /* R2 */
583 reg2[1] |= 0x10;
584 }
585 }
586 }
587 }
588
589 /* set ports, enable P0 for symbol rates > 4Ms/s */
590 if (params->u.qpsk.symbol_rate >= 4000000)
591 reg1[1] |= 0x0c;
592 else
593 reg1[1] |= 0x04;
594
595 reg2[1] |= 0x0c;
596
597 R = 64;
598 A = 64;
599 P = 64; //32
600
601 M = (freq * R) / 4; /* in Mhz */
602 N = (M - A * 1000) / (P * 1000);
603
604 reg1[1] |= (N >> 9) & 0x03;
605 reg1[2] = (N >> 1) & 0xff;
606 reg1[3] = (N << 7) & 0x80;
607
608 reg2[1] |= (R >> 8) & 0x03;
609 reg2[2] = R & 0xFF; /* R */
610
611 reg1[3] |= A & 0x7f; /* A */
612
613 if (P == 64)
614 reg1[1] |= 0x40; /* Prescaler 64/65 */
615
616 reg0[1] |= 0x03;
617
618 /* already enabled - do not reenable i2c repeater or TX fails */
619 msg.buf = reg0;
620 msg.len = sizeof(reg0);
621 if (i2c_transfer(i2c, &msg, 1) != 1)
622 return -EIO;
623
624 stv0299_enable_plli2c(fe);
625 msg.buf = reg1;
626 msg.len = sizeof(reg1);
627 if (i2c_transfer(i2c, &msg, 1) != 1)
628 return -EIO;
629
630 stv0299_enable_plli2c(fe);
631 msg.buf = reg2;
632 msg.len = sizeof(reg2);
633 if (i2c_transfer(i2c, &msg, 1) != 1)
634 return -EIO;
635
636 return 0;
637}
638
505static u8 typhoon_cinergy1200s_inittab[] = { 639static u8 typhoon_cinergy1200s_inittab[] = {
506 0x01, 0x15, 640 0x01, 0x15,
507 0x02, 0x30, 641 0x02, 0x30,
@@ -571,6 +705,18 @@ static struct stv0299_config cinergy_1200s_config = {
571 .pll_set = philips_su1278_ty_ci_pll_set, 705 .pll_set = philips_su1278_ty_ci_pll_set,
572}; 706};
573 707
708static struct stv0299_config cinergy_1200s_1894_0010_config = {
709 .demod_address = 0x68,
710 .inittab = typhoon_cinergy1200s_inittab,
711 .mclk = 88000000UL,
712 .invert = 1,
713 .skip_reinit = 0,
714 .lock_output = STV0229_LOCKOUTPUT_1,
715 .volt13_op0_op1 = STV0299_VOLT13_OP0,
716 .min_delay_ms = 100,
717 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
718 .pll_set = philips_su1278sh2_tua6100_pll_set,
719};
574 720
575static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 721static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
576{ 722{
@@ -767,6 +913,15 @@ static void frontend_init(struct budget_av *budget_av)
767 switch (saa->pci->subsystem_device) { 913 switch (saa->pci->subsystem_device) {
768 914
769 case SUBID_DVBS_KNC1: 915 case SUBID_DVBS_KNC1:
916 if (saa->pci->subsystem_vendor == 0x1894) {
917 fe = stv0299_attach(&cinergy_1200s_1894_0010_config,
918 &budget_av->budget.i2c_adap);
919 } else {
920 fe = stv0299_attach(&typhoon_config,
921 &budget_av->budget.i2c_adap);
922 }
923 break;
924
770 case SUBID_DVBS_KNC1_PLUS: 925 case SUBID_DVBS_KNC1_PLUS:
771 case SUBID_DVBS_TYPHOON: 926 case SUBID_DVBS_TYPHOON:
772 fe = stv0299_attach(&typhoon_config, 927 fe = stv0299_attach(&typhoon_config,
@@ -1021,6 +1176,7 @@ MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
1021static struct pci_device_id pci_tbl[] = { 1176static struct pci_device_id pci_tbl[] = {
1022 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56), 1177 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
1023 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010), 1178 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
1179 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
1024 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011), 1180 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
1025 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020), 1181 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
1026 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021), 1182 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),