[media] it913x-fe ver 1.13 add BER and UNC monitoring
authorMalcolm Priestley <tvboxspy@gmail.com>
Tue, 3 Jan 2012 09:28:32 +0000 (06:28 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 6 Jan 2012 15:08:02 +0000 (13:08 -0200)
Add BER monitoring with Pre-Viterbi error rate.

Add UCBLOCKS based on Aborted packets.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/frontends/it913x-fe.c
drivers/media/dvb/frontends/it913x-fe.h

index 29cb47eb2f8e30f93a27e1b00eb6d276932584b1..7290801eac63b2d2edb38bf25624e8cda349c25b 100644 (file)
@@ -66,6 +66,7 @@ struct it913x_fe_state {
        u8 tun_fdiv;
        u8 tun_clk_mode;
        u32 tun_fn_min;
+       u32 ucblocks;
 };
 
 static int it913x_read_reg(struct it913x_fe_state *state,
@@ -562,14 +563,26 @@ static int it913x_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
 
 static int it913x_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
 {
-       *ber = 0;
+       struct it913x_fe_state *state = fe->demodulator_priv;
+       int ret;
+       u8 reg[5];
+       /* Read Aborted Packets and Pre-Viterbi error rate 5 bytes */
+       ret = it913x_read_reg(state, RSD_ABORT_PKT_LSB, reg, sizeof(reg));
+       state->ucblocks += (u32)(reg[1] << 8) | reg[0];
+       *ber = (u32)(reg[4] << 16) | (reg[3] << 8) | reg[2];
        return 0;
 }
 
 static int it913x_fe_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
 {
-       *ucblocks = 0;
-       return 0;
+       struct it913x_fe_state *state = fe->demodulator_priv;
+       int ret;
+       u8 reg[2];
+       /* Aborted Packets */
+       ret = it913x_read_reg(state, RSD_ABORT_PKT_LSB, reg, sizeof(reg));
+       state->ucblocks += (u32)(reg[1] << 8) | reg[0];
+       *ucblocks = state->ucblocks;
+       return ret;
 }
 
 static int it913x_fe_get_frontend(struct dvb_frontend *fe)
@@ -959,5 +972,5 @@ static struct dvb_frontend_ops it913x_fe_ofdm_ops = {
 
 MODULE_DESCRIPTION("it913x Frontend and it9137 tuner");
 MODULE_AUTHOR("Malcolm Priestley tvboxspy@gmail.com");
-MODULE_VERSION("1.12");
+MODULE_VERSION("1.13");
 MODULE_LICENSE("GPL");
index 5ee3e2f1416514f69c4473cacf33b80abc3f8c5a..c4a908e354e0d3528a4ca94d17a9865e6356fc76 100644 (file)
@@ -148,6 +148,16 @@ static inline struct dvb_frontend *it913x_fe_attach(
 #define COEFF_1_2048           0x0001
 #define XTAL_CLK               0x0025
 #define BFS_FCW                        0x0029
+
+/* Error Regs */
+#define RSD_ABORT_PKT_LSB      0x0032
+#define RSD_ABORT_PKT_MSB      0x0033
+#define RSD_BIT_ERR_0_7                0x0034
+#define RSD_BIT_ERR_8_15       0x0035
+#define RSD_BIT_ERR_23_16      0x0036
+#define RSD_BIT_COUNT_LSB      0x0037
+#define RSD_BIT_COUNT_MSB      0x0038
+
 #define TPSD_LOCK              0x003c
 #define TRAINING_MODE          0x0040
 #define ADC_X_2                        0x0045