Skip to content

Commit

Permalink
[media] stb0899: sign extend raw CRL_FREQ value
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Reinhard Nißl authored and Mauro Carvalho Chehab committed Jun 8, 2013
1 parent 703e606 commit ccac68f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/media/dvb-frontends/stb0899_algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ccac68f

Please sign in to comment.