aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/tridentfb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/tridentfb.c')
-rw-r--r--drivers/video/tridentfb.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
index bd54cd0de39a..beefab2992c0 100644
--- a/drivers/video/tridentfb.c
+++ b/drivers/video/tridentfb.c
@@ -27,7 +27,6 @@
27#define VERSION "0.7.8-NEWAPI" 27#define VERSION "0.7.8-NEWAPI"
28 28
29struct tridentfb_par { 29struct tridentfb_par {
30 int vclk; /* in MHz */
31 void __iomem *io_virt; /* iospace virtual memory address */ 30 void __iomem *io_virt; /* iospace virtual memory address */
32}; 31};
33 32
@@ -669,27 +668,26 @@ static void set_screen_start(int base)
669 (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17)); 668 (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17));
670} 669}
671 670
672/* Use 20.12 fixed-point for NTSC value and frequency calculation */
673#define calc_freq(n, m, k) ( ((unsigned long)0xE517 * (n + 8) / ((m + 2) * (1 << k))) >> 12 )
674
675/* Set dotclock frequency */ 671/* Set dotclock frequency */
676static void set_vclk(int freq) 672static void set_vclk(unsigned long freq)
677{ 673{
678 int m, n, k; 674 int m, n, k;
679 int f, fi, d, di; 675 unsigned long f, fi, d, di;
680 unsigned char lo = 0, hi = 0; 676 unsigned char lo = 0, hi = 0;
681 677
682 d = 20; 678 d = 20000;
683 for (k = 2; k >= 0; k--) 679 for (k = 2; k >= 0; k--)
684 for (m = 0; m < 63; m++) 680 for (m = 0; m < 63; m++)
685 for (n = 0; n < 128; n++) { 681 for (n = 0; n < 128; n++) {
686 fi = calc_freq(n, m, k); 682 fi = ((14318l * (n + 8)) / (m + 2)) >> k;
687 if ((di = abs(fi - freq)) < d) { 683 if ((di = abs(fi - freq)) < d) {
688 d = di; 684 d = di;
689 f = fi; 685 f = fi;
690 lo = n; 686 lo = n;
691 hi = (k << 6) | m; 687 hi = (k << 6) | m;
692 } 688 }
689 if (fi > freq)
690 break;
693 } 691 }
694 if (chip3D) { 692 if (chip3D) {
695 write3C4(ClockHigh, hi); 693 write3C4(ClockHigh, hi);
@@ -888,6 +886,8 @@ static int tridentfb_set_par(struct fb_info *info)
888 struct fb_var_screeninfo *var = &info->var; 886 struct fb_var_screeninfo *var = &info->var;
889 int bpp = var->bits_per_pixel; 887 int bpp = var->bits_per_pixel;
890 unsigned char tmp; 888 unsigned char tmp;
889 unsigned long vclk;
890
891 debug("enter\n"); 891 debug("enter\n");
892 hdispend = var->xres / 8 - 1; 892 hdispend = var->xres / 8 - 1;
893 hsyncstart = (var->xres + var->right_margin) / 8; 893 hsyncstart = (var->xres + var->right_margin) / 8;
@@ -905,7 +905,6 @@ static int tridentfb_set_par(struct fb_info *info)
905 vblankstart = var->yres; 905 vblankstart = var->yres;
906 vblankend = vtotal + 2; 906 vblankend = vtotal + 2;
907 907
908 enable_mmio();
909 crtc_unlock(); 908 crtc_unlock();
910 write3CE(CyberControl, 8); 909 write3CE(CyberControl, 8);
911 910
@@ -1015,11 +1014,11 @@ static int tridentfb_set_par(struct fb_info *info)
1015 write3X4(Performance, 0x92); 1014 write3X4(Performance, 0x92);
1016 write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */ 1015 write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */
1017 1016
1018 /* convert from picoseconds to MHz */ 1017 /* convert from picoseconds to kHz */
1019 par->vclk = 1000000 / info->var.pixclock; 1018 vclk = PICOS2KHZ(info->var.pixclock);
1020 if (bpp == 32) 1019 if (bpp == 32)
1021 par->vclk *= 2; 1020 vclk *= 2;
1022 set_vclk(par->vclk); 1021 set_vclk(vclk);
1023 1022
1024 write3C4(0, 3); 1023 write3C4(0, 3);
1025 write3C4(1, 1); /* set char clock 8 dots wide */ 1024 write3C4(1, 1); /* set char clock 8 dots wide */