diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-04 01:00:00 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-04 01:01:07 -0400 |
commit | 90acb85fb48372f30e0a2f6d516d2285faea6e6c (patch) | |
tree | 8a9338977d43745a716fe4f429f671b450df9640 | |
parent | 030755bde42bbed133182b0ece7c7a9c759478e8 (diff) |
[media] tuner-xc2028: Fix signal strength report
There are several bugs at the signal strength algorithm:
- It is using logical OR, instead of bit OR;
- It doesn't wait up to 18 ms as it should;
- the strength range is not ok.
Rework on it, in order to make it work.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/common/tuners/tuner-xc2028.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c index 9638a69f36b2..42fdf5c57091 100644 --- a/drivers/media/common/tuners/tuner-xc2028.c +++ b/drivers/media/common/tuners/tuner-xc2028.c | |||
@@ -903,7 +903,7 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) | |||
903 | { | 903 | { |
904 | struct xc2028_data *priv = fe->tuner_priv; | 904 | struct xc2028_data *priv = fe->tuner_priv; |
905 | u16 frq_lock, signal = 0; | 905 | u16 frq_lock, signal = 0; |
906 | int rc; | 906 | int rc, i; |
907 | 907 | ||
908 | tuner_dbg("%s called\n", __func__); | 908 | tuner_dbg("%s called\n", __func__); |
909 | 909 | ||
@@ -914,21 +914,28 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) | |||
914 | mutex_lock(&priv->lock); | 914 | mutex_lock(&priv->lock); |
915 | 915 | ||
916 | /* Sync Lock Indicator */ | 916 | /* Sync Lock Indicator */ |
917 | rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock); | 917 | for (i = 0; i < 3; i++) { |
918 | if (rc < 0) | 918 | rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock); |
919 | goto ret; | 919 | if (rc < 0) |
920 | goto ret; | ||
920 | 921 | ||
921 | /* Frequency is locked */ | 922 | if (frq_lock) |
922 | if (frq_lock == 1) | 923 | break; |
923 | signal = 1 << 11; | 924 | msleep(6); |
925 | } | ||
926 | |||
927 | /* Frequency was not locked */ | ||
928 | if (frq_lock == 2) | ||
929 | goto ret; | ||
924 | 930 | ||
925 | /* Get SNR of the video signal */ | 931 | /* Get SNR of the video signal */ |
926 | rc = xc2028_get_reg(priv, XREG_SNR, &signal); | 932 | rc = xc2028_get_reg(priv, XREG_SNR, &signal); |
927 | if (rc < 0) | 933 | if (rc < 0) |
928 | goto ret; | 934 | goto ret; |
929 | 935 | ||
930 | /* Use both frq_lock and signal to generate the result */ | 936 | /* Signal level is 3 bits only */ |
931 | signal = signal || ((signal & 0x07) << 12); | 937 | |
938 | signal = ((1 << 12) - 1) | ((signal & 0x07) << 12); | ||
932 | 939 | ||
933 | ret: | 940 | ret: |
934 | mutex_unlock(&priv->lock); | 941 | mutex_unlock(&priv->lock); |