init301.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:314k
- tempcx = 0x0061; /* TW: BIOS; Was 0x0078; */
- }
- temp = (tempbx & 0x00FF) ;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4B,temp);
- temp = (tempcx & 0x00FF) ;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4C,temp);
- tempbx &= 0x0300;
- temp = (tempcx & 0xFF00) >> 8;
- temp = (temp & 0x0003) << 2;
- temp |= (tempbx >> 8);
- if(HwDeviceExtension->jChipType < SIS_315H) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4D,temp);
- } else {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4D,0xF0,temp);
- }
- temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x43);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,(USHORT)(temp - 3));
- }
- temp = 0;
- if((HwDeviceExtension->jChipType == SIS_630)||
- (HwDeviceExtension->jChipType == SIS_730)) {
- temp = 0x35;
- } else if(HwDeviceExtension->jChipType >= SIS_315H) {
- temp = 0x38;
- }
- if(temp) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,temp) & 0x40) {
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF);
- temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp - 1);
- }
- }
- }
- }
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
- if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,0x00);
- }
- }
- #endif
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) return;
- } else {
- /* TW: !!! The following is a duplicate, done for LCDA as well (see above) */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if((ModeNo == 0x4a) || (ModeNo == 0x38)) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72);
- }
- }
- }
- }
- return;
- }
- }
- /* TW: From here: Part2 LCD setup */
- tempbx = SiS_Pr->SiS_HDE;
- /* TW: Inserted from 650/301LVx 1.10.6s */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1;
- }
- tempbx--; /* RHACTE=HDE-1 */
- temp = tempbx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2C,temp);
- temp = (tempbx & 0xFF00) >> 8;
- temp <<= 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,temp);
- temp = 0x01;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
- if(SiS_Pr->SiS_ModeType == ModeEGA) {
- if(SiS_Pr->SiS_VGAHDE >= 1024) {
- temp = 0x02;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
- temp = 0x01;
- }
- }
- }
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,temp);
- tempbx = SiS_Pr->SiS_VDE; /* RTVACTEO=(VDE-1)&0xFF */
- push1 = tempbx;
- tempbx--;
- temp = tempbx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x03,temp);
- temp = ((tempbx & 0xFF00) >> 8) & 0x07;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,temp);
- tempcx = SiS_Pr->SiS_VT;
- push2 = tempcx;
- tempcx--;
- temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x19,temp);
- temp = (tempcx & 0xFF00) >> 8;
- temp <<= 5;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp |= 0x10;
- else {
- if(SiS_Pr->SiS_LCDInfo & LCDSync) /* TW: 630/301 BIOS checks this */
- temp |= 0x10;
- }
- } else {
- /* TW: Inserted from 630/301LVx 1.10.6s */
- if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
- if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {
- temp |= 0x10;
- }
- }
- }
- /* 630/301 does not do all this */
- if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- /* TW: Inserted from 650/301LVx 1.10.6s */
- temp |= (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37) >> 6);
- } else {
- tempbx = (tempbx & 0xFF00) | (SiS_Pr->SiS_LCDInfo & 0x0FF);
- if(tempbx & LCDSync) {
- tempbx &= (0xFF00 | LCDSyncBit);
- tempbx = (tempbx & 0xFF00) | ((tempbx & 0x00FF) >> LCDSyncShift);
- temp |= (tempbx & 0x00FF);
- }
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1A,temp);
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x09,0xF0);
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x0A,0xF0);
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB);
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF);
- if(HwDeviceExtension->jChipType >= SIS_315H) { /* ------------- 310 series ------------ */
- /* TW: Inserted this entire section from 650/301LV(x) BIOS */
- SiS_GetCRT2Part2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
- &CRT2Index,&resindex);
- switch(CRT2Index) {
- case Panel_1024x768 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; /* "Normal" */
- case Panel_1280x1024 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1280x1024_1; break;
- case Panel_1400x1050 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1400x1050_1; break;
- case Panel_1600x1200 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1600x1200_1; break;
- case Panel_1024x768 + 16 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2; break; /* Non-Expanding */
- case Panel_1280x1024 + 16: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1280x1024_2; break;
- case Panel_1400x1050 + 16: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1400x1050_2; break;
- case Panel_1600x1200 + 16: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1600x1200_2; break;
- case Panel_1024x768 + 32 : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break; /* VESA Timing */
- case Panel_1280x1024 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1280x1024_3; break;
- case Panel_1400x1050 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1400x1050_3; break;
- case Panel_1600x1200 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1600x1200_3; break;
- default: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break;
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]);
- for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
- }
- for(j = 0x1c; j <= 0x1d; i++, j++ ) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
- }
- for(j = 0x1f; j <= 0x21; i++, j++ ) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]);
- if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
- if(SiS_Pr->SiS_VGAVDE == 0x20d) {
- temp = 0xc3;
- if(SiS_Pr->SiS_ModeType <= ModeVGA) {
- temp++;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp += 2;
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0xb3);
- }
- if(SiS_Pr->SiS_VGAVDE == 0x1a4) {
- temp = 0x4d;
- if(SiS_Pr->SiS_ModeType <= ModeVGA) {
- temp++;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++;
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
- }
- }
- /* TW: Inserted from 650/301LVx 1.10.6s: */
- /* !!! This is a duplicate, done for LCDA as well - see above */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xfc,0x03);
- temp = 1;
- if(ModeNo<=0x13) temp = 3;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp);
- }
- }
- } else { /* ------------- 300 series ----------- */
- tempcx++;
- tempbx = 768;
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) {
- tempbx = 1024;
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) {
- tempbx = 1200;
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) {
- if(tempbx != SiS_Pr->SiS_VDE) {
- tempbx = 960;
- }
- }
- }
- }
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) {
- tempbx = SiS_Pr->SiS_VDE - 1;
- tempcx--;
- }
- tempax = 1;
- if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) {
- if(tempbx != SiS_Pr->SiS_VDE){
- tempax = tempbx;
- if(tempax < SiS_Pr->SiS_VDE) {
- tempax = 0;
- tempcx = 0;
- } else {
- tempax -= SiS_Pr->SiS_VDE;
- }
- tempax >>= 1;
- }
- tempcx -= tempax; /* lcdvdes */
- tempbx -= tempax; /* lcdvdee */
- } else {
- tempax >>= 1;
- tempcx -= tempax; /* lcdvdes */
- tempbx -= tempax; /* lcdvdee */
- }
- temp = tempcx & 0x00FF; /* RVEQ1EQ=lcdvdes */
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,temp);
- temp = tempbx & 0x00FF; /* RVEQ2EQ=lcdvdee */
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,temp);
- temp = ((tempbx & 0xFF00) >> 8 ) << 3;
- temp |= ((tempcx & 0xFF00) >> 8);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp);
- tempbx = push2;
- tempax = push1;
- tempcx = tempbx;
- tempcx -= tempax;
- tempcx >>= 4;
- tempbx += tempax;
- tempbx >>= 1;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx -= 10;
- temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,temp);
- temp = ((tempbx & 0xFF00) >> 8) << 4;
- tempbx += (tempcx + 1);
- temp |= (tempbx & 0x000F);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp);
- /* TW: Code from 630/301B (I+II) BIOS */
- if( ( ( (HwDeviceExtension->jChipType == SIS_630) ||
- (HwDeviceExtension->jChipType == SIS_730) ) &&
- (HwDeviceExtension->jChipRevision > 2) ) &&
- (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) &&
- (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) &&
- (!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) ) {
- if(ModeNo == 0x13) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xB9);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0xCC);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xA6);
- } else {
- if((crt2crtc & 0x3F) == 4) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x2B);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x13);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xE5);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0x08);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xE2);
- }
- }
- }
- /* TW: Inserted missing code from 630/301B BIOS: (II: 3258) */
- if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) {
- crt2crtc &= 0x1f;
- tempcx = 0;
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
- if (SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- tempcx += 7;
- }
- }
- tempcx += crt2crtc;
- if (crt2crtc >= 4) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xff);
- }
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- if(crt2crtc == 4) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x28);
- }
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x18);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]);
- }
- tempcx = (SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE) >> 2; /* (HT-HDE)>>2 */
- tempbx = SiS_Pr->SiS_HDE + 7; /* lcdhdee */
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- tempbx += 2;
- }
- push1 = tempbx;
- temp = tempbx & 0x00FF; /* RHEQPLE=lcdhdee */
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,temp);
- temp = (tempbx & 0xFF00) >> 8;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,temp);
- temp = 7;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- temp += 2;
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1F,temp); /* RHBLKE=lcdhdes */
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x20,0x0F);
- tempbx += tempcx;
- push2 = tempbx;
- temp = tempbx & 0xFF; /* RHBURSTS=lcdhrs */
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) {
- if(SiS_Pr->SiS_HDE == 1280) temp = 0x47;
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1C,temp);
- temp = ((tempbx & 0xFF00) >> 8) << 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,temp);
- tempbx = push2;
- tempcx <<= 1;
- tempbx += tempcx;
- temp = tempbx & 0x00FF; /* RHSYEXP2S=lcdhre */
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,temp);
- if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
- if(SiS_Pr->SiS_VGAVDE == 525) {
- if(SiS_Pr->SiS_ModeType <= ModeVGA)
- temp=0xC6;
- else
- temp=0xC3;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0xB3);
- } else if(SiS_Pr->SiS_VGAVDE == 420) {
- if(SiS_Pr->SiS_ModeType <= ModeVGA)
- temp=0x4F;
- else
- temp=0x4D; /* 650: 4e */
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
- }
- }
- } /* HwDeviceExtension */
- }
- USHORT
- SiS_GetVGAHT2(SiS_Private *SiS_Pr)
- {
- ULONG tempax,tempbx;
- tempbx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX) & 0xFFFF;
- tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT;
- tempax = (tempax * SiS_Pr->SiS_HT) / tempbx;
- return((USHORT) tempax);
- }
- /* TW: Set 301 Macrovision(tm) registers */
- /* TW: Double-Checked against 650/301LV, 650/301LVx and 630/301B BIOS */
- void
- SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
- USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp;
- #ifdef oldHV
- USHORT i;
- const UCHAR *tempdi;
- #endif
- USHORT modeflag;
- /* TW: Inserted from 650/301LVx 1.10.6s */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
- if(ModeNo<=0x13)
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x00,0x00);
- if(SiS_Pr->SiS_VBInfo & SetPALTV) {
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA);
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8);
- } else {
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xF5);
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xB7);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xF6);
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xBf);
- }
- }
- temp = 0;
- if((HwDeviceExtension->jChipType == SIS_630)||
- (HwDeviceExtension->jChipType == SIS_730)) {
- temp = 0x35;
- } else if(HwDeviceExtension->jChipType >= SIS_315H) {
- temp = 0x38;
- }
- if(temp) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,temp) & 0x40){
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA);
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8);
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x3D,0xA8);
- }
- }
- }
- }
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
- tempdi = SiS_Pr->SiS_HiTVGroup3Data;
- if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
- tempdi = SiS_Pr->SiS_HiTVGroup3Simu;
- if(!(modeflag & Charx8Dot)) {
- tempdi = SiS_Pr->SiS_HiTVGroup3Text;
- }
- }
- for(i=0; i<=0x3E; i++){
- SiS_SetReg1(SiS_Pr->SiS_Part3Port,i,tempdi[i]);
- }
- }
- #endif
- return;
- }
- /* TW: Set 301 VGA2 registers */
- /* TW: Double-Checked against 650/301LV(x) and 630/301B BIOS */
- void
- SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
- USHORT ModeIdIndex,USHORT RefreshRateTableIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT tempax,tempcx,tempbx,modeflag,temp,temp2;
- ULONG tempebx,tempeax,templong;
- if(ModeNo<=0x13)
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- /* TW: From 650/301LVx 1.10.6s BIOS */
- if(SiS_Pr->SiS_VBType & (VB_SIS30xLV | VB_SIS30xNEW)) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x24,0x0e);
- }
- }
- if(SiS_Pr->SiS_VBType & VB_SIS30xNEW) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f);
- }
- }
- /* TW: From 650/301LV BIOS */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- /* TW: This is a duplicate; done at the end, too */
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) {
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
- }
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
- return;
- }
- temp = SiS_Pr->SiS_RVBHCFACT;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x13,temp);
- tempbx = SiS_Pr->SiS_RVBHCMAX;
- temp = tempbx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x14,temp);
- temp2 = (((tempbx & 0xFF00) >> 8) << 7) & 0x00ff;
- tempcx = SiS_Pr->SiS_VGAHT - 1;
- temp = tempcx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x16,temp);
- temp = (((tempcx & 0xFF00) >> 8) << 3) & 0x00ff;
- temp2 |= temp;
- tempcx = SiS_Pr->SiS_VGAVT - 1;
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempcx -= 5;
- temp = tempcx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x17,temp);
- temp = temp2 | ((tempcx & 0xFF00) >> 8);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x15,temp);
- tempcx = SiS_Pr->SiS_VBInfo;
- tempbx = SiS_Pr->SiS_VGAHDE;
- if(modeflag & HalfDCLK) tempbx >>= 1;
- /* TW: New for 650/301LV and 630/301B */
- temp = 0xA0;
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
- temp = 0;
- if(tempbx > 800) {
- temp = 0xA0;
- if(tempbx != 1024) {
- temp = 0xC0;
- if(tempbx != 1280) temp = 0;
- }
- }
- } else
- #endif
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(tempbx <= 800) {
- temp = 0x80;
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD){
- temp = 0;
- if(tempbx > 800) temp = 0x60;
- }
- }
- } else {
- temp = 0x80;
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD){
- temp = 0;
- if(tempbx > 800) temp = 0x60;
- }
- }
- if(SiS_Pr->SiS_HiVision & 0x03) {
- temp = 0;
- if(SiS_Pr->SiS_VGAHDE == 1024) temp = 0x20;
- }
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) temp = 0;
- }
- if(SiS_Pr->SiS_VBType & VB_SIS301) {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024)
- temp |= 0x0A;
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp);
- tempebx = SiS_Pr->SiS_VDE;
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
- if(!(temp & 0xE0)) tempebx >>=1;
- }
- #endif
- tempcx = SiS_Pr->SiS_RVBHRS;
- temp = tempcx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x18,temp);
- tempeax = SiS_Pr->SiS_VGAVDE;
- tempcx |= 0x4000;
- if(tempeax <= tempebx){
- tempcx ^= 0x4000;
- } else {
- tempeax -= tempebx;
- }
- templong = (tempeax * 256 * 1024) % tempebx;
- tempeax = (tempeax * 256 * 1024) / tempebx;
- tempebx = tempeax;
- if(templong != 0) tempebx++;
- temp = (USHORT)(tempebx & 0x000000FF);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1B,temp);
- temp = (USHORT)((tempebx & 0x0000FF00) >> 8);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1A,temp);
- tempbx = (USHORT)(tempebx >> 16);
- temp = tempbx & 0x00FF;
- temp <<= 4;
- temp |= ((tempcx & 0xFF00) >> 8);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x19,temp);
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1C,0x28);
- tempbx = 0;
- tempax = SiS_Pr->SiS_VGAHDE;
- if(modeflag & HalfDCLK) tempax >>= 1;
- if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || (SiS_Pr->SiS_HiVision & 0x03)) {
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempax >>= 1;
- else if(tempax > 800) tempax -= 800;
- } else {
- if(tempax > 800) tempax -= 800;
- }
- }
- if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetPALTV)) && (!(SiS_Pr->SiS_HiVision & 0x03))) {
- if(tempax > 800) {
- tempbx = 8;
- if(tempax == 1024)
- tempax *= 25;
- else
- tempax *= 20;
- temp = tempax % 32;
- tempax /= 32;
- tempax--;
- if (temp!=0) tempax++;
- }
- }
- tempax--;
- temp = (tempax & 0xFF00) >> 8;
- temp &= 0x03;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1D,tempax & 0x00FF);
- temp <<= 4;
- temp |= tempbx;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1E,temp);
- temp = 0x0036;
- if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) &&
- (!(SiS_Pr->SiS_HiVision & 0x03))) {
- temp |= 0x01;
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- if(!(SiS_Pr->SiS_SetFlag & TVSimuMode))
- temp &= 0xFE;
- }
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0,temp);
- tempbx = SiS_Pr->SiS_HT;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1;
- }
- tempbx >>= 1;
- tempbx -= 2;
- temp = ((tempbx & 0x0700) >> 8) << 3;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp);
- temp = tempbx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x22,temp);
- if( (SiS_Pr->SiS_VBType & (VB_SIS30xLV | VB_SIS30xNEW)) &&
- (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) {
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x24,0x0e);
- }
- /* TW: 650 BIOS does this for all bridge types - assumingly wrong */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- /* TW: This is a duplicate; done for LCDA as well (see above) */
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) {
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
- }
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
- }
- } /* 301B */
- SiS_SetCRT2VCLK(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,HwDeviceExtension);
- }
- /* TW: Double-Checked against 650/301LV(x) and 630/301B BIOS */
- void
- SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT vclkindex;
- USHORT tempah;
- vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
- HwDeviceExtension);
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,tempah);
- tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,tempah);
- /* TW: New from 650/301LV, LVx BIOS */
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if((ModeNo == 0x4a) || (ModeNo == 0x38)) {
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0a,0x57);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0b,0x46);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1f,0xf6);
- }
- }
- }
- }
- } else { /* 650/301LVx does not do this anymore, jumps to SetRegs above - BUG? */
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,0x01);
- tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,tempah);
- tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,tempah);
- }
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x12,0x00);
- tempah = 0x08;
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
- tempah |= 0x20;
- }
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,tempah);
- }
- /* TW: Double-checked against 650/LVDS (1.10.07), 630/301B/LVDS/LVDS+CH, 650/301LVx (1.10.6s) BIOS */
- USHORT
- SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT tempbx;
- #ifdef SIS300
- const USHORT LCDXlat1VCLK300[4] = {VCLK65, VCLK65, VCLK65, VCLK65};
- const USHORT LCDXlat2VCLK300[4] = {VCLK108_2,VCLK108_2,VCLK108_2,VCLK108_2};
- const USHORT LVDSXlat2VCLK300[4]= {VCLK65, VCLK65, VCLK65, VCLK65};
- const USHORT LVDSXlat3VCLK300[4]= {VCLK65, VCLK65, VCLK65, VCLK65};
- #endif
- #ifdef SIS315H
- const USHORT LCDXlat1VCLK310[4] = {VCLK65+2, VCLK65+2, VCLK65+2, VCLK65+2};
- const USHORT LCDXlat2VCLK310[4] = {VCLK108_2+5,VCLK108_2+5,VCLK108_2+5,VCLK108_2+5};
- const USHORT LVDSXlat2VCLK310[4]= {VCLK65+2, VCLK65+2, VCLK65+2, VCLK65+2};
- const USHORT LVDSXlat3VCLK310[4]= {VCLK108_2+5,VCLK108_2+5,VCLK108_2+5,VCLK108_2+5};
- /* {VCLK65+2, VCLK65+2, VCLK65+2, VCLK65+2}; - 650/LVDS 1.10.07 */
- #endif
- const USHORT LCDXlat0VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40};
- const USHORT LVDSXlat1VCLK[4] = {VCLK40, VCLK40, VCLK40, VCLK40};
- USHORT CRT2Index,VCLKIndex=0;
- USHORT modeflag,resinfo;
- const UCHAR *CHTVVCLKPtr=NULL;
- const USHORT *LCDXlatVCLK1 = NULL;
- const USHORT *LCDXlatVCLK2 = NULL;
- const USHORT *LVDSXlatVCLK2 = NULL;
- const USHORT *LVDSXlatVCLK3 = NULL;
- #ifdef SIS315H
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- LCDXlatVCLK1 = LCDXlat1VCLK310;
- LCDXlatVCLK2 = LCDXlat2VCLK310;
- LVDSXlatVCLK2 = LVDSXlat2VCLK310;
- LVDSXlatVCLK3 = LVDSXlat3VCLK310;
- } else {
- #endif
- #ifdef SIS300
- LCDXlatVCLK1 = LCDXlat1VCLK300;
- LCDXlatVCLK2 = LCDXlat2VCLK300;
- LVDSXlatVCLK2 = LVDSXlat2VCLK300;
- LVDSXlatVCLK3 = LVDSXlat3VCLK300;
- #endif
- #ifdef SIS315H
- }
- #endif
- if(ModeNo<=0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
- CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) { /* 301 */
- if (SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
- CRT2Index >>= 6;
- if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)){ /* LCD */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* TW: Inserted from 630/301B BIOS */
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)
- VCLKIndex = LCDXlat0VCLK[CRT2Index];
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)
- VCLKIndex = LCDXlatVCLK1[CRT2Index];
- else
- VCLKIndex = LCDXlatVCLK2[CRT2Index];
- } else {
- /* TW: 650/301LV BIOS does not check expanding, 315 does */
- if( (HwDeviceExtension->jChipType > SIS_315PRO) ||
- (!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) ) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
- VCLKIndex = 0x19;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- VCLKIndex = 0x19;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
- VCLKIndex = 0x21;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
- VCLKIndex = LCDXlatVCLK1[CRT2Index];
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
- VCLKIndex = 0x45;
- if(resinfo == 0x09) VCLKIndex++;
- } else {
- VCLKIndex = LCDXlatVCLK2[CRT2Index];
- }
- } else {
- VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02)); /* Port 3cch */
- VCLKIndex = ((VCLKIndex >> 2) & 0x03);
- if(ModeNo > 0x13) {
- VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- }
- if(ModeNo <= 0x13) { /* TW: Inserted from 315 BIOS */
- if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42;
- }
- if(VCLKIndex == 0) VCLKIndex = 0x41;
- if(VCLKIndex == 1) VCLKIndex = 0x43;
- if(VCLKIndex == 4) VCLKIndex = 0x44;
- }
- }
- } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */
- if((SiS_Pr->SiS_IF_DEF_HiVision == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) {
- if(SiS_Pr->SiS_SetFlag & RPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2;
- else VCLKIndex = HiTVVCLK;
- if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
- if(modeflag & Charx8Dot) VCLKIndex = HiTVSimuVCLK;
- else VCLKIndex = HiTVTextVCLK;
- }
- } else {
- if(SiS_Pr->SiS_SetFlag & RPLLDIV2XO) VCLKIndex = TVVCLKDIV2;
- else VCLKIndex = TVVCLK;
- }
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- VCLKIndex += 25;
- }
- } else { /* RAMDAC2 */
- VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02));
- VCLKIndex = ((VCLKIndex >> 2) & 0x03);
- if(ModeNo > 0x13) {
- VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- VCLKIndex &= 0x3f;
- if( (HwDeviceExtension->jChipType == SIS_630) &&
- (HwDeviceExtension->jChipRevision >= 0x30)) {
- if(VCLKIndex == 0x14) VCLKIndex = 0x2e;
- }
- }
- }
- }
- } else { /* If not programming CRT2 */
- VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02));
- VCLKIndex = ((VCLKIndex >> 2) & 0x03);
- if(ModeNo > 0x13) {
- VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- VCLKIndex &= 0x3f;
- if( (HwDeviceExtension->jChipType != SIS_630) &&
- (HwDeviceExtension->jChipType != SIS_300) ) {
- if(VCLKIndex == 0x1b) VCLKIndex = 0x35;
- }
- }
- }
- }
- } else { /* LVDS */
- VCLKIndex = CRT2Index;
- if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { /* programming CRT2 */
- if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) {
- VCLKIndex &= 0x1f;
- tempbx = 0;
- if(SiS_Pr->SiS_VBInfo & SetPALTV) tempbx += 2;
- if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
- switch(tempbx) {
- case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break;
- case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break;
- case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break;
- case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break;
- }
- VCLKIndex = CHTVVCLKPtr[VCLKIndex];
- } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- VCLKIndex >>= 6;
- if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) ||
- (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480))
- VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)
- VCLKIndex = LVDSXlatVCLK2[VCLKIndex];
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)
- VCLKIndex = LVDSXlatVCLK2[VCLKIndex];
- else VCLKIndex = LVDSXlatVCLK3[VCLKIndex];
- } else {
- VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02));
- VCLKIndex = ((VCLKIndex >> 2) & 0x03);
- if(ModeNo > 0x13) {
- VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- if( (HwDeviceExtension->jChipType == SIS_630) &&
- (HwDeviceExtension->jChipRevision >= 0x30) ) {
- if(VCLKIndex == 0x14) VCLKIndex = 0x2e;
- }
- }
- }
- } else { /* if not programming CRT2 */
- VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02));
- VCLKIndex = ((VCLKIndex >> 2) & 0x03);
- if(ModeNo > 0x13) {
- VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if( (HwDeviceExtension->jChipType != SIS_630) &&
- (HwDeviceExtension->jChipType != SIS_300) ) {
- if(VCLKIndex == 0x1b) VCLKIndex = 0x35;
- }
- }
- }
- }
- }
- if(HwDeviceExtension->jChipType < SIS_315H) {
- VCLKIndex &= 0x3F;
- }
- return (VCLKIndex);
- }
- /* TW: Set 301 Palette address port registers */
- /* TW: Checked against 650/301LV BIOS */
- void
- SiS_SetGroup5(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr,
- UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex)
- {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
- if(SiS_Pr->SiS_ModeType == ModeVGA){
- if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))){
- SiS_EnableCRT2(SiS_Pr);
- SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex);
- }
- }
- return;
- }
- /* TW: Checked against 650/LVDS and 630/301B BIOS */
- void
- SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp,tempah,i,modeflag,j;
- USHORT ResInfo,DisplayType;
- const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL;
- if(ModeNo <= 0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- }
- temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
- &ResInfo,&DisplayType);
- if(temp == 0) return;
- /* TW: Inserted from 630/LVDS BIOS */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_Pr->SiS_SetFlag & CRT2IsVGA) return;
- }
- switch(DisplayType) {
- case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break;
- case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break;
- case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break;
- case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break;
- case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break;
- case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break;
- case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break;
- case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break;
- case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break;
- case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break;
- case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break;
- case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2_H; break;
- case 12: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1; break;
- case 13: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H; break;
- case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1; break;
- case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1_H; break;
- case 16: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2; break;
- case 17: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2_H; break;
- case 18: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break;
- case 19: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break;
- case 20: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break;
- case 21: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break;
- case 22: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x480_1; break; /* FSTN */
- case 23: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break;
- case 24: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break;
- case 25: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break;
- case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break;
- case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1; break;
- case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1_H; break;
- case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2; break;
- case 30: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2_H; break;
- case 36: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1; break;
- case 37: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1_H; break;
- case 38: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2; break;
- case 39: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2_H; break;
- }
- SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /*unlock cr0-7 */
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[0];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah);
- for(i=0x02,j=1;i<=0x05;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x06,j=5;i<=0x07;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x10,j=7;i<=0x11;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x15,j=9;i<=0x16;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x0A,j=11;i<=0x0C;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah);
- }
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[14];
- tempah &= 0xE0;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); /* TW: Modfied (650/LVDS); Was SetReg(tempah) */
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[14];
- tempah &= 0x01;
- tempah <<= 5;
- if(modeflag & DoubleScanMode){
- tempah |= 0x080;
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah);
- /* TW: Inserted from 650/LVDS BIOS */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(modeflag & HalfDCLK)
- SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f);
- }
- return;
- }
- #if 0 /* TW: Unused */
- /*301b*/
- void
- SiS_CHACRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex)
- {
- USHORT temp,tempah,i,modeflag,j;
- USHORT ResInfo,DisplayType;
- SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL;
- if(ModeNo<=0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
- }
- temp=SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
- &ResInfo,&DisplayType);
- if(temp==0){
- return;
- }
- switch(DisplayType) {
- case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break;
- case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break;
- case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break;
- case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break;
- case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break;
- case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break;
- case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break;
- case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break;
- case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break;
- case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break;
- case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break;
- case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2_H; break;
- case 12: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1; break;
- case 13: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H; break;
- case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1; break;
- case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1_H; break;
- case 16: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2; break;
- case 17: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2_H; break;
- case 18: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break;
- case 19: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break;
- case 20: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break;
- case 21: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break;
- case 22: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x480_1; break; /* FSTN */
- }
- tempah=(UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x11); /*unlock cr0-7 */
- tempah=tempah&0x7F;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x11,tempah);
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[0];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x0,tempah);
- for(i=0x02,j=1;i<=0x05;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x06,j=5;i<=0x07;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x10,j=7;i<=0x11;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x15,j=9;i<=0x16;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x0A,j=11;i<=0x0C;i++,j++){
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah);
- }
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[14];
- tempah=tempah&0x0E0;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah);
- tempah = (LVDSCRT1Ptr+ResInfo)->CR[14];
- tempah=tempah&0x01;
- tempah=tempah<<5;
- if(modeflag&DoubleScanMode){
- tempah=tempah|0x080;
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah);
- return;
- }
- #endif
- /* TW: Checked against 650/LVDS BIOS: modified for new panel resolutions */
- BOOLEAN
- SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,USHORT *ResInfo,
- USHORT *DisplayType)
- {
- USHORT tempbx,modeflag=0;
- USHORT Flag,CRT2CRTC;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- /* TW: Inserted from 650/LVDS BIOS */
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
- if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return 0;
- }
- }
- if(ModeNo <= 0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- CRT2CRTC = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- CRT2CRTC = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- }
- Flag = 1;
- tempbx = 0;
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
- Flag = 0;
- tempbx = 18;
- if(SiS_Pr->SiS_VBInfo & SetPALTV) tempbx += 2;
- if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx++;
- }
- }
- if(Flag) {
- tempbx = SiS_Pr->SiS_LCDResInfo;
- tempbx -= SiS_Pr->SiS_PanelMinLVDS;
- if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) {
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 6;
- if(modeflag & HalfDCLK) tempbx += 3;
- } else {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- tempbx = 14;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2;
- if(modeflag & HalfDCLK) tempbx++;
- } else if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
- tempbx = 12;
- if(modeflag & HalfDCLK) tempbx++;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
- tempbx = 23;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2;
- if(modeflag & HalfDCLK) tempbx++;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) {
- tempbx = 27;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2;
- if(modeflag & HalfDCLK) tempbx++;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
- tempbx = 36;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2;
- if(modeflag & HalfDCLK) tempbx++;
- }
- }
- }
- if(SiS_Pr->SiS_IF_DEF_FSTN){
- if(SiS_Pr->SiS_LCDResInfo==SiS_Pr->SiS_Panel320x480){
- tempbx=22;
- }
- }
- *ResInfo = CRT2CRTC & 0x3F;
- *DisplayType = tempbx;
- return 1;
- }
- /* TW: Checked against 650/LVDS (1.10a, 1.10.07), 630/301B (I/II) and 630/LVDS BIOS */
- void
- SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT tempah,tempal,pushax;
- USHORT vclkindex=0;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) return;
- }
- }
- if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) || (SiS_Pr->SiS_IF_DEF_TRUMPION == 1)) {
- SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
- tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- tempal &= 0x3F;
- if(tempal == 2) RefreshRateTableIndex--;
- vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,HwDeviceExtension);
- SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
- } else {
- vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,HwDeviceExtension);
- }
- tempal = 0x02B;
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
- if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- tempal += 3;
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86);
- pushax = tempal;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x20);
- tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
- tempal++;
- tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x10);
- tempal = pushax;
- tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
- tempal++;
- tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x00);
- tempal = pushax;
- tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
- tempal++;
- tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
- return;
- }
- #if 0 /* TW: Not used */
- void
- SiS_SetDefCRT2ExtRegs(SiS_Private *SiS_Pr, USHORT BaseAddr)
- {
- USHORT temp;
- if(SiS_Pr->SiS_IF_DEF_LVDS==0) {
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,0x40);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x10,0x80);
- temp=(UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16);
- temp &= 0xC3;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,temp);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x32,0x02);
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,0x00);
- }
- }
- #endif
- /* TW: Start of Chrontel 70xx functions ---------------------- */
- /* Set-up the Chrontel Registers */
- void
- SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex)
- {
- USHORT temp, tempbx, tempcl;
- USHORT TVType, resindex;
- const SiS_CHTVRegDataStruct *CHTVRegData = NULL;
- if(ModeNo <= 0x13)
- tempcl = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- else
- tempcl = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- TVType = 0;
- if(SiS_Pr->SiS_VBInfo & SetPALTV) TVType += 2;
- if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) TVType += 1;
- switch(TVType) {
- case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break;
- case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break;
- case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break;
- case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break;
- }
- resindex = tempcl & 0x3F;
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
- /* Chrontel 7005 */
- /* TW: We don't support modes >800x600 */
- if (resindex > 5) return;
- if(SiS_Pr->SiS_VBInfo & SetPALTV) {
- SiS_SetCH700x(SiS_Pr,0x4304); /* TW: 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/
- SiS_SetCH700x(SiS_Pr,0x6909); /* TW: Black level for PAL (105)*/
- } else {
- SiS_SetCH700x(SiS_Pr,0x0304); /* TW: upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/
- SiS_SetCH700x(SiS_Pr,0x7109); /* TW: Black level for NTSC (113)*/
- }
- temp = CHTVRegData[resindex].Reg[0];
- tempbx=((temp&0x00FF)<<8)|0x00; /* TW: Mode register */
- SiS_SetCH700x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[1];
- tempbx=((temp&0x00FF)<<8)|0x07; /* TW: Start active video register */
- SiS_SetCH700x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[2];
- tempbx=((temp&0x00FF)<<8)|0x08; /* TW: Position overflow register */
- SiS_SetCH700x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[3];
- tempbx=((temp&0x00FF)<<8)|0x0A; /* TW: Horiz Position register */
- SiS_SetCH700x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[4];
- tempbx=((temp&0x00FF)<<8)|0x0B; /* TW: Vertical Position register */
- SiS_SetCH700x(SiS_Pr,tempbx);
- /* TW: Set minimum flicker filter for Luma channel (SR1-0=00),
- minimum text enhancement (S3-2=10),
- maximum flicker filter for Chroma channel (S5-4=10)
- =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!)
- */
- SiS_SetCH700x(SiS_Pr,0x2801);
- /* TW: Set video bandwidth
- High bandwith Luma composite video filter(S0=1)
- low bandwith Luma S-video filter (S2-1=00)
- disable peak filter in S-video channel (S3=0)
- high bandwidth Chroma Filter (S5-4=11)
- =00110001=0x31
- */
- SiS_SetCH700x(SiS_Pr,0xb103); /* old: 3103 */
- /* TW: Register 0x3D does not exist in non-macrovision register map
- (Maybe this is a macrovision register?)
- */
- /* SiS_SetCH70xx(SiS_Pr,0x003D); */
- /* TW: Register 0x10 only contains 1 writable bit (S0) for sensing,
- all other bits a read-only. Macrovision?
- */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0010,0x1F);
- /* TW: Register 0x11 only contains 3 writable bits (S0-S2) for
- contrast enhancement (set to 010 -> gain 2 Yout = 9/8*(Yin-57) )
- */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0211,0xF8);
- /* TW: Clear DSEN
- */
- SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xEF);
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) { /* ---- NTSC ---- */
- if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) {
- if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on, no need to set FSCI */
- } else {
- if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */
- }
- }
- } else {
- if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE);
- } else {
- if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */
- SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x031C,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x0a1D,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x031F,0xF0);
- SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */
- }
- }
- }
- } else { /* ---- PAL ---- */
- /* TW: We don't play around with FSCI in PAL mode */
- if (resindex == 0x04) {
- SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */
- } else {
- SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
- SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */
- }
- }
- } else {
- /* Chrontel 7019 */
- /* TW: We don't support modes >1024x768 */
- if (resindex > 6) return;
- temp = CHTVRegData[resindex].Reg[0];
- tempbx=((temp & 0x00FF) <<8 ) | 0x00;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[1];
- tempbx=((temp & 0x00FF) <<8 ) | 0x01;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[2];
- tempbx=((temp & 0x00FF) <<8 ) | 0x02;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[3];
- tempbx=((temp & 0x00FF) <<8 ) | 0x04;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[4];
- tempbx=((temp & 0x00FF) <<8 ) | 0x03;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[5];
- tempbx=((temp & 0x00FF) <<8 ) | 0x05;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[6];
- tempbx=((temp & 0x00FF) <<8 ) | 0x06;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[7];
- tempbx=((temp & 0x00FF) <<8 ) | 0x07;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[8];
- tempbx=((temp & 0x00FF) <<8 ) | 0x08;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[9];
- tempbx=((temp & 0x00FF) <<8 ) | 0x15;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[10];
- tempbx=((temp & 0x00FF) <<8 ) | 0x1f;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[11];
- tempbx=((temp & 0x00FF) <<8 ) | 0x0c;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[12];
- tempbx=((temp & 0x00FF) <<8 ) | 0x0d;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[13];
- tempbx=((temp & 0x00FF) <<8 ) | 0x0e;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[14];
- tempbx=((temp & 0x00FF) <<8 ) | 0x0f;
- SiS_SetCH701x(SiS_Pr,tempbx);
- temp = CHTVRegData[resindex].Reg[15];
- tempbx=((temp & 0x00FF) <<8 ) | 0x10;
- SiS_SetCH701x(SiS_Pr,tempbx);
- }
- }
- void
- SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
- {
- UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71,
- 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d };
- UCHAR table28b4[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
- 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 };
- UCHAR table28c0[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef,
- 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 };
- UCHAR *tableptr = NULL;
- USHORT tempbh;
- int i;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- tableptr = table28c0;
- } else {
- tableptr = table28b4;
- }
- tempbh = SiS_GetCH701x(SiS_Pr,0x74);
- if((tempbh == 0xf6) || (tempbh == 0xc7)) {
- tempbh = SiS_GetCH701x(SiS_Pr,0x73);
- if(tempbh == 0xc8) {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) return;
- } else if(tempbh == 0xdb) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) return;
- }
- }
- for(i=0; i<0x0c; i++) {
- SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]);
- }
- SiS_Chrontel19f2(SiS_Pr);
- tempbh = SiS_GetCH701x(SiS_Pr,0x1e);
- tempbh |= 0xc0;
- SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e);
- }
- /* TW: Chrontel 701x functions ================================= */
- void
- SiS_Chrontel19f2(SiS_Private *SiS_Pr)
- {
- UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b };
- UCHAR table19e8[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
- UCHAR table19ed[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
- UCHAR *tableptr = NULL;
- int i;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- tableptr = table19ed;
- } else {
- tableptr = table19e8;
- }
- for(i=0; i<5; i++) {
- SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]);
- }
- }
- void
- SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr)
- {
- USHORT temp;
- /* TW: Enable Chrontel 7019 LCD panel backlight */
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- temp = SiS_GetCH701x(SiS_Pr,0x66);
- temp |= 0x20;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
- }
- }
- void
- SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
- {
- USHORT temp;
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- temp = SiS_GetCH701x(SiS_Pr,0x01);
- temp &= 0x3f;
- temp |= 0x80;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01);
- }
- SiS_SetCH701x(SiS_Pr,0x2049); /* TW: Enable TV path */
- temp = SiS_GetCH701x(SiS_Pr,0x49);
- if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- temp = SiS_GetCH701x(SiS_Pr,0x73);
- temp |= 0x60;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73);
- }
- temp = SiS_GetCH701x(SiS_Pr,0x47);
- temp &= 0x7f;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
- SiS_LongDelay(SiS_Pr,2);
- temp = SiS_GetCH701x(SiS_Pr,0x47);
- temp |= 0x80;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
- }
- }
- void
- SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr)
- {
- USHORT temp;
- /* TW: Disable Chrontel 7019 LCD panel backlight */
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- temp = SiS_GetCH701x(SiS_Pr,0x66);
- temp &= 0xDF;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
- }
- }
- void
- SiS_Chrontel701xOff(SiS_Private *SiS_Pr)
- {
- USHORT temp;
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- SiS_LongDelay(SiS_Pr,2);
- /* TW: Complete power down of LVDS */
- temp = SiS_GetCH701x(SiS_Pr,0x76);
- temp &= 0xfc;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
- SiS_SetCH701x(SiS_Pr,0x0066);
- }
- }
- void
- SiS_ChrontelResetDB(SiS_Private *SiS_Pr)
- {
- /* TW: Reset Chrontel 7019 datapath */
- SiS_SetCH701x(SiS_Pr,0x1048);
- SiS_LongDelay(SiS_Pr,1);
- SiS_SetCH701x(SiS_Pr,0x1848);
- }
- void
- SiS_ChrontelDoSomething4(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- USHORT temp;
- SiS_SetCH701x(SiS_Pr,0xaf76);
- temp = SiS_GetCH701x(SiS_Pr,0x49);
- temp &= 1;
- if(temp != 1) {
- temp = SiS_GetCH701x(SiS_Pr,0x47);
- temp &= 0x70;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
- SiS_LongDelay(SiS_Pr,3);
- temp = SiS_GetCH701x(SiS_Pr,0x47);
- temp |= 0x80;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
- }
- }
- void
- SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT BaseAddr)
- {
- USHORT temp,temp1;
- temp1 = 0;
- temp = SiS_GetCH701x(SiS_Pr,0x61);
- if(temp < 2) {
- temp++;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61);
- temp1 = 1;
- }
- SiS_SetCH701x(SiS_Pr,0xac76);
- temp = SiS_GetCH701x(SiS_Pr,0x66);
- temp |= 0x5f;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
- if(ModeNo > 0x13) {
- if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_GenericDelay(SiS_Pr,0x3ff);
- } else {
- SiS_GenericDelay(SiS_Pr,0x2ff);
- }
- } else {
- if(!temp1)
- SiS_GenericDelay(SiS_Pr,0x2ff);
- }
- temp = SiS_GetCH701x(SiS_Pr,0x76);
- temp |= 0x03;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
- temp = SiS_GetCH701x(SiS_Pr,0x66);
- temp &= 0x7f;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
- SiS_LongDelay(SiS_Pr,1);
- }
- void
- SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- USHORT temp,tempcl,tempch;
- SiS_LongDelay(SiS_Pr, 1);
- tempcl = 3;
- tempch = 0;
- do {
- temp = SiS_GetCH701x(SiS_Pr,0x66);
- temp &= 0x04;
- if(temp == 0x04) break;
- SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension, BaseAddr);
- if(tempcl == 0) {
- if(tempch == 3) break;
- SiS_ChrontelResetDB(SiS_Pr);
- tempcl = 3;
- tempch++;
- }
- tempcl--;
- temp = SiS_GetCH701x(SiS_Pr,0x76);
- temp &= 0xfb;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
- SiS_LongDelay(SiS_Pr,2);
- temp = SiS_GetCH701x(SiS_Pr,0x76);
- temp |= 0x04;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
- SiS_SetCH701x(SiS_Pr,0x6078);
- SiS_LongDelay(SiS_Pr,2);
- } while(0);
- SiS_SetCH701x(SiS_Pr,0x0077);
- }
- void
- SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT BaseAddr)
- {
- USHORT temp;
- temp = SiS_GetCH701x(SiS_Pr,0x03);
- temp |= 0x80;
- temp &= 0xbf;
- SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03);
- SiS_ChrontelResetDB(SiS_Pr);
- SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension, BaseAddr);
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34);
- SiS_ChrontelDoSomething3(SiS_Pr,temp, HwDeviceExtension, BaseAddr);
- SiS_SetCH701x(SiS_Pr,0xaf76);
- }
- /* TW: End of Chrontel 701x functions ==================================== */
- /* TW: Generic Read/write routines for Chrontel ========================== */
- /* TW: The Chrontel is connected to the 630/730 via
- * the 630/730's DDC/I2C port.
- *
- * On 630(S)T chipset, the index changed from 0x11 to 0x0a,
- * possibly for working around the DDC problems
- */
- void
- SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
- {
- if (SiS_Pr->SiS_IF_DEF_CH70xx == 1)
- SiS_SetCH700x(SiS_Pr,tempbx);
- else
- SiS_SetCH701x(SiS_Pr,tempbx);
- }
- /* TW: Write to Chrontel 700x */
- /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */
- void
- SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx)
- {
- USHORT tempah,temp,i;
- if(!(SiS_Pr->SiS_ChrontelInit)) {
- SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */
- SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
- SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
- SiS_Pr->SiS_DDC_DataShift = 0x00;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */
- }
- for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */
- /* SiS_SetSwitchDDC2(SiS_Pr); */
- if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = tempbx & 0x00FF; /* TW: Write RAB */
- tempah |= 0x80; /* TW: (set bit 7, see datasheet) */
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = (tempbx & 0xFF00) >> 8;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */
- if(temp) continue; /* TW: (ERROR: no ack) */
- if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */
- SiS_Pr->SiS_ChrontelInit = 1;
- return;
- }
- /* TW: For 630ST */
- if(!(SiS_Pr->SiS_ChrontelInit)) {
- SiS_Pr->SiS_DDC_Index = 0x0a; /* TW: Bit 7 = SC; Bit 6 = SD */
- SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */
- SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */
- SiS_Pr->SiS_DDC_DataShift = 0x00;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */
- for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */
- /* SiS_SetSwitchDDC2(SiS_Pr); */
- if (SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = tempbx & 0x00FF; /* TW: Write RAB */
- tempah |= 0x80; /* TW: (set bit 7, see datasheet) */
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = (tempbx & 0xFF00) >> 8;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */
- if(temp) continue; /* TW: (ERROR: no ack) */
- if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */
- SiS_Pr->SiS_ChrontelInit = 1;
- return;
- }
- }
- }
- /* TW: Write to Chrontel 701x */
- /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */
- void
- SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
- {
- USHORT tempah,temp,i;
- SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */
- SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */
- SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */
- SiS_Pr->SiS_DDC_DataShift = 0x00;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */
- for(i=0;i<10;i++) { /* TW: Do only 10 attempts to write */
- if (SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = tempbx & 0x00FF;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write RAB */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = (tempbx & 0xFF00) >> 8;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write data */
- if(temp) continue; /* TW: (ERROR: no ack) */
- if(SiS_SetStop(SiS_Pr)) continue; /* TW: Set stop condition */
- return;
- }
- }
- /* TW: Read from Chrontel 70xx */
- /* Parameter is [Register no (S7-S0)] */
- USHORT
- SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
- {
- if (SiS_Pr->SiS_IF_DEF_CH70xx == 1)
- return(SiS_GetCH700x(SiS_Pr,tempbx));
- else
- return(SiS_GetCH701x(SiS_Pr,tempbx));
- }
- /* TW: Read from Chrontel 700x */
- /* Parameter is [Register no (S7-S0)] */
- USHORT
- SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx)
- {
- USHORT tempah,temp,i;
- if(!(SiS_Pr->SiS_ChrontelInit)) {
- SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */
- SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
- SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
- SiS_Pr->SiS_DDC_DataShift = 0x00;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB */
- }
- SiS_Pr->SiS_DDC_ReadAddr = tempbx;
- for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */
- /* SiS_SetSwitchDDC2(SiS_Pr); */
- if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80; /* TW: Write RAB | 0x80 */
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
- if(temp) continue; /* TW: (ERROR: no ack) */
- if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */
- if (SiS_SetStop(SiS_Pr)) continue; /* TW: Stop condition */
- SiS_Pr->SiS_ChrontelInit = 1;
- return(tempah);
- }
- /* TW: For 630ST */
- if(!SiS_Pr->SiS_ChrontelInit) {
- SiS_Pr->SiS_DDC_Index = 0x0a; /* TW: Bit 0 = SC; Bit 1 = SD */
- SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */
- SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */
- SiS_Pr->SiS_DDC_DataShift = 0x00;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB (Device Address Byte) */
- for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */
- /* SiS_SetSwitchDDC2(SiS_Pr); */
- if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80; /* TW: Write RAB | 0x80 */
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
- if(temp) continue; /* TW: (ERROR: no ack) */
- if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */
- if (SiS_SetStop(SiS_Pr)) continue; /* TW: Stop condition */
- SiS_Pr->SiS_ChrontelInit = 1;
- return(tempah);
- }
- }
- return(0xFFFF);
- }
- /* TW: Read from Chrontel 701x */
- /* Parameter is [Register no (S7-S0)] */
- USHORT
- SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
- {
- USHORT tempah,temp,i;
- SiS_Pr->SiS_DDC_Index = 0x11; /* TW: Bit 0 = SC; Bit 1 = SD */
- SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */
- SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */
- SiS_Pr->SiS_DDC_DataShift = 0x00;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* TW: DAB */
- SiS_Pr->SiS_DDC_ReadAddr = tempbx;
- for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */
- if(SiS_SetStart(SiS_Pr)) continue; /* TW: Set start condition */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr;
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: Write DAB (S0=0=write) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = SiS_Pr->SiS_DDC_ReadAddr; /* TW: Write RAB */
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
- if(temp) continue; /* TW: (ERROR: no ack) */
- if (SiS_SetStart(SiS_Pr)) continue; /* TW: Re-start */
- tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */
- temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* TW: DAB (S0=1=read) */
- if(temp) continue; /* TW: (ERROR: no ack) */
- tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* TW: Read byte */
- SiS_SetStop(SiS_Pr); /* TW: Stop condition */
- return(tempah);
- }
- return 0xFFFF;
- }
- #ifdef LINUX_XF86
- /* TW: Our own DDC functions */
- USHORT
- SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdatatype)
- {
- unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6};
- unsigned char flag, cr32;
- USHORT temp = 0, myadaptnum = adaptnum;
- SiS_Pr->SiS_ChrontelInit = 0; /* force re-detection! */
- SiS_Pr->SiS_DDC_SecAddr = 0;
- SiS_Pr->SiS_DDC_DeviceAddr = ddcdtype[DDCdatatype];
- SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_P3c4;
- SiS_Pr->SiS_DDC_Index = 0x11;
- flag = 0xff;
- cr32 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x32);
- if(pSiS->VGAEngine == SIS_300_VGA) { /* 300 series */
- if(pSiS->VBFlags & VB_SISBRIDGE) {
- if(myadaptnum == 0) {
- if(!(cr32 & 0x20)) {
- myadaptnum = 2;
- if(!(cr32 & 0x10)) {
- myadaptnum = 1;
- if(!(cr32 & 0x08)) {
- myadaptnum = 0;
- }
- }
- }
- }
- }
- if(myadaptnum != 0) {
- flag = 0;
- if(pSiS->VBFlags & VB_SISBRIDGE) {
- SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port;
- SiS_Pr->SiS_DDC_Index = 0x0f;
- }
- }
- if(cr32 & 0x80) {
- if(myadaptnum >= 1) {
- if(!(cr32 & 0x08)) {
- myadaptnum = 1;
- if(!(cr32 & 0x10)) return 0xFFFF;
- }
- }
- }
- temp = 4 - (myadaptnum * 2);
- if(flag) temp = 0;
- SiS_Pr->SiS_DDC_Data = 0x02 << temp;
- SiS_Pr->SiS_DDC_Clk = 0x01 << temp;
- } else { /* 310/325 series */
- if(pSiS->VBFlags & (VB_30xLV|VB_30xLVX)) myadaptnum = 0;
- if(pSiS->VBFlags & VB_SISBRIDGE) {
- if(myadaptnum == 0) {
- if(!(cr32 & 0x20)) {
- myadaptnum = 2;
- if(!(cr32 & 0x10)) {
- myadaptnum = 1;
- if(!(cr32 & 0x08)) {
- myadaptnum = 0;
- }
- }
- }
- }
- if(myadaptnum == 2) {
- myadaptnum = 1;
- }
- }
- if(myadaptnum == 1) {
- flag = 0;
- if(pSiS->VBFlags & VB_SISBRIDGE) {
- SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port;
- SiS_Pr->SiS_DDC_Index = 0x0f;
- }
- }
- if(cr32 & 0x80) {
- if(myadaptnum >= 1) {
- if(!(cr32 & 0x08)) {
- myadaptnum = 1;
- if(!(cr32 & 0x10)) return 0xFFFF;
- }
- }
- }
- temp = myadaptnum;
- if(myadaptnum == 1) {
- temp = 0;
- if(pSiS->VBFlags & VB_LVDS) flag = 0xff;
- }
- if(flag) temp = 0;
- SiS_Pr->SiS_DDC_Data = 0x02 << temp;
- SiS_Pr->SiS_DDC_Clk = 0x01 << temp;
- }
- return 0;
- }
- USHORT
- SiS_WriteDABDDC(SiS_Private *SiS_Pr)
- {
- SiS_SetStart(SiS_Pr);
- if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) return 0xFFFF;
- if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) return 0xFFFF;
- return(0);
- }
- USHORT
- SiS_PrepareReadDDC(SiS_Private *SiS_Pr)
- {
- SiS_SetStart(SiS_Pr);
- if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) return 0xFFFF;
- return(0);
- }
- USHORT
- SiS_PrepareDDC(SiS_Private *SiS_Pr)
- {
- if(SiS_WriteDABDDC(SiS_Pr)) SiS_WriteDABDDC(SiS_Pr);
- if(SiS_PrepareReadDDC(SiS_Pr)) return(SiS_PrepareReadDDC(SiS_Pr));
- return(0);
- }
- void
- SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno)
- {
- SiS_SetSCLKLow(SiS_Pr);
- if(yesno) {
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data, SiS_Pr->SiS_DDC_Data);
- } else {
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data, 0);
- }
- SiS_SetSCLKHigh(SiS_Pr);
- }
- USHORT
- SiS_DoProbeDDC(SiS_Private *SiS_Pr)
- {
- unsigned char mask, value;
- USHORT temp, ret;
- SiS_SetSwitchDDC2(SiS_Pr);
- if(SiS_PrepareDDC(SiS_Pr)) {
- SiS_SetStop(SiS_Pr);
- return(0xFFFF);
- }
- mask = 0xf0;
- value = 0x20;
- if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
- temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
- SiS_SendACK(SiS_Pr, 0);
- if(temp == 0) {
- mask = 0xff;
- value = 0xff;
- }
- }
- temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
- SiS_SendACK(SiS_Pr, 1);
- temp &= mask;
- if(temp == value) ret = 0;
- else {
- ret = 0xFFFF;
- if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
- if(value == 0x30) ret = 0;
- }
- }
- SiS_SetStop(SiS_Pr);
- return(ret);
- }
- USHORT
- SiS_ProbeDDC(SiS_Private *SiS_Pr)
- {
- USHORT flag;
- flag = 0x180;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xa0;
- if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x02;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xa2;
- if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x08;
- SiS_Pr->SiS_DDC_DeviceAddr = 0xa6;
- if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x10;
- if(!(flag & 0x1a)) flag = 0;
- return(flag);
- }
- USHORT
- SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT DDCdatatype, unsigned char *buffer)
- {
- USHORT flag, length, i;
- unsigned char chksum,gotcha;
- if(DDCdatatype > 3) return 0xFFFF; /* incomplete! */
- flag = 0;
- SiS_SetSwitchDDC2(SiS_Pr);
- if(!(SiS_PrepareDDC(SiS_Pr))) {
- length = 127;
- if(DDCdatatype != 1) length = 255;
- chksum = 0;
- gotcha = 0;
- for(i=0; i<length; i++) {
- buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
- chksum += buffer[i];
- gotcha |= buffer[i];
- SiS_SendACK(SiS_Pr, 0);
- }
- buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
- chksum += buffer[i];
- SiS_SendACK(SiS_Pr, 1);
- if(gotcha) flag = (USHORT)chksum;
- else flag = 0xFFFF;
- } else {
- flag = 0xFFFF;
- }
- SiS_SetStop(SiS_Pr);
- return(flag);
- }
- /* TW: Our private DDC function
- It complies somewhat with the corresponding VESA function
- in arguments and return values.
- Since this is probably called before the mode is changed,
- we use our pre-detected pSiS-values instead of SiS_Pr as
- regards chipset and video bridge type.
- Arguments:
- adaptnum: 0=CRT1, 1=CRT2
- CRT2 DDC is not supported in some cases.
- DDCdatatype: 0=Probe, 1=EDID, 2=VDIF(not supported), 3=?, 4=?(not supported)
- buffer: ptr to 256 data bytes which will be filled with read data.
- Returns 0xFFFF if error, otherwise
- if DDCdatatype > 0: Returns 0 if reading OK (included a correct checksum)
- if DDCdatatype = 0: Returns supported DDC modes
- */
- USHORT
- SiS_HandleDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum,
- USHORT DDCdatatype, unsigned char *buffer)
- {
- if(DDCdatatype == 2) return 0xFFFF;
- if(adaptnum > 2) return 0xFFFF;
- if(pSiS->VGAEngine == SIS_300_VGA) {
- if((adaptnum != 0) && (DDCdatatype != 0)) return 0xFFFF;
- }
- if((!(pSiS->VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF;
- if(SiS_InitDDCRegs(SiS_Pr, pSiS, adaptnum, DDCdatatype) == 0xFFFF) return 0xFFFF;
- if(DDCdatatype == 0) {
- return(SiS_ProbeDDC(SiS_Pr));
- } else {
- if(DDCdatatype > 4) return 0xFFFF;
- return(SiS_ReadDDC(SiS_Pr, pSiS, DDCdatatype, buffer));
- }
- }
- /* TW: Generic I2C functions (compliant to i2c library) */
- #if 0
- USHORT
- SiS_I2C_GetByte(SiS_Private *SiS_Pr)
- {
- return(SiS_ReadDDC2Data(SiS_Pr,0));
- }
- Bool
- SiS_I2C_PutByte(SiS_Private *SiS_Pr, USHORT data)
- {
- if(SiS_WriteDDC2Data(SiS_Pr,data)) return FALSE;
- return TRUE;
- }
- Bool
- SiS_I2C_Address(SiS_Private *SiS_Pr, USHORT addr)
- {
- if(SiS_SetStart(SiS_Pr)) return FALSE;
- if(SiS_WriteDDC2Data(SiS_Pr,addr)) return FALSE;
- return TRUE;
- }
- void
- SiS_I2C_Stop(SiS_Private *SiS_Pr)
- {
- SiS_SetStop(SiS_Pr);
- }
- #endif
- #endif
- void
- SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh)
- {
- USHORT tempal,tempah,tempbl;
- tempal = tempax & 0x00FF;
- tempah =(tempax >> 8) & 0x00FF;
- tempbl = SiS_GetCH70xx(SiS_Pr,tempal);
- tempbl = (((tempbl & tempbh) | tempah) << 8 | tempal);
- SiS_SetCH70xx(SiS_Pr,tempbl);
- }
- /* TW: Generic I2C functions for Chrontel --------- */
- void
- SiS_SetSwitchDDC2(SiS_Private *SiS_Pr)
- {
- SiS_SetSCLKHigh(SiS_Pr);
- /* SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAY); */
- SiS_WaitRetraceDDC(SiS_Pr);
- SiS_SetSCLKLow(SiS_Pr);
- /* SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAY); */
- SiS_WaitRetraceDDC(SiS_Pr);
- }
- /* TW: Set I2C start condition */
- /* TW: This is done by a SD high-to-low transition while SC is high */
- USHORT
- SiS_SetStart(SiS_Private *SiS_Pr)
- {
- if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: SD->high */
- if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: SC->high */
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data,0x00); /* TW: SD->low = start condition */
- if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */
- return 0;
- }
- /* TW: Set I2C stop condition */
- /* TW: This is done by a SD low-to-high transition while SC is high */
- USHORT
- SiS_SetStop(SiS_Private *SiS_Pr)
- {
- if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* TW: (SC->low) */
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data,0x00); /* TW: SD->low */
- if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: SC->high */
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: SD->high = stop condition */
- if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* TW: (SC->high) */
- return 0;
- }
- /* TW: Write 8 bits of data */
- USHORT
- SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax)
- {
- USHORT i,flag,temp;
- flag=0x80;
- for(i=0;i<8;i++) {
- SiS_SetSCLKLow(SiS_Pr); /* TW: SC->low */
- if(tempax & flag) {
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: Write bit (1) to SD */
- } else {
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data,0x00); /* TW: Write bit (0) to SD */
- }
- SiS_SetSCLKHigh(SiS_Pr); /* TW: SC->high */
- flag >>= 1;
- }
- temp = SiS_CheckACK(SiS_Pr); /* TW: Check acknowledge */
- return(temp);
- }
- USHORT
- SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax)
- {
- USHORT i,temp,getdata;
- getdata=0;
- for(i=0; i<8; i++) {
- getdata <<= 1;
- SiS_SetSCLKLow(SiS_Pr);
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);
- SiS_SetSCLKHigh(SiS_Pr);
- temp = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);
- if(temp & SiS_Pr->SiS_DDC_Data) getdata |= 0x01;
- }
- return(getdata);
- }
- USHORT
- SiS_SetSCLKLow(SiS_Private *SiS_Pr)
- {
- USHORT temp, watchdog=50000;
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Clk,0x00); /* SetSCLKLow() */
- do {
- temp = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);
- } while((temp & SiS_Pr->SiS_DDC_Clk) && --watchdog);
- if (!watchdog) return 0xFFFF;
- SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
- return 0;
- }
- USHORT
- SiS_SetSCLKHigh(SiS_Private *SiS_Pr)
- {
- USHORT temp,watchdog=50000;
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Clk,SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */
- do {
- temp = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);
- } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog);
- if (!watchdog) return 0xFFFF;
- SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
- return 0;
- }
- void
- SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime)
- {
- USHORT i;
- for(i=0; i<delaytime; i++) {
- SiS_GetReg1(SiS_Pr->SiS_P3c4,0x05);
- }
- }
- /* TW: Check I2C acknowledge */
- /* Returns 0 if ack ok, non-0 if ack not ok */
- USHORT
- SiS_CheckACK(SiS_Private *SiS_Pr)
- {
- USHORT tempah;
- SiS_SetSCLKLow(SiS_Pr); /* TW: (SC->low) */
- SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
- ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data); /* TW: (SD->high) */
- SiS_SetSCLKHigh(SiS_Pr); /* TW: SC->high = clock impulse for ack */
- tempah = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);/* TW: Read SD */
- SiS_SetSCLKLow(SiS_Pr); /* TW: SC->low = end of clock impulse */
- if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* TW: Ack OK if bit = 0 */
- else return(0);
- }
- /* TW: End of I2C functions ----------------------- */
- /* =============== SiS 310/325 O.E.M. ================= */
- #ifdef SIS315H
- USHORT
- GetLCDPtrIndex(SiS_Private *SiS_Pr)
- {
- USHORT index;
- index = SiS_Pr->SiS_LCDResInfo & 0x0F;
- index--;
- index *= 3;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) index += 2;
- else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++;
- return index;
- }
- /*
- ---------------------------------------------------------
- GetTVPtrIndex()
- return 0 : NTSC Enhanced/Standard
- 1 : NTSC Standard TVSimuMode
- 2 : PAL Enhanced/Standard
- 3 : PAL Standard TVSimuMode
- 4 : HiVision Enhanced/Standard
- 5 : HiVision Standard TVSimuMode
- ---------------------------------------------------------
- */
- USHORT
- GetTVPtrIndex(SiS_Private *SiS_Pr)
- {
- USHORT index;
- index = 0;
- if(SiS_Pr->SiS_VBInfo & SetPALTV) index++;
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) index++; /* Hivision TV use PAL */
- index <<= 1;
- if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (SiS_Pr->SiS_SetFlag & TVSimuMode))
- index++;
- return index;
- }
- /* TW: Checked against 650/LVDS (1.10.07) and 650/301LVx (1.10.6s) BIOS (including data) */
- void
- SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo)
- {
- USHORT delay,index;
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
- delay = SiS310_CRT2DelayCompensation1;
- if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B))
- delay = SiS310_CRT2DelayCompensation2;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1)
- delay = SiS310_CRT2DelayCompensation3;
- } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- index = GetLCDPtrIndex(SiS_Pr);
- delay = SiS310_LCDDelayCompensation1[index];
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
- delay = SiS310_LCDDelayCompensation2[index];
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1)
- delay = SiS310_LCDDelayCompensation3[index];
- } else {
- index = GetTVPtrIndex(SiS_Pr);
- delay = SiS310_TVDelayCompensation1[index];
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
- delay = SiS310_TVDelayCompensation2[index];
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1)
- delay = SiS310_TVDelayCompensation3[index];
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay);
- } else {
- delay <<= 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,delay);
- }
- } else {
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2D,delay); /* index 2D D[3:0] */
- }
- }
- /* TW: Checked against 650/301LVx 1.10.6s BIOS (including data) */
- void
- SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT index,temp;
- temp = GetTVPtrIndex(SiS_Pr);
- temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */
- if (ModeNo<=0x13)
- index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
- else
- index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
- temp = SiS310_TVAntiFlick1[temp][index];
- temp <<= 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8f,temp); /* index 0A D[6:4] */
- }
- /* TW: Checked against 650/301LVx 1.10.6s BIOS (including data) */
- void
- SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT index,temp;
- temp = GetTVPtrIndex(SiS_Pr);
- temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */
- if (ModeNo<=0x13)
- index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
- else
- index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
- temp = SiS310_TVEdge1[temp][index];
- temp <<= 5;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x3A,0x1F,temp); /* index 0A D[7:5] */
- }
- /* TW: Checked against 650/301LVx 1.10.6s BIOS (incl data) */
- void
- SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT index, temp, i, j;
- UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect;
- temp = GetTVPtrIndex(SiS_Pr);
- temp >>= 1; /* 0: NTSC, 1: PAL, 2: HiTV */
- if (ModeNo<=0x13) {
- index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
- } else {
- index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
- }
- if(SiS_Pr->SiS_VBInfo&SetCRT2ToHiVisionTV) temp = 1; /* Hivision TV uses PAL */
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- for(i=0x35, j=0; i<=0x38; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]);
- }
- for(i=0x48; i<=0x4A; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]);
- }
- } else {
- for(i=0x35, j=0; i<=0x38; i++, j++){
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter1[temp][index][j]);
- }
- }
-
- if(ROMAddr && SiS_Pr->SiS_UseROM) {
- OutputSelect = ROMAddr[0xf3];
- }
- if(OutputSelect & EnablePALMN) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- temp &= (EnablePALMN | EnablePALN);
- if(temp == EnablePALMN) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- for(i=0x35, j=0; i<=0x38; i++, j++){
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter2[index][j]);
- }
- for(i=0x48; i<=0x4A; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter2[index][j]);
- }
- } else {
- for(i=0x35, j=0; i<=0x38; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALMFilter[index][j]);
- }
- }
- }
- if(temp == EnablePALN) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- for(i=0x35, j=0; i<=0x38; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter2[index][j]);
- }
- for(i=0x48, j=0; i<=0x4A; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter2[index][j]);
- }
- } else {
- for(i=0x35, j=0; i<=0x38; i++, j++)
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_PALNFilter[index][j]);
- }
- }
- }
- }
- }
- /* TW: Checked against 650/301LVx 1.10.6s BIOS (including data) */
- void
- SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT index,temp,temp1,i,j,resinfo;
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return;
- temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38); /* if PALM/N not set */
- temp1 &= (EnablePALMN | EnablePALN);
- if(temp1) return;
- if (ModeNo<=0x13) {
- resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
- } else {
- resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
- temp = GetTVPtrIndex(SiS_Pr);
- /* 0: NTSC Graphics, 1: NTSC Text, 2:PAL Graphics,
- * 3: PAL Text, 4: HiTV Graphics 5:HiTV Text
- */
- index = temp % 2;
- temp >>= 1; /* 0:NTSC, 1:PAL, 2:HiTV */
- for(j=0, i=0x31; i<=0x34; i++, j++) {
- if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV))
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]);
- else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_SetFlag & TVSimuMode))
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]);
- else
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]);
- }
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* TW: 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if(resinfo == 6) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x21);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0xf0);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xf5);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7f);
- } else if (resinfo == 7) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x21);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0xf0);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xf5);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7f);
- } else if (resinfo == 8) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x1e);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0x8b);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xfb);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7b);
- }
- }
- }
- }
- void
- SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- SetDelayComp(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo);
- /* TW: The TV funtions are not for LVDS */
- if( (SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) {
- SetAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- SetPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- SetYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
- SetEdgeEnhance(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- }
- }
- }
- /* TW: New from 650/301LVx 1.10.6s - clashes with OEMLCD() */
- void
- SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
- USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp;
- USHORT resinfo;
- if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return;
- if(ModeNo<=0x13) {
- resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
- } else {
- resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
- if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
- }
- tempch = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
- tempch &= 0xf0;
- tempch >>= 4;
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1f,0x76);
- }
- } else {
- tempcl = tempbh = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01);
- tempcl &= 0x0f;
- tempbh &= 0x70;
- tempbh >>= 4;
- tempbl = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x04);
- tempbx = (tempbh << 8) | tempbl;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
- if((resinfo == 8) || (!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding))) {
- if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
- tempbx = 770;
- } else {
- if(tempbx > 770) tempbx = 770;
- if(SiS_Pr->SiS_VGAVDE < 600) { /* Shouldn't that be <=? */
- tempax = 768 - SiS_Pr->SiS_VGAVDE;
- tempax >>= 3;
- if(SiS_Pr->SiS_VGAVDE < 480) tempax >>= 1; /* Shouldn't that be <=? */
- tempbx -= tempax;
- }
- }
- } else return;
- }
- #if 0
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- }
- #endif
- temp = tempbx & 0xff;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,temp);
- temp = (tempbx & 0xff00) >> 8;
- temp <<= 4;
- temp |= tempcl;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,temp);
- }
- }
- }
- /* TW: New and checked from 650/301LV BIOS */
- /* This might clash with newer "FinalizeLCD()" function */
- void
- SiS_OEMLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT tempbx,tempah,tempbl,tempbh,tempcl;
- if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return;
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr);
- tempbh = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x1a);
- tempbh &= 0x38;
- tempbh >>= 3;
- tempbl = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x18);
- tempbx = (tempbh << 8) | tempbl;
- if(SiS_Pr->SiS_LCDTypeInfo == 1) tempbx -= 0x12;
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,tempbx & 0x00ff);
- tempah = (tempbx & 0xff00) >> 8;
- tempah &= 0x07;
- tempah <<= 3;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1a,0xc7,tempah);
- tempah = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x19);
- tempah &= 0x0f;
- if(SiS_Pr->SiS_LCDTypeInfo == 1) tempah -= 2;
- tempah &= 0x0f;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,tempah);
- tempah = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x14);
- if(SiS_Pr->SiS_LCDTypeInfo == 1) tempah++;
- tempah -= 8;
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,tempah);
- } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- tempcl = tempbh = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01);
- tempbh &= 0x70;
- tempbh >>= 4;
- tempbl = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x04);
- tempbx = (tempbh << 8) | tempbl;
- if(SiS_Pr->SiS_LCDTypeInfo == 1) {
- tempbx -= 0x1e;
- tempcl &= 0x0f;
- tempcl -= 4;
- tempcl &= 0x0f;
- }
- tempbl = tempbx & 0x00ff;
- tempbh = (tempbx >> 8) & 0x00ff;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,tempbl);
- tempbh <<= 4;
- tempbh |= tempcl;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,tempbh);
- }
- }
- #endif
- /* ================= SiS 300 O.E.M. ================== */
- #ifdef SIS300
- #if 0 /* Not used */
- USHORT
- GetRevisionID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- ULONG temp1;
- #ifndef LINUX_XF86
- ULONG base;
- #endif
- USHORT temp2 = 0;
- if((HwDeviceExtension->jChipType==SIS_540)||
- (HwDeviceExtension->jChipType==SIS_630)||
- (HwDeviceExtension->jChipType==SIS_730)) {
- #ifndef LINUX_XF86
- base = 0x80000008;
- OutPortLong(base,0xcf8);
- temp1 = InPortLong(0xcfc);
- #else
- temp1=pciReadLong(0x00000000, 0x08);
- #endif
- temp1 &= 0x000000FF;
- temp2 = (USHORT)(temp1);
- return temp2;
- }
- return 0;
- }
- #endif
- /* TW: Checked against 630/301B BIOS (incl data) */
- USHORT
- GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, int Flag)
- {
- USHORT tempbx=0;
- UCHAR customtable[] = {
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
- };
- if(Flag) {
- if(customtable[SiS_Pr->SiS_LCDTypeInfo] == 0xFF) return 0xFFFF;
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- tempbx = SiS_Pr->SiS_LCDTypeInfo << 2;
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx++;
- } else {
- tempbx = SiS_Pr->SiS_LCDTypeInfo;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 16;
- }
- return tempbx;
- }
- /* TW: Checked against 630/301B and 630/LVDS BIOS (incl data) */
- void
- SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT index,temp;
- /* TW: The Panel Compensation Delay should be set according to tables
- * here. Unfortunately, the different BIOS versions don't case about
- * a uniform way using eg. ROM byte 0x220, but use different
- * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). So we can't
- * rely on the other OEM bits in 0x237, 0x238 here either.
- * ROMAddr > 0x233 is even used for code (!) in newer BIOSes!
- */
- #if 0
- if((ROMAddr) && SiS_Pr->SiS_UseROM) {
- if(!(ROMAddr[0x237] & 0x01)) return;
- if(!(ROMAddr[0x237] & 0x02)) return;
- }
- #endif
- /* TW: We just check if a non-standard delay has been set; if not,
- * we use our tables. Otherwise don't do anything here.
- */
- if((ROMAddr) && SiS_Pr->SiS_UseROM) {
- if(ROMAddr[0x220] & 0x80) return;
- }
- /* TW: We don't need to set this if the user select a custom pdc */
- if(HwDeviceExtension->pdc) return;
- temp = GetOEMLCDPtr(SiS_Pr,HwDeviceExtension, 0);
- index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex;
- if (SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- temp = SiS300_OEMLCDDelay2[temp][index];
- } else {
- temp = SiS300_OEMLCDDelay3[temp][index];
- }
- temp &= 0x3c;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* index 0A D[6:4] */
- }
- /* TW: Checked against 630/301B 2.04.50 and 630/LVDS BIOS */
- USHORT
- GetOEMTVPtr(SiS_Private *SiS_Pr)
- {
- USHORT index;
- index = 0;
- if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) index += 2;
- else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) index += 3;
- else if(SiS_Pr->SiS_VBInfo & SetPALTV) index += 1;
- } else {
- if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) index += 2;
- if(SiS_Pr->SiS_VBInfo & SetPALTV) index += 1;
- }
- return index;
- }
- /* TW: Checked against 630/301B 2.04.50 and 630/LVDS BIOS (incl data) */
- void
- SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT index,temp;
- #if 0 /* TW: Not used in newer BIOSes (2.04.5a) */
- if((ROMAddr) && SiS_Pr->SiS_UseROM) {
- if(!(ROMAddr[0x238] & 0x01)) return;
- if(!(ROMAddr[0x238] & 0x02)) return;
- }
- #endif
- temp = GetOEMTVPtr(SiS_Pr);
- index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVDelayIndex;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- temp = SiS300_OEMTVDelay301[temp][index];
- } else {
- temp = SiS300_OEMTVDelayLVDS[temp][index];
- }
- temp &= 0x3c;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* index 0A D[6:4] */
- }
- /* TW: Checked against 630/301B 2.04.50 BIOS (incl data) */
- void
- SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
- USHORT ModeIdIndex)
- {
- USHORT index,temp;
- temp = GetOEMTVPtr(SiS_Pr);
- index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVFlickerIndex;
- temp = SiS300_OEMTVFlicker[temp][index];
- temp &= 0x70;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8F,temp); /* index 0A D[6:4] */
- }
- /* TW: Checked against 630/301B 2.04.50 BIOS (incl data) */
- void
- SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT index,i,j,temp;
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) return;
- temp = GetOEMTVPtr(SiS_Pr);
- index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVPhaseIndex;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- for(i=0x31, j=0; i<=0x34; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]);
- }
- } else {
- for(i=0x31, j=0; i<=0x34; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Phase1[temp][index][j]);
- }
- }
- }
- /* TW: Checked against 630/301B 2.04.50 BIOS (incl data) */
- void
- SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT index,temp,temp1,i,j;
- if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVisionTV)) return;
- temp = GetOEMTVPtr(SiS_Pr);
- index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex;
- if(HwDeviceExtension->jChipType > SIS_300) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
- temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35);
- if(temp1 & (EnablePALMN | EnablePALN)) {
- temp = 8;
- if(temp1 & EnablePALN) temp = 9;
- }
- }
- }
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- for(i=0x35, j=0; i<=0x38; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]);
- }
- for(i=0x48; i<=0x4A; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]);
- }
- } else {
- for(i=0x35, j=0; i<=0x38; i++, j++) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,SiS300_Filter1[temp][index][j]);
- }
- }
- }
- void
- SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo)
- {
- USHORT ModeIdIndex;
- ModeIdIndex = SiS_SearchVBModeID(SiS_Pr,ROMAddr,&ModeNo);
- if(!(ModeIdIndex)) return;
- if (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- SetOEMLCDDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- }
- if (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- SetOEMTVDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- if(SiS_Pr->SiS_IF_DEF_LVDS==0) {
- SetOEMAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- SetOEMPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- SetOEMYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
- }
- }
- }
- #endif