aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorManu Abraham <abraham.manu@gmail.com>2008-10-26 17:28:52 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-29 14:53:24 -0500
commit3f4009255bbcfcf55cf8ca40d70e4cf75e4dc68c (patch)
tree094fd545c4aac0cbca3c5471511a062fd2409ebe /drivers/media/dvb
parent9bb17eee39d862611d2f34d5c611661b3dfd2e54 (diff)
V4L/DVB (9469): Port STB0899 and STB6100
Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/frontends/stb0899_algo.c18
-rw-r--r--drivers/media/dvb/frontends/stb0899_drv.c423
-rw-r--r--drivers/media/dvb/frontends/stb0899_priv.h4
-rw-r--r--drivers/media/dvb/frontends/stb6100.c28
4 files changed, 66 insertions, 407 deletions
diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c
index 750e88c2c8e6..ced9b7ae7d50 100644
--- a/drivers/media/dvb/frontends/stb0899_algo.c
+++ b/drivers/media/dvb/frontends/stb0899_algo.c
@@ -293,7 +293,7 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state)
293 if (stb0899_check_carrier(state) == NOCARRIER) { 293 if (stb0899_check_carrier(state) == NOCARRIER) {
294 index++; 294 index++;
295 last_derot_freq = derot_freq; 295 last_derot_freq = derot_freq;
296 derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */ 296 derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */
297 297
298 if(ABS(derot_freq) > derot_limit) 298 if(ABS(derot_freq) > derot_limit)
299 next_loop--; 299 next_loop--;
@@ -309,11 +309,11 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state)
309 } 309 }
310 } 310 }
311 311
312 internal->direction = -internal->direction; /* Change zigzag direction */ 312 internal->direction = -internal->direction; /* Change zigzag direction */
313 } while ((internal->status != CARRIEROK) && next_loop); 313 } while ((internal->status != CARRIEROK) && next_loop);
314 314
315 if (internal->status == CARRIEROK) { 315 if (internal->status == CARRIEROK) {
316 stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ 316 stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */
317 internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]); 317 internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]);
318 dprintk(state->verbose, FE_DEBUG, 1, "----> CARRIER OK !, Derot Freq=%d", internal->derot_freq); 318 dprintk(state->verbose, FE_DEBUG, 1, "----> CARRIER OK !, Derot Freq=%d", internal->derot_freq);
319 } else { 319 } else {
@@ -396,7 +396,7 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state)
396 do { 396 do {
397 if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) { 397 if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) {
398 398
399 derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ 399 derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */
400 if (ABS(derot_freq) > derot_limit) 400 if (ABS(derot_freq) > derot_limit)
401 next_loop--; 401 next_loop--;
402 402
@@ -414,11 +414,11 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state)
414 index++; 414 index++;
415 } 415 }
416 } 416 }
417 internal->direction = -internal->direction; /* change zig zag direction */ 417 internal->direction = -internal->direction; /* change zig zag direction */
418 } while ((internal->status != DATAOK) && next_loop); 418 } while ((internal->status != DATAOK) && next_loop);
419 419
420 if (internal->status == DATAOK) { 420 if (internal->status == DATAOK) {
421 stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ 421 stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */
422 internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]); 422 internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]);
423 dprintk(state->verbose, FE_DEBUG, 1, "------> DATAOK ! Derot Freq=%d", internal->derot_freq); 423 dprintk(state->verbose, FE_DEBUG, 1, "------> DATAOK ! Derot Freq=%d", internal->derot_freq);
424 } 424 }
@@ -568,12 +568,12 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state)
568 STB0899_SETFIELD_VAL(DEMAPVIT_KDIVIDER, reg, 60); 568 STB0899_SETFIELD_VAL(DEMAPVIT_KDIVIDER, reg, 60);
569 stb0899_write_reg(state, STB0899_DEMAPVIT, reg); 569 stb0899_write_reg(state, STB0899_DEMAPVIT, reg);
570 570
571 stb0899_write_reg(state, STB0899_EQON, 0x01); /* Equalizer OFF while acquiring */ 571 stb0899_write_reg(state, STB0899_EQON, 0x01); /* Equalizer OFF while acquiring */
572 stb0899_write_reg(state, STB0899_VITSYNC, 0x19); 572 stb0899_write_reg(state, STB0899_VITSYNC, 0x19);
573 573
574 stb0899_first_subrange(state); 574 stb0899_first_subrange(state);
575 do { 575 do {
576 /* Initialisations */ 576 /* Initialisations */
577 cfr[0] = cfr[1] = 0; 577 cfr[0] = cfr[1] = 0;
578 stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* RESET derotator frequency */ 578 stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* RESET derotator frequency */
579 579
@@ -588,7 +588,7 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state)
588 /* enable tuner I/O */ 588 /* enable tuner I/O */
589 stb0899_i2c_gate_ctrl(&state->frontend, 1); 589 stb0899_i2c_gate_ctrl(&state->frontend, 1);
590 590
591 /* Move tuner to frequency */ 591 /* Move tuner to frequency */
592 dprintk(state->verbose, FE_DEBUG, 1, "Tuner set frequency"); 592 dprintk(state->verbose, FE_DEBUG, 1, "Tuner set frequency");
593 if (state->config->tuner_set_frequency) 593 if (state->config->tuner_set_frequency)
594 state->config->tuner_set_frequency(&state->frontend, internal->freq); 594 state->config->tuner_set_frequency(&state->frontend, internal->freq);
diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c
index cf787f5fc00c..8a329d6e6e85 100644
--- a/drivers/media/dvb/frontends/stb0899_drv.c
+++ b/drivers/media/dvb/frontends/stb0899_drv.c
@@ -823,16 +823,12 @@ static int stb0899_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t
823static int stb0899_diseqc_init(struct stb0899_state *state) 823static int stb0899_diseqc_init(struct stb0899_state *state)
824{ 824{
825 struct dvb_diseqc_master_cmd tx_data; 825 struct dvb_diseqc_master_cmd tx_data;
826/*
826 struct dvb_diseqc_slave_reply rx_data; 827 struct dvb_diseqc_slave_reply rx_data;
827 828*/
828 u8 f22_tx, f22_rx, reg; 829 u8 f22_tx, f22_rx, reg;
829 830
830 u32 mclk, tx_freq = 22000, count = 0, i; 831 u32 mclk, tx_freq = 22000;/* count = 0, i; */
831
832 u32 trial = 0; /* try max = 2 (try 20khz and 17.5 khz) */
833 u32 ret_1 = 0; /* 20 Khz status */
834 u32 ret_2 = 0; /* 17.5 Khz status */
835
836 tx_data.msg[0] = 0xe2; 832 tx_data.msg[0] = 0xe2;
837 tx_data.msg_len = 3; 833 tx_data.msg_len = 3;
838 reg = stb0899_read_reg(state, STB0899_DISCNTRL2); 834 reg = stb0899_read_reg(state, STB0899_DISCNTRL2);
@@ -860,8 +856,9 @@ static int stb0899_diseqc_init(struct stb0899_state *state)
860static int stb0899_sleep(struct dvb_frontend *fe) 856static int stb0899_sleep(struct dvb_frontend *fe)
861{ 857{
862 struct stb0899_state *state = fe->demodulator_priv; 858 struct stb0899_state *state = fe->demodulator_priv;
859/*
863 u8 reg; 860 u8 reg;
864 861*/
865 dprintk(state->verbose, FE_DEBUG, 1, "Going to Sleep .. (Really tired .. :-))"); 862 dprintk(state->verbose, FE_DEBUG, 1, "Going to Sleep .. (Really tired .. :-))");
866 /* post process event */ 863 /* post process event */
867 stb0899_postproc(state, STB0899_POSTPROC_GPIO_POWER, 0); 864 stb0899_postproc(state, STB0899_POSTPROC_GPIO_POWER, 0);
@@ -895,7 +892,6 @@ static int stb0899_init(struct dvb_frontend *fe)
895 struct stb0899_config *config = state->config; 892 struct stb0899_config *config = state->config;
896 893
897 dprintk(state->verbose, FE_DEBUG, 1, "Initializing STB0899 ... "); 894 dprintk(state->verbose, FE_DEBUG, 1, "Initializing STB0899 ... ");
898// mutex_init(&state->search_lock);
899 895
900 /* init device */ 896 /* init device */
901 dprintk(state->verbose, FE_DEBUG, 1, "init device"); 897 dprintk(state->verbose, FE_DEBUG, 1, "init device");
@@ -968,8 +964,8 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
968 int val; 964 int val;
969 u32 reg; 965 u32 reg;
970 switch (state->delsys) { 966 switch (state->delsys) {
971 case DVBFE_DELSYS_DVBS: 967 case SYS_DVBS:
972 case DVBFE_DELSYS_DSS: 968 case SYS_DSS:
973 if (internal->lock) { 969 if (internal->lock) {
974 reg = stb0899_read_reg(state, STB0899_VSTATUS); 970 reg = stb0899_read_reg(state, STB0899_VSTATUS);
975 if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) { 971 if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) {
@@ -984,7 +980,7 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
984 } 980 }
985 } 981 }
986 break; 982 break;
987 case DVBFE_DELSYS_DVBS2: 983 case SYS_DVBS2:
988 if (internal->lock) { 984 if (internal->lock) {
989 reg = STB0899_READ_S2REG(STB0899_DEMOD, IF_AGC_GAIN); 985 reg = STB0899_READ_S2REG(STB0899_DEMOD, IF_AGC_GAIN);
990 val = STB0899_GETFIELD(IF_AGC_GAIN, reg); 986 val = STB0899_GETFIELD(IF_AGC_GAIN, reg);
@@ -1014,8 +1010,8 @@ static int stb0899_read_snr(struct dvb_frontend *fe, u16 *snr)
1014 1010
1015 reg = stb0899_read_reg(state, STB0899_VSTATUS); 1011 reg = stb0899_read_reg(state, STB0899_VSTATUS);
1016 switch (state->delsys) { 1012 switch (state->delsys) {
1017 case DVBFE_DELSYS_DVBS: 1013 case SYS_DVBS:
1018 case DVBFE_DELSYS_DSS: 1014 case SYS_DSS:
1019 if (internal->lock) { 1015 if (internal->lock) {
1020 if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) { 1016 if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) {
1021 1017
@@ -1028,7 +1024,7 @@ static int stb0899_read_snr(struct dvb_frontend *fe, u16 *snr)
1028 } 1024 }
1029 } 1025 }
1030 break; 1026 break;
1031 case DVBFE_DELSYS_DVBS2: 1027 case SYS_DVBS2:
1032 if (internal->lock) { 1028 if (internal->lock) {
1033 reg = STB0899_READ_S2REG(STB0899_S2DEMOD, UWP_CNTRL1); 1029 reg = STB0899_READ_S2REG(STB0899_S2DEMOD, UWP_CNTRL1);
1034 quant = STB0899_GETFIELD(UWP_ESN0_QUANT, reg); 1030 quant = STB0899_GETFIELD(UWP_ESN0_QUANT, reg);
@@ -1067,8 +1063,8 @@ static int stb0899_read_status(struct dvb_frontend *fe, enum fe_status *status)
1067 *status = 0; 1063 *status = 0;
1068 1064
1069 switch (state->delsys) { 1065 switch (state->delsys) {
1070 case DVBFE_DELSYS_DVBS: 1066 case SYS_DVBS:
1071 case DVBFE_DELSYS_DSS: 1067 case SYS_DSS:
1072 dprintk(state->verbose, FE_DEBUG, 1, "Delivery system DVB-S/DSS"); 1068 dprintk(state->verbose, FE_DEBUG, 1, "Delivery system DVB-S/DSS");
1073 if (internal->lock) { 1069 if (internal->lock) {
1074 reg = stb0899_read_reg(state, STB0899_VSTATUS); 1070 reg = stb0899_read_reg(state, STB0899_VSTATUS);
@@ -1086,7 +1082,7 @@ static int stb0899_read_status(struct dvb_frontend *fe, enum fe_status *status)
1086 } 1082 }
1087 } 1083 }
1088 break; 1084 break;
1089 case DVBFE_DELSYS_DVBS2: 1085 case SYS_DVBS2:
1090 dprintk(state->verbose, FE_DEBUG, 1, "Delivery system DVB-S2"); 1086 dprintk(state->verbose, FE_DEBUG, 1, "Delivery system DVB-S2");
1091 if (internal->lock) { 1087 if (internal->lock) {
1092 reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STAT2); 1088 reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STAT2);
@@ -1141,8 +1137,8 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber)
1141 *ber = 0; 1137 *ber = 0;
1142 1138
1143 switch (state->delsys) { 1139 switch (state->delsys) {
1144 case DVBFE_DELSYS_DVBS: 1140 case SYS_DVBS:
1145 case DVBFE_DELSYS_DSS: 1141 case SYS_DSS:
1146 if (internal->lock) { 1142 if (internal->lock) {
1147 /* average 5 BER values */ 1143 /* average 5 BER values */
1148 for (i = 0; i < 5; i++) { 1144 for (i = 0; i < 5; i++) {
@@ -1162,7 +1158,7 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber)
1162 } 1158 }
1163 } 1159 }
1164 break; 1160 break;
1165 case DVBFE_DELSYS_DVBS2: 1161 case SYS_DVBS2:
1166 if (internal->lock) { 1162 if (internal->lock) {
1167 /* Average 5 PER values */ 1163 /* Average 5 PER values */
1168 for (i = 0; i < 5; i++) { 1164 for (i = 0; i < 5; i++) {
@@ -1309,97 +1305,6 @@ int stb0899_get_dev_id(struct stb0899_state *state)
1309 return 0; 1305 return 0;
1310} 1306}
1311 1307
1312static const struct dvbfe_info dvbs_info = {
1313 .name = "STB0899 DVB-S",
1314 .delsys = {
1315 .dvbs.modulation = DVBFE_MOD_QPSK,
1316 .dvbs.fec = DVBFE_FEC_1_2 | DVBFE_FEC_2_3 |
1317 DVBFE_FEC_3_4 | DVBFE_FEC_5_6 |
1318 DVBFE_FEC_6_7
1319 },
1320
1321 .frequency_min = 950000,
1322 .frequency_max = 2150000,
1323 .frequency_step = 0,
1324 .symbol_rate_min = 1000000,
1325 .symbol_rate_max = 45000000,
1326 .symbol_rate_tolerance = 0
1327};
1328
1329static const struct dvbfe_info dss_info = {
1330 .name = "STB0899 DSS",
1331 .delsys = {
1332 .dss.modulation = DVBFE_MOD_BPSK | DVBFE_MOD_QPSK,
1333 .dss.fec = DVBFE_FEC_1_2 | DVBFE_FEC_2_3 |
1334 DVBFE_FEC_3_4 | DVBFE_FEC_5_6 |
1335 DVBFE_FEC_6_7
1336 },
1337
1338 .frequency_min = 950000,
1339 .frequency_max = 2150000,
1340 .frequency_step = 0,
1341 .symbol_rate_min = 1000000,
1342 .symbol_rate_max = 45000000,
1343 .symbol_rate_tolerance = 0
1344};
1345
1346static const struct dvbfe_info dvbs2_info = {
1347 .name = "STB0899 DVB-S2",
1348 .delsys = {
1349 .dvbs2.modulation = DVBFE_MOD_QPSK | DVBFE_MOD_8PSK |
1350 DVBFE_MOD_16APSK | DVBFE_MOD_32APSK,
1351
1352 .dvbs2.fec = DVBFE_FEC_1_4 | DVBFE_FEC_1_3 |
1353 DVBFE_FEC_2_5 | DVBFE_FEC_1_2 |
1354 DVBFE_FEC_3_5 | DVBFE_FEC_2_3 |
1355 DVBFE_FEC_3_4 | DVBFE_FEC_4_5 |
1356 DVBFE_FEC_5_6 | DVBFE_FEC_8_9 |
1357 DVBFE_FEC_9_10,
1358 },
1359
1360 .frequency_min = 950000,
1361 .frequency_max = 2150000,
1362 .frequency_step = 0,
1363 .symbol_rate_min = 1000000,
1364 .symbol_rate_max = 45000000,
1365 .symbol_rate_tolerance = 0
1366};
1367
1368static int stb0899_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
1369{
1370 struct stb0899_state *state = fe->demodulator_priv;
1371
1372 dprintk(state->verbose, FE_DEBUG, 1, "Get Info");
1373
1374 switch (state->delsys) {
1375 case DVBFE_DELSYS_DVBS:
1376 dprintk(state->verbose, FE_ERROR, 1, "Querying DVB-S info");
1377 memcpy(fe_info, &dvbs_info, sizeof (struct dvbfe_info));
1378 break;
1379 case DVBFE_DELSYS_DSS:
1380 dprintk(state->verbose, FE_ERROR, 1, "Querying DSS info");
1381 memcpy(fe_info, &dss_info, sizeof (struct dvbfe_info));
1382 break;
1383 case DVBFE_DELSYS_DVBS2:
1384 dprintk(state->verbose, FE_ERROR, 1, "Querying DVB-S2 info");
1385 memcpy(fe_info, &dvbs2_info, sizeof (struct dvbfe_info));
1386 break;
1387 default:
1388 dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system");
1389 return -EINVAL;
1390 }
1391 dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys);
1392
1393 return 0;
1394}
1395
1396static int stb0899_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
1397{
1398 *fe_delsys = DVBFE_DELSYS_DVBS | DVBFE_DELSYS_DSS | DVBFE_DELSYS_DVBS2;
1399
1400 return 0;
1401}
1402
1403static void stb0899_set_delivery(struct stb0899_state *state) 1308static void stb0899_set_delivery(struct stb0899_state *state)
1404{ 1309{
1405 u8 reg; 1310 u8 reg;
@@ -1409,7 +1314,7 @@ static void stb0899_set_delivery(struct stb0899_state *state)
1409 stop_clk[1] = stb0899_read_reg(state, STB0899_STOPCLK2); 1314 stop_clk[1] = stb0899_read_reg(state, STB0899_STOPCLK2);
1410 1315
1411 switch (state->delsys) { 1316 switch (state->delsys) {
1412 case DVBFE_DELSYS_DVBS: 1317 case SYS_DVBS:
1413 dprintk(state->verbose, FE_DEBUG, 1, "Delivery System -- DVB-S"); 1318 dprintk(state->verbose, FE_DEBUG, 1, "Delivery System -- DVB-S");
1414 /* FECM/Viterbi ON */ 1319 /* FECM/Viterbi ON */
1415 reg = stb0899_read_reg(state, STB0899_FECM); 1320 reg = stb0899_read_reg(state, STB0899_FECM);
@@ -1438,7 +1343,7 @@ static void stb0899_set_delivery(struct stb0899_state *state)
1438 1343
1439 STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 1); 1344 STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 1);
1440 break; 1345 break;
1441 case DVBFE_DELSYS_DVBS2: 1346 case SYS_DVBS2:
1442 /* FECM/Viterbi OFF */ 1347 /* FECM/Viterbi OFF */
1443 reg = stb0899_read_reg(state, STB0899_FECM); 1348 reg = stb0899_read_reg(state, STB0899_FECM);
1444 STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 0); 1349 STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 0);
@@ -1466,7 +1371,7 @@ static void stb0899_set_delivery(struct stb0899_state *state)
1466 1371
1467 STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 0); 1372 STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 0);
1468 break; 1373 break;
1469 case DVBFE_DELSYS_DSS: 1374 case SYS_DSS:
1470 /* FECM/Viterbi ON */ 1375 /* FECM/Viterbi ON */
1471 reg = stb0899_read_reg(state, STB0899_FECM); 1376 reg = stb0899_read_reg(state, STB0899_FECM);
1472 STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 1); 1377 STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 1);
@@ -1525,33 +1430,19 @@ static void stb0899_set_iterations(struct stb0899_state *state)
1525 stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_MAX_ITER, STB0899_OFF0_MAX_ITER, reg); 1430 stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_MAX_ITER, STB0899_OFF0_MAX_ITER, reg);
1526} 1431}
1527 1432
1528static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_params *params) 1433static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
1529{ 1434{
1530 struct stb0899_state *state = fe->demodulator_priv; 1435 struct stb0899_state *state = fe->demodulator_priv;
1531 struct stb0899_params *i_params = &state->params; 1436 struct stb0899_params *i_params = &state->params;
1532 struct stb0899_internal *internal = &state->internal; 1437 struct stb0899_internal *internal = &state->internal;
1533 struct stb0899_config *config = state->config; 1438 struct stb0899_config *config = state->config;
1439 struct dtv_frontend_properties *props = &fe->dtv_property_cache;
1534 1440
1535 u32 SearchRange, gain; 1441 u32 SearchRange, gain;
1536 1442
1537 i_params->freq = params->frequency; 1443 i_params->freq = p->frequency;
1538 switch (state->delsys) { 1444 i_params->srate = p->u.qpsk.symbol_rate;
1539 case DVBFE_DELSYS_DVBS: 1445 state->delsys = props->delivery_system;
1540 dprintk(state->verbose, FE_ERROR, 1, "set DVB-S params");
1541 i_params->srate = params->delsys.dvbs.symbol_rate;
1542 break;
1543 case DVBFE_DELSYS_DSS:
1544 dprintk(state->verbose, FE_ERROR, 1, "set DSS params");
1545 i_params->srate = params->delsys.dss.symbol_rate;
1546 break;
1547 case DVBFE_DELSYS_DVBS2:
1548 dprintk(state->verbose, FE_ERROR, 1, "set DVB-S2 params");
1549 i_params->srate = params->delsys.dvbs2.symbol_rate;
1550 break;
1551 default:
1552 dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system");
1553 return -EINVAL;
1554 }
1555 dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys); 1446 dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys);
1556 1447
1557 SearchRange = 10000000; 1448 SearchRange = 10000000;
@@ -1563,11 +1454,11 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa
1563 1454
1564 if (state->config->tuner_set_rfsiggain) { 1455 if (state->config->tuner_set_rfsiggain) {
1565 if (internal->srate > 15000000) 1456 if (internal->srate > 15000000)
1566 gain = 8; /* 15Mb < srate < 45Mb, gain = 8dB */ 1457 gain = 8; /* 15Mb < srate < 45Mb, gain = 8dB */
1567 else if (internal->srate > 5000000) 1458 else if (internal->srate > 5000000)
1568 gain = 12; /* 5Mb < srate < 15Mb, gain = 12dB */ 1459 gain = 12; /* 5Mb < srate < 15Mb, gain = 12dB */
1569 else 1460 else
1570 gain = 14; /* 1Mb < srate < 5Mb, gain = 14db */ 1461 gain = 14; /* 1Mb < srate < 5Mb, gain = 14db */
1571 state->config->tuner_set_rfsiggain(fe, gain); 1462 state->config->tuner_set_rfsiggain(fe, gain);
1572 } 1463 }
1573 1464
@@ -1577,8 +1468,8 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa
1577 stb0899_set_mclk(state, config->hi_clk); 1468 stb0899_set_mclk(state, config->hi_clk);
1578 1469
1579 switch (state->delsys) { 1470 switch (state->delsys) {
1580 case DVBFE_DELSYS_DVBS: 1471 case SYS_DVBS:
1581 case DVBFE_DELSYS_DSS: 1472 case SYS_DSS:
1582 dprintk(state->verbose, FE_DEBUG, 1, "DVB-S delivery system"); 1473 dprintk(state->verbose, FE_DEBUG, 1, "DVB-S delivery system");
1583 internal->freq = i_params->freq; 1474 internal->freq = i_params->freq;
1584 internal->srate = i_params->srate; 1475 internal->srate = i_params->srate;
@@ -1626,7 +1517,7 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa
1626 return DVBFE_ALGO_SEARCH_FAILED; 1517 return DVBFE_ALGO_SEARCH_FAILED;
1627 } 1518 }
1628 break; 1519 break;
1629 case DVBFE_DELSYS_DVBS2: 1520 case SYS_DVBS2:
1630 internal->freq = i_params->freq; 1521 internal->freq = i_params->freq;
1631 internal->srate = i_params->srate; 1522 internal->srate = i_params->srate;
1632 internal->srch_range = SearchRange; 1523 internal->srch_range = SearchRange;
@@ -1676,195 +1567,6 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa
1676 1567
1677 return DVBFE_ALGO_SEARCH_ERROR; 1568 return DVBFE_ALGO_SEARCH_ERROR;
1678} 1569}
1679
1680static enum stb0899_status stb0899_track_carrier(struct stb0899_state *state)
1681{
1682 u8 reg;
1683
1684 reg = stb0899_read_reg(state, STB0899_DSTATUS);
1685 dprintk(state->verbose, FE_DEBUG, 1, "--------------------> STB0899_DSTATUS=[0x%02x]", reg);
1686 if (STB0899_GETFIELD(CARRIER_FOUND, reg)) {
1687 dprintk(state->verbose, FE_DEBUG, 1, "-------------> CARRIEROK !");
1688 return CARRIEROK;
1689 } else {
1690 dprintk(state->verbose, FE_DEBUG, 1, "-------------> NOCARRIER !");
1691 return NOCARRIER;
1692 }
1693
1694 return NOCARRIER;
1695}
1696
1697static enum stb0899_status stb0899_get_ifagc(struct stb0899_state *state)
1698{
1699 u8 reg;
1700
1701 reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STATUS);
1702 dprintk(state->verbose, FE_DEBUG, 1, "DMD_STATUS=[0x%02x]", reg);
1703 if (STB0899_GETFIELD(IF_AGC_LOCK, reg)) {
1704 dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCKED !");
1705 return AGC1OK;
1706 } else {
1707 dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCK LOST !");
1708 return NOAGC1;
1709 }
1710
1711 return NOAGC1;
1712}
1713
1714static int stb0899_get_s1fec(struct stb0899_internal *internal, enum dvbfe_fec *fec)
1715{
1716 switch (internal->fecrate) {
1717 case STB0899_FEC_1_2:
1718 *fec = DVBFE_FEC_1_2;
1719 break;
1720 case STB0899_FEC_2_3:
1721 *fec = DVBFE_FEC_2_3;
1722 break;
1723 case STB0899_FEC_3_4:
1724 *fec = DVBFE_FEC_3_4;
1725 break;
1726 case STB0899_FEC_5_6:
1727 *fec = DVBFE_FEC_5_6;
1728 break;
1729 case STB0899_FEC_6_7:
1730 *fec = DVBFE_FEC_6_7;
1731 break;
1732 case STB0899_FEC_7_8:
1733 *fec = DVBFE_FEC_7_8;
1734 break;
1735 default:
1736 return -EINVAL;
1737 }
1738
1739 return 0;
1740}
1741
1742static int stb0899_get_modcod(struct stb0899_internal *internal, struct dvbs2_params *params)
1743{
1744 switch (internal->modcod) {
1745 case STB0899_DUMMY_PLF:
1746 params->modulation = DVBFE_MOD_NONE;
1747 params->fec = DVBFE_FEC_NONE;
1748 break;
1749 case STB0899_QPSK_14:
1750 params->modulation = DVBFE_MOD_QPSK;
1751 params->fec = DVBFE_FEC_1_4;
1752 break;
1753 case STB0899_QPSK_13:
1754 params->modulation = DVBFE_MOD_QPSK;
1755 params->fec = DVBFE_FEC_1_3;
1756 break;
1757 case STB0899_QPSK_25:
1758 params->modulation = DVBFE_MOD_QPSK;
1759 params->fec = DVBFE_FEC_2_5;
1760 break;
1761 case STB0899_QPSK_12:
1762 params->modulation = DVBFE_MOD_QPSK;
1763 params->fec = DVBFE_FEC_1_2;
1764 break;
1765 case STB0899_QPSK_35:
1766 params->modulation = DVBFE_MOD_QPSK;
1767 params->fec = DVBFE_FEC_3_5;
1768 break;
1769 case STB0899_QPSK_23:
1770 params->modulation = DVBFE_MOD_QPSK;
1771 params->fec = DVBFE_FEC_2_3;
1772 break;
1773 case STB0899_QPSK_34:
1774 params->modulation = DVBFE_MOD_QPSK;
1775 params->fec = DVBFE_FEC_3_4;
1776 break;
1777 case STB0899_QPSK_45:
1778 params->modulation = DVBFE_MOD_QPSK;
1779 params->fec = DVBFE_FEC_4_5;
1780 break;
1781 case STB0899_QPSK_56:
1782 params->modulation = DVBFE_MOD_QPSK;
1783 params->fec = DVBFE_FEC_5_6;
1784 break;
1785 case STB0899_QPSK_89:
1786 params->modulation = DVBFE_MOD_QPSK;
1787 params->fec = DVBFE_FEC_8_9;
1788 break;
1789 case STB0899_QPSK_910:
1790 params->modulation = DVBFE_MOD_QPSK;
1791 params->fec = DVBFE_FEC_9_10;
1792 break;
1793 case STB0899_8PSK_35:
1794 params->modulation = DVBFE_MOD_8PSK;
1795 params->fec = DVBFE_FEC_3_5;
1796 break;
1797 case STB0899_8PSK_23:
1798 params->modulation = DVBFE_MOD_8PSK;
1799 params->fec = DVBFE_FEC_2_3;
1800 break;
1801 case STB0899_8PSK_34:
1802 params->modulation = DVBFE_MOD_8PSK;
1803 params->fec = DVBFE_FEC_3_4;
1804 break;
1805 case STB0899_8PSK_56:
1806 params->modulation = DVBFE_MOD_8PSK;
1807 params->fec = DVBFE_FEC_5_6;
1808 break;
1809 case STB0899_8PSK_89:
1810 params->modulation = DVBFE_MOD_8PSK;
1811 params->fec = DVBFE_FEC_8_9;
1812 break;
1813 case STB0899_8PSK_910:
1814 params->modulation = DVBFE_MOD_8PSK;
1815 params->fec = DVBFE_FEC_9_10;
1816 break;
1817 case STB0899_16APSK_23:
1818 params->modulation = DVBFE_MOD_16APSK;
1819 params->fec = DVBFE_FEC_2_3;
1820 break;
1821 case STB0899_16APSK_34:
1822 params->modulation = DVBFE_MOD_16APSK;
1823 params->fec = DVBFE_FEC_3_4;
1824 break;
1825 case STB0899_16APSK_45:
1826 params->modulation = DVBFE_MOD_16APSK;
1827 params->fec = DVBFE_FEC_4_5;
1828 break;
1829 case STB0899_16APSK_56:
1830 params->modulation = DVBFE_MOD_16APSK;
1831 params->fec = DVBFE_FEC_5_6;
1832 break;
1833 case STB0899_16APSK_89:
1834 params->modulation = DVBFE_MOD_16APSK;
1835 params->fec = DVBFE_FEC_8_9;
1836 break;
1837 case STB0899_16APSK_910:
1838 params->modulation = DVBFE_MOD_16APSK;
1839 params->fec = DVBFE_FEC_9_10;
1840 break;
1841 case STB0899_32APSK_34:
1842 params->modulation = DVBFE_MOD_32APSK;
1843 params->fec = DVBFE_FEC_3_4;
1844 break;
1845 case STB0899_32APSK_45:
1846 params->modulation = DVBFE_MOD_32APSK;
1847 params->fec = DVBFE_FEC_4_5;
1848 break;
1849 case STB0899_32APSK_56:
1850 params->modulation = DVBFE_MOD_32APSK;
1851 params->fec = DVBFE_FEC_5_6;
1852 break;
1853 case STB0899_32APSK_89:
1854 params->modulation = DVBFE_MOD_32APSK;
1855 params->fec = DVBFE_FEC_8_9;
1856 break;
1857 case STB0899_32APSK_910:
1858 params->modulation = DVBFE_MOD_32APSK;
1859 params->fec = DVBFE_FEC_9_10;
1860 break;
1861 default:
1862 return -EINVAL;
1863 }
1864
1865 return 0;
1866}
1867
1868/* 1570/*
1869 * stb0899_track 1571 * stb0899_track
1870 * periodically check the signal level against a specified 1572 * periodically check the signal level against a specified
@@ -1881,46 +1583,18 @@ static int stb0899_get_modcod(struct stb0899_internal *internal, struct dvbs2_pa
1881 * Once a new lock has established, the internal state 1583 * Once a new lock has established, the internal state
1882 * frequency (internal->freq) is updated 1584 * frequency (internal->freq) is updated
1883 */ 1585 */
1884static int stb0899_track(struct dvb_frontend *fe, struct dvbfe_params *params, int *delay) 1586static int stb0899_track(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
1885{ 1587{
1886 u32 lock_lost;
1887
1888 struct stb0899_state *state = fe->demodulator_priv;
1889 struct stb0899_internal *internal = &state->internal;
1890
1891
1892 *delay = HZ/10;
1893
1894 return 0; 1588 return 0;
1895} 1589}
1896 1590
1897static int stb0899_get_params(struct dvb_frontend *fe, struct dvbfe_params *params) 1591static int stb0899_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
1898{ 1592{
1899 struct stb0899_state *state = fe->demodulator_priv; 1593 struct stb0899_state *state = fe->demodulator_priv;
1900 struct stb0899_internal *internal = &state->internal; 1594 struct stb0899_internal *internal = &state->internal;
1901 1595
1902 params->frequency = internal->freq; 1596 dprintk(state->verbose, FE_DEBUG, 1, "Get params");
1903 params->inversion = internal->inversion; 1597 p->u.qpsk.symbol_rate = internal->srate;
1904 params->delivery = state->delsys;
1905 switch (state->delsys) {
1906 case DVBFE_DELSYS_DVBS:
1907 dprintk(state->verbose, FE_DEBUG, 1, "Get DVB-S params");
1908 params->delsys.dvbs.symbol_rate = internal->srate;
1909 params->delsys.dvbs.modulation = DVBFE_MOD_QPSK;
1910 break;
1911 case DVBFE_DELSYS_DSS:
1912 dprintk(state->verbose, FE_DEBUG, 1, "Get DSS params");
1913 params->delsys.dss.symbol_rate = internal->srate;
1914 params->delsys.dss.modulation = DVBFE_MOD_QPSK;
1915 break;
1916 case DVBFE_DELSYS_DVBS2:
1917 dprintk(state->verbose, FE_DEBUG, 1, "Get DVB-S2 params");
1918 params->delsys.dvbs2.symbol_rate = internal->srate;
1919 break;
1920 default:
1921 dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system");
1922 return -EINVAL;
1923 }
1924 1598
1925 return 0; 1599 return 0;
1926} 1600}
@@ -1930,18 +1604,21 @@ static enum dvbfe_algo stb0899_frontend_algo(struct dvb_frontend *fe)
1930 return DVBFE_ALGO_CUSTOM; 1604 return DVBFE_ALGO_CUSTOM;
1931} 1605}
1932 1606
1933static int stb0899_set_delsys(struct dvb_frontend *fe, enum dvbfe_delsys delsys)
1934{
1935 struct stb0899_state *state = fe->demodulator_priv;
1936
1937 state->delsys = delsys;
1938 return 0;
1939}
1940
1941static struct dvb_frontend_ops stb0899_ops = { 1607static struct dvb_frontend_ops stb0899_ops = {
1942 1608
1943 .info = { 1609 .info = {
1944 .name = "STB0899 Multistandard", 1610 .name = "STB0899 Multistandard",
1611 .type = FE_QPSK,
1612 .frequency_min = 950000,
1613 .frequency_max = 2150000,
1614 .frequency_stepsize = 0,
1615 .frequency_tolerance = 0,
1616 .symbol_rate_min = 5000000,
1617 .symbol_rate_max = 45000000,
1618
1619 .caps = FE_CAN_INVERSION_AUTO |
1620 FE_CAN_FEC_AUTO |
1621 FE_CAN_QPSK
1945 }, 1622 },
1946 1623
1947 .release = stb0899_release, 1624 .release = stb0899_release,
@@ -1950,14 +1627,12 @@ static struct dvb_frontend_ops stb0899_ops = {
1950// .wakeup = stb0899_wakeup, 1627// .wakeup = stb0899_wakeup,
1951 1628
1952 .i2c_gate_ctrl = stb0899_i2c_gate_ctrl, 1629 .i2c_gate_ctrl = stb0899_i2c_gate_ctrl,
1953 .get_info = stb0899_get_info,
1954 .get_delsys = stb0899_get_delsys,
1955 .set_delsys = stb0899_set_delsys,
1956 1630
1957 .get_frontend_algo = stb0899_frontend_algo, 1631 .get_frontend_algo = stb0899_frontend_algo,
1958 .search = stb0899_search, 1632 .search = stb0899_search,
1959 .track = stb0899_track, 1633 .track = stb0899_track,
1960 .get_params = stb0899_get_params, 1634 .get_frontend = stb0899_get_frontend,
1635
1961 1636
1962 .read_status = stb0899_read_status, 1637 .read_status = stb0899_read_status,
1963 .read_snr = stb0899_read_snr, 1638 .read_snr = stb0899_read_snr,
diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h
index 2e845c930063..24619e3689db 100644
--- a/drivers/media/dvb/frontends/stb0899_priv.h
+++ b/drivers/media/dvb/frontends/stb0899_priv.h
@@ -160,7 +160,7 @@ enum stb0899_fec {
160struct stb0899_params { 160struct stb0899_params {
161 u32 freq; /* Frequency */ 161 u32 freq; /* Frequency */
162 u32 srate; /* Symbol rate */ 162 u32 srate; /* Symbol rate */
163 enum dvbfe_fec fecrate; 163 enum fe_code_rate fecrate;
164}; 164};
165 165
166struct stb0899_internal { 166struct stb0899_internal {
@@ -220,7 +220,7 @@ struct stb0899_state {
220 struct stb0899_internal internal; /* Device internal parameters */ 220 struct stb0899_internal internal; /* Device internal parameters */
221 221
222 /* cached params from API */ 222 /* cached params from API */
223 enum dvbfe_delsys delsys; 223 enum fe_delivery_system delsys;
224 struct stb0899_params params; 224 struct stb0899_params params;
225 225
226 u32 rx_freq; /* DiSEqC 2.0 receiver freq */ 226 u32 rx_freq; /* DiSEqC 2.0 receiver freq */
diff --git a/drivers/media/dvb/frontends/stb6100.c b/drivers/media/dvb/frontends/stb6100.c
index 083d6b627189..19a9e5fb9705 100644
--- a/drivers/media/dvb/frontends/stb6100.c
+++ b/drivers/media/dvb/frontends/stb6100.c
@@ -305,7 +305,7 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
305 int rc; 305 int rc;
306 const struct stb6100_lkup *ptr; 306 const struct stb6100_lkup *ptr;
307 struct stb6100_state *state = fe->tuner_priv; 307 struct stb6100_state *state = fe->tuner_priv;
308 struct dvbfe_params params; 308 struct dvb_frontend_parameters p;
309 309
310 u32 srate = 0, fvco, nint, nfrac; 310 u32 srate = 0, fvco, nint, nfrac;
311 u8 regs[STB6100_NUMREGS]; 311 u8 regs[STB6100_NUMREGS];
@@ -313,28 +313,12 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
313 313
314 if ((rc = stb6100_read_regs(state, regs)) < 0) 314 if ((rc = stb6100_read_regs(state, regs)) < 0)
315 return rc; 315 return rc;
316 if (fe->ops.get_params) { 316
317 dprintk(verbose, FE_DEBUG, 1, "Get Frontend parameters"); 317 if (fe->ops.get_frontend) {
318 fe->ops.get_params(fe, &params); 318 dprintk(verbose, FE_DEBUG, 1, "Get frontend parameters");
319 } 319 fe->ops.get_frontend(fe, &p);
320 switch (params.delivery) {
321 case DVBFE_DELSYS_DVBS:
322 srate = params.delsys.dvbs.symbol_rate;
323 dprintk(verbose, FE_DEBUG, 1, "Delivery system = DVB-S, Symbol Rate=[%d]", srate);
324 break;
325 case DVBFE_DELSYS_DSS:
326 dprintk(verbose, FE_DEBUG, 1, "Delivery system = DSS, Symbol Rate=[%d]", srate);
327 srate = params.delsys.dss.symbol_rate;
328 break;
329 case DVBFE_DELSYS_DVBS2:
330 dprintk(verbose, FE_DEBUG, 1, "Delivery system = DVB-S2, Symbol Rate=[%d]", srate);
331 srate = params.delsys.dvbs2.symbol_rate;
332 break;
333 default:
334 dprintk(verbose, FE_NOTICE, 1, "symbol rate unknown!");
335 srate = 22000000; /* just a typical default value */
336 break;
337 } 320 }
321 srate = p.u.qpsk.symbol_rate;
338 322
339 /* Baseband gain. */ 323 /* Baseband gain. */
340 if (srate >= 15000000) 324 if (srate >= 15000000)