74 #ifdef CONFIG_FB_SIS_300
78 #ifdef CONFIG_FB_SIS_315
82 #define SiS_I2CDELAY 1000
83 #define SiS_I2CDELAYSHORT 150
85 static unsigned short SiS_GetBIOSLCDResInfo(
struct SiS_Private *SiS_Pr);
86 static void SiS_SetCH70xx(
struct SiS_Private *SiS_Pr,
unsigned short reg,
unsigned char val);
120 SiS_SetRegSR11ANDOR(
struct SiS_Private *SiS_Pr,
unsigned short DataAND,
unsigned short DataOR)
133 #ifdef CONFIG_FB_SIS_315
134 static unsigned char *
138 unsigned char *myptr =
NULL;
139 unsigned short romindex = 0,
reg = 0,
idx = 0;
157 myptr = (
unsigned char *)&SiS_LCDStruct661[
idx];
162 myptr = &ROMAddr[romindex];
168 static unsigned short
172 unsigned short romptr = 0;
196 SiS_AdjustCRT2Rate(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex,
197 unsigned short RRTI,
unsigned short *
i)
199 unsigned short checkmask=0, modeid, infoflag;
262 for(; SiS_Pr->
SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) {
263 infoflag = SiS_Pr->
SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag;
264 if(infoflag & checkmask)
return true;
271 for((*i) = 0; ; (*i)++) {
272 if(SiS_Pr->
SiS_RefIndex[RRTI + (*i)].ModeID != modeid)
break;
273 infoflag = SiS_Pr->
SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag;
274 if(infoflag & checkmask)
return true;
286 unsigned short RRTI,
i,backup_i;
287 unsigned short modeflag,
index,
temp,backupindex;
288 static const unsigned short LCDRefreshIndex[] = {
289 0x00, 0x00, 0x01, 0x01,
290 0x01, 0x01, 0x01, 0x01,
291 0x01, 0x01, 0x01, 0x01,
292 0x01, 0x01, 0x01, 0x01,
293 0x00, 0x00, 0x00, 0x00
297 if(ModeNo == 0xfe)
return 0;
311 if(ModeNo < 0x14)
return 0xFFFF;
316 if(index > 0) index--;
326 temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)];
327 if(index > temp) index =
temp;
345 if(backupindex <= 1) RRTI++;
352 if(SiS_Pr->
SiS_RefIndex[RRTI + i].ModeID != ModeNo)
break;
355 if(temp < SiS_Pr->SiS_ModeType)
break;
358 }
while(index != 0xFFFF);
371 if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i))) {
384 SiS_SaveCRT2Info(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo)
399 #ifdef CONFIG_FB_SIS_300
407 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
410 if(temp1 & temp)
return true;
423 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
426 if(temp1 & temp)
return true;
440 while (delaytime-- > 0)
444 #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
452 #ifdef CONFIG_FB_SIS_315
457 SiS_GenericDelay(SiS_Pr, 6623);
462 #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
464 SiS_ShortDelay(
struct SiS_Private *SiS_Pr,
unsigned short delay)
467 SiS_GenericDelay(SiS_Pr, 66);
473 SiS_PanelDelay(
struct SiS_Private *SiS_Pr,
unsigned short DelayTime)
475 #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
477 unsigned short PanelID, DelayIndex, Delay=0;
482 #ifdef CONFIG_FB_SIS_300
489 DelayIndex = PanelID >> 4;
490 if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) {
493 if(DelayTime >= 2) DelayTime -= 2;
494 if(!(DelayTime & 0x01)) {
500 if(ROMAddr[0x220] & 0x40) {
501 if(!(DelayTime & 0x01)) Delay = (
unsigned short)ROMAddr[0x225];
502 else Delay = (
unsigned short)ROMAddr[0x226];
506 SiS_ShortDelay(SiS_Pr, Delay);
512 #ifdef CONFIG_FB_SIS_315
519 if(!(DelayTime & 0x01)) {
535 DelayIndex = PanelID & 0x0f;
537 DelayIndex = PanelID >> 4;
539 if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) {
542 if(DelayTime >= 2) DelayTime -= 2;
543 if(!(DelayTime & 0x01)) {
549 if(ROMAddr[0x13c] & 0x40) {
550 if(!(DelayTime & 0x01)) {
551 Delay = (
unsigned short)ROMAddr[0x17e];
553 Delay = (
unsigned short)ROMAddr[0x17f];
558 SiS_ShortDelay(SiS_Pr, Delay);
564 if(!(DelayTime & 0x01)) {
579 #ifdef CONFIG_FB_SIS_315
581 SiS_PanelDelayLoop(
struct SiS_Private *SiS_Pr,
unsigned short DelayTime,
unsigned short DelayLoop)
584 for(i = 0; i < DelayLoop; i++) {
585 SiS_PanelDelay(SiS_Pr, DelayTime);
608 #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
625 #ifdef CONFIG_FB_SIS_300
632 SiS_WaitRetrace2(SiS_Pr, 0x25);
636 #ifdef CONFIG_FB_SIS_315
640 SiS_WaitRetrace2(SiS_Pr, 0x30);
649 unsigned short tempal,
temp,
i,
j;
652 for(i = 0; i < 3; i++) {
653 for(j = 0; j < 100; j++) {
656 if((tempal & 0x08))
continue;
659 if(!(tempal & 0x08))
continue;
681 #ifdef CONFIG_FB_SIS_300
703 #ifdef CONFIG_FB_SIS_315
716 #ifdef CONFIG_FB_SIS_315
727 #ifdef CONFIG_FB_SIS_315
732 if(SiS_CRT2IsLCD(SiS_Pr))
return true;
740 #ifdef CONFIG_FB_SIS_315
742 if((SiS_CRT2IsLCD(SiS_Pr)) ||
751 #ifdef CONFIG_FB_SIS_315
763 #ifdef CONFIG_FB_SIS_315
772 #ifdef CONFIG_FB_SIS_315
774 SiS_WeHaveBacklightCtrl(
struct SiS_Private *SiS_Pr)
783 #ifdef CONFIG_FB_SIS_315
792 if((flag == 0xe0) || (flag == 0xc0) ||
793 (flag == 0xb0) || (flag == 0x90))
return false;
799 #ifdef CONFIG_FB_SIS_315
811 #ifdef CONFIG_FB_SIS_315
823 #ifdef CONFIG_FB_SIS_315
837 if(flag & SetCRT2ToTV)
return true;
843 #ifdef CONFIG_FB_SIS_315
856 if(flag & SetCRT2ToLCD)
return true;
871 if((flag == 1) || (flag == 2))
return true;
881 if(SiS_HaveBridge(SiS_Pr)) {
885 if((flag == 0x80) || (flag == 0x20))
return true;
888 if((flag == 0x40) || (flag == 0x10))
return true;
897 unsigned short flag1;
909 #ifdef CONFIG_FB_SIS_300
913 unsigned int acpibase;
918 acpibase = sisfb_read_lpc_pci_dword(SiS_Pr, 0x74);
920 if(!acpibase)
return;
927 if(!(myvbinfo & SetCRT2ToTV)) temp |= 0x0100;
935 unsigned short ModeIdIndex,
int checkcrt2mode)
937 unsigned short tempax, tempbx,
temp;
938 unsigned short modeflag, resinfo = 0;
952 if(SiS_HaveBridge(SiS_Pr)) {
960 #ifdef CONFIG_FB_SIS_315
1003 if(temp & EnableCHYPbPr) {
1047 if(!(tempbx & temp)) {
1065 if(tempbx & SetCRT2ToLCD) tempbx &= (clearmask |
SetCRT2ToLCD);
1078 if(tempbx & SetCRT2ToTV) {
1082 if(tempbx & SetCRT2ToLCD) {
1111 if((!(modeflag &
CRT2Mode)) && (checkcrt2mode)) {
1117 if(SiS_BridgeIsEnabled(SiS_Pr)) {
1118 if(!(tempbx & DriverMode)) {
1119 if(SiS_BridgeInSlavemode(SiS_Pr)) {
1127 if(!(tempbx & DisableCRT2Display)) {
1128 if(tempbx & DriverMode) {
1129 if(tempbx & SetSimuScanMode) {
1130 if((!(modeflag &
CRT2Mode)) && (checkcrt2mode)) {
1145 #ifdef CONFIG_FB_SIS_300
1188 switch((temp >> 4)) {
1208 unsigned short temp,
temp1, resinfo = 0, romindex = 0;
1213 if(!(SiS_Pr->
SiS_VBInfo & SetCRT2ToTV))
return;
1239 OutputSelect = ROMAddr[romindex];
1308 }
else if(temp1 & 0x04) {
1404 static unsigned short
1420 #ifdef CONFIG_FB_SIS_315
1421 unsigned char *ROMAddr;
1422 unsigned short temp;
1424 if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) {
1450 SiS_CheckScaling(
struct SiS_Private *SiS_Pr,
unsigned short resinfo,
1451 const unsigned char *nonscalingmodes)
1454 while(nonscalingmodes[i] != 0xff) {
1455 if(nonscalingmodes[i++] == resinfo) {
1468 unsigned short temp,modeflag,resinfo=0,modexres=0,modeyres=0;
1469 bool panelcanscale =
false;
1470 #ifdef CONFIG_FB_SIS_300
1472 static const unsigned char SiS300SeriesLCDRes[] =
1473 { 0, 1, 2, 3, 7, 4, 5, 8,
1474 0, 0, 10, 0, 0, 0, 0, 15 };
1476 #ifdef CONFIG_FB_SIS_315
1477 unsigned char *myptr =
NULL;
1505 if(temp == 0) temp = 0x02;
1515 #ifdef CONFIG_FB_SIS_300
1519 if(temp < 0x0f) temp &= 0x07;
1522 temp = SiS300SeriesLCDRes[
temp];
1527 #ifdef CONFIG_FB_SIS_315
1550 #ifdef CONFIG_FB_SIS_300
1592 #ifdef CONFIG_FB_SIS_315
1600 }
else if((myptr = GetLCDStructPtr661(SiS_Pr))) {
1687 SiS_GetLCDInfoBIOS(SiS_Pr);
1708 SiS_GetLCDInfoBIOS(SiS_Pr);
1728 SiS_GetLCDInfoBIOS(SiS_Pr);
1735 SiS_GetLCDInfoBIOS(SiS_Pr);
1742 SiS_GetLCDInfoBIOS(SiS_Pr);
1749 SiS_GetLCDInfoBIOS(SiS_Pr);
1766 SiS_GetLCDInfoBIOS(SiS_Pr);
1773 SiS_GetLCDInfoBIOS(SiS_Pr);
1793 SiS_GetLCDInfoBIOS(SiS_Pr);
1800 SiS_GetLCDInfoBIOS(SiS_Pr);
1884 static const unsigned char nonscalingmodes[] = {
1887 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1891 static const unsigned char nonscalingmodes[] = {
1896 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1900 static const unsigned char nonscalingmodes[] = {
1905 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1912 static const unsigned char nonscalingmodes[] = {
1917 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1927 static const unsigned char nonscalingmodes[] = {
1932 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1936 static const unsigned char nonscalingmodes[] = {
1941 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1952 static const unsigned char nonscalingmodes[] = {
1957 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1969 static const unsigned char nonscalingmodes[] = {
1975 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1979 static const unsigned char nonscalingmodes[] = {
1985 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1989 static const unsigned char nonscalingmodes[] = {
1995 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2007 static const unsigned char nonscalingmodes[] = {
2013 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2017 static const unsigned char nonscalingmodes[] = {
2023 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2029 #ifdef CONFIG_FB_SIS_300
2039 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
2040 if(!(ROMAddr[0x235] & 0x02)) {
2096 if(ModeNo == 0x12) {
2100 }
else if(ModeNo > 0x13) {
2119 }
else if(ModeNo > 0x13) {
2140 printk(
KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n",
2151 unsigned short RefreshRateTableIndex)
2153 unsigned short CRT2Index, VCLKIndex = 0, VCLKIndexGEN = 0, VCLKIndexGENCRT = 0;
2154 unsigned short modeflag, resinfo, tempbx;
2155 const unsigned char *CHTVVCLKPtr =
NULL;
2157 if(ModeNo <= 0x13) {
2162 VCLKIndexGENCRT = VCLKIndexGEN;
2166 CRT2Index = SiS_Pr->
SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2167 VCLKIndexGEN = SiS_Pr->
SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2182 VCLKIndex = VCLKIndexGEN;
2199 default: VCLKIndex = VCLKIndexGEN;
2202 if(ModeNo <= 0x13) {
2204 if(SiS_Pr->
SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42;
2206 if(SiS_Pr->
SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00;
2210 if(VCLKIndex == 0) VCLKIndex = 0x41;
2211 if(VCLKIndex == 1) VCLKIndex = 0x43;
2212 if(VCLKIndex == 4) VCLKIndex = 0x44;
2217 }
else if(SiS_Pr->
SiS_VBInfo & SetCRT2ToTV) {
2233 VCLKIndex = VCLKIndexGENCRT;
2238 if(VCLKIndex == 0x14) VCLKIndex = 0x34;
2241 if(VCLKIndex == 0x17) VCLKIndex = 0x45;
2248 VCLKIndex = VCLKIndexGENCRT;
2253 if(VCLKIndex == 0x1b) VCLKIndex = 0x48;
2261 VCLKIndex = CRT2Index;
2295 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
2297 }
else if(SiS_Pr->
SiS_VBInfo & SetCRT2ToLCD) {
2305 #ifdef CONFIG_FB_SIS_300
2323 VCLKIndex = VCLKIndexGENCRT;
2328 if(VCLKIndex == 0x14) VCLKIndex = 0x2e;
2336 VCLKIndex = VCLKIndexGENCRT;
2341 if(VCLKIndex == 0x1b) VCLKIndex = 0x48;
2345 if(VCLKIndex == 0x0b) VCLKIndex = 0x40;
2346 if(VCLKIndex == 0x0d) VCLKIndex = 0x41;
2364 SiS_SetCRT2ModeRegs(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex)
2366 unsigned short i,
j, modeflag, tempah=0;
2368 #if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
2369 unsigned short tempbl;
2371 #ifdef CONFIG_FB_SIS_315
2373 unsigned short tempah2, tempbl2;
2394 #ifdef CONFIG_FB_SIS_300
2411 tempah = ((0x10 >> tempcl) | 0x80);
2413 }
else tempah = 0x80;
2421 #ifdef CONFIG_FB_SIS_315
2426 tempah = (0x08 >> tempcl);
2427 if (tempah == 0) tempah = 1;
2430 }
else tempah = 0x40;
2443 #ifdef CONFIG_FB_SIS_315
2473 tempah = (tempah << 5) & 0xFF;
2475 tempah = (tempah >> 5) & 0xFF;
2510 if(SiS_IsDualLink(SiS_Pr)) tempah |= 0x40;
2524 #ifdef CONFIG_FB_SIS_315
2535 if(SiS_Pr->
SiS_VBInfo & SetCRT2ToTV) tempah ^= 0x01;
2544 #ifdef CONFIG_FB_SIS_300
2566 #ifdef CONFIG_FB_SIS_315
2605 ((SiS_Pr->
SiS_ROMNew) && (!(ROMAddr[0x5b] & 0x04)))) {
2619 tempah = 0x30; tempah2 = 0xc0;
2620 tempbl = 0xcf; tempbl2 = 0x3f;
2622 tempah = tempah2 = 0x00;
2626 tempah = tempah2 = 0x00;
2632 tempah = 0x30; tempah2 = 0xc0;
2633 tempbl = 0xcf; tempbl2 = 0x3f;
2635 tempah = tempah2 = 0x00;
2637 tempbl = tempbl2 = 0xff;
2662 #ifdef CONFIG_FB_SIS_300
2685 #ifdef CONFIG_FB_SIS_315
2728 return ((
unsigned short)SiS_Pr->
SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO);
2732 SiS_GetCRT2ResInfo(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex)
2734 unsigned short xres, yres, modeflag=0, resindex;
2747 if(ModeNo <= 0x13) {
2760 if(yres == 350) yres = 400;
2763 if(ModeNo == 0x12) yres = 400;
2767 if(modeflag &
HalfDCLK) xres <<= 1;
2779 if(yres == 350) yres = 357;
2780 if(yres == 400) yres = 420;
2781 if(yres == 480) yres = 525;
2788 if(yres == 400) yres = 405;
2790 if(yres == 350) yres = 360;
2792 if(yres == 360) yres = 375;
2797 if(yres == 1024) yres = 1056;
2807 if(xres == 720) xres = 640;
2809 }
else if(xres == 720) xres = 640;
2831 SiS_GetCRT2Ptr(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex,
2832 unsigned short RefreshRateTableIndex,
unsigned short *CRT2Index,
2833 unsigned short *ResIndex)
2835 unsigned short tempbx=0, tempal=0, resinfo=0;
2837 if(ModeNo <= 0x13) {
2840 tempal = SiS_Pr->
SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2866 if(ModeNo >= 0x13) {
2867 tempal = SiS_Pr->
SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS;
2871 #ifdef CONFIG_FB_SIS_315
2940 *CRT2Index = tempbx;
2976 #ifdef CONFIG_FB_SIS_300
2993 #ifdef CONFIG_FB_SIS_300
3005 (*CRT2Index) = tempbx;
3006 (*ResIndex) = tempal & 0x1F;
3011 SiS_GetRAMDAC2DATA(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex,
3012 unsigned short RefreshRateTableIndex)
3014 unsigned short tempax=0, tempbx=0,
index, dotclock;
3015 unsigned short temp1=0, modeflag=0, tempcx=0;
3020 if(ModeNo <= 0x13) {
3029 dotclock = (modeflag &
Charx8Dot) ? 8 : 9;
3050 if(temp1 & 0x01) tempbx |= 0x0100;
3051 if(temp1 & 0x20) tempbx |= 0x0200;
3055 if(modeflag & HalfDCLK) tempax <<= 1;
3064 SiS_CalcPanelLinkTiming(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
3065 unsigned short ModeIdIndex,
unsigned short RefreshRateTableIndex)
3067 unsigned short ResIndex;
3073 if(SiS_Pr->
CModeFlag & HalfDCLK) ResIndex <<= 1;
3080 ResIndex = SiS_Pr->
SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS;
3082 if(ResIndex == 0x09) {
3107 SiS_GetCRT2DataLVDS(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex,
3108 unsigned short RefreshRateTableIndex)
3110 unsigned short CRT2Index, ResIndex, backup;
3113 SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex);
3129 #ifdef CONFIG_FB_SIS_315
3130 SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3142 SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
3143 &CRT2Index, &ResIndex);
3154 #ifdef CONFIG_FB_SIS_300
3178 SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3188 #ifdef CONFIG_FB_SIS_300
3190 if(ResIndex < 0x08) {
3202 SiS_GetCRT2Data301(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex,
3203 unsigned short RefreshRateTableIndex)
3205 unsigned char *ROMAddr =
NULL;
3206 unsigned short tempax, tempbx, modeflag, romptr=0;
3207 unsigned short resinfo, CRT2Index, ResIndex;
3210 #ifdef CONFIG_FB_SIS_315
3214 if(ModeNo <= 0x13) {
3223 #ifdef CONFIG_FB_SIS_315
3227 (resinfo661 >= 0) &&
3229 if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) {
3231 romptr += (resinfo661 * 10);
3247 SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex);
3259 if(modeflag & HalfDCLK) tempax <<= 1;
3265 SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3269 }
else if(SiS_Pr->
SiS_VBInfo & SetCRT2ToTV) {
3271 SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
3272 &CRT2Index,&ResIndex);
3298 if(modeflag & HalfDCLK) {
3302 tempax = ((TVPtr+ResIndex)->
RVBHRS2 >> 12) & 0x07;
3303 if((TVPtr+ResIndex)->RVBHRS2 & 0x8000) SiS_Pr->
SiS_RVBHRS2 -= tempax;
3353 if(modeflag & HalfDCLK) {
3371 }
else if(SiS_Pr->
SiS_VBInfo & SetCRT2ToLCD) {
3382 if(modeflag & HalfDCLK) tempax <<= 1;
3400 #ifdef CONFIG_FB_SIS_315
3403 SiS_Pr->
SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8);
3404 SiS_Pr->
SiS_VGAVT = (ROMAddr[romptr+4] << 4) | ((ROMAddr[romptr+3] & 0xf0) >> 4);
3405 SiS_Pr->
SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8);
3406 SiS_Pr->
SiS_VT = (ROMAddr[romptr+7] << 4) | ((ROMAddr[romptr+6] & 0xf0) >> 4);
3407 SiS_Pr->
SiS_RVBHRS2 = ROMAddr[romptr+8] | ((ROMAddr[romptr+9] & 0x0f) << 8);
3410 tempax = (ROMAddr[romptr+9] >> 4) & 0x07;
3411 if(ROMAddr[romptr+9] & 0x80) SiS_Pr->
SiS_RVBHRS2 -= tempax;
3433 SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
3434 &CRT2Index,&ResIndex);
3460 #ifdef CONFIG_FB_SIS_315
3461 case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data;
break;
3471 SiS_Pr->
SiS_HT = (LCDPtr+ResIndex)->LCDHT;
3472 SiS_Pr->
SiS_VT = (LCDPtr+ResIndex)->LCDVT;
3484 else if(SiS_Pr->
SiS_VGAVDE == 400) tempbx = 640;
3488 else if(SiS_Pr->
SiS_VGAVDE == 420) tempbx = 620;
3489 else if(SiS_Pr->
SiS_VGAVDE == 525) tempbx = 775;
3490 else if(SiS_Pr->
SiS_VGAVDE == 600) tempbx = 775;
3491 else if(SiS_Pr->
SiS_VGAVDE == 350) tempbx = 560;
3492 else if(SiS_Pr->
SiS_VGAVDE == 400) tempbx = 640;
3497 else if(SiS_Pr->
SiS_VGAVDE == 400) tempbx = 800;
3498 else if(SiS_Pr->
SiS_VGAVDE == 1024) tempbx = 960;
3502 else if(SiS_Pr->
SiS_VGAVDE == 375) tempbx = 800;
3503 else if(SiS_Pr->
SiS_VGAVDE == 405) tempbx = 864;
3508 else if(SiS_Pr->
SiS_VGAVDE == 400) tempbx = 1000;
3525 SiS_GetCRT2Data(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex,
3526 unsigned short RefreshRateTableIndex)
3532 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3536 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3538 SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3544 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3558 #ifdef CONFIG_FB_SIS_300
3582 SiS_GetLVDSDesData(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex,
3583 unsigned short RefreshRateTableIndex)
3585 unsigned short modeflag, ResIndex;
3625 if(ModeNo <= 0x13) ResIndex = SiS_Pr->
SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3626 else ResIndex = SiS_Pr->
SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3630 #ifdef CONFIG_FB_SIS_315
3673 }
else if((PanelDesPtr = SiS_GetLVDSDesPtr(SiS_Pr))) {
3705 #ifdef CONFIG_FB_SIS_300
3750 #ifdef CONFIG_FB_SIS_315
3771 if(!(modeflag & HalfDCLK)) SiS_Pr->
SiS_LCDHDES = 632;
3776 if(!(modeflag & HalfDCLK)) SiS_Pr->
SiS_LCDHDES = 320;
3778 #ifdef CONFIG_FB_SIS_315
3782 if(!(modeflag & HalfDCLK)) {
3800 #ifdef CONFIG_FB_SIS_315
3807 unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr);
3809 unsigned short temp;
3820 if((ROMAddr[romptr + 2] & (0x06 << 1)) && !drivermode) {
3838 #ifdef CONFIG_FB_SIS_315
3839 unsigned short tempah, pushax=0, modenum;
3841 unsigned short temp=0;
3849 #ifdef CONFIG_FB_SIS_300
3851 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
3855 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
3857 SiS_PanelDelay(SiS_Pr, 3);
3859 if(SiS_Is301B(SiS_Pr)) {
3861 SiS_ShortDelay(SiS_Pr,1);
3872 if( (!(SiS_CRT2IsLCD(SiS_Pr))) ||
3873 (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) {
3874 SiS_PanelDelay(SiS_Pr, 2);
3878 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
3886 #ifdef CONFIG_FB_SIS_315
3904 didpwd = SiS_HandlePWD(SiS_Pr);
3906 if( (modenum <= 0x13) ||
3911 if(custom1) SiS_PanelDelay(SiS_Pr, 3);
3925 SiS_PanelDelay(SiS_Pr, 3);
3930 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
3954 SiS_PanelDelay(SiS_Pr, 2);
3971 SiS_PanelDelay(SiS_Pr, 2);
3982 if(SiS_IsNotM650orLater(SiS_Pr)) {
3989 (!(SiS_CRT2IsLCD(SiS_Pr))) &&
3992 if(custom1) SiS_PanelDelay(SiS_Pr, 2);
3996 if(custom1) SiS_PanelDelay(SiS_Pr, 4);
4002 if(SiS_IsVAorLCD(SiS_Pr)) {
4003 SiS_PanelDelayLoop(SiS_Pr, 3, 20);
4017 #ifdef CONFIG_FB_SIS_300
4018 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4019 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4020 SiS_PanelDelay(SiS_Pr, 3);
4040 #ifdef CONFIG_FB_SIS_300
4042 if( (!(SiS_CRT2IsLCD(SiS_Pr))) ||
4043 (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) {
4044 SiS_PanelDelay(SiS_Pr, 2);
4045 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
4056 #ifdef CONFIG_FB_SIS_300
4064 SiS_WaitVBRetrace(SiS_Pr);
4066 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4067 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4068 SiS_PanelDelay(SiS_Pr, 3);
4073 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4074 SiS_WaitVBRetrace(SiS_Pr);
4078 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4079 SiS_PanelDelay(SiS_Pr, 3);
4094 if( (!(SiS_CRT2IsLCD(SiS_Pr))) ||
4095 (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) {
4096 SiS_PanelDelay(SiS_Pr, 2);
4097 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
4104 #ifdef CONFIG_FB_SIS_315
4106 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
4122 (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) {
4129 SiS_Chrontel701xBLOff(SiS_Pr);
4130 SiS_Chrontel701xOff(SiS_Pr);
4135 (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) {
4143 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4144 SiS_PanelDelay(SiS_Pr, 3);
4149 (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr))) ) {
4172 if(SiS_CRT2IsLCD(SiS_Pr)) {
4181 if(SiS_IsLCDOrLCDA(SiS_Pr)) {
4209 if(SiS_CRT2IsLCD(SiS_Pr)) {
4210 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4211 SiS_PanelDelay(SiS_Pr, 2);
4212 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
4237 unsigned short temp=0, tempah;
4238 #ifdef CONFIG_FB_SIS_315
4239 unsigned short temp1, pushax=0;
4240 bool delaylong =
false;
4249 #ifdef CONFIG_FB_SIS_300
4251 if(SiS_CRT2IsLCD(SiS_Pr)) {
4255 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00);
4258 if(!(SiS_CR36BIOSWord23d(SiS_Pr))) {
4259 SiS_PanelDelay(SiS_Pr, 0);
4265 (SiS_CRT2IsLCD(SiS_Pr))) {
4271 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4278 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4279 SiS_PanelDelay(SiS_Pr, 1);
4281 SiS_WaitVBRetrace(SiS_Pr);
4282 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00);
4289 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4299 if(SiS_CRT2IsLCD(SiS_Pr)) {
4301 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4302 SiS_PanelDelay(SiS_Pr, 1);
4316 #ifdef CONFIG_FB_SIS_315
4319 unsigned char r30=0,
r31=0, r32=0, r33=0, cr36=0;
4333 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
4336 if(SiS_LCDAEnabled(SiS_Pr)) {
4337 if(SiS_TVEnabled(SiS_Pr)) tempah = 0x18;
4353 didpwd = SiS_HandlePWD(SiS_Pr);
4355 if(SiS_IsVAorLCD(SiS_Pr)) {
4358 SiS_PanelDelayLoop(SiS_Pr, 3, 2);
4360 SiS_PanelDelayLoop(SiS_Pr, 3, 2);
4362 SiS_GenericDelay(SiS_Pr, 17664);
4366 SiS_PanelDelayLoop(SiS_Pr, 3, 2);
4368 SiS_GenericDelay(SiS_Pr, 17664);
4374 SiS_PanelDelayLoop(SiS_Pr, 3, 10);
4383 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4386 if(!(SiS_LCDAEnabled(SiS_Pr))) temp |= 0x20;
4397 SiS_PanelDelay(SiS_Pr, 2);
4410 if( (SiS_LCDAEnabled(SiS_Pr)) ||
4411 (SiS_CRT2IsLCD(SiS_Pr)) ) {
4428 SiS_PanelDelay(SiS_Pr, 2);
4437 SiS_GenericDelay(SiS_Pr, 2048);
4448 unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr);
4455 if(ROMAddr[romptr + 1] & 0x10) SiS_Pr->
EMI_30 = 0x40;
4487 switch((cr36 & 0x0f)) {
4492 r31 = 0x05; r32 = 0x60; r33 = 0x33;
4493 if((cr36 & 0xf0) == 0x30) {
4494 r31 = 0x0d; r32 = 0x70; r33 = 0x40;
4501 r31 = 0x12; r32 = 0xd0; r33 = 0x6b;
4503 r31 = 0x0d; r32 = 0x70; r33 = 0x6b;
4510 r31 = 0x05; r32 = 0x60; r33 = 0x00;
4512 r31 = 0x0d; r32 = 0x70; r33 = 0x40;
4519 r31 = 0x05; r32 = 0x60; r33 = 0x00;
4528 if((cr36 & 0x0f) == 0x09) {
4529 r30 = 0x60;
r31 = 0x05; r32 = 0x60; r33 = 0x00;
4535 if((cr36 & 0x0f) == 0x03) {
4536 r30 = 0x20;
r31 = 0x12; r32 = 0xd0; r33 = 0x6b;
4542 if((cr36 & 0x0f) == 0x02) {
4552 if(!(SiS_Pr->
OverruleEMI && (!r30) && (!
r31) && (!r32) && (!r33))) {
4554 SiS_GenericDelay(SiS_Pr, 2048);
4564 if( (SiS_LCDAEnabled(SiS_Pr)) ||
4565 (SiS_CRT2IsLCD(SiS_Pr)) ) {
4568 SiS_PanelDelayLoop(SiS_Pr, 3, 5);
4570 SiS_PanelDelayLoop(SiS_Pr, 3, 5);
4573 SiS_WaitVBRetrace(SiS_Pr);
4574 SiS_WaitVBRetrace(SiS_Pr);
4576 SiS_GenericDelay(SiS_Pr, 1280);
4586 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4587 if(SiS_IsVAorLCD(SiS_Pr)) {
4588 SiS_PanelDelayLoop(SiS_Pr, 3, 10);
4590 SiS_PanelDelayLoop(SiS_Pr, 3, 10);
4592 SiS_WaitVBRetrace(SiS_Pr);
4594 SiS_GenericDelay(SiS_Pr, 2048);
4595 SiS_WaitVBRetrace(SiS_Pr);
4611 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4622 if(SiS_CRT2IsLCD(SiS_Pr)) {
4623 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00);
4624 SiS_PanelDelay(SiS_Pr, 0);
4629 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4631 if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
4639 if(!(temp & 0x80)) {
4646 SiS_VBLongWait(SiS_Pr);
4651 SiS_VBLongWait(SiS_Pr);
4654 if(SiS_CRT2IsLCD(SiS_Pr)) {
4655 SiS_PanelDelay(SiS_Pr, 1);
4656 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00);
4666 #ifdef CONFIG_FB_SIS_300
4668 if(SiS_CRT2IsLCD(SiS_Pr)) {
4670 SiS_PanelDelay(SiS_Pr, 1);
4671 SiS_PanelDelay(SiS_Pr, 1);
4672 SiS_PanelDelay(SiS_Pr, 1);
4674 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00);
4675 if(!(SiS_CR36BIOSWord23d(SiS_Pr))) {
4676 SiS_PanelDelay(SiS_Pr, 0);
4684 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4691 if(!(SiS_CRT2IsLCD(SiS_Pr))) {
4692 SiS_WaitVBRetrace(SiS_Pr);
4697 if(SiS_CRT2IsLCD(SiS_Pr)) {
4700 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4701 SiS_PanelDelay(SiS_Pr, 1);
4702 SiS_PanelDelay(SiS_Pr, 1);
4704 SiS_WaitVBRetrace(SiS_Pr);
4705 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00);
4714 #ifdef CONFIG_FB_SIS_315
4716 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
4723 if(SiS_CRT2IsLCD(SiS_Pr)) {
4724 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00);
4725 SiS_PanelDelay(SiS_Pr, 0);
4737 SiS_Chrontel701xBLOff(SiS_Pr);
4746 if(SiS_IsLCDOrLCDA(SiS_Pr)) {
4753 if(!(temp1 & 0x80)) {
4759 SiS_Chrontel701xBLOn(SiS_Pr);
4764 if(SiS_CRT2IsLCD(SiS_Pr)) {
4777 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4782 if(SiS_IsTVOrYPbPrOrScart(SiS_Pr)) {
4783 SiS_Chrontel701xOn(SiS_Pr);
4786 (SiS_IsLCDOrLCDA(SiS_Pr)) ) {
4787 SiS_ChrontelDoSomething1(SiS_Pr);
4792 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4794 (SiS_IsLCDOrLCDA(SiS_Pr)) ) {
4795 SiS_Chrontel701xBLOn(SiS_Pr);
4796 SiS_ChrontelInitTVVSync(SiS_Pr);
4800 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4801 if(SiS_CRT2IsLCD(SiS_Pr)) {
4802 SiS_PanelDelay(SiS_Pr, 1);
4803 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00);
4822 SiS_SetCRT2Offset(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short ModeIdIndex,
4823 unsigned short RRTI)
4835 temp = (
unsigned char)(((offset >> 3) & 0xFF) + 1);
4836 if(offset & 0x07) temp++;
4842 SiS_SetCRT2Sync(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo,
unsigned short RefreshRateTableIndex)
4844 unsigned short tempah=0, tempbl, infoflag;
4851 infoflag = SiS_Pr->
SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4860 }
else tempah = infoflag >> 8;
4898 #ifdef CONFIG_FB_SIS_300
4902 tempah = infoflag >> 8;
4907 tempbl = (tempah >> 6) & 0x03;
4921 tempah = ((infoflag >> 8) & 0xc0) | 0x20;
4931 #ifdef CONFIG_FB_SIS_315
4938 tempah = infoflag >> 8;
4944 tempah = infoflag >> 8;
4948 tempbl = (tempah >> 6) & 0x03;
4965 tempah = tempbl = infoflag >> 8;
4969 if(ModeNo <= 0x13) {
4977 tempbl = (tempah >> 6) & 0x03;
4987 if(SiS_Pr->
SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0;
5009 #ifdef CONFIG_FB_SIS_300
5011 SiS_SetCRT2FIFO_300(
struct SiS_Private *SiS_Pr,
unsigned short ModeNo)
5014 unsigned short temp,
index, modeidindex, refreshratetableindex;
5015 unsigned short VCLK = 0,
MCLK, colorth = 0,
data2 = 0;
5016 unsigned short tempbx, tempcl, CRT1ModeNo, CRT2ModeNo, SelectRate_backup;
5017 unsigned int data, pci50, pciA0;
5018 static const unsigned char colortharray[] = {
5030 refreshratetableindex =
SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex);
5032 if(CRT1ModeNo >= 0x13) {
5039 if(!colorth) colorth++;
5054 if(CRT1ModeNo >= 0x13) {
5068 data2 = temp - ((colorth * VCLK) /
MCLK);
5070 temp = (28 * 16) %
data2;
5076 SiS_GetFIFOThresholdIndex300(SiS_Pr, &tempbx, &tempcl);
5077 data = SiS_GetFIFOThresholdB300(tempbx, tempcl);
5081 pci50 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50);
5082 pciA0 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xa0);
5086 index = (
unsigned short)(((pciA0 >> 28) & 0x0f) * 3);
5087 index += (
unsigned short)(((pci50 >> 9)) & 0x03);
5097 index = (pci50 >> 1) & 0x07;
5099 if(pci50 & 0x01) index += 6;
5100 if(!(pciA0 & 0x01)) index += 24;
5106 data = SiS_GetLatencyFactor630(SiS_Pr, index) + 15;
5118 CRT2ModeNo = ModeNo;
5121 refreshratetableindex =
SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex);
5124 index =
SiS_GetVCLK2Ptr(SiS_Pr, CRT2ModeNo, modeidindex, refreshratetableindex);
5129 if(ROMAddr[0x220] & 0x01) {
5130 VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8);
5145 if(!colorth) colorth++;
5147 data = data * VCLK * colorth;
5148 temp = data % (
MCLK << 4);
5149 data = data / (
MCLK << 4);
5152 if(data < 6) data = 6;
5153 else if(data > 0x14) data = 0x14;