Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] stb0899: fix inversion enum values to match usage with CFR

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>

authored by

Reinhard Nißl and committed by
Mauro Carvalho Chehab
069ebbfc fa64cfd2

+4 -4
+2 -2
drivers/media/dvb-frontends/stb0899_algo.c
··· 444 444 int range_offst, tp_freq; 445 445 446 446 range_offst = internal->srch_range / 2000; 447 - tp_freq = internal->freq + (internal->derot_freq * internal->mclk) / 1000; 447 + tp_freq = internal->freq - (internal->derot_freq * internal->mclk) / 1000; 448 448 449 449 if ((tp_freq >= params->freq - range_offst) && (tp_freq <= params->freq + range_offst)) { 450 450 internal->status = RANGEOK; ··· 638 638 "RANGE OK ! derot freq=%d, mclk=%d", 639 639 internal->derot_freq, internal->mclk); 640 640 641 - internal->freq = params->freq + ((internal->derot_freq * internal->mclk) / 1000); 641 + internal->freq = params->freq - ((internal->derot_freq * internal->mclk) / 1000); 642 642 reg = stb0899_read_reg(state, STB0899_PLPARM); 643 643 internal->fecrate = STB0899_GETFIELD(VITCURPUN, reg); 644 644 dprintk(state->verbose, FE_DEBUG, 1,
+2 -2
drivers/media/dvb-frontends/stb0899_drv.h
··· 45 45 }; 46 46 47 47 enum stb0899_inversion { 48 - IQ_SWAP_OFF = 0, 49 - IQ_SWAP_ON, 48 + IQ_SWAP_OFF = +1, /* inversion affects the sign of e. g. */ 49 + IQ_SWAP_ON = -1, /* the derotator frequency register */ 50 50 }; 51 51 52 52 #define STB0899_GPIO00 0xf140