* [PATCH v2] af9033: implement ber and ucb functions
@ 2012-04-07 14:34 Hans-Frieder Vogt
2012-05-07 13:25 ` Antti Palosaari
2012-05-07 18:47 ` Antti Palosaari
0 siblings, 2 replies; 3+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-07 14:34 UTC (permalink / raw)
To: Antti Palosaari; +Cc: linux-media, Michael Büsch, Gianluca Gennari
af9033: implement read_ber and read_ucblocks functions. Version 2 of patch that
reflects my findings on the behaviour of abort_cnt, err_cnt and bit_cnt:
- bit_cnt is always 0x2710 (10000)
- abort_cnt is between 0 and 0x2710
- err_cnt is between 0 and 640000 (= 0x2710 * 8 * 8)
in the current implementation BER is calculated as the number of bit errors per
processed bits, ignoring those bits that are already discarded and counted in
abort_cnt, i.e. UCBLOCKS.
Signed-off-by: Hans-Frieder Vogt <hfvogt@gmx.net>
drivers/media/dvb/frontends/af9033.c | 65 +++++++++++++++++++++++++++++++++--
1 file changed, 63 insertions(+), 2 deletions(-)
diff -Nupr a/drivers/media/dvb/frontends/af9033.c b/drivers/media/dvb/frontends/af9033.c
--- a/drivers/media/dvb/frontends/af9033.c 2012-04-07 16:00:45.615402757 +0200
+++ b/drivers/media/dvb/frontends/af9033.c 2012-04-07 16:27:21.534741880 +0200
@@ -29,6 +29,10 @@ struct af9033_state {
u32 bandwidth_hz;
bool ts_mode_parallel;
bool ts_mode_serial;
+
+ u32 ber;
+ u32 ucb;
+ unsigned long last_stat_check;
};
/* write multiple registers */
@@ -772,16 +776,73 @@ err:
return ret;
}
+static int af9033_update_ch_stat(struct af9033_state *state)
+{
+ int ret = 0;
+ u32 err_cnt, bit_cnt;
+ u16 abort_cnt;
+ u8 buf[7];
+
+ /* only update data every half second */
+ if (time_after(jiffies, state->last_stat_check + msecs_to_jiffies(500))) {
+ ret = af9033_rd_regs(state, 0x800032, buf, sizeof(buf));
+ if (ret < 0)
+ goto err;
+ /* in 8 byte packets? */
+ abort_cnt = (buf[1] << 8) + buf[0];
+ /* in bits */
+ err_cnt = (buf[4] << 16) + (buf[3] << 8) + buf[2];
+ /* in 8 byte packets? always(?) 0x2710 = 10000 */
+ bit_cnt = (buf[6] << 8) + buf[5];
+
+ if (bit_cnt < abort_cnt) {
+ abort_cnt = 1000;
+ state->ber = 0xffffffff;
+ } else {
+ /* 8 byte packets, that have not been rejected already */
+ bit_cnt -= (u32)abort_cnt;
+ if (bit_cnt == 0) {
+ state->ber = 0xffffffff;
+ } else {
+ err_cnt -= (u32)abort_cnt * 8 * 8;
+ bit_cnt *= 8 * 8;
+ state->ber = err_cnt * (0xffffffff / bit_cnt);
+ }
+ }
+ state->ucb += abort_cnt;
+ state->last_stat_check = jiffies;
+ }
+
+ return 0;
+err:
+ pr_debug("%s: failed=%d\n", __func__, ret);
+ return ret;
+}
+
static int af9033_read_ber(struct dvb_frontend *fe, u32 *ber)
{
- *ber = 0;
+ struct af9033_state *state = fe->demodulator_priv;
+ int ret;
+
+ ret = af9033_update_ch_stat(state);
+ if (ret < 0)
+ return ret;
+
+ *ber = state->ber;
return 0;
}
static int af9033_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{
- *ucblocks = 0;
+ struct af9033_state *state = fe->demodulator_priv;
+ int ret;
+
+ ret = af9033_update_ch_stat(state);
+ if (ret < 0)
+ return ret;
+
+ *ucblocks = state->ucb;
return 0;
}
Hans-Frieder Vogt e-mail: hfvogt <at> gmx .dot. net
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] af9033: implement ber and ucb functions
2012-04-07 14:34 [PATCH v2] af9033: implement ber and ucb functions Hans-Frieder Vogt
@ 2012-05-07 13:25 ` Antti Palosaari
2012-05-07 18:47 ` Antti Palosaari
1 sibling, 0 replies; 3+ messages in thread
From: Antti Palosaari @ 2012-05-07 13:25 UTC (permalink / raw)
To: Hans-Frieder Vogt; +Cc: linux-media, Michael Büsch, Gianluca Gennari
On 07.04.2012 17:34, Hans-Frieder Vogt wrote:
> af9033: implement read_ber and read_ucblocks functions. Version 2 of patch that
> reflects my findings on the behaviour of abort_cnt, err_cnt and bit_cnt:
>
> - bit_cnt is always 0x2710 (10000)
> - abort_cnt is between 0 and 0x2710
> - err_cnt is between 0 and 640000 (= 0x2710 * 8 * 8)
>
> in the current implementation BER is calculated as the number of bit errors per
> processed bits, ignoring those bits that are already discarded and counted in
> abort_cnt, i.e. UCBLOCKS.
It still increases UCBLOCKS counter every query even there is no signal
at all. BER is in that case always maximum value. Hymps, maybe I just
apply that still in order to go ahead...
status 00 | signal 0000 | snr 0000 | ber ffffffff | unc 0024b105 |
status 00 | signal 0000 | snr 0000 | ber ffffffff | unc 0024d815 |
One of my plans is to block that kind of "illegal" situations in
frontend core level. As UCB and BER counters are only valid in case of
demod is LOCKed.
regards
Antti
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] af9033: implement ber and ucb functions
2012-04-07 14:34 [PATCH v2] af9033: implement ber and ucb functions Hans-Frieder Vogt
2012-05-07 13:25 ` Antti Palosaari
@ 2012-05-07 18:47 ` Antti Palosaari
1 sibling, 0 replies; 3+ messages in thread
From: Antti Palosaari @ 2012-05-07 18:47 UTC (permalink / raw)
To: Hans-Frieder Vogt; +Cc: linux-media, Michael Büsch, Gianluca Gennari
On 07.04.2012 17:34, Hans-Frieder Vogt wrote:
> af9033: implement read_ber and read_ucblocks functions. Version 2 of patch that
> reflects my findings on the behaviour of abort_cnt, err_cnt and bit_cnt:
>
> - bit_cnt is always 0x2710 (10000)
> - abort_cnt is between 0 and 0x2710
> - err_cnt is between 0 and 640000 (= 0x2710 * 8 * 8)
>
> in the current implementation BER is calculated as the number of bit errors per
> processed bits, ignoring those bits that are already discarded and counted in
> abort_cnt, i.e. UCBLOCKS.
>
> Signed-off-by: Hans-Frieder Vogt<hfvogt@gmx.net>
Applied and PULL requested via my tree. Thanks!
regards
Antti
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-07 18:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-07 14:34 [PATCH v2] af9033: implement ber and ucb functions Hans-Frieder Vogt
2012-05-07 13:25 ` Antti Palosaari
2012-05-07 18:47 ` Antti Palosaari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).