[media] stb0899: fix inversion enum values to match usage with CFR
authorReinhard Nißl <rnissl@gmx.de>
Sun, 2 Jun 2013 17:52:43 +0000 (14:52 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 8 Jun 2013 23:13:29 +0000 (20:13 -0300)
Throughout the zig-zag-implementations, inversion is taken into
account when reading and writing the CFR register, which contains
the derotator frequency. As swapping IQ signals changes the sign
of that register for example, the idea is to compensate that sign
change by multiplying the register value with the inversion enum
value.
The current enum values 0 and 1 for IQ_SWAP_OFF and IQ_SWAP_ON
don't work in the case IQ_SWAP_OFF, due to the multiplication by
zero (I've only found a single device which actually uses
IQ_SWAP_OFF in it's config).
I've changed the enum values to +1 and -1 to accommodate to the
intended usage.

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>
drivers/media/dvb-frontends/stb0899_algo.c
drivers/media/dvb-frontends/stb0899_drv.h

index 14d720ba120742fbe1a756df2a12ef2667729c3d..e0d31a2ea5782e4fa038d1f594845e0913d1d9d9 100644 (file)
@@ -444,7 +444,7 @@ static enum stb0899_status stb0899_check_range(struct stb0899_state *state)
        int range_offst, tp_freq;
 
        range_offst = internal->srch_range / 2000;
-       tp_freq = internal->freq + (internal->derot_freq * internal->mclk) / 1000;
+       tp_freq = internal->freq - (internal->derot_freq * internal->mclk) / 1000;
 
        if ((tp_freq >= params->freq - range_offst) && (tp_freq <= params->freq + range_offst)) {
                internal->status = RANGEOK;
@@ -638,7 +638,7 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state)
                                                        "RANGE OK ! derot freq=%d, mclk=%d",
                                                        internal->derot_freq, internal->mclk);
 
-                                               internal->freq = params->freq + ((internal->derot_freq * internal->mclk) / 1000);
+                                               internal->freq = params->freq - ((internal->derot_freq * internal->mclk) / 1000);
                                                reg = stb0899_read_reg(state, STB0899_PLPARM);
                                                internal->fecrate = STB0899_GETFIELD(VITCURPUN, reg);
                                                dprintk(state->verbose, FE_DEBUG, 1,
index 1ddad6a8cc07f0fcb534c237417717f2f345dc91..139264d19263539bf68eef8c4a919eb3756b7b19 100644 (file)
@@ -45,8 +45,8 @@ struct stb0899_s2_reg {
 };
 
 enum stb0899_inversion {
-       IQ_SWAP_OFF     = 0,
-       IQ_SWAP_ON,
+       IQ_SWAP_OFF     = +1, /* inversion affects the sign of e. g. */
+       IQ_SWAP_ON      = -1, /* the derotator frequency register    */
 };
 
 #define STB0899_GPIO00                         0xf140