10 #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25)
12 static const unsigned short XGINew_VGA_DAC[] = {
13 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
14 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
15 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
16 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
17 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
18 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
19 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
20 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
21 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
22 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
31 pVBInfo->
MCLKData = XGI340New_MCLKData;
45 pVBInfo->
SR15 = XGI340_SR13;
46 pVBInfo->
CR40 = XGI340_cr41;
47 pVBInfo->
CR6B = XGI340_CR6B;
48 pVBInfo->
CR6E = XGI340_CR6E;
49 pVBInfo->
CR6F = XGI340_CR6F;
50 pVBInfo->
CR89 = XGI340_CR89;
51 pVBInfo->
AGPReg = XGI340_AGPReg;
52 pVBInfo->
SR16 = XGI340_SR16;
70 if (ChipType ==
XG27) {
72 pVBInfo->
MCLKData = XGI27New_MCLKData;
73 pVBInfo->
CR40 = XGI27_cr41;
75 pVBInfo->
SR15 = XG27_SR13;
80 if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
86 static void XGI_SetSeqRegs(
unsigned short ModeNo,
87 unsigned short ModeIdIndex,
90 unsigned char tempah, SRdata;
91 unsigned short i, modeflag;
93 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
109 for (i = 02; i <= 04; i++) {
119 unsigned char CRTCdata;
126 for (i = 0; i <= 0x18; i++) {
133 static void XGI_SetATTRegs(
unsigned short ModeNo,
134 unsigned short ModeIdIndex,
137 unsigned char ARdata;
138 unsigned short i, modeflag;
140 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
142 for (i = 0; i <= 0x13; i++) {
145 if ((modeflag &
Charx8Dot) && i == 0x13) {
148 }
else if ((pVBInfo->
VBInfo &
169 unsigned char GRdata;
172 for (i = 0; i <= 0x08; i++) {
189 for (i = 0x0A; i <= 0x0E; i++)
193 static unsigned char XGI_SetDefaultVCLK(
struct vb_device_info *pVBInfo)
208 static unsigned char XGI_AjustCRT2Rate(
unsigned short ModeNo,
209 unsigned short ModeIdIndex,
210 unsigned short RefreshRateTableIndex,
unsigned short *i,
213 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
215 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
216 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
217 tempbx = pVBInfo->
RefIndex[RefreshRateTableIndex + (*i)].ModeID;
282 for (; pVBInfo->
RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
284 infoflag = pVBInfo->
RefIndex[RefreshRateTableIndex + (*i)].
286 if (infoflag & tempax)
293 for ((*i) = 0;; (*i)++) {
294 infoflag = pVBInfo->
RefIndex[RefreshRateTableIndex + (*i)].
296 if (pVBInfo->
RefIndex[RefreshRateTableIndex + (*i)].ModeID
301 if (infoflag & tempax)
307 static void XGI_SetSync(
unsigned short RefreshRateTableIndex,
313 sync = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
331 data = pVBInfo->
TimingH[0].data[0];
334 for (i = 0x01; i <= 0x04; i++) {
339 for (i = 0x05; i <= 0x06; i++) {
346 data = pVBInfo->
TimingH[0].data[7];
380 static void XGI_SetCRT1Timing_V(
unsigned short ModeIdIndex,
381 unsigned short ModeNo,
387 for (i = 0x00; i <= 0x01; i++) {
392 for (i = 0x02; i <= 0x03; i++) {
397 for (i = 0x04; i <= 0x05; i++) {
404 data = pVBInfo->
TimingV[0].data[6];
409 data = pVBInfo->
TimingV[0].data[6];
424 static void XGI_SetCRT1CRTC(
unsigned short ModeNo,
unsigned short ModeIdIndex,
425 unsigned short RefreshRateTableIndex,
433 index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
440 for (i = 0; i < 8; i++)
444 for (i = 0; i < 7; i++)
448 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
450 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
462 static void XGI_SetXG21CRTC(
unsigned short ModeNo,
unsigned short ModeIdIndex,
463 unsigned short RefreshRateTableIndex,
466 unsigned char index, Tempax, Tempbx, Tempcx, Tempdx;
467 unsigned short Temp1, Temp2, Temp3;
469 index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
490 Temp2 = Temp1 & 0x3C0;
498 Tempax = (
unsigned char) Temp2;
513 Tempcx = Tempbx >> 1;
514 Tempdx = Tempax & 0x04;
540 Temp2 = Temp1 & 0x7E0;
543 Temp3 = Temp1 & 0x1F;
548 Tempax = (
unsigned char) Temp2;
552 Tempbx = (
unsigned char) Temp1;
559 static void XGI_SetXG27CRTC(
unsigned short ModeNo,
560 unsigned short ModeIdIndex,
561 unsigned short RefreshRateTableIndex,
564 unsigned short index, Tempax, Tempbx, Tempcx;
566 index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
576 Tempbx |= (Tempax << 2);
587 Tempbx = Tempbx & 0x3C0;
593 if (Tempcx <= Tempax)
599 Tempax |= ((Tempbx << 2) & 0xFF);
613 Tempax = Tempax & 0x04;
617 Tempcx |= (Tempax << 8);
618 Tempcx |= ((Tempbx & 0x80) << 2);
622 Tempcx |= (Tempax << 7);
636 if (Tempbx <= Tempcx)
640 Tempax = (Tempbx << 2) & 0xFF;
643 Tempax = Tempcx >> 8;
654 temp = (temp & 3) << 6;
662 static void xgifb_set_lcd(
int chip_id,
664 unsigned short RefreshRateTableIndex,
665 unsigned short ModeNo)
667 unsigned short Data, Temp;
668 unsigned short XGI_P3cc;
670 XGI_P3cc = pVBInfo->
P3cc;
677 if (chip_id ==
XG27) {
679 if ((Temp & 0x03) == 0) {
685 if (chip_id ==
XG27) {
686 XGI_SetXG27FPBits(pVBInfo);
701 Data = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
716 static void XGI_UpdateXG21CRTC(
unsigned short ModeNo,
718 unsigned short RefreshRateTableIndex)
723 if (ModeNo == 0x2E &&
724 (pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
727 else if (ModeNo == 0x2E && (pVBInfo->
RefIndex[RefreshRateTableIndex].
730 else if (ModeNo == 0x2F)
732 else if (ModeNo == 0x50)
734 else if (ModeNo == 0x59)
750 unsigned short ModeNo,
unsigned short ModeIdIndex,
751 unsigned short RefreshRateTableIndex,
754 unsigned short resindex, tempax, tempbx, tempcx,
temp, modeflag;
758 resindex = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
760 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
765 tempax = tempax >> 1;
767 if (modeflag & HalfDCLK)
768 tempax = tempax << 1;
770 temp = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
773 tempbx = tempbx >> 1;
776 tempbx = tempbx << 1;
790 (
unsigned short) ((tempcx & 0x0ff00) >> 10));
793 tempbx = tempbx >> 8;
813 static void XGI_SetCRT1Offset(
unsigned short ModeNo,
814 unsigned short ModeIdIndex,
815 unsigned short RefreshRateTableIndex,
826 temp2 = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
857 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
858 temp = temp * temp2 + temp2 / 2;
872 temp = (
unsigned char) temp2;
877 temp2 = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
882 DisplayUnit = DisplayUnit << 5;
883 ah = (DisplayUnit & 0xff00) >> 8;
884 al = DisplayUnit & 0x00ff;
891 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
897 static unsigned short XGI_GetVCLK2Ptr(
unsigned short ModeNo,
898 unsigned short ModeIdIndex,
899 unsigned short RefreshRateTableIndex,
903 unsigned short CRT2Index, VCLKIndex;
904 unsigned short modeflag, resinfo;
907 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
908 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
909 CRT2Index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
912 CRT2Index = CRT2Index >> 6;
927 if (modeflag & Charx8Dot) {
950 VCLKIndex = pVBInfo->
RefIndex[RefreshRateTableIndex].
964 static void XGI_SetCRT1VCLK(
unsigned short ModeNo,
965 unsigned short ModeIdIndex,
967 unsigned short RefreshRateTableIndex,
971 unsigned short vclkindex;
974 index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
985 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
986 RefreshRateTableIndex, HwDeviceExtension,
990 data = pVBInfo->
VBVCLKData[vclkindex].Part4_A;
992 data = pVBInfo->
VBVCLKData[vclkindex].Part4_B;
996 index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1028 temp = (temp & 1) << 6;
1036 static void XGI_SetCRT1FIFO(
unsigned short ModeNo,
1040 unsigned short data;
1055 XGI_SetXG21FPBits(pVBInfo);
1059 unsigned short ModeNo,
unsigned short RefreshRateTableIndex,
1065 unsigned char index;
1067 index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1098 unsigned short ModeNo,
unsigned short ModeIdIndex,
1099 unsigned short RefreshRateTableIndex,
1102 unsigned short data,
data2,
data3, infoflag = 0, modeflag, resindex,
1105 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1106 infoflag = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1123 resindex = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
1127 if (infoflag & InterlaceMode) {
1130 else if (xres == 1280)
1134 data2 = data & 0x00FF;
1136 data2 = (data & 0xFF00) >> 8;
1139 if (modeflag & HalfDCLK)
1153 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1182 static void XGI_WriteDAC(
unsigned short dl,
1188 unsigned short temp, bh,
bl;
1207 outb((
unsigned short) dh, pVBInfo->
P3c9);
1208 outb((
unsigned short) bh, pVBInfo->
P3c9);
1209 outb((
unsigned short) bl, pVBInfo->
P3c9);
1212 static void XGI_LoadDAC(
unsigned short ModeNo,
unsigned short ModeIdIndex,
1215 unsigned short data,
data2,
i,
k,
m,
n, o, si, di, bx,
dl, al,
ah, dh;
1216 const unsigned short *
table = XGINew_VGA_DAC;
1221 for (i = 0; i < 16; i++) {
1224 for (k = 0; k < 3; k++) {
1238 for (i = 16; i < 32; i++) {
1241 for (k = 0; k < 3; k++)
1247 for (m = 0; m < 9; m++) {
1252 for (n = 0; n < 3; n++) {
1253 for (o = 0; o < 5; o++) {
1258 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1263 for (o = 0; o < 3; o++) {
1268 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1278 static void XGI_GetLVDSResInfo(
unsigned short ModeNo,
1279 unsigned short ModeIdIndex,
1282 unsigned short resindex, xres, yres, modeflag;
1285 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
1288 resindex = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
1293 if (modeflag & HalfDCLK)
1296 if (modeflag & DoubleScanMode)
1303 pVBInfo->
HDE = xres;
1305 pVBInfo->
VDE = yres;
1308 static void *XGI_GetLcdPtr(
unsigned short BX,
unsigned short ModeNo,
1309 unsigned short ModeIdIndex,
1310 unsigned short RefreshRateTableIndex,
1313 unsigned short i, tempdx, tempbx, tempal, modeflag,
table;
1319 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1320 tempal = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1322 tempal = tempal & 0x0f;
1325 tempal = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1328 tempal = pVBInfo->
RefIndex[RefreshRateTableIndex].
1333 tempal = (tempal >> 4);
1335 tempal = (tempal & 0x0f);
1341 tempdi = xgifb_epllcd_crt1;
1344 tempdi = XGI_EPLLCDDataPtr;
1347 tempdi = XGI_EPLLCDDesDataPtr;
1350 tempdi = XGI_LCDDataTable;
1353 tempdi = XGI_LCDDesDataTable;
1365 while (tempdi[i].
PANELID != 0xff) {
1367 if (tempbx & 0x0080) {
1368 tempbx &= (~0x0080);
1375 if (tempdi[i].
PANELID == tempdx) {
1376 tempbx = tempdi[
i].
MASK;
1379 if (modeflag & HalfDCLK)
1383 if (tempbx == tempdi[i].
CAP)
1392 return &XGI_LVDSCRT11024x768_1_H[tempal];
1395 return &XGI_LVDSCRT11024x768_2_H[tempal];
1398 return &XGI_LVDSCRT11280x1024_1_H[tempal];
1401 return &XGI_LVDSCRT11280x1024_2_H[tempal];
1404 return &XGI_LVDSCRT11400x1050_1_H[tempal];
1407 return &XGI_LVDSCRT11400x1050_2_H[tempal];
1410 return &XGI_LVDSCRT11600x1200_1_H[tempal];
1413 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
1416 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
1419 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
1422 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
1427 }
else if (table == 1) {
1430 return &XGI_LVDSCRT11024x768_1_V[tempal];
1433 return &XGI_LVDSCRT11024x768_2_V[tempal];
1436 return &XGI_LVDSCRT11280x1024_1_V[tempal];
1439 return &XGI_LVDSCRT11280x1024_2_V[tempal];
1442 return &XGI_LVDSCRT11400x1050_1_V[tempal];
1445 return &XGI_LVDSCRT11400x1050_2_V[tempal];
1448 return &XGI_LVDSCRT11600x1200_1_V[tempal];
1451 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
1454 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
1457 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
1460 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
1465 }
else if (table == 2) {
1468 return &XGI_LVDS1024x768Data_1[tempal];
1471 return &XGI_LVDS1024x768Data_2[tempal];
1474 return &XGI_LVDS1280x1024Data_1[tempal];
1480 return &XGI_LVDS1400x1050Data_1[tempal];
1483 return &XGI_LVDS1400x1050Data_2[tempal];
1486 return &XGI_LVDS1600x1200Data_1[tempal];
1489 return &XGI_LVDSNoScalingData[tempal];
1492 return &XGI_LVDS1024x768Data_1x75[tempal];
1495 return &XGI_LVDS1024x768Data_2x75[tempal];
1498 return &XGI_LVDS1280x1024Data_1x75[tempal];
1501 return &XGI_LVDS1280x1024Data_2x75[tempal];
1504 return &XGI_LVDSNoScalingDatax75[tempal];
1509 }
else if (table == 3) {
1512 return &XGI_LVDS1024x768Des_1[tempal];
1515 return &XGI_LVDS1024x768Des_3[tempal];
1518 return &XGI_LVDS1024x768Des_2[tempal];
1521 return &XGI_LVDS1280x1024Des_1[tempal];
1524 return &XGI_LVDS1280x1024Des_2[tempal];
1527 return &XGI_LVDS1400x1050Des_1[tempal];
1530 return &XGI_LVDS1400x1050Des_2[tempal];
1533 return &XGI_LVDS1600x1200Des_1[tempal];
1536 return &XGI_LVDSNoScalingDesData[tempal];
1539 return &XGI_LVDS1024x768Des_1x75[tempal];
1542 return &XGI_LVDS1024x768Des_3x75[tempal];
1545 return &XGI_LVDS1024x768Des_2x75[tempal];
1548 return &XGI_LVDS1280x1024Des_1x75[tempal];
1551 return &XGI_LVDS1280x1024Des_2x75[tempal];
1554 return &XGI_LVDSNoScalingDesDatax75[tempal];
1559 }
else if (table == 4) {
1562 return &XGI_ExtLCD1024x768Data[tempal];
1565 return &XGI_StLCD1024x768Data[tempal];
1568 return &XGI_CetLCD1024x768Data[tempal];
1571 return &XGI_ExtLCD1280x1024Data[tempal];
1574 return &XGI_StLCD1280x1024Data[tempal];
1577 return &XGI_CetLCD1280x1024Data[tempal];
1581 return &xgifb_lcd_1400x1050[tempal];
1587 return &XGI_ExtLCD1600x1200Data[tempal];
1590 return &XGI_StLCD1600x1200Data[tempal];
1593 return &XGI_NoScalingData[tempal];
1596 return &XGI_ExtLCD1024x768x75Data[tempal];
1599 return &XGI_ExtLCD1024x768x75Data[tempal];
1602 return &XGI_CetLCD1024x768x75Data[tempal];
1606 return &xgifb_lcd_1280x1024x75[tempal];
1612 return &XGI_NoScalingDatax75[tempal];
1617 }
else if (table == 5) {
1620 return &XGI_ExtLCDDes1024x768Data[tempal];
1623 return &XGI_StLCDDes1024x768Data[tempal];
1626 return &XGI_CetLCDDes1024x768Data[tempal];
1631 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
1633 return &XGI_ExtLCDDes1280x1024Data[tempal];
1638 return &XGI_StLCDDLDes1280x1024Data[tempal];
1640 return &XGI_StLCDDes1280x1024Data[tempal];
1645 return &XGI_CetLCDDLDes1280x1024Data[tempal];
1647 return &XGI_CetLCDDes1280x1024Data[tempal];
1653 return &xgifb_lcddldes_1400x1050[tempal];
1655 return &xgifb_lcddes_1400x1050[tempal];
1658 return &XGI_CetLCDDes1400x1050Data[tempal];
1661 return &XGI_CetLCDDes1400x1050Data2[tempal];
1666 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
1668 return &XGI_ExtLCDDes1600x1200Data[tempal];
1673 return &XGI_StLCDDLDes1600x1200Data[tempal];
1675 return &XGI_StLCDDes1600x1200Data[tempal];
1678 return &XGI_NoScalingDesData[tempal];
1682 return &xgifb_lcddes_1024x768x75[tempal];
1685 return &XGI_CetLCDDes1024x768x75Data[tempal];
1691 return &xgifb_lcddldes_1280x1024x75[tempal];
1693 return &xgifb_lcddes_1280x1024x75[tempal];
1698 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
1700 return &XGI_CetLCDDes1280x1024x75Data[tempal];
1703 return &XGI_NoScalingDesDatax75[tempal];
1713 unsigned short ModeIdIndex,
1714 unsigned short RefreshRateTableIndex,
1717 unsigned short i, tempdx, tempal, modeflag;
1719 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1720 tempal = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1721 tempal = tempal & 0x3f;
1722 tempdx = pVBInfo->
TVInfo;
1727 if (modeflag & HalfDCLK)
1732 while (XGI_TVDataTable[i].
MASK != 0xffff) {
1733 if ((tempdx & XGI_TVDataTable[i].
MASK) ==
1734 XGI_TVDataTable[i].CAP)
1739 return &XGI_TVDataTable[
i].DATAPTR[tempal];
1742 static void XGI_GetLVDSData(
unsigned short ModeNo,
unsigned short ModeIdIndex,
1743 unsigned short RefreshRateTableIndex,
1746 unsigned short tempbx;
1752 LCDPtr = XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex,
1753 RefreshRateTableIndex, pVBInfo);
1765 pVBInfo->
HDE = 1024;
1770 pVBInfo->
HDE = 1280;
1771 pVBInfo->
VDE = 1024;
1773 pVBInfo->
HDE = 1400;
1774 pVBInfo->
VDE = 1050;
1776 pVBInfo->
HDE = 1600;
1777 pVBInfo->
VDE = 1200;
1783 static void XGI_ModCRT1Regs(
unsigned short ModeNo,
unsigned short ModeIdIndex,
1784 unsigned short RefreshRateTableIndex,
1788 unsigned char index;
1789 unsigned short tempbx,
i;
1793 index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1799 LCDPtr = XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex,
1800 RefreshRateTableIndex, pVBInfo);
1802 for (i = 0; i < 8; i++)
1803 pVBInfo->
TimingH[0].data[i] = LCDPtr[0].
Reg[i];
1806 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
1811 LCDPtr1 = XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex,
1812 RefreshRateTableIndex, pVBInfo);
1813 for (i = 0; i < 7; i++)
1814 pVBInfo->
TimingV[0].data[i] = LCDPtr1[0].
Reg[i];
1817 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
1820 static unsigned short XGI_GetLCDCapPtr(
struct vb_device_info *pVBInfo)
1822 unsigned char tempal, tempah, tempbl,
i;
1825 tempal = tempah & 0x0F;
1826 tempah = tempah & 0xF0;
1830 while (tempbl != 0xFF) {
1831 if (tempbl & 0x80) {
1833 tempbl = tempbl & ~(0x80);
1836 if (tempal == tempbl)
1847 static unsigned short XGI_GetLCDCapPtr1(
struct vb_device_info *pVBInfo)
1849 unsigned short tempah, tempal, tempbl,
i;
1857 while (tempbl != 0xFF) {
1858 if ((tempbl & 0x80) && (tempbl != 0x80)) {
1863 if (tempal == tempbl)
1870 if (tempbl == 0xFF) {
1879 static void XGI_GetLCDSync(
unsigned short *HSyncWidth,
1880 unsigned short *VSyncWidth,
1883 unsigned short Index;
1885 Index = XGI_GetLCDCapPtr(pVBInfo);
1886 *HSyncWidth = pVBInfo->
LCDCapList[Index].LCD_HSyncWidth;
1887 *VSyncWidth = pVBInfo->
LCDCapList[Index].LCD_VSyncWidth;
1892 static void XGI_SetLVDSRegs(
unsigned short ModeNo,
unsigned short ModeIdIndex,
1893 unsigned short RefreshRateTableIndex,
1896 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
1901 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1904 LCDPtr1 = XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex,
1905 RefreshRateTableIndex, pVBInfo);
1907 LCDPtr = XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex,
1908 RefreshRateTableIndex, pVBInfo);
1910 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
1932 pVBInfo->
HDE = tempax;
1933 pVBInfo->
VDE = tempbx;
1934 pVBInfo->
VGAHDE = tempax;
1935 pVBInfo->
VGAVDE = tempbx;
1938 tempax = pVBInfo->
HT;
1945 tempcx = pVBInfo->
HDE;
1946 tempbx = tempbx & 0x0fff;
1949 if (tempcx >= tempax)
1954 tempcx = tempcx >> 3;
1955 tempbx = tempbx >> 3;
1958 (
unsigned short) (tempbx & 0xff));
1960 (
unsigned short) (tempcx & 0xff));
1962 tempax = pVBInfo->
HT;
1965 tempbx = LCDPtr1->
LCDHRS;
1976 if (tempcx >= tempax)
1979 tempax = tempbx & 0x07;
1980 tempax = tempax >> 5;
1981 tempcx = tempcx >> 3;
1982 tempbx = tempbx >> 3;
1989 (
unsigned short) (tempbx & 0xff));
1991 tempax = pVBInfo->
VT;
1996 tempcx = pVBInfo->
VDE;
1998 tempbx = tempbx & 0x0fff;
2000 if (tempcx >= tempax)
2004 (
unsigned short) (tempbx & 0xff));
2006 (
unsigned short) (tempcx & 0xff));
2008 tempbx = (tempbx >> 8) & 0x07;
2009 tempcx = (tempcx >> 8) & 0x07;
2012 (
unsigned short) ((tempcx << 3)
2015 tempax = pVBInfo->
VT;
2017 tempbx = LCDPtr1->
LCDVRS;
2027 if (tempcx >= tempax)
2031 (
unsigned short) (tempbx & 0xff));
2033 (
unsigned short) (tempcx & 0x0f));
2035 tempax = ((tempbx >> 8) & 0x07) << 3;
2037 tempbx = pVBInfo->
VGAVDE;
2038 if (tempbx != pVBInfo->
VDE)
2047 tempcx = pVBInfo->
VGAVT;
2048 tempbx = pVBInfo->
VDE;
2049 tempax = pVBInfo->
VGAVDE;
2053 temp1 = (temp << 18) / tempbx;
2055 tempdx = (
unsigned short) ((temp << 18) % tempbx);
2064 (
unsigned short) (temp2 & 0xff));
2066 (
unsigned short) ((temp2 >> 8) & 0xff));
2068 tempbx = (
unsigned short) (temp2 >> 16);
2069 tempax = tempbx & 0x03;
2071 tempbx = pVBInfo->
VGAVDE;
2072 if (tempbx == pVBInfo->
VDE)
2081 (
unsigned short) (temp2 & 0xff));
2084 (
unsigned short) ((temp2 >> 8) &
2086 tempbx = (
unsigned short) (temp2 >> 16);
2089 (
unsigned short) ((tempbx &
2092 tempcx = pVBInfo->
VGAVDE;
2093 if (tempcx == pVBInfo->
VDE)
2101 tempcx = pVBInfo->
VGAHDE;
2102 tempbx = pVBInfo->
HDE;
2104 temp1 = tempcx << 16;
2106 tempax = (
unsigned short) (temp1 / tempbx);
2108 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2112 temp1 = pVBInfo->
VGAHDE << 16;
2115 temp3 = temp3 << 16;
2118 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
2120 tempax = (
unsigned short) (temp3 & 0xff);
2123 temp1 = pVBInfo->
VGAVDE << 18;
2124 temp1 = temp1 / push3;
2125 tempbx = (
unsigned short) (temp1 & 0xffff);
2130 tempax = ((tempbx >> 8) & 0xff) << 3;
2131 tempax |= (
unsigned short) ((temp3 >> 8) & 0x07);
2133 (
unsigned short) (tempax & 0xff));
2135 (
unsigned short) (tempbx & 0xff));
2137 temp3 = temp3 >> 16;
2139 if (modeflag & HalfDCLK)
2143 (
unsigned short) ((temp3 >> 8) & 0xff));
2145 (
unsigned short) (temp3 & 0xff));
2154 static void XGI_GetLCDVCLKPtr(
unsigned char *di_0,
unsigned char *di_1,
2157 unsigned short index;
2160 index = XGI_GetLCDCapPtr1(pVBInfo);
2173 static unsigned char XGI_GetVCLKPtr(
unsigned short RefreshRateTableIndex,
2174 unsigned short ModeNo,
unsigned short ModeIdIndex,
2178 unsigned short index, modeflag;
2179 unsigned char tempal;
2182 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2186 index = XGI_GetLCDCapPtr(pVBInfo);
2205 if (!(modeflag & Charx8Dot))
2236 tempal = (
unsigned char)
inb((pVBInfo->
P3ca + 0x02));
2237 tempal = tempal >> 2;
2242 tempal = tempal ^ tempal;
2244 tempal = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2248 static void XGI_GetVCLKLen(
unsigned char tempal,
unsigned char *di_0,
2255 *di_0 = XGI_VBVCLKData[tempal].Part4_A;
2256 *di_1 = XGI_VBVCLKData[tempal].Part4_B;
2259 *di_0 = XGI_VCLKData[tempal].SR2B;
2260 *di_1 = XGI_VCLKData[tempal].SR2C;
2264 static void XGI_SetCRT2ECLK(
unsigned short ModeNo,
unsigned short ModeIdIndex,
2265 unsigned short RefreshRateTableIndex,
2268 unsigned char di_0, di_1, tempal;
2271 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2273 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2274 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2276 for (i = 0; i < 4; i++) {
2278 (
unsigned short) (0x10 * i));
2293 unsigned short tempcl, tempch,
temp, tempbl, tempax;
2301 if (!(temp & 0x20)) {
2313 if (!(temp == 0x08)) {
2360 if (tempcl & ActiveLCD) {
2379 unsigned short flag, tempbx, tempah;
2396 goto bigger_than_0xB0;
2400 goto bigger_than_0xB0;
2404 goto bigger_than_0xB0;
2419 pVBInfo->
VBType = tempbx;
2422 static void XGI_GetVBInfo(
unsigned short ModeNo,
unsigned short ModeIdIndex,
2426 unsigned short tempax,
push, tempbx,
temp, modeflag;
2428 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2433 if (!(pVBInfo->
VBType & 0xFFFF))
2438 tempbx = tempbx |
temp;
2443 tempbx = tempbx | tempax;
2446 temp = 0xFFFF ^
temp;
2508 if (!(tempbx & temp)) {
2583 if (!(tempbx & DisableCRT2Display)) {
2586 if (!(tempbx & XGI_SetCRT2ToLCDA))
2602 pVBInfo->
VBInfo = tempbx;
2605 static void XGI_GetTVInfo(
unsigned short ModeNo,
unsigned short ModeIdIndex,
2608 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
2614 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2615 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
2627 tempbx &= ~TVSetPAL;
2635 if (pVBInfo->
VBInfo & SetCRT2ToSCART)
2664 if (!(tempbx & TVSetPAL) &&
2677 }
else if (!(pVBInfo->
VBType &
2688 pVBInfo->
TVInfo = tempbx;
2691 static unsigned char XGI_GetLCDInfo(
unsigned short ModeNo,
2694 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
2700 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2702 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
2704 tempbx = temp & 0x0F;
2711 if (pVBInfo->
VBInfo & DriverMode) {
2713 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA)
2716 tempax = tempax >> 4;
2718 if ((resinfo == 6) || (resinfo == 9)) {
2721 }
else if ((resinfo == 7) || (resinfo == 8)) {
2743 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
2745 tempax = pVBInfo->
LCDCapList[LCDIdIndex].LCD_Capability;
2780 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
2781 if (pVBInfo->
EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
2783 if (pVBInfo->
EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
2790 static unsigned char XG21GPIODataTransfer(
unsigned char ujDate)
2792 unsigned char ujRet = 0;
2793 unsigned char i = 0;
2795 for (i = 0; i < 8; i++) {
2797 ujRet |= (ujDate >>
i) & 1;
2809 static unsigned char XGI_XG21GetPSCValue(
struct vb_device_info *pVBInfo)
2818 temp = XG21GPIODataTransfer(temp);
2830 static unsigned char XGI_XG27GetPSCValue(
struct vb_device_info *pVBInfo)
2843 temp |= ((CRB4 & 0x04) << 3);
2856 static void XGI_XG21BLSignalVDD(
unsigned short tempbh,
unsigned short tempbl,
2866 if (tempbh & 0x20) {
2867 temp = (tempbl >> 4) & 0x02;
2876 temp = XG21GPIODataTransfer(temp);
2882 static void XGI_XG27BLSignalVDD(
unsigned short tempbh,
unsigned short tempbl,
2886 unsigned short tempbh0, tempbl0;
2895 if (tempbh & 0x20) {
2896 temp = (tempbl >> 4) & 0x02;
2921 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
2923 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
2926 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
2928 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
2931 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
2934 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
2941 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
2943 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
2946 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
2948 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
2951 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
2954 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
2968 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
2972 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
2977 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
2979 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
2985 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
2993 while ((
inb(pVBInfo->
P3da) & 0x01))
2996 while (!(
inb(pVBInfo->
P3da) & 0x01))
3005 static void XGI_SaveCRT2Info(
unsigned short ModeNo,
3017 static void XGI_GetCRT2ResInfo(
unsigned short ModeNo,
3018 unsigned short ModeIdIndex,
3021 unsigned short xres, yres, modeflag, resindex;
3023 resindex = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
3027 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3029 if (modeflag & HalfDCLK)
3032 if (modeflag & DoubleScanMode)
3049 else if (yres == 350)
3063 else if (yres == 400)
3065 else if (yres == 480)
3077 pVBInfo->
HDE = xres;
3079 pVBInfo->
VDE = yres;
3082 static unsigned char XGI_IsLCDDualLink(
struct vb_device_info *pVBInfo)
3092 static void XGI_GetRAMDAC2DATA(
unsigned short ModeNo,
3093 unsigned short ModeIdIndex,
3094 unsigned short RefreshRateTableIndex,
3097 unsigned short tempax, tempbx,
temp1,
temp2, modeflag = 0, tempcx,
3102 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3103 CRT1Index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3107 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
3109 tempcx = (
unsigned short)
3112 tempcx = tempcx << 2;
3123 if (modeflag & Charx8Dot)
3128 pVBInfo->
VGAHT = tempax;
3129 pVBInfo->
HT = tempax;
3131 pVBInfo->
VGAVT = tempbx;
3132 pVBInfo->
VT = tempbx;
3135 static void XGI_GetCRT2Data(
unsigned short ModeNo,
unsigned short ModeIdIndex,
3136 unsigned short RefreshRateTableIndex,
3139 unsigned short tempax = 0, tempbx, modeflag, resinfo;
3144 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3145 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
3150 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3158 LCDPtr = XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex,
3159 RefreshRateTableIndex, pVBInfo);
3173 if (pVBInfo->
VGAVDE == 357)
3175 else if (pVBInfo->
VGAVDE == 420)
3177 else if (pVBInfo->
VGAVDE == 525)
3179 else if (pVBInfo->
VGAVDE == 600)
3190 if (pVBInfo->
VGAVDE == 360)
3192 else if (pVBInfo->
VGAVDE == 375)
3194 else if (pVBInfo->
VGAVDE == 405)
3203 if (pVBInfo->
VGAVDE == 350)
3205 else if (pVBInfo->
VGAVDE == 400)
3207 else if (pVBInfo->
VGAVDE == 1024)
3215 if (pVBInfo->
VGAVDE == 1024) {
3223 if (pVBInfo->
VGAVDE == 350)
3225 else if (pVBInfo->
VGAVDE == 400)
3231 tempax = pVBInfo->
VGAHDE;
3232 tempbx = pVBInfo->
VGAVDE;
3235 pVBInfo->
HDE = tempax;
3236 pVBInfo->
VDE = tempbx;
3243 TVPtr = XGI_GetTVPtr(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3256 if (resinfo == 0x08)
3258 else if (resinfo == 0x09)
3260 else if (resinfo == 0x12)
3263 if (pVBInfo->
VGAVDE == 350)
3274 if (!(modeflag & Charx8Dot)) {
3298 if (!(pVBInfo->
TVInfo & TVSetPAL)) {
3306 pVBInfo->
HT = tempax;
3307 pVBInfo->
VT = tempbx;
3312 static void XGI_SetCRT2VCLK(
unsigned short ModeNo,
unsigned short ModeIdIndex,
3313 unsigned short RefreshRateTableIndex,
3316 unsigned char di_0, di_1, tempal;
3318 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3320 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3321 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3341 static unsigned short XGI_GetColorDepth(
unsigned short ModeNo,
3344 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
3346 unsigned short modeflag;
3348 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3354 return ColorDepth[
index];
3357 static unsigned short XGI_GetOffset(
unsigned short ModeNo,
3358 unsigned short ModeIdIndex,
3359 unsigned short RefreshRateTableIndex,
3363 unsigned short temp, colordepth, modeinfo,
index, infoflag,
3364 ColorDepth[] = { 0x01, 0x02, 0x04 };
3366 modeinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeInfo;
3367 infoflag = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
3369 index = (modeinfo >> 8) & 0xFF;
3373 if (infoflag & InterlaceMode)
3376 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
3378 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
3379 temp = ModeNo - 0x7C;
3380 colordepth = ColorDepth[
temp];
3382 if (infoflag & InterlaceMode)
3384 return temp * colordepth;
3386 return temp * colordepth;
3390 static void XGI_SetCRT2Offset(
unsigned short ModeNo,
3391 unsigned short ModeIdIndex,
3392 unsigned short RefreshRateTableIndex,
3402 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3403 HwDeviceExtension, pVBInfo);
3404 temp = (
unsigned char) (offset & 0xFF);
3406 temp = (
unsigned char) ((offset & 0xFF00) >> 8);
3408 temp = (
unsigned char) (((offset >> 3) & 0xFF) + 1);
3420 static void XGI_PreSetGroup1(
unsigned short ModeNo,
unsigned short ModeIdIndex,
3422 unsigned short RefreshRateTableIndex,
3425 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
3427 CRT1Index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3429 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
3431 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3432 HwDeviceExtension, pVBInfo);
3433 XGI_SetCRT2FIFO(pVBInfo);
3435 for (tempcx = 4; tempcx < 7; tempcx++)
3442 static void XGI_SetGroup1(
unsigned short ModeNo,
unsigned short ModeIdIndex,
3444 unsigned short RefreshRateTableIndex,
3447 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
3448 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
3450 CRT1Index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3452 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
3453 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3456 if (modeflag & HalfDCLK) {
3458 temp = (pVBInfo->
VGAHT / 2 - 1) & 0x0FF;
3460 temp = (((pVBInfo->
VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
3463 temp = (pVBInfo->
VGAHDE / 2 + 16) & 0x0FF;
3465 tempcx = ((pVBInfo->
VGAHT - pVBInfo->
VGAHDE) / 2) >> 2;
3466 pushbx = pVBInfo->
VGAHDE / 2 + 16;
3467 tempcx = tempcx >> 1;
3468 tempbx = pushbx + tempcx;
3473 tempbx |= ((pVBInfo->
3474 XGINEWUB_CRT1Table[CRT1Index].CR[14] &
3476 tempbx = (tempbx - 3) << 3;
3480 temp = (temp & 0x04) << (5 - 2);
3481 tempcx = ((tempcx |
temp) - 3) << 3;
3487 if (tempcx > (pVBInfo->
VGAHT / 2))
3488 tempcx = pVBInfo->
VGAHT / 2;
3490 temp = tempbx & 0x00FF;
3494 temp = (pVBInfo->
VGAHT - 1) & 0x0FF;
3496 temp = (((pVBInfo->
VGAHT - 1) & 0xFF00) >> 8) << 4;
3499 temp = (pVBInfo->
VGAHDE + 16) & 0x0FF;
3502 pushbx = pVBInfo->
VGAHDE + 16;
3503 tempcx = tempcx >> 1;
3504 tempbx = pushbx + tempcx;
3509 tempbx |= ((pVBInfo->
3510 XGINEWUB_CRT1Table[CRT1Index].CR[5] &
3512 tempbx = (tempbx - 3) << 3;
3516 temp = (temp & 0x04) << (5 - 2);
3517 tempcx = ((tempcx |
temp) - 3) << 3;
3522 if (tempcx > pVBInfo->
VGAHT)
3523 tempcx = pVBInfo->
VGAHT;
3525 temp = tempbx & 0x00FF;
3529 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
3531 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
3532 tempax |= (tempbx & 0xFF00);
3533 temp = (tempax & 0xFF00) >> 8;
3535 temp = tempcx & 0x00FF;
3537 tempcx = (pVBInfo->
VGAVT - 1);
3538 temp = tempcx & 0x00FF;
3541 tempbx = pVBInfo->
VGAVDE - 1;
3542 temp = tempbx & 0x00FF;
3544 temp = ((tempbx & 0xFF00) << 3) >> 8;
3545 temp |= ((tempcx & 0xFF00) >> 8);
3548 tempax = pVBInfo->
VGAVDE;
3549 tempbx = pVBInfo->
VGAVDE;
3550 tempcx = pVBInfo->
VGAVT;
3554 tempcx = ((pVBInfo->
VGAVT - pVBInfo->
VGAVDE) >> 4) + tempbx + 1;
3572 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
3575 temp = tempbx & 0x00FF;
3577 temp = ((tempbx & 0xFF00) >> 8) << 4;
3578 temp = ((tempcx & 0x000F) | (temp));
3582 if (modeflag & DoubleScanMode)
3585 if (modeflag & HalfDCLK)
3591 static unsigned short XGI_GetVGAHT2(
struct vb_device_info *pVBInfo)
3593 unsigned long tempax, tempbx;
3598 tempax = (tempax * pVBInfo->
HT) / tempbx;
3600 return (
unsigned short) tempax;
3603 static void XGI_SetLockRegs(
unsigned short ModeNo,
unsigned short ModeIdIndex,
3605 unsigned short RefreshRateTableIndex,
3608 unsigned short push1, push2, tempax, tempbx = 0, tempcx,
temp, resinfo,
3609 modeflag, CRT1Index;
3612 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3613 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
3614 CRT1Index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3627 tempax = pVBInfo->
VGAHDE;
3629 if (modeflag & HalfDCLK)
3630 tempax = tempax >> 1;
3632 tempax = (tempax / tempcx) - 1;
3633 tempbx |= ((tempax & 0x00FF) << 8);
3634 temp = tempax & 0x00FF;
3637 temp = (tempbx & 0xFF00) >> 8;
3654 if (!(pVBInfo->
VBInfo & DisableCRT2Display)) {
3656 tempax = pVBInfo->
VGAHT;
3658 tempax = XGI_GetVGAHT2(pVBInfo);
3661 if (tempax >= pVBInfo->
VGAHT)
3662 tempax = pVBInfo->
VGAHT;
3664 if (modeflag & HalfDCLK)
3665 tempax = tempax >> 1;
3667 tempax = (tempax / tempcx) - 5;
3670 temp = (tempbx & 0x00FF) - 1;
3671 if (!(modeflag & HalfDCLK)) {
3679 tempbx = (tempbx & 0xFF00) >> 8;
3680 tempcx = (tempcx + tempbx) >> 1;
3681 temp = (tempcx & 0x00FF) + 2;
3685 if (!(modeflag & HalfDCLK)) {
3686 if ((modeflag & Charx8Dot)) {
3688 if (pVBInfo->
VGAHDE >= 800)
3692 }
else if (!(modeflag & HalfDCLK)) {
3695 pVBInfo->
VGAHDE >= 800) {
3697 if (pVBInfo->
VGAHDE >= 1280 &&
3712 if (ModeNo == 0x50) {
3732 tempbx = pVBInfo->
VGAVT;
3735 tempbx = pVBInfo->
VGAVDE;
3761 temp = tempbx & 0x00FF;
3763 temp = tempbx & 0x00FF;
3768 temp = tempbx & 0x00FF;
3771 if (tempbx & 0x0100)
3776 if (modeflag & DoubleScanMode)
3779 if (tempbx & 0x0200)
3782 temp = (tempax & 0xFF00) >> 8;
3785 if (tempbx & 0x0400)
3793 tempax = tempax >> 2;
3796 if (resinfo != 0x09) {
3797 tempax = tempax << 1;
3805 (pVBInfo->
TVInfo & TVSetPAL)) {
3817 if (pVBInfo->
TVInfo & TVSetPAL) {
3830 tempax = tempax >> 2;
3835 if ((pVBInfo->
TVInfo & TVSetPAL)) {
3836 if (tempbx <= 513) {
3842 temp = tempbx & 0x00FF;
3845 temp = tempbx & 0x00FF;
3848 if (tempbx & 0x0100)
3851 if (tempbx & 0x0200)
3856 if (tempbx & 0x0100)
3859 if (tempbx & 0x0200)
3862 if (tempbx & 0x0400)
3866 temp = tempbx & 0x00FF;
3871 if (tempbx & 0x0010)
3874 temp = tempcx & 0x00FF;
3876 temp = (tempcx & 0x0FF00) >> 8;
3879 temp = (tempax & 0xFF00) >> 8;
3881 temp = (temp >> 1) & 0x09;
3900 static void XGI_SetGroup2(
unsigned short ModeNo,
unsigned short ModeIdIndex,
3901 unsigned short RefreshRateTableIndex,
3905 unsigned short i,
j, tempax, tempbx, tempcx,
temp, push1, push2,
3906 modeflag, resinfo, crt2crtc;
3907 unsigned char const *TimingPoint;
3909 unsigned long longtemp, tempeax, tempebx,
temp2, tempecx;
3912 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3913 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
3914 crt2crtc = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3924 if (pVBInfo->
VBInfo & SetCRT2ToSCART)
3927 if (!(pVBInfo->
TVInfo & TVSetPAL))
3936 tempax = (tempax & 0xff00) >> 8;
3939 TimingPoint = XGI330_NTSCTiming;
3941 if (pVBInfo->
TVInfo & TVSetPAL)
3942 TimingPoint = XGI330_PALTiming;
3945 TimingPoint = XGI330_HiTVExtTiming;
3948 TimingPoint = XGI330_HiTVSt2Timing;
3951 TimingPoint = XGI330_HiTVSt1Timing;
3953 if (!(modeflag & Charx8Dot))
3954 TimingPoint = XGI330_HiTVTextTiming;
3959 TimingPoint = XGI330_YPbPr525iTiming;
3962 TimingPoint = XGI330_YPbPr525pTiming;
3965 TimingPoint = XGI330_YPbPr750pTiming;
3968 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
3971 for (i = 0x39; i <= 0x45; i++, j++)
3985 if (pVBInfo->
TVInfo & TVSetPAL)
3990 if (pVBInfo->
VDE <= tempax) {
3991 tempax -= pVBInfo->
VDE;
3992 tempax = tempax >> 2;
3993 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
3995 temp = (tempax & 0xFF00) >> 8;
3996 temp += (
unsigned short) TimingPoint[0];
4003 tempcx = pVBInfo->
VGAHDE;
4004 if (tempcx >= 1024) {
4006 if (pVBInfo->
TVInfo & TVSetPAL)
4014 temp = (tempax & 0xFF00) >> 8;
4015 temp += TimingPoint[1];
4022 tempcx = pVBInfo->
VGAHDE;
4023 if (tempcx >= 1024) {
4025 if (pVBInfo->
TVInfo & TVSetPAL)
4034 tempcx = pVBInfo->
HT;
4036 if (XGI_IsLCDDualLink(pVBInfo))
4037 tempcx = tempcx >> 1;
4040 temp = tempcx & 0x00FF;
4043 temp = (tempcx & 0xFF00) >> 8;
4046 tempcx = pVBInfo->
HT >> 1;
4053 temp = tempcx & 0x00FF;
4057 tempbx = TimingPoint[
j] | ((TimingPoint[j + 1]) << 8);
4060 temp = tempbx & 0x00FF;
4062 temp = (tempbx & 0xFF00) >> 8;
4067 tempbx = tempbx + 8;
4069 tempbx = tempbx - 4;
4073 temp = (tempbx & 0x00FF) << 4;
4077 tempcx += (TimingPoint[
j] | ((TimingPoint[j + 1]) << 8));
4078 temp = tempcx & 0x00FF;
4080 temp = ((tempcx & 0xFF00) >> 8) << 4;
4087 temp = tempcx & 0xFF;
4093 temp = TimingPoint[
j] | ((TimingPoint[j + 1]) << 8);
4095 temp = tempcx & 0x00FF;
4102 tempax = XGI_GetVGAHT2(pVBInfo);
4103 tempcx = tempax - 1;
4105 temp = tempcx & 0x00FF;
4108 tempbx = pVBInfo->
VDE;
4110 if (pVBInfo->
VGAVDE == 360)
4112 if (pVBInfo->
VGAVDE == 375)
4114 if (pVBInfo->
VGAVDE == 405)
4122 tempbx = tempbx >> 1;
4124 tempbx = tempbx >> 1;
4128 temp = tempbx & 0x00FF;
4146 temp = (tempcx & 0xFF00) >> 8;
4147 temp |= ((tempbx & 0xFF00) >> 8) << 6;
4168 tempbx = pVBInfo->
VDE;
4169 tempcx = tempbx - 2;
4174 tempbx = tempbx >> 1;
4179 if (tempcx & 0x0400)
4182 if (tempbx & 0x0400)
4188 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
4190 temp = (tempbx - 3) & 0x00FF;
4194 tempbx = tempbx & 0x00FF;
4196 if (!(modeflag & HalfDCLK)) {
4197 tempcx = pVBInfo->
VGAHDE;
4198 if (tempcx >= pVBInfo->
HDE) {
4207 if (pVBInfo->
VGAHDE >= 1024) {
4209 if (pVBInfo->
VGAHDE >= 1280) {
4211 tempbx = tempbx & 0xDFFF;
4216 if (!(tempbx & 0x2000)) {
4217 if (modeflag & HalfDCLK)
4218 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
4221 tempeax = pVBInfo->
VGAHDE;
4222 tempebx = (tempcx & 0xFF00) >> 8;
4223 longtemp = tempeax * tempebx;
4224 tempecx = tempcx & 0x00FF;
4225 longtemp = longtemp / tempecx;
4232 tempecx = tempecx * 8;
4235 longtemp = longtemp * tempecx;
4236 tempecx = pVBInfo->
HDE;
4237 temp2 = longtemp % tempecx;
4238 tempeax = longtemp / tempecx;
4242 tempax = (
unsigned short) tempeax;
4247 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
4252 tempbx = (
unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
4253 | (tempbx & 0x00FF));
4254 tempax = (
unsigned short) (((tempeax & 0x000000FF) << 8)
4255 | (tempax & 0x00FF));
4256 temp = (tempax & 0xFF00) >> 8;
4258 temp = (tempax & 0x00FF) >> 8;
4262 temp = (tempbx & 0xFF00) >> 8;
4264 temp = tempcx & 0x00FF;
4266 if (tempbx & 0x2000)
4273 if (pVBInfo->
TVInfo & TVSetPAL) {
4281 temp = tempbx & 0x00FF;
4283 temp = tempcx & 0x00FF;
4286 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
4288 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
4306 TimingPoint = XGI_NTSC1024AdjTime;
4307 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
4340 static void XGI_SetLCDRegs(
unsigned short ModeNo,
unsigned short ModeIdIndex,
4342 unsigned short RefreshRateTableIndex,
4345 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx,
temp,
4346 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
4351 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4352 resinfo = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
4353 CRT1Index = pVBInfo->
RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4359 tempbx = pVBInfo->
HDE;
4361 if (XGI_IsLCDDualLink(pVBInfo))
4362 tempbx = tempbx >> 1;
4365 temp = tempbx & 0x00FF;
4367 temp = (tempbx & 0xFF00) >> 8;
4373 tempbx = pVBInfo->
VDE;
4376 temp = tempbx & 0x00FF;
4378 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
4381 tempcx = pVBInfo->
VT - 1;
4383 temp = tempcx & 0x00FF;
4385 temp = (tempcx & 0xFF00) >> 8;
4395 LCDBDesPtr = XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex,
4396 RefreshRateTableIndex, pVBInfo);
4416 tempbx = pVBInfo->
HDE;
4417 tempcx = pVBInfo->
VDE;
4421 tempax = pVBInfo->
VT;
4429 if (tempcx >= tempax)
4432 temp = tempbx & 0x00FF;
4434 temp = tempcx & 0x00FF;
4436 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
4437 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
4439 tempah = tempah << 3;
4444 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4446 tempax = pVBInfo->
VT;
4447 tempbx = pVBInfo->
LCDVRS;
4450 if (tempcx >= tempax)
4453 temp = tempbx & 0x00FF;
4455 temp = (tempbx & 0xFF00) >> 8;
4457 temp |= (tempcx & 0x000F);
4460 tempax = pVBInfo->
HT;
4464 if (XGI_IsLCDDualLink(pVBInfo)) {
4465 tempax = tempax >> 1;
4466 tempbx = tempbx >> 1;
4467 tempcx = tempcx >> 1;
4478 if (tempcx >= tempax)
4481 temp = tempbx & 0x00FF;
4483 temp = ((tempbx & 0xFF00) >> 8) << 4;
4485 temp = tempcx & 0x00FF;
4487 temp = (tempcx & 0xFF00) >> 8;
4490 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4492 tempax = pVBInfo->
HT;
4493 tempbx = pVBInfo->
LCDHRS;
4494 if (XGI_IsLCDDualLink(pVBInfo)) {
4495 tempax = tempax >> 1;
4496 tempbx = tempbx >> 1;
4497 tempcx = tempcx >> 1;
4505 if (tempcx >= tempax)
4508 temp = tempbx & 0x00FF;
4511 temp = (tempbx & 0xFF00) >> 8;
4514 temp = tempcx & 0x00FF;
4518 if (pVBInfo->
VGAVDE == 525) {
4530 if (pVBInfo->
VGAVDE == 420) {
4551 unsigned short tempax, tempbx,
i;
4556 tempax = pVBInfo->
VGAHDE;
4557 tempbx = pVBInfo->
HDE;
4559 tempax = pVBInfo->
VGAVDE;
4560 tempbx = pVBInfo->
VDE;
4563 if (tempax <= tempbx)
4564 return &xgifb_tap4_timing[0];
4566 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
4568 if (pVBInfo->
TVInfo & TVSetPAL)
4569 Tap4TimingPtr = PALTap4Timing;
4574 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
4576 Tap4TimingPtr = YPbPr750pTap4Timing;
4580 Tap4TimingPtr = xgifb_tap4_timing;
4583 while (Tap4TimingPtr[i].
DE != 0xFFFF) {
4584 if (Tap4TimingPtr[i].
DE == tempax)
4588 return &Tap4TimingPtr[
i];
4593 unsigned short i,
j;
4600 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo);
4601 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
4607 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
4608 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
4611 Tap4TimingPtr->
Reg[j]);
4623 static void XGI_SetGroup3(
unsigned short ModeNo,
unsigned short ModeIdIndex,
4627 unsigned char const *tempdi;
4628 unsigned short modeflag;
4631 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4634 if (pVBInfo->
TVInfo & TVSetPAL) {
4656 tempdi = XGI330_HiTVGroup3Data;
4658 tempdi = XGI330_HiTVGroup3Simu;
4659 if (!(modeflag & Charx8Dot))
4660 tempdi = XGI330_HiTVGroup3Text;
4664 tempdi = XGI330_Ren525pGroup3;
4667 tempdi = XGI330_Ren750pGroup3;
4669 for (i = 0; i <= 0x3E; i++)
4680 static void XGI_SetGroup4(
unsigned short ModeNo,
unsigned short ModeIdIndex,
4681 unsigned short RefreshRateTableIndex,
4685 unsigned short tempax, tempcx, tempbx, modeflag,
temp,
temp2;
4687 unsigned long tempebx, tempeax, templong;
4690 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4695 temp = tempbx & 0x00FF;
4697 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
4698 tempcx = pVBInfo->
VGAHT - 1;
4699 temp = tempcx & 0x00FF;
4702 temp = ((tempcx & 0xFF00) >> 8) << 3;
4705 tempcx = pVBInfo->
VGAVT - 1;
4709 temp = tempcx & 0x00FF;
4711 temp = temp2 | ((tempcx & 0xFF00) >> 8);
4714 tempcx = pVBInfo->
VBInfo;
4715 tempbx = pVBInfo->
VGAHDE;
4717 if (modeflag & HalfDCLK)
4718 tempbx = tempbx >> 1;
4720 if (XGI_IsLCDDualLink(pVBInfo))
4721 tempbx = tempbx >> 1;
4744 if (pVBInfo->
VGAHDE == 1280)
4746 if (pVBInfo->
VGAHDE == 1024)
4751 tempebx = pVBInfo->
VDE;
4753 if (tempcx & SetCRT2ToHiVision) {
4754 if (!(temp & 0xE000))
4755 tempbx = tempbx >> 1;
4758 tempcx = pVBInfo->
RVBHRS;
4759 temp = tempcx & 0x00FF;
4762 tempeax = pVBInfo->
VGAVDE;
4765 if (tempeax <= tempebx) {
4766 tempcx = (tempcx & (~0x4000));
4767 tempeax = pVBInfo->
VGAVDE;
4772 templong = (tempeax * 256 * 1024) % tempebx;
4773 tempeax = (tempeax * 256 * 1024) / tempebx;
4779 temp = (
unsigned short) (tempebx & 0x000000FF);
4782 temp = (
unsigned short) ((tempebx & 0x0000FF00) >> 8);
4784 tempbx = (
unsigned short) (tempebx >> 16);
4785 temp = tempbx & 0x00FF;
4787 temp |= ((tempcx & 0xFF00) >> 8);
4795 tempax = pVBInfo->
VGAHDE;
4796 if (modeflag & HalfDCLK)
4797 tempax = tempax >> 1;
4799 if (XGI_IsLCDDualLink(pVBInfo))
4800 tempax = tempax >> 1;
4805 }
else if (pVBInfo->
VGAHDE > 800) {
4806 if (pVBInfo->
VGAHDE == 1024)
4807 tempax = (tempax * 25 / 32) - 1;
4809 tempax = (tempax * 20 / 32) - 1;
4813 temp = (tempax & 0xFF00) >> 8;
4814 temp = ((temp & 0x0003) << 4);
4816 temp = (tempax & 0x00FF);
4819 if (pVBInfo->
VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) {
4820 if (pVBInfo->
VGAHDE > 800)
4826 if (pVBInfo->
VBInfo & SetCRT2ToTV) {
4839 tempbx = pVBInfo->
HT;
4840 if (XGI_IsLCDDualLink(pVBInfo))
4841 tempbx = tempbx >> 1;
4842 tempbx = (tempbx >> 1) - 2;
4843 temp = ((tempbx & 0x0700) >> 8) << 3;
4845 temp = tempbx & 0x00FF;
4850 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4858 static void XGI_SetGroup5(
unsigned short ModeNo,
unsigned short ModeIdIndex,
4861 unsigned short Pindex, Pdata;
4867 | DisableCRT2Display))) {
4868 XGINew_EnableCRT2(pVBInfo);
4887 static unsigned char XGI_XG21CheckLVDSMode(
struct xgifb_video_info *xgifb_info,
4888 unsigned short ModeNo,
unsigned short ModeIdIndex,
4891 unsigned short xres, yres, colordepth, modeflag, resindex;
4893 resindex = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
4897 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4899 if (!(modeflag & Charx8Dot)) {
4904 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
4907 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
4910 if (xres > xgifb_info->
lvds_data.LVDSHDE)
4913 if (yres > xgifb_info->
lvds_data.LVDSVDE)
4916 if (xres != xgifb_info->
lvds_data.LVDSHDE ||
4917 yres != xgifb_info->
lvds_data.LVDSVDE) {
4918 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4927 unsigned short ModeNo,
4928 unsigned short ModeIdIndex,
4931 unsigned char temp, Miscdata;
4932 unsigned short xres, yres, modeflag, resindex;
4933 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
4934 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
4935 unsigned short value;
4937 temp = (
unsigned char) ((xgifb_info->
lvds_data.LVDS_Capability &
4942 outb((Miscdata & 0x3F) | temp, pVBInfo->
P3c2);
4950 if (chip_id ==
XG27)
4951 XGI_SetXG27FPBits(pVBInfo);
4953 XGI_SetXG21FPBits(pVBInfo);
4955 resindex = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_RESINFO;
4959 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4961 if (!(modeflag & Charx8Dot))
4962 xres = xres * 8 / 9;
4966 LVDSHBS = xres + (xgifb_info->
lvds_data.LVDSHDE - xres) / 2;
4968 if (LVDSHBS > LVDSHT)
4971 LVDSHRS = LVDSHBS + xgifb_info->
lvds_data.LVDSHFP;
4972 if (LVDSHRS > LVDSHT)
4975 LVDSHRE = LVDSHRS + xgifb_info->
lvds_data.LVDSHSYNC;
4976 if (LVDSHRE > LVDSHT)
4979 LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->
lvds_data.LVDSHDE;
4983 LVDSVBS = yres + (xgifb_info->
lvds_data.LVDSVDE - yres) / 2;
4984 if (modeflag & DoubleScanMode)
4985 LVDSVBS += yres / 2;
4987 if (LVDSVBS > LVDSVT)
4990 LVDSVRS = LVDSVBS + xgifb_info->
lvds_data.LVDSVFP;
4991 if (LVDSVRS > LVDSVT)
4994 LVDSVRE = LVDSVRS + xgifb_info->
lvds_data.LVDSVSYNC;
4995 if (LVDSVRE > LVDSVT)
4998 LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->
lvds_data.LVDSVDE;
5003 if (!(modeflag & Charx8Dot))
5007 value = (LVDSHT >> 3) - 5;
5012 value = (LVDSHBS >> 3) - 1;
5017 value = (LVDSHBE >> 3) - 1;
5023 value = (LVDSHRS >> 3) + 2;
5033 value = (LVDSHRE >> 3) + 2;
5049 value = LVDSVBS - 1;
5056 value = LVDSVBE - 1;
5061 value = LVDSVRS - 1;
5067 if (chip_id ==
XG27) {
5070 (value & 0x700) >> 8);
5075 (value & 0x600) >> 9);
5081 value = LVDSVRE - 1;
5086 if (chip_id ==
XG27)
5088 (value << 2) & 0xFC);
5092 (value << 2) & 0x7C);
5094 for (temp = 0, value = 0; temp < 3; temp++) {
5104 if (!(modeflag & Charx8Dot)) {
5127 unsigned short tempax;
5129 tempax = pVBInfo->
VBInfo;
5144 static unsigned char XGI_DisableChISLCD(
struct vb_device_info *pVBInfo)
5146 unsigned short tempbx, tempah;
5152 if (!(tempah & 0x08))
5171 static unsigned char XGI_EnableChISLCD(
struct vb_device_info *pVBInfo)
5173 unsigned short tempbx, tempah;
5179 if (!(tempah & 0x08))
5196 unsigned short tempah = 0;
5203 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA) {
5204 if (pVBInfo->
VBInfo & SetCRT2ToDualEdge) {
5228 || (XGI_DisableChISLCD(pVBInfo))
5229 || (XGI_IsLCDON(pVBInfo)))
5235 & (DisableCRT2Display | XGI_SetCRT2ToLCDA
5238 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
5242 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA) {
5244 & XGI_SetCRT2ToLCDA))
5258 ((!(pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA)) &&
5266 (!(pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA)) ||
5287 if (pVBInfo->
VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA
5310 static unsigned short XGI_GetTVPtrIndex(
struct vb_device_info *pVBInfo)
5312 unsigned short tempbx = 0;
5314 if (pVBInfo->
TVInfo & TVSetPAL)
5346 static void XGI_GetTVPtrIndex2(
unsigned short *tempbx,
unsigned char *tempcl,
5353 if (pVBInfo->
TVInfo & TVSetPAL)
5384 unsigned char tempah, tempbl, tempbh;
5393 if (pVBInfo->
VBInfo & SetCRT2ToDualEdge)
5394 tempbl = tempbl >> 4;
5399 if (!(pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA))
5413 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA) {
5426 tempah = tempah << 4;
5433 static void XGI_SetLCDCap_A(
unsigned short tempcx,
5436 unsigned short temp;
5443 (
unsigned short) (0x20 | (tempcx & 0x00C0)));
5447 (
unsigned short) (0x30 | (tempcx & 0x00C0)));
5458 static void XGI_SetLCDCap_B(
unsigned short tempcx,
5463 (
unsigned short) (((tempcx & 0x00ff) >> 6)
5467 (
unsigned short) (((tempcx & 0x00ff) >> 6)
5478 for (i = 0; i < 0xFFFF; i++) {
5479 if (!(
inb(pVBInfo->
P3da) & 0x08))
5483 for (i = 0; i < 0xFFFF; i++) {
5484 if ((
inb(pVBInfo->
P3da) & 0x08))
5492 unsigned short index;
5494 index = XGI_GetLCDCapPtr(pVBInfo);
5498 XGI_LongWait(pVBInfo);
5500 XGI_LongWait(pVBInfo);
5510 XGI_LongWait(pVBInfo);
5516 unsigned short tempcx;
5518 tempcx = pVBInfo->
LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
5530 (
unsigned char) (tempcx & 0x1F));
5542 XGI_SetLCDCap_B(tempcx, pVBInfo);
5543 else if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA)
5544 XGI_SetLCDCap_A(tempcx, pVBInfo);
5548 SetSpectrum(pVBInfo);
5552 XGI_SetLCDCap_A(tempcx, pVBInfo);
5562 static void XGI_SetAntiFlicker(
unsigned short ModeNo,
5563 unsigned short ModeIdIndex,
5566 unsigned short tempbx;
5568 unsigned char tempah;
5573 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5575 tempah = TVAntiFlickList[tempbx];
5576 tempah = tempah << 4;
5581 static void XGI_SetEdgeEnhance(
unsigned short ModeNo,
5582 unsigned short ModeIdIndex,
5585 unsigned short tempbx;
5587 unsigned char tempah;
5589 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5591 tempah = TVEdgeList[tempbx];
5592 tempah = tempah << 5;
5599 unsigned short tempbx;
5601 unsigned char tempcl, tempch;
5603 unsigned long tempData;
5605 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo);
5606 tempData = TVPhaseList[tempbx];
5611 & 0x0000FF00) >> 8));
5613 & 0x00FF0000) >> 16));
5615 & 0xFF000000) >> 24));
5618 static void XGI_SetYFilter(
unsigned short ModeNo,
unsigned short ModeIdIndex,
5621 unsigned short tempbx,
index;
5623 unsigned char tempcl, tempch, tempal, *filterPtr;
5625 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo);
5630 filterPtr = NTSCYFilter1;
5634 filterPtr = PALYFilter1;
5641 filterPtr = xgifb_palmn_yfilter1;
5649 filterPtr = xgifb_yfilter2;
5656 tempal = pVBInfo->
EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
5662 if ((tempcl == 0) && (tempch == 1)) {
5688 static void XGI_OEM310Setting(
unsigned short ModeNo,
5689 unsigned short ModeIdIndex,
5692 XGI_SetDelayComp(pVBInfo);
5695 XGI_SetLCDCap(pVBInfo);
5697 if (pVBInfo->
VBInfo & SetCRT2ToTV) {
5698 XGI_SetPhaseIncr(pVBInfo);
5699 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
5700 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
5703 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
5713 static void XGI_SetCRT2ModeRegs(
unsigned short ModeNo,
5717 unsigned short tempbl;
5720 unsigned char tempah;
5723 if (!(pVBInfo->
VBInfo & DisableCRT2Display)) {
5735 tempah = (0x008 >> tempcl);
5749 if (pVBInfo->
VBInfo & DisableCRT2Display)
5759 if ((pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA) &&
5766 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA) {
5781 tempah = tempah ^ 0x05;
5783 tempah = tempah ^ 0x01;
5786 if (!(pVBInfo->
VBInfo & SetCRT2ToDualEdge))
5793 | XGI_SetCRT2ToLCDA)) {
5801 if (pVBInfo->
VBInfo & SetCRT2ToTV) {
5803 if (pVBInfo->
VBInfo & DriverMode)
5804 tempah = tempah ^ 0x20;
5813 if (pVBInfo->
VBInfo & SetCRT2ToTV) {
5833 if (pVBInfo->
VBInfo & SetCRT2ToDualEdge) {
5835 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA)
5842 if (!(pVBInfo->
VBInfo & DisableCRT2Display)) {
5843 if (pVBInfo->
VBInfo & SetCRT2ToDualEdge)
5851 if (!(pVBInfo->
VBInfo & DisableCRT2Display)) {
5852 if (pVBInfo->
VBInfo & SetCRT2ToDualEdge)
5860 if (!(pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA)) {
5862 if (!(pVBInfo->
VBInfo & SetCRT2ToDualEdge))
5895 unsigned short flag;
5901 if ((flag == 1) || (flag == 2))
5909 unsigned short ModeNo,
unsigned short ModeIdIndex,
5912 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
5913 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
5916 unsigned short RefreshRateTableIndex,
i, modeflag,
index,
temp;
5918 modeflag = pVBInfo->
EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5937 temp = LCDARefreshIndex[
5940 temp = LCDRefreshIndex[
5951 RefreshRateTableIndex = pVBInfo->
EModeIDTable[ModeIdIndex].REFindex;
5952 ModeNo = pVBInfo->
RefIndex[RefreshRateTableIndex].ModeID;
5954 if ((pVBInfo->
RefIndex[RefreshRateTableIndex].XRes == 800) &&
5955 (pVBInfo->
RefIndex[RefreshRateTableIndex].YRes == 600)) {
5959 if ((pVBInfo->
RefIndex[RefreshRateTableIndex].XRes == 1024) &&
5960 (pVBInfo->
RefIndex[RefreshRateTableIndex].YRes == 768)) {
5963 if ((pVBInfo->
RefIndex[RefreshRateTableIndex].XRes == 1280) &&
5964 (pVBInfo->
RefIndex[RefreshRateTableIndex].YRes == 1024)) {
5971 if (pVBInfo->
RefIndex[RefreshRateTableIndex + i].
5974 temp = pVBInfo->
RefIndex[RefreshRateTableIndex +
i].
5977 if (temp < pVBInfo->ModeType)
5982 }
while (index != 0xFFFF);
5985 temp = pVBInfo->
RefIndex[RefreshRateTableIndex + i - 1].
5987 if (temp & InterlaceMode)
5993 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
5994 RefreshRateTableIndex, &i, pVBInfo);
5996 return RefreshRateTableIndex +
i;
5999 static void XGI_SetLCDAGroup(
unsigned short ModeNo,
unsigned short ModeIdIndex,
6003 unsigned short RefreshRateTableIndex;
6007 ModeIdIndex, pVBInfo);
6008 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
6009 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6010 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6011 HwDeviceExtension, pVBInfo);
6012 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6013 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6016 static unsigned char XGI_SetCRT2Group301(
unsigned short ModeNo,
6020 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
6022 tempbx = pVBInfo->
VBInfo;
6027 ModeIdIndex, pVBInfo);
6028 XGI_SaveCRT2Info(ModeNo, pVBInfo);
6029 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
6030 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6031 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
6032 RefreshRateTableIndex, pVBInfo);
6033 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
6034 RefreshRateTableIndex, pVBInfo);
6035 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
6036 RefreshRateTableIndex, pVBInfo);
6037 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6038 HwDeviceExtension, pVBInfo);
6039 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
6040 RefreshRateTableIndex, pVBInfo);
6041 XGI_SetTap4Regs(pVBInfo);
6042 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
6043 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6044 HwDeviceExtension, pVBInfo);
6045 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6046 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
6047 XGI_AutoThreshold(pVBInfo);
6053 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
6054 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
6060 unsigned short temp;
6061 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
6069 pVBInfo->
P3d4, 0x53) | 0x02));
6091 for (i = 0; i < 8; i++)
6094 for (i = 8; i < 11; i++)
6098 for (i = 11; i < 13; i++)
6102 for (i = 13; i < 16; i++)
6115 for (i = 0; i < 256; i++) {
6116 outb((
unsigned char) DAC_TEST_PARMS[0], (pVBInfo->
P3c8 + 1));
6117 outb((
unsigned char) DAC_TEST_PARMS[1], (pVBInfo->
P3c8 + 1));
6118 outb((
unsigned char) DAC_TEST_PARMS[2], (pVBInfo->
P3c8 + 1));
6123 XGI_WaitDisply(pVBInfo);
6134 for (i = 0; i < 256; i++) {
6145 pVBInfo->
P3d4, 0x53) & 0xFD));
6153 unsigned short tempah;
6161 }
else if (pVBInfo->
VBInfo & SetCRT2ToDualEdge) {
6173 pVBInfo->
P3c4, 0x32);
6186 if (!(tempah & 0x80))
6194 || (!(pVBInfo->
VBInfo & DisableCRT2Display))) {
6198 if (!XGI_DisableChISLCD(pVBInfo)) {
6199 if (XGI_EnableChISLCD(pVBInfo) ||
6215 if (!(pVBInfo->
VBInfo & DisableCRT2Display)) {
6219 (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA) &&
6220 (pVBInfo->
VBInfo & SetCRT2ToDualEdge)) {
6221 tempah = tempah & 0x40;
6222 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA)
6223 tempah = tempah ^ 0xC0;
6244 XGI_DisableGatingCRT(HwDeviceExtension,
6246 XGI_DisplayOn(xgifb_info, HwDeviceExtension,
6253 | XGI_SetCRT2ToLCDA))
6259 if (!(tempah & 0x80))
6263 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
6269 unsigned short ModeNo,
unsigned short ModeIdIndex,
6272 unsigned short RefreshRateTableIndex,
temp;
6274 XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo);
6276 XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo);
6277 XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo);
6278 XGI_SetGRCRegs(pVBInfo);
6279 XGI_ClearExt1Regs(pVBInfo);
6283 XGI_SetDefaultVCLK(pVBInfo);
6299 ModeIdIndex, pVBInfo);
6300 if (RefreshRateTableIndex != 0xFFFF) {
6301 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
6302 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6303 pVBInfo, HwDeviceExtension);
6304 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
6305 RefreshRateTableIndex, pVBInfo);
6306 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6307 HwDeviceExtension, pVBInfo);
6308 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
6309 RefreshRateTableIndex, pVBInfo);
6317 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
6318 RefreshRateTableIndex, pVBInfo);
6320 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
6321 RefreshRateTableIndex, pVBInfo);
6323 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
6324 RefreshRateTableIndex);
6326 xgifb_set_lcd(HwDeviceExtension->
jChipType,
6327 pVBInfo, RefreshRateTableIndex, ModeNo);
6330 xgifb_set_lvds(xgifb_info,
6332 ModeNo, ModeIdIndex, pVBInfo);
6337 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
6338 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
6339 RefreshRateTableIndex, pVBInfo);
6340 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
6345 unsigned short ModeNo)
6347 unsigned short ModeIdIndex;
6400 ModeNo = ModeNo & 0x7F;
6409 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
6410 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
6411 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
6412 XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
6415 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
6416 ModeIdIndex, pVBInfo);
6418 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA) {
6419 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
6420 HwDeviceExtension, pVBInfo);
6423 XGI_SetCRT1Group(xgifb_info,
6424 HwDeviceExtension, ModeNo,
6425 ModeIdIndex, pVBInfo);
6426 if (pVBInfo->
VBInfo & XGI_SetCRT2ToLCDA) {
6427 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
6436 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
6441 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
6450 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
6451 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo);
6452 XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
6456 if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo,
6469 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
6470 ModeIdIndex, pVBInfo);
6472 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
6475 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);