summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinhard Nißl <rnissl@gmx.de>2013-06-02 14:37:06 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-08 20:11:49 -0300
commitccac68f9818d0ff5c4cde26590a7f284285c724e (patch)
tree565b25f698fe86305b3cf58c096722b6a8167b08
parent703e60655ca520c5380d8c83a9db0d5e9b906856 (diff)
[media] stb0899: sign extend raw CRL_FREQ value
Contrary to the chip's specs, the register's value is signed, so we need to sign extend the value before using it in calculations like when determining the offset frequency. Signed-off-by: Reinhard Nißl <rnissl@gmx.de> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb-frontends/stb0899_algo.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c
index 117a56926dca..bd9dbd70af0f 100644
--- a/drivers/media/dvb-frontends/stb0899_algo.c
+++ b/drivers/media/dvb-frontends/stb0899_algo.c
@@ -1487,6 +1487,10 @@ enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state)
/* Store signal parameters */
offsetfreq = STB0899_READ_S2REG(STB0899_S2DEMOD, CRL_FREQ);
+ /* sign extend 30 bit value before using it in calculations */
+ if (offsetfreq & (1 << 29))
+ offsetfreq |= -1 << 30;
+
offsetfreq = offsetfreq / ((1 << 30) / 1000);
offsetfreq *= (internal->master_clk / 1000000);
reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_CNTRL2);