extractedLnx/linux-2.4.24/drivers/video/sis/init301.c_SiS_SetGroup1.c
void
SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension,
USHORT RefreshRateTableIndex)
{
USHORT temp=0, tempax=0, tempbx=0, tempcx=0;
USHORT pushbx=0, CRT1Index=0;
#ifdef SIS315H
USHORT tempbl=0;
#endif
USHORT modeflag, resinfo=0;
if(ModeNo <= 0x13) {
modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
} else {
if(SiS_Pr->UseCustomMode) {
modeflag = SiS_Pr->CModeFlag;
} else {
CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
}
}
if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
#ifdef SIS315H
SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo,
RefreshRateTableIndex,HwDeviceExtension);
SiS_SetGroup1_LCDA(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
HwDeviceExtension,RefreshRateTableIndex);
#endif
} else {
if( (HwDeviceExtension->jChipType >= SIS_315H) &&
(SiS_Pr->SiS_IF_DEF_LVDS == 1) &&
(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ) {
SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo,
RefreshRateTableIndex,HwDeviceExtension);
} else {
SiS_SetCRT2Offset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
RefreshRateTableIndex,HwDeviceExtension);
if (HwDeviceExtension->jChipType < SIS_315H ) {
#ifdef SIS300
SiS_SetCRT2FIFO_300(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension);
#endif
} else {
#ifdef SIS315H
SiS_SetCRT2FIFO_310(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension);
#endif
}
SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo,
RefreshRateTableIndex,HwDeviceExtension);
/* 1. Horizontal setup */
if (HwDeviceExtension->jChipType < SIS_315H ) {
#ifdef SIS300 /* ------------- 300 series --------------*/
temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */
temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4;
SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */
temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */
pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA@HRS 0x0B,0x0C */
tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2;
tempbx = pushbx + tempcx;
tempcx <<= 1;
tempcx += tempbx;
if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
if(SiS_Pr->UseCustomMode) {
tempbx = SiS_Pr->CHSyncStart + 12;
tempcx = SiS_Pr->CHSyncEnd + 12;
}
if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
unsigned char cr4, cr14, cr5, cr15;
if(SiS_Pr->UseCustomMode) {
cr4 = SiS_Pr->CCRT1CRTC[4];
cr14 = SiS_Pr->CCRT1CRTC[14];
cr5 = SiS_Pr->CCRT1CRTC[5];
cr15 = SiS_Pr->CCRT1CRTC[15];
} else {
cr4 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4];
cr14 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14];
cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5];
cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15];
}
tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 1) << 3;
tempcx = (((cr5 & 0x1F) | ((cr15 & 0x04) << (6-2))) - 1) << 3;
}
if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == SIS_RI_1024x768)){
if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){
tempbx = 1040;
tempcx = 1042;
}
}
}
temp = tempbx & 0x00FF;
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); /* CRT2 Horizontal Retrace Start */
#endif /* SIS300 */
} else {
#ifdef SIS315H /* ------------------- 315/330 series --------------- */
tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */
if(modeflag & HalfDCLK) {
if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
tempax = SiS_Pr->SiS_VGAHDE >> 1;
tempcx = SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE + tempax;
if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
tempcx = SiS_Pr->SiS_HT - tempax;
}
} else {
tempcx >>= 1;
}
}
tempcx--;
temp = tempcx & 0xff;
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */
temp = ((tempcx & 0xff00) >> 8) << 4;
SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp); /* CRT2 Horizontal Total Overflow [7:4] */
tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HDEE 0x0A,0x0C */
tempbx = SiS_Pr->SiS_VGAHDE;
tempcx -= tempbx;
tempcx >>= 2;
if(modeflag & HalfDCLK) {
tempbx >>= 1;
tempcx >>= 1;
}
tempbx += 16;
temp = tempbx & 0xff;
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */
pushbx = tempbx;
tempcx >>= 1;
tempbx += tempcx;
tempcx += tempbx;
if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
if(SiS_Pr->UseCustomMode) {
tempbx = SiS_Pr->CHSyncStart + 16;
tempcx = SiS_Pr->CHSyncEnd + 16;
tempax = SiS_Pr->SiS_VGAHT;
if(modeflag & HalfDCLK) tempax >>= 1;
tempax--;
if(tempcx > tempax) tempcx = tempax;
}
if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
unsigned char cr4, cr14, cr5, cr15;
if(SiS_Pr->UseCustomMode) {
cr4 = SiS_Pr->CCRT1CRTC[4];
cr14 = SiS_Pr->CCRT1CRTC[14];
cr5 = SiS_Pr->CCRT1CRTC[5];
cr15 = SiS_Pr->CCRT1CRTC[15];
} else {
cr4 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4];
cr14 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14];
cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5];
cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15];
}
tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */
tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */
tempcx &= 0x00FF;
tempcx |= (tempbx & 0xFF00);
tempbx += 16;
tempcx += 16;
tempax = SiS_Pr->SiS_VGAHT;
if(modeflag & HalfDCLK) tempax >>= 1;
tempax--;
if(tempcx > tempax) tempcx = tempax;
}
if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
if(resinfo == SIS_RI_1024x768) {
tempbx = 1040;
tempcx = 1042;
}
}
}
#if 0
/* Makes no sense, but is in 650/30xLV 1.10.6s */
if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == SIS_RI_1024x768)){
if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) {
if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
tempbx = 1040;
tempcx = 1042;
}
}
}
#endif
}
temp = tempbx & 0xff;
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp); /* CRT2 Horizontal Retrace Start */
#endif /* SIS315H */
} /* 315/330 series */
/* The following is done for all bridge/chip types/series */
tempax = tempbx & 0xFF00;
tempbx = pushbx;
tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
tempax |= (tempbx & 0xFF00);
temp = (tempax & 0xFF00) >> 8;
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp); /* Overflow */
temp = tempcx & 0x00FF;
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp); /* CRT2 Horizontal Retrace End */
/* 2. Vertical setup */
tempcx = SiS_Pr->SiS_VGAVT - 1;
temp = tempcx & 0x00FF;
if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
if(HwDeviceExtension->jChipType < SIS_315H) {
if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) {
temp--;
}
}
} else {
temp--;
}
} else if(HwDeviceExtension->jChipType >= SIS_315H) {
/* 650/30xLV 1.10.6s */
temp--;
}
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp); /* CRT2 Vertical Total */
tempbx = SiS_Pr->SiS_VGAVDE - 1;
temp = tempbx & 0x00FF;
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0F,temp); /* CRT2 Vertical Display Enable End */
temp = ((tempbx & 0xFF00) << 3) >> 8;
temp |= ((tempcx & 0xFF00) >> 8);
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow (and HWCursor Test Mode) */
/* 650/LVDS (1.10.07), 650/30xLV (1.10.6s) */
if(HwDeviceExtension->jChipType >= SIS_315H) {
tempbx++;
tempax = tempbx;
tempcx++;
tempcx -= tempax;
tempcx >>= 2;
tempbx += tempcx;
if(tempcx < 4) tempcx = 4;
tempcx >>= 2;
tempcx += tempbx;
tempcx++;
} else {
/* 300 series, LVDS/301B: */
tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
}
if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
if(SiS_Pr->UseCustomMode) {
tempbx = SiS_Pr->CVSyncStart;
tempcx = (tempcx & 0xFF00) | (SiS_Pr->CVSyncEnd & 0x00FF);
}
if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
unsigned char cr8, cr7, cr13, cr9;
if(SiS_Pr->UseCustomMode) {
cr8 = SiS_Pr->CCRT1CRTC[8];
cr7 = SiS_Pr->CCRT1CRTC[7];
cr13 = SiS_Pr->CCRT1CRTC[13];
cr9 = SiS_Pr->CCRT1CRTC[9];
} else {
cr8 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8];
cr7 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7];
cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13];
cr9 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9];
}
tempbx = cr8;
if(cr7 & 0x04) tempbx |= 0x0100;
if(cr7 & 0x80) tempbx |= 0x0200;
if(cr13 & 0x08) tempbx |= 0x0400;
tempcx = (tempcx & 0xFF00) | (cr9 & 0x00FF);
}
}
temp = tempbx & 0x00FF;
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp); /* CRT2 Vertical Retrace Start */
temp = ((tempbx & 0xFF00) >> 8) << 4;
temp |= (tempcx & 0x000F);
SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,temp); /* CRT2 Vert. Retrace End; Overflow; "Enable CRTC Check" */
/* 3. Panel compensation delay */
if(HwDeviceExtension->jChipType < SIS_315H) {
#ifdef SIS300 /* ---------- 300 series -------------- */
if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
temp = 0x20;
if(HwDeviceExtension->jChipType == SIS_300) {
temp = 0x10;
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) temp = 0x2c;
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20;
}
if(SiS_Pr->SiS_VBType & VB_SIS301) {
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20;
}
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24;
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) temp = 0x2c;
if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08;
if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c;
else temp = 0x20;
}
if((ROMAddr) && (SiS_Pr->SiS_UseROM)) {
if(ROMAddr[0x220] & 0x80) {
if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV-SetCRT2ToHiVisionTV))
temp = ROMAddr[0x221];
else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)
temp = ROMAddr[0x222];
else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)
temp = ROMAddr[0x223];
else
temp = ROMAddr[0x224];
temp &= 0x3c;
}
}
if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
if(HwDeviceExtension->pdc) {
temp = HwDeviceExtension->pdc & 0x3c;
}
}
} else {
temp = 0x20;
if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) temp = 0x04;
}
if((ROMAddr) && SiS_Pr->SiS_UseROM) {
if(ROMAddr[0x220] & 0x80) {
temp = ROMAddr[0x220] & 0x3c;
}
}
if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
if(HwDeviceExtension->pdc) {
temp = HwDeviceExtension->pdc & 0x3c;
}
}
}
SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x03C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */
#endif /* SIS300 */
} else {
#ifdef SIS315H /* --------------- 315/330 series ---------------*/
if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
temp = 0x10;
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) temp = 0x2c;
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20;
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) temp = 0x24;
if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) temp = 0x2c;
if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
temp = 0x08;
if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
switch(SiS_Pr->SiS_HiVision) {
case 2:
case 1:
case 0:
temp = 0x08;
break;
default:
if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c;
else temp = 0x20;
}
}
}
if((SiS_Pr->SiS_VBType & VB_SIS301B302B) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
tempbl = 0x00;
if((ROMAddr) && (SiS_Pr->SiS_UseROM)) {
if(HwDeviceExtension->jChipType < SIS_330) {
if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0;
} else {
if(ROMAddr[0x1bc] & 0x80) tempbl = 0xf0;
}
}
} else { /* LV (550/301LV checks ROM byte, other LV BIOSes do not) */
tempbl = 0xF0;
}
if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD|SetCRT2ToLCDA)) {
if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
if(HwDeviceExtension->pdc) {
temp = HwDeviceExtension->pdc;
tempbl = 0;
}
}
}
} else {
if(HwDeviceExtension->jChipType == SIS_740) {
temp = 0x03;
} else {
temp = 0x00;
}
if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a;
tempbl = 0xF0;
if(HwDeviceExtension->jChipType == SIS_650) {
if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F;
}
}
if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) {
temp = 0x08;
tempbl = 0;
if((ROMAddr) && (SiS_Pr->SiS_UseROM)) {
if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0;
}
}
}
SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp); /* Panel Link Delay Compensation */
tempax = 0;
if (modeflag & DoubleScanMode) tempax |= 0x80;
if (modeflag & HalfDCLK) tempax |= 0x40;
SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax);
#endif /* SIS315H */
}
} /* Slavemode */
if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
/* For 301BDH with LCD, we set up the Panel Link */
if( (SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) {
SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
HwDeviceExtension,RefreshRateTableIndex);
} else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
SiS_SetGroup1_301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
HwDeviceExtension,RefreshRateTableIndex);
}
} else {
if(HwDeviceExtension->jChipType < SIS_315H) {
SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
HwDeviceExtension,RefreshRateTableIndex);
} else {
if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
HwDeviceExtension,RefreshRateTableIndex);
}
} else {
SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
HwDeviceExtension,RefreshRateTableIndex);
}
}
}
} /* LCDA */
}
Generated by GNU enscript 1.6.4.