signed-off-by: Hartmut Birr - The uncorrected block counter shouldn't be reset on read. The tda10021 contains an uncorrected block counter, which has only a resoltion of 7 bits and which isn't able wrap to zero. The driver must manage the block counter by itself. diff -r 4c4fd6b8755c linux/drivers/media/dvb/frontends/tda10021.c --- a/linux/drivers/media/dvb/frontends/tda10021.c Fri May 02 07:51:27 2008 -0300 +++ b/linux/drivers/media/dvb/frontends/tda10021.c Sat May 03 18:55:09 2008 +0200 @@ -41,6 +41,8 @@ struct tda10021_state { u8 pwm; u8 reg0; + u8 last_lock : 1; + u32 ucblocks; }; @@ -266,6 +268,10 @@ static int tda10021_set_parameters (stru tda10021_setup_reg0 (state, reg0x00[qam], p->inversion); + /* reset uncorrected block counter */ + state->last_lock = 0; + state->ucblocks = 0; + return 0; } @@ -273,6 +279,7 @@ static int tda10021_read_status(struct d { struct tda10021_state* state = fe->demodulator_priv; int sync; + u32 ucblocks; *status = 0; //0x11[0] == EQALGO -> Equalizer algorithms state @@ -291,6 +298,22 @@ static int tda10021_read_status(struct d if (sync & 8) *status |= FE_HAS_LOCK; + /* read uncorrected block counter */ + ucblocks = tda10021_readreg(state, 0x13) & 0x7f; + + /* reset uncorrected block counter */ + _tda10021_writereg(state, 0x10, tda10021_inittab[0x10] & 0xdf); + _tda10021_writereg(state, 0x10, tda10021_inittab[0x10]); + + if (sync & 8) { + if (state->last_lock) + /* update ucblocks */ + state->ucblocks += ucblocks; + state->last_lock = 1; + } else { + state->last_lock = 0; + } + return 0; } @@ -335,14 +358,10 @@ static int tda10021_read_ucblocks(struct static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) { struct tda10021_state* state = fe->demodulator_priv; - - *ucblocks = tda10021_readreg (state, 0x13) & 0x7f; - if (*ucblocks == 0x7f) - *ucblocks = 0xffffffff; - - /* reset uncorrected block counter */ - _tda10021_writereg (state, 0x10, tda10021_inittab[0x10] & 0xdf); - _tda10021_writereg (state, 0x10, tda10021_inittab[0x10]); + fe_status_t status; + + tda10021_read_status(fe, &status); + *ucblocks = state->ucblocks; return 0; }