diff options
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/frontends/stv090x.c | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index 6c99a86c8efd..e74419b682d3 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c | |||
@@ -3418,14 +3418,12 @@ static int stv090x_table_lookup(const struct stv090x_tab *tab, int max, int val) | |||
3418 | int res = 0; | 3418 | int res = 0; |
3419 | int min = 0, med; | 3419 | int min = 0, med; |
3420 | 3420 | ||
3421 | if (val < tab[min].read) | 3421 | if ((val >= tab[min].read && val < tab[max].read) || |
3422 | res = tab[min].real; | 3422 | (val >= tab[max].read && val < tab[min].read)) { |
3423 | else if (val >= tab[max].read) | ||
3424 | res = tab[max].real; | ||
3425 | else { | ||
3426 | while ((max - min) > 1) { | 3423 | while ((max - min) > 1) { |
3427 | med = (max + min) / 2; | 3424 | med = (max + min) / 2; |
3428 | if (val >= tab[min].read && val < tab[med].read) | 3425 | if ((val >= tab[min].read && val < tab[med].read) || |
3426 | (val >= tab[med].read && val < tab[min].read)) | ||
3429 | max = med; | 3427 | max = med; |
3430 | else | 3428 | else |
3431 | min = med; | 3429 | min = med; |
@@ -3434,6 +3432,18 @@ static int stv090x_table_lookup(const struct stv090x_tab *tab, int max, int val) | |||
3434 | (tab[max].real - tab[min].real) / | 3432 | (tab[max].real - tab[min].real) / |
3435 | (tab[max].read - tab[min].read)) + | 3433 | (tab[max].read - tab[min].read)) + |
3436 | tab[min].real; | 3434 | tab[min].real; |
3435 | } else { | ||
3436 | if (tab[min].read < tab[max].read) { | ||
3437 | if (val < tab[min].read) | ||
3438 | res = tab[min].real; | ||
3439 | else if (val >= tab[max].read) | ||
3440 | res = tab[max].real; | ||
3441 | } else { | ||
3442 | if (val >= tab[min].read) | ||
3443 | res = tab[min].real; | ||
3444 | else if (val < tab[max].read) | ||
3445 | res = tab[max].real; | ||
3446 | } | ||
3437 | } | 3447 | } |
3438 | 3448 | ||
3439 | return res; | 3449 | return res; |
@@ -3443,16 +3453,22 @@ static int stv090x_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
3443 | { | 3453 | { |
3444 | struct stv090x_state *state = fe->demodulator_priv; | 3454 | struct stv090x_state *state = fe->demodulator_priv; |
3445 | u32 reg; | 3455 | u32 reg; |
3446 | s32 agc; | 3456 | s32 agc_0, agc_1, agc; |
3457 | s32 str; | ||
3447 | 3458 | ||
3448 | reg = STV090x_READ_DEMOD(state, AGCIQIN1); | 3459 | reg = STV090x_READ_DEMOD(state, AGCIQIN1); |
3449 | agc = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); | 3460 | agc_1 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); |
3461 | reg = STV090x_READ_DEMOD(state, AGCIQIN0); | ||
3462 | agc_0 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD); | ||
3463 | agc = MAKEWORD16(agc_1, agc_0); | ||
3450 | 3464 | ||
3451 | *strength = stv090x_table_lookup(stv090x_rf_tab, ARRAY_SIZE(stv090x_rf_tab) - 1, agc); | 3465 | str = stv090x_table_lookup(stv090x_rf_tab, |
3466 | ARRAY_SIZE(stv090x_rf_tab) - 1, agc); | ||
3452 | if (agc > stv090x_rf_tab[0].read) | 3467 | if (agc > stv090x_rf_tab[0].read) |
3453 | *strength = 5; | 3468 | str = 0; |
3454 | else if (agc < stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read) | 3469 | else if (agc < stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read) |
3455 | *strength = -100; | 3470 | str = -100; |
3471 | *strength = (str + 100) * 0xFFFF / 100; | ||
3456 | 3472 | ||
3457 | return 0; | 3473 | return 0; |
3458 | } | 3474 | } |
@@ -3463,6 +3479,8 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) | |||
3463 | u32 reg_0, reg_1, reg, i; | 3479 | u32 reg_0, reg_1, reg, i; |
3464 | s32 val_0, val_1, val = 0; | 3480 | s32 val_0, val_1, val = 0; |
3465 | u8 lock_f; | 3481 | u8 lock_f; |
3482 | s32 div; | ||
3483 | u32 last; | ||
3466 | 3484 | ||
3467 | switch (state->delsys) { | 3485 | switch (state->delsys) { |
3468 | case STV090x_DVBS2: | 3486 | case STV090x_DVBS2: |
@@ -3474,14 +3492,15 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) | |||
3474 | reg_1 = STV090x_READ_DEMOD(state, NNOSPLHT1); | 3492 | reg_1 = STV090x_READ_DEMOD(state, NNOSPLHT1); |
3475 | val_1 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD); | 3493 | val_1 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD); |
3476 | reg_0 = STV090x_READ_DEMOD(state, NNOSPLHT0); | 3494 | reg_0 = STV090x_READ_DEMOD(state, NNOSPLHT0); |
3477 | val_0 = STV090x_GETFIELD_Px(reg_1, NOSPLHT_NORMED_FIELD); | 3495 | val_0 = STV090x_GETFIELD_Px(reg_0, NOSPLHT_NORMED_FIELD); |
3478 | val += MAKEWORD16(val_1, val_0); | 3496 | val += MAKEWORD16(val_1, val_0); |
3479 | msleep(1); | 3497 | msleep(1); |
3480 | } | 3498 | } |
3481 | val /= 16; | 3499 | val /= 16; |
3482 | *cnr = stv090x_table_lookup(stv090x_s2cn_tab, ARRAY_SIZE(stv090x_s2cn_tab) - 1, val); | 3500 | last = ARRAY_SIZE(stv090x_s2cn_tab) - 1; |
3483 | if (val < stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s2cn_tab) - 1].read) | 3501 | div = stv090x_s2cn_tab[0].read - |
3484 | *cnr = 1000; | 3502 | stv090x_s2cn_tab[last].read; |
3503 | *cnr = 0xFFFF - ((val * 0xFFFF) / div); | ||
3485 | } | 3504 | } |
3486 | break; | 3505 | break; |
3487 | 3506 | ||
@@ -3495,14 +3514,15 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr) | |||
3495 | reg_1 = STV090x_READ_DEMOD(state, NOSDATAT1); | 3514 | reg_1 = STV090x_READ_DEMOD(state, NOSDATAT1); |
3496 | val_1 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD); | 3515 | val_1 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD); |
3497 | reg_0 = STV090x_READ_DEMOD(state, NOSDATAT0); | 3516 | reg_0 = STV090x_READ_DEMOD(state, NOSDATAT0); |
3498 | val_0 = STV090x_GETFIELD_Px(reg_1, NOSDATAT_UNNORMED_FIELD); | 3517 | val_0 = STV090x_GETFIELD_Px(reg_0, NOSDATAT_UNNORMED_FIELD); |
3499 | val += MAKEWORD16(val_1, val_0); | 3518 | val += MAKEWORD16(val_1, val_0); |
3500 | msleep(1); | 3519 | msleep(1); |
3501 | } | 3520 | } |
3502 | val /= 16; | 3521 | val /= 16; |
3503 | *cnr = stv090x_table_lookup(stv090x_s1cn_tab, ARRAY_SIZE(stv090x_s1cn_tab) - 1, val); | 3522 | last = ARRAY_SIZE(stv090x_s1cn_tab) - 1; |
3504 | if (val < stv090x_s2cn_tab[ARRAY_SIZE(stv090x_s1cn_tab) - 1].read) | 3523 | div = stv090x_s1cn_tab[0].read - |
3505 | *cnr = 1000; | 3524 | stv090x_s1cn_tab[last].read; |
3525 | *cnr = 0xFFFF - ((val * 0xFFFF) / div); | ||
3506 | } | 3526 | } |
3507 | break; | 3527 | break; |
3508 | default: | 3528 | default: |