diff options
author | Chris Pascoe <c.pascoe@itee.uq.edu.au> | 2007-11-20 08:17:54 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 19:02:37 -0200 |
commit | a1dcd9de648c8cf21abaeca7f77885665eed4117 (patch) | |
tree | f35cdf7d007056445a0603a12fb20d3eed5ec7ba /drivers/media/dvb/frontends/zl10353.c | |
parent | 702a67624e4bc9c7056418b576af928940b7dbb9 (diff) | |
download | kernel_samsung_smdk4412-a1dcd9de648c8cf21abaeca7f77885665eed4117.tar.gz kernel_samsung_smdk4412-a1dcd9de648c8cf21abaeca7f77885665eed4117.tar.bz2 kernel_samsung_smdk4412-a1dcd9de648c8cf21abaeca7f77885665eed4117.zip |
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>
Diffstat (limited to 'drivers/media/dvb/frontends/zl10353.c')
-rw-r--r-- | drivers/media/dvb/frontends/zl10353.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c index 1736c6ac39c..091fbcced00 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, 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; @@ -143,7 +144,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); @@ -153,8 +156,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; @@ -170,7 +173,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; |