aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends
diff options
context:
space:
mode:
authorIgor M. Liplianin <liplianin@me.by>2009-12-14 18:24:56 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-02-26 13:10:24 -0500
commitcd79d33e168dba0d7de32c5bf010e20cff184b2a (patch)
treea9e40f6281e62f27fc7d36e885416b5fef696c46 /drivers/media/dvb/frontends
parentd41592a2a2b9a27425ade3fc2c8526e9e997acd6 (diff)
V4L/DVB (13818): Add Prof 7500 DVB-S2 USB card
The card based on stv0903 demod, stb6100 tuner. Signed-off-by: Igor M. Liplianin <liplianin@me.by> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r--drivers/media/dvb/frontends/stv0900.h2
-rw-r--r--drivers/media/dvb/frontends/stv0900_core.c87
-rw-r--r--drivers/media/dvb/frontends/stv0900_priv.h11
-rw-r--r--drivers/media/dvb/frontends/stv0900_reg.h6
-rw-r--r--drivers/media/dvb/frontends/stv0900_sw.c44
5 files changed, 142 insertions, 8 deletions
diff --git a/drivers/media/dvb/frontends/stv0900.h b/drivers/media/dvb/frontends/stv0900.h
index 29c3fa85c227..e3e35d1ce838 100644
--- a/drivers/media/dvb/frontends/stv0900.h
+++ b/drivers/media/dvb/frontends/stv0900.h
@@ -49,6 +49,8 @@ struct stv0900_config {
49 u8 tun2_maddress; 49 u8 tun2_maddress;
50 u8 tun1_adc;/* 1 for stv6110, 2 for stb6100 */ 50 u8 tun1_adc;/* 1 for stv6110, 2 for stb6100 */
51 u8 tun2_adc; 51 u8 tun2_adc;
52 u8 tun1_type;/* for now 3 for stb6100 auto, else - software */
53 u8 tun2_type;
52 /* Set device param to start dma */ 54 /* Set device param to start dma */
53 int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); 55 int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured);
54}; 56};
diff --git a/drivers/media/dvb/frontends/stv0900_core.c b/drivers/media/dvb/frontends/stv0900_core.c
index 8762c86044a5..115dc01c2234 100644
--- a/drivers/media/dvb/frontends/stv0900_core.c
+++ b/drivers/media/dvb/frontends/stv0900_core.c
@@ -567,6 +567,46 @@ void stv0900_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)
567 } 567 }
568} 568}
569 569
570u32 stv0900_get_freq_auto(struct stv0900_internal *intp, int demod)
571{
572 u32 freq, round;
573 /* Formulat :
574 Tuner_Frequency(MHz) = Regs / 64
575 Tuner_granularity(MHz) = Regs / 2048
576 real_Tuner_Frequency = Tuner_Frequency(MHz) - Tuner_granularity(MHz)
577 */
578 freq = (stv0900_get_bits(intp, TUN_RFFREQ2) << 10) +
579 (stv0900_get_bits(intp, TUN_RFFREQ1) << 2) +
580 stv0900_get_bits(intp, TUN_RFFREQ0);
581
582 freq = (freq * 1000) / 64;
583
584 round = (stv0900_get_bits(intp, TUN_RFRESTE1) >> 2) +
585 stv0900_get_bits(intp, TUN_RFRESTE0);
586
587 round = (round * 1000) / 2048;
588
589 return freq + round;
590}
591
592void stv0900_set_tuner_auto(struct stv0900_internal *intp, u32 Frequency,
593 u32 Bandwidth, int demod)
594{
595 u32 tunerFrequency;
596 /* Formulat:
597 Tuner_frequency_reg= Frequency(MHz)*64
598 */
599 tunerFrequency = (Frequency * 64) / 1000;
600
601 stv0900_write_bits(intp, TUN_RFFREQ2, (tunerFrequency >> 10));
602 stv0900_write_bits(intp, TUN_RFFREQ1, (tunerFrequency >> 2) & 0xff);
603 stv0900_write_bits(intp, TUN_RFFREQ0, (tunerFrequency & 0x03));
604 /* Low Pass Filter = BW /2 (MHz)*/
605 stv0900_write_bits(intp, TUN_BW, Bandwidth / 2000000);
606 /* Tuner Write trig */
607 stv0900_write_reg(intp, TNRLD, 1);
608}
609
570static s32 stv0900_get_rf_level(struct stv0900_internal *intp, 610static s32 stv0900_get_rf_level(struct stv0900_internal *intp,
571 const struct stv0900_table *lookup, 611 const struct stv0900_table *lookup,
572 enum fe_stv0900_demod_num demod) 612 enum fe_stv0900_demod_num demod)
@@ -1329,7 +1369,6 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
1329 enum fe_stv0900_error error = STV0900_NO_ERROR; 1369 enum fe_stv0900_error error = STV0900_NO_ERROR;
1330 enum fe_stv0900_error demodError = STV0900_NO_ERROR; 1370 enum fe_stv0900_error demodError = STV0900_NO_ERROR;
1331 struct stv0900_internal *intp = NULL; 1371 struct stv0900_internal *intp = NULL;
1332
1333 int selosci, i; 1372 int selosci, i;
1334 1373
1335 struct stv0900_inode *temp_int = find_inode(state->i2c_adap, 1374 struct stv0900_inode *temp_int = find_inode(state->i2c_adap,
@@ -1404,6 +1443,27 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
1404 stv0900_write_bits(intp, F0900_P1_RST_HWARE, 0); 1443 stv0900_write_bits(intp, F0900_P1_RST_HWARE, 0);
1405 } 1444 }
1406 1445
1446 intp->tuner_type[0] = p_init->tuner1_type;
1447 intp->tuner_type[1] = p_init->tuner2_type;
1448 /* tuner init */
1449 switch (p_init->tuner1_type) {
1450 case 3: /*FE_AUTO_STB6100:*/
1451 stv0900_write_reg(intp, R0900_P1_TNRCFG, 0x3c);
1452 stv0900_write_reg(intp, R0900_P1_TNRCFG2, 0x86);
1453 stv0900_write_reg(intp, R0900_P1_TNRCFG3, 0x18);
1454 stv0900_write_reg(intp, R0900_P1_TNRXTAL, 27); /* 27MHz */
1455 stv0900_write_reg(intp, R0900_P1_TNRSTEPS, 0x05);
1456 stv0900_write_reg(intp, R0900_P1_TNRGAIN, 0x17);
1457 stv0900_write_reg(intp, R0900_P1_TNRADJ, 0x1f);
1458 stv0900_write_reg(intp, R0900_P1_TNRCTL2, 0x0);
1459 stv0900_write_bits(intp, F0900_P1_TUN_TYPE, 3);
1460 break;
1461 /* case FE_SW_TUNER: */
1462 default:
1463 stv0900_write_bits(intp, F0900_P1_TUN_TYPE, 6);
1464 break;
1465 }
1466
1407 stv0900_write_bits(intp, F0900_P1_TUN_MADDRESS, p_init->tun1_maddress); 1467 stv0900_write_bits(intp, F0900_P1_TUN_MADDRESS, p_init->tun1_maddress);
1408 switch (p_init->tuner1_adc) { 1468 switch (p_init->tuner1_adc) {
1409 case 1: 1469 case 1:
@@ -1413,6 +1473,27 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
1413 break; 1473 break;
1414 } 1474 }
1415 1475
1476 stv0900_write_reg(intp, R0900_P1_TNRLD, 1); /* hw tuner */
1477
1478 /* tuner init */
1479 switch (p_init->tuner2_type) {
1480 case 3: /*FE_AUTO_STB6100:*/
1481 stv0900_write_reg(intp, R0900_P2_TNRCFG, 0x3c);
1482 stv0900_write_reg(intp, R0900_P2_TNRCFG2, 0x86);
1483 stv0900_write_reg(intp, R0900_P2_TNRCFG3, 0x18);
1484 stv0900_write_reg(intp, R0900_P2_TNRXTAL, 27); /* 27MHz */
1485 stv0900_write_reg(intp, R0900_P2_TNRSTEPS, 0x05);
1486 stv0900_write_reg(intp, R0900_P2_TNRGAIN, 0x17);
1487 stv0900_write_reg(intp, R0900_P2_TNRADJ, 0x1f);
1488 stv0900_write_reg(intp, R0900_P2_TNRCTL2, 0x0);
1489 stv0900_write_bits(intp, F0900_P2_TUN_TYPE, 3);
1490 break;
1491 /* case FE_SW_TUNER: */
1492 default:
1493 stv0900_write_bits(intp, F0900_P2_TUN_TYPE, 6);
1494 break;
1495 }
1496
1416 stv0900_write_bits(intp, F0900_P2_TUN_MADDRESS, p_init->tun2_maddress); 1497 stv0900_write_bits(intp, F0900_P2_TUN_MADDRESS, p_init->tun2_maddress);
1417 switch (p_init->tuner2_adc) { 1498 switch (p_init->tuner2_adc) {
1418 case 1: 1499 case 1:
@@ -1422,6 +1503,8 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
1422 break; 1503 break;
1423 } 1504 }
1424 1505
1506 stv0900_write_reg(intp, R0900_P2_TNRLD, 1); /* hw tuner */
1507
1425 stv0900_write_bits(intp, F0900_P1_TUN_IQSWAP, p_init->tun1_iq_inv); 1508 stv0900_write_bits(intp, F0900_P1_TUN_IQSWAP, p_init->tun1_iq_inv);
1426 stv0900_write_bits(intp, F0900_P2_TUN_IQSWAP, p_init->tun2_iq_inv); 1509 stv0900_write_bits(intp, F0900_P2_TUN_IQSWAP, p_init->tun2_iq_inv);
1427 stv0900_set_mclk(intp, 135000000); 1510 stv0900_set_mclk(intp, 135000000);
@@ -1824,10 +1907,12 @@ struct dvb_frontend *stv0900_attach(const struct stv0900_config *config,
1824 init_params.tun1_maddress = config->tun1_maddress; 1907 init_params.tun1_maddress = config->tun1_maddress;
1825 init_params.tun1_iq_inv = STV0900_IQ_NORMAL; 1908 init_params.tun1_iq_inv = STV0900_IQ_NORMAL;
1826 init_params.tuner1_adc = config->tun1_adc; 1909 init_params.tuner1_adc = config->tun1_adc;
1910 init_params.tuner1_type = config->tun1_type;
1827 init_params.path2_ts_clock = config->path2_mode; 1911 init_params.path2_ts_clock = config->path2_mode;
1828 init_params.ts_config = config->ts_config_regs; 1912 init_params.ts_config = config->ts_config_regs;
1829 init_params.tun2_maddress = config->tun2_maddress; 1913 init_params.tun2_maddress = config->tun2_maddress;
1830 init_params.tuner2_adc = config->tun2_adc; 1914 init_params.tuner2_adc = config->tun2_adc;
1915 init_params.tuner2_type = config->tun2_type;
1831 init_params.tun2_iq_inv = STV0900_IQ_SWAPPED; 1916 init_params.tun2_iq_inv = STV0900_IQ_SWAPPED;
1832 1917
1833 err_stv0900 = stv0900_init_internal(&state->frontend, 1918 err_stv0900 = stv0900_init_internal(&state->frontend,
diff --git a/drivers/media/dvb/frontends/stv0900_priv.h b/drivers/media/dvb/frontends/stv0900_priv.h
index d8ba8a984abe..b62b0f0a4fef 100644
--- a/drivers/media/dvb/frontends/stv0900_priv.h
+++ b/drivers/media/dvb/frontends/stv0900_priv.h
@@ -247,6 +247,7 @@ struct stv0900_init_params{
247 247
248 u8 tun1_maddress; 248 u8 tun1_maddress;
249 int tuner1_adc; 249 int tuner1_adc;
250 int tuner1_type;
250 251
251 /* IQ from the tuner1 to the demod */ 252 /* IQ from the tuner1 to the demod */
252 enum stv0900_iq_inversion tun1_iq_inv; 253 enum stv0900_iq_inversion tun1_iq_inv;
@@ -254,6 +255,7 @@ struct stv0900_init_params{
254 255
255 u8 tun2_maddress; 256 u8 tun2_maddress;
256 int tuner2_adc; 257 int tuner2_adc;
258 int tuner2_type;
257 259
258 /* IQ from the tuner2 to the demod */ 260 /* IQ from the tuner2 to the demod */
259 enum stv0900_iq_inversion tun2_iq_inv; 261 enum stv0900_iq_inversion tun2_iq_inv;
@@ -309,6 +311,8 @@ struct stv0900_internal{
309 s32 bw[2]; 311 s32 bw[2];
310 s32 symbol_rate[2]; 312 s32 symbol_rate[2];
311 s32 srch_range[2]; 313 s32 srch_range[2];
314 /* for software/auto tuner */
315 int tuner_type[2];
312 316
313 /* algorithm for search Blind, Cold or Warm*/ 317 /* algorithm for search Blind, Cold or Warm*/
314 enum fe_stv0900_search_algo srch_algo[2]; 318 enum fe_stv0900_search_algo srch_algo[2];
@@ -394,4 +398,11 @@ extern enum
394fe_stv0900_tracking_standard stv0900_get_standard(struct dvb_frontend *fe, 398fe_stv0900_tracking_standard stv0900_get_standard(struct dvb_frontend *fe,
395 enum fe_stv0900_demod_num demod); 399 enum fe_stv0900_demod_num demod);
396 400
401extern u32
402stv0900_get_freq_auto(struct stv0900_internal *intp, int demod);
403
404extern void
405stv0900_set_tuner_auto(struct stv0900_internal *intp, u32 Frequency,
406 u32 Bandwidth, int demod);
407
397#endif 408#endif
diff --git a/drivers/media/dvb/frontends/stv0900_reg.h b/drivers/media/dvb/frontends/stv0900_reg.h
index 7b8edf192e97..731afe93a823 100644
--- a/drivers/media/dvb/frontends/stv0900_reg.h
+++ b/drivers/media/dvb/frontends/stv0900_reg.h
@@ -3174,17 +3174,21 @@ extern s32 shiftx(s32 x, int demod, s32 shift);
3174#define R0900_P1_TNRRF1 0xf4e9 3174#define R0900_P1_TNRRF1 0xf4e9
3175#define TNRRF1 REGx(R0900_P1_TNRRF1) 3175#define TNRRF1 REGx(R0900_P1_TNRRF1)
3176#define F0900_P1_TUN_RFFREQ2 0xf4e900ff 3176#define F0900_P1_TUN_RFFREQ2 0xf4e900ff
3177#define TUN_RFFREQ2 FLDx(F0900_P1_TUN_RFFREQ2)
3177 3178
3178/*P1_TNRRF0*/ 3179/*P1_TNRRF0*/
3179#define R0900_P1_TNRRF0 0xf4ea 3180#define R0900_P1_TNRRF0 0xf4ea
3180#define TNRRF0 REGx(R0900_P1_TNRRF0) 3181#define TNRRF0 REGx(R0900_P1_TNRRF0)
3181#define F0900_P1_TUN_RFFREQ1 0xf4ea00ff 3182#define F0900_P1_TUN_RFFREQ1 0xf4ea00ff
3183#define TUN_RFFREQ1 FLDx(F0900_P1_TUN_RFFREQ1)
3182 3184
3183/*P1_TNRBW*/ 3185/*P1_TNRBW*/
3184#define R0900_P1_TNRBW 0xf4eb 3186#define R0900_P1_TNRBW 0xf4eb
3185#define TNRBW REGx(R0900_P1_TNRBW) 3187#define TNRBW REGx(R0900_P1_TNRBW)
3186#define F0900_P1_TUN_RFFREQ0 0xf4eb00c0 3188#define F0900_P1_TUN_RFFREQ0 0xf4eb00c0
3189#define TUN_RFFREQ0 FLDx(F0900_P1_TUN_RFFREQ0)
3187#define F0900_P1_TUN_BW 0xf4eb003f 3190#define F0900_P1_TUN_BW 0xf4eb003f
3191#define TUN_BW FLDx(F0900_P1_TUN_BW)
3188 3192
3189/*P1_TNRADJ*/ 3193/*P1_TNRADJ*/
3190#define R0900_P1_TNRADJ 0xf4ec 3194#define R0900_P1_TNRADJ 0xf4ec
@@ -3234,11 +3238,13 @@ extern s32 shiftx(s32 x, int demod, s32 shift);
3234#define F0900_P1_TUN_I2CLOCKED 0xf4f60010 3238#define F0900_P1_TUN_I2CLOCKED 0xf4f60010
3235#define F0900_P1_TUN_PROGDONE 0xf4f6000c 3239#define F0900_P1_TUN_PROGDONE 0xf4f6000c
3236#define F0900_P1_TUN_RFRESTE1 0xf4f60003 3240#define F0900_P1_TUN_RFRESTE1 0xf4f60003
3241#define TUN_RFRESTE1 FLDx(F0900_P1_TUN_RFRESTE1)
3237 3242
3238/*P1_TNRRESTE*/ 3243/*P1_TNRRESTE*/
3239#define R0900_P1_TNRRESTE 0xf4f7 3244#define R0900_P1_TNRRESTE 0xf4f7
3240#define TNRRESTE REGx(R0900_P1_TNRRESTE) 3245#define TNRRESTE REGx(R0900_P1_TNRRESTE)
3241#define F0900_P1_TUN_RFRESTE0 0xf4f700ff 3246#define F0900_P1_TUN_RFRESTE0 0xf4f700ff
3247#define TUN_RFRESTE0 FLDx(F0900_P1_TUN_RFRESTE0)
3242 3248
3243/*P1_SMAPCOEF7*/ 3249/*P1_SMAPCOEF7*/
3244#define R0900_P1_SMAPCOEF7 0xf500 3250#define R0900_P1_SMAPCOEF7 0xf500
diff --git a/drivers/media/dvb/frontends/stv0900_sw.c b/drivers/media/dvb/frontends/stv0900_sw.c
index b8da87fa637f..5161c2884426 100644
--- a/drivers/media/dvb/frontends/stv0900_sw.c
+++ b/drivers/media/dvb/frontends/stv0900_sw.c
@@ -606,7 +606,12 @@ static int stv0900_get_demod_cold_lock(struct dvb_frontend *fe,
606 tuner_freq -= (current_step * currier_step); 606 tuner_freq -= (current_step * currier_step);
607 607
608 if (intp->chip_id <= 0x20) { 608 if (intp->chip_id <= 0x20) {
609 stv0900_set_tuner(fe, tuner_freq, intp->bw[d]); 609 if (intp->tuner_type[d] == 3)
610 stv0900_set_tuner_auto(intp, tuner_freq,
611 intp->bw[d], demod);
612 else
613 stv0900_set_tuner(fe, tuner_freq, intp->bw[d]);
614
610 stv0900_write_reg(intp, DMDISTATE, 0x1c); 615 stv0900_write_reg(intp, DMDISTATE, 0x1c);
611 stv0900_write_reg(intp, CFRINIT1, 0); 616 stv0900_write_reg(intp, CFRINIT1, 0);
612 stv0900_write_reg(intp, CFRINIT0, 0); 617 stv0900_write_reg(intp, CFRINIT0, 0);
@@ -976,8 +981,16 @@ static void stv0900_track_optimization(struct dvb_frontend *fe)
976 intp->rolloff) + 10000000; 981 intp->rolloff) + 10000000;
977 982
978 if ((intp->chip_id >= 0x20) || (blind_tun_sw == 1)) { 983 if ((intp->chip_id >= 0x20) || (blind_tun_sw == 1)) {
979 if (intp->srch_algo[demod] != STV0900_WARM_START) 984 if (intp->srch_algo[demod] != STV0900_WARM_START) {
980 stv0900_set_bandwidth(fe, intp->bw[demod]); 985 if (intp->tuner_type[demod] == 3)
986 stv0900_set_tuner_auto(intp,
987 intp->freq[demod],
988 intp->bw[demod],
989 demod);
990 else
991 stv0900_set_bandwidth(fe,
992 intp->bw[demod]);
993 }
981 } 994 }
982 995
983 if ((intp->srch_algo[demod] == STV0900_BLIND_SEARCH) || 996 if ((intp->srch_algo[demod] == STV0900_BLIND_SEARCH) ||
@@ -1202,7 +1215,11 @@ fe_stv0900_signal_type stv0900_get_signal_params(struct dvb_frontend *fe)
1202 } 1215 }
1203 1216
1204 result->standard = stv0900_get_standard(fe, d); 1217 result->standard = stv0900_get_standard(fe, d);
1205 result->frequency = stv0900_get_tuner_freq(fe); 1218 if (intp->tuner_type[demod] == 3)
1219 result->frequency = stv0900_get_freq_auto(intp, d);
1220 else
1221 result->frequency = stv0900_get_tuner_freq(fe);
1222
1206 offsetFreq = stv0900_get_carr_freq(intp, intp->mclk, d) / 1000; 1223 offsetFreq = stv0900_get_carr_freq(intp, intp->mclk, d) / 1000;
1207 result->frequency += offsetFreq; 1224 result->frequency += offsetFreq;
1208 result->symbol_rate = stv0900_get_symbol_rate(intp, intp->mclk, d); 1225 result->symbol_rate = stv0900_get_symbol_rate(intp, intp->mclk, d);
@@ -1239,7 +1256,11 @@ fe_stv0900_signal_type stv0900_get_signal_params(struct dvb_frontend *fe)
1239 if ((intp->srch_algo[d] == STV0900_BLIND_SEARCH) || 1256 if ((intp->srch_algo[d] == STV0900_BLIND_SEARCH) ||
1240 (intp->symbol_rate[d] < 10000000)) { 1257 (intp->symbol_rate[d] < 10000000)) {
1241 offsetFreq = result->frequency - intp->freq[d]; 1258 offsetFreq = result->frequency - intp->freq[d];
1242 intp->freq[d] = stv0900_get_tuner_freq(fe); 1259 if (intp->tuner_type[demod] == 3)
1260 intp->freq[d] = stv0900_get_freq_auto(intp, d);
1261 else
1262 intp->freq[d] = stv0900_get_tuner_freq(fe);
1263
1243 if (ABS(offsetFreq) <= ((intp->srch_range[d] / 2000) + 500)) 1264 if (ABS(offsetFreq) <= ((intp->srch_range[d] / 2000) + 500))
1244 range = STV0900_RANGEOK; 1265 range = STV0900_RANGEOK;
1245 else if (ABS(offsetFreq) <= 1266 else if (ABS(offsetFreq) <=
@@ -1481,7 +1502,12 @@ static u32 stv0900_search_srate_coarse(struct dvb_frontend *fe)
1481 else 1502 else
1482 tuner_freq -= (current_step * currier_step); 1503 tuner_freq -= (current_step * currier_step);
1483 1504
1484 stv0900_set_tuner(fe, tuner_freq, intp->bw[demod]); 1505 if (intp->tuner_type[demod] == 3)
1506 stv0900_set_tuner_auto(intp, tuner_freq,
1507 intp->bw[demod], demod);
1508 else
1509 stv0900_set_tuner(fe, tuner_freq,
1510 intp->bw[demod]);
1485 } 1511 }
1486 } 1512 }
1487 1513
@@ -1875,7 +1901,11 @@ enum fe_stv0900_signal_type stv0900_algo(struct dvb_frontend *fe)
1875 1901
1876 } 1902 }
1877 1903
1878 stv0900_set_tuner(fe, intp->freq[demod], intp->bw[demod]); 1904 if (intp->tuner_type[demod] == 3)
1905 stv0900_set_tuner_auto(intp, intp->freq[demod],
1906 intp->bw[demod], demod);
1907 else
1908 stv0900_set_tuner(fe, intp->freq[demod], intp->bw[demod]);
1879 1909
1880 agc1_power = MAKEWORD(stv0900_get_bits(intp, AGCIQ_VALUE1), 1910 agc1_power = MAKEWORD(stv0900_get_bits(intp, AGCIQ_VALUE1),
1881 stv0900_get_bits(intp, AGCIQ_VALUE0)); 1911 stv0900_get_bits(intp, AGCIQ_VALUE0));