aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttpci/budget-av.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/ttpci/budget-av.c')
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c184
1 files changed, 20 insertions, 164 deletions
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 2d21fec23b4d..2235ff8b8a1d 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -37,6 +37,7 @@
37#include "stv0299.h" 37#include "stv0299.h"
38#include "tda10021.h" 38#include "tda10021.h"
39#include "tda1004x.h" 39#include "tda1004x.h"
40#include "tua6100.h"
40#include "dvb-pll.h" 41#include "dvb-pll.h"
41#include <media/saa7146_vv.h> 42#include <media/saa7146_vv.h>
42#include <linux/module.h> 43#include <linux/module.h>
@@ -235,7 +236,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
235 236
236 /* set tda10021 back to original clock configuration on reset */ 237 /* set tda10021 back to original clock configuration on reset */
237 if (budget_av->tda10021_poclkp) { 238 if (budget_av->tda10021_poclkp) {
238 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 239 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
239 budget_av->tda10021_ts_enabled = 0; 240 budget_av->tda10021_ts_enabled = 0;
240 } 241 }
241 242
@@ -257,7 +258,7 @@ static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
257 258
258 /* set tda10021 back to original clock configuration when cam removed */ 259 /* set tda10021 back to original clock configuration when cam removed */
259 if (budget_av->tda10021_poclkp) { 260 if (budget_av->tda10021_poclkp) {
260 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 261 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
261 budget_av->tda10021_ts_enabled = 0; 262 budget_av->tda10021_ts_enabled = 0;
262 } 263 }
263 return 0; 264 return 0;
@@ -277,7 +278,7 @@ static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
277 278
278 /* tda10021 seems to need a different TS clock config when data is routed to the CAM */ 279 /* tda10021 seems to need a different TS clock config when data is routed to the CAM */
279 if (budget_av->tda10021_poclkp) { 280 if (budget_av->tda10021_poclkp) {
280 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1); 281 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa1);
281 budget_av->tda10021_ts_enabled = 1; 282 budget_av->tda10021_ts_enabled = 1;
282 } 283 }
283 284
@@ -548,144 +549,6 @@ static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,
548 return 0; 549 return 0;
549} 550}
550 551
551#define MIN2(a,b) ((a) < (b) ? (a) : (b))
552#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
553
554static int philips_su1278sh2_tua6100_tuner_set_params(struct dvb_frontend *fe,
555 struct dvb_frontend_parameters *params)
556{
557 u8 reg0 [2] = { 0x00, 0x00 };
558 u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 };
559 u8 reg2 [3] = { 0x02, 0x00, 0x00 };
560 int _fband;
561 int first_ZF;
562 int R, A, N, P, M;
563 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 };
564 int freq = params->frequency;
565 struct budget *budget = (struct budget *) fe->dvb->priv;
566
567 first_ZF = (freq) / 1000;
568
569 if (abs(MIN2(abs(first_ZF-1190),abs(first_ZF-1790))) <
570 abs(MIN3(abs(first_ZF-1202),abs(first_ZF-1542),abs(first_ZF-1890))))
571 _fband = 2;
572 else
573 _fband = 3;
574
575 if (_fband == 2) {
576 if (((first_ZF >= 950) && (first_ZF < 1350)) ||
577 ((first_ZF >= 1430) && (first_ZF < 1950)))
578 reg0[1] = 0x07;
579 else if (((first_ZF >= 1350) && (first_ZF < 1430)) ||
580 ((first_ZF >= 1950) && (first_ZF < 2150)))
581 reg0[1] = 0x0B;
582 }
583
584 if(_fband == 3) {
585 if (((first_ZF >= 950) && (first_ZF < 1350)) ||
586 ((first_ZF >= 1455) && (first_ZF < 1950)))
587 reg0[1] = 0x07;
588 else if (((first_ZF >= 1350) && (first_ZF < 1420)) ||
589 ((first_ZF >= 1950) && (first_ZF < 2150)))
590 reg0[1] = 0x0B;
591 else if ((first_ZF >= 1420) && (first_ZF < 1455))
592 reg0[1] = 0x0F;
593 }
594
595 if (first_ZF > 1525)
596 reg1[1] |= 0x80;
597 else
598 reg1[1] &= 0x7F;
599
600 if (_fband == 2) {
601 if (first_ZF > 1430) { /* 1430MHZ */
602 reg1[1] &= 0xCF; /* N2 */
603 reg2[1] &= 0xCF; /* R2 */
604 reg2[1] |= 0x10;
605 } else {
606 reg1[1] &= 0xCF; /* N2 */
607 reg1[1] |= 0x20;
608 reg2[1] &= 0xCF; /* R2 */
609 reg2[1] |= 0x10;
610 }
611 }
612
613 if (_fband == 3) {
614 if ((first_ZF >= 1455) &&
615 (first_ZF < 1630)) {
616 reg1[1] &= 0xCF; /* N2 */
617 reg1[1] |= 0x20;
618 reg2[1] &= 0xCF; /* R2 */
619 } else {
620 if (first_ZF < 1455) {
621 reg1[1] &= 0xCF; /* N2 */
622 reg1[1] |= 0x20;
623 reg2[1] &= 0xCF; /* R2 */
624 reg2[1] |= 0x10;
625 } else {
626 if (first_ZF >= 1630) {
627 reg1[1] &= 0xCF; /* N2 */
628 reg2[1] &= 0xCF; /* R2 */
629 reg2[1] |= 0x10;
630 }
631 }
632 }
633 }
634
635 /* set ports, enable P0 for symbol rates > 4Ms/s */
636 if (params->u.qpsk.symbol_rate >= 4000000)
637 reg1[1] |= 0x0c;
638 else
639 reg1[1] |= 0x04;
640
641 reg2[1] |= 0x0c;
642
643 R = 64;
644 A = 64;
645 P = 64; //32
646
647 M = (freq * R) / 4; /* in Mhz */
648 N = (M - A * 1000) / (P * 1000);
649
650 reg1[1] |= (N >> 9) & 0x03;
651 reg1[2] = (N >> 1) & 0xff;
652 reg1[3] = (N << 7) & 0x80;
653
654 reg2[1] |= (R >> 8) & 0x03;
655 reg2[2] = R & 0xFF; /* R */
656
657 reg1[3] |= A & 0x7f; /* A */
658
659 if (P == 64)
660 reg1[1] |= 0x40; /* Prescaler 64/65 */
661
662 reg0[1] |= 0x03;
663
664 /* already enabled - do not reenable i2c repeater or TX fails */
665 if (fe->ops.i2c_gate_ctrl)
666 fe->ops.i2c_gate_ctrl(fe, 1);
667 msg.buf = reg0;
668 msg.len = sizeof(reg0);
669 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
670 return -EIO;
671
672 if (fe->ops.i2c_gate_ctrl)
673 fe->ops.i2c_gate_ctrl(fe, 1);
674 msg.buf = reg1;
675 msg.len = sizeof(reg1);
676 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
677 return -EIO;
678
679 if (fe->ops.i2c_gate_ctrl)
680 fe->ops.i2c_gate_ctrl(fe, 1);
681 msg.buf = reg2;
682 msg.len = sizeof(reg2);
683 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
684 return -EIO;
685
686 return 0;
687}
688
689static u8 typhoon_cinergy1200s_inittab[] = { 552static u8 typhoon_cinergy1200s_inittab[] = {
690 0x01, 0x15, 553 0x01, 0x15,
691 0x02, 0x30, 554 0x02, 0x30,
@@ -1068,9 +931,9 @@ static int tda10021_set_frontend(struct dvb_frontend *fe,
1068 931
1069 result = budget_av->tda10021_set_frontend(fe, p); 932 result = budget_av->tda10021_set_frontend(fe, p);
1070 if (budget_av->tda10021_ts_enabled) { 933 if (budget_av->tda10021_ts_enabled) {
1071 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1); 934 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa1);
1072 } else { 935 } else {
1073 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 936 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
1074 } 937 }
1075 938
1076 return result; 939 return result;
@@ -1096,15 +959,16 @@ static void frontend_init(struct budget_av *budget_av)
1096 switch (saa->pci->subsystem_device) { 959 switch (saa->pci->subsystem_device) {
1097 960
1098 case SUBID_DVBS_KNC1: 961 case SUBID_DVBS_KNC1:
962 case SUBID_DVBS_KNC1_PLUS:
1099 case SUBID_DVBS_EASYWATCH_1: 963 case SUBID_DVBS_EASYWATCH_1:
1100 if (saa->pci->subsystem_vendor == 0x1894) { 964 if (saa->pci->subsystem_vendor == 0x1894) {
1101 fe = stv0299_attach(&cinergy_1200s_1894_0010_config, 965 fe = dvb_attach(stv0299_attach, &cinergy_1200s_1894_0010_config,
1102 &budget_av->budget.i2c_adap); 966 &budget_av->budget.i2c_adap);
1103 if (fe) { 967 if (fe) {
1104 fe->ops.tuner_ops.set_params = philips_su1278sh2_tua6100_tuner_set_params; 968 dvb_attach(tua6100_attach, fe, 0x60, &budget_av->budget.i2c_adap);
1105 } 969 }
1106 } else { 970 } else {
1107 fe = stv0299_attach(&typhoon_config, 971 fe = dvb_attach(stv0299_attach, &typhoon_config,
1108 &budget_av->budget.i2c_adap); 972 &budget_av->budget.i2c_adap);
1109 if (fe) { 973 if (fe) {
1110 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 974 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1116,16 +980,15 @@ static void frontend_init(struct budget_av *budget_av)
1116 case SUBID_DVBS_TV_STAR_CI: 980 case SUBID_DVBS_TV_STAR_CI:
1117 case SUBID_DVBS_CYNERGY1200N: 981 case SUBID_DVBS_CYNERGY1200N:
1118 case SUBID_DVBS_EASYWATCH: 982 case SUBID_DVBS_EASYWATCH:
1119 fe = stv0299_attach(&philips_sd1878_config, 983 fe = dvb_attach(stv0299_attach, &philips_sd1878_config,
1120 &budget_av->budget.i2c_adap); 984 &budget_av->budget.i2c_adap);
1121 if (fe) { 985 if (fe) {
1122 fe->ops.tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params; 986 fe->ops.tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params;
1123 } 987 }
1124 break; 988 break;
1125 989
1126 case SUBID_DVBS_KNC1_PLUS:
1127 case SUBID_DVBS_TYPHOON: 990 case SUBID_DVBS_TYPHOON:
1128 fe = stv0299_attach(&typhoon_config, 991 fe = dvb_attach(stv0299_attach, &typhoon_config,
1129 &budget_av->budget.i2c_adap); 992 &budget_av->budget.i2c_adap);
1130 if (fe) { 993 if (fe) {
1131 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 994 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1133,7 +996,7 @@ static void frontend_init(struct budget_av *budget_av)
1133 break; 996 break;
1134 997
1135 case SUBID_DVBS_CINERGY1200: 998 case SUBID_DVBS_CINERGY1200:
1136 fe = stv0299_attach(&cinergy_1200s_config, 999 fe = dvb_attach(stv0299_attach, &cinergy_1200s_config,
1137 &budget_av->budget.i2c_adap); 1000 &budget_av->budget.i2c_adap);
1138 if (fe) { 1001 if (fe) {
1139 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 1002 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1141,19 +1004,10 @@ static void frontend_init(struct budget_av *budget_av)
1141 break; 1004 break;
1142 1005
1143 case SUBID_DVBC_KNC1: 1006 case SUBID_DVBC_KNC1:
1144 budget_av->reinitialise_demod = 1;
1145 fe = tda10021_attach(&philips_cu1216_config,
1146 &budget_av->budget.i2c_adap,
1147 read_pwm(budget_av));
1148 if (fe) {
1149 fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
1150 }
1151 break;
1152
1153 case SUBID_DVBC_KNC1_PLUS: 1007 case SUBID_DVBC_KNC1_PLUS:
1154 case SUBID_DVBC_CINERGY1200: 1008 case SUBID_DVBC_CINERGY1200:
1155 budget_av->reinitialise_demod = 1; 1009 budget_av->reinitialise_demod = 1;
1156 fe = tda10021_attach(&philips_cu1216_config, 1010 fe = dvb_attach(tda10021_attach, &philips_cu1216_config,
1157 &budget_av->budget.i2c_adap, 1011 &budget_av->budget.i2c_adap,
1158 read_pwm(budget_av)); 1012 read_pwm(budget_av));
1159 if (fe) { 1013 if (fe) {
@@ -1168,7 +1022,7 @@ static void frontend_init(struct budget_av *budget_av)
1168 case SUBID_DVBT_KNC1_PLUS: 1022 case SUBID_DVBT_KNC1_PLUS:
1169 case SUBID_DVBT_CINERGY1200: 1023 case SUBID_DVBT_CINERGY1200:
1170 budget_av->reinitialise_demod = 1; 1024 budget_av->reinitialise_demod = 1;
1171 fe = tda10046_attach(&philips_tu1216_config, 1025 fe = dvb_attach(tda10046_attach, &philips_tu1216_config,
1172 &budget_av->budget.i2c_adap); 1026 &budget_av->budget.i2c_adap);
1173 if (fe) { 1027 if (fe) {
1174 fe->ops.tuner_ops.init = philips_tu1216_tuner_init; 1028 fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
@@ -1192,8 +1046,7 @@ static void frontend_init(struct budget_av *budget_av)
1192 if (dvb_register_frontend(&budget_av->budget.dvb_adapter, 1046 if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
1193 budget_av->budget.dvb_frontend)) { 1047 budget_av->budget.dvb_frontend)) {
1194 printk(KERN_ERR "budget-av: Frontend registration failed!\n"); 1048 printk(KERN_ERR "budget-av: Frontend registration failed!\n");
1195 if (budget_av->budget.dvb_frontend->ops.release) 1049 dvb_frontend_detach(budget_av->budget.dvb_frontend);
1196 budget_av->budget.dvb_frontend->ops.release(budget_av->budget.dvb_frontend);
1197 budget_av->budget.dvb_frontend = NULL; 1050 budget_av->budget.dvb_frontend = NULL;
1198 } 1051 }
1199} 1052}
@@ -1227,8 +1080,10 @@ static int budget_av_detach(struct saa7146_dev *dev)
1227 if (budget_av->budget.ci_present) 1080 if (budget_av->budget.ci_present)
1228 ciintf_deinit(budget_av); 1081 ciintf_deinit(budget_av);
1229 1082
1230 if (budget_av->budget.dvb_frontend != NULL) 1083 if (budget_av->budget.dvb_frontend != NULL) {
1231 dvb_unregister_frontend(budget_av->budget.dvb_frontend); 1084 dvb_unregister_frontend(budget_av->budget.dvb_frontend);
1085 dvb_frontend_detach(budget_av->budget.dvb_frontend);
1086 }
1232 err = ttpci_budget_deinit(&budget_av->budget); 1087 err = ttpci_budget_deinit(&budget_av->budget);
1233 1088
1234 kfree(budget_av); 1089 kfree(budget_av);
@@ -1400,6 +1255,7 @@ static struct pci_device_id pci_tbl[] = {
1400 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010), 1255 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
1401 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010), 1256 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
1402 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011), 1257 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
1258 MAKE_EXTENSION_PCI(knc1sp, 0x1894, 0x0011),
1403 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014), 1259 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
1404 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016), 1260 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
1405 MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e), 1261 MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),