diff options
author | Krzysztof Helt <krzysztof.h1@wp.pl> | 2008-10-16 01:03:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:44 -0400 |
commit | 9a85cf51fb880e24179fc45d3ee7d5ff1eb58c3a (patch) | |
tree | 72a8689ab67530e5f1fe89a11f4e52b2d7380e69 /drivers/video/cirrusfb.c | |
parent | c395d3e8c7ed6d61ee87cb49187111122c8a499c (diff) |
cirrusfb: eliminate CRT registers from global structure
Move calculations of CRT register values into the cirrusfb_set_par_foo()
where the values are used.
Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/cirrusfb.c')
-rw-r--r-- | drivers/video/cirrusfb.c | 192 |
1 files changed, 83 insertions, 109 deletions
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c index 4e34a6817435..573bd456e5ab 100644 --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c | |||
@@ -334,22 +334,6 @@ struct cirrusfb_regs { | |||
334 | long multiplexing; | 334 | long multiplexing; |
335 | long mclk; | 335 | long mclk; |
336 | long divMCLK; | 336 | long divMCLK; |
337 | |||
338 | long HorizRes; /* The x resolution in pixel */ | ||
339 | long HorizTotal; | ||
340 | long HorizDispEnd; | ||
341 | long HorizBlankStart; | ||
342 | long HorizBlankEnd; | ||
343 | long HorizSyncStart; | ||
344 | long HorizSyncEnd; | ||
345 | |||
346 | long VertRes; /* the physical y resolution in scanlines */ | ||
347 | long VertTotal; | ||
348 | long VertDispEnd; | ||
349 | long VertSyncStart; | ||
350 | long VertSyncEnd; | ||
351 | long VertBlankStart; | ||
352 | long VertBlankEnd; | ||
353 | }; | 337 | }; |
354 | 338 | ||
355 | #ifdef CIRRUSFB_DEBUG | 339 | #ifdef CIRRUSFB_DEBUG |
@@ -664,8 +648,6 @@ static int cirrusfb_decode_var(const struct fb_var_screeninfo *var, | |||
664 | long maxclock; | 648 | long maxclock; |
665 | int maxclockidx = var->bits_per_pixel >> 3; | 649 | int maxclockidx = var->bits_per_pixel >> 3; |
666 | struct cirrusfb_info *cinfo = info->par; | 650 | struct cirrusfb_info *cinfo = info->par; |
667 | int xres, hfront, hsync, hback; | ||
668 | int yres, vfront, vsync, vback; | ||
669 | 651 | ||
670 | switch (var->bits_per_pixel) { | 652 | switch (var->bits_per_pixel) { |
671 | case 1: | 653 | case 1: |
@@ -723,7 +705,7 @@ static int cirrusfb_decode_var(const struct fb_var_screeninfo *var, | |||
723 | switch (var->bits_per_pixel) { | 705 | switch (var->bits_per_pixel) { |
724 | case 16: | 706 | case 16: |
725 | case 32: | 707 | case 32: |
726 | if (regs->HorizRes <= 800) | 708 | if (var->xres <= 800) |
727 | /* Xbh has this type of clock for 32-bit */ | 709 | /* Xbh has this type of clock for 32-bit */ |
728 | freq /= 2; | 710 | freq /= 2; |
729 | break; | 711 | break; |
@@ -735,57 +717,6 @@ static int cirrusfb_decode_var(const struct fb_var_screeninfo *var, | |||
735 | regs->mclk = cirrusfb_get_mclk(freq, var->bits_per_pixel, | 717 | regs->mclk = cirrusfb_get_mclk(freq, var->bits_per_pixel, |
736 | ®s->divMCLK); | 718 | ®s->divMCLK); |
737 | 719 | ||
738 | xres = var->xres; | ||
739 | hfront = var->right_margin; | ||
740 | hsync = var->hsync_len; | ||
741 | hback = var->left_margin; | ||
742 | |||
743 | yres = var->yres; | ||
744 | vfront = var->lower_margin; | ||
745 | vsync = var->vsync_len; | ||
746 | vback = var->upper_margin; | ||
747 | |||
748 | if (var->vmode & FB_VMODE_DOUBLE) { | ||
749 | yres *= 2; | ||
750 | vfront *= 2; | ||
751 | vsync *= 2; | ||
752 | vback *= 2; | ||
753 | } else if (var->vmode & FB_VMODE_INTERLACED) { | ||
754 | yres = (yres + 1) / 2; | ||
755 | vfront = (vfront + 1) / 2; | ||
756 | vsync = (vsync + 1) / 2; | ||
757 | vback = (vback + 1) / 2; | ||
758 | } | ||
759 | regs->HorizRes = xres; | ||
760 | regs->HorizTotal = (xres + hfront + hsync + hback) / 8 - 5; | ||
761 | regs->HorizDispEnd = xres / 8 - 1; | ||
762 | regs->HorizBlankStart = xres / 8; | ||
763 | /* does not count with "-5" */ | ||
764 | regs->HorizBlankEnd = regs->HorizTotal + 5; | ||
765 | regs->HorizSyncStart = (xres + hfront) / 8 + 1; | ||
766 | regs->HorizSyncEnd = (xres + hfront + hsync) / 8 + 1; | ||
767 | |||
768 | regs->VertRes = yres; | ||
769 | regs->VertTotal = yres + vfront + vsync + vback - 2; | ||
770 | regs->VertDispEnd = yres - 1; | ||
771 | regs->VertBlankStart = yres; | ||
772 | regs->VertBlankEnd = regs->VertTotal; | ||
773 | regs->VertSyncStart = yres + vfront - 1; | ||
774 | regs->VertSyncEnd = yres + vfront + vsync - 1; | ||
775 | |||
776 | if (regs->VertRes >= 1024) { | ||
777 | regs->VertTotal /= 2; | ||
778 | regs->VertSyncStart /= 2; | ||
779 | regs->VertSyncEnd /= 2; | ||
780 | regs->VertDispEnd /= 2; | ||
781 | } | ||
782 | if (regs->multiplexing) { | ||
783 | regs->HorizTotal /= 2; | ||
784 | regs->HorizSyncStart /= 2; | ||
785 | regs->HorizSyncEnd /= 2; | ||
786 | regs->HorizDispEnd /= 2; | ||
787 | } | ||
788 | |||
789 | return 0; | 720 | return 0; |
790 | } | 721 | } |
791 | 722 | ||
@@ -823,6 +754,8 @@ static int cirrusfb_set_par_foo(struct fb_info *info) | |||
823 | unsigned char tmp; | 754 | unsigned char tmp; |
824 | int offset = 0, err; | 755 | int offset = 0, err; |
825 | const struct cirrusfb_board_info_rec *bi; | 756 | const struct cirrusfb_board_info_rec *bi; |
757 | int hdispend, hsyncstart, hsyncend, htotal; | ||
758 | int yres, vdispend, vsyncstart, vsyncend, vtotal; | ||
826 | 759 | ||
827 | DPRINTK("ENTER\n"); | 760 | DPRINTK("ENTER\n"); |
828 | DPRINTK("Requested mode: %dx%dx%d\n", | 761 | DPRINTK("Requested mode: %dx%dx%d\n", |
@@ -840,76 +773,117 @@ static int cirrusfb_set_par_foo(struct fb_info *info) | |||
840 | 773 | ||
841 | bi = &cirrusfb_board_info[cinfo->btype]; | 774 | bi = &cirrusfb_board_info[cinfo->btype]; |
842 | 775 | ||
776 | hsyncstart = var->xres + var->right_margin; | ||
777 | hsyncend = hsyncstart + var->hsync_len; | ||
778 | htotal = (hsyncend + var->left_margin) / 8 - 5; | ||
779 | hdispend = var->xres / 8 - 1; | ||
780 | hsyncstart = hsyncstart / 8 + 1; | ||
781 | hsyncend = hsyncend / 8 + 1; | ||
782 | |||
783 | yres = var->yres; | ||
784 | vsyncstart = yres + var->lower_margin; | ||
785 | vsyncend = vsyncstart + var->vsync_len; | ||
786 | vtotal = vsyncend + var->upper_margin; | ||
787 | vdispend = yres - 1; | ||
788 | |||
789 | if (var->vmode & FB_VMODE_DOUBLE) { | ||
790 | yres *= 2; | ||
791 | vsyncstart *= 2; | ||
792 | vsyncend *= 2; | ||
793 | vtotal *= 2; | ||
794 | } else if (var->vmode & FB_VMODE_INTERLACED) { | ||
795 | yres = (yres + 1) / 2; | ||
796 | vsyncstart = (vsyncstart + 1) / 2; | ||
797 | vsyncend = (vsyncend + 1) / 2; | ||
798 | vtotal = (vtotal + 1) / 2; | ||
799 | } | ||
800 | |||
801 | vtotal -= 2; | ||
802 | vsyncstart -= 1; | ||
803 | vsyncend -= 1; | ||
804 | |||
805 | if (yres >= 1024) { | ||
806 | vtotal /= 2; | ||
807 | vsyncstart /= 2; | ||
808 | vsyncend /= 2; | ||
809 | vdispend /= 2; | ||
810 | } | ||
811 | if (regs.multiplexing) { | ||
812 | htotal /= 2; | ||
813 | hsyncstart /= 2; | ||
814 | hsyncend /= 2; | ||
815 | hdispend /= 2; | ||
816 | } | ||
843 | /* unlock register VGA_CRTC_H_TOTAL..CRT7 */ | 817 | /* unlock register VGA_CRTC_H_TOTAL..CRT7 */ |
844 | vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, 0x20); /* previously: 0x00) */ | 818 | vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, 0x20); /* previously: 0x00) */ |
845 | 819 | ||
846 | /* if debugging is enabled, all parameters get output before writing */ | 820 | /* if debugging is enabled, all parameters get output before writing */ |
847 | DPRINTK("CRT0: %ld\n", regs.HorizTotal); | 821 | DPRINTK("CRT0: %d\n", htotal); |
848 | vga_wcrt(regbase, VGA_CRTC_H_TOTAL, regs.HorizTotal); | 822 | vga_wcrt(regbase, VGA_CRTC_H_TOTAL, htotal); |
849 | 823 | ||
850 | DPRINTK("CRT1: %ld\n", regs.HorizDispEnd); | 824 | DPRINTK("CRT1: %d\n", hdispend); |
851 | vga_wcrt(regbase, VGA_CRTC_H_DISP, regs.HorizDispEnd); | 825 | vga_wcrt(regbase, VGA_CRTC_H_DISP, hdispend); |
852 | 826 | ||
853 | DPRINTK("CRT2: %ld\n", regs.HorizBlankStart); | 827 | DPRINTK("CRT2: %d\n", var->xres / 8); |
854 | vga_wcrt(regbase, VGA_CRTC_H_BLANK_START, regs.HorizBlankStart); | 828 | vga_wcrt(regbase, VGA_CRTC_H_BLANK_START, var->xres / 8); |
855 | 829 | ||
856 | /* + 128: Compatible read */ | 830 | /* + 128: Compatible read */ |
857 | DPRINTK("CRT3: 128+%ld\n", regs.HorizBlankEnd % 32); | 831 | DPRINTK("CRT3: 128+%d\n", (htotal + 5) % 32); |
858 | vga_wcrt(regbase, VGA_CRTC_H_BLANK_END, | 832 | vga_wcrt(regbase, VGA_CRTC_H_BLANK_END, |
859 | 128 + (regs.HorizBlankEnd % 32)); | 833 | 128 + ((htotal + 5) % 32)); |
860 | 834 | ||
861 | DPRINTK("CRT4: %ld\n", regs.HorizSyncStart); | 835 | DPRINTK("CRT4: %d\n", hsyncstart); |
862 | vga_wcrt(regbase, VGA_CRTC_H_SYNC_START, regs.HorizSyncStart); | 836 | vga_wcrt(regbase, VGA_CRTC_H_SYNC_START, hsyncstart); |
863 | 837 | ||
864 | tmp = regs.HorizSyncEnd % 32; | 838 | tmp = hsyncend % 32; |
865 | if (regs.HorizBlankEnd & 32) | 839 | if ((htotal + 5) & 32) |
866 | tmp += 128; | 840 | tmp += 128; |
867 | DPRINTK("CRT5: %d\n", tmp); | 841 | DPRINTK("CRT5: %d\n", tmp); |
868 | vga_wcrt(regbase, VGA_CRTC_H_SYNC_END, tmp); | 842 | vga_wcrt(regbase, VGA_CRTC_H_SYNC_END, tmp); |
869 | 843 | ||
870 | DPRINTK("CRT6: %ld\n", regs.VertTotal & 0xff); | 844 | DPRINTK("CRT6: %d\n", vtotal & 0xff); |
871 | vga_wcrt(regbase, VGA_CRTC_V_TOTAL, (regs.VertTotal & 0xff)); | 845 | vga_wcrt(regbase, VGA_CRTC_V_TOTAL, vtotal & 0xff); |
872 | 846 | ||
873 | tmp = 16; /* LineCompare bit #9 */ | 847 | tmp = 16; /* LineCompare bit #9 */ |
874 | if (regs.VertTotal & 256) | 848 | if (vtotal & 256) |
875 | tmp |= 1; | 849 | tmp |= 1; |
876 | if (regs.VertDispEnd & 256) | 850 | if (vdispend & 256) |
877 | tmp |= 2; | 851 | tmp |= 2; |
878 | if (regs.VertSyncStart & 256) | 852 | if (vsyncstart & 256) |
879 | tmp |= 4; | 853 | tmp |= 4; |
880 | if (regs.VertBlankStart & 256) | 854 | if ((vdispend + 1) & 256) |
881 | tmp |= 8; | 855 | tmp |= 8; |
882 | if (regs.VertTotal & 512) | 856 | if (vtotal & 512) |
883 | tmp |= 32; | 857 | tmp |= 32; |
884 | if (regs.VertDispEnd & 512) | 858 | if (vdispend & 512) |
885 | tmp |= 64; | 859 | tmp |= 64; |
886 | if (regs.VertSyncStart & 512) | 860 | if (vsyncstart & 512) |
887 | tmp |= 128; | 861 | tmp |= 128; |
888 | DPRINTK("CRT7: %d\n", tmp); | 862 | DPRINTK("CRT7: %d\n", tmp); |
889 | vga_wcrt(regbase, VGA_CRTC_OVERFLOW, tmp); | 863 | vga_wcrt(regbase, VGA_CRTC_OVERFLOW, tmp); |
890 | 864 | ||
891 | tmp = 0x40; /* LineCompare bit #8 */ | 865 | tmp = 0x40; /* LineCompare bit #8 */ |
892 | if (regs.VertBlankStart & 512) | 866 | if ((vdispend + 1) & 512) |
893 | tmp |= 0x20; | 867 | tmp |= 0x20; |
894 | if (var->vmode & FB_VMODE_DOUBLE) | 868 | if (var->vmode & FB_VMODE_DOUBLE) |
895 | tmp |= 0x80; | 869 | tmp |= 0x80; |
896 | DPRINTK("CRT9: %d\n", tmp); | 870 | DPRINTK("CRT9: %d\n", tmp); |
897 | vga_wcrt(regbase, VGA_CRTC_MAX_SCAN, tmp); | 871 | vga_wcrt(regbase, VGA_CRTC_MAX_SCAN, tmp); |
898 | 872 | ||
899 | DPRINTK("CRT10: %ld\n", regs.VertSyncStart & 0xff); | 873 | DPRINTK("CRT10: %d\n", vsyncstart & 0xff); |
900 | vga_wcrt(regbase, VGA_CRTC_V_SYNC_START, regs.VertSyncStart & 0xff); | 874 | vga_wcrt(regbase, VGA_CRTC_V_SYNC_START, vsyncstart & 0xff); |
901 | 875 | ||
902 | DPRINTK("CRT11: 64+32+%ld\n", regs.VertSyncEnd % 16); | 876 | DPRINTK("CRT11: 64+32+%d\n", vsyncend % 16); |
903 | vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, regs.VertSyncEnd % 16 + 64 + 32); | 877 | vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, vsyncend % 16 + 64 + 32); |
904 | 878 | ||
905 | DPRINTK("CRT12: %ld\n", regs.VertDispEnd & 0xff); | 879 | DPRINTK("CRT12: %d\n", vdispend & 0xff); |
906 | vga_wcrt(regbase, VGA_CRTC_V_DISP_END, regs.VertDispEnd & 0xff); | 880 | vga_wcrt(regbase, VGA_CRTC_V_DISP_END, vdispend & 0xff); |
907 | 881 | ||
908 | DPRINTK("CRT15: %ld\n", regs.VertBlankStart & 0xff); | 882 | DPRINTK("CRT15: %d\n", (vdispend + 1) & 0xff); |
909 | vga_wcrt(regbase, VGA_CRTC_V_BLANK_START, regs.VertBlankStart & 0xff); | 883 | vga_wcrt(regbase, VGA_CRTC_V_BLANK_START, (vdispend + 1) & 0xff); |
910 | 884 | ||
911 | DPRINTK("CRT16: %ld\n", regs.VertBlankEnd & 0xff); | 885 | DPRINTK("CRT16: %d\n", vtotal & 0xff); |
912 | vga_wcrt(regbase, VGA_CRTC_V_BLANK_END, regs.VertBlankEnd & 0xff); | 886 | vga_wcrt(regbase, VGA_CRTC_V_BLANK_END, vtotal & 0xff); |
913 | 887 | ||
914 | DPRINTK("CRT18: 0xff\n"); | 888 | DPRINTK("CRT18: 0xff\n"); |
915 | vga_wcrt(regbase, VGA_CRTC_LINE_COMPARE, 0xff); | 889 | vga_wcrt(regbase, VGA_CRTC_LINE_COMPARE, 0xff); |
@@ -917,13 +891,13 @@ static int cirrusfb_set_par_foo(struct fb_info *info) | |||
917 | tmp = 0; | 891 | tmp = 0; |
918 | if (var->vmode & FB_VMODE_INTERLACED) | 892 | if (var->vmode & FB_VMODE_INTERLACED) |
919 | tmp |= 1; | 893 | tmp |= 1; |
920 | if (regs.HorizBlankEnd & 64) | 894 | if ((htotal + 5) & 64) |
921 | tmp |= 16; | 895 | tmp |= 16; |
922 | if (regs.HorizBlankEnd & 128) | 896 | if ((htotal + 5) & 128) |
923 | tmp |= 32; | 897 | tmp |= 32; |
924 | if (regs.VertBlankEnd & 256) | 898 | if (vtotal & 256) |
925 | tmp |= 64; | 899 | tmp |= 64; |
926 | if (regs.VertBlankEnd & 512) | 900 | if (vtotal & 512) |
927 | tmp |= 128; | 901 | tmp |= 128; |
928 | 902 | ||
929 | DPRINTK("CRT1a: %d\n", tmp); | 903 | DPRINTK("CRT1a: %d\n", tmp); |
@@ -948,7 +922,7 @@ static int cirrusfb_set_par_foo(struct fb_info *info) | |||
948 | DPRINTK("CL_SEQR1B: %ld\n", (long) tmp); | 922 | DPRINTK("CL_SEQR1B: %ld\n", (long) tmp); |
949 | vga_wseq(regbase, CL_SEQR1B, tmp); | 923 | vga_wseq(regbase, CL_SEQR1B, tmp); |
950 | 924 | ||
951 | if (regs.VertRes >= 1024) | 925 | if (yres >= 1024) |
952 | /* 1280x1024 */ | 926 | /* 1280x1024 */ |
953 | vga_wcrt(regbase, VGA_CRTC_MODE, 0xc7); | 927 | vga_wcrt(regbase, VGA_CRTC_MODE, 0xc7); |
954 | else | 928 | else |
@@ -962,7 +936,7 @@ static int cirrusfb_set_par_foo(struct fb_info *info) | |||
962 | /* don't know if it would hurt to also program this if no interlaced */ | 936 | /* don't know if it would hurt to also program this if no interlaced */ |
963 | /* mode is used, but I feel better this way.. :-) */ | 937 | /* mode is used, but I feel better this way.. :-) */ |
964 | if (var->vmode & FB_VMODE_INTERLACED) | 938 | if (var->vmode & FB_VMODE_INTERLACED) |
965 | vga_wcrt(regbase, VGA_CRTC_REGS, regs.HorizTotal / 2); | 939 | vga_wcrt(regbase, VGA_CRTC_REGS, htotal / 2); |
966 | else | 940 | else |
967 | vga_wcrt(regbase, VGA_CRTC_REGS, 0x00); /* interlace control */ | 941 | vga_wcrt(regbase, VGA_CRTC_REGS, 0x00); /* interlace control */ |
968 | 942 | ||
@@ -1208,7 +1182,7 @@ static int cirrusfb_set_par_foo(struct fb_info *info) | |||
1208 | 1182 | ||
1209 | case BT_ALPINE: | 1183 | case BT_ALPINE: |
1210 | DPRINTK(" (for GD543x)\n"); | 1184 | DPRINTK(" (for GD543x)\n"); |
1211 | if (regs.HorizRes >= 1024) | 1185 | if (var->xres >= 1024) |
1212 | vga_wseq(regbase, CL_SEQR7, 0xa7); | 1186 | vga_wseq(regbase, CL_SEQR7, 0xa7); |
1213 | else | 1187 | else |
1214 | vga_wseq(regbase, CL_SEQR7, 0xa3); | 1188 | vga_wseq(regbase, CL_SEQR7, 0xa3); |