diff options
author | Chris Pascoe <c.pascoe@itee.uq.edu.au> | 2007-11-20 06:17:54 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:02:37 -0500 |
commit | a1dcd9de648c8cf21abaeca7f77885665eed4117 (patch) | |
tree | f35cdf7d007056445a0603a12fb20d3eed5ec7ba | |
parent | 702a67624e4bc9c7056418b576af928940b7dbb9 (diff) |
V4L/DVB (6656): zl10353: store frequencies in 0.1kHz to eliminate rounding errors
Whilst reanalysing my formulas I realised it was no longer possible to get the
right values for a 36.1667MHz IF due to rounding problems.
Storing frequencies in units of 0.1kHz makes it possible to calculate these
again correctly.
Signed-off-by: Chris Pascoe <c.pascoe@itee.uq.edu.au>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/dvb/dvb-usb/cxusb.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/zl10353.c | 15 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/zl10353.h | 8 |
3 files changed, 14 insertions, 11 deletions
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index c44b9799efaa..deeb3871a2aa 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c | |||
@@ -435,7 +435,7 @@ static struct mt352_config cxusb_mt352_config = { | |||
435 | 435 | ||
436 | static struct zl10353_config cxusb_zl10353_xc3028_config = { | 436 | static struct zl10353_config cxusb_zl10353_xc3028_config = { |
437 | .demod_address = 0x0f, | 437 | .demod_address = 0x0f, |
438 | .if2 = 4560, | 438 | .if2 = 45600, |
439 | .no_tuner = 1, | 439 | .no_tuner = 1, |
440 | .parallel_ts = 1, | 440 | .parallel_ts = 1, |
441 | }; | 441 | }; |
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c index 1736c6ac39cc..091fbcced006 100644 --- a/drivers/media/dvb/frontends/zl10353.c +++ b/drivers/media/dvb/frontends/zl10353.c | |||
@@ -123,9 +123,10 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe, | |||
123 | enum fe_bandwidth bandwidth, | 123 | enum fe_bandwidth bandwidth, |
124 | u16 *nominal_rate) | 124 | u16 *nominal_rate) |
125 | { | 125 | { |
126 | u32 adc_clock = 45056; /* 45.056 MHz */ | ||
127 | u8 bw; | ||
128 | struct zl10353_state *state = fe->demodulator_priv; | 126 | struct zl10353_state *state = fe->demodulator_priv; |
127 | u32 adc_clock = 450560; /* 45.056 MHz */ | ||
128 | u64 value; | ||
129 | u8 bw; | ||
129 | 130 | ||
130 | if (state->config.adc_clock) | 131 | if (state->config.adc_clock) |
131 | adc_clock = state->config.adc_clock; | 132 | adc_clock = state->config.adc_clock; |
@@ -143,7 +144,9 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe, | |||
143 | break; | 144 | break; |
144 | } | 145 | } |
145 | 146 | ||
146 | *nominal_rate = (bw * (1 << 23) / 7 * 125 + adc_clock / 2) / adc_clock; | 147 | value = (bw * (u64)10 * (1 << 23) / 7 * 125 + adc_clock / 2); |
148 | do_div(value, adc_clock); | ||
149 | *nominal_rate = value; | ||
147 | 150 | ||
148 | dprintk("%s: bw %d, adc_clock %d => 0x%x\n", | 151 | dprintk("%s: bw %d, adc_clock %d => 0x%x\n", |
149 | __FUNCTION__, bw, adc_clock, *nominal_rate); | 152 | __FUNCTION__, bw, adc_clock, *nominal_rate); |
@@ -153,8 +156,8 @@ static void zl10353_calc_input_freq(struct dvb_frontend *fe, | |||
153 | u16 *input_freq) | 156 | u16 *input_freq) |
154 | { | 157 | { |
155 | struct zl10353_state *state = fe->demodulator_priv; | 158 | struct zl10353_state *state = fe->demodulator_priv; |
156 | u32 adc_clock = 45056; /* 45.056 MHz */ | 159 | u32 adc_clock = 450560; /* 45.056 MHz */ |
157 | int if2 = 36167; /* 36.167 MHz */ | 160 | int if2 = 361667; /* 36.1667 MHz */ |
158 | int ife; | 161 | int ife; |
159 | u64 value; | 162 | u64 value; |
160 | 163 | ||
@@ -170,7 +173,7 @@ static void zl10353_calc_input_freq(struct dvb_frontend *fe, | |||
170 | if (ife > adc_clock / 2) | 173 | if (ife > adc_clock / 2) |
171 | ife = adc_clock - ife; | 174 | ife = adc_clock - ife; |
172 | } | 175 | } |
173 | value = 65536ULL * ife + adc_clock / 2; | 176 | value = (u64)65536 * ife + adc_clock / 2; |
174 | do_div(value, adc_clock); | 177 | do_div(value, adc_clock); |
175 | *input_freq = -value; | 178 | *input_freq = -value; |
176 | 179 | ||
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h index 2660cec93f83..fc734c22b5fa 100644 --- a/drivers/media/dvb/frontends/zl10353.h +++ b/drivers/media/dvb/frontends/zl10353.h | |||
@@ -29,9 +29,9 @@ struct zl10353_config | |||
29 | /* demodulator's I2C address */ | 29 | /* demodulator's I2C address */ |
30 | u8 demod_address; | 30 | u8 demod_address; |
31 | 31 | ||
32 | /* frequencies in kHz */ | 32 | /* frequencies in units of 0.1kHz */ |
33 | int adc_clock; /* default: 45056 */ | 33 | int adc_clock; /* default: 450560 (45.056 MHz) */ |
34 | int if2; /* default: 36167 */ | 34 | int if2; /* default: 361667 (36.1667 MHz) */ |
35 | 35 | ||
36 | /* set if no pll is connected to the secondary i2c bus */ | 36 | /* set if no pll is connected to the secondary i2c bus */ |
37 | int no_tuner; | 37 | int no_tuner; |
@@ -50,6 +50,6 @@ static inline struct dvb_frontend* zl10353_attach(const struct zl10353_config *c | |||
50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); |
51 | return NULL; | 51 | return NULL; |
52 | } | 52 | } |
53 | #endif // CONFIG_DVB_ZL10353 | 53 | #endif /* CONFIG_DVB_ZL10353 */ |
54 | 54 | ||
55 | #endif /* ZL10353_H */ | 55 | #endif /* ZL10353_H */ |