Skip to contentSkip to conversation

stb0899: fix inversion enum values to match usage with CFR

PATCH New Reinhard Nißl 1 participant 2 messages May 8, 2013 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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.

---
 drivers/media/dvb-frontends/stb0899_algo.c | 4 ++--
 drivers/media/dvb-frontends/stb0899_drv.h  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/media/dvb-frontends/stb0899_algo.c +2 -2
index 14d720b..e0d31a2 100644
@@ -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,
drivers/media/dvb-frontends/stb0899_drv.h +2 -2
index 1ddad6a..139264d 100644
@@ -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
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 2/2 stb0899: remove commented value from IQ_SWAP_ON/OFF usages

As the enum values have changed recently, the comments are void.

---
 drivers/media/pci/mantis/mantis_vp1041.c | 2 +-
 drivers/media/pci/ttpci/budget-av.c      | 2 +-
 drivers/media/pci/ttpci/budget-ci.c      | 2 +-
 drivers/media/usb/dvb-usb/az6027.c       | 2 +-
 drivers/media/usb/dvb-usb/pctv452e.c     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/media/pci/mantis/mantis_vp1041.c +1 -1
index 07aa887..07a2074 100644
@@ -273,7 +273,7 @@ struct stb0899_config vp1041_stb0899_config = {
 	.demod_address 		= 0x68, /*  0xd0 >> 1 */
 
 	.xtal_freq		= 27000000,
-	.inversion		= IQ_SWAP_ON, /* 1 */
+	.inversion		= IQ_SWAP_ON,
 
 	.lo_clk			= 76500000,
 	.hi_clk			= 99000000,
drivers/media/pci/ttpci/budget-av.c +1 -1
index 1f8b1bb..0ba3875 100644
@@ -1128,7 +1128,7 @@ static struct stb0899_config knc1_dvbs2_config = {
 //	.ts_pfbit_toggle	= STB0899_MPEG_NORMAL,	/* DirecTV, MPEG toggling seq	*/
 
 	.xtal_freq		= 27000000,
-	.inversion		= IQ_SWAP_OFF, /* 1 */
+	.inversion		= IQ_SWAP_OFF,
 
 	.lo_clk			= 76500000,
 	.hi_clk			= 90000000,
drivers/media/pci/ttpci/budget-ci.c +1 -1
index 98e5241..0acf920 100644
@@ -1280,7 +1280,7 @@ static struct stb0899_config tt3200_config = {
 	.demod_address 		= 0x68,
 
 	.xtal_freq		= 27000000,
-	.inversion		= IQ_SWAP_ON, /* 1 */
+	.inversion		= IQ_SWAP_ON,
 
 	.lo_clk			= 76500000,
 	.hi_clk			= 99000000,
drivers/media/usb/dvb-usb/az6027.c +1 -1
index 91e0119..ea2d5ee 100644
@@ -264,7 +264,7 @@ struct stb0899_config az6027_stb0899_config = {
 	.demod_address 		= 0xd0, /* 0x68, 0xd0 >> 1 */
 
 	.xtal_freq		= 27000000,
-	.inversion		= IQ_SWAP_ON, /* 1 */
+	.inversion		= IQ_SWAP_ON,
 
 	.lo_clk			= 76500000,
 	.hi_clk			= 99000000,
drivers/media/usb/dvb-usb/pctv452e.c +1 -1
index d1ddfa1..449a996 100644
@@ -828,7 +828,7 @@ static struct stb0899_config stb0899_config = {
 	.block_sync_mode = STB0899_SYNC_FORCED, /* ? */
 
 	.xtal_freq       = 27000000,	 /* Assume Hz ? */
-	.inversion       = IQ_SWAP_ON,       /* ? */
+	.inversion       = IQ_SWAP_ON,
 
 	.lo_clk	  = 76500000,
 	.hi_clk	  = 99000000,
Signature · 1 line
1.8.1.4