diff options
author | Manu Abraham <abraham.manu@gmail.com> | 2009-04-08 20:14:00 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 18:20:39 -0300 |
commit | 15bb366e86e07820374ec313170aab65d4e1d983 (patch) | |
tree | 0e045378faddba2fbc807b345b0dbf128025d480 /drivers | |
parent | 94a809143a47343b45c73e84f7f26e3087c2fd62 (diff) |
V4L/DVB (11588): stv090x: support > 60MSPS, simplify Srate calculation
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/dvb/frontends/stv090x.c | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index a350364a42f..6e7c47a1f67 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c @@ -725,18 +725,22 @@ static int stv090x_set_srate(struct stv090x_state *state, u32 srate) { u32 sym; - if (srate > 6000000) { - sym = (srate / 1000) * 65536; - sym /= (state->mclk / 1000); + if (srate > 60000000) { + sym = (srate << 4); /* SR * 2^16 / master_clk */ + sym /= (state->mclk >> 12); + } else if (srate > 6000000) { + sym = (srate << 6); + sym /= (state->mclk >> 10); } else { - sym = (srate / 100) * 65536; - sym /= (state->mclk / 100); + sym = (srate << 9); + sym /= (state->mclk >> 7); } - if (STV090x_WRITE_DEMOD(state, SFRINIT1, (sym >> 8) & 0xff) < 0) /* MSB */ + if (STV090x_WRITE_DEMOD(state, SFRINIT1, (sym >> 8) & 0x7f) < 0) /* MSB */ goto err; if (STV090x_WRITE_DEMOD(state, SFRINIT0, (sym & 0xff)) < 0) /* LSB */ goto err; + return 0; err: dprintk(FE_ERROR, 1, "I/O error"); @@ -748,17 +752,29 @@ static int stv090x_set_max_srate(struct stv090x_state *state, u32 clk, u32 srate u32 sym; srate = 105 * (srate / 100); - if (srate > 6000000) { - sym = (srate / 1000) * 65536; - sym /= (clk / 1000); + if (srate > 60000000) { + sym = (srate << 4); /* SR * 2^16 / master_clk */ + sym /= (state->mclk >> 12); + } else if (srate > 6000000) { + sym = (srate << 6); + sym /= (state->mclk >> 10); } else { - sym = (srate / 100) * 65536; - sym /= (clk / 100); + sym = (srate << 9); + sym /= (state->mclk >> 7); } - if (STV090x_WRITE_DEMOD(state, SFRUP1, (sym >> 8) & 0x7f) < 0) /* MSB */ - goto err; - if (STV090x_WRITE_DEMOD(state, SFRUP0, sym & 0xff) < 0) /* LSB */ - goto err; + + if (sym < 0x7fff) { + if (STV090x_WRITE_DEMOD(state, SFRUP1, (sym >> 8) & 0x7f) < 0) /* MSB */ + goto err; + if (STV090x_WRITE_DEMOD(state, SFRUP0, sym & 0xff) < 0) /* LSB */ + goto err; + } else { + if (STV090x_WRITE_DEMOD(state, SFRUP1, 0x7f) < 0) /* MSB */ + goto err; + if (STV090x_WRITE_DEMOD(state, SFRUP0, 0xff) < 0) /* LSB */ + goto err; + } + return 0; err: dprintk(FE_ERROR, 1, "I/O error"); @@ -770,13 +786,17 @@ static int stv090x_set_min_srate(struct stv090x_state *state, u32 clk, u32 srate u32 sym; srate = 95 * (srate / 100); - if (srate > 6000000) { - sym = (srate / 1000) * 65536; - sym /= (clk / 1000); + if (srate > 60000000) { + sym = (srate << 4); /* SR * 2^16 / master_clk */ + sym /= (state->mclk >> 12); + } else if (srate > 6000000) { + sym = (srate << 6); + sym /= (state->mclk >> 10); } else { - sym = (srate / 100) * 65536; - sym /= (clk / 100); + sym = (srate << 9); + sym /= (state->mclk >> 7); } + if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym >> 8) & 0xff)) < 0) /* MSB */ goto err; if (STV090x_WRITE_DEMOD(state, SFRLOW0, (sym & 0xff)) < 0) /* LSB */ |