summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb
diff options
context:
space:
mode:
authorChris Pascoe <c.pascoe@itee.uq.edu.au>2007-11-20 21:17:54 +1000
committerChris Pascoe <c.pascoe@itee.uq.edu.au>2007-11-20 21:17:54 +1000
commitc5810836461ecca233f23cf834fe738ea36a95c8 (patch)
tree03f92fef33151fd7761a16ca064afcb9561eac7e /linux/drivers/media/dvb
parent4de1c600c7600abdac0c940ad71f3a07432eeaf2 (diff)
downloadmediapointer-dvb-s2-c5810836461ecca233f23cf834fe738ea36a95c8.tar.gz
mediapointer-dvb-s2-c5810836461ecca233f23cf834fe738ea36a95c8.tar.bz2
zl10353: store frequencies in 0.1kHz to eliminate rounding errors
From: Chris Pascoe <c.pascoe@itee.uq.edu.au> 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>
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r--linux/drivers/media/dvb/dvb-usb/cxusb.c2
-rw-r--r--linux/drivers/media/dvb/frontends/zl10353.c15
-rw-r--r--linux/drivers/media/dvb/frontends/zl10353.h8
3 files changed, 14 insertions, 11 deletions
diff --git a/linux/drivers/media/dvb/dvb-usb/cxusb.c b/linux/drivers/media/dvb/dvb-usb/cxusb.c
index 6b6633577..a6196f9ac 100644
--- a/linux/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/linux/drivers/media/dvb/dvb-usb/cxusb.c
@@ -435,7 +435,7 @@ static struct mt352_config cxusb_mt352_config = {
static struct zl10353_config cxusb_zl10353_xc3028_config = {
.demod_address = 0x0f,
- .if2 = 4560,
+ .if2 = 45600,
.no_tuner = 1,
.parallel_ts = 1,
};
diff --git a/linux/drivers/media/dvb/frontends/zl10353.c b/linux/drivers/media/dvb/frontends/zl10353.c
index e3ba1f23b..276612e00 100644
--- a/linux/drivers/media/dvb/frontends/zl10353.c
+++ b/linux/drivers/media/dvb/frontends/zl10353.c
@@ -128,9 +128,10 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe,
enum fe_bandwidth bandwidth,
u16 *nominal_rate)
{
- u32 adc_clock = 45056; /* 45.056 MHz */
- u8 bw;
struct zl10353_state *state = fe->demodulator_priv;
+ u32 adc_clock = 450560; /* 45.056 MHz */
+ u64 value;
+ u8 bw;
if (state->config.adc_clock)
adc_clock = state->config.adc_clock;
@@ -148,7 +149,9 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe,
break;
}
- *nominal_rate = (bw * (1 << 23) / 7 * 125 + adc_clock / 2) / adc_clock;
+ value = (bw * (u64)10 * (1 << 23) / 7 * 125 + adc_clock / 2);
+ do_div(value, adc_clock);
+ *nominal_rate = value;
dprintk("%s: bw %d, adc_clock %d => 0x%x\n",
__FUNCTION__, bw, adc_clock, *nominal_rate);
@@ -158,8 +161,8 @@ static void zl10353_calc_input_freq(struct dvb_frontend *fe,
u16 *input_freq)
{
struct zl10353_state *state = fe->demodulator_priv;
- u32 adc_clock = 45056; /* 45.056 MHz */
- int if2 = 36167; /* 36.167 MHz */
+ u32 adc_clock = 450560; /* 45.056 MHz */
+ int if2 = 361667; /* 36.1667 MHz */
int ife;
u64 value;
@@ -175,7 +178,7 @@ static void zl10353_calc_input_freq(struct dvb_frontend *fe,
if (ife > adc_clock / 2)
ife = adc_clock - ife;
}
- value = 65536ULL * ife + adc_clock / 2;
+ value = (u64)65536 * ife + adc_clock / 2;
do_div(value, adc_clock);
*input_freq = -value;
diff --git a/linux/drivers/media/dvb/frontends/zl10353.h b/linux/drivers/media/dvb/frontends/zl10353.h
index 2660cec93..fc734c22b 100644
--- a/linux/drivers/media/dvb/frontends/zl10353.h
+++ b/linux/drivers/media/dvb/frontends/zl10353.h
@@ -29,9 +29,9 @@ struct zl10353_config
/* demodulator's I2C address */
u8 demod_address;
- /* frequencies in kHz */
- int adc_clock; /* default: 45056 */
- int if2; /* default: 36167 */
+ /* frequencies in units of 0.1kHz */
+ int adc_clock; /* default: 450560 (45.056 MHz) */
+ int if2; /* default: 361667 (36.1667 MHz) */
/* set if no pll is connected to the secondary i2c bus */
int no_tuner;
@@ -50,6 +50,6 @@ static inline struct dvb_frontend* zl10353_attach(const struct zl10353_config *c
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
return NULL;
}
-#endif // CONFIG_DVB_ZL10353
+#endif /* CONFIG_DVB_ZL10353 */
#endif /* ZL10353_H */