aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends/m88rs2000.c
diff options
context:
space:
mode:
authorIgor M. Liplianin <liplianin@me.by>2012-12-28 17:40:16 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-12-28 18:29:42 -0500
commit38f7889cea9d5754493fa601a2d466ba33f13f55 (patch)
treef7e9c6451cce59699c3309bb75c5705517a05c09 /drivers/media/dvb-frontends/m88rs2000.c
parenta3e7ad256cae84dfbb8d016a5838c72f3b695883 (diff)
[media] m88rs2000: SNR, BER implemented
Trivial patch to implement SNR, BER, UCB counter for Montage rs2000 demod. Signed-off-by: Igor M. Liplianin <liplianin@me.by> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb-frontends/m88rs2000.c')
-rw-r--r--drivers/media/dvb-frontends/m88rs2000.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c
index 5d3d5dd62daa..df9e7dd6fe74 100644
--- a/drivers/media/dvb-frontends/m88rs2000.c
+++ b/drivers/media/dvb-frontends/m88rs2000.c
@@ -492,12 +492,29 @@ static int m88rs2000_read_status(struct dvb_frontend *fe, fe_status_t *status)
492 return 0; 492 return 0;
493} 493}
494 494
495/* Extact code for these unknown but lmedm04 driver uses interupt callbacks */
496
497static int m88rs2000_read_ber(struct dvb_frontend *fe, u32 *ber) 495static int m88rs2000_read_ber(struct dvb_frontend *fe, u32 *ber)
498{ 496{
499 deb_info("m88rs2000_read_ber %d\n", *ber); 497 struct m88rs2000_state *state = fe->demodulator_priv;
500 *ber = 0; 498 u8 tmp0, tmp1;
499
500 m88rs2000_demod_write(state, 0x9a, 0x30);
501 tmp0 = m88rs2000_demod_read(state, 0xd8);
502 if ((tmp0 & 0x10) != 0) {
503 m88rs2000_demod_write(state, 0x9a, 0xb0);
504 *ber = 0xffffffff;
505 return 0;
506 }
507
508 *ber = (m88rs2000_demod_read(state, 0xd7) << 8) |
509 m88rs2000_demod_read(state, 0xd6);
510
511 tmp1 = m88rs2000_demod_read(state, 0xd9);
512 m88rs2000_demod_write(state, 0xd9, (tmp1 & ~7) | 4);
513 /* needs twice */
514 m88rs2000_demod_write(state, 0xd8, (tmp0 & ~8) | 0x30);
515 m88rs2000_demod_write(state, 0xd8, (tmp0 & ~8) | 0x30);
516 m88rs2000_demod_write(state, 0x9a, 0xb0);
517
501 return 0; 518 return 0;
502} 519}
503 520
@@ -510,15 +527,26 @@ static int m88rs2000_read_signal_strength(struct dvb_frontend *fe,
510 527
511static int m88rs2000_read_snr(struct dvb_frontend *fe, u16 *snr) 528static int m88rs2000_read_snr(struct dvb_frontend *fe, u16 *snr)
512{ 529{
513 deb_info("m88rs2000_read_snr %d\n", *snr); 530 struct m88rs2000_state *state = fe->demodulator_priv;
514 *snr = 0; 531
532 *snr = 512 * m88rs2000_demod_read(state, 0x65);
533
515 return 0; 534 return 0;
516} 535}
517 536
518static int m88rs2000_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 537static int m88rs2000_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
519{ 538{
520 deb_info("m88rs2000_read_ber %d\n", *ucblocks); 539 struct m88rs2000_state *state = fe->demodulator_priv;
521 *ucblocks = 0; 540 u8 tmp;
541
542 *ucblocks = (m88rs2000_demod_read(state, 0xd5) << 8) |
543 m88rs2000_demod_read(state, 0xd4);
544 tmp = m88rs2000_demod_read(state, 0xd8);
545 m88rs2000_demod_write(state, 0xd8, tmp & ~0x20);
546 /* needs two times */
547 m88rs2000_demod_write(state, 0xd8, tmp | 0x20);
548 m88rs2000_demod_write(state, 0xd8, tmp | 0x20);
549
522 return 0; 550 return 0;
523} 551}
524 552