aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohannes Stezenbach <js@linuxtv.org>2005-05-17 00:54:29 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-17 10:59:29 -0400
commit3a4a571124cdd04215e0f78bc53fe16bab58f32d (patch)
treec1faa0ab53d80ab3f7a00c05b080de72981cd9e8 /drivers
parent3165dcb300ff60e794909f02b1fd3a41908682ea (diff)
[PATCH] dvb: nxt6000: support frontend status reads
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/frontends/nxt6000.c44
-rw-r--r--drivers/media/dvb/frontends/nxt6000_priv.h21
2 files changed, 64 insertions, 1 deletions
diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c
index a41f7da8b842..f79a69d0eb07 100644
--- a/drivers/media/dvb/frontends/nxt6000.c
+++ b/drivers/media/dvb/frontends/nxt6000.c
@@ -180,7 +180,12 @@ static void nxt6000_setup(struct dvb_frontend* fe)
180 180
181 nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM); 181 nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM);
182 nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01); 182 nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01);
183 nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC); 183 nxt6000_writereg(state, VIT_BERTIME_2, 0x00); // BER Timer = 0x000200 * 256 = 131072 bits
184 nxt6000_writereg(state, VIT_BERTIME_1, 0x02); //
185 nxt6000_writereg(state, VIT_BERTIME_0, 0x00); //
186 nxt6000_writereg(state, VIT_COR_INTEN, 0x98); // Enable BER interrupts
187 nxt6000_writereg(state, VIT_COR_CTL, 0x82); // Enable BER measurement
188 nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC | 0x02 );
184 nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F)); 189 nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F));
185 nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02); 190 nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02);
186 nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW); 191 nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW);
@@ -486,6 +491,40 @@ static void nxt6000_release(struct dvb_frontend* fe)
486 kfree(state); 491 kfree(state);
487} 492}
488 493
494static int nxt6000_read_snr(struct dvb_frontend* fe, u16* snr)
495{
496 struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
497
498 *snr = nxt6000_readreg( state, OFDM_CHC_SNR) / 8;
499
500 return 0;
501}
502
503static int nxt6000_read_ber(struct dvb_frontend* fe, u32* ber)
504{
505 struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
506
507 nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18 );
508
509 *ber = (nxt6000_readreg( state, VIT_BER_1 ) << 8 ) |
510 nxt6000_readreg( state, VIT_BER_0 );
511
512 nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18); // Clear BER Done interrupts
513
514 return 0;
515}
516
517static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
518{
519 struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv;
520
521 *signal_strength = (short) (511 -
522 (nxt6000_readreg(state, AGC_GAIN_1) +
523 ((nxt6000_readreg(state, AGC_GAIN_2) & 0x03) << 8)));
524
525 return 0;
526}
527
489static struct dvb_frontend_ops nxt6000_ops; 528static struct dvb_frontend_ops nxt6000_ops;
490 529
491struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, 530struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
@@ -542,6 +581,9 @@ static struct dvb_frontend_ops nxt6000_ops = {
542 .set_frontend = nxt6000_set_frontend, 581 .set_frontend = nxt6000_set_frontend,
543 582
544 .read_status = nxt6000_read_status, 583 .read_status = nxt6000_read_status,
584 .read_ber = nxt6000_read_ber,
585 .read_signal_strength = nxt6000_read_signal_strength,
586 .read_snr = nxt6000_read_snr,
545}; 587};
546 588
547module_param(debug, int, 0644); 589module_param(debug, int, 0644);
diff --git a/drivers/media/dvb/frontends/nxt6000_priv.h b/drivers/media/dvb/frontends/nxt6000_priv.h
index 64b1a89b2a22..0422e580038a 100644
--- a/drivers/media/dvb/frontends/nxt6000_priv.h
+++ b/drivers/media/dvb/frontends/nxt6000_priv.h
@@ -65,12 +65,27 @@
65#define BER_DONE (0x08) 65#define BER_DONE (0x08)
66#define BER_OVERFLOW (0x10) 66#define BER_OVERFLOW (0x10)
67 67
68/* 0x38 VIT_BERTIME_2 */
69#define VIT_BERTIME_2 (0x38)
70
71/* 0x39 VIT_BERTIME_1 */
72#define VIT_BERTIME_1 (0x39)
73
74/* 0x3A VIT_BERTIME_0 */
75#define VIT_BERTIME_0 (0x3a)
76
68 /* 0x38 OFDM_BERTimer *//* Use the alias registers */ 77 /* 0x38 OFDM_BERTimer *//* Use the alias registers */
69#define A_VIT_BER_TIMER_0 (0x1D) 78#define A_VIT_BER_TIMER_0 (0x1D)
70 79
71 /* 0x3A VIT_BER_TIMER_0 *//* Use the alias registers */ 80 /* 0x3A VIT_BER_TIMER_0 *//* Use the alias registers */
72#define A_VIT_BER_0 (0x1B) 81#define A_VIT_BER_0 (0x1B)
73 82
83/* 0x3B VIT_BER_1 */
84#define VIT_BER_1 (0x3b)
85
86/* 0x3C VIT_BER_0 */
87#define VIT_BER_0 (0x3c)
88
74/* 0x40 OFDM_COR_CTL */ 89/* 0x40 OFDM_COR_CTL */
75#define OFDM_COR_CTL (0x40) 90#define OFDM_COR_CTL (0x40)
76#define COREACT (0x20) 91#define COREACT (0x20)
@@ -117,6 +132,12 @@
117#define OFDM_ITB_CTL (0x4B) 132#define OFDM_ITB_CTL (0x4B)
118#define ITBINV (0x01) 133#define ITBINV (0x01)
119 134
135/* 0x49 AGC_GAIN_1 */
136#define AGC_GAIN_1 (0x49)
137
138/* 0x4A AGC_GAIN_2 */
139#define AGC_GAIN_2 (0x4A)
140
120/* 0x4C OFDM_ITB_FREQ_1 */ 141/* 0x4C OFDM_ITB_FREQ_1 */
121#define OFDM_ITB_FREQ_1 (0x4C) 142#define OFDM_ITB_FREQ_1 (0x4C)
122 143