[PATCH] dvb: nxt6000: support frontend status reads
authorJohannes Stezenbach <js@linuxtv.org>
Tue, 17 May 2005 04:54:29 +0000 (21:54 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 17 May 2005 14:59:29 +0000 (07:59 -0700)
add support for read_ber, read_signal_strength and read_status (Greg Wickham)

Signed-off-by: Johannes Stezenbach <js@linuxtv.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/media/dvb/frontends/nxt6000.c
drivers/media/dvb/frontends/nxt6000_priv.h

index a41f7da8b842286b0a9b55636e8d3cf1b241171d..f79a69d0eb0715852752ccff9db4fcbd49984812 100644 (file)
@@ -180,7 +180,12 @@ static void nxt6000_setup(struct dvb_frontend* fe)
 
        nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM);
        nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01);
-       nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC);
+       nxt6000_writereg(state, VIT_BERTIME_2, 0x00);  // BER Timer = 0x000200 * 256 = 131072 bits
+       nxt6000_writereg(state, VIT_BERTIME_1, 0x02);  //
+       nxt6000_writereg(state, VIT_BERTIME_0, 0x00);  //
+       nxt6000_writereg(state, VIT_COR_INTEN, 0x98); // Enable BER interrupts
+       nxt6000_writereg(state, VIT_COR_CTL, 0x82);   // Enable BER measurement
+       nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC | 0x02 );
        nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F));
        nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02);
        nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW);
@@ -486,6 +491,40 @@ static void nxt6000_release(struct dvb_frontend* fe)
        kfree(state);
 }
 
+static int nxt6000_read_snr(struct dvb_frontend* fe, u16* snr)
+{
+       struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
+
+       *snr = nxt6000_readreg( state, OFDM_CHC_SNR) / 8;
+
+       return 0;
+}
+
+static int nxt6000_read_ber(struct dvb_frontend* fe, u32* ber)
+{
+       struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
+
+       nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18 );
+
+       *ber = (nxt6000_readreg( state, VIT_BER_1 ) << 8 ) |
+               nxt6000_readreg( state, VIT_BER_0 );
+
+       nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18); // Clear BER Done interrupts
+
+       return 0;
+}
+
+static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
+{
+       struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
+
+       *signal_strength = (short) (511 -
+               (nxt6000_readreg(state, AGC_GAIN_1) +
+               ((nxt6000_readreg(state, AGC_GAIN_2) & 0x03) << 8)));
+
+       return 0;
+}
+
 static struct dvb_frontend_ops nxt6000_ops;
 
 struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
@@ -542,6 +581,9 @@ static struct dvb_frontend_ops nxt6000_ops = {
        .set_frontend = nxt6000_set_frontend,
 
        .read_status = nxt6000_read_status,
+       .read_ber = nxt6000_read_ber,
+       .read_signal_strength = nxt6000_read_signal_strength,
+       .read_snr = nxt6000_read_snr,
 };
 
 module_param(debug, int, 0644);
index 64b1a89b2a22a2026a9bd7a81a7c44788458938f..0422e580038ac14719741c7c53e5b243f919b374 100644 (file)
 #define BER_DONE               (0x08)
 #define BER_OVERFLOW           (0x10)
 
+/* 0x38 VIT_BERTIME_2 */
+#define VIT_BERTIME_2      (0x38)
+
+/* 0x39 VIT_BERTIME_1 */
+#define VIT_BERTIME_1      (0x39)
+
+/* 0x3A VIT_BERTIME_0 */
+#define VIT_BERTIME_0      (0x3a)
+
                             /* 0x38 OFDM_BERTimer *//* Use the alias registers */
 #define A_VIT_BER_TIMER_0      (0x1D)
 
                             /* 0x3A VIT_BER_TIMER_0 *//* Use the alias registers */
 #define A_VIT_BER_0            (0x1B)
 
+/* 0x3B VIT_BER_1 */
+#define VIT_BER_1              (0x3b)
+
+/* 0x3C VIT_BER_0 */
+#define VIT_BER_0              (0x3c)
+
 /* 0x40 OFDM_COR_CTL */
 #define OFDM_COR_CTL           (0x40)
 #define COREACT                (0x20)
 #define OFDM_ITB_CTL           (0x4B)
 #define ITBINV                 (0x01)
 
+/* 0x49 AGC_GAIN_1 */
+#define AGC_GAIN_1             (0x49)
+
+/* 0x4A AGC_GAIN_2 */
+#define AGC_GAIN_2             (0x4A)
+
 /* 0x4C OFDM_ITB_FREQ_1 */
 #define OFDM_ITB_FREQ_1        (0x4C)