diff options
Diffstat (limited to 'drivers/video/sis/init.c')
-rw-r--r-- | drivers/video/sis/init.c | 685 |
1 files changed, 49 insertions, 636 deletions
diff --git a/drivers/video/sis/init.c b/drivers/video/sis/init.c index c311ad3c3687..31137adc8fba 100644 --- a/drivers/video/sis/init.c +++ b/drivers/video/sis/init.c | |||
@@ -62,11 +62,11 @@ | |||
62 | 62 | ||
63 | #include "init.h" | 63 | #include "init.h" |
64 | 64 | ||
65 | #ifdef SIS300 | 65 | #ifdef CONFIG_FB_SIS_300 |
66 | #include "300vtbl.h" | 66 | #include "300vtbl.h" |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #ifdef SIS315H | 69 | #ifdef CONFIG_FB_SIS_315 |
70 | #include "310vtbl.h" | 70 | #include "310vtbl.h" |
71 | #endif | 71 | #endif |
72 | 72 | ||
@@ -78,7 +78,7 @@ | |||
78 | /* POINTER INITIALIZATION */ | 78 | /* POINTER INITIALIZATION */ |
79 | /*********************************************/ | 79 | /*********************************************/ |
80 | 80 | ||
81 | #if defined(SIS300) || defined(SIS315H) | 81 | #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) |
82 | static void | 82 | static void |
83 | InitCommonPointer(struct SiS_Private *SiS_Pr) | 83 | InitCommonPointer(struct SiS_Private *SiS_Pr) |
84 | { | 84 | { |
@@ -160,7 +160,7 @@ InitCommonPointer(struct SiS_Private *SiS_Pr) | |||
160 | } | 160 | } |
161 | #endif | 161 | #endif |
162 | 162 | ||
163 | #ifdef SIS300 | 163 | #ifdef CONFIG_FB_SIS_300 |
164 | static void | 164 | static void |
165 | InitTo300Pointer(struct SiS_Private *SiS_Pr) | 165 | InitTo300Pointer(struct SiS_Private *SiS_Pr) |
166 | { | 166 | { |
@@ -237,7 +237,7 @@ InitTo300Pointer(struct SiS_Private *SiS_Pr) | |||
237 | } | 237 | } |
238 | #endif | 238 | #endif |
239 | 239 | ||
240 | #ifdef SIS315H | 240 | #ifdef CONFIG_FB_SIS_315 |
241 | static void | 241 | static void |
242 | InitTo310Pointer(struct SiS_Private *SiS_Pr) | 242 | InitTo310Pointer(struct SiS_Private *SiS_Pr) |
243 | { | 243 | { |
@@ -321,13 +321,13 @@ bool | |||
321 | SiSInitPtr(struct SiS_Private *SiS_Pr) | 321 | SiSInitPtr(struct SiS_Private *SiS_Pr) |
322 | { | 322 | { |
323 | if(SiS_Pr->ChipType < SIS_315H) { | 323 | if(SiS_Pr->ChipType < SIS_315H) { |
324 | #ifdef SIS300 | 324 | #ifdef CONFIG_FB_SIS_300 |
325 | InitTo300Pointer(SiS_Pr); | 325 | InitTo300Pointer(SiS_Pr); |
326 | #else | 326 | #else |
327 | return false; | 327 | return false; |
328 | #endif | 328 | #endif |
329 | } else { | 329 | } else { |
330 | #ifdef SIS315H | 330 | #ifdef CONFIG_FB_SIS_315 |
331 | InitTo310Pointer(SiS_Pr); | 331 | InitTo310Pointer(SiS_Pr); |
332 | #else | 332 | #else |
333 | return false; | 333 | return false; |
@@ -340,9 +340,7 @@ SiSInitPtr(struct SiS_Private *SiS_Pr) | |||
340 | /* HELPER: Get ModeID */ | 340 | /* HELPER: Get ModeID */ |
341 | /*********************************************/ | 341 | /*********************************************/ |
342 | 342 | ||
343 | #ifndef SIS_XORG_XF86 | ||
344 | static | 343 | static |
345 | #endif | ||
346 | unsigned short | 344 | unsigned short |
347 | SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, | 345 | SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, |
348 | int Depth, bool FSTN, int LCDwidth, int LCDheight) | 346 | int Depth, bool FSTN, int LCDwidth, int LCDheight) |
@@ -884,51 +882,51 @@ SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDispl | |||
884 | void | 882 | void |
885 | SiS_SetReg(SISIOADDRESS port, unsigned short index, unsigned short data) | 883 | SiS_SetReg(SISIOADDRESS port, unsigned short index, unsigned short data) |
886 | { | 884 | { |
887 | OutPortByte(port, index); | 885 | outb((u8)index, port); |
888 | OutPortByte(port + 1, data); | 886 | outb((u8)data, port + 1); |
889 | } | 887 | } |
890 | 888 | ||
891 | void | 889 | void |
892 | SiS_SetRegByte(SISIOADDRESS port, unsigned short data) | 890 | SiS_SetRegByte(SISIOADDRESS port, unsigned short data) |
893 | { | 891 | { |
894 | OutPortByte(port, data); | 892 | outb((u8)data, port); |
895 | } | 893 | } |
896 | 894 | ||
897 | void | 895 | void |
898 | SiS_SetRegShort(SISIOADDRESS port, unsigned short data) | 896 | SiS_SetRegShort(SISIOADDRESS port, unsigned short data) |
899 | { | 897 | { |
900 | OutPortWord(port, data); | 898 | outw((u16)data, port); |
901 | } | 899 | } |
902 | 900 | ||
903 | void | 901 | void |
904 | SiS_SetRegLong(SISIOADDRESS port, unsigned int data) | 902 | SiS_SetRegLong(SISIOADDRESS port, unsigned int data) |
905 | { | 903 | { |
906 | OutPortLong(port, data); | 904 | outl((u32)data, port); |
907 | } | 905 | } |
908 | 906 | ||
909 | unsigned char | 907 | unsigned char |
910 | SiS_GetReg(SISIOADDRESS port, unsigned short index) | 908 | SiS_GetReg(SISIOADDRESS port, unsigned short index) |
911 | { | 909 | { |
912 | OutPortByte(port, index); | 910 | outb((u8)index, port); |
913 | return(InPortByte(port + 1)); | 911 | return inb(port + 1); |
914 | } | 912 | } |
915 | 913 | ||
916 | unsigned char | 914 | unsigned char |
917 | SiS_GetRegByte(SISIOADDRESS port) | 915 | SiS_GetRegByte(SISIOADDRESS port) |
918 | { | 916 | { |
919 | return(InPortByte(port)); | 917 | return inb(port); |
920 | } | 918 | } |
921 | 919 | ||
922 | unsigned short | 920 | unsigned short |
923 | SiS_GetRegShort(SISIOADDRESS port) | 921 | SiS_GetRegShort(SISIOADDRESS port) |
924 | { | 922 | { |
925 | return(InPortWord(port)); | 923 | return inw(port); |
926 | } | 924 | } |
927 | 925 | ||
928 | unsigned int | 926 | unsigned int |
929 | SiS_GetRegLong(SISIOADDRESS port) | 927 | SiS_GetRegLong(SISIOADDRESS port) |
930 | { | 928 | { |
931 | return(InPortLong(port)); | 929 | return inl(port); |
932 | } | 930 | } |
933 | 931 | ||
934 | void | 932 | void |
@@ -1089,7 +1087,7 @@ static void | |||
1089 | SiSInitPCIetc(struct SiS_Private *SiS_Pr) | 1087 | SiSInitPCIetc(struct SiS_Private *SiS_Pr) |
1090 | { | 1088 | { |
1091 | switch(SiS_Pr->ChipType) { | 1089 | switch(SiS_Pr->ChipType) { |
1092 | #ifdef SIS300 | 1090 | #ifdef CONFIG_FB_SIS_300 |
1093 | case SIS_300: | 1091 | case SIS_300: |
1094 | case SIS_540: | 1092 | case SIS_540: |
1095 | case SIS_630: | 1093 | case SIS_630: |
@@ -1108,7 +1106,7 @@ SiSInitPCIetc(struct SiS_Private *SiS_Pr) | |||
1108 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A); | 1106 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A); |
1109 | break; | 1107 | break; |
1110 | #endif | 1108 | #endif |
1111 | #ifdef SIS315H | 1109 | #ifdef CONFIG_FB_SIS_315 |
1112 | case SIS_315H: | 1110 | case SIS_315H: |
1113 | case SIS_315: | 1111 | case SIS_315: |
1114 | case SIS_315PRO: | 1112 | case SIS_315PRO: |
@@ -1152,9 +1150,7 @@ SiSInitPCIetc(struct SiS_Private *SiS_Pr) | |||
1152 | /* HELPER: SetLVDSetc */ | 1150 | /* HELPER: SetLVDSetc */ |
1153 | /*********************************************/ | 1151 | /*********************************************/ |
1154 | 1152 | ||
1155 | #ifdef SIS_LINUX_KERNEL | ||
1156 | static | 1153 | static |
1157 | #endif | ||
1158 | void | 1154 | void |
1159 | SiSSetLVDSetc(struct SiS_Private *SiS_Pr) | 1155 | SiSSetLVDSetc(struct SiS_Private *SiS_Pr) |
1160 | { | 1156 | { |
@@ -1174,7 +1170,7 @@ SiSSetLVDSetc(struct SiS_Private *SiS_Pr) | |||
1174 | if((temp == 1) || (temp == 2)) return; | 1170 | if((temp == 1) || (temp == 2)) return; |
1175 | 1171 | ||
1176 | switch(SiS_Pr->ChipType) { | 1172 | switch(SiS_Pr->ChipType) { |
1177 | #ifdef SIS300 | 1173 | #ifdef CONFIG_FB_SIS_300 |
1178 | case SIS_540: | 1174 | case SIS_540: |
1179 | case SIS_630: | 1175 | case SIS_630: |
1180 | case SIS_730: | 1176 | case SIS_730: |
@@ -1188,7 +1184,7 @@ SiSSetLVDSetc(struct SiS_Private *SiS_Pr) | |||
1188 | } | 1184 | } |
1189 | break; | 1185 | break; |
1190 | #endif | 1186 | #endif |
1191 | #ifdef SIS315H | 1187 | #ifdef CONFIG_FB_SIS_315 |
1192 | case SIS_550: | 1188 | case SIS_550: |
1193 | case SIS_650: | 1189 | case SIS_650: |
1194 | case SIS_740: | 1190 | case SIS_740: |
@@ -1420,9 +1416,7 @@ SiS_ResetSegmentRegisters(struct SiS_Private *SiS_Pr) | |||
1420 | /* HELPER: GetVBType */ | 1416 | /* HELPER: GetVBType */ |
1421 | /*********************************************/ | 1417 | /*********************************************/ |
1422 | 1418 | ||
1423 | #ifdef SIS_LINUX_KERNEL | ||
1424 | static | 1419 | static |
1425 | #endif | ||
1426 | void | 1420 | void |
1427 | SiS_GetVBType(struct SiS_Private *SiS_Pr) | 1421 | SiS_GetVBType(struct SiS_Private *SiS_Pr) |
1428 | { | 1422 | { |
@@ -1487,7 +1481,6 @@ SiS_GetVBType(struct SiS_Private *SiS_Pr) | |||
1487 | /* HELPER: Check RAM size */ | 1481 | /* HELPER: Check RAM size */ |
1488 | /*********************************************/ | 1482 | /*********************************************/ |
1489 | 1483 | ||
1490 | #ifdef SIS_LINUX_KERNEL | ||
1491 | static bool | 1484 | static bool |
1492 | SiS_CheckMemorySize(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | 1485 | SiS_CheckMemorySize(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
1493 | unsigned short ModeIdIndex) | 1486 | unsigned short ModeIdIndex) |
@@ -1501,13 +1494,12 @@ SiS_CheckMemorySize(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
1501 | if(AdapterMemSize < memorysize) return false; | 1494 | if(AdapterMemSize < memorysize) return false; |
1502 | return true; | 1495 | return true; |
1503 | } | 1496 | } |
1504 | #endif | ||
1505 | 1497 | ||
1506 | /*********************************************/ | 1498 | /*********************************************/ |
1507 | /* HELPER: Get DRAM type */ | 1499 | /* HELPER: Get DRAM type */ |
1508 | /*********************************************/ | 1500 | /*********************************************/ |
1509 | 1501 | ||
1510 | #ifdef SIS315H | 1502 | #ifdef CONFIG_FB_SIS_315 |
1511 | static unsigned char | 1503 | static unsigned char |
1512 | SiS_Get310DRAMType(struct SiS_Private *SiS_Pr) | 1504 | SiS_Get310DRAMType(struct SiS_Private *SiS_Pr) |
1513 | { | 1505 | { |
@@ -1574,7 +1566,6 @@ SiS_GetMCLK(struct SiS_Private *SiS_Pr) | |||
1574 | /* HELPER: ClearBuffer */ | 1566 | /* HELPER: ClearBuffer */ |
1575 | /*********************************************/ | 1567 | /*********************************************/ |
1576 | 1568 | ||
1577 | #ifdef SIS_LINUX_KERNEL | ||
1578 | static void | 1569 | static void |
1579 | SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | 1570 | SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo) |
1580 | { | 1571 | { |
@@ -1587,7 +1578,7 @@ SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | |||
1587 | 1578 | ||
1588 | if(SiS_Pr->SiS_ModeType >= ModeEGA) { | 1579 | if(SiS_Pr->SiS_ModeType >= ModeEGA) { |
1589 | if(ModeNo > 0x13) { | 1580 | if(ModeNo > 0x13) { |
1590 | SiS_SetMemory(memaddr, memsize, 0); | 1581 | memset_io(memaddr, 0, memsize); |
1591 | } else { | 1582 | } else { |
1592 | pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; | 1583 | pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; |
1593 | for(i = 0; i < 0x4000; i++) writew(0x0000, &pBuffer[i]); | 1584 | for(i = 0; i < 0x4000; i++) writew(0x0000, &pBuffer[i]); |
@@ -1596,10 +1587,9 @@ SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | |||
1596 | pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; | 1587 | pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; |
1597 | for(i = 0; i < 0x4000; i++) writew(0x0720, &pBuffer[i]); | 1588 | for(i = 0; i < 0x4000; i++) writew(0x0720, &pBuffer[i]); |
1598 | } else { | 1589 | } else { |
1599 | SiS_SetMemory(memaddr, 0x8000, 0); | 1590 | memset_io(memaddr, 0, 0x8000); |
1600 | } | 1591 | } |
1601 | } | 1592 | } |
1602 | #endif | ||
1603 | 1593 | ||
1604 | /*********************************************/ | 1594 | /*********************************************/ |
1605 | /* HELPER: SearchModeID */ | 1595 | /* HELPER: SearchModeID */ |
@@ -2132,7 +2122,7 @@ SiS_SetCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2132 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); | 2122 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); |
2133 | } | 2123 | } |
2134 | 2124 | ||
2135 | #ifdef SIS315H | 2125 | #ifdef CONFIG_FB_SIS_315 |
2136 | if(SiS_Pr->ChipType == XGI_20) { | 2126 | if(SiS_Pr->ChipType == XGI_20) { |
2137 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x04,crt1data[4] - 1); | 2127 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x04,crt1data[4] - 1); |
2138 | if(!(temp = crt1data[5] & 0x1f)) { | 2128 | if(!(temp = crt1data[5] & 0x1f)) { |
@@ -2215,7 +2205,7 @@ SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2215 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,clkb); | 2205 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,clkb); |
2216 | 2206 | ||
2217 | if(SiS_Pr->ChipType >= SIS_315H) { | 2207 | if(SiS_Pr->ChipType >= SIS_315H) { |
2218 | #ifdef SIS315H | 2208 | #ifdef CONFIG_FB_SIS_315 |
2219 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); | 2209 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); |
2220 | if(SiS_Pr->ChipType == XGI_20) { | 2210 | if(SiS_Pr->ChipType == XGI_20) { |
2221 | unsigned short mf = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); | 2211 | unsigned short mf = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); |
@@ -2236,7 +2226,7 @@ SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2236 | /* FIFO */ | 2226 | /* FIFO */ |
2237 | /*********************************************/ | 2227 | /*********************************************/ |
2238 | 2228 | ||
2239 | #ifdef SIS300 | 2229 | #ifdef CONFIG_FB_SIS_300 |
2240 | void | 2230 | void |
2241 | SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1, | 2231 | SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1, |
2242 | unsigned short *idx2) | 2232 | unsigned short *idx2) |
@@ -2506,11 +2496,7 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2506 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data); | 2496 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data); |
2507 | 2497 | ||
2508 | /* Write foreground and background queue */ | 2498 | /* Write foreground and background queue */ |
2509 | #ifdef SIS_LINUX_KERNEL | ||
2510 | templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); | 2499 | templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); |
2511 | #else | ||
2512 | templ = pciReadLong(0x00000000, 0x50); | ||
2513 | #endif | ||
2514 | 2500 | ||
2515 | if(SiS_Pr->ChipType == SIS_730) { | 2501 | if(SiS_Pr->ChipType == SIS_730) { |
2516 | 2502 | ||
@@ -2530,13 +2516,8 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2530 | 2516 | ||
2531 | } | 2517 | } |
2532 | 2518 | ||
2533 | #ifdef SIS_LINUX_KERNEL | ||
2534 | sisfb_write_nbridge_pci_dword(SiS_Pr, 0x50, templ); | 2519 | sisfb_write_nbridge_pci_dword(SiS_Pr, 0x50, templ); |
2535 | templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xA0); | 2520 | templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xA0); |
2536 | #else | ||
2537 | pciWriteLong(0x00000000, 0x50, templ); | ||
2538 | templ = pciReadLong(0x00000000, 0xA0); | ||
2539 | #endif | ||
2540 | 2521 | ||
2541 | /* GUI grant timer (PCI config 0xA3) */ | 2522 | /* GUI grant timer (PCI config 0xA3) */ |
2542 | if(SiS_Pr->ChipType == SIS_730) { | 2523 | if(SiS_Pr->ChipType == SIS_730) { |
@@ -2552,15 +2533,11 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2552 | 2533 | ||
2553 | } | 2534 | } |
2554 | 2535 | ||
2555 | #ifdef SIS_LINUX_KERNEL | ||
2556 | sisfb_write_nbridge_pci_dword(SiS_Pr, 0xA0, templ); | 2536 | sisfb_write_nbridge_pci_dword(SiS_Pr, 0xA0, templ); |
2557 | #else | ||
2558 | pciWriteLong(0x00000000, 0xA0, templ); | ||
2559 | #endif | ||
2560 | } | 2537 | } |
2561 | #endif /* SIS300 */ | 2538 | #endif /* CONFIG_FB_SIS_300 */ |
2562 | 2539 | ||
2563 | #ifdef SIS315H | 2540 | #ifdef CONFIG_FB_SIS_315 |
2564 | static void | 2541 | static void |
2565 | SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) | 2542 | SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) |
2566 | { | 2543 | { |
@@ -2612,7 +2589,7 @@ SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2612 | } | 2589 | } |
2613 | 2590 | ||
2614 | if(SiS_Pr->ChipType < SIS_315H) { | 2591 | if(SiS_Pr->ChipType < SIS_315H) { |
2615 | #ifdef SIS300 | 2592 | #ifdef CONFIG_FB_SIS_300 |
2616 | if(VCLK > 150) data |= 0x80; | 2593 | if(VCLK > 150) data |= 0x80; |
2617 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data); | 2594 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data); |
2618 | 2595 | ||
@@ -2621,7 +2598,7 @@ SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2621 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data); | 2598 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data); |
2622 | #endif | 2599 | #endif |
2623 | } else if(SiS_Pr->ChipType < XGI_20) { | 2600 | } else if(SiS_Pr->ChipType < XGI_20) { |
2624 | #ifdef SIS315H | 2601 | #ifdef CONFIG_FB_SIS_315 |
2625 | if(VCLK >= 166) data |= 0x0c; | 2602 | if(VCLK >= 166) data |= 0x0c; |
2626 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); | 2603 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); |
2627 | 2604 | ||
@@ -2630,7 +2607,7 @@ SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2630 | } | 2607 | } |
2631 | #endif | 2608 | #endif |
2632 | } else { | 2609 | } else { |
2633 | #ifdef SIS315H | 2610 | #ifdef CONFIG_FB_SIS_315 |
2634 | if(VCLK >= 200) data |= 0x0c; | 2611 | if(VCLK >= 200) data |= 0x0c; |
2635 | if(SiS_Pr->ChipType == XGI_20) data &= ~0x04; | 2612 | if(SiS_Pr->ChipType == XGI_20) data &= ~0x04; |
2636 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); | 2613 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); |
@@ -2675,7 +2652,7 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2675 | unsigned short ModeIdIndex, unsigned short RRTI) | 2652 | unsigned short ModeIdIndex, unsigned short RRTI) |
2676 | { | 2653 | { |
2677 | unsigned short data, infoflag = 0, modeflag, resindex; | 2654 | unsigned short data, infoflag = 0, modeflag, resindex; |
2678 | #ifdef SIS315H | 2655 | #ifdef CONFIG_FB_SIS_315 |
2679 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; | 2656 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; |
2680 | unsigned short data2, data3; | 2657 | unsigned short data2, data3; |
2681 | #endif | 2658 | #endif |
@@ -2736,7 +2713,7 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2736 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,data); | 2713 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,data); |
2737 | } | 2714 | } |
2738 | 2715 | ||
2739 | #ifdef SIS315H | 2716 | #ifdef CONFIG_FB_SIS_315 |
2740 | if(SiS_Pr->ChipType >= SIS_315H) { | 2717 | if(SiS_Pr->ChipType >= SIS_315H) { |
2741 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xfb); | 2718 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xfb); |
2742 | } | 2719 | } |
@@ -2826,7 +2803,7 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2826 | 2803 | ||
2827 | SiS_SetVCLKState(SiS_Pr, ModeNo, RRTI, ModeIdIndex); | 2804 | SiS_SetVCLKState(SiS_Pr, ModeNo, RRTI, ModeIdIndex); |
2828 | 2805 | ||
2829 | #ifdef SIS315H | 2806 | #ifdef CONFIG_FB_SIS_315 |
2830 | if(((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) || | 2807 | if(((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) || |
2831 | (SiS_Pr->ChipType == XGI_40)) { | 2808 | (SiS_Pr->ChipType == XGI_40)) { |
2832 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { | 2809 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { |
@@ -2845,7 +2822,7 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
2845 | #endif | 2822 | #endif |
2846 | } | 2823 | } |
2847 | 2824 | ||
2848 | #ifdef SIS315H | 2825 | #ifdef CONFIG_FB_SIS_315 |
2849 | static void | 2826 | static void |
2850 | SiS_SetupDualChip(struct SiS_Private *SiS_Pr) | 2827 | SiS_SetupDualChip(struct SiS_Private *SiS_Pr) |
2851 | { | 2828 | { |
@@ -2999,11 +2976,6 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho | |||
2999 | SiS_Pr->SiS_SelectCRT2Rate = 0; | 2976 | SiS_Pr->SiS_SelectCRT2Rate = 0; |
3000 | SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); | 2977 | SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); |
3001 | 2978 | ||
3002 | #ifdef SIS_XORG_XF86 | ||
3003 | xf86DrvMsgVerb(0, X_PROBED, 4, "(init: VBType=0x%04x, VBInfo=0x%04x)\n", | ||
3004 | SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo); | ||
3005 | #endif | ||
3006 | |||
3007 | if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { | 2979 | if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { |
3008 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { | 2980 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { |
3009 | SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; | 2981 | SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; |
@@ -3028,7 +3000,7 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho | |||
3028 | } | 3000 | } |
3029 | 3001 | ||
3030 | switch(SiS_Pr->ChipType) { | 3002 | switch(SiS_Pr->ChipType) { |
3031 | #ifdef SIS300 | 3003 | #ifdef CONFIG_FB_SIS_300 |
3032 | case SIS_300: | 3004 | case SIS_300: |
3033 | SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo, RefreshRateTableIndex); | 3005 | SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo, RefreshRateTableIndex); |
3034 | break; | 3006 | break; |
@@ -3039,7 +3011,7 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho | |||
3039 | break; | 3011 | break; |
3040 | #endif | 3012 | #endif |
3041 | default: | 3013 | default: |
3042 | #ifdef SIS315H | 3014 | #ifdef CONFIG_FB_SIS_315 |
3043 | if(SiS_Pr->ChipType == XGI_20) { | 3015 | if(SiS_Pr->ChipType == XGI_20) { |
3044 | unsigned char sr2b = 0, sr2c = 0; | 3016 | unsigned char sr2b = 0, sr2c = 0; |
3045 | switch(ModeNo) { | 3017 | switch(ModeNo) { |
@@ -3062,7 +3034,7 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho | |||
3062 | 3034 | ||
3063 | SiS_SetCRT1ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); | 3035 | SiS_SetCRT1ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); |
3064 | 3036 | ||
3065 | #ifdef SIS315H | 3037 | #ifdef CONFIG_FB_SIS_315 |
3066 | if(SiS_Pr->ChipType == XGI_40) { | 3038 | if(SiS_Pr->ChipType == XGI_40) { |
3067 | SiS_SetupDualChip(SiS_Pr); | 3039 | SiS_SetupDualChip(SiS_Pr); |
3068 | } | 3040 | } |
@@ -3070,11 +3042,9 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho | |||
3070 | 3042 | ||
3071 | SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex); | 3043 | SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex); |
3072 | 3044 | ||
3073 | #ifdef SIS_LINUX_KERNEL | ||
3074 | if(SiS_Pr->SiS_flag_clearbuffer) { | 3045 | if(SiS_Pr->SiS_flag_clearbuffer) { |
3075 | SiS_ClearBuffer(SiS_Pr, ModeNo); | 3046 | SiS_ClearBuffer(SiS_Pr, ModeNo); |
3076 | } | 3047 | } |
3077 | #endif | ||
3078 | 3048 | ||
3079 | if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { | 3049 | if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { |
3080 | SiS_WaitRetrace1(SiS_Pr); | 3050 | SiS_WaitRetrace1(SiS_Pr); |
@@ -3104,7 +3074,7 @@ SiS_InitVB(struct SiS_Private *SiS_Pr) | |||
3104 | static void | 3074 | static void |
3105 | SiS_ResetVB(struct SiS_Private *SiS_Pr) | 3075 | SiS_ResetVB(struct SiS_Private *SiS_Pr) |
3106 | { | 3076 | { |
3107 | #ifdef SIS315H | 3077 | #ifdef CONFIG_FB_SIS_315 |
3108 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; | 3078 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; |
3109 | unsigned short temp; | 3079 | unsigned short temp; |
3110 | 3080 | ||
@@ -3139,7 +3109,7 @@ SiS_StrangeStuff(struct SiS_Private *SiS_Pr) | |||
3139 | * which locks CRT2 in some way to CRT1 timing. Disable | 3109 | * which locks CRT2 in some way to CRT1 timing. Disable |
3140 | * this here. | 3110 | * this here. |
3141 | */ | 3111 | */ |
3142 | #ifdef SIS315H | 3112 | #ifdef CONFIG_FB_SIS_315 |
3143 | if((IS_SIS651) || (IS_SISM650) || | 3113 | if((IS_SIS651) || (IS_SISM650) || |
3144 | SiS_Pr->ChipType == SIS_340 || | 3114 | SiS_Pr->ChipType == SIS_340 || |
3145 | SiS_Pr->ChipType == XGI_40) { | 3115 | SiS_Pr->ChipType == XGI_40) { |
@@ -3160,7 +3130,7 @@ SiS_StrangeStuff(struct SiS_Private *SiS_Pr) | |||
3160 | static void | 3130 | static void |
3161 | SiS_Handle760(struct SiS_Private *SiS_Pr) | 3131 | SiS_Handle760(struct SiS_Private *SiS_Pr) |
3162 | { | 3132 | { |
3163 | #ifdef SIS315H | 3133 | #ifdef CONFIG_FB_SIS_315 |
3164 | unsigned int somebase; | 3134 | unsigned int somebase; |
3165 | unsigned char temp1, temp2, temp3; | 3135 | unsigned char temp1, temp2, temp3; |
3166 | 3136 | ||
@@ -3170,11 +3140,7 @@ SiS_Handle760(struct SiS_Private *SiS_Pr) | |||
3170 | (!(SiS_Pr->SiS_SysFlags & SF_760UMA)) ) | 3140 | (!(SiS_Pr->SiS_SysFlags & SF_760UMA)) ) |
3171 | return; | 3141 | return; |
3172 | 3142 | ||
3173 | #ifdef SIS_LINUX_KERNEL | ||
3174 | somebase = sisfb_read_mio_pci_word(SiS_Pr, 0x74); | 3143 | somebase = sisfb_read_mio_pci_word(SiS_Pr, 0x74); |
3175 | #else | ||
3176 | somebase = pciReadWord(0x00001000, 0x74); | ||
3177 | #endif | ||
3178 | somebase &= 0xffff; | 3144 | somebase &= 0xffff; |
3179 | 3145 | ||
3180 | if(somebase == 0) return; | 3146 | if(somebase == 0) return; |
@@ -3190,105 +3156,34 @@ SiS_Handle760(struct SiS_Private *SiS_Pr) | |||
3190 | temp2 = 0x0b; | 3156 | temp2 = 0x0b; |
3191 | } | 3157 | } |
3192 | 3158 | ||
3193 | #ifdef SIS_LINUX_KERNEL | ||
3194 | sisfb_write_nbridge_pci_byte(SiS_Pr, 0x7e, temp1); | 3159 | sisfb_write_nbridge_pci_byte(SiS_Pr, 0x7e, temp1); |
3195 | sisfb_write_nbridge_pci_byte(SiS_Pr, 0x8d, temp2); | 3160 | sisfb_write_nbridge_pci_byte(SiS_Pr, 0x8d, temp2); |
3196 | #else | ||
3197 | pciWriteByte(0x00000000, 0x7e, temp1); | ||
3198 | pciWriteByte(0x00000000, 0x8d, temp2); | ||
3199 | #endif | ||
3200 | 3161 | ||
3201 | SiS_SetRegByte((somebase + 0x85), temp3); | 3162 | SiS_SetRegByte((somebase + 0x85), temp3); |
3202 | #endif | 3163 | #endif |
3203 | } | 3164 | } |
3204 | 3165 | ||
3205 | /*********************************************/ | 3166 | /*********************************************/ |
3206 | /* X.org/XFree86: SET SCREEN PITCH */ | ||
3207 | /*********************************************/ | ||
3208 | |||
3209 | #ifdef SIS_XORG_XF86 | ||
3210 | static void | ||
3211 | SiS_SetPitchCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) | ||
3212 | { | ||
3213 | SISPtr pSiS = SISPTR(pScrn); | ||
3214 | unsigned short HDisplay = pSiS->scrnPitch >> 3; | ||
3215 | |||
3216 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,(HDisplay & 0xFF)); | ||
3217 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,(HDisplay >> 8)); | ||
3218 | } | ||
3219 | |||
3220 | static void | ||
3221 | SiS_SetPitchCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) | ||
3222 | { | ||
3223 | SISPtr pSiS = SISPTR(pScrn); | ||
3224 | unsigned short HDisplay = pSiS->scrnPitch2 >> 3; | ||
3225 | |||
3226 | /* Unlock CRT2 */ | ||
3227 | if(pSiS->VGAEngine == SIS_315_VGA) | ||
3228 | SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2F, 0x01); | ||
3229 | else | ||
3230 | SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24, 0x01); | ||
3231 | |||
3232 | SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(HDisplay & 0xFF)); | ||
3233 | SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0xF0,(HDisplay >> 8)); | ||
3234 | } | ||
3235 | |||
3236 | static void | ||
3237 | SiS_SetPitch(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn) | ||
3238 | { | ||
3239 | SISPtr pSiS = SISPTR(pScrn); | ||
3240 | bool isslavemode = false; | ||
3241 | |||
3242 | if( (pSiS->VBFlags2 & VB2_VIDEOBRIDGE) && | ||
3243 | ( ((pSiS->VGAEngine == SIS_300_VGA) && | ||
3244 | (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) || | ||
3245 | ((pSiS->VGAEngine == SIS_315_VGA) && | ||
3246 | (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) { | ||
3247 | isslavemode = true; | ||
3248 | } | ||
3249 | |||
3250 | /* We need to set pitch for CRT1 if bridge is in slave mode, too */ | ||
3251 | if((pSiS->VBFlags & DISPTYPE_DISP1) || (isslavemode)) { | ||
3252 | SiS_SetPitchCRT1(SiS_Pr, pScrn); | ||
3253 | } | ||
3254 | /* We must not set the pitch for CRT2 if bridge is in slave mode */ | ||
3255 | if((pSiS->VBFlags & DISPTYPE_DISP2) && (!isslavemode)) { | ||
3256 | SiS_SetPitchCRT2(SiS_Pr, pScrn); | ||
3257 | } | ||
3258 | } | ||
3259 | #endif | ||
3260 | |||
3261 | /*********************************************/ | ||
3262 | /* SiSSetMode() */ | 3167 | /* SiSSetMode() */ |
3263 | /*********************************************/ | 3168 | /*********************************************/ |
3264 | 3169 | ||
3265 | #ifdef SIS_XORG_XF86 | ||
3266 | /* We need pScrn for setting the pitch correctly */ | ||
3267 | bool | ||
3268 | SiSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, unsigned short ModeNo, bool dosetpitch) | ||
3269 | #else | ||
3270 | bool | 3170 | bool |
3271 | SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | 3171 | SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) |
3272 | #endif | ||
3273 | { | 3172 | { |
3274 | SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; | 3173 | SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; |
3275 | unsigned short RealModeNo, ModeIdIndex; | 3174 | unsigned short RealModeNo, ModeIdIndex; |
3276 | unsigned char backupreg = 0; | 3175 | unsigned char backupreg = 0; |
3277 | #ifdef SIS_LINUX_KERNEL | ||
3278 | unsigned short KeepLockReg; | 3176 | unsigned short KeepLockReg; |
3279 | 3177 | ||
3280 | SiS_Pr->UseCustomMode = false; | 3178 | SiS_Pr->UseCustomMode = false; |
3281 | SiS_Pr->CRT1UsesCustomMode = false; | 3179 | SiS_Pr->CRT1UsesCustomMode = false; |
3282 | #endif | ||
3283 | 3180 | ||
3284 | SiS_Pr->SiS_flag_clearbuffer = 0; | 3181 | SiS_Pr->SiS_flag_clearbuffer = 0; |
3285 | 3182 | ||
3286 | if(SiS_Pr->UseCustomMode) { | 3183 | if(SiS_Pr->UseCustomMode) { |
3287 | ModeNo = 0xfe; | 3184 | ModeNo = 0xfe; |
3288 | } else { | 3185 | } else { |
3289 | #ifdef SIS_LINUX_KERNEL | ||
3290 | if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1; | 3186 | if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1; |
3291 | #endif | ||
3292 | ModeNo &= 0x7f; | 3187 | ModeNo &= 0x7f; |
3293 | } | 3188 | } |
3294 | 3189 | ||
@@ -3301,13 +3196,8 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | |||
3301 | SiS_GetSysFlags(SiS_Pr); | 3196 | SiS_GetSysFlags(SiS_Pr); |
3302 | 3197 | ||
3303 | SiS_Pr->SiS_VGAINFO = 0x11; | 3198 | SiS_Pr->SiS_VGAINFO = 0x11; |
3304 | #if defined(SIS_XORG_XF86) && (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__)) | ||
3305 | if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); | ||
3306 | #endif | ||
3307 | 3199 | ||
3308 | #ifdef SIS_LINUX_KERNEL | ||
3309 | KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); | 3200 | KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); |
3310 | #endif | ||
3311 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); | 3201 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); |
3312 | 3202 | ||
3313 | SiSInitPCIetc(SiS_Pr); | 3203 | SiSInitPCIetc(SiS_Pr); |
@@ -3344,12 +3234,10 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | |||
3344 | SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); | 3234 | SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); |
3345 | SiS_SetLowModeTest(SiS_Pr, ModeNo); | 3235 | SiS_SetLowModeTest(SiS_Pr, ModeNo); |
3346 | 3236 | ||
3347 | #ifdef SIS_LINUX_KERNEL | ||
3348 | /* Check memory size (kernel framebuffer driver only) */ | 3237 | /* Check memory size (kernel framebuffer driver only) */ |
3349 | if(!SiS_CheckMemorySize(SiS_Pr, ModeNo, ModeIdIndex)) { | 3238 | if(!SiS_CheckMemorySize(SiS_Pr, ModeNo, ModeIdIndex)) { |
3350 | return false; | 3239 | return false; |
3351 | } | 3240 | } |
3352 | #endif | ||
3353 | 3241 | ||
3354 | SiS_OpenCRTC(SiS_Pr); | 3242 | SiS_OpenCRTC(SiS_Pr); |
3355 | 3243 | ||
@@ -3384,7 +3272,7 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | |||
3384 | SiS_DisplayOn(SiS_Pr); | 3272 | SiS_DisplayOn(SiS_Pr); |
3385 | SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); | 3273 | SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); |
3386 | 3274 | ||
3387 | #ifdef SIS315H | 3275 | #ifdef CONFIG_FB_SIS_315 |
3388 | if(SiS_Pr->ChipType >= SIS_315H) { | 3276 | if(SiS_Pr->ChipType >= SIS_315H) { |
3389 | if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { | 3277 | if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { |
3390 | if(!(SiS_IsDualEdge(SiS_Pr))) { | 3278 | if(!(SiS_IsDualEdge(SiS_Pr))) { |
@@ -3396,7 +3284,7 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | |||
3396 | 3284 | ||
3397 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { | 3285 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { |
3398 | if(SiS_Pr->ChipType >= SIS_315H) { | 3286 | if(SiS_Pr->ChipType >= SIS_315H) { |
3399 | #ifdef SIS315H | 3287 | #ifdef CONFIG_FB_SIS_315 |
3400 | if(!SiS_Pr->SiS_ROMNew) { | 3288 | if(!SiS_Pr->SiS_ROMNew) { |
3401 | if(SiS_IsVAMode(SiS_Pr)) { | 3289 | if(SiS_IsVAMode(SiS_Pr)) { |
3402 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); | 3290 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); |
@@ -3424,424 +3312,16 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) | |||
3424 | } | 3312 | } |
3425 | } | 3313 | } |
3426 | 3314 | ||
3427 | #ifdef SIS_XORG_XF86 | ||
3428 | if(pScrn) { | ||
3429 | /* SetPitch: Adapt to virtual size & position */ | ||
3430 | if((ModeNo > 0x13) && (dosetpitch)) { | ||
3431 | SiS_SetPitch(SiS_Pr, pScrn); | ||
3432 | } | ||
3433 | |||
3434 | /* Backup/Set ModeNo in BIOS scratch area */ | ||
3435 | SiS_GetSetModeID(pScrn, ModeNo); | ||
3436 | } | ||
3437 | #endif | ||
3438 | |||
3439 | SiS_CloseCRTC(SiS_Pr); | 3315 | SiS_CloseCRTC(SiS_Pr); |
3440 | 3316 | ||
3441 | SiS_Handle760(SiS_Pr); | 3317 | SiS_Handle760(SiS_Pr); |
3442 | 3318 | ||
3443 | #ifdef SIS_LINUX_KERNEL | ||
3444 | /* We never lock registers in XF86 */ | 3319 | /* We never lock registers in XF86 */ |
3445 | if(KeepLockReg != 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00); | 3320 | if(KeepLockReg != 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00); |
3446 | #endif | ||
3447 | 3321 | ||
3448 | return true; | 3322 | return true; |
3449 | } | 3323 | } |
3450 | 3324 | ||
3451 | /*********************************************/ | ||
3452 | /* X.org/XFree86: SiSBIOSSetMode() */ | ||
3453 | /* for non-Dual-Head mode */ | ||
3454 | /*********************************************/ | ||
3455 | |||
3456 | #ifdef SIS_XORG_XF86 | ||
3457 | bool | ||
3458 | SiSBIOSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, | ||
3459 | DisplayModePtr mode, bool IsCustom) | ||
3460 | { | ||
3461 | SISPtr pSiS = SISPTR(pScrn); | ||
3462 | unsigned short ModeNo = 0; | ||
3463 | |||
3464 | SiS_Pr->UseCustomMode = false; | ||
3465 | |||
3466 | if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { | ||
3467 | |||
3468 | xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n", | ||
3469 | SiS_Pr->CHDisplay, | ||
3470 | (mode->Flags & V_INTERLACE ? SiS_Pr->CVDisplay * 2 : | ||
3471 | (mode->Flags & V_DBLSCAN ? SiS_Pr->CVDisplay / 2 : | ||
3472 | SiS_Pr->CVDisplay))); | ||
3473 | |||
3474 | } else { | ||
3475 | |||
3476 | /* Don't need vbflags here; checks done earlier */ | ||
3477 | ModeNo = SiS_GetModeNumber(pScrn, mode, pSiS->VBFlags); | ||
3478 | if(!ModeNo) return false; | ||
3479 | |||
3480 | xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo); | ||
3481 | |||
3482 | } | ||
3483 | |||
3484 | return(SiSSetMode(SiS_Pr, pScrn, ModeNo, true)); | ||
3485 | } | ||
3486 | |||
3487 | /*********************************************/ | ||
3488 | /* X.org/XFree86: SiSBIOSSetModeCRT2() */ | ||
3489 | /* for Dual-Head modes */ | ||
3490 | /*********************************************/ | ||
3491 | |||
3492 | bool | ||
3493 | SiSBIOSSetModeCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, | ||
3494 | DisplayModePtr mode, bool IsCustom) | ||
3495 | { | ||
3496 | SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; | ||
3497 | SISPtr pSiS = SISPTR(pScrn); | ||
3498 | #ifdef SISDUALHEAD | ||
3499 | SISEntPtr pSiSEnt = pSiS->entityPrivate; | ||
3500 | #endif | ||
3501 | unsigned short ModeIdIndex; | ||
3502 | unsigned short ModeNo = 0; | ||
3503 | unsigned char backupreg = 0; | ||
3504 | |||
3505 | SiS_Pr->UseCustomMode = false; | ||
3506 | |||
3507 | /* Remember: Custom modes for CRT2 are ONLY supported | ||
3508 | * -) on the 30x/B/C, and | ||
3509 | * -) if CRT2 is LCD or VGA, or CRT1 is LCDA | ||
3510 | */ | ||
3511 | |||
3512 | if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { | ||
3513 | |||
3514 | ModeNo = 0xfe; | ||
3515 | |||
3516 | } else { | ||
3517 | |||
3518 | ModeNo = SiS_GetModeNumber(pScrn, mode, pSiS->VBFlags); | ||
3519 | if(!ModeNo) return false; | ||
3520 | |||
3521 | } | ||
3522 | |||
3523 | SiSRegInit(SiS_Pr, BaseAddr); | ||
3524 | SiSInitPtr(SiS_Pr); | ||
3525 | SiS_GetSysFlags(SiS_Pr); | ||
3526 | #if defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__) | ||
3527 | SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); | ||
3528 | #else | ||
3529 | SiS_Pr->SiS_VGAINFO = 0x11; | ||
3530 | #endif | ||
3531 | |||
3532 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); | ||
3533 | |||
3534 | SiSInitPCIetc(SiS_Pr); | ||
3535 | SiSSetLVDSetc(SiS_Pr); | ||
3536 | SiSDetermineROMUsage(SiS_Pr); | ||
3537 | |||
3538 | /* Save mode info so we can set it from within SetMode for CRT1 */ | ||
3539 | #ifdef SISDUALHEAD | ||
3540 | if(pSiS->DualHeadMode) { | ||
3541 | pSiSEnt->CRT2ModeNo = ModeNo; | ||
3542 | pSiSEnt->CRT2DMode = mode; | ||
3543 | pSiSEnt->CRT2IsCustom = IsCustom; | ||
3544 | pSiSEnt->CRT2CR30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); | ||
3545 | pSiSEnt->CRT2CR31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); | ||
3546 | pSiSEnt->CRT2CR35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); | ||
3547 | pSiSEnt->CRT2CR38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); | ||
3548 | #if 0 | ||
3549 | /* We can't set CRT2 mode before CRT1 mode is set - says who...? */ | ||
3550 | if(pSiSEnt->CRT1ModeNo == -1) { | ||
3551 | xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, | ||
3552 | "Setting CRT2 mode delayed until after setting CRT1 mode\n"); | ||
3553 | return true; | ||
3554 | } | ||
3555 | #endif | ||
3556 | pSiSEnt->CRT2ModeSet = true; | ||
3557 | } | ||
3558 | #endif | ||
3559 | |||
3560 | if(SiS_Pr->UseCustomMode) { | ||
3561 | |||
3562 | unsigned short temptemp = SiS_Pr->CVDisplay; | ||
3563 | |||
3564 | if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; | ||
3565 | else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; | ||
3566 | |||
3567 | xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, | ||
3568 | "Setting custom mode %dx%d on CRT2\n", | ||
3569 | SiS_Pr->CHDisplay, temptemp); | ||
3570 | |||
3571 | } else { | ||
3572 | |||
3573 | xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, | ||
3574 | "Setting standard mode 0x%x on CRT2\n", ModeNo); | ||
3575 | |||
3576 | } | ||
3577 | |||
3578 | SiS_UnLockCRT2(SiS_Pr); | ||
3579 | |||
3580 | if(!SiS_Pr->UseCustomMode) { | ||
3581 | if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return false; | ||
3582 | } else { | ||
3583 | ModeIdIndex = 0; | ||
3584 | } | ||
3585 | |||
3586 | SiS_GetVBType(SiS_Pr); | ||
3587 | |||
3588 | SiS_InitVB(SiS_Pr); | ||
3589 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { | ||
3590 | if(SiS_Pr->ChipType >= SIS_315H) { | ||
3591 | SiS_ResetVB(SiS_Pr); | ||
3592 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); | ||
3593 | SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c); | ||
3594 | backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); | ||
3595 | } else { | ||
3596 | backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); | ||
3597 | } | ||
3598 | } | ||
3599 | |||
3600 | /* Get VB information (connectors, connected devices) */ | ||
3601 | if(!SiS_Pr->UseCustomMode) { | ||
3602 | SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 1); | ||
3603 | } else { | ||
3604 | /* If this is a custom mode, we don't check the modeflag for CRT2Mode */ | ||
3605 | SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 0); | ||
3606 | } | ||
3607 | SiS_SetYPbPr(SiS_Pr); | ||
3608 | SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex); | ||
3609 | SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); | ||
3610 | SiS_SetLowModeTest(SiS_Pr, ModeNo); | ||
3611 | |||
3612 | SiS_ResetSegmentRegisters(SiS_Pr); | ||
3613 | |||
3614 | /* Set mode on CRT2 */ | ||
3615 | if( (SiS_Pr->SiS_VBType & VB_SISVB) || | ||
3616 | (SiS_Pr->SiS_IF_DEF_LVDS == 1) || | ||
3617 | (SiS_Pr->SiS_IF_DEF_CH70xx != 0) || | ||
3618 | (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) { | ||
3619 | SiS_SetCRT2Group(SiS_Pr, ModeNo); | ||
3620 | } | ||
3621 | |||
3622 | SiS_StrangeStuff(SiS_Pr); | ||
3623 | |||
3624 | SiS_DisplayOn(SiS_Pr); | ||
3625 | SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); | ||
3626 | |||
3627 | if(SiS_Pr->ChipType >= SIS_315H) { | ||
3628 | if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { | ||
3629 | if(!(SiS_IsDualEdge(SiS_Pr))) { | ||
3630 | SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); | ||
3631 | } | ||
3632 | } | ||
3633 | } | ||
3634 | |||
3635 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { | ||
3636 | if(SiS_Pr->ChipType >= SIS_315H) { | ||
3637 | if(!SiS_Pr->SiS_ROMNew) { | ||
3638 | if(SiS_IsVAMode(SiS_Pr)) { | ||
3639 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); | ||
3640 | } else { | ||
3641 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); | ||
3642 | } | ||
3643 | } | ||
3644 | |||
3645 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); | ||
3646 | |||
3647 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) { | ||
3648 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); | ||
3649 | } | ||
3650 | } else if((SiS_Pr->ChipType == SIS_630) || | ||
3651 | (SiS_Pr->ChipType == SIS_730)) { | ||
3652 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); | ||
3653 | } | ||
3654 | } | ||
3655 | |||
3656 | /* SetPitch: Adapt to virtual size & position */ | ||
3657 | SiS_SetPitchCRT2(SiS_Pr, pScrn); | ||
3658 | |||
3659 | SiS_Handle760(SiS_Pr); | ||
3660 | |||
3661 | return true; | ||
3662 | } | ||
3663 | |||
3664 | /*********************************************/ | ||
3665 | /* X.org/XFree86: SiSBIOSSetModeCRT1() */ | ||
3666 | /* for Dual-Head modes */ | ||
3667 | /*********************************************/ | ||
3668 | |||
3669 | bool | ||
3670 | SiSBIOSSetModeCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, | ||
3671 | DisplayModePtr mode, bool IsCustom) | ||
3672 | { | ||
3673 | SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; | ||
3674 | SISPtr pSiS = SISPTR(pScrn); | ||
3675 | unsigned short ModeIdIndex, ModeNo = 0; | ||
3676 | unsigned char backupreg = 0; | ||
3677 | #ifdef SISDUALHEAD | ||
3678 | SISEntPtr pSiSEnt = pSiS->entityPrivate; | ||
3679 | unsigned char backupcr30, backupcr31, backupcr38, backupcr35, backupp40d=0; | ||
3680 | bool backupcustom; | ||
3681 | #endif | ||
3682 | |||
3683 | SiS_Pr->UseCustomMode = false; | ||
3684 | |||
3685 | if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) { | ||
3686 | |||
3687 | unsigned short temptemp = SiS_Pr->CVDisplay; | ||
3688 | |||
3689 | if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1; | ||
3690 | else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1; | ||
3691 | |||
3692 | xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, | ||
3693 | "Setting custom mode %dx%d on CRT1\n", | ||
3694 | SiS_Pr->CHDisplay, temptemp); | ||
3695 | ModeNo = 0xfe; | ||
3696 | |||
3697 | } else { | ||
3698 | |||
3699 | ModeNo = SiS_GetModeNumber(pScrn, mode, 0); /* don't give VBFlags */ | ||
3700 | if(!ModeNo) return false; | ||
3701 | |||
3702 | xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, | ||
3703 | "Setting standard mode 0x%x on CRT1\n", ModeNo); | ||
3704 | } | ||
3705 | |||
3706 | SiSInitPtr(SiS_Pr); | ||
3707 | SiSRegInit(SiS_Pr, BaseAddr); | ||
3708 | SiS_GetSysFlags(SiS_Pr); | ||
3709 | #if defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__) | ||
3710 | SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff); | ||
3711 | #else | ||
3712 | SiS_Pr->SiS_VGAINFO = 0x11; | ||
3713 | #endif | ||
3714 | |||
3715 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); | ||
3716 | |||
3717 | SiSInitPCIetc(SiS_Pr); | ||
3718 | SiSSetLVDSetc(SiS_Pr); | ||
3719 | SiSDetermineROMUsage(SiS_Pr); | ||
3720 | |||
3721 | SiS_UnLockCRT2(SiS_Pr); | ||
3722 | |||
3723 | if(!SiS_Pr->UseCustomMode) { | ||
3724 | if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return false; | ||
3725 | } else { | ||
3726 | ModeIdIndex = 0; | ||
3727 | } | ||
3728 | |||
3729 | /* Determine VBType */ | ||
3730 | SiS_GetVBType(SiS_Pr); | ||
3731 | |||
3732 | SiS_InitVB(SiS_Pr); | ||
3733 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { | ||
3734 | if(SiS_Pr->ChipType >= SIS_315H) { | ||
3735 | backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); | ||
3736 | } else { | ||
3737 | backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); | ||
3738 | } | ||
3739 | } | ||
3740 | |||
3741 | /* Get VB information (connectors, connected devices) */ | ||
3742 | /* (We don't care if the current mode is a CRT2 mode) */ | ||
3743 | SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 0); | ||
3744 | SiS_SetYPbPr(SiS_Pr); | ||
3745 | SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex); | ||
3746 | SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); | ||
3747 | SiS_SetLowModeTest(SiS_Pr, ModeNo); | ||
3748 | |||
3749 | SiS_OpenCRTC(SiS_Pr); | ||
3750 | |||
3751 | /* Set mode on CRT1 */ | ||
3752 | SiS_SetCRT1Group(SiS_Pr, ModeNo, ModeIdIndex); | ||
3753 | if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { | ||
3754 | SiS_SetCRT2Group(SiS_Pr, ModeNo); | ||
3755 | } | ||
3756 | |||
3757 | /* SetPitch: Adapt to virtual size & position */ | ||
3758 | SiS_SetPitchCRT1(SiS_Pr, pScrn); | ||
3759 | |||
3760 | SiS_HandleCRT1(SiS_Pr); | ||
3761 | |||
3762 | SiS_StrangeStuff(SiS_Pr); | ||
3763 | |||
3764 | SiS_CloseCRTC(SiS_Pr); | ||
3765 | |||
3766 | #ifdef SISDUALHEAD | ||
3767 | if(pSiS->DualHeadMode) { | ||
3768 | pSiSEnt->CRT1ModeNo = ModeNo; | ||
3769 | pSiSEnt->CRT1DMode = mode; | ||
3770 | } | ||
3771 | #endif | ||
3772 | |||
3773 | if(SiS_Pr->UseCustomMode) { | ||
3774 | SiS_Pr->CRT1UsesCustomMode = true; | ||
3775 | SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock; | ||
3776 | SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag; | ||
3777 | } else { | ||
3778 | SiS_Pr->CRT1UsesCustomMode = false; | ||
3779 | } | ||
3780 | |||
3781 | /* Reset CRT2 if changing mode on CRT1 */ | ||
3782 | #ifdef SISDUALHEAD | ||
3783 | if(pSiS->DualHeadMode) { | ||
3784 | if(pSiSEnt->CRT2ModeNo != -1) { | ||
3785 | xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, | ||
3786 | "(Re-)Setting mode for CRT2\n"); | ||
3787 | backupcustom = SiS_Pr->UseCustomMode; | ||
3788 | backupcr30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); | ||
3789 | backupcr31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); | ||
3790 | backupcr35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); | ||
3791 | backupcr38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); | ||
3792 | if(SiS_Pr->SiS_VBType & VB_SISVB) { | ||
3793 | /* Backup LUT-enable */ | ||
3794 | if(pSiSEnt->CRT2ModeSet) { | ||
3795 | backupp40d = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x0d) & 0x08; | ||
3796 | } | ||
3797 | } | ||
3798 | if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { | ||
3799 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,pSiSEnt->CRT2CR30); | ||
3800 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,pSiSEnt->CRT2CR31); | ||
3801 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,pSiSEnt->CRT2CR35); | ||
3802 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,pSiSEnt->CRT2CR38); | ||
3803 | } | ||
3804 | |||
3805 | SiSBIOSSetModeCRT2(SiS_Pr, pSiSEnt->pScrn_1, | ||
3806 | pSiSEnt->CRT2DMode, pSiSEnt->CRT2IsCustom); | ||
3807 | |||
3808 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,backupcr30); | ||
3809 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,backupcr31); | ||
3810 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupcr35); | ||
3811 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupcr38); | ||
3812 | if(SiS_Pr->SiS_VBType & VB_SISVB) { | ||
3813 | SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d, ~0x08, backupp40d); | ||
3814 | } | ||
3815 | SiS_Pr->UseCustomMode = backupcustom; | ||
3816 | } | ||
3817 | } | ||
3818 | #endif | ||
3819 | |||
3820 | /* Warning: From here, the custom mode entries in SiS_Pr are | ||
3821 | * possibly overwritten | ||
3822 | */ | ||
3823 | |||
3824 | SiS_DisplayOn(SiS_Pr); | ||
3825 | SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); | ||
3826 | |||
3827 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { | ||
3828 | if(SiS_Pr->ChipType >= SIS_315H) { | ||
3829 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); | ||
3830 | } else if((SiS_Pr->ChipType == SIS_630) || | ||
3831 | (SiS_Pr->ChipType == SIS_730)) { | ||
3832 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); | ||
3833 | } | ||
3834 | } | ||
3835 | |||
3836 | SiS_Handle760(SiS_Pr); | ||
3837 | |||
3838 | /* Backup/Set ModeNo in BIOS scratch area */ | ||
3839 | SiS_GetSetModeID(pScrn,ModeNo); | ||
3840 | |||
3841 | return true; | ||
3842 | } | ||
3843 | #endif /* Linux_XF86 */ | ||
3844 | |||
3845 | #ifndef GETBITSTR | 3325 | #ifndef GETBITSTR |
3846 | #define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) | 3326 | #define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) |
3847 | #define GENMASK(mask) BITMASK(1?mask,0?mask) | 3327 | #define GENMASK(mask) BITMASK(1?mask,0?mask) |
@@ -3927,7 +3407,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
3927 | SiS_Pr->CVBlankStart = SiS_Pr->SiS_VGAVDE; | 3407 | SiS_Pr->CVBlankStart = SiS_Pr->SiS_VGAVDE; |
3928 | 3408 | ||
3929 | if(SiS_Pr->ChipType < SIS_315H) { | 3409 | if(SiS_Pr->ChipType < SIS_315H) { |
3930 | #ifdef SIS300 | 3410 | #ifdef CONFIG_FB_SIS_300 |
3931 | tempbx = SiS_Pr->SiS_VGAHT; | 3411 | tempbx = SiS_Pr->SiS_VGAHT; |
3932 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { | 3412 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
3933 | tempbx = SiS_Pr->PanelHT; | 3413 | tempbx = SiS_Pr->PanelHT; |
@@ -3936,7 +3416,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
3936 | remaining = tempbx % 8; | 3416 | remaining = tempbx % 8; |
3937 | #endif | 3417 | #endif |
3938 | } else { | 3418 | } else { |
3939 | #ifdef SIS315H | 3419 | #ifdef CONFIG_FB_SIS_315 |
3940 | /* OK for LCDA, LVDS */ | 3420 | /* OK for LCDA, LVDS */ |
3941 | tempbx = SiS_Pr->PanelHT - SiS_Pr->PanelXRes; | 3421 | tempbx = SiS_Pr->PanelHT - SiS_Pr->PanelXRes; |
3942 | tempax = SiS_Pr->SiS_VGAHDE; /* not /2 ! */ | 3422 | tempax = SiS_Pr->SiS_VGAHDE; /* not /2 ! */ |
@@ -3950,7 +3430,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
3950 | SiS_Pr->CHTotal = SiS_Pr->CHBlankEnd = tempbx; | 3430 | SiS_Pr->CHTotal = SiS_Pr->CHBlankEnd = tempbx; |
3951 | 3431 | ||
3952 | if(SiS_Pr->ChipType < SIS_315H) { | 3432 | if(SiS_Pr->ChipType < SIS_315H) { |
3953 | #ifdef SIS300 | 3433 | #ifdef CONFIG_FB_SIS_300 |
3954 | if(SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) { | 3434 | if(SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) { |
3955 | SiS_Pr->CHSyncStart = SiS_Pr->SiS_VGAHDE + ((SiS_Pr->PanelHRS + 1) & ~1); | 3435 | SiS_Pr->CHSyncStart = SiS_Pr->SiS_VGAHDE + ((SiS_Pr->PanelHRS + 1) & ~1); |
3956 | SiS_Pr->CHSyncEnd = SiS_Pr->CHSyncStart + SiS_Pr->PanelHRE; | 3436 | SiS_Pr->CHSyncEnd = SiS_Pr->CHSyncStart + SiS_Pr->PanelHRE; |
@@ -3982,7 +3462,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
3982 | } | 3462 | } |
3983 | #endif | 3463 | #endif |
3984 | } else { | 3464 | } else { |
3985 | #ifdef SIS315H | 3465 | #ifdef CONFIG_FB_SIS_315 |
3986 | tempax = VGAHDE; | 3466 | tempax = VGAHDE; |
3987 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { | 3467 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
3988 | tempbx = SiS_Pr->PanelXRes; | 3468 | tempbx = SiS_Pr->PanelXRes; |
@@ -4001,7 +3481,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
4001 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { | 3481 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
4002 | tempax = SiS_Pr->PanelYRes; | 3482 | tempax = SiS_Pr->PanelYRes; |
4003 | } else if(SiS_Pr->ChipType < SIS_315H) { | 3483 | } else if(SiS_Pr->ChipType < SIS_315H) { |
4004 | #ifdef SIS300 | 3484 | #ifdef CONFIG_FB_SIS_300 |
4005 | /* Stupid hack for 640x400/320x200 */ | 3485 | /* Stupid hack for 640x400/320x200 */ |
4006 | if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { | 3486 | if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { |
4007 | if((tempax + tempbx) == 438) tempbx += 16; | 3487 | if((tempax + tempbx) == 438) tempbx += 16; |
@@ -4054,36 +3534,12 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, | |||
4054 | if(modeflag & DoubleScanMode) tempax |= 0x80; | 3534 | if(modeflag & DoubleScanMode) tempax |= 0x80; |
4055 | SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,tempax); | 3535 | SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,tempax); |
4056 | 3536 | ||
4057 | #ifdef SIS_XORG_XF86 | ||
4058 | #ifdef TWDEBUG | ||
4059 | xf86DrvMsg(0, X_INFO, "%d %d %d %d %d %d %d %d (%d %d %d %d)\n", | ||
4060 | SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal, | ||
4061 | SiS_Pr->CVDisplay, SiS_Pr->CVSyncStart, SiS_Pr->CVSyncEnd, SiS_Pr->CVTotal, | ||
4062 | SiS_Pr->CHBlankStart, SiS_Pr->CHBlankEnd, SiS_Pr->CVBlankStart, SiS_Pr->CVBlankEnd); | ||
4063 | xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", | ||
4064 | SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1], | ||
4065 | SiS_Pr->CCRT1CRTC[2], SiS_Pr->CCRT1CRTC[3], | ||
4066 | SiS_Pr->CCRT1CRTC[4], SiS_Pr->CCRT1CRTC[5], | ||
4067 | SiS_Pr->CCRT1CRTC[6], SiS_Pr->CCRT1CRTC[7]); | ||
4068 | xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", | ||
4069 | SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9], | ||
4070 | SiS_Pr->CCRT1CRTC[10], SiS_Pr->CCRT1CRTC[11], | ||
4071 | SiS_Pr->CCRT1CRTC[12], SiS_Pr->CCRT1CRTC[13], | ||
4072 | SiS_Pr->CCRT1CRTC[14], SiS_Pr->CCRT1CRTC[15]); | ||
4073 | xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", SiS_Pr->CCRT1CRTC[16]); | ||
4074 | #endif | ||
4075 | #endif | ||
4076 | } | 3537 | } |
4077 | 3538 | ||
4078 | void | 3539 | void |
4079 | SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, | 3540 | SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, |
4080 | int xres, int yres, | 3541 | int xres, int yres, |
4081 | #ifdef SIS_XORG_XF86 | ||
4082 | DisplayModePtr current | ||
4083 | #endif | ||
4084 | #ifdef SIS_LINUX_KERNEL | ||
4085 | struct fb_var_screeninfo *var, bool writeres | 3542 | struct fb_var_screeninfo *var, bool writeres |
4086 | #endif | ||
4087 | ) | 3543 | ) |
4088 | { | 3544 | { |
4089 | unsigned short HRE, HBE, HRS, HBS, HDE, HT; | 3545 | unsigned short HRE, HBE, HRS, HBS, HDE, HT; |
@@ -4127,25 +3583,10 @@ SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, | |||
4127 | 3583 | ||
4128 | D = B - F - C; | 3584 | D = B - F - C; |
4129 | 3585 | ||
4130 | #ifdef SIS_XORG_XF86 | ||
4131 | current->HDisplay = (E * 8); | ||
4132 | current->HSyncStart = (E * 8) + (F * 8); | ||
4133 | current->HSyncEnd = (E * 8) + (F * 8) + (C * 8); | ||
4134 | current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8); | ||
4135 | #ifdef TWDEBUG | ||
4136 | xf86DrvMsg(0, X_INFO, | ||
4137 | "H: A %d B %d C %d D %d E %d F %d HT %d HDE %d HRS %d HBS %d HBE %d HRE %d\n", | ||
4138 | A, B, C, D, E, F, HT, HDE, HRS, HBS, HBE, HRE); | ||
4139 | #else | ||
4140 | (void)VBS; (void)HBS; (void)A; | ||
4141 | #endif | ||
4142 | #endif | ||
4143 | #ifdef SIS_LINUX_KERNEL | ||
4144 | if(writeres) var->xres = xres = E * 8; | 3586 | if(writeres) var->xres = xres = E * 8; |
4145 | var->left_margin = D * 8; | 3587 | var->left_margin = D * 8; |
4146 | var->right_margin = F * 8; | 3588 | var->right_margin = F * 8; |
4147 | var->hsync_len = C * 8; | 3589 | var->hsync_len = C * 8; |
4148 | #endif | ||
4149 | 3590 | ||
4150 | /* Vertical */ | 3591 | /* Vertical */ |
4151 | sr_data = crdata[13]; | 3592 | sr_data = crdata[13]; |
@@ -4192,30 +3633,10 @@ SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, | |||
4192 | 3633 | ||
4193 | D = B - F - C; | 3634 | D = B - F - C; |
4194 | 3635 | ||
4195 | #ifdef SIS_XORG_XF86 | ||
4196 | current->VDisplay = VDE + 1; | ||
4197 | current->VSyncStart = VRS + 1; | ||
4198 | current->VSyncEnd = ((VRS & ~0x1f) | VRE) + 1; | ||
4199 | if(VRE <= (VRS & 0x1f)) current->VSyncEnd += 32; | ||
4200 | current->VTotal = E + D + C + F; | ||
4201 | #if 0 | ||
4202 | current->VDisplay = E; | ||
4203 | current->VSyncStart = E + D; | ||
4204 | current->VSyncEnd = E + D + C; | ||
4205 | current->VTotal = E + D + C + F; | ||
4206 | #endif | ||
4207 | #ifdef TWDEBUG | ||
4208 | xf86DrvMsg(0, X_INFO, | ||
4209 | "V: A %d B %d C %d D %d E %d F %d VT %d VDE %d VRS %d VBS %d VBE %d VRE %d\n", | ||
4210 | A, B, C, D, E, F, VT, VDE, VRS, VBS, VBE, VRE); | ||
4211 | #endif | ||
4212 | #endif | ||
4213 | #ifdef SIS_LINUX_KERNEL | ||
4214 | if(writeres) var->yres = yres = E; | 3636 | if(writeres) var->yres = yres = E; |
4215 | var->upper_margin = D; | 3637 | var->upper_margin = D; |
4216 | var->lower_margin = F; | 3638 | var->lower_margin = F; |
4217 | var->vsync_len = C; | 3639 | var->vsync_len = C; |
4218 | #endif | ||
4219 | 3640 | ||
4220 | if((xres == 320) && ((yres == 200) || (yres == 240))) { | 3641 | if((xres == 320) && ((yres == 200) || (yres == 240))) { |
4221 | /* Terrible hack, but correct CRTC data for | 3642 | /* Terrible hack, but correct CRTC data for |
@@ -4224,17 +3645,9 @@ SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, | |||
4224 | * a negative D. The CRT controller does not | 3645 | * a negative D. The CRT controller does not |
4225 | * seem to like correcting HRE to 50) | 3646 | * seem to like correcting HRE to 50) |
4226 | */ | 3647 | */ |
4227 | #ifdef SIS_XORG_XF86 | ||
4228 | current->HDisplay = 320; | ||
4229 | current->HSyncStart = 328; | ||
4230 | current->HSyncEnd = 376; | ||
4231 | current->HTotal = 400; | ||
4232 | #endif | ||
4233 | #ifdef SIS_LINUX_KERNEL | ||
4234 | var->left_margin = (400 - 376); | 3648 | var->left_margin = (400 - 376); |
4235 | var->right_margin = (328 - 320); | 3649 | var->right_margin = (328 - 320); |
4236 | var->hsync_len = (376 - 328); | 3650 | var->hsync_len = (376 - 328); |
4237 | #endif | ||
4238 | 3651 | ||
4239 | } | 3652 | } |
4240 | 3653 | ||