Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $XFree86$ */ |
| 2 | /* $XdotOrg$ */ |
| 3 | /* |
| 4 | * Mode initializing code (CRT1 section) for |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 5 | * for SiS 300/305/540/630/730, |
| 6 | * SiS 315/550/[M]650/651/[M]661[FGM]X/[M]74x[GX]/330/[M]76x[GX], |
| 7 | * XGI Volari V3XT/V5/V8, Z7 |
| 8 | * (Universal module for Linux kernel framebuffer and X.org/XFree86 4.x) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 10 | * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * |
| 12 | * If distributed as part of the Linux kernel, the following license terms |
| 13 | * apply: |
| 14 | * |
| 15 | * * This program is free software; you can redistribute it and/or modify |
| 16 | * * it under the terms of the GNU General Public License as published by |
| 17 | * * the Free Software Foundation; either version 2 of the named License, |
| 18 | * * or any later version. |
| 19 | * * |
| 20 | * * This program is distributed in the hope that it will be useful, |
| 21 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * * GNU General Public License for more details. |
| 24 | * * |
| 25 | * * You should have received a copy of the GNU General Public License |
| 26 | * * along with this program; if not, write to the Free Software |
| 27 | * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
| 28 | * |
| 29 | * Otherwise, the following license terms apply: |
| 30 | * |
| 31 | * * Redistribution and use in source and binary forms, with or without |
| 32 | * * modification, are permitted provided that the following conditions |
| 33 | * * are met: |
| 34 | * * 1) Redistributions of source code must retain the above copyright |
| 35 | * * notice, this list of conditions and the following disclaimer. |
| 36 | * * 2) Redistributions in binary form must reproduce the above copyright |
| 37 | * * notice, this list of conditions and the following disclaimer in the |
| 38 | * * documentation and/or other materials provided with the distribution. |
| 39 | * * 3) The name of the author may not be used to endorse or promote products |
| 40 | * * derived from this software without specific prior written permission. |
| 41 | * * |
| 42 | * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 43 | * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 44 | * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 45 | * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 46 | * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 47 | * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 48 | * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 49 | * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 50 | * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 51 | * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 52 | * |
| 53 | * Author: Thomas Winischhofer <thomas@winischhofer.net> |
| 54 | * |
| 55 | * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. |
| 56 | * Used by permission. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 58 | |
| 59 | #ifdef HAVE_CONFIG_H |
| 60 | #include "config.h" |
| 61 | #endif |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #include "init.h" |
| 64 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 65 | #ifdef CONFIG_FB_SIS_300 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | #include "300vtbl.h" |
| 67 | #endif |
| 68 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 69 | #ifdef CONFIG_FB_SIS_315 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #include "310vtbl.h" |
| 71 | #endif |
| 72 | |
| 73 | #if defined(ALLOC_PRAGMA) |
| 74 | #pragma alloc_text(PAGE,SiSSetMode) |
| 75 | #endif |
| 76 | |
| 77 | /*********************************************/ |
| 78 | /* POINTER INITIALIZATION */ |
| 79 | /*********************************************/ |
| 80 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 81 | #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 83 | InitCommonPointer(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 85 | SiS_Pr->SiS_SModeIDTable = SiS_SModeIDTable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | SiS_Pr->SiS_StResInfo = SiS_StResInfo; |
| 87 | SiS_Pr->SiS_ModeResInfo = SiS_ModeResInfo; |
| 88 | SiS_Pr->SiS_StandTable = SiS_StandTable; |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | SiS_Pr->SiS_NTSCTiming = SiS_NTSCTiming; |
| 91 | SiS_Pr->SiS_PALTiming = SiS_PALTiming; |
| 92 | SiS_Pr->SiS_HiTVSt1Timing = SiS_HiTVSt1Timing; |
| 93 | SiS_Pr->SiS_HiTVSt2Timing = SiS_HiTVSt2Timing; |
| 94 | |
| 95 | SiS_Pr->SiS_HiTVExtTiming = SiS_HiTVExtTiming; |
| 96 | SiS_Pr->SiS_HiTVGroup3Data = SiS_HiTVGroup3Data; |
| 97 | SiS_Pr->SiS_HiTVGroup3Simu = SiS_HiTVGroup3Simu; |
| 98 | #if 0 |
| 99 | SiS_Pr->SiS_HiTVTextTiming = SiS_HiTVTextTiming; |
| 100 | SiS_Pr->SiS_HiTVGroup3Text = SiS_HiTVGroup3Text; |
| 101 | #endif |
| 102 | |
| 103 | SiS_Pr->SiS_StPALData = SiS_StPALData; |
| 104 | SiS_Pr->SiS_ExtPALData = SiS_ExtPALData; |
| 105 | SiS_Pr->SiS_StNTSCData = SiS_StNTSCData; |
| 106 | SiS_Pr->SiS_ExtNTSCData = SiS_ExtNTSCData; |
| 107 | SiS_Pr->SiS_St1HiTVData = SiS_StHiTVData; |
| 108 | SiS_Pr->SiS_St2HiTVData = SiS_St2HiTVData; |
| 109 | SiS_Pr->SiS_ExtHiTVData = SiS_ExtHiTVData; |
| 110 | SiS_Pr->SiS_St525iData = SiS_StNTSCData; |
| 111 | SiS_Pr->SiS_St525pData = SiS_St525pData; |
| 112 | SiS_Pr->SiS_St750pData = SiS_St750pData; |
| 113 | SiS_Pr->SiS_Ext525iData = SiS_ExtNTSCData; |
| 114 | SiS_Pr->SiS_Ext525pData = SiS_ExtNTSCData; |
| 115 | SiS_Pr->SiS_Ext750pData = SiS_Ext750pData; |
| 116 | |
| 117 | SiS_Pr->pSiS_OutputSelect = &SiS_OutputSelect; |
| 118 | SiS_Pr->pSiS_SoftSetting = &SiS_SoftSetting; |
| 119 | |
| 120 | SiS_Pr->SiS_LCD1280x720Data = SiS_LCD1280x720Data; |
| 121 | SiS_Pr->SiS_StLCD1280x768_2Data = SiS_StLCD1280x768_2Data; |
| 122 | SiS_Pr->SiS_ExtLCD1280x768_2Data = SiS_ExtLCD1280x768_2Data; |
| 123 | SiS_Pr->SiS_LCD1280x800Data = SiS_LCD1280x800Data; |
| 124 | SiS_Pr->SiS_LCD1280x800_2Data = SiS_LCD1280x800_2Data; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 125 | SiS_Pr->SiS_LCD1280x854Data = SiS_LCD1280x854Data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | SiS_Pr->SiS_LCD1280x960Data = SiS_LCD1280x960Data; |
| 127 | SiS_Pr->SiS_StLCD1400x1050Data = SiS_StLCD1400x1050Data; |
| 128 | SiS_Pr->SiS_ExtLCD1400x1050Data = SiS_ExtLCD1400x1050Data; |
| 129 | SiS_Pr->SiS_LCD1680x1050Data = SiS_LCD1680x1050Data; |
| 130 | SiS_Pr->SiS_StLCD1600x1200Data = SiS_StLCD1600x1200Data; |
| 131 | SiS_Pr->SiS_ExtLCD1600x1200Data = SiS_ExtLCD1600x1200Data; |
| 132 | SiS_Pr->SiS_NoScaleData = SiS_NoScaleData; |
| 133 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 134 | SiS_Pr->SiS_LVDS320x240Data_1 = SiS_LVDS320x240Data_1; |
| 135 | SiS_Pr->SiS_LVDS320x240Data_2 = SiS_LVDS320x240Data_2; |
| 136 | SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | SiS_Pr->SiS_LVDS800x600Data_1 = SiS_LVDS800x600Data_1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | SiS_Pr->SiS_LVDS1024x600Data_1 = SiS_LVDS1024x600Data_1; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 139 | SiS_Pr->SiS_LVDS1024x768Data_1 = SiS_LVDS1024x768Data_1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 141 | SiS_Pr->SiS_LVDSCRT1320x240_1 = SiS_LVDSCRT1320x240_1; |
| 142 | SiS_Pr->SiS_LVDSCRT1320x240_2 = SiS_LVDSCRT1320x240_2; |
| 143 | SiS_Pr->SiS_LVDSCRT1320x240_2_H = SiS_LVDSCRT1320x240_2_H; |
| 144 | SiS_Pr->SiS_LVDSCRT1320x240_3 = SiS_LVDSCRT1320x240_3; |
| 145 | SiS_Pr->SiS_LVDSCRT1320x240_3_H = SiS_LVDSCRT1320x240_3_H; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | SiS_Pr->SiS_LVDSCRT1640x480_1 = SiS_LVDSCRT1640x480_1; |
| 147 | SiS_Pr->SiS_LVDSCRT1640x480_1_H = SiS_LVDSCRT1640x480_1_H; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 148 | #if 0 |
| 149 | SiS_Pr->SiS_LVDSCRT11024x600_1 = SiS_LVDSCRT11024x600_1; |
| 150 | SiS_Pr->SiS_LVDSCRT11024x600_1_H = SiS_LVDSCRT11024x600_1_H; |
| 151 | SiS_Pr->SiS_LVDSCRT11024x600_2 = SiS_LVDSCRT11024x600_2; |
| 152 | SiS_Pr->SiS_LVDSCRT11024x600_2_H = SiS_LVDSCRT11024x600_2_H; |
| 153 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
| 155 | SiS_Pr->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData; |
| 156 | SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData; |
| 157 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* lowest value LVDS/LCDA */ |
| 159 | SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */ |
| 160 | } |
| 161 | #endif |
| 162 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 163 | #ifdef CONFIG_FB_SIS_300 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 165 | InitTo300Pointer(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 167 | InitCommonPointer(SiS_Pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | SiS_Pr->SiS_VBModeIDTable = SiS300_VBModeIDTable; |
| 170 | SiS_Pr->SiS_EModeIDTable = SiS300_EModeIDTable; |
| 171 | SiS_Pr->SiS_RefIndex = SiS300_RefIndex; |
| 172 | SiS_Pr->SiS_CRT1Table = SiS300_CRT1Table; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 173 | if(SiS_Pr->ChipType == SIS_300) { |
| 174 | SiS_Pr->SiS_MCLKData_0 = SiS300_MCLKData_300; /* 300 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | } else { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 176 | SiS_Pr->SiS_MCLKData_0 = SiS300_MCLKData_630; /* 630, 730 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | } |
| 178 | SiS_Pr->SiS_VCLKData = SiS300_VCLKData; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 179 | SiS_Pr->SiS_VBVCLKData = (struct SiS_VBVCLKData *)SiS300_VCLKData; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
| 181 | SiS_Pr->SiS_SR15 = SiS300_SR15; |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | SiS_Pr->SiS_PanelDelayTbl = SiS300_PanelDelayTbl; |
| 184 | SiS_Pr->SiS_PanelDelayTblLVDS = SiS300_PanelDelayTbl; |
| 185 | |
| 186 | SiS_Pr->SiS_ExtLCD1024x768Data = SiS300_ExtLCD1024x768Data; |
| 187 | SiS_Pr->SiS_St2LCD1024x768Data = SiS300_St2LCD1024x768Data; |
| 188 | SiS_Pr->SiS_ExtLCD1280x1024Data = SiS300_ExtLCD1280x1024Data; |
| 189 | SiS_Pr->SiS_St2LCD1280x1024Data = SiS300_St2LCD1280x1024Data; |
| 190 | |
| 191 | SiS_Pr->SiS_CRT2Part2_1024x768_1 = SiS300_CRT2Part2_1024x768_1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | SiS_Pr->SiS_CRT2Part2_1024x768_2 = SiS300_CRT2Part2_1024x768_2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | SiS_Pr->SiS_CRT2Part2_1024x768_3 = SiS300_CRT2Part2_1024x768_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
| 195 | SiS_Pr->SiS_CHTVUPALData = SiS300_CHTVUPALData; |
| 196 | SiS_Pr->SiS_CHTVOPALData = SiS300_CHTVOPALData; |
| 197 | SiS_Pr->SiS_CHTVUPALMData = SiS_CHTVUNTSCData; /* not supported on 300 series */ |
| 198 | SiS_Pr->SiS_CHTVOPALMData = SiS_CHTVONTSCData; /* not supported on 300 series */ |
| 199 | SiS_Pr->SiS_CHTVUPALNData = SiS300_CHTVUPALData; /* not supported on 300 series */ |
| 200 | SiS_Pr->SiS_CHTVOPALNData = SiS300_CHTVOPALData; /* not supported on 300 series */ |
| 201 | SiS_Pr->SiS_CHTVSOPALData = SiS300_CHTVSOPALData; |
| 202 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 203 | SiS_Pr->SiS_LVDS848x480Data_1 = SiS300_LVDS848x480Data_1; |
| 204 | SiS_Pr->SiS_LVDS848x480Data_2 = SiS300_LVDS848x480Data_2; |
| 205 | SiS_Pr->SiS_LVDSBARCO1024Data_1 = SiS300_LVDSBARCO1024Data_1; |
| 206 | SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS300_LVDSBARCO1366Data_1; |
| 207 | SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS300_LVDSBARCO1366Data_2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 209 | SiS_Pr->SiS_PanelType04_1a = SiS300_PanelType04_1a; |
| 210 | SiS_Pr->SiS_PanelType04_2a = SiS300_PanelType04_2a; |
| 211 | SiS_Pr->SiS_PanelType04_1b = SiS300_PanelType04_1b; |
| 212 | SiS_Pr->SiS_PanelType04_2b = SiS300_PanelType04_2b; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
| 214 | SiS_Pr->SiS_CHTVCRT1UNTSC = SiS300_CHTVCRT1UNTSC; |
| 215 | SiS_Pr->SiS_CHTVCRT1ONTSC = SiS300_CHTVCRT1ONTSC; |
| 216 | SiS_Pr->SiS_CHTVCRT1UPAL = SiS300_CHTVCRT1UPAL; |
| 217 | SiS_Pr->SiS_CHTVCRT1OPAL = SiS300_CHTVCRT1OPAL; |
| 218 | SiS_Pr->SiS_CHTVCRT1SOPAL = SiS300_CHTVCRT1SOPAL; |
| 219 | SiS_Pr->SiS_CHTVReg_UNTSC = SiS300_CHTVReg_UNTSC; |
| 220 | SiS_Pr->SiS_CHTVReg_ONTSC = SiS300_CHTVReg_ONTSC; |
| 221 | SiS_Pr->SiS_CHTVReg_UPAL = SiS300_CHTVReg_UPAL; |
| 222 | SiS_Pr->SiS_CHTVReg_OPAL = SiS300_CHTVReg_OPAL; |
| 223 | SiS_Pr->SiS_CHTVReg_UPALM = SiS300_CHTVReg_UNTSC; /* not supported on 300 series */ |
| 224 | SiS_Pr->SiS_CHTVReg_OPALM = SiS300_CHTVReg_ONTSC; /* not supported on 300 series */ |
| 225 | SiS_Pr->SiS_CHTVReg_UPALN = SiS300_CHTVReg_UPAL; /* not supported on 300 series */ |
| 226 | SiS_Pr->SiS_CHTVReg_OPALN = SiS300_CHTVReg_OPAL; /* not supported on 300 series */ |
| 227 | SiS_Pr->SiS_CHTVReg_SOPAL = SiS300_CHTVReg_SOPAL; |
| 228 | SiS_Pr->SiS_CHTVVCLKUNTSC = SiS300_CHTVVCLKUNTSC; |
| 229 | SiS_Pr->SiS_CHTVVCLKONTSC = SiS300_CHTVVCLKONTSC; |
| 230 | SiS_Pr->SiS_CHTVVCLKUPAL = SiS300_CHTVVCLKUPAL; |
| 231 | SiS_Pr->SiS_CHTVVCLKOPAL = SiS300_CHTVVCLKOPAL; |
| 232 | SiS_Pr->SiS_CHTVVCLKUPALM = SiS300_CHTVVCLKUNTSC; /* not supported on 300 series */ |
| 233 | SiS_Pr->SiS_CHTVVCLKOPALM = SiS300_CHTVVCLKONTSC; /* not supported on 300 series */ |
| 234 | SiS_Pr->SiS_CHTVVCLKUPALN = SiS300_CHTVVCLKUPAL; /* not supported on 300 series */ |
| 235 | SiS_Pr->SiS_CHTVVCLKOPALN = SiS300_CHTVVCLKOPAL; /* not supported on 300 series */ |
| 236 | SiS_Pr->SiS_CHTVVCLKSOPAL = SiS300_CHTVVCLKSOPAL; |
| 237 | } |
| 238 | #endif |
| 239 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 240 | #ifdef CONFIG_FB_SIS_315 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 242 | InitTo310Pointer(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 244 | InitCommonPointer(SiS_Pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | SiS_Pr->SiS_EModeIDTable = SiS310_EModeIDTable; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 247 | SiS_Pr->SiS_RefIndex = SiS310_RefIndex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | SiS_Pr->SiS_CRT1Table = SiS310_CRT1Table; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 249 | if(SiS_Pr->ChipType >= SIS_340) { |
| 250 | SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_340; /* 340 + XGI */ |
| 251 | } else if(SiS_Pr->ChipType >= SIS_761) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_761; /* 761 - preliminary */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 253 | } else if(SiS_Pr->ChipType >= SIS_760) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_760; /* 760 */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 255 | } else if(SiS_Pr->ChipType >= SIS_661) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_660; /* 661/741 */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 257 | } else if(SiS_Pr->ChipType == SIS_330) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_330; /* 330 */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 259 | } else if(SiS_Pr->ChipType > SIS_315PRO) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_650; /* 550, 650, 740 */ |
| 261 | } else { |
| 262 | SiS_Pr->SiS_MCLKData_0 = SiS310_MCLKData_0_315; /* 315 */ |
| 263 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 264 | if(SiS_Pr->ChipType >= SIS_340) { |
| 265 | SiS_Pr->SiS_MCLKData_1 = SiS310_MCLKData_1_340; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | } else { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 267 | SiS_Pr->SiS_MCLKData_1 = SiS310_MCLKData_1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } |
| 269 | SiS_Pr->SiS_VCLKData = SiS310_VCLKData; |
| 270 | SiS_Pr->SiS_VBVCLKData = SiS310_VBVCLKData; |
| 271 | |
| 272 | SiS_Pr->SiS_SR15 = SiS310_SR15; |
| 273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | SiS_Pr->SiS_PanelDelayTbl = SiS310_PanelDelayTbl; |
| 275 | SiS_Pr->SiS_PanelDelayTblLVDS = SiS310_PanelDelayTblLVDS; |
| 276 | |
| 277 | SiS_Pr->SiS_St2LCD1024x768Data = SiS310_St2LCD1024x768Data; |
| 278 | SiS_Pr->SiS_ExtLCD1024x768Data = SiS310_ExtLCD1024x768Data; |
| 279 | SiS_Pr->SiS_St2LCD1280x1024Data = SiS310_St2LCD1280x1024Data; |
| 280 | SiS_Pr->SiS_ExtLCD1280x1024Data = SiS310_ExtLCD1280x1024Data; |
| 281 | |
| 282 | SiS_Pr->SiS_CRT2Part2_1024x768_1 = SiS310_CRT2Part2_1024x768_1; |
| 283 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | SiS_Pr->SiS_CHTVUPALData = SiS310_CHTVUPALData; |
| 285 | SiS_Pr->SiS_CHTVOPALData = SiS310_CHTVOPALData; |
| 286 | SiS_Pr->SiS_CHTVUPALMData = SiS310_CHTVUPALMData; |
| 287 | SiS_Pr->SiS_CHTVOPALMData = SiS310_CHTVOPALMData; |
| 288 | SiS_Pr->SiS_CHTVUPALNData = SiS310_CHTVUPALNData; |
| 289 | SiS_Pr->SiS_CHTVOPALNData = SiS310_CHTVOPALNData; |
| 290 | SiS_Pr->SiS_CHTVSOPALData = SiS310_CHTVSOPALData; |
| 291 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 292 | SiS_Pr->SiS_CHTVCRT1UNTSC = SiS310_CHTVCRT1UNTSC; |
| 293 | SiS_Pr->SiS_CHTVCRT1ONTSC = SiS310_CHTVCRT1ONTSC; |
| 294 | SiS_Pr->SiS_CHTVCRT1UPAL = SiS310_CHTVCRT1UPAL; |
| 295 | SiS_Pr->SiS_CHTVCRT1OPAL = SiS310_CHTVCRT1OPAL; |
| 296 | SiS_Pr->SiS_CHTVCRT1SOPAL = SiS310_CHTVCRT1OPAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
| 298 | SiS_Pr->SiS_CHTVReg_UNTSC = SiS310_CHTVReg_UNTSC; |
| 299 | SiS_Pr->SiS_CHTVReg_ONTSC = SiS310_CHTVReg_ONTSC; |
| 300 | SiS_Pr->SiS_CHTVReg_UPAL = SiS310_CHTVReg_UPAL; |
| 301 | SiS_Pr->SiS_CHTVReg_OPAL = SiS310_CHTVReg_OPAL; |
| 302 | SiS_Pr->SiS_CHTVReg_UPALM = SiS310_CHTVReg_UPALM; |
| 303 | SiS_Pr->SiS_CHTVReg_OPALM = SiS310_CHTVReg_OPALM; |
| 304 | SiS_Pr->SiS_CHTVReg_UPALN = SiS310_CHTVReg_UPALN; |
| 305 | SiS_Pr->SiS_CHTVReg_OPALN = SiS310_CHTVReg_OPALN; |
| 306 | SiS_Pr->SiS_CHTVReg_SOPAL = SiS310_CHTVReg_OPAL; |
| 307 | |
| 308 | SiS_Pr->SiS_CHTVVCLKUNTSC = SiS310_CHTVVCLKUNTSC; |
| 309 | SiS_Pr->SiS_CHTVVCLKONTSC = SiS310_CHTVVCLKONTSC; |
| 310 | SiS_Pr->SiS_CHTVVCLKUPAL = SiS310_CHTVVCLKUPAL; |
| 311 | SiS_Pr->SiS_CHTVVCLKOPAL = SiS310_CHTVVCLKOPAL; |
| 312 | SiS_Pr->SiS_CHTVVCLKUPALM = SiS310_CHTVVCLKUPALM; |
| 313 | SiS_Pr->SiS_CHTVVCLKOPALM = SiS310_CHTVVCLKOPALM; |
| 314 | SiS_Pr->SiS_CHTVVCLKUPALN = SiS310_CHTVVCLKUPALN; |
| 315 | SiS_Pr->SiS_CHTVVCLKOPALN = SiS310_CHTVVCLKOPALN; |
| 316 | SiS_Pr->SiS_CHTVVCLKSOPAL = SiS310_CHTVVCLKOPAL; |
| 317 | } |
| 318 | #endif |
| 319 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 320 | bool |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 321 | SiSInitPtr(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 323 | if(SiS_Pr->ChipType < SIS_315H) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 324 | #ifdef CONFIG_FB_SIS_300 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 325 | InitTo300Pointer(SiS_Pr); |
| 326 | #else |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 327 | return false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | #endif |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 329 | } else { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 330 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 331 | InitTo310Pointer(SiS_Pr); |
| 332 | #else |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 333 | return false; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 334 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | } |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 336 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | /*********************************************/ |
| 340 | /* HELPER: Get ModeID */ |
| 341 | /*********************************************/ |
| 342 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 343 | static |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 344 | unsigned short |
| 345 | SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 346 | int Depth, bool FSTN, int LCDwidth, int LCDheight) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 348 | unsigned short ModeIndex = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
| 350 | switch(HDisplay) |
| 351 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 352 | case 320: |
| 353 | if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; |
| 354 | else if(VDisplay == 240) { |
| 355 | if((VBFlags & CRT2_LCD) && (FSTN)) |
| 356 | ModeIndex = ModeIndex_320x240_FSTN[Depth]; |
| 357 | else |
| 358 | ModeIndex = ModeIndex_320x240[Depth]; |
| 359 | } |
| 360 | break; |
| 361 | case 400: |
| 362 | if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && (LCDwidth >= 600))) { |
| 363 | if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; |
| 364 | } |
| 365 | break; |
| 366 | case 512: |
| 367 | if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 1024) && (LCDwidth >= 768))) { |
| 368 | if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; |
| 369 | } |
| 370 | break; |
| 371 | case 640: |
| 372 | if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; |
| 373 | else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; |
| 374 | break; |
| 375 | case 720: |
| 376 | if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; |
| 377 | else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; |
| 378 | break; |
| 379 | case 768: |
| 380 | if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; |
| 381 | break; |
| 382 | case 800: |
| 383 | if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; |
| 384 | else if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; |
| 385 | break; |
| 386 | case 848: |
| 387 | if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; |
| 388 | break; |
| 389 | case 856: |
| 390 | if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; |
| 391 | break; |
| 392 | case 960: |
| 393 | if(VGAEngine == SIS_315_VGA) { |
| 394 | if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; |
| 395 | else if(VDisplay == 600) ModeIndex = ModeIndex_960x600[Depth]; |
| 396 | } |
| 397 | break; |
| 398 | case 1024: |
| 399 | if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; |
| 400 | else if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; |
| 401 | else if(VGAEngine == SIS_300_VGA) { |
| 402 | if(VDisplay == 600) ModeIndex = ModeIndex_1024x600[Depth]; |
| 403 | } |
| 404 | break; |
| 405 | case 1152: |
| 406 | if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; |
| 407 | if(VGAEngine == SIS_300_VGA) { |
| 408 | if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth]; |
| 409 | } |
| 410 | break; |
| 411 | case 1280: |
| 412 | switch(VDisplay) { |
| 413 | case 720: |
| 414 | ModeIndex = ModeIndex_1280x720[Depth]; |
| 415 | break; |
| 416 | case 768: |
| 417 | if(VGAEngine == SIS_300_VGA) { |
| 418 | ModeIndex = ModeIndex_300_1280x768[Depth]; |
| 419 | } else { |
| 420 | ModeIndex = ModeIndex_310_1280x768[Depth]; |
| 421 | } |
| 422 | break; |
| 423 | case 800: |
| 424 | if(VGAEngine == SIS_315_VGA) { |
| 425 | ModeIndex = ModeIndex_1280x800[Depth]; |
| 426 | } |
| 427 | break; |
| 428 | case 854: |
| 429 | if(VGAEngine == SIS_315_VGA) { |
| 430 | ModeIndex = ModeIndex_1280x854[Depth]; |
| 431 | } |
| 432 | break; |
| 433 | case 960: |
| 434 | ModeIndex = ModeIndex_1280x960[Depth]; |
| 435 | break; |
| 436 | case 1024: |
| 437 | ModeIndex = ModeIndex_1280x1024[Depth]; |
| 438 | break; |
| 439 | } |
| 440 | break; |
| 441 | case 1360: |
| 442 | if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; |
| 443 | if(VGAEngine == SIS_300_VGA) { |
| 444 | if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; |
| 445 | } |
| 446 | break; |
| 447 | case 1400: |
| 448 | if(VGAEngine == SIS_315_VGA) { |
| 449 | if(VDisplay == 1050) { |
| 450 | ModeIndex = ModeIndex_1400x1050[Depth]; |
| 451 | } |
| 452 | } |
| 453 | break; |
| 454 | case 1600: |
| 455 | if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; |
| 456 | break; |
| 457 | case 1680: |
| 458 | if(VGAEngine == SIS_315_VGA) { |
| 459 | if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; |
| 460 | } |
| 461 | break; |
| 462 | case 1920: |
| 463 | if(VDisplay == 1440) ModeIndex = ModeIndex_1920x1440[Depth]; |
| 464 | else if(VGAEngine == SIS_315_VGA) { |
| 465 | if(VDisplay == 1080) ModeIndex = ModeIndex_1920x1080[Depth]; |
| 466 | } |
| 467 | break; |
| 468 | case 2048: |
| 469 | if(VDisplay == 1536) { |
| 470 | if(VGAEngine == SIS_300_VGA) { |
| 471 | ModeIndex = ModeIndex_300_2048x1536[Depth]; |
| 472 | } else { |
| 473 | ModeIndex = ModeIndex_310_2048x1536[Depth]; |
| 474 | } |
| 475 | } |
| 476 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 479 | return ModeIndex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 482 | unsigned short |
| 483 | SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 484 | int Depth, bool FSTN, unsigned short CustomT, int LCDwidth, int LCDheight, |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 485 | unsigned int VBFlags2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 487 | unsigned short ModeIndex = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 489 | if(VBFlags2 & (VB2_LVDS | VB2_30xBDH)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
| 491 | switch(HDisplay) |
| 492 | { |
| 493 | case 320: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 494 | if((CustomT != CUT_PANEL848) && (CustomT != CUT_PANEL856)) { |
| 495 | if(VDisplay == 200) { |
| 496 | if(!FSTN) ModeIndex = ModeIndex_320x200[Depth]; |
| 497 | } else if(VDisplay == 240) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | if(!FSTN) ModeIndex = ModeIndex_320x240[Depth]; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 499 | else if(VGAEngine == SIS_315_VGA) { |
| 500 | ModeIndex = ModeIndex_320x240_FSTN[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | } |
| 502 | } |
| 503 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 504 | break; |
| 505 | case 400: |
| 506 | if((CustomT != CUT_PANEL848) && (CustomT != CUT_PANEL856)) { |
| 507 | if(!((VGAEngine == SIS_300_VGA) && (VBFlags2 & VB2_TRUMPION))) { |
| 508 | if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | } |
| 510 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 511 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | case 512: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 513 | if((CustomT != CUT_PANEL848) && (CustomT != CUT_PANEL856)) { |
| 514 | if(!((VGAEngine == SIS_300_VGA) && (VBFlags2 & VB2_TRUMPION))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | if(LCDwidth >= 1024 && LCDwidth != 1152 && LCDheight >= 768) { |
| 516 | if(VDisplay == 384) { |
| 517 | ModeIndex = ModeIndex_512x384[Depth]; |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | } |
| 522 | break; |
| 523 | case 640: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 524 | if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | else if(VDisplay == 400) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 526 | if((CustomT != CUT_PANEL848) && (CustomT != CUT_PANEL856)) |
| 527 | ModeIndex = ModeIndex_640x400[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | } |
| 529 | break; |
| 530 | case 800: |
| 531 | if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; |
| 532 | break; |
| 533 | case 848: |
| 534 | if(CustomT == CUT_PANEL848) { |
| 535 | if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; |
| 536 | } |
| 537 | break; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 538 | case 856: |
| 539 | if(CustomT == CUT_PANEL856) { |
| 540 | if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; |
| 541 | } |
| 542 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | case 1024: |
| 544 | if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; |
| 545 | else if(VGAEngine == SIS_300_VGA) { |
| 546 | if((VDisplay == 600) && (LCDheight == 600)) { |
| 547 | ModeIndex = ModeIndex_1024x600[Depth]; |
| 548 | } |
| 549 | } |
| 550 | break; |
| 551 | case 1152: |
| 552 | if(VGAEngine == SIS_300_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 553 | if((VDisplay == 768) && (LCDheight == 768)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | ModeIndex = ModeIndex_1152x768[Depth]; |
| 555 | } |
| 556 | } |
| 557 | break; |
| 558 | case 1280: |
| 559 | if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth]; |
| 560 | else if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 561 | if((VDisplay == 768) && (LCDheight == 768)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | ModeIndex = ModeIndex_310_1280x768[Depth]; |
| 563 | } |
| 564 | } |
| 565 | break; |
| 566 | case 1360: |
| 567 | if(VGAEngine == SIS_300_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 568 | if(CustomT == CUT_BARCO1366) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth]; |
| 570 | } |
| 571 | } |
| 572 | if(CustomT == CUT_PANEL848) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 573 | if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | } |
| 575 | break; |
| 576 | case 1400: |
| 577 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 578 | if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | } |
| 580 | break; |
| 581 | case 1600: |
| 582 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 583 | if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | } |
| 585 | break; |
| 586 | } |
| 587 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 588 | } else if(VBFlags2 & VB2_SISBRIDGE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | |
| 590 | switch(HDisplay) |
| 591 | { |
| 592 | case 320: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 593 | if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 595 | break; |
| 596 | case 400: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | if(LCDwidth >= 800 && LCDheight >= 600) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 598 | if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 600 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | case 512: |
| 602 | if(LCDwidth >= 1024 && LCDheight >= 768 && LCDwidth != 1152) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 603 | if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | } |
| 605 | break; |
| 606 | case 640: |
| 607 | if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; |
| 608 | else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; |
| 609 | break; |
| 610 | case 720: |
| 611 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 612 | if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth]; |
| 614 | } |
| 615 | break; |
| 616 | case 768: |
| 617 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 618 | if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | } |
| 620 | break; |
| 621 | case 800: |
| 622 | if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; |
| 623 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 624 | if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | } |
| 626 | break; |
| 627 | case 848: |
| 628 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 629 | if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | } |
| 631 | break; |
| 632 | case 856: |
| 633 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 634 | if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | } |
| 636 | break; |
| 637 | case 960: |
| 638 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 639 | if(VDisplay == 540) ModeIndex = ModeIndex_960x540[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | else if(VDisplay == 600) ModeIndex = ModeIndex_960x600[Depth]; |
| 641 | } |
| 642 | break; |
| 643 | case 1024: |
| 644 | if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; |
| 645 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 646 | if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | } |
| 648 | break; |
| 649 | case 1152: |
| 650 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 651 | if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | } |
| 653 | break; |
| 654 | case 1280: |
| 655 | switch(VDisplay) { |
| 656 | case 720: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 657 | ModeIndex = ModeIndex_1280x720[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | case 768: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 659 | if(VGAEngine == SIS_300_VGA) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | ModeIndex = ModeIndex_300_1280x768[Depth]; |
| 661 | } else { |
| 662 | ModeIndex = ModeIndex_310_1280x768[Depth]; |
| 663 | } |
| 664 | break; |
| 665 | case 800: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 666 | if(VGAEngine == SIS_315_VGA) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | ModeIndex = ModeIndex_1280x800[Depth]; |
| 668 | } |
| 669 | break; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 670 | case 854: |
| 671 | if(VGAEngine == SIS_315_VGA) { |
| 672 | ModeIndex = ModeIndex_1280x854[Depth]; |
| 673 | } |
| 674 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | case 960: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 676 | ModeIndex = ModeIndex_1280x960[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | break; |
| 678 | case 1024: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 679 | ModeIndex = ModeIndex_1280x1024[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | break; |
| 681 | } |
| 682 | break; |
| 683 | case 1360: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 684 | if(VGAEngine == SIS_315_VGA) { /* OVER1280 only? */ |
| 685 | if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | } |
| 687 | break; |
| 688 | case 1400: |
| 689 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 690 | if(VBFlags2 & VB2_LCDOVER1280BRIDGE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth]; |
| 692 | } |
| 693 | } |
| 694 | break; |
| 695 | case 1600: |
| 696 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 697 | if(VBFlags2 & VB2_LCDOVER1280BRIDGE) { |
| 698 | if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | } |
| 700 | } |
| 701 | break; |
| 702 | #ifndef VB_FORBID_CRT2LCD_OVER_1600 |
| 703 | case 1680: |
| 704 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 705 | if(VBFlags2 & VB2_LCDOVER1280BRIDGE) { |
| 706 | if(VDisplay == 1050) ModeIndex = ModeIndex_1680x1050[Depth]; |
| 707 | } |
| 708 | } |
| 709 | break; |
| 710 | case 1920: |
| 711 | if(VGAEngine == SIS_315_VGA) { |
| 712 | if(VBFlags2 & VB2_LCDOVER1600BRIDGE) { |
| 713 | if(VDisplay == 1440) ModeIndex = ModeIndex_1920x1440[Depth]; |
| 714 | } |
| 715 | } |
| 716 | break; |
| 717 | case 2048: |
| 718 | if(VGAEngine == SIS_315_VGA) { |
| 719 | if(VBFlags2 & VB2_LCDOVER1600BRIDGE) { |
| 720 | if(VDisplay == 1536) ModeIndex = ModeIndex_310_2048x1536[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | } |
| 722 | } |
| 723 | break; |
| 724 | #endif |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | return ModeIndex; |
| 729 | } |
| 730 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 731 | unsigned short |
| 732 | SiS_GetModeID_TV(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, int Depth, |
| 733 | unsigned int VBFlags2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 735 | unsigned short ModeIndex = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 737 | if(VBFlags2 & VB2_CHRONTEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | |
| 739 | switch(HDisplay) |
| 740 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 741 | case 512: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | if(VGAEngine == SIS_315_VGA) { |
| 743 | if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; |
| 744 | } |
| 745 | break; |
| 746 | case 640: |
| 747 | if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; |
| 748 | else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; |
| 749 | break; |
| 750 | case 800: |
| 751 | if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; |
| 752 | break; |
| 753 | case 1024: |
| 754 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 755 | if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | } |
| 757 | break; |
| 758 | } |
| 759 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 760 | } else if(VBFlags2 & VB2_SISTVBRIDGE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | |
| 762 | switch(HDisplay) |
| 763 | { |
| 764 | case 320: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 765 | if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth]; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 767 | break; |
| 768 | case 400: |
| 769 | if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth]; |
| 770 | break; |
| 771 | case 512: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | if( ((VBFlags & TV_YPBPR) && (VBFlags & (TV_YPBPR750P | TV_YPBPR1080I))) || |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 773 | (VBFlags & TV_HIVISION) || |
| 774 | ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) { |
| 775 | if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | } |
| 777 | break; |
| 778 | case 640: |
| 779 | if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth]; |
| 780 | else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth]; |
| 781 | break; |
| 782 | case 720: |
| 783 | if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 784 | if(VDisplay == 480) { |
| 785 | ModeIndex = ModeIndex_720x480[Depth]; |
| 786 | } else if(VDisplay == 576) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | if( ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR750P)) || |
| 788 | ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 789 | ModeIndex = ModeIndex_720x576[Depth]; |
| 790 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | } |
| 792 | break; |
| 793 | case 768: |
| 794 | if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 795 | if( ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR750P)) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 797 | if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | } |
| 799 | } |
| 800 | break; |
| 801 | case 800: |
| 802 | if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth]; |
| 803 | else if(VDisplay == 480) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 804 | if(!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR750P))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | ModeIndex = ModeIndex_800x480[Depth]; |
| 806 | } |
| 807 | } |
| 808 | break; |
| 809 | case 960: |
| 810 | if(VGAEngine == SIS_315_VGA) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 811 | if(VDisplay == 600) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { |
| 813 | ModeIndex = ModeIndex_960x600[Depth]; |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | break; |
| 818 | case 1024: |
| 819 | if(VDisplay == 768) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 820 | if(VBFlags2 & VB2_30xBLV) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | ModeIndex = ModeIndex_1024x768[Depth]; |
| 822 | } |
| 823 | } else if(VDisplay == 576) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 824 | if( (VBFlags & TV_HIVISION) || |
| 825 | ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)) || |
| 826 | ((VBFlags2 & VB2_30xBLV) && |
| 827 | ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL))) ) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | ModeIndex = ModeIndex_1024x576[Depth]; |
| 829 | } |
| 830 | } |
| 831 | break; |
| 832 | case 1280: |
| 833 | if(VDisplay == 720) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 834 | if((VBFlags & TV_HIVISION) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | ((VBFlags & TV_YPBPR) && (VBFlags & (TV_YPBPR1080I | TV_YPBPR750P)))) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 836 | ModeIndex = ModeIndex_1280x720[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | } |
| 838 | } else if(VDisplay == 1024) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 839 | if((VBFlags & TV_HIVISION) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 841 | ModeIndex = ModeIndex_1280x1024[Depth]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | } |
| 843 | } |
| 844 | break; |
| 845 | } |
| 846 | } |
| 847 | return ModeIndex; |
| 848 | } |
| 849 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 850 | unsigned short |
| 851 | SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, int Depth, |
| 852 | unsigned int VBFlags2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 854 | if(!(VBFlags2 & VB2_SISVGA2BRIDGE)) return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 856 | if(HDisplay >= 1920) return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | |
| 858 | switch(HDisplay) |
| 859 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | case 1600: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 861 | if(VDisplay == 1200) { |
| 862 | if(VGAEngine != SIS_315_VGA) return 0; |
| 863 | if(!(VBFlags2 & VB2_30xB)) return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | } |
| 865 | break; |
| 866 | case 1680: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 867 | if(VDisplay == 1050) { |
| 868 | if(VGAEngine != SIS_315_VGA) return 0; |
| 869 | if(!(VBFlags2 & VB2_30xB)) return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | } |
| 871 | break; |
| 872 | } |
| 873 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 874 | return SiS_GetModeID(VGAEngine, 0, HDisplay, VDisplay, Depth, false, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | } |
| 876 | |
| 877 | |
| 878 | /*********************************************/ |
| 879 | /* HELPER: SetReg, GetReg */ |
| 880 | /*********************************************/ |
| 881 | |
| 882 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 883 | SiS_SetReg(SISIOADDRESS port, unsigned short index, unsigned short data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | { |
Aaro Koskinen | 2ad2847 | 2010-11-19 21:58:48 +0000 | [diff] [blame] | 885 | outb((u8)index, port); |
| 886 | outb((u8)data, port + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 890 | SiS_SetRegByte(SISIOADDRESS port, unsigned short data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | { |
Aaro Koskinen | 2ad2847 | 2010-11-19 21:58:48 +0000 | [diff] [blame] | 892 | outb((u8)data, port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | } |
| 894 | |
| 895 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 896 | SiS_SetRegShort(SISIOADDRESS port, unsigned short data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | { |
Aaro Koskinen | 2ad2847 | 2010-11-19 21:58:48 +0000 | [diff] [blame] | 898 | outw((u16)data, port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 902 | SiS_SetRegLong(SISIOADDRESS port, unsigned int data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | { |
Aaro Koskinen | 2ad2847 | 2010-11-19 21:58:48 +0000 | [diff] [blame] | 904 | outl((u32)data, port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | } |
| 906 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 907 | unsigned char |
| 908 | SiS_GetReg(SISIOADDRESS port, unsigned short index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | { |
Aaro Koskinen | 2ad2847 | 2010-11-19 21:58:48 +0000 | [diff] [blame] | 910 | outb((u8)index, port); |
| 911 | return inb(port + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | } |
| 913 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 914 | unsigned char |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | SiS_GetRegByte(SISIOADDRESS port) |
| 916 | { |
Aaro Koskinen | 2ad2847 | 2010-11-19 21:58:48 +0000 | [diff] [blame] | 917 | return inb(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | } |
| 919 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 920 | unsigned short |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | SiS_GetRegShort(SISIOADDRESS port) |
| 922 | { |
Aaro Koskinen | 2ad2847 | 2010-11-19 21:58:48 +0000 | [diff] [blame] | 923 | return inw(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | } |
| 925 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 926 | unsigned int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | SiS_GetRegLong(SISIOADDRESS port) |
| 928 | { |
Aaro Koskinen | 2ad2847 | 2010-11-19 21:58:48 +0000 | [diff] [blame] | 929 | return inl(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | } |
| 931 | |
| 932 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 933 | SiS_SetRegANDOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND, unsigned short DataOR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 935 | unsigned short temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 937 | temp = SiS_GetReg(Port, Index); |
| 938 | temp = (temp & (DataAND)) | DataOR; |
| 939 | SiS_SetReg(Port, Index, temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 943 | SiS_SetRegAND(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 945 | unsigned short temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 947 | temp = SiS_GetReg(Port, Index); |
| 948 | temp &= DataAND; |
| 949 | SiS_SetReg(Port, Index, temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | } |
| 951 | |
| 952 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 953 | SiS_SetRegOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataOR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 955 | unsigned short temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 956 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 957 | temp = SiS_GetReg(Port, Index); |
| 958 | temp |= DataOR; |
| 959 | SiS_SetReg(Port, Index, temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | /*********************************************/ |
| 963 | /* HELPER: DisplayOn, DisplayOff */ |
| 964 | /*********************************************/ |
| 965 | |
| 966 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 967 | SiS_DisplayOn(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | { |
| 969 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x01,0xDF); |
| 970 | } |
| 971 | |
| 972 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 973 | SiS_DisplayOff(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | { |
| 975 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x20); |
| 976 | } |
| 977 | |
| 978 | |
| 979 | /*********************************************/ |
| 980 | /* HELPER: Init Port Addresses */ |
| 981 | /*********************************************/ |
| 982 | |
| 983 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 984 | SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | { |
| 986 | SiS_Pr->SiS_P3c4 = BaseAddr + 0x14; |
| 987 | SiS_Pr->SiS_P3d4 = BaseAddr + 0x24; |
| 988 | SiS_Pr->SiS_P3c0 = BaseAddr + 0x10; |
| 989 | SiS_Pr->SiS_P3ce = BaseAddr + 0x1e; |
| 990 | SiS_Pr->SiS_P3c2 = BaseAddr + 0x12; |
| 991 | SiS_Pr->SiS_P3ca = BaseAddr + 0x1a; |
| 992 | SiS_Pr->SiS_P3c6 = BaseAddr + 0x16; |
| 993 | SiS_Pr->SiS_P3c7 = BaseAddr + 0x17; |
| 994 | SiS_Pr->SiS_P3c8 = BaseAddr + 0x18; |
| 995 | SiS_Pr->SiS_P3c9 = BaseAddr + 0x19; |
| 996 | SiS_Pr->SiS_P3cb = BaseAddr + 0x1b; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 997 | SiS_Pr->SiS_P3cc = BaseAddr + 0x1c; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | SiS_Pr->SiS_P3cd = BaseAddr + 0x1d; |
| 999 | SiS_Pr->SiS_P3da = BaseAddr + 0x2a; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1000 | SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04; |
| 1001 | SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10; |
| 1002 | SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12; |
| 1003 | SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14; |
| 1004 | SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2; |
| 1005 | SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14; |
| 1006 | SiS_Pr->SiS_VidCapt = BaseAddr + SIS_VIDEO_CAPTURE; |
| 1007 | SiS_Pr->SiS_VidPlay = BaseAddr + SIS_VIDEO_PLAYBACK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | /*********************************************/ |
| 1011 | /* HELPER: GetSysFlags */ |
| 1012 | /*********************************************/ |
| 1013 | |
| 1014 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1015 | SiS_GetSysFlags(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | { |
| 1017 | unsigned char cr5f, temp1, temp2; |
| 1018 | |
| 1019 | /* 661 and newer: NEVER write non-zero to SR11[7:4] */ |
| 1020 | /* (SR11 is used for DDC and in enable/disablebridge) */ |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1021 | SiS_Pr->SiS_SensibleSR11 = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | SiS_Pr->SiS_MyCR63 = 0x63; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1023 | if(SiS_Pr->ChipType >= SIS_330) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | SiS_Pr->SiS_MyCR63 = 0x53; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1025 | if(SiS_Pr->ChipType >= SIS_661) { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1026 | SiS_Pr->SiS_SensibleSR11 = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | /* You should use the macros, not these flags directly */ |
| 1031 | |
| 1032 | SiS_Pr->SiS_SysFlags = 0; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1033 | if(SiS_Pr->ChipType == SIS_650) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | cr5f = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0; |
| 1035 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x5c,0x07); |
| 1036 | temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; |
| 1037 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x5c,0xf8); |
| 1038 | temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; |
| 1039 | if((!temp1) || (temp2)) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1040 | switch(cr5f) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | case 0x80: |
| 1042 | case 0x90: |
| 1043 | case 0xc0: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1044 | SiS_Pr->SiS_SysFlags |= SF_IsM650; |
| 1045 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | case 0xa0: |
| 1047 | case 0xb0: |
| 1048 | case 0xe0: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1049 | SiS_Pr->SiS_SysFlags |= SF_Is651; |
| 1050 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | } |
| 1052 | } else { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1053 | switch(cr5f) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | case 0x90: |
| 1055 | temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8; |
| 1056 | switch(temp1) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1057 | case 0x00: SiS_Pr->SiS_SysFlags |= SF_IsM652; break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | case 0x40: SiS_Pr->SiS_SysFlags |= SF_IsM653; break; |
| 1059 | default: SiS_Pr->SiS_SysFlags |= SF_IsM650; break; |
| 1060 | } |
| 1061 | break; |
| 1062 | case 0xb0: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1063 | SiS_Pr->SiS_SysFlags |= SF_Is652; |
| 1064 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | default: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1066 | SiS_Pr->SiS_SysFlags |= SF_IsM650; |
| 1067 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | } |
| 1069 | } |
| 1070 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1071 | |
| 1072 | if(SiS_Pr->ChipType >= SIS_760 && SiS_Pr->ChipType <= SIS_761) { |
| 1073 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x30) { |
| 1074 | SiS_Pr->SiS_SysFlags |= SF_760LFB; |
| 1075 | } |
| 1076 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0xf0) { |
| 1077 | SiS_Pr->SiS_SysFlags |= SF_760UMA; |
| 1078 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | } |
| 1080 | } |
| 1081 | |
| 1082 | /*********************************************/ |
| 1083 | /* HELPER: Init PCI & Engines */ |
| 1084 | /*********************************************/ |
| 1085 | |
| 1086 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1087 | SiSInitPCIetc(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1089 | switch(SiS_Pr->ChipType) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 1090 | #ifdef CONFIG_FB_SIS_300 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | case SIS_300: |
| 1092 | case SIS_540: |
| 1093 | case SIS_630: |
| 1094 | case SIS_730: |
| 1095 | /* Set - PCI LINEAR ADDRESSING ENABLE (0x80) |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1096 | * - RELOCATED VGA IO ENABLED (0x20) |
| 1097 | * - MMIO ENABLED (0x01) |
| 1098 | * Leave other bits untouched. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1100 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x20,0xa1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | /* - Enable 2D (0x40) |
| 1102 | * - Enable 3D (0x02) |
| 1103 | * - Enable 3D Vertex command fetch (0x10) ? |
| 1104 | * - Enable 3D command parser (0x08) ? |
| 1105 | */ |
| 1106 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A); |
| 1107 | break; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1108 | #endif |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 1109 | #ifdef CONFIG_FB_SIS_315 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | case SIS_315H: |
| 1111 | case SIS_315: |
| 1112 | case SIS_315PRO: |
| 1113 | case SIS_650: |
| 1114 | case SIS_740: |
| 1115 | case SIS_330: |
| 1116 | case SIS_661: |
| 1117 | case SIS_741: |
| 1118 | case SIS_660: |
| 1119 | case SIS_760: |
| 1120 | case SIS_761: |
| 1121 | case SIS_340: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1122 | case XGI_40: |
| 1123 | /* See above */ |
| 1124 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x20,0xa1); |
| 1125 | /* - Enable 3D G/L transformation engine (0x80) |
| 1126 | * - Enable 2D (0x40) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | * - Enable 3D vertex command fetch (0x10) |
| 1128 | * - Enable 3D command parser (0x08) |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1129 | * - Enable 3D (0x02) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | */ |
| 1131 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0xDA); |
| 1132 | break; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1133 | case XGI_20: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | case SIS_550: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1135 | /* See above */ |
| 1136 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x20,0xa1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | /* No 3D engine ! */ |
| 1138 | /* - Enable 2D (0x40) |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1139 | * - disable 3D |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1141 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1E,0x60,0x40); |
| 1142 | break; |
| 1143 | #endif |
| 1144 | default: |
| 1145 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | /*********************************************/ |
| 1150 | /* HELPER: SetLVDSetc */ |
| 1151 | /*********************************************/ |
| 1152 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1153 | static |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1154 | void |
| 1155 | SiSSetLVDSetc(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1157 | unsigned short temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | |
| 1159 | SiS_Pr->SiS_IF_DEF_LVDS = 0; |
| 1160 | SiS_Pr->SiS_IF_DEF_TRUMPION = 0; |
| 1161 | SiS_Pr->SiS_IF_DEF_CH70xx = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | SiS_Pr->SiS_IF_DEF_CONEX = 0; |
| 1163 | |
| 1164 | SiS_Pr->SiS_ChrontelInit = 0; |
| 1165 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1166 | if(SiS_Pr->ChipType == XGI_20) return; |
| 1167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | /* Check for SiS30x first */ |
| 1169 | temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); |
| 1170 | if((temp == 1) || (temp == 2)) return; |
| 1171 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1172 | switch(SiS_Pr->ChipType) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 1173 | #ifdef CONFIG_FB_SIS_300 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | case SIS_540: |
| 1175 | case SIS_630: |
| 1176 | case SIS_730: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1177 | temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x37) & 0x0e) >> 1; |
| 1178 | if((temp >= 2) && (temp <= 5)) SiS_Pr->SiS_IF_DEF_LVDS = 1; |
| 1179 | if(temp == 3) SiS_Pr->SiS_IF_DEF_TRUMPION = 1; |
| 1180 | if((temp == 4) || (temp == 5)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | /* Save power status (and error check) - UNUSED */ |
| 1182 | SiS_Pr->SiS_Backup70xx = SiS_GetCH700x(SiS_Pr, 0x0e); |
| 1183 | SiS_Pr->SiS_IF_DEF_CH70xx = 1; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1184 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | break; |
| 1186 | #endif |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 1187 | #ifdef CONFIG_FB_SIS_315 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | case SIS_550: |
| 1189 | case SIS_650: |
| 1190 | case SIS_740: |
| 1191 | case SIS_330: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1192 | temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x37) & 0x0e) >> 1; |
| 1193 | if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; |
| 1194 | if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; |
| 1195 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | case SIS_661: |
| 1197 | case SIS_741: |
| 1198 | case SIS_660: |
| 1199 | case SIS_760: |
| 1200 | case SIS_761: |
| 1201 | case SIS_340: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1202 | case XGI_20: |
| 1203 | case XGI_40: |
| 1204 | temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & 0xe0) >> 5; |
| 1205 | if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1; |
| 1206 | if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2; |
| 1207 | if(temp == 4) SiS_Pr->SiS_IF_DEF_CONEX = 1; /* Not yet supported */ |
| 1208 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | #endif |
| 1210 | default: |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1211 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1212 | } |
| 1213 | } |
| 1214 | |
| 1215 | /*********************************************/ |
| 1216 | /* HELPER: Enable DSTN/FSTN */ |
| 1217 | /*********************************************/ |
| 1218 | |
| 1219 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1220 | SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | { |
| 1222 | SiS_Pr->SiS_IF_DEF_DSTN = enable ? 1 : 0; |
| 1223 | } |
| 1224 | |
| 1225 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1226 | SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | { |
| 1228 | SiS_Pr->SiS_IF_DEF_FSTN = enable ? 1 : 0; |
| 1229 | } |
| 1230 | |
| 1231 | /*********************************************/ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1232 | /* HELPER: Get modeflag */ |
| 1233 | /*********************************************/ |
| 1234 | |
| 1235 | unsigned short |
| 1236 | SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 1237 | unsigned short ModeIdIndex) |
| 1238 | { |
| 1239 | if(SiS_Pr->UseCustomMode) { |
| 1240 | return SiS_Pr->CModeFlag; |
| 1241 | } else if(ModeNo <= 0x13) { |
| 1242 | return SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1243 | } else { |
| 1244 | return SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1245 | } |
| 1246 | } |
| 1247 | |
| 1248 | /*********************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | /* HELPER: Determine ROM usage */ |
| 1250 | /*********************************************/ |
| 1251 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1252 | bool |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1253 | SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1254 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1255 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; |
| 1256 | unsigned short romversoffs, romvmaj = 1, romvmin = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1258 | if(SiS_Pr->ChipType >= XGI_20) { |
| 1259 | /* XGI ROMs don't qualify */ |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1260 | return false; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1261 | } else if(SiS_Pr->ChipType >= SIS_761) { |
| 1262 | /* I very much assume 761, 340 and newer will use new layout */ |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1263 | return true; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1264 | } else if(SiS_Pr->ChipType >= SIS_661) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | if((ROMAddr[0x1a] == 'N') && |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1266 | (ROMAddr[0x1b] == 'e') && |
| 1267 | (ROMAddr[0x1c] == 'w') && |
| 1268 | (ROMAddr[0x1d] == 'V')) { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1269 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | } |
| 1271 | romversoffs = ROMAddr[0x16] | (ROMAddr[0x17] << 8); |
| 1272 | if(romversoffs) { |
| 1273 | if((ROMAddr[romversoffs+1] == '.') || (ROMAddr[romversoffs+4] == '.')) { |
| 1274 | romvmaj = ROMAddr[romversoffs] - '0'; |
| 1275 | romvmin = ((ROMAddr[romversoffs+2] -'0') * 10) + (ROMAddr[romversoffs+3] - '0'); |
| 1276 | } |
| 1277 | } |
| 1278 | if((romvmaj != 0) || (romvmin >= 92)) { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1279 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | } |
| 1281 | } else if(IS_SIS650740) { |
| 1282 | if((ROMAddr[0x1a] == 'N') && |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1283 | (ROMAddr[0x1b] == 'e') && |
| 1284 | (ROMAddr[0x1c] == 'w') && |
| 1285 | (ROMAddr[0x1d] == 'V')) { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1286 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | } |
| 1288 | } |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1289 | return false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1290 | } |
| 1291 | |
| 1292 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1293 | SiSDetermineROMUsage(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1294 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1295 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; |
| 1296 | unsigned short romptr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1298 | SiS_Pr->SiS_UseROM = false; |
| 1299 | SiS_Pr->SiS_ROMNew = false; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1300 | SiS_Pr->SiS_PWDOffset = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1302 | if(SiS_Pr->ChipType >= XGI_20) return; |
| 1303 | |
| 1304 | if((ROMAddr) && (SiS_Pr->UseROM)) { |
| 1305 | if(SiS_Pr->ChipType == SIS_300) { |
| 1306 | /* 300: We check if the code starts below 0x220 by |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1307 | * checking the jmp instruction at the beginning |
| 1308 | * of the BIOS image. |
| 1309 | */ |
| 1310 | if((ROMAddr[3] == 0xe9) && ((ROMAddr[5] << 8) | ROMAddr[4]) > 0x21a) |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1311 | SiS_Pr->SiS_UseROM = true; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1312 | } else if(SiS_Pr->ChipType < SIS_315H) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | /* Sony's VAIO BIOS 1.09 follows the standard, so perhaps |
| 1314 | * the others do as well |
| 1315 | */ |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1316 | SiS_Pr->SiS_UseROM = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1317 | } else { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1318 | /* 315/330 series stick to the standard(s) */ |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1319 | SiS_Pr->SiS_UseROM = true; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1320 | if((SiS_Pr->SiS_ROMNew = SiSDetermineROMLayout661(SiS_Pr))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1321 | SiS_Pr->SiS_EMIOffset = 14; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1322 | SiS_Pr->SiS_PWDOffset = 17; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1323 | SiS_Pr->SiS661LCD2TableSize = 36; |
| 1324 | /* Find out about LCD data table entry size */ |
| 1325 | if((romptr = SISGETROMW(0x0102))) { |
| 1326 | if(ROMAddr[romptr + (32 * 16)] == 0xff) |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1327 | SiS_Pr->SiS661LCD2TableSize = 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1328 | else if(ROMAddr[romptr + (34 * 16)] == 0xff) |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1329 | SiS_Pr->SiS661LCD2TableSize = 34; |
| 1330 | else if(ROMAddr[romptr + (36 * 16)] == 0xff) /* 0.94, 2.05.00+ */ |
| 1331 | SiS_Pr->SiS661LCD2TableSize = 36; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1332 | else if( (ROMAddr[romptr + (38 * 16)] == 0xff) || /* 2.00.00 - 2.02.00 */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1333 | (ROMAddr[0x6F] & 0x01) ) { /* 2.03.00 - <2.05.00 */ |
| 1334 | SiS_Pr->SiS661LCD2TableSize = 38; /* UMC data layout abandoned at 2.05.00 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1335 | SiS_Pr->SiS_EMIOffset = 16; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1336 | SiS_Pr->SiS_PWDOffset = 19; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1337 | } |
| 1338 | } |
| 1339 | } |
| 1340 | } |
| 1341 | } |
| 1342 | } |
| 1343 | |
| 1344 | /*********************************************/ |
| 1345 | /* HELPER: SET SEGMENT REGISTERS */ |
| 1346 | /*********************************************/ |
| 1347 | |
| 1348 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1349 | SiS_SetSegRegLower(struct SiS_Private *SiS_Pr, unsigned short value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1351 | unsigned short temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | |
| 1353 | value &= 0x00ff; |
| 1354 | temp = SiS_GetRegByte(SiS_Pr->SiS_P3cb) & 0xf0; |
| 1355 | temp |= (value >> 4); |
| 1356 | SiS_SetRegByte(SiS_Pr->SiS_P3cb, temp); |
| 1357 | temp = SiS_GetRegByte(SiS_Pr->SiS_P3cd) & 0xf0; |
| 1358 | temp |= (value & 0x0f); |
| 1359 | SiS_SetRegByte(SiS_Pr->SiS_P3cd, temp); |
| 1360 | } |
| 1361 | |
| 1362 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1363 | SiS_SetSegRegUpper(struct SiS_Private *SiS_Pr, unsigned short value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1365 | unsigned short temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1366 | |
| 1367 | value &= 0x00ff; |
| 1368 | temp = SiS_GetRegByte(SiS_Pr->SiS_P3cb) & 0x0f; |
| 1369 | temp |= (value & 0xf0); |
| 1370 | SiS_SetRegByte(SiS_Pr->SiS_P3cb, temp); |
| 1371 | temp = SiS_GetRegByte(SiS_Pr->SiS_P3cd) & 0x0f; |
| 1372 | temp |= (value << 4); |
| 1373 | SiS_SetRegByte(SiS_Pr->SiS_P3cd, temp); |
| 1374 | } |
| 1375 | |
| 1376 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1377 | SiS_SetSegmentReg(struct SiS_Private *SiS_Pr, unsigned short value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1378 | { |
| 1379 | SiS_SetSegRegLower(SiS_Pr, value); |
| 1380 | SiS_SetSegRegUpper(SiS_Pr, value); |
| 1381 | } |
| 1382 | |
| 1383 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1384 | SiS_ResetSegmentReg(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | { |
| 1386 | SiS_SetSegmentReg(SiS_Pr, 0); |
| 1387 | } |
| 1388 | |
| 1389 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1390 | SiS_SetSegmentRegOver(struct SiS_Private *SiS_Pr, unsigned short value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1392 | unsigned short temp = value >> 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | |
| 1394 | temp &= 0x07; |
| 1395 | temp |= (temp << 4); |
| 1396 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x1d,temp); |
| 1397 | SiS_SetSegmentReg(SiS_Pr, value); |
| 1398 | } |
| 1399 | |
| 1400 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1401 | SiS_ResetSegmentRegOver(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | { |
| 1403 | SiS_SetSegmentRegOver(SiS_Pr, 0); |
| 1404 | } |
| 1405 | |
| 1406 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1407 | SiS_ResetSegmentRegisters(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1409 | if((IS_SIS65x) || (SiS_Pr->ChipType >= SIS_661)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1410 | SiS_ResetSegmentReg(SiS_Pr); |
| 1411 | SiS_ResetSegmentRegOver(SiS_Pr); |
| 1412 | } |
| 1413 | } |
| 1414 | |
| 1415 | /*********************************************/ |
| 1416 | /* HELPER: GetVBType */ |
| 1417 | /*********************************************/ |
| 1418 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1419 | static |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1420 | void |
| 1421 | SiS_GetVBType(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1422 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1423 | unsigned short flag = 0, rev = 0, nolcd = 0; |
| 1424 | unsigned short p4_0f, p4_25, p4_27; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1425 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1426 | SiS_Pr->SiS_VBType = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1427 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1428 | if((SiS_Pr->SiS_IF_DEF_LVDS) || (SiS_Pr->SiS_IF_DEF_CONEX)) |
| 1429 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1431 | if(SiS_Pr->ChipType == XGI_20) |
| 1432 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1434 | flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1436 | if(flag > 3) |
| 1437 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1439 | rev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); |
| 1440 | |
| 1441 | if(flag >= 2) { |
| 1442 | SiS_Pr->SiS_VBType = VB_SIS302B; |
| 1443 | } else if(flag == 1) { |
| 1444 | if(rev >= 0xC0) { |
| 1445 | SiS_Pr->SiS_VBType = VB_SIS301C; |
| 1446 | } else if(rev >= 0xB0) { |
| 1447 | SiS_Pr->SiS_VBType = VB_SIS301B; |
| 1448 | /* Check if 30xB DH version (no LCD support, use Panel Link instead) */ |
| 1449 | nolcd = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x23); |
| 1450 | if(!(nolcd & 0x02)) SiS_Pr->SiS_VBType |= VB_NoLCD; |
| 1451 | } else { |
| 1452 | SiS_Pr->SiS_VBType = VB_SIS301; |
| 1453 | } |
| 1454 | } |
| 1455 | if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS301C | VB_SIS302B)) { |
| 1456 | if(rev >= 0xE0) { |
| 1457 | flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x39); |
| 1458 | if(flag == 0xff) SiS_Pr->SiS_VBType = VB_SIS302LV; |
| 1459 | else SiS_Pr->SiS_VBType = VB_SIS301C; /* VB_SIS302ELV; */ |
| 1460 | } else if(rev >= 0xD0) { |
| 1461 | SiS_Pr->SiS_VBType = VB_SIS301LV; |
| 1462 | } |
| 1463 | } |
| 1464 | if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { |
| 1465 | p4_0f = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x0f); |
| 1466 | p4_25 = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x25); |
| 1467 | p4_27 = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x27); |
| 1468 | SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0x7f); |
| 1469 | SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x25,0x08); |
| 1470 | SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,0xfd); |
| 1471 | if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x08) { |
| 1472 | SiS_Pr->SiS_VBType |= VB_UMC; |
| 1473 | } |
| 1474 | SiS_SetReg(SiS_Pr->SiS_Part4Port,0x27,p4_27); |
| 1475 | SiS_SetReg(SiS_Pr->SiS_Part4Port,0x25,p4_25); |
| 1476 | SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0f,p4_0f); |
| 1477 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1478 | } |
| 1479 | |
| 1480 | /*********************************************/ |
| 1481 | /* HELPER: Check RAM size */ |
| 1482 | /*********************************************/ |
| 1483 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1484 | static bool |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1485 | SiS_CheckMemorySize(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 1486 | unsigned short ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1488 | unsigned short AdapterMemSize = SiS_Pr->VideoMemorySize / (1024*1024); |
| 1489 | unsigned short modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); |
| 1490 | unsigned short memorysize = ((modeflag & MemoryInfoFlag) >> MemorySizeShift) + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1492 | if(!AdapterMemSize) return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1494 | if(AdapterMemSize < memorysize) return false; |
| 1495 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1496 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | |
| 1498 | /*********************************************/ |
| 1499 | /* HELPER: Get DRAM type */ |
| 1500 | /*********************************************/ |
| 1501 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 1502 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1503 | static unsigned char |
| 1504 | SiS_Get310DRAMType(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1506 | unsigned char data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | |
| 1508 | if((*SiS_Pr->pSiS_SoftSetting) & SoftDRAMType) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1509 | data = (*SiS_Pr->pSiS_SoftSetting) & 0x03; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | } else { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1511 | if(SiS_Pr->ChipType >= XGI_20) { |
| 1512 | /* Do I need this? SR17 seems to be zero anyway... */ |
| 1513 | data = 0; |
| 1514 | } else if(SiS_Pr->ChipType >= SIS_340) { |
| 1515 | /* TODO */ |
| 1516 | data = 0; |
| 1517 | } if(SiS_Pr->ChipType >= SIS_661) { |
| 1518 | if(SiS_Pr->SiS_ROMNew) { |
| 1519 | data = ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0xc0) >> 6); |
| 1520 | } else { |
| 1521 | data = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x07; |
| 1522 | } |
| 1523 | } else if(IS_SIS550650740) { |
| 1524 | data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x07; |
| 1525 | } else { /* 315, 330 */ |
| 1526 | data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3a) & 0x03; |
| 1527 | if(SiS_Pr->ChipType == SIS_330) { |
| 1528 | if(data > 1) { |
| 1529 | switch(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0x30) { |
| 1530 | case 0x00: data = 1; break; |
| 1531 | case 0x10: data = 3; break; |
| 1532 | case 0x20: data = 3; break; |
| 1533 | case 0x30: data = 2; break; |
| 1534 | } |
| 1535 | } else { |
| 1536 | data = 0; |
| 1537 | } |
| 1538 | } |
| 1539 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1540 | } |
| 1541 | |
| 1542 | return data; |
| 1543 | } |
| 1544 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1545 | static unsigned short |
| 1546 | SiS_GetMCLK(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1548 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; |
| 1549 | unsigned short index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1551 | index = SiS_Get310DRAMType(SiS_Pr); |
| 1552 | if(SiS_Pr->ChipType >= SIS_661) { |
| 1553 | if(SiS_Pr->SiS_ROMNew) { |
| 1554 | return((unsigned short)(SISGETROMW((0x90 + (index * 5) + 3)))); |
| 1555 | } |
| 1556 | return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); |
| 1557 | } else if(index >= 4) { |
| 1558 | return(SiS_Pr->SiS_MCLKData_1[index - 4].CLOCK); |
| 1559 | } else { |
| 1560 | return(SiS_Pr->SiS_MCLKData_0[index].CLOCK); |
| 1561 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1562 | } |
| 1563 | #endif |
| 1564 | |
| 1565 | /*********************************************/ |
| 1566 | /* HELPER: ClearBuffer */ |
| 1567 | /*********************************************/ |
| 1568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1570 | SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1572 | unsigned char SISIOMEMTYPE *memaddr = SiS_Pr->VideoMemoryAddress; |
| 1573 | unsigned int memsize = SiS_Pr->VideoMemorySize; |
| 1574 | unsigned short SISIOMEMTYPE *pBuffer; |
| 1575 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1576 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1577 | if(!memaddr || !memsize) return; |
| 1578 | |
| 1579 | if(SiS_Pr->SiS_ModeType >= ModeEGA) { |
| 1580 | if(ModeNo > 0x13) { |
Aaro Koskinen | ec49ec3 | 2010-11-19 21:58:49 +0000 | [diff] [blame^] | 1581 | memset_io(memaddr, 0, memsize); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1582 | } else { |
| 1583 | pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; |
| 1584 | for(i = 0; i < 0x4000; i++) writew(0x0000, &pBuffer[i]); |
| 1585 | } |
| 1586 | } else if(SiS_Pr->SiS_ModeType < ModeCGA) { |
| 1587 | pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; |
| 1588 | for(i = 0; i < 0x4000; i++) writew(0x0720, &pBuffer[i]); |
| 1589 | } else { |
Aaro Koskinen | ec49ec3 | 2010-11-19 21:58:49 +0000 | [diff] [blame^] | 1590 | memset_io(memaddr, 0, 0x8000); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1591 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1593 | |
| 1594 | /*********************************************/ |
| 1595 | /* HELPER: SearchModeID */ |
| 1596 | /*********************************************/ |
| 1597 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1598 | bool |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1599 | SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo, |
| 1600 | unsigned short *ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1602 | unsigned char VGAINFO = SiS_Pr->SiS_VGAINFO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1604 | if((*ModeNo) <= 0x13) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1605 | |
| 1606 | if((*ModeNo) <= 0x05) (*ModeNo) |= 0x01; |
| 1607 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1608 | for((*ModeIdIndex) = 0; ;(*ModeIdIndex)++) { |
| 1609 | if(SiS_Pr->SiS_SModeIDTable[(*ModeIdIndex)].St_ModeID == (*ModeNo)) break; |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1610 | if(SiS_Pr->SiS_SModeIDTable[(*ModeIdIndex)].St_ModeID == 0xFF) return false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | } |
| 1612 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1613 | if((*ModeNo) == 0x07) { |
| 1614 | if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ |
| 1615 | /* else 350 lines */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1616 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1617 | if((*ModeNo) <= 0x03) { |
| 1618 | if(!(VGAINFO & 0x80)) (*ModeIdIndex)++; |
| 1619 | if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */ |
| 1620 | /* else 350 lines */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | } |
| 1622 | /* else 200 lines */ |
| 1623 | |
| 1624 | } else { |
| 1625 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1626 | for((*ModeIdIndex) = 0; ;(*ModeIdIndex)++) { |
| 1627 | if(SiS_Pr->SiS_EModeIDTable[(*ModeIdIndex)].Ext_ModeID == (*ModeNo)) break; |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1628 | if(SiS_Pr->SiS_EModeIDTable[(*ModeIdIndex)].Ext_ModeID == 0xFF) return false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | } |
| 1630 | |
| 1631 | } |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1632 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | } |
| 1634 | |
| 1635 | /*********************************************/ |
| 1636 | /* HELPER: GetModePtr */ |
| 1637 | /*********************************************/ |
| 1638 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1639 | unsigned short |
| 1640 | SiS_GetModePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1642 | unsigned short index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1643 | |
| 1644 | if(ModeNo <= 0x13) { |
| 1645 | index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_StTableIndex; |
| 1646 | } else { |
| 1647 | if(SiS_Pr->SiS_ModeType <= ModeEGA) index = 0x1B; |
| 1648 | else index = 0x0F; |
| 1649 | } |
| 1650 | return index; |
| 1651 | } |
| 1652 | |
| 1653 | /*********************************************/ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1654 | /* HELPERS: Get some indices */ |
| 1655 | /*********************************************/ |
| 1656 | |
| 1657 | unsigned short |
| 1658 | SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide) |
| 1659 | { |
| 1660 | if(SiS_Pr->SiS_RefIndex[Index].Ext_InfoFlag & HaveWideTiming) { |
| 1661 | if(UseWide == 1) { |
| 1662 | return SiS_Pr->SiS_RefIndex[Index].Ext_CRTVCLK_WIDE; |
| 1663 | } else { |
| 1664 | return SiS_Pr->SiS_RefIndex[Index].Ext_CRTVCLK_NORM; |
| 1665 | } |
| 1666 | } else { |
| 1667 | return SiS_Pr->SiS_RefIndex[Index].Ext_CRTVCLK; |
| 1668 | } |
| 1669 | } |
| 1670 | |
| 1671 | unsigned short |
| 1672 | SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide) |
| 1673 | { |
| 1674 | if(SiS_Pr->SiS_RefIndex[Index].Ext_InfoFlag & HaveWideTiming) { |
| 1675 | if(UseWide == 1) { |
| 1676 | return SiS_Pr->SiS_RefIndex[Index].Ext_CRT1CRTC_WIDE; |
| 1677 | } else { |
| 1678 | return SiS_Pr->SiS_RefIndex[Index].Ext_CRT1CRTC_NORM; |
| 1679 | } |
| 1680 | } else { |
| 1681 | return SiS_Pr->SiS_RefIndex[Index].Ext_CRT1CRTC; |
| 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | /*********************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1686 | /* HELPER: LowModeTests */ |
| 1687 | /*********************************************/ |
| 1688 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1689 | static bool |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1690 | SiS_DoLowModeTest(struct SiS_Private *SiS_Pr, unsigned short ModeNo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1691 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1692 | unsigned short temp, temp1, temp2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1694 | if((ModeNo != 0x03) && (ModeNo != 0x10) && (ModeNo != 0x12)) |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1695 | return true; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1696 | temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x11); |
| 1697 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x11,0x80); |
| 1698 | temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); |
| 1699 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,0x55); |
| 1700 | temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00); |
| 1701 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,temp1); |
| 1702 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x11,temp); |
| 1703 | if((SiS_Pr->ChipType >= SIS_315H) || |
| 1704 | (SiS_Pr->ChipType == SIS_300)) { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1705 | if(temp2 == 0x55) return false; |
| 1706 | else return true; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1707 | } else { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1708 | if(temp2 != 0x55) return true; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1709 | else { |
| 1710 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 1711 | return false; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1712 | } |
| 1713 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1714 | } |
| 1715 | |
| 1716 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1717 | SiS_SetLowModeTest(struct SiS_Private *SiS_Pr, unsigned short ModeNo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1718 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1719 | if(SiS_DoLowModeTest(SiS_Pr, ModeNo)) { |
| 1720 | SiS_Pr->SiS_SetFlag |= LowModeTests; |
| 1721 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1722 | } |
| 1723 | |
| 1724 | /*********************************************/ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1725 | /* HELPER: OPEN/CLOSE CRT1 CRTC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | /*********************************************/ |
| 1727 | |
| 1728 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1729 | SiS_OpenCRTC(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1730 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1731 | if(IS_SIS650) { |
| 1732 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); |
| 1733 | if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20); |
| 1734 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); |
| 1735 | } else if(IS_SIS661741660760) { |
| 1736 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x61,0xf7); |
| 1737 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f); |
| 1738 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7); |
| 1739 | if(!SiS_Pr->SiS_ROMNew) { |
| 1740 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef); |
| 1741 | } |
| 1742 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1743 | } |
| 1744 | |
| 1745 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1746 | SiS_CloseCRTC(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1747 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1748 | #if 0 /* This locks some CRTC registers. We don't want that. */ |
| 1749 | unsigned short temp1 = 0, temp2 = 0; |
| 1750 | |
| 1751 | if(IS_SIS661741660760) { |
| 1752 | if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { |
| 1753 | temp1 = 0xa0; temp2 = 0x08; |
| 1754 | } |
| 1755 | SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x51,0x1f,temp1); |
| 1756 | SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x56,0xe7,temp2); |
| 1757 | } |
| 1758 | #endif |
| 1759 | } |
| 1760 | |
| 1761 | static void |
| 1762 | SiS_HandleCRT1(struct SiS_Private *SiS_Pr) |
| 1763 | { |
| 1764 | /* Enable CRT1 gating */ |
| 1765 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0xbf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | #if 0 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1767 | if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x01)) { |
| 1768 | if((SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x0a) || |
| 1769 | (SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x01)) { |
| 1770 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0x40); |
| 1771 | } |
| 1772 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | #endif |
| 1774 | } |
| 1775 | |
| 1776 | /*********************************************/ |
| 1777 | /* HELPER: GetColorDepth */ |
| 1778 | /*********************************************/ |
| 1779 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1780 | unsigned short |
| 1781 | SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 1782 | unsigned short ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1783 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1784 | static const unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 1785 | unsigned short modeflag; |
| 1786 | short index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1788 | /* Do NOT check UseCustomMode, will skrew up FIFO */ |
| 1789 | if(ModeNo == 0xfe) { |
| 1790 | modeflag = SiS_Pr->CModeFlag; |
| 1791 | } else if(ModeNo <= 0x13) { |
| 1792 | modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1793 | } else { |
| 1794 | modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1795 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1796 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1797 | index = (modeflag & ModeTypeMask) - ModeEGA; |
| 1798 | if(index < 0) index = 0; |
| 1799 | return ColorDepth[index]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1800 | } |
| 1801 | |
| 1802 | /*********************************************/ |
| 1803 | /* HELPER: GetOffset */ |
| 1804 | /*********************************************/ |
| 1805 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1806 | unsigned short |
| 1807 | SiS_GetOffset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 1808 | unsigned short ModeIdIndex, unsigned short RRTI) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1809 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1810 | unsigned short xres, temp, colordepth, infoflag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1811 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1812 | if(SiS_Pr->UseCustomMode) { |
| 1813 | infoflag = SiS_Pr->CInfoFlag; |
| 1814 | xres = SiS_Pr->CHDisplay; |
| 1815 | } else { |
| 1816 | infoflag = SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag; |
| 1817 | xres = SiS_Pr->SiS_RefIndex[RRTI].XRes; |
| 1818 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1819 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1820 | colordepth = SiS_GetColorDepth(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1821 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1822 | temp = xres / 16; |
| 1823 | if(infoflag & InterlaceMode) temp <<= 1; |
| 1824 | temp *= colordepth; |
| 1825 | if(xres % 16) temp += (colordepth >> 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1826 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1827 | return temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1828 | } |
| 1829 | |
| 1830 | /*********************************************/ |
| 1831 | /* SEQ */ |
| 1832 | /*********************************************/ |
| 1833 | |
| 1834 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1835 | SiS_SetSeqRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1837 | unsigned char SRdata; |
| 1838 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1839 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1840 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1841 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1842 | /* or "display off" */ |
| 1843 | SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0] | 0x20; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1844 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1845 | /* determine whether to force x8 dotclock */ |
| 1846 | if((SiS_Pr->SiS_VBType & VB_SISVB) || (SiS_Pr->SiS_IF_DEF_LVDS)) { |
| 1847 | |
| 1848 | if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
| 1849 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) SRdata |= 0x01; |
| 1850 | } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) SRdata |= 0x01; |
| 1851 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | } |
| 1853 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1854 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x01,SRdata); |
| 1855 | |
| 1856 | for(i = 2; i <= 4; i++) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1857 | SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i - 1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1858 | SiS_SetReg(SiS_Pr->SiS_P3c4,i,SRdata); |
| 1859 | } |
| 1860 | } |
| 1861 | |
| 1862 | /*********************************************/ |
| 1863 | /* MISC */ |
| 1864 | /*********************************************/ |
| 1865 | |
| 1866 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1867 | SiS_SetMiscRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1868 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1869 | unsigned char Miscdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1870 | |
| 1871 | Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC; |
| 1872 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1873 | if(SiS_Pr->ChipType < SIS_661) { |
| 1874 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { |
| 1875 | if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { |
| 1876 | Miscdata |= 0x0C; |
| 1877 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | } |
| 1879 | } |
| 1880 | |
| 1881 | SiS_SetRegByte(SiS_Pr->SiS_P3c2,Miscdata); |
| 1882 | } |
| 1883 | |
| 1884 | /*********************************************/ |
| 1885 | /* CRTC */ |
| 1886 | /*********************************************/ |
| 1887 | |
| 1888 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1889 | SiS_SetCRTCRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1890 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1891 | unsigned char CRTCdata; |
| 1892 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1893 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1894 | /* Unlock CRTC */ |
| 1895 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1897 | for(i = 0; i <= 0x18; i++) { |
| 1898 | CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; |
| 1899 | SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); |
| 1900 | } |
| 1901 | |
| 1902 | if(SiS_Pr->ChipType >= SIS_661) { |
| 1903 | SiS_OpenCRTC(SiS_Pr); |
| 1904 | for(i = 0x13; i <= 0x14; i++) { |
| 1905 | CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; |
| 1906 | SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); |
| 1907 | } |
| 1908 | } else if( ( (SiS_Pr->ChipType == SIS_630) || |
| 1909 | (SiS_Pr->ChipType == SIS_730) ) && |
| 1910 | (SiS_Pr->ChipRevision >= 0x30) ) { |
| 1911 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { |
| 1912 | if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
| 1913 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x18,0xFE); |
| 1914 | } |
| 1915 | } |
| 1916 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1917 | } |
| 1918 | |
| 1919 | /*********************************************/ |
| 1920 | /* ATT */ |
| 1921 | /*********************************************/ |
| 1922 | |
| 1923 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1924 | SiS_SetATTRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1925 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1926 | unsigned char ARdata; |
| 1927 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1928 | |
| 1929 | for(i = 0; i <= 0x13; i++) { |
| 1930 | ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[i]; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1931 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1932 | if(i == 0x13) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1933 | /* Pixel shift. If screen on LCD or TV is shifted left or right, |
| 1934 | * this might be the cause. |
| 1935 | */ |
| 1936 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { |
| 1937 | if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ARdata = 0; |
| 1938 | } |
| 1939 | if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { |
| 1940 | if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { |
| 1941 | if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { |
| 1942 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata = 0; |
| 1943 | } |
| 1944 | } |
| 1945 | } |
| 1946 | if(SiS_Pr->ChipType >= SIS_661) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1947 | if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1948 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1949 | } |
| 1950 | } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1951 | if(SiS_Pr->ChipType >= SIS_315H) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1952 | if(IS_SIS550650740660) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1953 | /* 315, 330 don't do this */ |
| 1954 | if(SiS_Pr->SiS_VBType & VB_SIS30xB) { |
| 1955 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata = 0; |
| 1956 | } else { |
| 1957 | ARdata = 0; |
| 1958 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1959 | } |
| 1960 | } else { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1961 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1962 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1963 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1964 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1965 | SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ |
| 1966 | SiS_SetRegByte(SiS_Pr->SiS_P3c0,i); /* set index */ |
| 1967 | SiS_SetRegByte(SiS_Pr->SiS_P3c0,ARdata); /* set data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1968 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1969 | |
| 1970 | SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */ |
| 1971 | SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x14); /* set index */ |
| 1972 | SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x00); /* set data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1973 | |
| 1974 | SiS_GetRegByte(SiS_Pr->SiS_P3da); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1975 | SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | SiS_GetRegByte(SiS_Pr->SiS_P3da); |
| 1977 | } |
| 1978 | |
| 1979 | /*********************************************/ |
| 1980 | /* GRC */ |
| 1981 | /*********************************************/ |
| 1982 | |
| 1983 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1984 | SiS_SetGRCRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1985 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 1986 | unsigned char GRdata; |
| 1987 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1988 | |
| 1989 | for(i = 0; i <= 0x08; i++) { |
| 1990 | GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; |
| 1991 | SiS_SetReg(SiS_Pr->SiS_P3ce,i,GRdata); |
| 1992 | } |
| 1993 | |
| 1994 | if(SiS_Pr->SiS_ModeType > ModeVGA) { |
| 1995 | /* 256 color disable */ |
| 1996 | SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF); |
| 1997 | } |
| 1998 | } |
| 1999 | |
| 2000 | /*********************************************/ |
| 2001 | /* CLEAR EXTENDED REGISTERS */ |
| 2002 | /*********************************************/ |
| 2003 | |
| 2004 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2005 | SiS_ClearExt1Regs(struct SiS_Private *SiS_Pr, unsigned short ModeNo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2006 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2007 | unsigned short i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2009 | for(i = 0x0A; i <= 0x0E; i++) { |
| 2010 | SiS_SetReg(SiS_Pr->SiS_P3c4,i,0x00); |
| 2011 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2012 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2013 | if(SiS_Pr->ChipType >= SIS_315H) { |
| 2014 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE); |
| 2015 | if(ModeNo <= 0x13) { |
| 2016 | if(ModeNo == 0x06 || ModeNo >= 0x0e) { |
| 2017 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x0e,0x20); |
| 2018 | } |
| 2019 | } |
| 2020 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | } |
| 2022 | |
| 2023 | /*********************************************/ |
| 2024 | /* RESET VCLK */ |
| 2025 | /*********************************************/ |
| 2026 | |
| 2027 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2028 | SiS_ResetCRT1VCLK(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2029 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2030 | if(SiS_Pr->ChipType >= SIS_315H) { |
| 2031 | if(SiS_Pr->ChipType < SIS_661) { |
| 2032 | if(SiS_Pr->SiS_IF_DEF_LVDS == 0) return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2033 | } |
| 2034 | } else { |
| 2035 | if((SiS_Pr->SiS_IF_DEF_LVDS == 0) && |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2036 | (!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) ) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2037 | return; |
| 2038 | } |
| 2039 | } |
| 2040 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2041 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x20); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[1].SR2B); |
| 2043 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[1].SR2C); |
| 2044 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2045 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2046 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[0].SR2B); |
| 2047 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[0].SR2C); |
| 2048 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); |
| 2049 | } |
| 2050 | |
| 2051 | /*********************************************/ |
| 2052 | /* SYNC */ |
| 2053 | /*********************************************/ |
| 2054 | |
| 2055 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2056 | SiS_SetCRT1Sync(struct SiS_Private *SiS_Pr, unsigned short RRTI) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2057 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2058 | unsigned short sync; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2059 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2060 | if(SiS_Pr->UseCustomMode) { |
| 2061 | sync = SiS_Pr->CInfoFlag >> 8; |
| 2062 | } else { |
| 2063 | sync = SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag >> 8; |
| 2064 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2066 | sync &= 0xC0; |
| 2067 | sync |= 0x2f; |
| 2068 | SiS_SetRegByte(SiS_Pr->SiS_P3c2,sync); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | } |
| 2070 | |
| 2071 | /*********************************************/ |
| 2072 | /* CRTC/2 */ |
| 2073 | /*********************************************/ |
| 2074 | |
| 2075 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2076 | SiS_SetCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 2077 | unsigned short ModeIdIndex, unsigned short RRTI) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2079 | unsigned short temp, i, j, modeflag; |
| 2080 | unsigned char *crt1data = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2082 | modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2084 | if(SiS_Pr->UseCustomMode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2086 | crt1data = &SiS_Pr->CCRT1CRTC[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2087 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2088 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2090 | temp = SiS_GetRefCRT1CRTC(SiS_Pr, RRTI, SiS_Pr->SiS_UseWide); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2092 | /* Alternate for 1600x1200 LCDA */ |
| 2093 | if((temp == 0x20) && (SiS_Pr->Alternate1600x1200)) temp = 0x57; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2095 | crt1data = (unsigned char *)&SiS_Pr->SiS_CRT1Table[temp].CR[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2097 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2098 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2099 | /* unlock cr0-7 */ |
| 2100 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2101 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2102 | for(i = 0, j = 0; i <= 7; i++, j++) { |
| 2103 | SiS_SetReg(SiS_Pr->SiS_P3d4,j,crt1data[i]); |
| 2104 | } |
| 2105 | for(j = 0x10; i <= 10; i++, j++) { |
| 2106 | SiS_SetReg(SiS_Pr->SiS_P3d4,j,crt1data[i]); |
| 2107 | } |
| 2108 | for(j = 0x15; i <= 12; i++, j++) { |
| 2109 | SiS_SetReg(SiS_Pr->SiS_P3d4,j,crt1data[i]); |
| 2110 | } |
| 2111 | for(j = 0x0A; i <= 15; i++, j++) { |
| 2112 | SiS_SetReg(SiS_Pr->SiS_P3c4,j,crt1data[i]); |
| 2113 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2115 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,crt1data[16] & 0xE0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2116 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2117 | temp = (crt1data[16] & 0x01) << 5; |
| 2118 | if(modeflag & DoubleScanMode) temp |= 0x80; |
| 2119 | SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2120 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2121 | if(SiS_Pr->SiS_ModeType > ModeVGA) { |
| 2122 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); |
| 2123 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2125 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2126 | if(SiS_Pr->ChipType == XGI_20) { |
| 2127 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x04,crt1data[4] - 1); |
| 2128 | if(!(temp = crt1data[5] & 0x1f)) { |
| 2129 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0c,0xfb); |
| 2130 | } |
| 2131 | SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x05,0xe0,((temp - 1) & 0x1f)); |
| 2132 | temp = (crt1data[16] >> 5) + 3; |
| 2133 | if(temp > 7) temp -= 7; |
| 2134 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0e,0x1f,(temp << 5)); |
| 2135 | } |
| 2136 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2137 | } |
| 2138 | |
| 2139 | /*********************************************/ |
| 2140 | /* OFFSET & PITCH */ |
| 2141 | /*********************************************/ |
| 2142 | /* (partly overruled by SetPitch() in XF86) */ |
| 2143 | /*********************************************/ |
| 2144 | |
| 2145 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2146 | SiS_SetCRT1Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 2147 | unsigned short ModeIdIndex, unsigned short RRTI) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2148 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2149 | unsigned short temp, DisplayUnit, infoflag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2150 | |
| 2151 | if(SiS_Pr->UseCustomMode) { |
| 2152 | infoflag = SiS_Pr->CInfoFlag; |
| 2153 | } else { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2154 | infoflag = SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2155 | } |
| 2156 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2157 | DisplayUnit = SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, RRTI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | |
| 2159 | temp = (DisplayUnit >> 8) & 0x0f; |
| 2160 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,temp); |
| 2161 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2162 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,DisplayUnit & 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | |
| 2164 | if(infoflag & InterlaceMode) DisplayUnit >>= 1; |
| 2165 | |
| 2166 | DisplayUnit <<= 5; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2167 | temp = (DisplayUnit >> 8) + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2168 | if(DisplayUnit & 0xff) temp++; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2169 | if(SiS_Pr->ChipType == XGI_20) { |
| 2170 | if(ModeNo == 0x4a || ModeNo == 0x49) temp--; |
| 2171 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x10,temp); |
| 2173 | } |
| 2174 | |
| 2175 | /*********************************************/ |
| 2176 | /* VCLK */ |
| 2177 | /*********************************************/ |
| 2178 | |
| 2179 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2180 | SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 2181 | unsigned short ModeIdIndex, unsigned short RRTI) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2183 | unsigned short index = 0, clka, clkb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2185 | if(SiS_Pr->UseCustomMode) { |
| 2186 | clka = SiS_Pr->CSR2B; |
| 2187 | clkb = SiS_Pr->CSR2C; |
| 2188 | } else { |
| 2189 | index = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RRTI); |
| 2190 | if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && |
| 2191 | (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { |
| 2192 | /* Alternate for 1600x1200 LCDA */ |
| 2193 | if((index == 0x21) && (SiS_Pr->Alternate1600x1200)) index = 0x72; |
| 2194 | clka = SiS_Pr->SiS_VBVCLKData[index].Part4_A; |
| 2195 | clkb = SiS_Pr->SiS_VBVCLKData[index].Part4_B; |
| 2196 | } else { |
| 2197 | clka = SiS_Pr->SiS_VCLKData[index].SR2B; |
| 2198 | clkb = SiS_Pr->SiS_VCLKData[index].SR2C; |
| 2199 | } |
| 2200 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2201 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2202 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2203 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2204 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2b,clka); |
| 2205 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,clkb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2206 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2207 | if(SiS_Pr->ChipType >= SIS_315H) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2208 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2209 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); |
| 2210 | if(SiS_Pr->ChipType == XGI_20) { |
| 2211 | unsigned short mf = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); |
| 2212 | if(mf & HalfDCLK) { |
| 2213 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2b,SiS_GetReg(SiS_Pr->SiS_P3c4,0x2b)); |
| 2214 | clkb = SiS_GetReg(SiS_Pr->SiS_P3c4,0x2c); |
| 2215 | clkb = (((clkb & 0x1f) << 1) + 1) | (clkb & 0xe0); |
| 2216 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,clkb); |
| 2217 | } |
| 2218 | } |
| 2219 | #endif |
| 2220 | } else { |
| 2221 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80); |
| 2222 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2223 | } |
| 2224 | |
| 2225 | /*********************************************/ |
| 2226 | /* FIFO */ |
| 2227 | /*********************************************/ |
| 2228 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2229 | #ifdef CONFIG_FB_SIS_300 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2230 | void |
| 2231 | SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1, |
| 2232 | unsigned short *idx2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2233 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2234 | unsigned short temp1, temp2; |
| 2235 | static const unsigned char ThTiming[8] = { |
| 2236 | 1, 2, 2, 3, 0, 1, 1, 2 |
| 2237 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2239 | temp1 = temp2 = (SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x62) >> 1; |
| 2240 | (*idx2) = (unsigned short)(ThTiming[((temp2 >> 3) | temp1) & 0x07]); |
| 2241 | (*idx1) = (unsigned short)(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) >> 6) & 0x03; |
| 2242 | (*idx1) |= (unsigned short)(((SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) >> 4) & 0x0c)); |
| 2243 | (*idx1) <<= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2244 | } |
| 2245 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2246 | static unsigned short |
| 2247 | SiS_GetFIFOThresholdA300(unsigned short idx1, unsigned short idx2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2249 | static const unsigned char ThLowA[8 * 3] = { |
| 2250 | 61, 3,52, 5,68, 7,100,11, |
| 2251 | 43, 3,42, 5,54, 7, 78,11, |
| 2252 | 34, 3,37, 5,47, 7, 67,11 |
| 2253 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2255 | return (unsigned short)((ThLowA[idx1 + 1] * idx2) + ThLowA[idx1]); |
| 2256 | } |
| 2257 | |
| 2258 | unsigned short |
| 2259 | SiS_GetFIFOThresholdB300(unsigned short idx1, unsigned short idx2) |
| 2260 | { |
| 2261 | static const unsigned char ThLowB[8 * 3] = { |
| 2262 | 81, 4,72, 6,88, 8,120,12, |
| 2263 | 55, 4,54, 6,66, 8, 90,12, |
| 2264 | 42, 4,45, 6,55, 8, 75,12 |
| 2265 | }; |
| 2266 | |
| 2267 | return (unsigned short)((ThLowB[idx1 + 1] * idx2) + ThLowB[idx1]); |
| 2268 | } |
| 2269 | |
| 2270 | static unsigned short |
| 2271 | SiS_DoCalcDelay(struct SiS_Private *SiS_Pr, unsigned short MCLK, unsigned short VCLK, |
| 2272 | unsigned short colordepth, unsigned short key) |
| 2273 | { |
| 2274 | unsigned short idx1, idx2; |
| 2275 | unsigned int longtemp = VCLK * colordepth; |
| 2276 | |
| 2277 | SiS_GetFIFOThresholdIndex300(SiS_Pr, &idx1, &idx2); |
| 2278 | |
| 2279 | if(key == 0) { |
| 2280 | longtemp *= SiS_GetFIFOThresholdA300(idx1, idx2); |
| 2281 | } else { |
| 2282 | longtemp *= SiS_GetFIFOThresholdB300(idx1, idx2); |
| 2283 | } |
| 2284 | idx1 = longtemp % (MCLK * 16); |
| 2285 | longtemp /= (MCLK * 16); |
| 2286 | if(idx1) longtemp++; |
| 2287 | return (unsigned short)longtemp; |
| 2288 | } |
| 2289 | |
| 2290 | static unsigned short |
| 2291 | SiS_CalcDelay(struct SiS_Private *SiS_Pr, unsigned short VCLK, |
| 2292 | unsigned short colordepth, unsigned short MCLK) |
| 2293 | { |
| 2294 | unsigned short temp1, temp2; |
| 2295 | |
| 2296 | temp2 = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 0); |
| 2297 | temp1 = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 1); |
| 2298 | if(temp1 < 4) temp1 = 4; |
| 2299 | temp1 -= 4; |
| 2300 | if(temp2 < temp1) temp2 = temp1; |
| 2301 | return temp2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2302 | } |
| 2303 | |
| 2304 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2305 | SiS_SetCRT1FIFO_300(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 2306 | unsigned short RefreshRateTableIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2307 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2308 | unsigned short ThresholdLow = 0; |
| 2309 | unsigned short temp, index, VCLK, MCLK, colorth; |
| 2310 | static const unsigned short colortharray[6] = { 1, 1, 2, 2, 3, 4 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2312 | if(ModeNo > 0x13) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2313 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2314 | /* Get VCLK */ |
| 2315 | if(SiS_Pr->UseCustomMode) { |
| 2316 | VCLK = SiS_Pr->CSRClock; |
| 2317 | } else { |
| 2318 | index = SiS_GetRefCRTVCLK(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWide); |
| 2319 | VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; |
| 2320 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2322 | /* Get half colordepth */ |
| 2323 | colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2324 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2325 | /* Get MCLK */ |
| 2326 | index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A) & 0x07; |
| 2327 | MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2329 | temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xc3; |
| 2330 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2332 | do { |
| 2333 | ThresholdLow = SiS_CalcDelay(SiS_Pr, VCLK, colorth, MCLK) + 1; |
| 2334 | if(ThresholdLow < 0x13) break; |
| 2335 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x16,0xfc); |
| 2336 | ThresholdLow = 0x13; |
| 2337 | temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) >> 6; |
| 2338 | if(!temp) break; |
| 2339 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3f,((temp - 1) << 6)); |
| 2340 | } while(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2342 | } else ThresholdLow = 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2343 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2344 | /* Write CRT/CPU threshold low, CRT/Engine threshold high */ |
| 2345 | temp = (ThresholdLow << 4) | 0x0f; |
| 2346 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2348 | temp = (ThresholdLow & 0x10) << 1; |
| 2349 | if(ModeNo > 0x13) temp |= 0x40; |
| 2350 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2351 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2352 | /* What is this? */ |
| 2353 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2354 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2355 | /* Write CRT/CPU threshold high */ |
| 2356 | temp = ThresholdLow + 3; |
| 2357 | if(temp > 0x0f) temp = 0x0f; |
| 2358 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x09,temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2359 | } |
| 2360 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2361 | unsigned short |
| 2362 | SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2364 | static const unsigned char LatencyFactor[] = { |
| 2365 | 97, 88, 86, 79, 77, 0, /* 64 bit BQ=2 */ |
| 2366 | 0, 87, 85, 78, 76, 54, /* 64 bit BQ=1 */ |
| 2367 | 97, 88, 86, 79, 77, 0, /* 128 bit BQ=2 */ |
| 2368 | 0, 79, 77, 70, 68, 48, /* 128 bit BQ=1 */ |
| 2369 | 80, 72, 69, 63, 61, 0, /* 64 bit BQ=2 */ |
| 2370 | 0, 70, 68, 61, 59, 37, /* 64 bit BQ=1 */ |
| 2371 | 86, 77, 75, 68, 66, 0, /* 128 bit BQ=2 */ |
| 2372 | 0, 68, 66, 59, 57, 37 /* 128 bit BQ=1 */ |
| 2373 | }; |
| 2374 | static const unsigned char LatencyFactor730[] = { |
| 2375 | 69, 63, 61, |
| 2376 | 86, 79, 77, |
| 2377 | 103, 96, 94, |
| 2378 | 120,113,111, |
| 2379 | 137,130,128 |
| 2380 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2381 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2382 | if(SiS_Pr->ChipType == SIS_730) { |
| 2383 | return (unsigned short)LatencyFactor730[index]; |
| 2384 | } else { |
| 2385 | return (unsigned short)LatencyFactor[index]; |
| 2386 | } |
| 2387 | } |
| 2388 | |
| 2389 | static unsigned short |
| 2390 | SiS_CalcDelay2(struct SiS_Private *SiS_Pr, unsigned char key) |
| 2391 | { |
| 2392 | unsigned short index; |
| 2393 | |
| 2394 | if(SiS_Pr->ChipType == SIS_730) { |
| 2395 | index = ((key & 0x0f) * 3) + ((key & 0xc0) >> 6); |
| 2396 | } else { |
| 2397 | index = (key & 0xe0) >> 5; |
| 2398 | if(key & 0x10) index += 6; |
| 2399 | if(!(key & 0x01)) index += 24; |
| 2400 | if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80) index += 12; |
| 2401 | } |
| 2402 | return SiS_GetLatencyFactor630(SiS_Pr, index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | } |
| 2404 | |
| 2405 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2406 | SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 2407 | unsigned short RefreshRateTableIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2408 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2409 | unsigned short ThresholdLow = 0; |
| 2410 | unsigned short i, data, VCLK, MCLK16, colorth = 0; |
| 2411 | unsigned int templ, datal; |
| 2412 | const unsigned char *queuedata = NULL; |
| 2413 | static const unsigned char FQBQData[21] = { |
| 2414 | 0x01,0x21,0x41,0x61,0x81, |
| 2415 | 0x31,0x51,0x71,0x91,0xb1, |
| 2416 | 0x00,0x20,0x40,0x60,0x80, |
| 2417 | 0x30,0x50,0x70,0x90,0xb0, |
| 2418 | 0xff |
| 2419 | }; |
| 2420 | static const unsigned char FQBQData730[16] = { |
| 2421 | 0x34,0x74,0xb4, |
| 2422 | 0x23,0x63,0xa3, |
| 2423 | 0x12,0x52,0x92, |
| 2424 | 0x01,0x41,0x81, |
| 2425 | 0x00,0x40,0x80, |
| 2426 | 0xff |
| 2427 | }; |
| 2428 | static const unsigned short colortharray[6] = { |
| 2429 | 1, 1, 2, 2, 3, 4 |
| 2430 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2431 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2432 | i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2433 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2434 | if(ModeNo > 0x13) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2435 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2436 | /* Get VCLK */ |
| 2437 | if(SiS_Pr->UseCustomMode) { |
| 2438 | VCLK = SiS_Pr->CSRClock; |
| 2439 | } else { |
| 2440 | data = SiS_GetRefCRTVCLK(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWide); |
| 2441 | VCLK = SiS_Pr->SiS_VCLKData[data].CLOCK; |
| 2442 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2443 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2444 | /* Get MCLK * 16 */ |
| 2445 | data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A) & 0x07; |
| 2446 | MCLK16 = SiS_Pr->SiS_MCLKData_0[data].CLOCK * 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2447 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2448 | /* Get half colordepth */ |
| 2449 | colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2450 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2451 | if(SiS_Pr->ChipType == SIS_730) { |
| 2452 | queuedata = &FQBQData730[0]; |
| 2453 | } else { |
| 2454 | queuedata = &FQBQData[0]; |
| 2455 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2456 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2457 | do { |
| 2458 | templ = SiS_CalcDelay2(SiS_Pr, queuedata[i]) * VCLK * colorth; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2459 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2460 | datal = templ % MCLK16; |
| 2461 | templ = (templ / MCLK16) + 1; |
| 2462 | if(datal) templ++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2464 | if(templ > 0x13) { |
| 2465 | if(queuedata[i + 1] == 0xFF) { |
| 2466 | ThresholdLow = 0x13; |
| 2467 | break; |
| 2468 | } |
| 2469 | i++; |
| 2470 | } else { |
| 2471 | ThresholdLow = templ; |
| 2472 | break; |
| 2473 | } |
| 2474 | } while(queuedata[i] != 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2475 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2476 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2477 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2478 | if(SiS_Pr->ChipType != SIS_730) i = 9; |
| 2479 | ThresholdLow = 0x02; |
| 2480 | |
| 2481 | } |
| 2482 | |
| 2483 | /* Write CRT/CPU threshold low, CRT/Engine threshold high */ |
| 2484 | data = ((ThresholdLow & 0x0f) << 4) | 0x0f; |
| 2485 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,data); |
| 2486 | |
| 2487 | data = (ThresholdLow & 0x10) << 1; |
| 2488 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data); |
| 2489 | |
| 2490 | /* What is this? */ |
| 2491 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09); |
| 2492 | |
| 2493 | /* Write CRT/CPU threshold high (gap = 3) */ |
| 2494 | data = ThresholdLow + 3; |
| 2495 | if(data > 0x0f) data = 0x0f; |
| 2496 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | |
| 2498 | /* Write foreground and background queue */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2499 | templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2500 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2501 | if(SiS_Pr->ChipType == SIS_730) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2503 | templ &= 0xfffff9ff; |
| 2504 | templ |= ((queuedata[i] & 0xc0) << 3); |
| 2505 | |
| 2506 | } else { |
| 2507 | |
| 2508 | templ &= 0xf0ffffff; |
| 2509 | if( (ModeNo <= 0x13) && |
| 2510 | (SiS_Pr->ChipType == SIS_630) && |
| 2511 | (SiS_Pr->ChipRevision >= 0x30) ) { |
| 2512 | templ |= 0x0b000000; |
| 2513 | } else { |
| 2514 | templ |= ((queuedata[i] & 0xf0) << 20); |
| 2515 | } |
| 2516 | |
| 2517 | } |
| 2518 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2519 | sisfb_write_nbridge_pci_dword(SiS_Pr, 0x50, templ); |
| 2520 | templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xA0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2521 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2522 | /* GUI grant timer (PCI config 0xA3) */ |
| 2523 | if(SiS_Pr->ChipType == SIS_730) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2524 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2525 | templ &= 0x00ffffff; |
| 2526 | datal = queuedata[i] << 8; |
| 2527 | templ |= (((datal & 0x0f00) | ((datal & 0x3000) >> 8)) << 20); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2529 | } else { |
| 2530 | |
| 2531 | templ &= 0xf0ffffff; |
| 2532 | templ |= ((queuedata[i] & 0x0f) << 24); |
| 2533 | |
| 2534 | } |
| 2535 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2536 | sisfb_write_nbridge_pci_dword(SiS_Pr, 0xA0, templ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2537 | } |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2538 | #endif /* CONFIG_FB_SIS_300 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2539 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2540 | #ifdef CONFIG_FB_SIS_315 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2541 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2542 | SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2543 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2544 | unsigned short modeflag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2545 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2546 | /* disable auto-threshold */ |
| 2547 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2548 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2549 | modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2550 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2551 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE); |
| 2552 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0); |
| 2553 | if(ModeNo > 0x13) { |
| 2554 | if(SiS_Pr->ChipType >= XGI_20) { |
| 2555 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); |
| 2556 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); |
| 2557 | } else if(SiS_Pr->ChipType >= SIS_661) { |
| 2558 | if(!(modeflag & HalfDCLK)) { |
| 2559 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); |
| 2560 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); |
| 2561 | } |
| 2562 | } else { |
| 2563 | if((!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) { |
| 2564 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34); |
| 2565 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01); |
| 2566 | } |
| 2567 | } |
| 2568 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2569 | } |
| 2570 | #endif |
| 2571 | |
| 2572 | /*********************************************/ |
| 2573 | /* MODE REGISTERS */ |
| 2574 | /*********************************************/ |
| 2575 | |
| 2576 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2577 | SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 2578 | unsigned short RefreshRateTableIndex, unsigned short ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2580 | unsigned short data = 0, VCLK = 0, index = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2582 | if(ModeNo > 0x13) { |
| 2583 | if(SiS_Pr->UseCustomMode) { |
| 2584 | VCLK = SiS_Pr->CSRClock; |
| 2585 | } else { |
| 2586 | index = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); |
| 2587 | VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; |
| 2588 | } |
| 2589 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2591 | if(SiS_Pr->ChipType < SIS_315H) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2592 | #ifdef CONFIG_FB_SIS_300 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2593 | if(VCLK > 150) data |= 0x80; |
| 2594 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2595 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2596 | data = 0x00; |
| 2597 | if(VCLK >= 150) data |= 0x08; |
| 2598 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data); |
| 2599 | #endif |
| 2600 | } else if(SiS_Pr->ChipType < XGI_20) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2601 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2602 | if(VCLK >= 166) data |= 0x0c; |
| 2603 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2604 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2605 | if(VCLK >= 166) { |
| 2606 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7); |
| 2607 | } |
| 2608 | #endif |
| 2609 | } else { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2610 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2611 | if(VCLK >= 200) data |= 0x0c; |
| 2612 | if(SiS_Pr->ChipType == XGI_20) data &= ~0x04; |
| 2613 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); |
| 2614 | if(SiS_Pr->ChipType != XGI_20) { |
| 2615 | data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xe7; |
| 2616 | if(VCLK < 200) data |= 0x10; |
| 2617 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x1f,data); |
| 2618 | } |
| 2619 | #endif |
| 2620 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2621 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2622 | /* DAC speed */ |
| 2623 | if(SiS_Pr->ChipType >= SIS_661) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2624 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2625 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xE8,0x10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2626 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2627 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2628 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2629 | data = 0x03; |
| 2630 | if(VCLK >= 260) data = 0x00; |
| 2631 | else if(VCLK >= 160) data = 0x01; |
| 2632 | else if(VCLK >= 135) data = 0x02; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2633 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2634 | if(SiS_Pr->ChipType == SIS_540) { |
| 2635 | if((VCLK == 203) || (VCLK < 234)) data = 0x02; |
| 2636 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2637 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2638 | if(SiS_Pr->ChipType < SIS_315H) { |
| 2639 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data); |
| 2640 | } else { |
| 2641 | if(SiS_Pr->ChipType > SIS_315PRO) { |
| 2642 | if(ModeNo > 0x13) data &= 0xfc; |
| 2643 | } |
| 2644 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data); |
| 2645 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2646 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2647 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2648 | } |
| 2649 | |
| 2650 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2651 | SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 2652 | unsigned short ModeIdIndex, unsigned short RRTI) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2653 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2654 | unsigned short data, infoflag = 0, modeflag, resindex; |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2655 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2656 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; |
| 2657 | unsigned short data2, data3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | #endif |
| 2659 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2660 | modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2661 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2662 | if(SiS_Pr->UseCustomMode) { |
| 2663 | infoflag = SiS_Pr->CInfoFlag; |
| 2664 | } else { |
| 2665 | resindex = SiS_GetResInfo(SiS_Pr, ModeNo, ModeIdIndex); |
| 2666 | if(ModeNo > 0x13) { |
| 2667 | infoflag = SiS_Pr->SiS_RefIndex[RRTI].Ext_InfoFlag; |
| 2668 | } |
| 2669 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2671 | /* Disable DPMS */ |
| 2672 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2673 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2674 | data = 0; |
| 2675 | if(ModeNo > 0x13) { |
| 2676 | if(SiS_Pr->SiS_ModeType > ModeEGA) { |
| 2677 | data |= 0x02; |
| 2678 | data |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2); |
| 2679 | } |
| 2680 | if(infoflag & InterlaceMode) data |= 0x20; |
| 2681 | } |
| 2682 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x06,0xC0,data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2684 | if(SiS_Pr->ChipType != SIS_300) { |
| 2685 | data = 0; |
| 2686 | if(infoflag & InterlaceMode) { |
| 2687 | /* data = (Hsync / 8) - ((Htotal / 8) / 2) + 3 */ |
| 2688 | int hrs = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x04) | |
| 2689 | ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x0b) & 0xc0) << 2)) - 3; |
| 2690 | int hto = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x00) | |
| 2691 | ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x0b) & 0x03) << 8)) + 5; |
| 2692 | data = hrs - (hto >> 1) + 3; |
| 2693 | } |
| 2694 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x19,data); |
| 2695 | SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,((data >> 8) & 0x03)); |
| 2696 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2697 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2698 | if(modeflag & HalfDCLK) { |
| 2699 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x08); |
| 2700 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2701 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2702 | data = 0; |
| 2703 | if(modeflag & LineCompareOff) data = 0x08; |
| 2704 | if(SiS_Pr->ChipType == SIS_300) { |
| 2705 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xF7,data); |
| 2706 | } else { |
| 2707 | if(SiS_Pr->ChipType >= XGI_20) data |= 0x20; |
| 2708 | if(SiS_Pr->SiS_ModeType == ModeEGA) { |
| 2709 | if(ModeNo > 0x13) { |
| 2710 | data |= 0x40; |
| 2711 | } |
| 2712 | } |
| 2713 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,data); |
| 2714 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2715 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2716 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2717 | if(SiS_Pr->ChipType >= SIS_315H) { |
| 2718 | SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xfb); |
| 2719 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2720 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2721 | if(SiS_Pr->ChipType == SIS_315PRO) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2722 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2723 | data = SiS_Pr->SiS_SR15[(2 * 4) + SiS_Get310DRAMType(SiS_Pr)]; |
| 2724 | if(SiS_Pr->SiS_ModeType == ModeText) { |
| 2725 | data &= 0xc7; |
| 2726 | } else { |
| 2727 | data2 = SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, RRTI) >> 1; |
| 2728 | if(infoflag & InterlaceMode) data2 >>= 1; |
| 2729 | data3 = SiS_GetColorDepth(SiS_Pr, ModeNo, ModeIdIndex) >> 1; |
| 2730 | if(data3) data2 /= data3; |
| 2731 | if(data2 >= 0x50) { |
| 2732 | data &= 0x0f; |
| 2733 | data |= 0x50; |
| 2734 | } |
| 2735 | } |
| 2736 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2737 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2738 | } else if((SiS_Pr->ChipType == SIS_330) || (SiS_Pr->SiS_SysFlags & SF_760LFB)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2739 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2740 | data = SiS_Get310DRAMType(SiS_Pr); |
| 2741 | if(SiS_Pr->ChipType == SIS_330) { |
| 2742 | data = SiS_Pr->SiS_SR15[(2 * 4) + data]; |
| 2743 | } else { |
| 2744 | if(SiS_Pr->SiS_ROMNew) data = ROMAddr[0xf6]; |
| 2745 | else if(SiS_Pr->SiS_UseROM) data = ROMAddr[0x100 + data]; |
| 2746 | else data = 0xba; |
| 2747 | } |
| 2748 | if(SiS_Pr->SiS_ModeType <= ModeEGA) { |
| 2749 | data &= 0xc7; |
| 2750 | } else { |
| 2751 | if(SiS_Pr->UseCustomMode) { |
| 2752 | data2 = SiS_Pr->CSRClock; |
| 2753 | } else { |
| 2754 | data2 = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RRTI); |
| 2755 | data2 = SiS_Pr->SiS_VCLKData[data2].CLOCK; |
| 2756 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2757 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2758 | data3 = SiS_GetColorDepth(SiS_Pr, ModeNo, ModeIdIndex) >> 1; |
| 2759 | if(data3) data2 *= data3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2760 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2761 | data2 = ((unsigned int)(SiS_GetMCLK(SiS_Pr) * 1024)) / data2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2762 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2763 | if(SiS_Pr->ChipType == SIS_330) { |
| 2764 | if(SiS_Pr->SiS_ModeType != Mode16Bpp) { |
| 2765 | if (data2 >= 0x19c) data = 0xba; |
| 2766 | else if(data2 >= 0x140) data = 0x7a; |
| 2767 | else if(data2 >= 0x101) data = 0x3a; |
| 2768 | else if(data2 >= 0xf5) data = 0x32; |
| 2769 | else if(data2 >= 0xe2) data = 0x2a; |
| 2770 | else if(data2 >= 0xc4) data = 0x22; |
| 2771 | else if(data2 >= 0xac) data = 0x1a; |
| 2772 | else if(data2 >= 0x9e) data = 0x12; |
| 2773 | else if(data2 >= 0x8e) data = 0x0a; |
| 2774 | else data = 0x02; |
| 2775 | } else { |
| 2776 | if(data2 >= 0x127) data = 0xba; |
| 2777 | else data = 0x7a; |
| 2778 | } |
| 2779 | } else { /* 76x+LFB */ |
| 2780 | if (data2 >= 0x190) data = 0xba; |
| 2781 | else if(data2 >= 0xff) data = 0x7a; |
| 2782 | else if(data2 >= 0xd3) data = 0x3a; |
| 2783 | else if(data2 >= 0xa9) data = 0x1a; |
| 2784 | else if(data2 >= 0x93) data = 0x0a; |
| 2785 | else data = 0x02; |
| 2786 | } |
| 2787 | } |
| 2788 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data); |
| 2789 | |
| 2790 | } |
| 2791 | /* XGI: Nothing. */ |
| 2792 | /* TODO: Check SiS340 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2793 | #endif |
| 2794 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2795 | data = 0x60; |
| 2796 | if(SiS_Pr->SiS_ModeType != ModeText) { |
| 2797 | data ^= 0x60; |
| 2798 | if(SiS_Pr->SiS_ModeType != ModeEGA) { |
| 2799 | data ^= 0xA0; |
| 2800 | } |
| 2801 | } |
| 2802 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x21,0x1F,data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2803 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2804 | SiS_SetVCLKState(SiS_Pr, ModeNo, RRTI, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2805 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2806 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2807 | if(((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) || |
| 2808 | (SiS_Pr->ChipType == XGI_40)) { |
| 2809 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { |
| 2810 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x2c); |
| 2811 | } else { |
| 2812 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x6c); |
| 2813 | } |
| 2814 | } else if(SiS_Pr->ChipType == XGI_20) { |
| 2815 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { |
| 2816 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x33); |
| 2817 | } else { |
| 2818 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x73); |
| 2819 | } |
| 2820 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x51,0x02); |
| 2821 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2822 | #endif |
| 2823 | } |
| 2824 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 2825 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2826 | static void |
| 2827 | SiS_SetupDualChip(struct SiS_Private *SiS_Pr) |
| 2828 | { |
| 2829 | #if 0 |
| 2830 | /* TODO: Find out about IOAddress2 */ |
| 2831 | SISIOADDRESS P2_3c2 = SiS_Pr->IOAddress2 + 0x12; |
| 2832 | SISIOADDRESS P2_3c4 = SiS_Pr->IOAddress2 + 0x14; |
| 2833 | SISIOADDRESS P2_3ce = SiS_Pr->IOAddress2 + 0x1e; |
| 2834 | int i; |
| 2835 | |
| 2836 | if((SiS_Pr->ChipRevision != 0) || |
| 2837 | (!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x3a) & 0x04))) |
| 2838 | return; |
| 2839 | |
| 2840 | for(i = 0; i <= 4; i++) { /* SR00 - SR04 */ |
| 2841 | SiS_SetReg(P2_3c4,i,SiS_GetReg(SiS_Pr->SiS_P3c4,i)); |
| 2842 | } |
| 2843 | for(i = 0; i <= 8; i++) { /* GR00 - GR08 */ |
| 2844 | SiS_SetReg(P2_3ce,i,SiS_GetReg(SiS_Pr->SiS_P3ce,i)); |
| 2845 | } |
| 2846 | SiS_SetReg(P2_3c4,0x05,0x86); |
| 2847 | SiS_SetReg(P2_3c4,0x06,SiS_GetReg(SiS_Pr->SiS_P3c4,0x06)); /* SR06 */ |
| 2848 | SiS_SetReg(P2_3c4,0x21,SiS_GetReg(SiS_Pr->SiS_P3c4,0x21)); /* SR21 */ |
| 2849 | SiS_SetRegByte(P2_3c2,SiS_GetRegByte(SiS_Pr->SiS_P3cc)); /* MISC */ |
| 2850 | SiS_SetReg(P2_3c4,0x05,0x00); |
| 2851 | #endif |
| 2852 | } |
| 2853 | #endif |
| 2854 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2855 | /*********************************************/ |
| 2856 | /* LOAD DAC */ |
| 2857 | /*********************************************/ |
| 2858 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2859 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2860 | SiS_WriteDAC(struct SiS_Private *SiS_Pr, SISIOADDRESS DACData, unsigned short shiftflag, |
| 2861 | unsigned short dl, unsigned short ah, unsigned short al, unsigned short dh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2862 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2863 | unsigned short d1, d2, d3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2864 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2865 | switch(dl) { |
| 2866 | case 0: d1 = dh; d2 = ah; d3 = al; break; |
| 2867 | case 1: d1 = ah; d2 = al; d3 = dh; break; |
| 2868 | default: d1 = al; d2 = dh; d3 = ah; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2869 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2870 | SiS_SetRegByte(DACData, (d1 << shiftflag)); |
| 2871 | SiS_SetRegByte(DACData, (d2 << shiftflag)); |
| 2872 | SiS_SetRegByte(DACData, (d3 << shiftflag)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2873 | } |
| 2874 | |
| 2875 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2876 | SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2877 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2878 | unsigned short data, data2, time, i, j, k, m, n, o; |
| 2879 | unsigned short si, di, bx, sf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2880 | SISIOADDRESS DACAddr, DACData; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2881 | const unsigned char *table = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2882 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2883 | data = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex) & DACInfoFlag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2884 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2885 | j = time = 64; |
| 2886 | if(data == 0x00) table = SiS_MDA_DAC; |
| 2887 | else if(data == 0x08) table = SiS_CGA_DAC; |
| 2888 | else if(data == 0x10) table = SiS_EGA_DAC; |
| 2889 | else if(data == 0x18) { |
| 2890 | j = 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2891 | time = 256; |
| 2892 | table = SiS_VGA_DAC; |
| 2893 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2894 | |
| 2895 | if( ( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && /* 301B-DH LCD */ |
| 2896 | (SiS_Pr->SiS_VBType & VB_NoLCD) ) || |
| 2897 | (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) || /* LCDA */ |
| 2898 | (!(SiS_Pr->SiS_SetFlag & ProgrammingCRT2)) ) { /* Programming CRT1 */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2899 | SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2900 | DACAddr = SiS_Pr->SiS_P3c8; |
| 2901 | DACData = SiS_Pr->SiS_P3c9; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2902 | sf = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2903 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2904 | DACAddr = SiS_Pr->SiS_Part5Port; |
| 2905 | DACData = SiS_Pr->SiS_Part5Port + 1; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2906 | sf = 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2907 | } |
| 2908 | |
| 2909 | SiS_SetRegByte(DACAddr,0x00); |
| 2910 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2911 | for(i = 0; i < j; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2912 | data = table[i]; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2913 | for(k = 0; k < 3; k++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2914 | data2 = 0; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2915 | if(data & 0x01) data2 += 0x2A; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2916 | if(data & 0x02) data2 += 0x15; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2917 | SiS_SetRegByte(DACData, (data2 << sf)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2918 | data >>= 2; |
| 2919 | } |
| 2920 | } |
| 2921 | |
| 2922 | if(time == 256) { |
| 2923 | for(i = 16; i < 32; i++) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2924 | data = table[i] << sf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2925 | for(k = 0; k < 3; k++) SiS_SetRegByte(DACData, data); |
| 2926 | } |
| 2927 | si = 32; |
| 2928 | for(m = 0; m < 9; m++) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2929 | di = si; |
| 2930 | bx = si + 4; |
| 2931 | for(n = 0; n < 3; n++) { |
| 2932 | for(o = 0; o < 5; o++) { |
| 2933 | SiS_WriteDAC(SiS_Pr, DACData, sf, n, table[di], table[bx], table[si]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2934 | si++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2935 | } |
| 2936 | si -= 2; |
| 2937 | for(o = 0; o < 3; o++) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2938 | SiS_WriteDAC(SiS_Pr, DACData, sf, n, table[di], table[si], table[bx]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2939 | si--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2940 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2941 | } /* for n < 3 */ |
| 2942 | si += 5; |
| 2943 | } /* for m < 9 */ |
| 2944 | } |
| 2945 | } |
| 2946 | |
| 2947 | /*********************************************/ |
| 2948 | /* SET CRT1 REGISTER GROUP */ |
| 2949 | /*********************************************/ |
| 2950 | |
| 2951 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2952 | SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2953 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2954 | unsigned short StandTableIndex, RefreshRateTableIndex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2955 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2956 | SiS_Pr->SiS_CRT1Mode = ModeNo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2957 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2958 | StandTableIndex = SiS_GetModePtr(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2959 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2960 | if(SiS_Pr->SiS_SetFlag & LowModeTests) { |
| 2961 | if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2)) { |
| 2962 | SiS_DisableBridge(SiS_Pr); |
| 2963 | } |
| 2964 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2965 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2966 | SiS_ResetSegmentRegisters(SiS_Pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2967 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2968 | SiS_SetSeqRegs(SiS_Pr, StandTableIndex); |
| 2969 | SiS_SetMiscRegs(SiS_Pr, StandTableIndex); |
| 2970 | SiS_SetCRTCRegs(SiS_Pr, StandTableIndex); |
| 2971 | SiS_SetATTRegs(SiS_Pr, StandTableIndex); |
| 2972 | SiS_SetGRCRegs(SiS_Pr, StandTableIndex); |
| 2973 | SiS_ClearExt1Regs(SiS_Pr, ModeNo); |
| 2974 | SiS_ResetCRT1VCLK(SiS_Pr); |
| 2975 | |
| 2976 | SiS_Pr->SiS_SelectCRT2Rate = 0; |
| 2977 | SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); |
| 2978 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2979 | if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { |
| 2980 | if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { |
| 2981 | SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; |
| 2982 | } |
| 2983 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2984 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2985 | if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { |
| 2986 | SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; |
| 2987 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2988 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2989 | RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2990 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2991 | if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { |
| 2992 | SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2; |
| 2993 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2994 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 2995 | if(RefreshRateTableIndex != 0xFFFF) { |
| 2996 | SiS_SetCRT1Sync(SiS_Pr, RefreshRateTableIndex); |
| 2997 | SiS_SetCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); |
| 2998 | SiS_SetCRT1Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); |
| 2999 | SiS_SetCRT1VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); |
| 3000 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3001 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3002 | switch(SiS_Pr->ChipType) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3003 | #ifdef CONFIG_FB_SIS_300 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3004 | case SIS_300: |
| 3005 | SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo, RefreshRateTableIndex); |
| 3006 | break; |
| 3007 | case SIS_540: |
| 3008 | case SIS_630: |
| 3009 | case SIS_730: |
| 3010 | SiS_SetCRT1FIFO_630(SiS_Pr, ModeNo, RefreshRateTableIndex); |
| 3011 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3012 | #endif |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3013 | default: |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3014 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3015 | if(SiS_Pr->ChipType == XGI_20) { |
| 3016 | unsigned char sr2b = 0, sr2c = 0; |
| 3017 | switch(ModeNo) { |
| 3018 | case 0x00: |
| 3019 | case 0x01: sr2b = 0x4e; sr2c = 0xe9; break; |
| 3020 | case 0x04: |
| 3021 | case 0x05: |
| 3022 | case 0x0d: sr2b = 0x1b; sr2c = 0xe3; break; |
| 3023 | } |
| 3024 | if(sr2b) { |
| 3025 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2b,sr2b); |
| 3026 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,sr2c); |
| 3027 | SiS_SetRegByte(SiS_Pr->SiS_P3c2,(SiS_GetRegByte(SiS_Pr->SiS_P3cc) | 0x0c)); |
| 3028 | } |
| 3029 | } |
| 3030 | SiS_SetCRT1FIFO_310(SiS_Pr, ModeNo, ModeIdIndex); |
| 3031 | #endif |
| 3032 | break; |
| 3033 | } |
| 3034 | |
| 3035 | SiS_SetCRT1ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); |
| 3036 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3037 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3038 | if(SiS_Pr->ChipType == XGI_40) { |
| 3039 | SiS_SetupDualChip(SiS_Pr); |
| 3040 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | #endif |
| 3042 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3043 | SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3044 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3045 | if(SiS_Pr->SiS_flag_clearbuffer) { |
| 3046 | SiS_ClearBuffer(SiS_Pr, ModeNo); |
| 3047 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3048 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3049 | if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { |
| 3050 | SiS_WaitRetrace1(SiS_Pr); |
| 3051 | SiS_DisplayOn(SiS_Pr); |
| 3052 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3053 | } |
| 3054 | |
| 3055 | /*********************************************/ |
| 3056 | /* HELPER: VIDEO BRIDGE PROG CLK */ |
| 3057 | /*********************************************/ |
| 3058 | |
| 3059 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3060 | SiS_InitVB(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3061 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3062 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3063 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3064 | SiS_Pr->Init_P4_0E = 0; |
| 3065 | if(SiS_Pr->SiS_ROMNew) { |
| 3066 | SiS_Pr->Init_P4_0E = ROMAddr[0x82]; |
| 3067 | } else if(SiS_Pr->ChipType >= XGI_40) { |
| 3068 | if(SiS_Pr->SiS_XGIROM) { |
| 3069 | SiS_Pr->Init_P4_0E = ROMAddr[0x80]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3070 | } |
| 3071 | } |
| 3072 | } |
| 3073 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3074 | static void |
| 3075 | SiS_ResetVB(struct SiS_Private *SiS_Pr) |
| 3076 | { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3077 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3078 | unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; |
| 3079 | unsigned short temp; |
| 3080 | |
| 3081 | /* VB programming clock */ |
| 3082 | if(SiS_Pr->SiS_UseROM) { |
| 3083 | if(SiS_Pr->ChipType < SIS_330) { |
| 3084 | temp = ROMAddr[VB310Data_1_2_Offset] | 0x40; |
| 3085 | if(SiS_Pr->SiS_ROMNew) temp = ROMAddr[0x80] | 0x40; |
| 3086 | SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); |
| 3087 | } else if(SiS_Pr->ChipType >= SIS_661 && SiS_Pr->ChipType < XGI_20) { |
| 3088 | temp = ROMAddr[0x7e] | 0x40; |
| 3089 | if(SiS_Pr->SiS_ROMNew) temp = ROMAddr[0x80] | 0x40; |
| 3090 | SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); |
| 3091 | } |
| 3092 | } else if(SiS_Pr->ChipType >= XGI_40) { |
| 3093 | temp = 0x40; |
| 3094 | if(SiS_Pr->SiS_XGIROM) temp |= ROMAddr[0x7e]; |
| 3095 | /* Can we do this on any chipset? */ |
| 3096 | SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp); |
| 3097 | } |
| 3098 | #endif |
| 3099 | } |
| 3100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3101 | /*********************************************/ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3102 | /* HELPER: SET VIDEO/CAPTURE REGISTERS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3103 | /*********************************************/ |
| 3104 | |
| 3105 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3106 | SiS_StrangeStuff(struct SiS_Private *SiS_Pr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3107 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3108 | /* SiS65x and XGI set up some sort of "lock mode" for text |
| 3109 | * which locks CRT2 in some way to CRT1 timing. Disable |
| 3110 | * this here. |
| 3111 | */ |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3112 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3113 | if((IS_SIS651) || (IS_SISM650) || |
| 3114 | SiS_Pr->ChipType == SIS_340 || |
| 3115 | SiS_Pr->ChipType == XGI_40) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3116 | SiS_SetReg(SiS_Pr->SiS_VidCapt, 0x3f, 0x00); /* Fiddle with capture regs */ |
| 3117 | SiS_SetReg(SiS_Pr->SiS_VidCapt, 0x00, 0x00); |
| 3118 | SiS_SetReg(SiS_Pr->SiS_VidPlay, 0x00, 0x86); /* (BIOS does NOT unlock) */ |
| 3119 | SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x30, 0xfe); /* Fiddle with video regs */ |
| 3120 | SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x3f, 0xef); |
| 3121 | } |
| 3122 | /* !!! This does not support modes < 0x13 !!! */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3123 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3124 | } |
| 3125 | |
| 3126 | /*********************************************/ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3127 | /* HELPER: SET AGP TIMING FOR SiS760 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3128 | /*********************************************/ |
| 3129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3130 | static void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3131 | SiS_Handle760(struct SiS_Private *SiS_Pr) |
| 3132 | { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3133 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3134 | unsigned int somebase; |
| 3135 | unsigned char temp1, temp2, temp3; |
| 3136 | |
| 3137 | if( (SiS_Pr->ChipType != SIS_760) || |
| 3138 | ((SiS_GetReg(SiS_Pr->SiS_P3d4, 0x5c) & 0xf8) != 0x80) || |
| 3139 | (!(SiS_Pr->SiS_SysFlags & SF_760LFB)) || |
| 3140 | (!(SiS_Pr->SiS_SysFlags & SF_760UMA)) ) |
| 3141 | return; |
| 3142 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3143 | somebase = sisfb_read_mio_pci_word(SiS_Pr, 0x74); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3144 | somebase &= 0xffff; |
| 3145 | |
| 3146 | if(somebase == 0) return; |
| 3147 | |
| 3148 | temp3 = SiS_GetRegByte((somebase + 0x85)) & 0xb7; |
| 3149 | |
| 3150 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { |
| 3151 | temp1 = 0x21; |
| 3152 | temp2 = 0x03; |
| 3153 | temp3 |= 0x08; |
| 3154 | } else { |
| 3155 | temp1 = 0x25; |
| 3156 | temp2 = 0x0b; |
| 3157 | } |
| 3158 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3159 | sisfb_write_nbridge_pci_byte(SiS_Pr, 0x7e, temp1); |
| 3160 | sisfb_write_nbridge_pci_byte(SiS_Pr, 0x8d, temp2); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3161 | |
| 3162 | SiS_SetRegByte((somebase + 0x85), temp3); |
| 3163 | #endif |
| 3164 | } |
| 3165 | |
| 3166 | /*********************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3167 | /* SiSSetMode() */ |
| 3168 | /*********************************************/ |
| 3169 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 3170 | bool |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3171 | SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3172 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3173 | SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; |
| 3174 | unsigned short RealModeNo, ModeIdIndex; |
| 3175 | unsigned char backupreg = 0; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3176 | unsigned short KeepLockReg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3177 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 3178 | SiS_Pr->UseCustomMode = false; |
| 3179 | SiS_Pr->CRT1UsesCustomMode = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3180 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3181 | SiS_Pr->SiS_flag_clearbuffer = 0; |
| 3182 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3183 | if(SiS_Pr->UseCustomMode) { |
| 3184 | ModeNo = 0xfe; |
| 3185 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3186 | if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3187 | ModeNo &= 0x7f; |
| 3188 | } |
| 3189 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3190 | /* Don't use FSTN mode for CRT1 */ |
| 3191 | RealModeNo = ModeNo; |
| 3192 | if(ModeNo == 0x5b) ModeNo = 0x56; |
| 3193 | |
| 3194 | SiSInitPtr(SiS_Pr); |
| 3195 | SiSRegInit(SiS_Pr, BaseAddr); |
| 3196 | SiS_GetSysFlags(SiS_Pr); |
| 3197 | |
| 3198 | SiS_Pr->SiS_VGAINFO = 0x11; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3200 | KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3201 | SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); |
| 3202 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3203 | SiSInitPCIetc(SiS_Pr); |
| 3204 | SiSSetLVDSetc(SiS_Pr); |
| 3205 | SiSDetermineROMUsage(SiS_Pr); |
| 3206 | |
| 3207 | SiS_UnLockCRT2(SiS_Pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3208 | |
| 3209 | if(!SiS_Pr->UseCustomMode) { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 3210 | if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3211 | } else { |
| 3212 | ModeIdIndex = 0; |
| 3213 | } |
| 3214 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3215 | SiS_GetVBType(SiS_Pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3216 | |
| 3217 | /* Init/restore some VB registers */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3218 | SiS_InitVB(SiS_Pr); |
| 3219 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { |
| 3220 | if(SiS_Pr->ChipType >= SIS_315H) { |
| 3221 | SiS_ResetVB(SiS_Pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3222 | SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10); |
| 3223 | SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c); |
| 3224 | backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); |
| 3225 | } else { |
| 3226 | backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); |
| 3227 | } |
| 3228 | } |
| 3229 | |
| 3230 | /* Get VB information (connectors, connected devices) */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3231 | SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, (SiS_Pr->UseCustomMode) ? 0 : 1); |
| 3232 | SiS_SetYPbPr(SiS_Pr); |
| 3233 | SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex); |
| 3234 | SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); |
| 3235 | SiS_SetLowModeTest(SiS_Pr, ModeNo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3236 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3237 | /* Check memory size (kernel framebuffer driver only) */ |
| 3238 | if(!SiS_CheckMemorySize(SiS_Pr, ModeNo, ModeIdIndex)) { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 3239 | return false; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3240 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3241 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3242 | SiS_OpenCRTC(SiS_Pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3243 | |
| 3244 | if(SiS_Pr->UseCustomMode) { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 3245 | SiS_Pr->CRT1UsesCustomMode = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3246 | SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock; |
| 3247 | SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag; |
| 3248 | } else { |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 3249 | SiS_Pr->CRT1UsesCustomMode = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3250 | } |
| 3251 | |
| 3252 | /* Set mode on CRT1 */ |
| 3253 | if( (SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) || |
| 3254 | (!(SiS_Pr->SiS_VBInfo & SwitchCRT2)) ) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3255 | SiS_SetCRT1Group(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3256 | } |
| 3257 | |
| 3258 | /* Set mode on CRT2 */ |
| 3259 | if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA)) { |
| 3260 | if( (SiS_Pr->SiS_VBType & VB_SISVB) || |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3261 | (SiS_Pr->SiS_IF_DEF_LVDS == 1) || |
| 3262 | (SiS_Pr->SiS_IF_DEF_CH70xx != 0) || |
| 3263 | (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) { |
| 3264 | SiS_SetCRT2Group(SiS_Pr, RealModeNo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3265 | } |
| 3266 | } |
| 3267 | |
| 3268 | SiS_HandleCRT1(SiS_Pr); |
| 3269 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3270 | SiS_StrangeStuff(SiS_Pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3271 | |
| 3272 | SiS_DisplayOn(SiS_Pr); |
| 3273 | SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); |
| 3274 | |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3275 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3276 | if(SiS_Pr->ChipType >= SIS_315H) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3277 | if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3278 | if(!(SiS_IsDualEdge(SiS_Pr))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3279 | SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); |
| 3280 | } |
| 3281 | } |
| 3282 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3283 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3284 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3285 | if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { |
| 3286 | if(SiS_Pr->ChipType >= SIS_315H) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3287 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3288 | if(!SiS_Pr->SiS_ROMNew) { |
| 3289 | if(SiS_IsVAMode(SiS_Pr)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3290 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); |
| 3291 | } else { |
| 3292 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE); |
| 3293 | } |
| 3294 | } |
| 3295 | |
| 3296 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg); |
| 3297 | |
| 3298 | if((IS_SIS650) && (SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & 0xfc)) { |
| 3299 | if((ModeNo == 0x03) || (ModeNo == 0x10)) { |
| 3300 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x80); |
| 3301 | SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x56,0x08); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3302 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3303 | } |
| 3304 | |
| 3305 | if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) { |
| 3306 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); |
| 3307 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3308 | #endif |
| 3309 | } else if((SiS_Pr->ChipType == SIS_630) || |
| 3310 | (SiS_Pr->ChipType == SIS_730)) { |
| 3311 | SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3312 | } |
| 3313 | } |
| 3314 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3315 | SiS_CloseCRTC(SiS_Pr); |
| 3316 | |
| 3317 | SiS_Handle760(SiS_Pr); |
| 3318 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3319 | /* We never lock registers in XF86 */ |
| 3320 | if(KeepLockReg != 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3321 | |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 3322 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3323 | } |
| 3324 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3325 | #ifndef GETBITSTR |
| 3326 | #define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) |
| 3327 | #define GENMASK(mask) BITMASK(1?mask,0?mask) |
| 3328 | #define GETBITS(var,mask) (((var) & GENMASK(mask)) >> (0?mask)) |
| 3329 | #define GETBITSTR(val,from,to) ((GETBITS(val,from)) << (0?to)) |
| 3330 | #endif |
| 3331 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3332 | void |
| 3333 | SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3334 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3335 | int x = 1; /* Fix sync */ |
| 3336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3337 | SiS_Pr->CCRT1CRTC[0] = ((SiS_Pr->CHTotal >> 3) - 5) & 0xff; /* CR0 */ |
| 3338 | SiS_Pr->CCRT1CRTC[1] = (SiS_Pr->CHDisplay >> 3) - 1; /* CR1 */ |
| 3339 | SiS_Pr->CCRT1CRTC[2] = (SiS_Pr->CHBlankStart >> 3) - 1; /* CR2 */ |
| 3340 | SiS_Pr->CCRT1CRTC[3] = (((SiS_Pr->CHBlankEnd >> 3) - 1) & 0x1F) | 0x80; /* CR3 */ |
| 3341 | SiS_Pr->CCRT1CRTC[4] = (SiS_Pr->CHSyncStart >> 3) + 3; /* CR4 */ |
| 3342 | SiS_Pr->CCRT1CRTC[5] = ((((SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) | /* CR5 */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3343 | (((SiS_Pr->CHSyncEnd >> 3) + 3) & 0x1F); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3344 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3345 | SiS_Pr->CCRT1CRTC[6] = (SiS_Pr->CVTotal - 2) & 0xFF; /* CR6 */ |
| 3346 | SiS_Pr->CCRT1CRTC[7] = (((SiS_Pr->CVTotal - 2) & 0x100) >> 8) /* CR7 */ |
| 3347 | | (((SiS_Pr->CVDisplay - 1) & 0x100) >> 7) |
| 3348 | | (((SiS_Pr->CVSyncStart - x) & 0x100) >> 6) |
| 3349 | | (((SiS_Pr->CVBlankStart- 1) & 0x100) >> 5) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3350 | | 0x10 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3351 | | (((SiS_Pr->CVTotal - 2) & 0x200) >> 4) |
| 3352 | | (((SiS_Pr->CVDisplay - 1) & 0x200) >> 3) |
| 3353 | | (((SiS_Pr->CVSyncStart - x) & 0x200) >> 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3354 | |
| 3355 | SiS_Pr->CCRT1CRTC[16] = ((((SiS_Pr->CVBlankStart - 1) & 0x200) >> 4) >> 5); /* CR9 */ |
| 3356 | |
| 3357 | if(depth != 8) { |
| 3358 | if(SiS_Pr->CHDisplay >= 1600) SiS_Pr->CCRT1CRTC[16] |= 0x60; /* SRE */ |
| 3359 | else if(SiS_Pr->CHDisplay >= 640) SiS_Pr->CCRT1CRTC[16] |= 0x40; |
| 3360 | } |
| 3361 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3362 | SiS_Pr->CCRT1CRTC[8] = (SiS_Pr->CVSyncStart - x) & 0xFF; /* CR10 */ |
| 3363 | SiS_Pr->CCRT1CRTC[9] = ((SiS_Pr->CVSyncEnd - x) & 0x0F) | 0x80; /* CR11 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3364 | SiS_Pr->CCRT1CRTC[10] = (SiS_Pr->CVDisplay - 1) & 0xFF; /* CR12 */ |
| 3365 | SiS_Pr->CCRT1CRTC[11] = (SiS_Pr->CVBlankStart - 1) & 0xFF; /* CR15 */ |
| 3366 | SiS_Pr->CCRT1CRTC[12] = (SiS_Pr->CVBlankEnd - 1) & 0xFF; /* CR16 */ |
| 3367 | |
| 3368 | SiS_Pr->CCRT1CRTC[13] = /* SRA */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3369 | GETBITSTR((SiS_Pr->CVTotal -2), 10:10, 0:0) | |
| 3370 | GETBITSTR((SiS_Pr->CVDisplay -1), 10:10, 1:1) | |
| 3371 | GETBITSTR((SiS_Pr->CVBlankStart-1), 10:10, 2:2) | |
| 3372 | GETBITSTR((SiS_Pr->CVSyncStart -x), 10:10, 3:3) | |
| 3373 | GETBITSTR((SiS_Pr->CVBlankEnd -1), 8:8, 4:4) | |
| 3374 | GETBITSTR((SiS_Pr->CVSyncEnd ), 4:4, 5:5) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3375 | |
| 3376 | SiS_Pr->CCRT1CRTC[14] = /* SRB */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3377 | GETBITSTR((SiS_Pr->CHTotal >> 3) - 5, 9:8, 1:0) | |
| 3378 | GETBITSTR((SiS_Pr->CHDisplay >> 3) - 1, 9:8, 3:2) | |
| 3379 | GETBITSTR((SiS_Pr->CHBlankStart >> 3) - 1, 9:8, 5:4) | |
| 3380 | GETBITSTR((SiS_Pr->CHSyncStart >> 3) + 3, 9:8, 7:6) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3381 | |
| 3382 | |
| 3383 | SiS_Pr->CCRT1CRTC[15] = /* SRC */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3384 | GETBITSTR((SiS_Pr->CHBlankEnd >> 3) - 1, 7:6, 1:0) | |
| 3385 | GETBITSTR((SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3386 | } |
| 3387 | |
| 3388 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3389 | SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, |
| 3390 | unsigned short ModeIdIndex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3391 | { |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3392 | unsigned short modeflag, tempax, tempbx = 0, remaining = 0; |
| 3393 | unsigned short VGAHDE = SiS_Pr->SiS_VGAHDE; |
| 3394 | int i, j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3395 | |
| 3396 | /* 1:1 data: use data set by setcrt1crtc() */ |
| 3397 | if(SiS_Pr->SiS_LCDInfo & LCDPass11) return; |
| 3398 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3399 | modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3400 | |
| 3401 | if(modeflag & HalfDCLK) VGAHDE >>= 1; |
| 3402 | |
| 3403 | SiS_Pr->CHDisplay = VGAHDE; |
| 3404 | SiS_Pr->CHBlankStart = VGAHDE; |
| 3405 | |
| 3406 | SiS_Pr->CVDisplay = SiS_Pr->SiS_VGAVDE; |
| 3407 | SiS_Pr->CVBlankStart = SiS_Pr->SiS_VGAVDE; |
| 3408 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3409 | if(SiS_Pr->ChipType < SIS_315H) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3410 | #ifdef CONFIG_FB_SIS_300 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3411 | tempbx = SiS_Pr->SiS_VGAHT; |
| 3412 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
| 3413 | tempbx = SiS_Pr->PanelHT; |
| 3414 | } |
| 3415 | if(modeflag & HalfDCLK) tempbx >>= 1; |
| 3416 | remaining = tempbx % 8; |
| 3417 | #endif |
| 3418 | } else { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3419 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3420 | /* OK for LCDA, LVDS */ |
| 3421 | tempbx = SiS_Pr->PanelHT - SiS_Pr->PanelXRes; |
| 3422 | tempax = SiS_Pr->SiS_VGAHDE; /* not /2 ! */ |
| 3423 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
| 3424 | tempax = SiS_Pr->PanelXRes; |
| 3425 | } |
| 3426 | tempbx += tempax; |
| 3427 | if(modeflag & HalfDCLK) tempbx -= VGAHDE; |
| 3428 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3429 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3430 | SiS_Pr->CHTotal = SiS_Pr->CHBlankEnd = tempbx; |
| 3431 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3432 | if(SiS_Pr->ChipType < SIS_315H) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3433 | #ifdef CONFIG_FB_SIS_300 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3434 | if(SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) { |
| 3435 | SiS_Pr->CHSyncStart = SiS_Pr->SiS_VGAHDE + ((SiS_Pr->PanelHRS + 1) & ~1); |
| 3436 | SiS_Pr->CHSyncEnd = SiS_Pr->CHSyncStart + SiS_Pr->PanelHRE; |
| 3437 | if(modeflag & HalfDCLK) { |
| 3438 | SiS_Pr->CHSyncStart >>= 1; |
| 3439 | SiS_Pr->CHSyncEnd >>= 1; |
| 3440 | } |
| 3441 | } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
| 3442 | tempax = (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) >> 1; |
| 3443 | tempbx = (SiS_Pr->PanelHRS + 1) & ~1; |
| 3444 | if(modeflag & HalfDCLK) { |
| 3445 | tempax >>= 1; |
| 3446 | tempbx >>= 1; |
| 3447 | } |
| 3448 | SiS_Pr->CHSyncStart = (VGAHDE + tempax + tempbx + 7) & ~7; |
| 3449 | tempax = SiS_Pr->PanelHRE + 7; |
| 3450 | if(modeflag & HalfDCLK) tempax >>= 1; |
| 3451 | SiS_Pr->CHSyncEnd = (SiS_Pr->CHSyncStart + tempax) & ~7; |
| 3452 | } else { |
| 3453 | SiS_Pr->CHSyncStart = SiS_Pr->SiS_VGAHDE; |
| 3454 | if(modeflag & HalfDCLK) { |
| 3455 | SiS_Pr->CHSyncStart >>= 1; |
| 3456 | tempax = ((SiS_Pr->CHTotal - SiS_Pr->CHSyncStart) / 3) << 1; |
| 3457 | SiS_Pr->CHSyncEnd = SiS_Pr->CHSyncStart + tempax; |
| 3458 | } else { |
| 3459 | SiS_Pr->CHSyncEnd = (SiS_Pr->CHSyncStart + (SiS_Pr->CHTotal / 10) + 7) & ~7; |
| 3460 | SiS_Pr->CHSyncStart += 8; |
| 3461 | } |
| 3462 | } |
| 3463 | #endif |
| 3464 | } else { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3465 | #ifdef CONFIG_FB_SIS_315 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3466 | tempax = VGAHDE; |
| 3467 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
| 3468 | tempbx = SiS_Pr->PanelXRes; |
| 3469 | if(modeflag & HalfDCLK) tempbx >>= 1; |
| 3470 | tempax += ((tempbx - tempax) >> 1); |
| 3471 | } |
| 3472 | tempax += SiS_Pr->PanelHRS; |
| 3473 | SiS_Pr->CHSyncStart = tempax; |
| 3474 | tempax += SiS_Pr->PanelHRE; |
| 3475 | SiS_Pr->CHSyncEnd = tempax; |
| 3476 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3477 | } |
| 3478 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3479 | tempbx = SiS_Pr->PanelVT - SiS_Pr->PanelYRes; |
| 3480 | tempax = SiS_Pr->SiS_VGAVDE; |
| 3481 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
| 3482 | tempax = SiS_Pr->PanelYRes; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3483 | } else if(SiS_Pr->ChipType < SIS_315H) { |
Aaro Koskinen | f7854e5 | 2010-11-19 21:58:47 +0000 | [diff] [blame] | 3484 | #ifdef CONFIG_FB_SIS_300 |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3485 | /* Stupid hack for 640x400/320x200 */ |
| 3486 | if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { |
| 3487 | if((tempax + tempbx) == 438) tempbx += 16; |
| 3488 | } else if((SiS_Pr->SiS_LCDResInfo == Panel_800x600) || |
| 3489 | (SiS_Pr->SiS_LCDResInfo == Panel_1024x600)) { |
| 3490 | tempax = 0; |
| 3491 | tempbx = SiS_Pr->SiS_VGAVT; |
| 3492 | } |
| 3493 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3494 | } |
| 3495 | SiS_Pr->CVTotal = SiS_Pr->CVBlankEnd = tempbx + tempax; |
| 3496 | |
| 3497 | tempax = SiS_Pr->SiS_VGAVDE; |
| 3498 | if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { |
| 3499 | tempax += (SiS_Pr->PanelYRes - tempax) >> 1; |
| 3500 | } |
| 3501 | tempax += SiS_Pr->PanelVRS; |
| 3502 | SiS_Pr->CVSyncStart = tempax; |
| 3503 | tempax += SiS_Pr->PanelVRE; |
| 3504 | SiS_Pr->CVSyncEnd = tempax; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3505 | if(SiS_Pr->ChipType < SIS_315H) { |
| 3506 | SiS_Pr->CVSyncStart--; |
| 3507 | SiS_Pr->CVSyncEnd--; |
| 3508 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3509 | |
| 3510 | SiS_CalcCRRegisters(SiS_Pr, 8); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3511 | SiS_Pr->CCRT1CRTC[15] &= ~0xF8; |
| 3512 | SiS_Pr->CCRT1CRTC[15] |= (remaining << 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3513 | SiS_Pr->CCRT1CRTC[16] &= ~0xE0; |
| 3514 | |
| 3515 | SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); |
| 3516 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3517 | for(i = 0, j = 0; i <= 7; i++, j++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3518 | SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); |
| 3519 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3520 | for(j = 0x10; i <= 10; i++, j++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3521 | SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); |
| 3522 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3523 | for(j = 0x15; i <= 12; i++, j++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3524 | SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]); |
| 3525 | } |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3526 | for(j = 0x0A; i <= 15; i++, j++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3527 | SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->CCRT1CRTC[i]); |
| 3528 | } |
| 3529 | |
| 3530 | tempax = SiS_Pr->CCRT1CRTC[16] & 0xE0; |
| 3531 | SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1F,tempax); |
| 3532 | |
| 3533 | tempax = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; |
| 3534 | if(modeflag & DoubleScanMode) tempax |= 0x80; |
| 3535 | SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,tempax); |
| 3536 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3537 | } |
| 3538 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3539 | void |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3540 | SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, |
| 3541 | int xres, int yres, |
Richard Knutsson | c30660ea | 2007-02-12 00:55:06 -0800 | [diff] [blame] | 3542 | struct fb_var_screeninfo *var, bool writeres |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3543 | ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3544 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3545 | unsigned short HRE, HBE, HRS, HBS, HDE, HT; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3546 | unsigned short VRE, VBE, VRS, VBS, VDE, VT; |
| 3547 | unsigned char sr_data, cr_data, cr_data2; |
| 3548 | int A, B, C, D, E, F, temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3549 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3550 | sr_data = crdata[14]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3551 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3552 | /* Horizontal total */ |
| 3553 | HT = crdata[0] | ((unsigned short)(sr_data & 0x03) << 8); |
| 3554 | A = HT + 5; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3555 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3556 | /* Horizontal display enable end */ |
| 3557 | HDE = crdata[1] | ((unsigned short)(sr_data & 0x0C) << 6); |
| 3558 | E = HDE + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3559 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3560 | /* Horizontal retrace (=sync) start */ |
| 3561 | HRS = crdata[4] | ((unsigned short)(sr_data & 0xC0) << 2); |
| 3562 | F = HRS - E - 3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3563 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3564 | /* Horizontal blank start */ |
| 3565 | HBS = crdata[2] | ((unsigned short)(sr_data & 0x30) << 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3566 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3567 | sr_data = crdata[15]; |
| 3568 | cr_data = crdata[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3569 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3570 | /* Horizontal blank end */ |
| 3571 | HBE = (crdata[3] & 0x1f) | |
| 3572 | ((unsigned short)(cr_data & 0x80) >> 2) | |
| 3573 | ((unsigned short)(sr_data & 0x03) << 6); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3574 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3575 | /* Horizontal retrace (=sync) end */ |
| 3576 | HRE = (cr_data & 0x1f) | ((sr_data & 0x04) << 3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3577 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3578 | temp = HBE - ((E - 1) & 255); |
| 3579 | B = (temp > 0) ? temp : (temp + 256); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3580 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3581 | temp = HRE - ((E + F + 3) & 63); |
| 3582 | C = (temp > 0) ? temp : (temp + 64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3583 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3584 | D = B - F - C; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3585 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3586 | if(writeres) var->xres = xres = E * 8; |
| 3587 | var->left_margin = D * 8; |
| 3588 | var->right_margin = F * 8; |
| 3589 | var->hsync_len = C * 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3590 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3591 | /* Vertical */ |
| 3592 | sr_data = crdata[13]; |
| 3593 | cr_data = crdata[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3594 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3595 | /* Vertical total */ |
| 3596 | VT = crdata[6] | |
| 3597 | ((unsigned short)(cr_data & 0x01) << 8) | |
| 3598 | ((unsigned short)(cr_data & 0x20) << 4) | |
| 3599 | ((unsigned short)(sr_data & 0x01) << 10); |
| 3600 | A = VT + 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3601 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3602 | /* Vertical display enable end */ |
| 3603 | VDE = crdata[10] | |
| 3604 | ((unsigned short)(cr_data & 0x02) << 7) | |
| 3605 | ((unsigned short)(cr_data & 0x40) << 3) | |
| 3606 | ((unsigned short)(sr_data & 0x02) << 9); |
| 3607 | E = VDE + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3608 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3609 | /* Vertical retrace (=sync) start */ |
| 3610 | VRS = crdata[8] | |
| 3611 | ((unsigned short)(cr_data & 0x04) << 6) | |
| 3612 | ((unsigned short)(cr_data & 0x80) << 2) | |
| 3613 | ((unsigned short)(sr_data & 0x08) << 7); |
| 3614 | F = VRS + 1 - E; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3615 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3616 | cr_data2 = (crdata[16] & 0x01) << 5; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3617 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3618 | /* Vertical blank start */ |
| 3619 | VBS = crdata[11] | |
| 3620 | ((unsigned short)(cr_data & 0x08) << 5) | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3621 | ((unsigned short)(cr_data2 & 0x20) << 4) | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3622 | ((unsigned short)(sr_data & 0x04) << 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3623 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3624 | /* Vertical blank end */ |
| 3625 | VBE = crdata[12] | ((unsigned short)(sr_data & 0x10) << 4); |
| 3626 | temp = VBE - ((E - 1) & 511); |
| 3627 | B = (temp > 0) ? temp : (temp + 512); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3628 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3629 | /* Vertical retrace (=sync) end */ |
| 3630 | VRE = (crdata[9] & 0x0f) | ((sr_data & 0x20) >> 1); |
| 3631 | temp = VRE - ((E + F - 1) & 31); |
| 3632 | C = (temp > 0) ? temp : (temp + 32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3633 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3634 | D = B - F - C; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3635 | |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3636 | if(writeres) var->yres = yres = E; |
| 3637 | var->upper_margin = D; |
| 3638 | var->lower_margin = F; |
| 3639 | var->vsync_len = C; |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3640 | |
| 3641 | if((xres == 320) && ((yres == 200) || (yres == 240))) { |
| 3642 | /* Terrible hack, but correct CRTC data for |
| 3643 | * these modes only produces a black screen... |
| 3644 | * (HRE is 0, leading into a too large C and |
| 3645 | * a negative D. The CRT controller does not |
| 3646 | * seem to like correcting HRE to 50) |
| 3647 | */ |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3648 | var->left_margin = (400 - 376); |
| 3649 | var->right_margin = (328 - 320); |
| 3650 | var->hsync_len = (376 - 328); |
Thomas Winischhofer | 544393f | 2005-09-09 13:04:45 -0700 | [diff] [blame] | 3651 | |
| 3652 | } |
| 3653 | |
| 3654 | } |
| 3655 | |
| 3656 | |
| 3657 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3658 | |