aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorSteven Toth <stoth@hauppauge.com>2008-04-22 21:52:01 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:09:45 -0400
commitd5b3d9ff368dee5e87d9987161ff258d87ecc7c0 (patch)
tree0a8a7e9eee5dedeec1f92ff2f52ebf8a29b1411b /drivers/media/dvb
parent6676237398d0c2e61e5a3a27e0951f60d6ef6fe3 (diff)
V4L/DVB (7674): tda10048: Adding an SNR table
Trying to improve the SNR reporting. Signed-off-by: Steven Toth <stoth@hauppauge.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/frontends/tda10048.c157
1 files changed, 147 insertions, 10 deletions
diff --git a/drivers/media/dvb/frontends/tda10048.c b/drivers/media/dvb/frontends/tda10048.c
index 701dd02b0d07..090fb7dd93c6 100644
--- a/drivers/media/dvb/frontends/tda10048.c
+++ b/drivers/media/dvb/frontends/tda10048.c
@@ -26,6 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include "dvb_frontend.h" 28#include "dvb_frontend.h"
29#include "dvb_math.h"
29#include "tda10048.h" 30#include "tda10048.h"
30 31
31#define TDA10048_DEFAULT_FIRMWARE "dvb-fe-tda10048-1.0.fw" 32#define TDA10048_DEFAULT_FIRMWARE "dvb-fe-tda10048-1.0.fw"
@@ -563,31 +564,167 @@ static int tda10048_read_signal_strength(struct dvb_frontend *fe,
563 u16 *signal_strength) 564 u16 *signal_strength)
564{ 565{
565 struct tda10048_state *state = fe->demodulator_priv; 566 struct tda10048_state *state = fe->demodulator_priv;
566 u16 v; 567 u8 v;
567 568
568 dprintk(1, "%s()\n", __func__); 569 dprintk(1, "%s()\n", __func__);
569 570
571 *signal_strength = 65535;
572
570 v = tda10048_readreg(state, TDA10048_NP_OUT); 573 v = tda10048_readreg(state, TDA10048_NP_OUT);
571 if (v == 0) 574 if (v > 0)
572 *signal_strength = 100; 575 *signal_strength -= (v << 8) | v;
573 else {
574 /* TODO: Apply .db math for correct values */
575 *signal_strength = v;
576 }
577 576
578 return 0; 577 return 0;
579} 578}
580 579
580/* SNR lookup table */
581static struct snr_tab {
582 u8 val;
583 u8 data;
584} snr_tab[] = {
585 { 0, 0 },
586 { 1, 246 },
587 { 2, 215 },
588 { 3, 198 },
589 { 4, 185 },
590 { 5, 176 },
591 { 6, 168 },
592 { 7, 161 },
593 { 8, 155 },
594 { 9, 150 },
595 { 10, 146 },
596 { 11, 141 },
597 { 12, 138 },
598 { 13, 134 },
599 { 14, 131 },
600 { 15, 128 },
601 { 16, 125 },
602 { 17, 122 },
603 { 18, 120 },
604 { 19, 118 },
605 { 20, 115 },
606 { 21, 113 },
607 { 22, 111 },
608 { 23, 109 },
609 { 24, 107 },
610 { 25, 106 },
611 { 26, 104 },
612 { 27, 102 },
613 { 28, 101 },
614 { 29, 99 },
615 { 30, 98 },
616 { 31, 96 },
617 { 32, 95 },
618 { 33, 94 },
619 { 34, 92 },
620 { 35, 91 },
621 { 36, 90 },
622 { 37, 89 },
623 { 38, 88 },
624 { 39, 86 },
625 { 40, 85 },
626 { 41, 84 },
627 { 42, 83 },
628 { 43, 82 },
629 { 44, 81 },
630 { 45, 80 },
631 { 46, 79 },
632 { 47, 78 },
633 { 48, 77 },
634 { 49, 76 },
635 { 50, 76 },
636 { 51, 75 },
637 { 52, 74 },
638 { 53, 73 },
639 { 54, 72 },
640 { 56, 71 },
641 { 57, 70 },
642 { 58, 69 },
643 { 60, 68 },
644 { 61, 67 },
645 { 63, 66 },
646 { 64, 65 },
647 { 66, 64 },
648 { 67, 63 },
649 { 68, 62 },
650 { 69, 62 },
651 { 70, 61 },
652 { 72, 60 },
653 { 74, 59 },
654 { 75, 58 },
655 { 77, 57 },
656 { 79, 56 },
657 { 81, 55 },
658 { 83, 54 },
659 { 85, 53 },
660 { 87, 52 },
661 { 89, 51 },
662 { 91, 50 },
663 { 93, 49 },
664 { 95, 48 },
665 { 97, 47 },
666 { 100, 46 },
667 { 102, 45 },
668 { 104, 44 },
669 { 107, 43 },
670 { 109, 42 },
671 { 112, 41 },
672 { 114, 40 },
673 { 117, 39 },
674 { 120, 38 },
675 { 123, 37 },
676 { 125, 36 },
677 { 128, 35 },
678 { 131, 34 },
679 { 134, 33 },
680 { 138, 32 },
681 { 141, 31 },
682 { 144, 30 },
683 { 147, 29 },
684 { 151, 28 },
685 { 154, 27 },
686 { 158, 26 },
687 { 162, 25 },
688 { 165, 24 },
689 { 169, 23 },
690 { 173, 22 },
691 { 177, 21 },
692 { 181, 20 },
693 { 186, 19 },
694 { 190, 18 },
695 { 194, 17 },
696 { 199, 16 },
697 { 204, 15 },
698 { 208, 14 },
699 { 213, 13 },
700 { 218, 12 },
701 { 223, 11 },
702 { 229, 10 },
703 { 234, 9 },
704 { 239, 8 },
705 { 245, 7 },
706 { 251, 6 },
707 { 255, 5 },
708};
709
581static int tda10048_read_snr(struct dvb_frontend *fe, u16 *snr) 710static int tda10048_read_snr(struct dvb_frontend *fe, u16 *snr)
582{ 711{
583 struct tda10048_state *state = fe->demodulator_priv; 712 struct tda10048_state *state = fe->demodulator_priv;
713 u8 v;
714 int i, ret = -EINVAL;
584 715
585 dprintk(1, "%s()\n", __func__); 716 dprintk(1, "%s()\n", __func__);
586 717
587 /* TODO: This result should be the same as signal strength */ 718 v = tda10048_readreg(state, TDA10048_NP_OUT);
588 *snr = tda10048_readreg(state, TDA10048_NP_OUT); 719 for (i = 0; i < ARRAY_SIZE(snr_tab); i++) {
720 if (v <= snr_tab[i].val) {
721 *snr = snr_tab[i].data;
722 ret = 0;
723 break;
724 }
725 }
589 726
590 return 0; 727 return ret;
591} 728}
592 729
593static int tda10048_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 730static int tda10048_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)