diff options
-rw-r--r-- | drivers/media/dvb/frontends/tda10048.c | 78 |
1 files changed, 32 insertions, 46 deletions
diff --git a/drivers/media/dvb/frontends/tda10048.c b/drivers/media/dvb/frontends/tda10048.c index bba249bd4e2e..80de9f602d37 100644 --- a/drivers/media/dvb/frontends/tda10048.c +++ b/drivers/media/dvb/frontends/tda10048.c | |||
@@ -341,21 +341,14 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, | |||
341 | { | 341 | { |
342 | struct tda10048_state *state = fe->demodulator_priv; | 342 | struct tda10048_state *state = fe->demodulator_priv; |
343 | u64 t, z; | 343 | u64 t, z; |
344 | u32 b = 8000000; | ||
345 | 344 | ||
346 | dprintk(1, "%s()\n", __func__); | 345 | dprintk(1, "%s()\n", __func__); |
347 | 346 | ||
348 | if (sample_freq_hz == 0) | 347 | if (sample_freq_hz == 0) |
349 | return -EINVAL; | 348 | return -EINVAL; |
350 | 349 | ||
351 | if (bw == BANDWIDTH_6_MHZ) | ||
352 | b = 6000000; | ||
353 | else | ||
354 | if (bw == BANDWIDTH_7_MHZ) | ||
355 | b = 7000000; | ||
356 | |||
357 | /* WREF = (B / (7 * fs)) * 2^31 */ | 350 | /* WREF = (B / (7 * fs)) * 2^31 */ |
358 | t = b * 10; | 351 | t = bw * 10; |
359 | /* avoid warning: this decimal constant is unsigned only in ISO C90 */ | 352 | /* avoid warning: this decimal constant is unsigned only in ISO C90 */ |
360 | /* t *= 2147483648 on 32bit platforms */ | 353 | /* t *= 2147483648 on 32bit platforms */ |
361 | t *= (2048 * 1024); | 354 | t *= (2048 * 1024); |
@@ -378,25 +371,18 @@ static int tda10048_set_invwref(struct dvb_frontend *fe, u32 sample_freq_hz, | |||
378 | { | 371 | { |
379 | struct tda10048_state *state = fe->demodulator_priv; | 372 | struct tda10048_state *state = fe->demodulator_priv; |
380 | u64 t; | 373 | u64 t; |
381 | u32 b = 8000000; | ||
382 | 374 | ||
383 | dprintk(1, "%s()\n", __func__); | 375 | dprintk(1, "%s()\n", __func__); |
384 | 376 | ||
385 | if (sample_freq_hz == 0) | 377 | if (sample_freq_hz == 0) |
386 | return -EINVAL; | 378 | return -EINVAL; |
387 | 379 | ||
388 | if (bw == BANDWIDTH_6_MHZ) | ||
389 | b = 6000000; | ||
390 | else | ||
391 | if (bw == BANDWIDTH_7_MHZ) | ||
392 | b = 7000000; | ||
393 | |||
394 | /* INVWREF = ((7 * fs) / B) * 2^5 */ | 380 | /* INVWREF = ((7 * fs) / B) * 2^5 */ |
395 | t = sample_freq_hz; | 381 | t = sample_freq_hz; |
396 | t *= 7; | 382 | t *= 7; |
397 | t *= 32; | 383 | t *= 32; |
398 | t *= 10; | 384 | t *= 10; |
399 | do_div(t, b); | 385 | do_div(t, bw); |
400 | t += 5; | 386 | t += 5; |
401 | do_div(t, 10); | 387 | do_div(t, 10); |
402 | 388 | ||
@@ -407,16 +393,16 @@ static int tda10048_set_invwref(struct dvb_frontend *fe, u32 sample_freq_hz, | |||
407 | } | 393 | } |
408 | 394 | ||
409 | static int tda10048_set_bandwidth(struct dvb_frontend *fe, | 395 | static int tda10048_set_bandwidth(struct dvb_frontend *fe, |
410 | enum fe_bandwidth bw) | 396 | u32 bw) |
411 | { | 397 | { |
412 | struct tda10048_state *state = fe->demodulator_priv; | 398 | struct tda10048_state *state = fe->demodulator_priv; |
413 | dprintk(1, "%s(bw=%d)\n", __func__, bw); | 399 | dprintk(1, "%s(bw=%d)\n", __func__, bw); |
414 | 400 | ||
415 | /* Bandwidth setting may need to be adjusted */ | 401 | /* Bandwidth setting may need to be adjusted */ |
416 | switch (bw) { | 402 | switch (bw) { |
417 | case BANDWIDTH_6_MHZ: | 403 | case 6000000: |
418 | case BANDWIDTH_7_MHZ: | 404 | case 7000000: |
419 | case BANDWIDTH_8_MHZ: | 405 | case 8000000: |
420 | tda10048_set_wref(fe, state->sample_freq, bw); | 406 | tda10048_set_wref(fe, state->sample_freq, bw); |
421 | tda10048_set_invwref(fe, state->sample_freq, bw); | 407 | tda10048_set_invwref(fe, state->sample_freq, bw); |
422 | break; | 408 | break; |
@@ -430,7 +416,7 @@ static int tda10048_set_bandwidth(struct dvb_frontend *fe, | |||
430 | return 0; | 416 | return 0; |
431 | } | 417 | } |
432 | 418 | ||
433 | static int tda10048_set_if(struct dvb_frontend *fe, enum fe_bandwidth bw) | 419 | static int tda10048_set_if(struct dvb_frontend *fe, u32 bw) |
434 | { | 420 | { |
435 | struct tda10048_state *state = fe->demodulator_priv; | 421 | struct tda10048_state *state = fe->demodulator_priv; |
436 | struct tda10048_config *config = &state->config; | 422 | struct tda10048_config *config = &state->config; |
@@ -441,13 +427,13 @@ static int tda10048_set_if(struct dvb_frontend *fe, enum fe_bandwidth bw) | |||
441 | 427 | ||
442 | /* based on target bandwidth and clk we calculate pll factors */ | 428 | /* based on target bandwidth and clk we calculate pll factors */ |
443 | switch (bw) { | 429 | switch (bw) { |
444 | case BANDWIDTH_6_MHZ: | 430 | case 6000000: |
445 | if_freq_khz = config->dtv6_if_freq_khz; | 431 | if_freq_khz = config->dtv6_if_freq_khz; |
446 | break; | 432 | break; |
447 | case BANDWIDTH_7_MHZ: | 433 | case 7000000: |
448 | if_freq_khz = config->dtv7_if_freq_khz; | 434 | if_freq_khz = config->dtv7_if_freq_khz; |
449 | break; | 435 | break; |
450 | case BANDWIDTH_8_MHZ: | 436 | case 8000000: |
451 | if_freq_khz = config->dtv8_if_freq_khz; | 437 | if_freq_khz = config->dtv8_if_freq_khz; |
452 | break; | 438 | break; |
453 | default: | 439 | default: |
@@ -601,7 +587,7 @@ static int tda10048_set_inversion(struct dvb_frontend *fe, int inversion) | |||
601 | 587 | ||
602 | /* Retrieve the demod settings */ | 588 | /* Retrieve the demod settings */ |
603 | static int tda10048_get_tps(struct tda10048_state *state, | 589 | static int tda10048_get_tps(struct tda10048_state *state, |
604 | struct dvb_ofdm_parameters *p) | 590 | struct dtv_frontend_properties *p) |
605 | { | 591 | { |
606 | u8 val; | 592 | u8 val; |
607 | 593 | ||
@@ -612,27 +598,27 @@ static int tda10048_get_tps(struct tda10048_state *state, | |||
612 | val = tda10048_readreg(state, TDA10048_OUT_CONF2); | 598 | val = tda10048_readreg(state, TDA10048_OUT_CONF2); |
613 | switch ((val & 0x60) >> 5) { | 599 | switch ((val & 0x60) >> 5) { |
614 | case 0: | 600 | case 0: |
615 | p->constellation = QPSK; | 601 | p->modulation = QPSK; |
616 | break; | 602 | break; |
617 | case 1: | 603 | case 1: |
618 | p->constellation = QAM_16; | 604 | p->modulation = QAM_16; |
619 | break; | 605 | break; |
620 | case 2: | 606 | case 2: |
621 | p->constellation = QAM_64; | 607 | p->modulation = QAM_64; |
622 | break; | 608 | break; |
623 | } | 609 | } |
624 | switch ((val & 0x18) >> 3) { | 610 | switch ((val & 0x18) >> 3) { |
625 | case 0: | 611 | case 0: |
626 | p->hierarchy_information = HIERARCHY_NONE; | 612 | p->hierarchy = HIERARCHY_NONE; |
627 | break; | 613 | break; |
628 | case 1: | 614 | case 1: |
629 | p->hierarchy_information = HIERARCHY_1; | 615 | p->hierarchy = HIERARCHY_1; |
630 | break; | 616 | break; |
631 | case 2: | 617 | case 2: |
632 | p->hierarchy_information = HIERARCHY_2; | 618 | p->hierarchy = HIERARCHY_2; |
633 | break; | 619 | break; |
634 | case 3: | 620 | case 3: |
635 | p->hierarchy_information = HIERARCHY_4; | 621 | p->hierarchy = HIERARCHY_4; |
636 | break; | 622 | break; |
637 | } | 623 | } |
638 | switch (val & 0x07) { | 624 | switch (val & 0x07) { |
@@ -738,17 +724,17 @@ static int tda10048_output_mode(struct dvb_frontend *fe, int serial) | |||
738 | 724 | ||
739 | /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ | 725 | /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ |
740 | /* TODO: Support manual tuning with specific params */ | 726 | /* TODO: Support manual tuning with specific params */ |
741 | static int tda10048_set_frontend(struct dvb_frontend *fe, | 727 | static int tda10048_set_frontend(struct dvb_frontend *fe) |
742 | struct dvb_frontend_parameters *p) | ||
743 | { | 728 | { |
729 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; | ||
744 | struct tda10048_state *state = fe->demodulator_priv; | 730 | struct tda10048_state *state = fe->demodulator_priv; |
745 | 731 | ||
746 | dprintk(1, "%s(frequency=%d)\n", __func__, p->frequency); | 732 | dprintk(1, "%s(frequency=%d)\n", __func__, p->frequency); |
747 | 733 | ||
748 | /* Update the I/F pll's if the bandwidth changes */ | 734 | /* Update the I/F pll's if the bandwidth changes */ |
749 | if (p->u.ofdm.bandwidth != state->bandwidth) { | 735 | if (p->bandwidth_hz != state->bandwidth) { |
750 | tda10048_set_if(fe, p->u.ofdm.bandwidth); | 736 | tda10048_set_if(fe, p->bandwidth_hz); |
751 | tda10048_set_bandwidth(fe, p->u.ofdm.bandwidth); | 737 | tda10048_set_bandwidth(fe, p->bandwidth_hz); |
752 | } | 738 | } |
753 | 739 | ||
754 | if (fe->ops.tuner_ops.set_params) { | 740 | if (fe->ops.tuner_ops.set_params) { |
@@ -797,8 +783,8 @@ static int tda10048_init(struct dvb_frontend *fe) | |||
797 | tda10048_set_inversion(fe, config->inversion); | 783 | tda10048_set_inversion(fe, config->inversion); |
798 | 784 | ||
799 | /* Establish default RF values */ | 785 | /* Establish default RF values */ |
800 | tda10048_set_if(fe, BANDWIDTH_8_MHZ); | 786 | tda10048_set_if(fe, 8000000); |
801 | tda10048_set_bandwidth(fe, BANDWIDTH_8_MHZ); | 787 | tda10048_set_bandwidth(fe, 8000000); |
802 | 788 | ||
803 | /* Ensure we leave the gate closed */ | 789 | /* Ensure we leave the gate closed */ |
804 | tda10048_i2c_gate_ctrl(fe, 0); | 790 | tda10048_i2c_gate_ctrl(fe, 0); |
@@ -1043,7 +1029,7 @@ static int tda10048_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
1043 | } | 1029 | } |
1044 | 1030 | ||
1045 | static int tda10048_get_frontend(struct dvb_frontend *fe, | 1031 | static int tda10048_get_frontend(struct dvb_frontend *fe, |
1046 | struct dvb_frontend_parameters *p) | 1032 | struct dtv_frontend_properties *p) |
1047 | { | 1033 | { |
1048 | struct tda10048_state *state = fe->demodulator_priv; | 1034 | struct tda10048_state *state = fe->demodulator_priv; |
1049 | 1035 | ||
@@ -1052,7 +1038,7 @@ static int tda10048_get_frontend(struct dvb_frontend *fe, | |||
1052 | p->inversion = tda10048_readreg(state, TDA10048_CONF_C1_1) | 1038 | p->inversion = tda10048_readreg(state, TDA10048_CONF_C1_1) |
1053 | & 0x20 ? INVERSION_ON : INVERSION_OFF; | 1039 | & 0x20 ? INVERSION_ON : INVERSION_OFF; |
1054 | 1040 | ||
1055 | return tda10048_get_tps(state, &p->u.ofdm); | 1041 | return tda10048_get_tps(state, p); |
1056 | } | 1042 | } |
1057 | 1043 | ||
1058 | static int tda10048_get_tune_settings(struct dvb_frontend *fe, | 1044 | static int tda10048_get_tune_settings(struct dvb_frontend *fe, |
@@ -1126,7 +1112,7 @@ struct dvb_frontend *tda10048_attach(const struct tda10048_config *config, | |||
1126 | memcpy(&state->config, config, sizeof(*config)); | 1112 | memcpy(&state->config, config, sizeof(*config)); |
1127 | state->i2c = i2c; | 1113 | state->i2c = i2c; |
1128 | state->fwloaded = config->no_firmware; | 1114 | state->fwloaded = config->no_firmware; |
1129 | state->bandwidth = BANDWIDTH_8_MHZ; | 1115 | state->bandwidth = 8000000; |
1130 | 1116 | ||
1131 | /* check if the demod is present */ | 1117 | /* check if the demod is present */ |
1132 | if (tda10048_readreg(state, TDA10048_IDENTITY) != 0x048) | 1118 | if (tda10048_readreg(state, TDA10048_IDENTITY) != 0x048) |
@@ -1152,11 +1138,11 @@ struct dvb_frontend *tda10048_attach(const struct tda10048_config *config, | |||
1152 | tda10048_establish_defaults(&state->frontend); | 1138 | tda10048_establish_defaults(&state->frontend); |
1153 | 1139 | ||
1154 | /* Set the xtal and freq defaults */ | 1140 | /* Set the xtal and freq defaults */ |
1155 | if (tda10048_set_if(&state->frontend, BANDWIDTH_8_MHZ) != 0) | 1141 | if (tda10048_set_if(&state->frontend, 8000000) != 0) |
1156 | goto error; | 1142 | goto error; |
1157 | 1143 | ||
1158 | /* Default bandwidth */ | 1144 | /* Default bandwidth */ |
1159 | if (tda10048_set_bandwidth(&state->frontend, BANDWIDTH_8_MHZ) != 0) | 1145 | if (tda10048_set_bandwidth(&state->frontend, 8000000) != 0) |
1160 | goto error; | 1146 | goto error; |
1161 | 1147 | ||
1162 | /* Leave the gate closed */ | 1148 | /* Leave the gate closed */ |
@@ -1188,8 +1174,8 @@ static struct dvb_frontend_ops tda10048_ops = { | |||
1188 | .release = tda10048_release, | 1174 | .release = tda10048_release, |
1189 | .init = tda10048_init, | 1175 | .init = tda10048_init, |
1190 | .i2c_gate_ctrl = tda10048_i2c_gate_ctrl, | 1176 | .i2c_gate_ctrl = tda10048_i2c_gate_ctrl, |
1191 | .set_frontend_legacy = tda10048_set_frontend, | 1177 | .set_frontend = tda10048_set_frontend, |
1192 | .get_frontend_legacy = tda10048_get_frontend, | 1178 | .get_frontend = tda10048_get_frontend, |
1193 | .get_tune_settings = tda10048_get_tune_settings, | 1179 | .get_tune_settings = tda10048_get_tune_settings, |
1194 | .read_status = tda10048_read_status, | 1180 | .read_status = tda10048_read_status, |
1195 | .read_ber = tda10048_read_ber, | 1181 | .read_ber = tda10048_read_ber, |