aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/dib3000mb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/dib3000mb.c')
-rw-r--r--drivers/media/dvb/frontends/dib3000mb.c113
1 files changed, 54 insertions, 59 deletions
diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c
index 437904cbf3e6..af91e0c92339 100644
--- a/drivers/media/dvb/frontends/dib3000mb.c
+++ b/drivers/media/dvb/frontends/dib3000mb.c
@@ -112,39 +112,37 @@ static u16 dib3000_seq[2][2][2] = /* fft,gua, inv */
112 } 112 }
113 }; 113 };
114 114
115static int dib3000mb_get_frontend(struct dvb_frontend* fe, 115static int dib3000mb_get_frontend(struct dvb_frontend* fe);
116 struct dvb_frontend_parameters *fep);
117 116
118static int dib3000mb_set_frontend(struct dvb_frontend* fe, 117static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
119 struct dvb_frontend_parameters *fep, int tuner)
120{ 118{
121 struct dib3000_state* state = fe->demodulator_priv; 119 struct dib3000_state* state = fe->demodulator_priv;
122 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm; 120 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
123 fe_code_rate_t fe_cr = FEC_NONE; 121 fe_code_rate_t fe_cr = FEC_NONE;
124 int search_state, seq; 122 int search_state, seq;
125 123
126 if (tuner && fe->ops.tuner_ops.set_params) { 124 if (tuner && fe->ops.tuner_ops.set_params) {
127 fe->ops.tuner_ops.set_params(fe, fep); 125 fe->ops.tuner_ops.set_params(fe);
128 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); 126 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
129 127
130 deb_setf("bandwidth: "); 128 deb_setf("bandwidth: ");
131 switch (ofdm->bandwidth) { 129 switch (c->bandwidth_hz) {
132 case BANDWIDTH_8_MHZ: 130 case 8000000:
133 deb_setf("8 MHz\n"); 131 deb_setf("8 MHz\n");
134 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]); 132 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]);
135 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz); 133 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz);
136 break; 134 break;
137 case BANDWIDTH_7_MHZ: 135 case 7000000:
138 deb_setf("7 MHz\n"); 136 deb_setf("7 MHz\n");
139 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[1]); 137 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[1]);
140 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_7mhz); 138 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_7mhz);
141 break; 139 break;
142 case BANDWIDTH_6_MHZ: 140 case 6000000:
143 deb_setf("6 MHz\n"); 141 deb_setf("6 MHz\n");
144 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[0]); 142 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[0]);
145 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_6mhz); 143 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_6mhz);
146 break; 144 break;
147 case BANDWIDTH_AUTO: 145 case 0:
148 return -EOPNOTSUPP; 146 return -EOPNOTSUPP;
149 default: 147 default:
150 err("unknown bandwidth value."); 148 err("unknown bandwidth value.");
@@ -154,7 +152,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
154 wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4); 152 wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4);
155 153
156 deb_setf("transmission mode: "); 154 deb_setf("transmission mode: ");
157 switch (ofdm->transmission_mode) { 155 switch (c->transmission_mode) {
158 case TRANSMISSION_MODE_2K: 156 case TRANSMISSION_MODE_2K:
159 deb_setf("2k\n"); 157 deb_setf("2k\n");
160 wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K); 158 wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K);
@@ -171,7 +169,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
171 } 169 }
172 170
173 deb_setf("guard: "); 171 deb_setf("guard: ");
174 switch (ofdm->guard_interval) { 172 switch (c->guard_interval) {
175 case GUARD_INTERVAL_1_32: 173 case GUARD_INTERVAL_1_32:
176 deb_setf("1_32\n"); 174 deb_setf("1_32\n");
177 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32); 175 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32);
@@ -196,7 +194,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
196 } 194 }
197 195
198 deb_setf("inversion: "); 196 deb_setf("inversion: ");
199 switch (fep->inversion) { 197 switch (c->inversion) {
200 case INVERSION_OFF: 198 case INVERSION_OFF:
201 deb_setf("off\n"); 199 deb_setf("off\n");
202 wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF); 200 wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF);
@@ -212,8 +210,8 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
212 return -EINVAL; 210 return -EINVAL;
213 } 211 }
214 212
215 deb_setf("constellation: "); 213 deb_setf("modulation: ");
216 switch (ofdm->constellation) { 214 switch (c->modulation) {
217 case QPSK: 215 case QPSK:
218 deb_setf("qpsk\n"); 216 deb_setf("qpsk\n");
219 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK); 217 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK);
@@ -232,7 +230,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
232 return -EINVAL; 230 return -EINVAL;
233 } 231 }
234 deb_setf("hierarchy: "); 232 deb_setf("hierarchy: ");
235 switch (ofdm->hierarchy_information) { 233 switch (c->hierarchy) {
236 case HIERARCHY_NONE: 234 case HIERARCHY_NONE:
237 deb_setf("none "); 235 deb_setf("none ");
238 /* fall through */ 236 /* fall through */
@@ -256,16 +254,16 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
256 } 254 }
257 255
258 deb_setf("hierarchy: "); 256 deb_setf("hierarchy: ");
259 if (ofdm->hierarchy_information == HIERARCHY_NONE) { 257 if (c->hierarchy == HIERARCHY_NONE) {
260 deb_setf("none\n"); 258 deb_setf("none\n");
261 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF); 259 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF);
262 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP); 260 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP);
263 fe_cr = ofdm->code_rate_HP; 261 fe_cr = c->code_rate_HP;
264 } else if (ofdm->hierarchy_information != HIERARCHY_AUTO) { 262 } else if (c->hierarchy != HIERARCHY_AUTO) {
265 deb_setf("on\n"); 263 deb_setf("on\n");
266 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON); 264 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON);
267 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP); 265 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP);
268 fe_cr = ofdm->code_rate_LP; 266 fe_cr = c->code_rate_LP;
269 } 267 }
270 deb_setf("fec: "); 268 deb_setf("fec: ");
271 switch (fe_cr) { 269 switch (fe_cr) {
@@ -300,9 +298,9 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
300 } 298 }
301 299
302 seq = dib3000_seq 300 seq = dib3000_seq
303 [ofdm->transmission_mode == TRANSMISSION_MODE_AUTO] 301 [c->transmission_mode == TRANSMISSION_MODE_AUTO]
304 [ofdm->guard_interval == GUARD_INTERVAL_AUTO] 302 [c->guard_interval == GUARD_INTERVAL_AUTO]
305 [fep->inversion == INVERSION_AUTO]; 303 [c->inversion == INVERSION_AUTO];
306 304
307 deb_setf("seq? %d\n", seq); 305 deb_setf("seq? %d\n", seq);
308 306
@@ -310,8 +308,8 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
310 308
311 wr(DIB3000MB_REG_ISI, seq ? DIB3000MB_ISI_INHIBIT : DIB3000MB_ISI_ACTIVATE); 309 wr(DIB3000MB_REG_ISI, seq ? DIB3000MB_ISI_INHIBIT : DIB3000MB_ISI_ACTIVATE);
312 310
313 if (ofdm->transmission_mode == TRANSMISSION_MODE_2K) { 311 if (c->transmission_mode == TRANSMISSION_MODE_2K) {
314 if (ofdm->guard_interval == GUARD_INTERVAL_1_8) { 312 if (c->guard_interval == GUARD_INTERVAL_1_8) {
315 wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_2K_1_8); 313 wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_2K_1_8);
316 } else { 314 } else {
317 wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_DEFAULT); 315 wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_DEFAULT);
@@ -339,10 +337,10 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
339 wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_low); 337 wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_low);
340 338
341 /* something has to be auto searched */ 339 /* something has to be auto searched */
342 if (ofdm->constellation == QAM_AUTO || 340 if (c->modulation == QAM_AUTO ||
343 ofdm->hierarchy_information == HIERARCHY_AUTO || 341 c->hierarchy == HIERARCHY_AUTO ||
344 fe_cr == FEC_AUTO || 342 fe_cr == FEC_AUTO ||
345 fep->inversion == INVERSION_AUTO) { 343 c->inversion == INVERSION_AUTO) {
346 int as_count=0; 344 int as_count=0;
347 345
348 deb_setf("autosearch enabled.\n"); 346 deb_setf("autosearch enabled.\n");
@@ -361,10 +359,9 @@ static int dib3000mb_set_frontend(struct dvb_frontend* fe,
361 deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count); 359 deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count);
362 360
363 if (search_state == 1) { 361 if (search_state == 1) {
364 struct dvb_frontend_parameters feps; 362 if (dib3000mb_get_frontend(fe) == 0) {
365 if (dib3000mb_get_frontend(fe, &feps) == 0) {
366 deb_setf("reading tuning data from frontend succeeded.\n"); 363 deb_setf("reading tuning data from frontend succeeded.\n");
367 return dib3000mb_set_frontend(fe, &feps, 0); 364 return dib3000mb_set_frontend(fe, 0);
368 } 365 }
369 } 366 }
370 367
@@ -453,11 +450,10 @@ static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
453 return 0; 450 return 0;
454} 451}
455 452
456static int dib3000mb_get_frontend(struct dvb_frontend* fe, 453static int dib3000mb_get_frontend(struct dvb_frontend* fe)
457 struct dvb_frontend_parameters *fep)
458{ 454{
455 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
459 struct dib3000_state* state = fe->demodulator_priv; 456 struct dib3000_state* state = fe->demodulator_priv;
460 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
461 fe_code_rate_t *cr; 457 fe_code_rate_t *cr;
462 u16 tps_val; 458 u16 tps_val;
463 int inv_test1,inv_test2; 459 int inv_test1,inv_test2;
@@ -484,25 +480,25 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
484 else 480 else
485 inv_test2 = 2; 481 inv_test2 = 2;
486 482
487 fep->inversion = 483 c->inversion =
488 ((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) || 484 ((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) ||
489 ((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ? 485 ((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ?
490 INVERSION_ON : INVERSION_OFF; 486 INVERSION_ON : INVERSION_OFF;
491 487
492 deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, fep->inversion); 488 deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, c->inversion);
493 489
494 switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) { 490 switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) {
495 case DIB3000_CONSTELLATION_QPSK: 491 case DIB3000_CONSTELLATION_QPSK:
496 deb_getf("QPSK "); 492 deb_getf("QPSK ");
497 ofdm->constellation = QPSK; 493 c->modulation = QPSK;
498 break; 494 break;
499 case DIB3000_CONSTELLATION_16QAM: 495 case DIB3000_CONSTELLATION_16QAM:
500 deb_getf("QAM16 "); 496 deb_getf("QAM16 ");
501 ofdm->constellation = QAM_16; 497 c->modulation = QAM_16;
502 break; 498 break;
503 case DIB3000_CONSTELLATION_64QAM: 499 case DIB3000_CONSTELLATION_64QAM:
504 deb_getf("QAM64 "); 500 deb_getf("QAM64 ");
505 ofdm->constellation = QAM_64; 501 c->modulation = QAM_64;
506 break; 502 break;
507 default: 503 default:
508 err("Unexpected constellation returned by TPS (%d)", tps_val); 504 err("Unexpected constellation returned by TPS (%d)", tps_val);
@@ -512,24 +508,24 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
512 508
513 if (rd(DIB3000MB_REG_TPS_HRCH)) { 509 if (rd(DIB3000MB_REG_TPS_HRCH)) {
514 deb_getf("HRCH ON\n"); 510 deb_getf("HRCH ON\n");
515 cr = &ofdm->code_rate_LP; 511 cr = &c->code_rate_LP;
516 ofdm->code_rate_HP = FEC_NONE; 512 c->code_rate_HP = FEC_NONE;
517 switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) { 513 switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) {
518 case DIB3000_ALPHA_0: 514 case DIB3000_ALPHA_0:
519 deb_getf("HIERARCHY_NONE "); 515 deb_getf("HIERARCHY_NONE ");
520 ofdm->hierarchy_information = HIERARCHY_NONE; 516 c->hierarchy = HIERARCHY_NONE;
521 break; 517 break;
522 case DIB3000_ALPHA_1: 518 case DIB3000_ALPHA_1:
523 deb_getf("HIERARCHY_1 "); 519 deb_getf("HIERARCHY_1 ");
524 ofdm->hierarchy_information = HIERARCHY_1; 520 c->hierarchy = HIERARCHY_1;
525 break; 521 break;
526 case DIB3000_ALPHA_2: 522 case DIB3000_ALPHA_2:
527 deb_getf("HIERARCHY_2 "); 523 deb_getf("HIERARCHY_2 ");
528 ofdm->hierarchy_information = HIERARCHY_2; 524 c->hierarchy = HIERARCHY_2;
529 break; 525 break;
530 case DIB3000_ALPHA_4: 526 case DIB3000_ALPHA_4:
531 deb_getf("HIERARCHY_4 "); 527 deb_getf("HIERARCHY_4 ");
532 ofdm->hierarchy_information = HIERARCHY_4; 528 c->hierarchy = HIERARCHY_4;
533 break; 529 break;
534 default: 530 default:
535 err("Unexpected ALPHA value returned by TPS (%d)", tps_val); 531 err("Unexpected ALPHA value returned by TPS (%d)", tps_val);
@@ -540,9 +536,9 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
540 tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_LP); 536 tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_LP);
541 } else { 537 } else {
542 deb_getf("HRCH OFF\n"); 538 deb_getf("HRCH OFF\n");
543 cr = &ofdm->code_rate_HP; 539 cr = &c->code_rate_HP;
544 ofdm->code_rate_LP = FEC_NONE; 540 c->code_rate_LP = FEC_NONE;
545 ofdm->hierarchy_information = HIERARCHY_NONE; 541 c->hierarchy = HIERARCHY_NONE;
546 542
547 tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_HP); 543 tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_HP);
548 } 544 }
@@ -577,19 +573,19 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
577 switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) { 573 switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) {
578 case DIB3000_GUARD_TIME_1_32: 574 case DIB3000_GUARD_TIME_1_32:
579 deb_getf("GUARD_INTERVAL_1_32 "); 575 deb_getf("GUARD_INTERVAL_1_32 ");
580 ofdm->guard_interval = GUARD_INTERVAL_1_32; 576 c->guard_interval = GUARD_INTERVAL_1_32;
581 break; 577 break;
582 case DIB3000_GUARD_TIME_1_16: 578 case DIB3000_GUARD_TIME_1_16:
583 deb_getf("GUARD_INTERVAL_1_16 "); 579 deb_getf("GUARD_INTERVAL_1_16 ");
584 ofdm->guard_interval = GUARD_INTERVAL_1_16; 580 c->guard_interval = GUARD_INTERVAL_1_16;
585 break; 581 break;
586 case DIB3000_GUARD_TIME_1_8: 582 case DIB3000_GUARD_TIME_1_8:
587 deb_getf("GUARD_INTERVAL_1_8 "); 583 deb_getf("GUARD_INTERVAL_1_8 ");
588 ofdm->guard_interval = GUARD_INTERVAL_1_8; 584 c->guard_interval = GUARD_INTERVAL_1_8;
589 break; 585 break;
590 case DIB3000_GUARD_TIME_1_4: 586 case DIB3000_GUARD_TIME_1_4:
591 deb_getf("GUARD_INTERVAL_1_4 "); 587 deb_getf("GUARD_INTERVAL_1_4 ");
592 ofdm->guard_interval = GUARD_INTERVAL_1_4; 588 c->guard_interval = GUARD_INTERVAL_1_4;
593 break; 589 break;
594 default: 590 default:
595 err("Unexpected Guard Time returned by TPS (%d)", tps_val); 591 err("Unexpected Guard Time returned by TPS (%d)", tps_val);
@@ -600,11 +596,11 @@ static int dib3000mb_get_frontend(struct dvb_frontend* fe,
600 switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) { 596 switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) {
601 case DIB3000_TRANSMISSION_MODE_2K: 597 case DIB3000_TRANSMISSION_MODE_2K:
602 deb_getf("TRANSMISSION_MODE_2K "); 598 deb_getf("TRANSMISSION_MODE_2K ");
603 ofdm->transmission_mode = TRANSMISSION_MODE_2K; 599 c->transmission_mode = TRANSMISSION_MODE_2K;
604 break; 600 break;
605 case DIB3000_TRANSMISSION_MODE_8K: 601 case DIB3000_TRANSMISSION_MODE_8K:
606 deb_getf("TRANSMISSION_MODE_8K "); 602 deb_getf("TRANSMISSION_MODE_8K ");
607 ofdm->transmission_mode = TRANSMISSION_MODE_8K; 603 c->transmission_mode = TRANSMISSION_MODE_8K;
608 break; 604 break;
609 default: 605 default:
610 err("unexpected transmission mode return by TPS (%d)", tps_val); 606 err("unexpected transmission mode return by TPS (%d)", tps_val);
@@ -701,9 +697,9 @@ static int dib3000mb_fe_init_nonmobile(struct dvb_frontend* fe)
701 return dib3000mb_fe_init(fe, 0); 697 return dib3000mb_fe_init(fe, 0);
702} 698}
703 699
704static int dib3000mb_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep) 700static int dib3000mb_set_frontend_and_tuner(struct dvb_frontend *fe)
705{ 701{
706 return dib3000mb_set_frontend(fe, fep, 1); 702 return dib3000mb_set_frontend(fe, 1);
707} 703}
708 704
709static void dib3000mb_release(struct dvb_frontend* fe) 705static void dib3000mb_release(struct dvb_frontend* fe)
@@ -794,10 +790,9 @@ error:
794} 790}
795 791
796static struct dvb_frontend_ops dib3000mb_ops = { 792static struct dvb_frontend_ops dib3000mb_ops = {
797 793 .delsys = { SYS_DVBT },
798 .info = { 794 .info = {
799 .name = "DiBcom 3000M-B DVB-T", 795 .name = "DiBcom 3000M-B DVB-T",
800 .type = FE_OFDM,
801 .frequency_min = 44250000, 796 .frequency_min = 44250000,
802 .frequency_max = 867250000, 797 .frequency_max = 867250000,
803 .frequency_stepsize = 62500, 798 .frequency_stepsize = 62500,