diff options
author | Hartmut Birr <e9hack@googlemail.com> | 2007-02-13 16:01:56 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 10:35:32 -0500 |
commit | 90e3bd4ba5563f2a6efbb46ce7e10845329dfffd (patch) | |
tree | 93682f3e888655eba094212e9c0808e9d5b1ec4c /drivers/media/dvb/frontends/stv0297.c | |
parent | 59327a4897a0395d6f0358574dbb113102b63769 (diff) |
V4L/DVB (5247): Stv0297: Enable BER/UNC counting
Enable BER/UNC counting for the stv0297 frontend.
The idea for this patch comes from stv0297_cs.c.
Signed-off-by: Hartmut Birr <e9hack@googlemail.com>
Signed-off-by: Oliver Endriss <o.endriss@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends/stv0297.c')
-rw-r--r-- | drivers/media/dvb/frontends/stv0297.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 1ca64249010c..9a343972ff50 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c | |||
@@ -35,6 +35,7 @@ struct stv0297_state { | |||
35 | const struct stv0297_config *config; | 35 | const struct stv0297_config *config; |
36 | struct dvb_frontend frontend; | 36 | struct dvb_frontend frontend; |
37 | 37 | ||
38 | unsigned long last_ber; | ||
38 | unsigned long base_freq; | 39 | unsigned long base_freq; |
39 | }; | 40 | }; |
40 | 41 | ||
@@ -310,6 +311,8 @@ static int stv0297_init(struct dvb_frontend *fe) | |||
310 | stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]); | 311 | stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]); |
311 | msleep(200); | 312 | msleep(200); |
312 | 313 | ||
314 | state->last_ber = 0; | ||
315 | |||
313 | return 0; | 316 | return 0; |
314 | } | 317 | } |
315 | 318 | ||
@@ -340,11 +343,13 @@ static int stv0297_read_ber(struct dvb_frontend *fe, u32 * ber) | |||
340 | struct stv0297_state *state = fe->demodulator_priv; | 343 | struct stv0297_state *state = fe->demodulator_priv; |
341 | u8 BER[3]; | 344 | u8 BER[3]; |
342 | 345 | ||
343 | stv0297_writereg(state, 0xA0, 0x80); // Start Counting bit errors for 4096 Bytes | ||
344 | mdelay(25); // Hopefully got 4096 Bytes | ||
345 | stv0297_readregs(state, 0xA0, BER, 3); | 346 | stv0297_readregs(state, 0xA0, BER, 3); |
346 | mdelay(25); | 347 | if (!(BER[0] & 0x80)) { |
347 | *ber = (BER[2] << 8 | BER[1]) / (8 * 4096); | 348 | state->last_ber = BER[2] << 8 | BER[1]; |
349 | stv0297_writereg_mask(state, 0xA0, 0x80, 0x80); | ||
350 | } | ||
351 | |||
352 | *ber = state->last_ber; | ||
348 | 353 | ||
349 | return 0; | 354 | return 0; |
350 | } | 355 | } |
@@ -376,9 +381,14 @@ static int stv0297_read_ucblocks(struct dvb_frontend *fe, u32 * ucblocks) | |||
376 | { | 381 | { |
377 | struct stv0297_state *state = fe->demodulator_priv; | 382 | struct stv0297_state *state = fe->demodulator_priv; |
378 | 383 | ||
384 | stv0297_writereg_mask(state, 0xDF, 0x03, 0x03); /* freeze the counters */ | ||
385 | |||
379 | *ucblocks = (stv0297_readreg(state, 0xD5) << 8) | 386 | *ucblocks = (stv0297_readreg(state, 0xD5) << 8) |
380 | | stv0297_readreg(state, 0xD4); | 387 | | stv0297_readreg(state, 0xD4); |
381 | 388 | ||
389 | stv0297_writereg_mask(state, 0xDF, 0x03, 0x02); /* clear the counters */ | ||
390 | stv0297_writereg_mask(state, 0xDF, 0x03, 0x01); /* re-enable the counters */ | ||
391 | |||
382 | return 0; | 392 | return 0; |
383 | } | 393 | } |
384 | 394 | ||
@@ -648,6 +658,7 @@ struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, | |||
648 | /* setup the state */ | 658 | /* setup the state */ |
649 | state->config = config; | 659 | state->config = config; |
650 | state->i2c = i2c; | 660 | state->i2c = i2c; |
661 | state->last_ber = 0; | ||
651 | state->base_freq = 0; | 662 | state->base_freq = 0; |
652 | 663 | ||
653 | /* check if the demod is there */ | 664 | /* check if the demod is there */ |