aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorManu Abraham <abraham.manu@gmail.com>2009-04-08 19:14:00 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:20:39 -0400
commit15bb366e86e07820374ec313170aab65d4e1d983 (patch)
tree0e045378faddba2fbc807b345b0dbf128025d480 /drivers/media/dvb
parent94a809143a47343b45c73e84f7f26e3087c2fd62 (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/media/dvb')
-rw-r--r--drivers/media/dvb/frontends/stv090x.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c
index a350364a42f5..6e7c47a1f670 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)
725{ 725{
726 u32 sym; 726 u32 sym;
727 727
728 if (srate > 6000000) { 728 if (srate > 60000000) {
729 sym = (srate / 1000) * 65536; 729 sym = (srate << 4); /* SR * 2^16 / master_clk */
730 sym /= (state->mclk / 1000); 730 sym /= (state->mclk >> 12);
731 } else if (srate > 6000000) {
732 sym = (srate << 6);
733 sym /= (state->mclk >> 10);
731 } else { 734 } else {
732 sym = (srate / 100) * 65536; 735 sym = (srate << 9);
733 sym /= (state->mclk / 100); 736 sym /= (state->mclk >> 7);
734 } 737 }
735 738
736 if (STV090x_WRITE_DEMOD(state, SFRINIT1, (sym >> 8) & 0xff) < 0) /* MSB */ 739 if (STV090x_WRITE_DEMOD(state, SFRINIT1, (sym >> 8) & 0x7f) < 0) /* MSB */
737 goto err; 740 goto err;
738 if (STV090x_WRITE_DEMOD(state, SFRINIT0, (sym & 0xff)) < 0) /* LSB */ 741 if (STV090x_WRITE_DEMOD(state, SFRINIT0, (sym & 0xff)) < 0) /* LSB */
739 goto err; 742 goto err;
743
740 return 0; 744 return 0;
741err: 745err:
742 dprintk(FE_ERROR, 1, "I/O error"); 746 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
748 u32 sym; 752 u32 sym;
749 753
750 srate = 105 * (srate / 100); 754 srate = 105 * (srate / 100);
751 if (srate > 6000000) { 755 if (srate > 60000000) {
752 sym = (srate / 1000) * 65536; 756 sym = (srate << 4); /* SR * 2^16 / master_clk */
753 sym /= (clk / 1000); 757 sym /= (state->mclk >> 12);
758 } else if (srate > 6000000) {
759 sym = (srate << 6);
760 sym /= (state->mclk >> 10);
754 } else { 761 } else {
755 sym = (srate / 100) * 65536; 762 sym = (srate << 9);
756 sym /= (clk / 100); 763 sym /= (state->mclk >> 7);
757 } 764 }
758 if (STV090x_WRITE_DEMOD(state, SFRUP1, (sym >> 8) & 0x7f) < 0) /* MSB */ 765
759 goto err; 766 if (sym < 0x7fff) {
760 if (STV090x_WRITE_DEMOD(state, SFRUP0, sym & 0xff) < 0) /* LSB */ 767 if (STV090x_WRITE_DEMOD(state, SFRUP1, (sym >> 8) & 0x7f) < 0) /* MSB */
761 goto err; 768 goto err;
769 if (STV090x_WRITE_DEMOD(state, SFRUP0, sym & 0xff) < 0) /* LSB */
770 goto err;
771 } else {
772 if (STV090x_WRITE_DEMOD(state, SFRUP1, 0x7f) < 0) /* MSB */
773 goto err;
774 if (STV090x_WRITE_DEMOD(state, SFRUP0, 0xff) < 0) /* LSB */
775 goto err;
776 }
777
762 return 0; 778 return 0;
763err: 779err:
764 dprintk(FE_ERROR, 1, "I/O error"); 780 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
770 u32 sym; 786 u32 sym;
771 787
772 srate = 95 * (srate / 100); 788 srate = 95 * (srate / 100);
773 if (srate > 6000000) { 789 if (srate > 60000000) {
774 sym = (srate / 1000) * 65536; 790 sym = (srate << 4); /* SR * 2^16 / master_clk */
775 sym /= (clk / 1000); 791 sym /= (state->mclk >> 12);
792 } else if (srate > 6000000) {
793 sym = (srate << 6);
794 sym /= (state->mclk >> 10);
776 } else { 795 } else {
777 sym = (srate / 100) * 65536; 796 sym = (srate << 9);
778 sym /= (clk / 100); 797 sym /= (state->mclk >> 7);
779 } 798 }
799
780 if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym >> 8) & 0xff)) < 0) /* MSB */ 800 if (STV090x_WRITE_DEMOD(state, SFRLOW1, ((sym >> 8) & 0xff)) < 0) /* MSB */
781 goto err; 801 goto err;
782 if (STV090x_WRITE_DEMOD(state, SFRLOW0, (sym & 0xff)) < 0) /* LSB */ 802 if (STV090x_WRITE_DEMOD(state, SFRLOW0, (sym & 0xff)) < 0) /* LSB */