aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/dib7000p.c
diff options
context:
space:
mode:
authorOlivier Grenie <olivier.grenie@dibcom.fr>2011-01-04 11:08:14 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 19:31:43 -0400
commitb4d6046e841955be9cc49164b03b91c9524f9c2e (patch)
tree9959b1becc3387b977b9c736e1f16ef20b607a01 /drivers/media/dvb/frontends/dib7000p.c
parentbe9bae10ffa5aeeef051e893c3b15a5d10eb657d (diff)
[media] DiBxxxx: Codingstype updates
This patchs fix several conding-style violations. Signed-off-by: Olivier Grenie <olivier.grenie@dibcom.fr> Signed-off-by: Patrick Boettcher <patrick.boettcher@dibcom.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends/dib7000p.c')
-rw-r--r--drivers/media/dvb/frontends/dib7000p.c205
1 files changed, 94 insertions, 111 deletions
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c
index 18495bd166e6..b3ca3e2f8d53 100644
--- a/drivers/media/dvb/frontends/dib7000p.c
+++ b/drivers/media/dvb/frontends/dib7000p.c
@@ -79,8 +79,8 @@ static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg)
79 u8 wb[2] = { reg >> 8, reg & 0xff }; 79 u8 wb[2] = { reg >> 8, reg & 0xff };
80 u8 rb[2]; 80 u8 rb[2];
81 struct i2c_msg msg[2] = { 81 struct i2c_msg msg[2] = {
82 {.addr = state->i2c_addr >> 1,.flags = 0,.buf = wb,.len = 2}, 82 {.addr = state->i2c_addr >> 1, .flags = 0, .buf = wb, .len = 2},
83 {.addr = state->i2c_addr >> 1,.flags = I2C_M_RD,.buf = rb,.len = 2}, 83 {.addr = state->i2c_addr >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2},
84 }; 84 };
85 85
86 if (i2c_transfer(state->i2c_adap, msg, 2) != 2) 86 if (i2c_transfer(state->i2c_adap, msg, 2) != 2)
@@ -96,7 +96,7 @@ static int dib7000p_write_word(struct dib7000p_state *state, u16 reg, u16 val)
96 (val >> 8) & 0xff, val & 0xff, 96 (val >> 8) & 0xff, val & 0xff,
97 }; 97 };
98 struct i2c_msg msg = { 98 struct i2c_msg msg = {
99 .addr = state->i2c_addr >> 1,.flags = 0,.buf = b,.len = 4 99 .addr = state->i2c_addr >> 1, .flags = 0, .buf = b, .len = 4
100 }; 100 };
101 return i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; 101 return i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0;
102} 102}
@@ -129,13 +129,13 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode)
129 dprintk("setting output mode for demod %p to %d", &state->demod, mode); 129 dprintk("setting output mode for demod %p to %d", &state->demod, mode);
130 130
131 switch (mode) { 131 switch (mode) {
132 case OUTMODE_MPEG2_PAR_GATED_CLK: // STBs with parallel gated clock 132 case OUTMODE_MPEG2_PAR_GATED_CLK:
133 outreg = (1 << 10); /* 0x0400 */ 133 outreg = (1 << 10); /* 0x0400 */
134 break; 134 break;
135 case OUTMODE_MPEG2_PAR_CONT_CLK: // STBs with parallel continues clock 135 case OUTMODE_MPEG2_PAR_CONT_CLK:
136 outreg = (1 << 10) | (1 << 6); /* 0x0440 */ 136 outreg = (1 << 10) | (1 << 6); /* 0x0440 */
137 break; 137 break;
138 case OUTMODE_MPEG2_SERIAL: // STBs with serial input 138 case OUTMODE_MPEG2_SERIAL:
139 outreg = (1 << 10) | (2 << 6) | (0 << 1); /* 0x0480 */ 139 outreg = (1 << 10) | (2 << 6) | (0 << 1); /* 0x0480 */
140 break; 140 break;
141 case OUTMODE_DIVERSITY: 141 case OUTMODE_DIVERSITY:
@@ -144,7 +144,7 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode)
144 else 144 else
145 outreg = (1 << 11); 145 outreg = (1 << 11);
146 break; 146 break;
147 case OUTMODE_MPEG2_FIFO: // e.g. USB feeding 147 case OUTMODE_MPEG2_FIFO:
148 smo_mode |= (3 << 1); 148 smo_mode |= (3 << 1);
149 fifo_threshold = 512; 149 fifo_threshold = 512;
150 outreg = (1 << 10) | (5 << 6); 150 outreg = (1 << 10) | (5 << 6);
@@ -152,7 +152,7 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode)
152 case OUTMODE_ANALOG_ADC: 152 case OUTMODE_ANALOG_ADC:
153 outreg = (1 << 10) | (3 << 6); 153 outreg = (1 << 10) | (3 << 6);
154 break; 154 break;
155 case OUTMODE_HIGH_Z: // disable 155 case OUTMODE_HIGH_Z:
156 outreg = 0; 156 outreg = 0;
157 break; 157 break;
158 default: 158 default:
@@ -284,7 +284,7 @@ static void dib7000p_set_adc_state(struct dib7000p_state *state, enum dibx000_ad
284 reg_909 &= 0x0003; 284 reg_909 &= 0x0003;
285 break; 285 break;
286 286
287 case DIBX000_ADC_OFF: // leave the VBG voltage on 287 case DIBX000_ADC_OFF:
288 reg_908 |= (1 << 14) | (1 << 13) | (1 << 12); 288 reg_908 |= (1 << 14) | (1 << 13) | (1 << 12);
289 reg_909 |= (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2); 289 reg_909 |= (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2);
290 break; 290 break;
@@ -336,13 +336,12 @@ static int dib7000p_set_bandwidth(struct dib7000p_state *state, u32 bw)
336static int dib7000p_sad_calib(struct dib7000p_state *state) 336static int dib7000p_sad_calib(struct dib7000p_state *state)
337{ 337{
338/* internal */ 338/* internal */
339// dib7000p_write_word(state, 72, (3 << 14) | (1 << 12) | (524 << 0)); // sampling clock of the SAD is writting in set_bandwidth
340 dib7000p_write_word(state, 73, (0 << 1) | (0 << 0)); 339 dib7000p_write_word(state, 73, (0 << 1) | (0 << 0));
341 340
342 if (state->version == SOC7090) 341 if (state->version == SOC7090)
343 dib7000p_write_word(state, 74, 2048); // P_sad_calib_value = (0.9/1.8)*4096 342 dib7000p_write_word(state, 74, 2048);
344 else 343 else
345 dib7000p_write_word(state, 74, 776); // P_sad_calib_value = 0.625*3.3 / 4096 344 dib7000p_write_word(state, 74, 776);
346 345
347 /* do the calibration */ 346 /* do the calibration */
348 dib7000p_write_word(state, 73, (1 << 0)); 347 dib7000p_write_word(state, 73, (1 << 0));
@@ -371,8 +370,8 @@ static void dib7000p_reset_pll(struct dib7000p_state *state)
371 if (state->version == SOC7090) { 370 if (state->version == SOC7090) {
372 dib7000p_write_word(state, 1856, (!bw->pll_reset << 13) | (bw->pll_range << 12) | (bw->pll_ratio << 6) | (bw->pll_prediv)); 371 dib7000p_write_word(state, 1856, (!bw->pll_reset << 13) | (bw->pll_range << 12) | (bw->pll_ratio << 6) | (bw->pll_prediv));
373 372
374 while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1) { 373 while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1)
375 } 374 ;
376 375
377 dib7000p_write_word(state, 1857, dib7000p_read_word(state, 1857) | (!bw->pll_bypass << 15)); 376 dib7000p_write_word(state, 1857, dib7000p_read_word(state, 1857) | (!bw->pll_bypass << 15));
378 } else { 377 } else {
@@ -420,7 +419,7 @@ int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth_config
420 dprintk("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)", prediv, bw->pll_prediv, loopdiv, bw->pll_ratio); 419 dprintk("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)", prediv, bw->pll_prediv, loopdiv, bw->pll_ratio);
421 reg_1856 &= 0xf000; 420 reg_1856 &= 0xf000;
422 reg_1857 = dib7000p_read_word(state, 1857); 421 reg_1857 = dib7000p_read_word(state, 1857);
423 dib7000p_write_word(state, 1857, reg_1857 & ~(1 << 15)); // desable pll 422 dib7000p_write_word(state, 1857, reg_1857 & ~(1 << 15));
424 423
425 dib7000p_write_word(state, 1856, reg_1856 | ((bw->pll_ratio & 0x3f) << 6) | (bw->pll_prediv & 0x3f)); 424 dib7000p_write_word(state, 1856, reg_1856 | ((bw->pll_ratio & 0x3f) << 6) | (bw->pll_prediv & 0x3f));
426 425
@@ -431,11 +430,10 @@ int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth_config
431 dib7000p_write_word(state, 18, (u16) ((internal >> 16) & 0xffff)); 430 dib7000p_write_word(state, 18, (u16) ((internal >> 16) & 0xffff));
432 dib7000p_write_word(state, 19, (u16) (internal & 0xffff)); 431 dib7000p_write_word(state, 19, (u16) (internal & 0xffff));
433 432
434 dib7000p_write_word(state, 1857, reg_1857 | (1 << 15)); // enable pll 433 dib7000p_write_word(state, 1857, reg_1857 | (1 << 15));
435 434
436 while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1) { 435 while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1)
437 dprintk("Waiting for PLL to lock"); 436 dprintk("Waiting for PLL to lock");
438 }
439 437
440 return 0; 438 return 0;
441 } 439 }
@@ -503,7 +501,7 @@ static u16 dib7000p_defaults[] = {
503 0xd4c0, 501 0xd4c0,
504 502
505 1, 26, 503 1, 26,
506 0x6680, // P_timf_alpha=6, P_corm_alpha=6, P_corm_thres=128 default: 6,4,26 504 0x6680,
507 505
508 /* set ADC level to -16 */ 506 /* set ADC level to -16 */
509 11, 79, 507 11, 79,
@@ -520,7 +518,7 @@ static u16 dib7000p_defaults[] = {
520 (1 << 13) - 501 - 117, 518 (1 << 13) - 501 - 117,
521 519
522 1, 142, 520 1, 142,
523 0x0410, // P_palf_filter_on=1, P_palf_filter_freeze=0, P_palf_alpha_regul=16 521 0x0410,
524 522
525 /* disable power smoothing */ 523 /* disable power smoothing */
526 8, 145, 524 8, 145,
@@ -534,42 +532,39 @@ static u16 dib7000p_defaults[] = {
534 0, 532 0,
535 533
536 1, 154, 534 1, 154,
537 1 << 13, // P_fft_freq_dir=1, P_fft_nb_to_cut=0 535 1 << 13,
538 536
539 1, 168, 537 1, 168,
540 0x0ccd, // P_pha3_thres, default 0x3000 538 0x0ccd,
541
542// 1, 169,
543// 0x0010, // P_cti_use_cpe=0, P_cti_use_prog=0, P_cti_win_len=16, default: 0x0010
544 539
545 1, 183, 540 1, 183,
546 0x200f, // P_cspu_regul=512, P_cspu_win_cut=15, default: 0x2005 541 0x200f,
547 542
548 1, 212, 543 1, 212,
549 0x169, // P_vit_ksi_dwn = 5 P_vit_ksi_up = 5 0x1e1, // P_vit_ksi_dwn = 4 P_vit_ksi_up = 7 544 0x169,
550 545
551 5, 187, 546 5, 187,
552 0x023d, // P_adp_regul_cnt=573, default: 410 547 0x023d,
553 0x00a4, // P_adp_noise_cnt= 548 0x00a4,
554 0x00a4, // P_adp_regul_ext 549 0x00a4,
555 0x7ff0, // P_adp_noise_ext 550 0x7ff0,
556 0x3ccc, // P_adp_fil 551 0x3ccc,
557 552
558 1, 198, 553 1, 198,
559 0x800, // P_equal_thres_wgn 554 0x800,
560 555
561 1, 222, 556 1, 222,
562 0x0010, // P_fec_ber_rs_len=2 557 0x0010,
563 558
564 1, 235, 559 1, 235,
565 0x0062, // P_smo_mode, P_smo_rs_discard, P_smo_fifo_flush, P_smo_pid_parse, P_smo_error_discard 560 0x0062,
566 561
567 2, 901, 562 2, 901,
568 0x0006, // P_clk_cfg1 563 0x0006,
569 (3 << 10) | (1 << 6), // P_divclksel=3 P_divbitsel=1 564 (3 << 10) | (1 << 6),
570 565
571 1, 905, 566 1, 905,
572 0x2c8e, // Tuner IO bank: max drive (14mA) + divout pads max drive 567 0x2c8e,
573 568
574 0, 569 0,
575}; 570};
@@ -609,8 +604,7 @@ static int dib7000p_demod_reset(struct dib7000p_state *state)
609 dib7000p_write_word(state, 42, (1<<5) | 3); /* P_iqc_thsat_ipc = 1 ; P_iqc_win2 = 3 */ 604 dib7000p_write_word(state, 42, (1<<5) | 3); /* P_iqc_thsat_ipc = 1 ; P_iqc_win2 = 3 */
610 dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */ 605 dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */
611 dib7000p_write_word(state, 44, 300); /* 300 fag P_iqc_dect_min = +280 */ 606 dib7000p_write_word(state, 44, 300); /* 300 fag P_iqc_dect_min = +280 */
612 //dib7000p_write_word(state, 273, (1<<6) | 10); /* P_vit_inoise_sel = 1, P_vit_inoise_gain = 10*/ 607 dib7000p_write_word(state, 273, (1<<6) | 30);
613 dib7000p_write_word(state, 273, (1<<6) | 30); //26/* P_vit_inoise_sel = 1, P_vit_inoise_gain = 26*/// FAG
614 } 608 }
615 if (dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) != 0) 609 if (dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) != 0)
616 dprintk("OUTPUT_MODE could not be reset."); 610 dprintk("OUTPUT_MODE could not be reset.");
@@ -624,9 +618,9 @@ static int dib7000p_demod_reset(struct dib7000p_state *state)
624 618
625 dib7000p_set_bandwidth(state, 8000); 619 dib7000p_set_bandwidth(state, 8000);
626 620
627 if(state->version == SOC7090) { 621 if (state->version == SOC7090) {
628 dib7000p_write_word(state, 36, 0x5755);/* P_iqc_impnc_on =1 & P_iqc_corr_inh = 1 for impulsive noise */ 622 dib7000p_write_word(state, 36, 0x5755);/* P_iqc_impnc_on =1 & P_iqc_corr_inh = 1 for impulsive noise */
629 } else { // P_iqc_alpha_pha, P_iqc_alpha_amp_dcc_alpha, ... 623 } else {
630 if (state->cfg.tuner_is_baseband) 624 if (state->cfg.tuner_is_baseband)
631 dib7000p_write_word(state, 36, 0x0755); 625 dib7000p_write_word(state, 36, 0x0755);
632 else 626 else
@@ -644,9 +638,9 @@ static void dib7000p_pll_clk_cfg(struct dib7000p_state *state)
644{ 638{
645 u16 tmp = 0; 639 u16 tmp = 0;
646 tmp = dib7000p_read_word(state, 903); 640 tmp = dib7000p_read_word(state, 903);
647 dib7000p_write_word(state, 903, (tmp | 0x1)); //pwr-up pll 641 dib7000p_write_word(state, 903, (tmp | 0x1));
648 tmp = dib7000p_read_word(state, 900); 642 tmp = dib7000p_read_word(state, 900);
649 dib7000p_write_word(state, 900, (tmp & 0x7fff) | (1 << 6)); //use High freq clock 643 dib7000p_write_word(state, 900, (tmp & 0x7fff) | (1 << 6));
650} 644}
651 645
652static void dib7000p_restart_agc(struct dib7000p_state *state) 646static void dib7000p_restart_agc(struct dib7000p_state *state)
@@ -660,11 +654,9 @@ static int dib7000p_update_lna(struct dib7000p_state *state)
660{ 654{
661 u16 dyn_gain; 655 u16 dyn_gain;
662 656
663 // when there is no LNA to program return immediatly
664 if (state->cfg.update_lna) { 657 if (state->cfg.update_lna) {
665 // read dyn_gain here (because it is demod-dependent and not fe)
666 dyn_gain = dib7000p_read_word(state, 394); 658 dyn_gain = dib7000p_read_word(state, 394);
667 if (state->cfg.update_lna(&state->demod, dyn_gain)) { // LNA has changed 659 if (state->cfg.update_lna(&state->demod, dyn_gain)) {
668 dib7000p_restart_agc(state); 660 dib7000p_restart_agc(state);
669 return 1; 661 return 1;
670 } 662 }
@@ -763,12 +755,11 @@ static int dib7000p_agc_startup(struct dvb_frontend *demod, struct dvb_frontend_
763 755
764 switch (state->agc_state) { 756 switch (state->agc_state) {
765 case 0: 757 case 0:
766 // set power-up level: interf+analog+AGC
767 dib7000p_set_power_mode(state, DIB7000P_POWER_ALL); 758 dib7000p_set_power_mode(state, DIB7000P_POWER_ALL);
768 if (state->version == SOC7090) { 759 if (state->version == SOC7090) {
769 reg = dib7000p_read_word(state, 0x79b) & 0xff00; 760 reg = dib7000p_read_word(state, 0x79b) & 0xff00;
770 dib7000p_write_word(state, 0x79a, upd_demod_gain_period & 0xFFFF); /* lsb */ 761 dib7000p_write_word(state, 0x79a, upd_demod_gain_period & 0xFFFF); /* lsb */
771 dib7000p_write_word(state, 0x79b, reg | (1 << 14) | ((upd_demod_gain_period >> 16) & 0xFF)); // bit 14 = enDemodGain 762 dib7000p_write_word(state, 0x79b, reg | (1 << 14) | ((upd_demod_gain_period >> 16) & 0xFF));
772 763
773 /* enable adc i & q */ 764 /* enable adc i & q */
774 reg = dib7000p_read_word(state, 0x780); 765 reg = dib7000p_read_word(state, 0x780);
@@ -787,7 +778,6 @@ static int dib7000p_agc_startup(struct dvb_frontend *demod, struct dvb_frontend_
787 break; 778 break;
788 779
789 case 1: 780 case 1:
790 // AGC initialization
791 if (state->cfg.agc_control) 781 if (state->cfg.agc_control)
792 state->cfg.agc_control(&state->demod, 1); 782 state->cfg.agc_control(&state->demod, 1);
793 783
@@ -831,13 +821,11 @@ static int dib7000p_agc_startup(struct dvb_frontend *demod, struct dvb_frontend_
831 break; 821 break;
832 822
833 case 4: /* LNA startup */ 823 case 4: /* LNA startup */
834 // wait AGC accurate lock time
835 ret = 7; 824 ret = 7;
836 825
837 if (dib7000p_update_lna(state)) 826 if (dib7000p_update_lna(state))
838 // wait only AGC rough lock time
839 ret = 5; 827 ret = 5;
840 else // nothing was done, go to the next state 828 else
841 (*agc_state)++; 829 (*agc_state)++;
842 break; 830 break;
843 831
@@ -971,10 +959,10 @@ static void dib7000p_set_channel(struct dib7000p_state *state, struct dvb_fronte
971 dib7000p_write_word(state, 208, value); 959 dib7000p_write_word(state, 208, value);
972 960
973 /* offset loop parameters */ 961 /* offset loop parameters */
974 dib7000p_write_word(state, 26, 0x6680); // timf(6xxx) 962 dib7000p_write_word(state, 26, 0x6680);
975 dib7000p_write_word(state, 32, 0x0003); // pha_off_max(xxx3) 963 dib7000p_write_word(state, 32, 0x0003);
976 dib7000p_write_word(state, 29, 0x1273); // isi 964 dib7000p_write_word(state, 29, 0x1273);
977 dib7000p_write_word(state, 33, 0x0005); // sfreq(xxx5) 965 dib7000p_write_word(state, 33, 0x0005);
978 966
979 /* P_dvsy_sync_wait */ 967 /* P_dvsy_sync_wait */
980 switch (ch->u.ofdm.transmission_mode) { 968 switch (ch->u.ofdm.transmission_mode) {
@@ -1005,9 +993,9 @@ static void dib7000p_set_channel(struct dib7000p_state *state, struct dvb_fronte
1005 break; 993 break;
1006 } 994 }
1007 if (state->cfg.diversity_delay == 0) 995 if (state->cfg.diversity_delay == 0)
1008 state->div_sync_wait = (value * 3) / 2 + 48; // add 50% SFN margin + compensate for one DVSY-fifo 996 state->div_sync_wait = (value * 3) / 2 + 48;
1009 else 997 else
1010 state->div_sync_wait = (value * 3) / 2 + state->cfg.diversity_delay; // add 50% SFN margin + compensate for one DVSY-fifo 998 state->div_sync_wait = (value * 3) / 2 + state->cfg.diversity_delay;
1011 999
1012 /* deactive the possibility of diversity reception if extended interleaver */ 1000 /* deactive the possibility of diversity reception if extended interleaver */
1013 state->div_force_off = !1 && ch->u.ofdm.transmission_mode != TRANSMISSION_MODE_8K; 1001 state->div_force_off = !1 && ch->u.ofdm.transmission_mode != TRANSMISSION_MODE_8K;
@@ -1061,16 +1049,15 @@ static int dib7000p_autosearch_start(struct dvb_frontend *demod, struct dvb_fron
1061 else 1049 else
1062 factor = 6; 1050 factor = 6;
1063 1051
1064 // always use the setting for 8MHz here lock_time for 7,6 MHz are longer
1065 value = 30 * internal * factor; 1052 value = 30 * internal * factor;
1066 dib7000p_write_word(state, 6, (u16) ((value >> 16) & 0xffff)); // lock0 wait time 1053 dib7000p_write_word(state, 6, (u16) ((value >> 16) & 0xffff));
1067 dib7000p_write_word(state, 7, (u16) (value & 0xffff)); // lock0 wait time 1054 dib7000p_write_word(state, 7, (u16) (value & 0xffff));
1068 value = 100 * internal * factor; 1055 value = 100 * internal * factor;
1069 dib7000p_write_word(state, 8, (u16) ((value >> 16) & 0xffff)); // lock1 wait time 1056 dib7000p_write_word(state, 8, (u16) ((value >> 16) & 0xffff));
1070 dib7000p_write_word(state, 9, (u16) (value & 0xffff)); // lock1 wait time 1057 dib7000p_write_word(state, 9, (u16) (value & 0xffff));
1071 value = 500 * internal * factor; 1058 value = 500 * internal * factor;
1072 dib7000p_write_word(state, 10, (u16) ((value >> 16) & 0xffff)); // lock2 wait time 1059 dib7000p_write_word(state, 10, (u16) ((value >> 16) & 0xffff));
1073 dib7000p_write_word(state, 11, (u16) (value & 0xffff)); // lock2 wait time 1060 dib7000p_write_word(state, 11, (u16) (value & 0xffff));
1074 1061
1075 value = dib7000p_read_word(state, 0); 1062 value = dib7000p_read_word(state, 0);
1076 dib7000p_write_word(state, 0, (u16) ((1 << 9) | value)); 1063 dib7000p_write_word(state, 0, (u16) ((1 << 9) | value));
@@ -1085,13 +1072,13 @@ static int dib7000p_autosearch_is_irq(struct dvb_frontend *demod)
1085 struct dib7000p_state *state = demod->demodulator_priv; 1072 struct dib7000p_state *state = demod->demodulator_priv;
1086 u16 irq_pending = dib7000p_read_word(state, 1284); 1073 u16 irq_pending = dib7000p_read_word(state, 1284);
1087 1074
1088 if (irq_pending & 0x1) // failed 1075 if (irq_pending & 0x1)
1089 return 1; 1076 return 1;
1090 1077
1091 if (irq_pending & 0x2) // succeeded 1078 if (irq_pending & 0x2)
1092 return 2; 1079 return 2;
1093 1080
1094 return 0; // still pending 1081 return 0;
1095} 1082}
1096 1083
1097static void dib7000p_spur_protect(struct dib7000p_state *state, u32 rf_khz, u32 bw) 1084static void dib7000p_spur_protect(struct dib7000p_state *state, u32 rf_khz, u32 bw)
@@ -1202,9 +1189,9 @@ static int dib7000p_tune(struct dvb_frontend *demod, struct dvb_frontend_paramet
1202 if (state->sfn_workaround_active) { 1189 if (state->sfn_workaround_active) {
1203 dprintk("SFN workaround is active"); 1190 dprintk("SFN workaround is active");
1204 tmp |= (1 << 9); 1191 tmp |= (1 << 9);
1205 dib7000p_write_word(state, 166, 0x4000); // P_pha3_force_pha_shift 1192 dib7000p_write_word(state, 166, 0x4000);
1206 } else { 1193 } else {
1207 dib7000p_write_word(state, 166, 0x0000); // P_pha3_force_pha_shift 1194 dib7000p_write_word(state, 166, 0x0000);
1208 } 1195 }
1209 dib7000p_write_word(state, 29, tmp); 1196 dib7000p_write_word(state, 29, tmp);
1210 1197
@@ -1425,8 +1412,7 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_pa
1425 if (state->version == SOC7090) { 1412 if (state->version == SOC7090) {
1426 dib7090_set_diversity_in(fe, 0); 1413 dib7090_set_diversity_in(fe, 0);
1427 dib7090_set_output_mode(fe, OUTMODE_HIGH_Z); 1414 dib7090_set_output_mode(fe, OUTMODE_HIGH_Z);
1428 } 1415 } else
1429 else
1430 dib7000p_set_output_mode(state, OUTMODE_HIGH_Z); 1416 dib7000p_set_output_mode(state, OUTMODE_HIGH_Z);
1431 1417
1432 /* maybe the parameter has been changed */ 1418 /* maybe the parameter has been changed */
@@ -1455,7 +1441,7 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_pa
1455 1441
1456 dprintk("autosearch returns: %d", found); 1442 dprintk("autosearch returns: %d", found);
1457 if (found == 0 || found == 1) 1443 if (found == 0 || found == 1)
1458 return 0; // no channel found 1444 return 0;
1459 1445
1460 dib7000p_get_frontend(fe, fep); 1446 dib7000p_get_frontend(fe, fep);
1461 } 1447 }
@@ -1566,8 +1552,8 @@ int dib7000pc_detection(struct i2c_adapter *i2c_adap)
1566{ 1552{
1567 u8 tx[2], rx[2]; 1553 u8 tx[2], rx[2];
1568 struct i2c_msg msg[2] = { 1554 struct i2c_msg msg[2] = {
1569 {.addr = 18 >> 1,.flags = 0,.buf = tx,.len = 2}, 1555 {.addr = 18 >> 1, .flags = 0, .buf = tx, .len = 2},
1570 {.addr = 18 >> 1,.flags = I2C_M_RD,.buf = rx,.len = 2}, 1556 {.addr = 18 >> 1, .flags = I2C_M_RD, .buf = rx, .len = 2},
1571 }; 1557 };
1572 1558
1573 tx[0] = 0x03; 1559 tx[0] = 0x03;
@@ -1725,9 +1711,8 @@ static int map_addr_to_serpar_number(struct i2c_msg *msg)
1725 msg->buf[0] -= 3; 1711 msg->buf[0] -= 3;
1726 else if (msg->buf[0] == 28) 1712 else if (msg->buf[0] == 28)
1727 msg->buf[0] = 23; 1713 msg->buf[0] = 23;
1728 else { 1714 else
1729 return -EINVAL; 1715 return -EINVAL;
1730 }
1731 return 0; 1716 return 0;
1732} 1717}
1733 1718
@@ -1909,7 +1894,7 @@ static int dib7090_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[]
1909 if (num == 1) { /* write */ 1894 if (num == 1) { /* write */
1910 word = (u16) ((msg[0].buf[1] << 8) | msg[0].buf[2]); 1895 word = (u16) ((msg[0].buf[1] << 8) | msg[0].buf[2]);
1911 word &= 0x3; 1896 word &= 0x3;
1912 word = (dib7000p_read_word(state, 72) & ~(3 << 12)) | (word << 12); //Mask bit 12,13 1897 word = (dib7000p_read_word(state, 72) & ~(3 << 12)) | (word << 12);
1913 dib7000p_write_word(state, 72, word); /* Set the proper input */ 1898 dib7000p_write_word(state, 72, word); /* Set the proper input */
1914 return num; 1899 return num;
1915 } 1900 }
@@ -1996,7 +1981,7 @@ static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout
1996 u16 rx_copy_buf[22]; 1981 u16 rx_copy_buf[22];
1997 1982
1998 dprintk("Configure DibStream Tx"); 1983 dprintk("Configure DibStream Tx");
1999 for (index_buf = 0; index_buf<22; index_buf++) 1984 for (index_buf = 0; index_buf < 22; index_buf++)
2000 rx_copy_buf[index_buf] = dib7000p_read_word(state, 1536+index_buf); 1985 rx_copy_buf[index_buf] = dib7000p_read_word(state, 1536+index_buf);
2001 1986
2002 dib7000p_write_word(state, 1615, 1); 1987 dib7000p_write_word(state, 1615, 1);
@@ -2009,7 +1994,7 @@ static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout
2009 dib7000p_write_word(state, 1612, syncSize); 1994 dib7000p_write_word(state, 1612, syncSize);
2010 dib7000p_write_word(state, 1615, 0); 1995 dib7000p_write_word(state, 1615, 0);
2011 1996
2012 for (index_buf = 0; index_buf<22; index_buf++) 1997 for (index_buf = 0; index_buf < 22; index_buf++)
2013 dib7000p_write_word(state, 1536+index_buf, rx_copy_buf[index_buf]); 1998 dib7000p_write_word(state, 1536+index_buf, rx_copy_buf[index_buf]);
2014 1999
2015 return 0; 2000 return 0;
@@ -2021,8 +2006,7 @@ static int dib7090_cfg_DibRx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout
2021 u32 syncFreq; 2006 u32 syncFreq;
2022 2007
2023 dprintk("Configure DibStream Rx"); 2008 dprintk("Configure DibStream Rx");
2024 if ((P_Kin != 0) && (P_Kout != 0)) 2009 if ((P_Kin != 0) && (P_Kout != 0)) {
2025 {
2026 syncFreq = dib7090_calcSyncFreq(P_Kin, P_Kout, insertExtSynchro, syncSize); 2010 syncFreq = dib7090_calcSyncFreq(P_Kin, P_Kout, insertExtSynchro, syncSize);
2027 dib7000p_write_word(state, 1542, syncFreq); 2011 dib7000p_write_word(state, 1542, syncFreq);
2028 } 2012 }
@@ -2044,7 +2028,7 @@ static int dib7090_enDivOnHostBus(struct dib7000p_state *state)
2044 u16 reg; 2028 u16 reg;
2045 2029
2046 dprintk("Enable Diversity on host bus"); 2030 dprintk("Enable Diversity on host bus");
2047 reg = (1 << 8) | (1 << 5); // P_enDivOutOnDibTx = 1 ; P_enDibTxOnHostBus = 1 2031 reg = (1 << 8) | (1 << 5);
2048 dib7000p_write_word(state, 1288, reg); 2032 dib7000p_write_word(state, 1288, reg);
2049 2033
2050 return dib7090_cfg_DibTx(state, 5, 5, 0, 0, 0, 0); 2034 return dib7090_cfg_DibTx(state, 5, 5, 0, 0, 0, 0);
@@ -2055,7 +2039,7 @@ static int dib7090_enAdcOnHostBus(struct dib7000p_state *state)
2055 u16 reg; 2039 u16 reg;
2056 2040
2057 dprintk("Enable ADC on host bus"); 2041 dprintk("Enable ADC on host bus");
2058 reg = (1 << 7) | (1 << 5); //P_enAdcOnDibTx = 1 ; P_enDibTxOnHostBus = 1 2042 reg = (1 << 7) | (1 << 5);
2059 dib7000p_write_word(state, 1288, reg); 2043 dib7000p_write_word(state, 1288, reg);
2060 2044
2061 return dib7090_cfg_DibTx(state, 20, 5, 10, 0, 0, 0); 2045 return dib7090_cfg_DibTx(state, 20, 5, 10, 0, 0, 0);
@@ -2066,7 +2050,7 @@ static int dib7090_enMpegOnHostBus(struct dib7000p_state *state)
2066 u16 reg; 2050 u16 reg;
2067 2051
2068 dprintk("Enable Mpeg on host bus"); 2052 dprintk("Enable Mpeg on host bus");
2069 reg = (1 << 9) | (1 << 5); //P_enMpegOnDibTx = 1 ; P_enDibTxOnHostBus = 1 2053 reg = (1 << 9) | (1 << 5);
2070 dib7000p_write_word(state, 1288, reg); 2054 dib7000p_write_word(state, 1288, reg);
2071 2055
2072 return dib7090_cfg_DibTx(state, 8, 5, 0, 0, 0, 0); 2056 return dib7090_cfg_DibTx(state, 8, 5, 0, 0, 0, 0);
@@ -2085,10 +2069,10 @@ static int dib7090_enMpegMux(struct dib7000p_state *state, u16 pulseWidth, u16 e
2085 dprintk("Enable Mpeg mux"); 2069 dprintk("Enable Mpeg mux");
2086 dib7000p_write_word(state, 1287, reg); 2070 dib7000p_write_word(state, 1287, reg);
2087 2071
2088 reg &= ~(1 << 7); // P_restart_mpegMux = 0 2072 reg &= ~(1 << 7);
2089 dib7000p_write_word(state, 1287, reg); 2073 dib7000p_write_word(state, 1287, reg);
2090 2074
2091 reg = (1 << 4); //P_enMpegMuxOnHostBus = 1 2075 reg = (1 << 4);
2092 dib7000p_write_word(state, 1288, reg); 2076 dib7000p_write_word(state, 1288, reg);
2093 2077
2094 return 0; 2078 return 0;
@@ -2099,10 +2083,10 @@ static int dib7090_disableMpegMux(struct dib7000p_state *state)
2099 u16 reg; 2083 u16 reg;
2100 2084
2101 dprintk("Disable Mpeg mux"); 2085 dprintk("Disable Mpeg mux");
2102 dib7000p_write_word(state, 1288, 0); //P_enMpegMuxOnHostBus = 0 2086 dib7000p_write_word(state, 1288, 0);
2103 2087
2104 reg = dib7000p_read_word(state, 1287); 2088 reg = dib7000p_read_word(state, 1287);
2105 reg &= ~(1 << 7); // P_restart_mpegMux = 0 2089 reg &= ~(1 << 7);
2106 dib7000p_write_word(state, 1287, reg); 2090 dib7000p_write_word(state, 1287, reg);
2107 2091
2108 return 0; 2092 return 0;
@@ -2112,19 +2096,19 @@ static int dib7090_set_input_mode(struct dvb_frontend *fe, int mode)
2112{ 2096{
2113 struct dib7000p_state *state = fe->demodulator_priv; 2097 struct dib7000p_state *state = fe->demodulator_priv;
2114 2098
2115 switch(mode) { 2099 switch (mode) {
2116 case INPUT_MODE_DIVERSITY: 2100 case INPUT_MODE_DIVERSITY:
2117 dprintk("Enable diversity INPUT"); 2101 dprintk("Enable diversity INPUT");
2118 dib7090_cfg_DibRx(state, 5,5,0,0,0,0,0); 2102 dib7090_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0);
2119 break; 2103 break;
2120 case INPUT_MODE_MPEG: 2104 case INPUT_MODE_MPEG:
2121 dprintk("Enable Mpeg INPUT"); 2105 dprintk("Enable Mpeg INPUT");
2122 dib7090_cfg_DibRx(state, 8,5,0,0,0,8,0); /*outputRate = 8 */ 2106 dib7090_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0); /*outputRate = 8 */
2123 break; 2107 break;
2124 case INPUT_MODE_OFF: 2108 case INPUT_MODE_OFF:
2125 default: 2109 default:
2126 dprintk("Disable INPUT"); 2110 dprintk("Disable INPUT");
2127 dib7090_cfg_DibRx(state, 0,0,0,0,0,0,0); 2111 dib7090_cfg_DibRx(state, 0, 0, 0, 0, 0, 0, 0);
2128 break; 2112 break;
2129 } 2113 }
2130 return 0; 2114 return 0;
@@ -2175,7 +2159,7 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode)
2175 } else { /* Use Smooth block */ 2159 } else { /* Use Smooth block */
2176 dprintk("Sip 7090P setting output mode TS_SERIAL using Smooth bloc"); 2160 dprintk("Sip 7090P setting output mode TS_SERIAL using Smooth bloc");
2177 dib7090_disableMpegMux(state); 2161 dib7090_disableMpegMux(state);
2178 dib7000p_write_word(state, 1288, (1 << 6)); //P_enDemOutInterfOnHostBus = 1 2162 dib7000p_write_word(state, 1288, (1 << 6));
2179 outreg |= (2 << 6) | (0 << 1); 2163 outreg |= (2 << 6) | (0 << 1);
2180 } 2164 }
2181 break; 2165 break;
@@ -2190,7 +2174,7 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode)
2190 } else { /* Use Smooth block */ 2174 } else { /* Use Smooth block */
2191 dprintk("Sip 7090P setting output mode TS_PARALLEL_GATED using Smooth block"); 2175 dprintk("Sip 7090P setting output mode TS_PARALLEL_GATED using Smooth block");
2192 dib7090_disableMpegMux(state); 2176 dib7090_disableMpegMux(state);
2193 dib7000p_write_word(state, 1288, (1 << 6)); //P_enDemOutInterfOnHostBus = 1 2177 dib7000p_write_word(state, 1288, (1 << 6));
2194 outreg |= (0 << 6); 2178 outreg |= (0 << 6);
2195 } 2179 }
2196 break; 2180 break;
@@ -2198,14 +2182,14 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode)
2198 case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */ 2182 case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */
2199 dprintk("Sip 7090P setting output mode TS_PARALLEL_CONT using Smooth block"); 2183 dprintk("Sip 7090P setting output mode TS_PARALLEL_CONT using Smooth block");
2200 dib7090_disableMpegMux(state); 2184 dib7090_disableMpegMux(state);
2201 dib7000p_write_word(state, 1288, (1 << 6)); //P_enDemOutInterfOnHostBus = 1 2185 dib7000p_write_word(state, 1288, (1 << 6));
2202 outreg |= (1 << 6); 2186 outreg |= (1 << 6);
2203 break; 2187 break;
2204 2188
2205 case OUTMODE_MPEG2_FIFO: /* Using Smooth block because not supported by new Mpeg Mux bloc */ 2189 case OUTMODE_MPEG2_FIFO: /* Using Smooth block because not supported by new Mpeg Mux bloc */
2206 dprintk("Sip 7090P setting output mode TS_FIFO using Smooth block"); 2190 dprintk("Sip 7090P setting output mode TS_FIFO using Smooth block");
2207 dib7090_disableMpegMux(state); 2191 dib7090_disableMpegMux(state);
2208 dib7000p_write_word(state, 1288, (1 << 6)); //P_enDemOutInterfOnHostBus = 1 2192 dib7000p_write_word(state, 1288, (1 << 6));
2209 outreg |= (5 << 6); 2193 outreg |= (5 << 6);
2210 smo_mode |= (3 << 1); 2194 smo_mode |= (3 << 1);
2211 fifo_threshold = 512; 2195 fifo_threshold = 512;
@@ -2242,12 +2226,11 @@ int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff)
2242 2226
2243 en_cur_state = dib7000p_read_word(state, 1922); 2227 en_cur_state = dib7000p_read_word(state, 1922);
2244 2228
2245 if (en_cur_state > 0xff) { //LNAs and MIX are ON and therefore it is a valid configuration 2229 if (en_cur_state > 0xff)
2246 state->tuner_enable = en_cur_state; 2230 state->tuner_enable = en_cur_state;
2247 }
2248 2231
2249 if (onoff) 2232 if (onoff)
2250 en_cur_state &= 0x00ff; //Mask to be applied 2233 en_cur_state &= 0x00ff;
2251 else { 2234 else {
2252 if (state->tuner_enable != 0) 2235 if (state->tuner_enable != 0)
2253 en_cur_state = state->tuner_enable; 2236 en_cur_state = state->tuner_enable;
@@ -2275,13 +2258,13 @@ EXPORT_SYMBOL(dib7090_get_adc_power);
2275int dib7090_slave_reset(struct dvb_frontend *fe) 2258int dib7090_slave_reset(struct dvb_frontend *fe)
2276{ 2259{
2277 struct dib7000p_state *state = fe->demodulator_priv; 2260 struct dib7000p_state *state = fe->demodulator_priv;
2278 u16 reg; 2261 u16 reg;
2279 2262
2280 reg = dib7000p_read_word(state, 1794); 2263 reg = dib7000p_read_word(state, 1794);
2281 dib7000p_write_word(state, 1794, reg | (4 << 12)); 2264 dib7000p_write_word(state, 1794, reg | (4 << 12));
2282 2265
2283 dib7000p_write_word(state, 1032, 0xffff); 2266 dib7000p_write_word(state, 1032, 0xffff);
2284 return 0; 2267 return 0;
2285} 2268}
2286EXPORT_SYMBOL(dib7090_slave_reset); 2269EXPORT_SYMBOL(dib7090_slave_reset);
2287 2270
@@ -2340,7 +2323,7 @@ struct dvb_frontend *dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr,
2340 2323
2341 return demod; 2324 return demod;
2342 2325
2343 error: 2326error:
2344 kfree(st); 2327 kfree(st);
2345 return NULL; 2328 return NULL;
2346} 2329}