summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/frontends
diff options
context:
space:
mode:
authorManu Abraham <manu@linuxtv.org>2009-04-09 03:14:00 +0400
committerManu Abraham <manu@linuxtv.org>2009-04-09 03:14:00 +0400
commitf0275699c613cb8cbe3aebf02b8db03c68ba28f1 (patch)
tree867ed385031f6fb2e0626b4a8da06fd469009a6e /linux/drivers/media/dvb/frontends
parent5fa5b751c79a00c20a2717b642094fab5945c1b3 (diff)
downloadmediapointer-dvb-s2-f0275699c613cb8cbe3aebf02b8db03c68ba28f1.tar.gz
mediapointer-dvb-s2-f0275699c613cb8cbe3aebf02b8db03c68ba28f1.tar.bz2
Support > 60MSPS, simplify Srate calculation
From: Manu Abraham <abraham.manu@gmail.com> Signed-off-by: Manu Abraham <manu@linuxtv.org>
Diffstat (limited to 'linux/drivers/media/dvb/frontends')
-rw-r--r--linux/drivers/media/dvb/frontends/stv090x.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/linux/drivers/media/dvb/frontends/stv090x.c b/linux/drivers/media/dvb/frontends/stv090x.c
index 219b10d0c..3a98731f0 100644
--- a/linux/drivers/media/dvb/frontends/stv090x.c
+++ b/linux/drivers/media/dvb/frontends/stv090x.c
@@ -1510,18 +1510,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");
@@ -1533,17 +1537,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");
@@ -1555,13 +1571,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 */