Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 1 | #include <linux/delay.h> |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2 | #include "XGIfb.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4 | #include "vb_def.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5 | #include "vb_util.h" |
| 6 | #include "vb_table.h" |
Miguel Gómez | e054102 | 2012-06-18 13:12:05 +0200 | [diff] [blame] | 7 | #include "vb_setmode.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 8 | |
| 9 | #define IndexMask 0xff |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 10 | #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 11 | |
Aaro Koskinen | 624554d | 2011-10-11 21:47:35 +0300 | [diff] [blame] | 12 | static const unsigned short XGINew_VGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 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}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 23 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 24 | void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 25 | { |
Aaro Koskinen | fb60d0c | 2012-04-07 01:14:04 +0300 | [diff] [blame] | 26 | pVBInfo->StandTable = (struct SiS_StandTable_S *) &XGI330_StandTable; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 27 | pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable; |
| 28 | pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex; |
| 29 | pVBInfo->XGINEWUB_CRT1Table |
| 30 | = (struct XGI_CRT1TableStruct *) XGI_CRT1Table; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 31 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 32 | pVBInfo->MCLKData = (struct SiS_MCLKData *) XGI340New_MCLKData; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 33 | pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 34 | pVBInfo->VCLKData = (struct SiS_VCLKData *) XGI_VCLKData; |
| 35 | pVBInfo->VBVCLKData = (struct SiS_VBVCLKData *) XGI_VBVCLKData; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 36 | pVBInfo->ScreenOffset = XGI330_ScreenOffset; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 37 | pVBInfo->StResInfo = (struct SiS_StResInfo_S *) XGI330_StResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 38 | pVBInfo->ModeResInfo |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 39 | = (struct SiS_ModeResInfo_S *) XGI330_ModeResInfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 40 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 41 | pVBInfo->LCDResInfo = 0; |
| 42 | pVBInfo->LCDTypeInfo = 0; |
| 43 | pVBInfo->LCDInfo = 0; |
| 44 | pVBInfo->VBInfo = 0; |
| 45 | pVBInfo->TVInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 46 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 47 | pVBInfo->SR15 = XGI340_SR13; |
| 48 | pVBInfo->CR40 = XGI340_cr41; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 49 | pVBInfo->CR6B = XGI340_CR6B; |
| 50 | pVBInfo->CR6E = XGI340_CR6E; |
| 51 | pVBInfo->CR6F = XGI340_CR6F; |
| 52 | pVBInfo->CR89 = XGI340_CR89; |
| 53 | pVBInfo->AGPReg = XGI340_AGPReg; |
| 54 | pVBInfo->SR16 = XGI340_SR16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 55 | |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 56 | pVBInfo->SR21 = 0xa3; |
| 57 | pVBInfo->SR22 = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 58 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 59 | pVBInfo->NTSCTiming = XGI330_NTSCTiming; |
| 60 | pVBInfo->PALTiming = XGI330_PALTiming; |
| 61 | pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming; |
| 62 | pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing; |
| 63 | pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing; |
| 64 | pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming; |
| 65 | pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming; |
| 66 | pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming; |
| 67 | pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming; |
| 68 | pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data; |
| 69 | pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu; |
| 70 | pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text; |
| 71 | pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3; |
| 72 | pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 73 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 74 | pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH; |
| 75 | pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV; |
| 76 | pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 77 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 78 | /* 310 customization related */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 79 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 80 | pVBInfo->LCDCapList = XGI_LCDDLCapList; |
| 81 | else |
| 82 | pVBInfo->LCDCapList = XGI_LCDCapList; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 83 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 84 | if (ChipType >= XG20) |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 85 | pVBInfo->XGINew_CR97 = 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 86 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 87 | if (ChipType == XG27) { |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 88 | unsigned char temp; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 89 | pVBInfo->MCLKData |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 90 | = (struct SiS_MCLKData *) XGI27New_MCLKData; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 91 | pVBInfo->CR40 = XGI27_cr41; |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 92 | pVBInfo->XGINew_CR97 = 0xc1; |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 93 | pVBInfo->SR15 = XG27_SR13; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 94 | |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 95 | /*Z11m DDR*/ |
| 96 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B); |
| 97 | /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */ |
| 98 | if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08)) |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 99 | pVBInfo->XGINew_CR97 = 0x80; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 100 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 101 | |
| 102 | } |
| 103 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 104 | static void XGI_SetSeqRegs(unsigned short ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 105 | unsigned short ModeIdIndex, |
| 106 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 107 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 108 | unsigned char tempah, SRdata; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 109 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 110 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 111 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 112 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 113 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
Aaro Koskinen | fb60d0c | 2012-04-07 01:14:04 +0300 | [diff] [blame] | 114 | tempah = pVBInfo->StandTable->SR[0]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 115 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 116 | i = XGI_SetCRT2ToLCDA; |
| 117 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 118 | tempah |= 0x01; |
| 119 | } else { |
| 120 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { |
| 121 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 122 | tempah |= 0x01; |
| 123 | } |
| 124 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 125 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 126 | tempah |= 0x20; /* screen off */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 127 | xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 128 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 129 | for (i = 02; i <= 04; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 130 | /* Get SR2,3,4 from file */ |
Aaro Koskinen | fb60d0c | 2012-04-07 01:14:04 +0300 | [diff] [blame] | 131 | SRdata = pVBInfo->StandTable->SR[i - 1]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 132 | xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 133 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 134 | } |
| 135 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 136 | static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 137 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 138 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 139 | unsigned char CRTCdata; |
| 140 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 141 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 142 | CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 143 | CRTCdata &= 0x7f; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 144 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 145 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 146 | for (i = 0; i <= 0x18; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 147 | /* Get CRTC from file */ |
Aaro Koskinen | fb60d0c | 2012-04-07 01:14:04 +0300 | [diff] [blame] | 148 | CRTCdata = pVBInfo->StandTable->CRTC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 149 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 150 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 151 | } |
| 152 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 153 | static void XGI_SetATTRegs(unsigned short ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 154 | unsigned short ModeIdIndex, |
| 155 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 156 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 157 | unsigned char ARdata; |
| 158 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 159 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 160 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 161 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 162 | for (i = 0; i <= 0x13; i++) { |
Aaro Koskinen | fb60d0c | 2012-04-07 01:14:04 +0300 | [diff] [blame] | 163 | ARdata = pVBInfo->StandTable->ATTR[i]; |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 164 | |
| 165 | if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */ |
| 166 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 167 | ARdata = 0; |
| 168 | } else { |
| 169 | if ((pVBInfo->VBInfo & |
| 170 | (SetCRT2ToTV | SetCRT2ToLCD)) && |
| 171 | (pVBInfo->VBInfo & SetInSlaveMode)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 172 | ARdata = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 173 | } |
| 174 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 175 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 176 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 177 | outb(i, pVBInfo->P3c0); /* set index */ |
| 178 | outb(ARdata, pVBInfo->P3c0); /* set data */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 179 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 180 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 181 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 182 | outb(0x14, pVBInfo->P3c0); /* set index */ |
| 183 | outb(0x00, pVBInfo->P3c0); /* set data */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 184 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 185 | outb(0x20, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 186 | } |
| 187 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 188 | static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 189 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 190 | unsigned char GRdata; |
| 191 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 192 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 193 | for (i = 0; i <= 0x08; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 194 | /* Get GR from file */ |
Aaro Koskinen | fb60d0c | 2012-04-07 01:14:04 +0300 | [diff] [blame] | 195 | GRdata = pVBInfo->StandTable->GRC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 196 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 197 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 198 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 199 | if (pVBInfo->ModeType > ModeVGA) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 200 | GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 201 | GRdata &= 0xBF; /* 256 color disable */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 202 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 203 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 204 | } |
| 205 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 206 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 207 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 208 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 209 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 210 | for (i = 0x0A; i <= 0x0E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 211 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 212 | } |
| 213 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 214 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 215 | { |
| 216 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 217 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 218 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B); |
| 219 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 220 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 221 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 222 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B); |
| 223 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 224 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 225 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 226 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 227 | } |
| 228 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 229 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 230 | unsigned short ModeIdIndex, |
| 231 | unsigned short RefreshRateTableIndex, unsigned short *i, |
| 232 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 233 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 234 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 235 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 236 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 237 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 238 | tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID; |
| 239 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 240 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 241 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 242 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 243 | tempax |= SupportRAMDAC2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 244 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 245 | if (pVBInfo->VBType & VB_XGI301C) |
| 246 | tempax |= SupportCRT2in301C; |
| 247 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 248 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 249 | /* 301b */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 250 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 251 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 252 | |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 253 | if (pVBInfo->LCDResInfo != Panel_1280x1024 && |
| 254 | pVBInfo->LCDResInfo != Panel_1280x960 && |
| 255 | (pVBInfo->LCDInfo & LCDNonExpanding) && |
| 256 | resinfo >= 9) |
| 257 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 258 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 259 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 260 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 261 | if ((pVBInfo->VBType & VB_SIS301LV) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 262 | (pVBInfo->VBExtInfo == VB_YPbPr1080i)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 263 | tempax |= SupportYPbPr750p; |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 264 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 265 | ((resinfo == 3) || |
| 266 | (resinfo == 4) || |
| 267 | (resinfo > 7))) |
| 268 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 269 | } else { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 270 | tempax |= SupportHiVision; |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 271 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 272 | ((resinfo == 4) || |
| 273 | (resinfo == 3 && |
| 274 | (pVBInfo->SetFlag & TVSimuMode)) || |
| 275 | (resinfo > 7))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 276 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 277 | } |
| 278 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 279 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
| 280 | SetCRT2ToSVIDEO | |
| 281 | SetCRT2ToSCART | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 282 | SetCRT2ToYPbPr525750 | |
| 283 | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 284 | tempax |= SupportTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 285 | |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 286 | if (pVBInfo->VBType & (VB_SIS301B | |
| 287 | VB_SIS302B | |
| 288 | VB_SIS301LV | |
| 289 | VB_SIS302LV | |
| 290 | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 291 | tempax |= SupportTV1024; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 292 | |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 293 | if (!(pVBInfo->VBInfo & TVSetPAL) && |
| 294 | (modeflag & NoSupportSimuTV) && |
| 295 | (pVBInfo->VBInfo & SetInSlaveMode) && |
| 296 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
| 297 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | } else { /* for LVDS */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 301 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 302 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 303 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 304 | if (resinfo > 0x08) |
| 305 | return 0; /* 1024x768 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 306 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 307 | if (pVBInfo->LCDResInfo < Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 308 | if (resinfo > 0x07) |
| 309 | return 0; /* 800x600 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 310 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 311 | if (resinfo == 0x04) |
| 312 | return 0; /* 512x384 */ |
| 313 | } |
| 314 | } |
| 315 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 316 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 317 | for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
| 318 | tempbx; (*i)--) { |
| 319 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
| 320 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 321 | if (infoflag & tempax) |
| 322 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 323 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 324 | if ((*i) == 0) |
| 325 | break; |
| 326 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 327 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 328 | for ((*i) = 0;; (*i)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 329 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
| 330 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 331 | if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID |
| 332 | != tempbx) { |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | if (infoflag & tempax) |
| 337 | return 1; |
| 338 | } |
| 339 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 340 | } |
| 341 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 342 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 343 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 344 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 345 | unsigned short sync, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 346 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 347 | /* di+0x00 */ |
| 348 | sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 349 | sync &= 0xC0; |
| 350 | temp = 0x2F; |
| 351 | temp |= sync; |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 352 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 353 | } |
| 354 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 355 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 356 | struct xgi_hw_device_info *HwDeviceExtension) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 357 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 358 | unsigned char data, data1, pushax; |
| 359 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 360 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 361 | /* unlock cr0-7 */ |
| 362 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 363 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 364 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 365 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 366 | data = pVBInfo->TimingH[0].data[0]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 367 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 368 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 369 | for (i = 0x01; i <= 0x04; i++) { |
| 370 | data = pVBInfo->TimingH[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 371 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 372 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 373 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 374 | for (i = 0x05; i <= 0x06; i++) { |
| 375 | data = pVBInfo->TimingH[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 376 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 377 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 378 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 379 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 380 | j &= 0x1F; |
| 381 | data = pVBInfo->TimingH[0].data[7]; |
| 382 | data &= 0xE0; |
| 383 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 384 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 385 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 386 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 387 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 388 | data = data - 1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 389 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 390 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 391 | data1 = data; |
| 392 | data1 &= 0xE0; |
| 393 | data &= 0x1F; |
| 394 | if (data == 0) { |
| 395 | pushax = data; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 396 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 397 | 0x0c); |
| 398 | data &= 0xFB; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 399 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 400 | data = pushax; |
| 401 | } |
| 402 | data = data - 1; |
| 403 | data |= data1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 404 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 405 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 406 | data = data >> 5; |
| 407 | data = data + 3; |
| 408 | if (data > 7) |
| 409 | data = data - 7; |
| 410 | data = data << 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 411 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 412 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 413 | } |
| 414 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 415 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
| 416 | unsigned short ModeNo, |
| 417 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 418 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 419 | unsigned char data; |
| 420 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 421 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 422 | for (i = 0x00; i <= 0x01; i++) { |
| 423 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 424 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 425 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 426 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 427 | for (i = 0x02; i <= 0x03; i++) { |
| 428 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 429 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 430 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 431 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 432 | for (i = 0x04; i <= 0x05; i++) { |
| 433 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 434 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 435 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 436 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 437 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 438 | j &= 0xC0; |
| 439 | data = pVBInfo->TimingV[0].data[6]; |
| 440 | data &= 0x3F; |
| 441 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 442 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 443 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 444 | data = pVBInfo->TimingV[0].data[6]; |
| 445 | data &= 0x80; |
| 446 | data = data >> 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 447 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 448 | i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 449 | i &= DoubleScanMode; |
| 450 | if (i) |
| 451 | data |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 452 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 453 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 454 | j &= 0x5F; |
| 455 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 456 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 457 | } |
| 458 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 459 | static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 460 | unsigned short RefreshRateTableIndex, |
| 461 | struct vb_device_info *pVBInfo, |
| 462 | struct xgi_hw_device_info *HwDeviceExtension) |
| 463 | { |
| 464 | unsigned char index, data; |
| 465 | unsigned short i; |
| 466 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 467 | /* Get index */ |
| 468 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 469 | index = index & IndexMask; |
| 470 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 471 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 472 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 473 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 474 | |
| 475 | for (i = 0; i < 8; i++) |
| 476 | pVBInfo->TimingH[0].data[i] |
| 477 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i]; |
| 478 | |
| 479 | for (i = 0; i < 7; i++) |
| 480 | pVBInfo->TimingV[0].data[i] |
| 481 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8]; |
| 482 | |
| 483 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 484 | |
| 485 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
| 486 | |
| 487 | if (pVBInfo->ModeType > 0x03) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 488 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 489 | } |
| 490 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 491 | /* --------------------------------------------------------------------- */ |
| 492 | /* Function : XGI_SetXG21CRTC */ |
| 493 | /* Input : Stand or enhance CRTC table */ |
| 494 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ |
| 495 | /* Description : Set LCD timing */ |
| 496 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 497 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 498 | unsigned short RefreshRateTableIndex, |
| 499 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 500 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 501 | unsigned char index, Tempax, Tempbx, Tempcx, Tempdx; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 502 | unsigned short Temp1, Temp2, Temp3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 503 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 504 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
| 505 | /* Tempax: CR4 HRS */ |
| 506 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
| 507 | Tempcx = Tempax; /* Tempcx: HRS */ |
| 508 | /* SR2E[7:0]->HRS */ |
| 509 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 510 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 511 | Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */ |
| 512 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ |
| 513 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ |
| 514 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ |
| 515 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 516 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 517 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
| 518 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 519 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 520 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
| 521 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ |
| 522 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ |
| 523 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 524 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 525 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
| 526 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 527 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 528 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
| 529 | if (Tempax < Tempcx) /* HRE < HRS */ |
| 530 | Temp2 |= 0x40; /* Temp2 + 0x40 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 531 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 532 | Temp2 &= 0xFF; |
| 533 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ |
| 534 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ |
| 535 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ |
| 536 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ |
| 537 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
| 538 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 539 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 540 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 541 | /* CR10 VRS */ |
| 542 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; |
| 543 | Tempbx = Tempax; /* Tempbx: VRS */ |
| 544 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ |
| 545 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
| 546 | /* CR7[2][7] VRE */ |
| 547 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; |
| 548 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
| 549 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ |
| 550 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ |
| 551 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ |
| 552 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 553 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 554 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
| 555 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ |
| 556 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 557 | Tempax &= 0x80; |
| 558 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 559 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
| 560 | /* Tempax: SRA */ |
| 561 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
| 562 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
| 563 | Temp2 = Tempax; |
| 564 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ |
| 565 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 566 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 567 | /* Tempax: CR11 VRE */ |
| 568 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; |
| 569 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 570 | /* Tempbx: SRA */ |
| 571 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
| 572 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
| 573 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 574 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 575 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ |
| 576 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 577 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 578 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
| 579 | if (Tempax < Temp3) /* VRE < VRS */ |
| 580 | Temp2 |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 581 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 582 | Temp2 &= 0xFF; |
| 583 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ |
| 584 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ |
| 585 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 586 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ |
| 587 | Tempbx = (unsigned char) Temp1; |
| 588 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ |
| 589 | Tempax &= 0x7F; |
| 590 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 591 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 592 | } |
| 593 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 594 | static void XGI_SetXG27CRTC(unsigned short ModeNo, |
| 595 | unsigned short ModeIdIndex, |
| 596 | unsigned short RefreshRateTableIndex, |
| 597 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 598 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 599 | unsigned short index, Tempax, Tempbx, Tempcx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 600 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 601 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
| 602 | /* Tempax: CR4 HRS */ |
| 603 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
| 604 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
| 605 | /* SR2E[7:0]->HRS */ |
| 606 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 607 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 608 | /* SR0B */ |
| 609 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; |
| 610 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 611 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 612 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 613 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
| 614 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
| 615 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 616 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 617 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
| 618 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ |
| 619 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ |
| 620 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 621 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 622 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
| 623 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 624 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 625 | /* Tempax: CR4 HRS */ |
| 626 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
| 627 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
| 628 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ |
| 629 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 630 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 631 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */ |
| 632 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 633 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ |
| 634 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ |
| 635 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
| 636 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 637 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 638 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 639 | /* CR10 VRS */ |
| 640 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; |
| 641 | /* SR34[7:0]->VRS[7:0] */ |
| 642 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 643 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 644 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
| 645 | /* CR7[7][2] VRS[9][8] */ |
| 646 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; |
| 647 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
| 648 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ |
| 649 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ |
| 650 | /* SR35[0]: VRS[8] */ |
| 651 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
| 652 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
| 653 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ |
| 654 | /* Tempax: SR0A */ |
| 655 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
| 656 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
| 657 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 658 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 659 | /* Tempax: CR11 VRE */ |
| 660 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; |
| 661 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 662 | /* Tempbx: SR0A */ |
| 663 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
| 664 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
| 665 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 666 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 667 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ |
| 668 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ |
| 669 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 670 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 671 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
| 672 | Tempbx |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 673 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 674 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
| 675 | Tempax = (Tempbx << 2) & 0xFF; |
| 676 | /* SR3F[7:2]:VRE[5:0] */ |
| 677 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
| 678 | Tempax = Tempcx >> 8; |
| 679 | /* SR35[2:0]:VRS[10:8] */ |
| 680 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 681 | } |
| 682 | |
Aaro Koskinen | a2d08cf | 2011-11-27 23:03:08 +0200 | [diff] [blame] | 683 | static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
| 684 | { |
| 685 | unsigned char temp; |
| 686 | |
| 687 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 688 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 689 | temp = (temp & 3) << 6; |
| 690 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 691 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 692 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 693 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 694 | |
| 695 | } |
| 696 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 697 | static void xgifb_set_lcd(int chip_id, |
| 698 | struct vb_device_info *pVBInfo, |
| 699 | unsigned short RefreshRateTableIndex, |
| 700 | unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 701 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 702 | unsigned short Data, Temp; |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 703 | unsigned short XGI_P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 704 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 705 | XGI_P3cc = pVBInfo->P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 706 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 707 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 708 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 709 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 710 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 711 | |
| 712 | if (chip_id == XG27) { |
| 713 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 714 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
| 715 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 716 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
| 717 | } |
| 718 | } |
| 719 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 720 | if (chip_id == XG27) { |
| 721 | XGI_SetXG27FPBits(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 722 | } else { |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 723 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 724 | if (Temp & 0x01) { |
| 725 | /* 18 bits FP */ |
| 726 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); |
| 727 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
| 728 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 729 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 730 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 731 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 732 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 733 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 734 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 735 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 736 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 737 | if (Data & 0x4000) |
| 738 | /* Hsync polarity */ |
| 739 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
| 740 | if (Data & 0x8000) |
| 741 | /* Vsync polarity */ |
| 742 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | /* --------------------------------------------------------------------- */ |
| 746 | /* Function : XGI_UpdateXG21CRTC */ |
| 747 | /* Input : */ |
| 748 | /* Output : CRT1 CRTC */ |
| 749 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 750 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 751 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 752 | struct vb_device_info *pVBInfo, |
| 753 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 754 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 755 | int index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 756 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 757 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 758 | if (ModeNo == 0x2E && |
| 759 | (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
| 760 | RES640x480x60)) |
| 761 | index = 12; |
| 762 | else if (ModeNo == 0x2E && (pVBInfo->RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 763 | Ext_CRT1CRTC == RES640x480x72)) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 764 | index = 13; |
| 765 | else if (ModeNo == 0x2F) |
| 766 | index = 14; |
| 767 | else if (ModeNo == 0x50) |
| 768 | index = 15; |
| 769 | else if (ModeNo == 0x59) |
| 770 | index = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 771 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 772 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 773 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 774 | pVBInfo->UpdateCRT1[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 775 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 776 | pVBInfo->UpdateCRT1[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 777 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 778 | pVBInfo->UpdateCRT1[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 779 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 780 | pVBInfo->UpdateCRT1[index].CR16); |
| 781 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 782 | } |
| 783 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 784 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 785 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 786 | unsigned short RefreshRateTableIndex, |
| 787 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 788 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 789 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 790 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 791 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 792 | |
Aaro Koskinen | 6c0965f | 2012-04-07 01:14:11 +0300 | [diff] [blame] | 793 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 794 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 795 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 796 | tempax = pVBInfo->ModeResInfo[resindex].HTotal; |
| 797 | tempbx = pVBInfo->ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 798 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 799 | if (modeflag & HalfDCLK) |
| 800 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 801 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 802 | if (modeflag & HalfDCLK) |
| 803 | tempax = tempax << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 804 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 805 | temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 806 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 807 | if (temp & InterlaceMode) |
| 808 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 809 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 810 | if (modeflag & DoubleScanMode) |
| 811 | tempbx = tempbx << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 812 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 813 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 814 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 815 | tempax /= tempcx; |
| 816 | tempax -= 1; |
| 817 | tempbx -= 1; |
| 818 | tempcx = tempax; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 819 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 820 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 821 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 822 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 823 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 824 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 825 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 826 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 827 | tempax = 0; |
| 828 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 829 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 830 | if (tempbx & 0x01) |
| 831 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 832 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 833 | if (tempbx & 0x02) |
| 834 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 835 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 836 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 837 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 838 | data &= 0xFF; |
| 839 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 840 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 841 | if (tempbx & 0x04) |
| 842 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 843 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 844 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 845 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 846 | } |
| 847 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 848 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 849 | unsigned short ModeIdIndex, |
| 850 | unsigned short RefreshRateTableIndex, |
| 851 | struct xgi_hw_device_info *HwDeviceExtension, |
| 852 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 853 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 854 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 855 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 856 | /* GetOffset */ |
| 857 | temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 858 | temp = temp >> 8; |
| 859 | temp = pVBInfo->ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 860 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 861 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 862 | temp2 &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 863 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 864 | if (temp2) |
| 865 | temp = temp << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 866 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 867 | temp2 = pVBInfo->ModeType - ModeEGA; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 868 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 869 | switch (temp2) { |
| 870 | case 0: |
| 871 | temp2 = 1; |
| 872 | break; |
| 873 | case 1: |
| 874 | temp2 = 2; |
| 875 | break; |
| 876 | case 2: |
| 877 | temp2 = 4; |
| 878 | break; |
| 879 | case 3: |
| 880 | temp2 = 4; |
| 881 | break; |
| 882 | case 4: |
| 883 | temp2 = 6; |
| 884 | break; |
| 885 | case 5: |
| 886 | temp2 = 8; |
| 887 | break; |
| 888 | default: |
| 889 | break; |
| 890 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 891 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 892 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 893 | temp = temp * temp2 + temp2 / 2; |
| 894 | else |
| 895 | temp *= temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 896 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 897 | /* SetOffset */ |
| 898 | DisplayUnit = temp; |
| 899 | temp2 = temp; |
| 900 | temp = temp >> 8; /* ah */ |
| 901 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 902 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 903 | i &= 0xF0; |
| 904 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 905 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 906 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 907 | temp = (unsigned char) temp2; |
| 908 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 909 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 910 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 911 | /* SetDisplayUnit */ |
| 912 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 913 | temp2 &= InterlaceMode; |
| 914 | if (temp2) |
| 915 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 916 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 917 | DisplayUnit = DisplayUnit << 5; |
| 918 | ah = (DisplayUnit & 0xff00) >> 8; |
| 919 | al = DisplayUnit & 0x00ff; |
| 920 | if (al == 0) |
| 921 | ah += 1; |
| 922 | else |
| 923 | ah += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 924 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 925 | if (HwDeviceExtension->jChipType >= XG20) |
| 926 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 927 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 928 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 929 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 930 | } |
| 931 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 932 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
| 933 | unsigned short ModeIdIndex, |
| 934 | unsigned short RefreshRateTableIndex, |
| 935 | struct xgi_hw_device_info *HwDeviceExtension, |
| 936 | struct vb_device_info *pVBInfo) |
| 937 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 938 | unsigned short CRT2Index, VCLKIndex; |
| 939 | unsigned short modeflag, resinfo; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 940 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 941 | /* si+Ext_ResInfo */ |
| 942 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 943 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 944 | CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 945 | |
| 946 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 947 | CRT2Index = CRT2Index >> 6; /* for LCD */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 948 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 949 | if (pVBInfo->LCDResInfo != Panel_1024x768) |
Peter Huewe | f477d3e | 2012-06-14 00:21:47 +0200 | [diff] [blame] | 950 | VCLKIndex = VCLK108_2_315 + 5; /* LCDXlat2VCLK */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 951 | else |
Peter Huewe | f477d3e | 2012-06-14 00:21:47 +0200 | [diff] [blame] | 952 | VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 953 | } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 954 | if (pVBInfo->SetFlag & RPLLDIV2XO) { |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 955 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 956 | } else { |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 957 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 958 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 959 | |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 960 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 961 | if (modeflag & Charx8Dot) { |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 962 | VCLKIndex = TVCLKBASE_315_25 + HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 963 | } else { |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 964 | VCLKIndex = TVCLKBASE_315_25 + HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 965 | } |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | /* 301lv */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 969 | if ((pVBInfo->VBType & VB_SIS301LV) && |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 970 | !(pVBInfo->VBExtInfo == VB_YPbPr1080i)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 971 | if (pVBInfo->VBExtInfo == YPbPr750p) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 972 | VCLKIndex = XGI_YPbPr750pVCLK; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 973 | else if (pVBInfo->VBExtInfo == YPbPr525p) |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 974 | VCLKIndex = YPbPr525pVCLK; |
| 975 | else if (pVBInfo->SetFlag & RPLLDIV2XO) |
| 976 | VCLKIndex = YPbPr525iVCLK_2; |
| 977 | else |
| 978 | VCLKIndex = YPbPr525iVCLK; |
| 979 | } |
| 980 | } else if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 981 | if (pVBInfo->SetFlag & RPLLDIV2XO) { |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 982 | VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 983 | } else { |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 984 | VCLKIndex = TVCLKBASE_315_25 + TVVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 985 | } |
| 986 | } else { /* for CRT2 */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 987 | /* di+Ext_CRTVCLK */ |
| 988 | VCLKIndex = pVBInfo->RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 989 | Ext_CRTVCLK; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 990 | VCLKIndex &= IndexMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 991 | } |
| 992 | } else { /* LVDS */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 993 | if ((pVBInfo->LCDResInfo == Panel_800x600) || |
| 994 | (pVBInfo->LCDResInfo == Panel_320x480)) |
Peter Huewe | f477d3e | 2012-06-14 00:21:47 +0200 | [diff] [blame] | 995 | VCLKIndex = VCLK40; /* LVDSXlat1VCLK */ |
Aaro Koskinen | 4c14bfd | 2011-08-31 21:45:57 +0300 | [diff] [blame] | 996 | else |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 997 | VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK, LVDSXlat3VCLK */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 998 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 999 | |
| 1000 | return VCLKIndex; |
| 1001 | } |
| 1002 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1003 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
| 1004 | unsigned short ModeIdIndex, |
| 1005 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1006 | unsigned short RefreshRateTableIndex, |
| 1007 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1008 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 1009 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1010 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1011 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1012 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 1013 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1014 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1015 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1016 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1017 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1018 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1019 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1020 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1021 | } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 1022 | | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1023 | & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1024 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, |
| 1025 | RefreshRateTableIndex, HwDeviceExtension, |
| 1026 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1027 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1028 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1029 | data = pVBInfo->VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1030 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1031 | data = pVBInfo->VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1032 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 1033 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1034 | } else { |
| 1035 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1036 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1037 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1038 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1039 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1040 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1041 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1042 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1043 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1044 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1045 | if (HwDeviceExtension->jChipType >= XG20) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1046 | if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
| 1047 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1048 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1049 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1050 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1051 | index = data; |
| 1052 | index &= 0xE0; |
| 1053 | data &= 0x1F; |
| 1054 | data = data << 1; |
| 1055 | data += 1; |
| 1056 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1057 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1058 | } |
| 1059 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1060 | } |
| 1061 | |
Aaro Koskinen | e85f203 | 2011-11-27 23:03:07 +0200 | [diff] [blame] | 1062 | static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
| 1063 | { |
| 1064 | unsigned char temp; |
| 1065 | |
| 1066 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
| 1067 | temp = (temp & 1) << 6; |
| 1068 | /* SR06[6] 18bit Dither */ |
| 1069 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 1070 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 1071 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 1072 | |
| 1073 | } |
| 1074 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1075 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1076 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1077 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1078 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1079 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1080 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1081 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1082 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1083 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1084 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1085 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
| 1086 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
| 1087 | data &= 0xC0; |
| 1088 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
| 1089 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
| 1090 | data |= 0x01; |
| 1091 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1092 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1093 | if (HwDeviceExtension->jChipType == XG21) |
| 1094 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1095 | } |
| 1096 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1097 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
| 1098 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, |
| 1099 | struct vb_device_info *pVBInfo) |
| 1100 | { |
| 1101 | unsigned short data, data2 = 0; |
| 1102 | short VCLK; |
| 1103 | |
| 1104 | unsigned char index; |
| 1105 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1106 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 1107 | index &= IndexMask; |
| 1108 | VCLK = pVBInfo->VCLKData[index].CLOCK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1109 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1110 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1111 | data &= 0xf3; |
| 1112 | if (VCLK >= 200) |
| 1113 | data |= 0x0c; /* VCLK > 200 */ |
| 1114 | |
| 1115 | if (HwDeviceExtension->jChipType >= XG20) |
| 1116 | data &= ~0x04; /* 2 pixel mode */ |
| 1117 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1118 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1119 | |
| 1120 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1121 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1122 | data &= 0xE7; |
| 1123 | if (VCLK < 200) |
| 1124 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1125 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1126 | } |
| 1127 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1128 | data2 = 0x00; |
| 1129 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1130 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1131 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1132 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1133 | |
| 1134 | } |
| 1135 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1136 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1137 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1138 | unsigned short RefreshRateTableIndex, |
| 1139 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1140 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1141 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1142 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1143 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1144 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1145 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1146 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1147 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1148 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1149 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1150 | data = infoflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1151 | data2 = 0; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1152 | data2 |= 0x02; |
| 1153 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1154 | data3 = data3 << 2; |
| 1155 | data2 |= data3; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1156 | data &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1157 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1158 | if (data) |
| 1159 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1160 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1161 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Aaro Koskinen | 6c0965f | 2012-04-07 01:14:11 +0300 | [diff] [blame] | 1162 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1163 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1164 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1165 | data = 0x0000; |
| 1166 | if (infoflag & InterlaceMode) { |
| 1167 | if (xres == 1024) |
| 1168 | data = 0x0035; |
| 1169 | else if (xres == 1280) |
| 1170 | data = 0x0048; |
| 1171 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1172 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1173 | data2 = data & 0x00FF; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1174 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1175 | data2 = (data & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1176 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1177 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1178 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1179 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1180 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1181 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1182 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1183 | if (modeflag & LineCompareOff) |
| 1184 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1185 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1186 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1187 | data = 0x60; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1188 | data = data ^ 0x60; |
| 1189 | data = data ^ 0xA0; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1190 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1191 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1192 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, |
| 1193 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1194 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1195 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1196 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1197 | if (HwDeviceExtension->jChipType == XG27) { |
| 1198 | if (data & 0x40) |
| 1199 | data = 0x2c; |
| 1200 | else |
| 1201 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1202 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1203 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1204 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1205 | if (data & 0x40) |
| 1206 | data = 0x33; |
| 1207 | else |
| 1208 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1209 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1210 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1211 | } else { |
| 1212 | if (data & 0x40) |
| 1213 | data = 0x2c; |
| 1214 | else |
| 1215 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1216 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1217 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1218 | |
| 1219 | } |
| 1220 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1221 | static void XGI_WriteDAC(unsigned short dl, |
| 1222 | unsigned short ah, |
| 1223 | unsigned short al, |
| 1224 | unsigned short dh, |
| 1225 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1226 | { |
| 1227 | unsigned short temp, bh, bl; |
| 1228 | |
| 1229 | bh = ah; |
| 1230 | bl = al; |
| 1231 | |
| 1232 | if (dl != 0) { |
| 1233 | temp = bh; |
| 1234 | bh = dh; |
| 1235 | dh = temp; |
| 1236 | if (dl == 1) { |
| 1237 | temp = bl; |
| 1238 | bl = dh; |
| 1239 | dh = temp; |
| 1240 | } else { |
| 1241 | temp = bl; |
| 1242 | bl = bh; |
| 1243 | bh = temp; |
| 1244 | } |
| 1245 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1246 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1247 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1248 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1249 | } |
| 1250 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1251 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1252 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1253 | { |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1254 | unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh; |
| 1255 | const unsigned short *table = XGINew_VGA_DAC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1256 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1257 | outb(0xFF, pVBInfo->P3c6); |
| 1258 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1259 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1260 | for (i = 0; i < 16; i++) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1261 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1262 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1263 | for (k = 0; k < 3; k++) { |
| 1264 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1265 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1266 | if (data & 0x01) |
| 1267 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1268 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1269 | if (data & 0x02) |
| 1270 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1271 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1272 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1273 | data = data >> 2; |
| 1274 | } |
| 1275 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1276 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1277 | for (i = 16; i < 32; i++) { |
| 1278 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1279 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1280 | for (k = 0; k < 3; k++) |
| 1281 | outb(data, pVBInfo->P3c9); |
| 1282 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1283 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1284 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1285 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1286 | for (m = 0; m < 9; m++) { |
| 1287 | di = si; |
| 1288 | bx = si + 0x04; |
| 1289 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1290 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1291 | for (n = 0; n < 3; n++) { |
| 1292 | for (o = 0; o < 5; o++) { |
| 1293 | dh = table[si]; |
| 1294 | ah = table[di]; |
| 1295 | al = table[bx]; |
| 1296 | si++; |
| 1297 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1298 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1299 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1300 | si -= 2; |
| 1301 | |
| 1302 | for (o = 0; o < 3; o++) { |
| 1303 | dh = table[bx]; |
| 1304 | ah = table[di]; |
| 1305 | al = table[si]; |
| 1306 | si--; |
| 1307 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1308 | } |
| 1309 | |
| 1310 | dl++; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1311 | } |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1312 | |
| 1313 | si += 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1314 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1315 | } |
| 1316 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1317 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
| 1318 | unsigned short ModeIdIndex, |
| 1319 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1320 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1321 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1322 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1323 | /* si+Ext_ResInfo */ |
| 1324 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1325 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1326 | /* si+Ext_ResInfo */ |
| 1327 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1328 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1329 | xres = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1330 | yres = pVBInfo->ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1331 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1332 | if (modeflag & HalfDCLK) |
| 1333 | xres = xres << 1; |
| 1334 | |
| 1335 | if (modeflag & DoubleScanMode) |
| 1336 | yres = yres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1337 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1338 | if (xres == 720) |
| 1339 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1340 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1341 | pVBInfo->VGAHDE = xres; |
| 1342 | pVBInfo->HDE = xres; |
| 1343 | pVBInfo->VGAVDE = yres; |
| 1344 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1345 | } |
| 1346 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1347 | static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, |
| 1348 | unsigned short ModeIdIndex, |
| 1349 | unsigned short RefreshRateTableIndex, |
| 1350 | struct vb_device_info *pVBInfo) |
| 1351 | { |
| 1352 | unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table; |
| 1353 | |
| 1354 | struct XGI330_LCDDataTablStruct *tempdi = NULL; |
| 1355 | |
| 1356 | tempbx = BX; |
| 1357 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1358 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1359 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1360 | |
| 1361 | tempal = tempal & 0x0f; |
| 1362 | |
| 1363 | if (tempbx <= 1) { /* ExpLink */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1364 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1365 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1366 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1367 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1368 | Ext_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1369 | } |
| 1370 | |
| 1371 | if (tempbx & 0x01) |
| 1372 | tempal = (tempal >> 4); |
| 1373 | |
| 1374 | tempal = (tempal & 0x0f); |
| 1375 | } |
| 1376 | |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 1377 | tempcx = LCDLenList[tempbx]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1378 | |
| 1379 | if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */ |
| 1380 | if ((tempbx == 5) || (tempbx) == 7) |
| 1381 | tempcx = LCDDesDataLen2; |
| 1382 | else if ((tempbx == 3) || (tempbx == 8)) |
| 1383 | tempcx = LVDSDesDataLen2; |
| 1384 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1385 | |
| 1386 | switch (tempbx) { |
| 1387 | case 0: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1388 | case 1: |
Aaro Koskinen | cc5c2ae | 2011-08-31 21:46:08 +0300 | [diff] [blame] | 1389 | tempdi = xgifb_epllcd_crt1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1390 | break; |
| 1391 | case 2: |
| 1392 | tempdi = XGI_EPLLCDDataPtr; |
| 1393 | break; |
| 1394 | case 3: |
| 1395 | tempdi = XGI_EPLLCDDesDataPtr; |
| 1396 | break; |
| 1397 | case 4: |
| 1398 | tempdi = XGI_LCDDataTable; |
| 1399 | break; |
| 1400 | case 5: |
| 1401 | tempdi = XGI_LCDDesDataTable; |
| 1402 | break; |
| 1403 | case 6: |
| 1404 | tempdi = XGI_EPLCHLCDRegPtr; |
| 1405 | break; |
| 1406 | case 7: |
| 1407 | case 8: |
| 1408 | case 9: |
| 1409 | tempdi = NULL; |
| 1410 | break; |
| 1411 | default: |
| 1412 | break; |
| 1413 | } |
| 1414 | |
| 1415 | if (tempdi == NULL) /* OEMUtil */ |
| 1416 | return NULL; |
| 1417 | |
| 1418 | table = tempbx; |
| 1419 | i = 0; |
| 1420 | |
| 1421 | while (tempdi[i].PANELID != 0xff) { |
| 1422 | tempdx = pVBInfo->LCDResInfo; |
| 1423 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 1424 | tempbx &= (~0x0080); |
| 1425 | tempdx = pVBInfo->LCDTypeInfo; |
| 1426 | } |
| 1427 | |
| 1428 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1429 | tempdx &= (~PanelResInfo); |
| 1430 | |
| 1431 | if (tempdi[i].PANELID == tempdx) { |
| 1432 | tempbx = tempdi[i].MASK; |
| 1433 | tempdx = pVBInfo->LCDInfo; |
| 1434 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1435 | if (modeflag & HalfDCLK) |
| 1436 | tempdx |= SetLCDLowResolution; |
| 1437 | |
| 1438 | tempbx &= tempdx; |
| 1439 | if (tempbx == tempdi[i].CAP) |
| 1440 | break; |
| 1441 | } |
| 1442 | i++; |
| 1443 | } |
| 1444 | |
| 1445 | if (table == 0) { |
| 1446 | switch (tempdi[i].DATAPTR) { |
| 1447 | case 0: |
| 1448 | return &XGI_LVDSCRT11024x768_1_H[tempal]; |
| 1449 | break; |
| 1450 | case 1: |
| 1451 | return &XGI_LVDSCRT11024x768_2_H[tempal]; |
| 1452 | break; |
| 1453 | case 2: |
| 1454 | return &XGI_LVDSCRT11280x1024_1_H[tempal]; |
| 1455 | break; |
| 1456 | case 3: |
| 1457 | return &XGI_LVDSCRT11280x1024_2_H[tempal]; |
| 1458 | break; |
| 1459 | case 4: |
| 1460 | return &XGI_LVDSCRT11400x1050_1_H[tempal]; |
| 1461 | break; |
| 1462 | case 5: |
| 1463 | return &XGI_LVDSCRT11400x1050_2_H[tempal]; |
| 1464 | break; |
| 1465 | case 6: |
| 1466 | return &XGI_LVDSCRT11600x1200_1_H[tempal]; |
| 1467 | break; |
| 1468 | case 7: |
| 1469 | return &XGI_LVDSCRT11024x768_1_Hx75[tempal]; |
| 1470 | break; |
| 1471 | case 8: |
| 1472 | return &XGI_LVDSCRT11024x768_2_Hx75[tempal]; |
| 1473 | break; |
| 1474 | case 9: |
| 1475 | return &XGI_LVDSCRT11280x1024_1_Hx75[tempal]; |
| 1476 | break; |
| 1477 | case 10: |
| 1478 | return &XGI_LVDSCRT11280x1024_2_Hx75[tempal]; |
| 1479 | break; |
| 1480 | default: |
| 1481 | break; |
| 1482 | } |
| 1483 | } else if (table == 1) { |
| 1484 | switch (tempdi[i].DATAPTR) { |
| 1485 | case 0: |
| 1486 | return &XGI_LVDSCRT11024x768_1_V[tempal]; |
| 1487 | break; |
| 1488 | case 1: |
| 1489 | return &XGI_LVDSCRT11024x768_2_V[tempal]; |
| 1490 | break; |
| 1491 | case 2: |
| 1492 | return &XGI_LVDSCRT11280x1024_1_V[tempal]; |
| 1493 | break; |
| 1494 | case 3: |
| 1495 | return &XGI_LVDSCRT11280x1024_2_V[tempal]; |
| 1496 | break; |
| 1497 | case 4: |
| 1498 | return &XGI_LVDSCRT11400x1050_1_V[tempal]; |
| 1499 | break; |
| 1500 | case 5: |
| 1501 | return &XGI_LVDSCRT11400x1050_2_V[tempal]; |
| 1502 | break; |
| 1503 | case 6: |
| 1504 | return &XGI_LVDSCRT11600x1200_1_V[tempal]; |
| 1505 | break; |
| 1506 | case 7: |
| 1507 | return &XGI_LVDSCRT11024x768_1_Vx75[tempal]; |
| 1508 | break; |
| 1509 | case 8: |
| 1510 | return &XGI_LVDSCRT11024x768_2_Vx75[tempal]; |
| 1511 | break; |
| 1512 | case 9: |
| 1513 | return &XGI_LVDSCRT11280x1024_1_Vx75[tempal]; |
| 1514 | break; |
| 1515 | case 10: |
| 1516 | return &XGI_LVDSCRT11280x1024_2_Vx75[tempal]; |
| 1517 | break; |
| 1518 | default: |
| 1519 | break; |
| 1520 | } |
| 1521 | } else if (table == 2) { |
| 1522 | switch (tempdi[i].DATAPTR) { |
| 1523 | case 0: |
| 1524 | return &XGI_LVDS1024x768Data_1[tempal]; |
| 1525 | break; |
| 1526 | case 1: |
| 1527 | return &XGI_LVDS1024x768Data_2[tempal]; |
| 1528 | break; |
| 1529 | case 2: |
| 1530 | return &XGI_LVDS1280x1024Data_1[tempal]; |
| 1531 | break; |
| 1532 | case 3: |
| 1533 | return &XGI_LVDS1280x1024Data_2[tempal]; |
| 1534 | break; |
| 1535 | case 4: |
| 1536 | return &XGI_LVDS1400x1050Data_1[tempal]; |
| 1537 | break; |
| 1538 | case 5: |
| 1539 | return &XGI_LVDS1400x1050Data_2[tempal]; |
| 1540 | break; |
| 1541 | case 6: |
| 1542 | return &XGI_LVDS1600x1200Data_1[tempal]; |
| 1543 | break; |
| 1544 | case 7: |
| 1545 | return &XGI_LVDSNoScalingData[tempal]; |
| 1546 | break; |
| 1547 | case 8: |
| 1548 | return &XGI_LVDS1024x768Data_1x75[tempal]; |
| 1549 | break; |
| 1550 | case 9: |
| 1551 | return &XGI_LVDS1024x768Data_2x75[tempal]; |
| 1552 | break; |
| 1553 | case 10: |
| 1554 | return &XGI_LVDS1280x1024Data_1x75[tempal]; |
| 1555 | break; |
| 1556 | case 11: |
| 1557 | return &XGI_LVDS1280x1024Data_2x75[tempal]; |
| 1558 | break; |
| 1559 | case 12: |
| 1560 | return &XGI_LVDSNoScalingDatax75[tempal]; |
| 1561 | break; |
| 1562 | default: |
| 1563 | break; |
| 1564 | } |
| 1565 | } else if (table == 3) { |
| 1566 | switch (tempdi[i].DATAPTR) { |
| 1567 | case 0: |
| 1568 | return &XGI_LVDS1024x768Des_1[tempal]; |
| 1569 | break; |
| 1570 | case 1: |
| 1571 | return &XGI_LVDS1024x768Des_3[tempal]; |
| 1572 | break; |
| 1573 | case 2: |
| 1574 | return &XGI_LVDS1024x768Des_2[tempal]; |
| 1575 | break; |
| 1576 | case 3: |
| 1577 | return &XGI_LVDS1280x1024Des_1[tempal]; |
| 1578 | break; |
| 1579 | case 4: |
| 1580 | return &XGI_LVDS1280x1024Des_2[tempal]; |
| 1581 | break; |
| 1582 | case 5: |
| 1583 | return &XGI_LVDS1400x1050Des_1[tempal]; |
| 1584 | break; |
| 1585 | case 6: |
| 1586 | return &XGI_LVDS1400x1050Des_2[tempal]; |
| 1587 | break; |
| 1588 | case 7: |
| 1589 | return &XGI_LVDS1600x1200Des_1[tempal]; |
| 1590 | break; |
| 1591 | case 8: |
| 1592 | return &XGI_LVDSNoScalingDesData[tempal]; |
| 1593 | break; |
| 1594 | case 9: |
| 1595 | return &XGI_LVDS1024x768Des_1x75[tempal]; |
| 1596 | break; |
| 1597 | case 10: |
| 1598 | return &XGI_LVDS1024x768Des_3x75[tempal]; |
| 1599 | break; |
| 1600 | case 11: |
| 1601 | return &XGI_LVDS1024x768Des_2x75[tempal]; |
| 1602 | break; |
| 1603 | case 12: |
| 1604 | return &XGI_LVDS1280x1024Des_1x75[tempal]; |
| 1605 | break; |
| 1606 | case 13: |
| 1607 | return &XGI_LVDS1280x1024Des_2x75[tempal]; |
| 1608 | break; |
| 1609 | case 14: |
| 1610 | return &XGI_LVDSNoScalingDesDatax75[tempal]; |
| 1611 | break; |
| 1612 | default: |
| 1613 | break; |
| 1614 | } |
| 1615 | } else if (table == 4) { |
| 1616 | switch (tempdi[i].DATAPTR) { |
| 1617 | case 0: |
| 1618 | return &XGI_ExtLCD1024x768Data[tempal]; |
| 1619 | break; |
| 1620 | case 1: |
| 1621 | return &XGI_StLCD1024x768Data[tempal]; |
| 1622 | break; |
| 1623 | case 2: |
| 1624 | return &XGI_CetLCD1024x768Data[tempal]; |
| 1625 | break; |
| 1626 | case 3: |
| 1627 | return &XGI_ExtLCD1280x1024Data[tempal]; |
| 1628 | break; |
| 1629 | case 4: |
| 1630 | return &XGI_StLCD1280x1024Data[tempal]; |
| 1631 | break; |
| 1632 | case 5: |
| 1633 | return &XGI_CetLCD1280x1024Data[tempal]; |
| 1634 | break; |
| 1635 | case 6: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1636 | case 7: |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 1637 | return &xgifb_lcd_1400x1050[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1638 | break; |
| 1639 | case 8: |
| 1640 | return &XGI_CetLCD1400x1050Data[tempal]; |
| 1641 | break; |
| 1642 | case 9: |
| 1643 | return &XGI_ExtLCD1600x1200Data[tempal]; |
| 1644 | break; |
| 1645 | case 10: |
| 1646 | return &XGI_StLCD1600x1200Data[tempal]; |
| 1647 | break; |
| 1648 | case 11: |
| 1649 | return &XGI_NoScalingData[tempal]; |
| 1650 | break; |
| 1651 | case 12: |
| 1652 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 1653 | break; |
| 1654 | case 13: |
| 1655 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 1656 | break; |
| 1657 | case 14: |
| 1658 | return &XGI_CetLCD1024x768x75Data[tempal]; |
| 1659 | break; |
| 1660 | case 15: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1661 | case 16: |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 1662 | return &xgifb_lcd_1280x1024x75[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1663 | break; |
| 1664 | case 17: |
| 1665 | return &XGI_CetLCD1280x1024x75Data[tempal]; |
| 1666 | break; |
| 1667 | case 18: |
| 1668 | return &XGI_NoScalingDatax75[tempal]; |
| 1669 | break; |
| 1670 | default: |
| 1671 | break; |
| 1672 | } |
| 1673 | } else if (table == 5) { |
| 1674 | switch (tempdi[i].DATAPTR) { |
| 1675 | case 0: |
| 1676 | return &XGI_ExtLCDDes1024x768Data[tempal]; |
| 1677 | break; |
| 1678 | case 1: |
| 1679 | return &XGI_StLCDDes1024x768Data[tempal]; |
| 1680 | break; |
| 1681 | case 2: |
| 1682 | return &XGI_CetLCDDes1024x768Data[tempal]; |
| 1683 | break; |
| 1684 | case 3: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1685 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 1686 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1687 | return &XGI_ExtLCDDLDes1280x1024Data[tempal]; |
| 1688 | else |
| 1689 | return &XGI_ExtLCDDes1280x1024Data[tempal]; |
| 1690 | break; |
| 1691 | case 4: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1692 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 1693 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1694 | return &XGI_StLCDDLDes1280x1024Data[tempal]; |
| 1695 | else |
| 1696 | return &XGI_StLCDDes1280x1024Data[tempal]; |
| 1697 | break; |
| 1698 | case 5: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1699 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 1700 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1701 | return &XGI_CetLCDDLDes1280x1024Data[tempal]; |
| 1702 | else |
| 1703 | return &XGI_CetLCDDes1280x1024Data[tempal]; |
| 1704 | break; |
| 1705 | case 6: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1706 | case 7: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1707 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 1708 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 1709 | return &xgifb_lcddldes_1400x1050[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1710 | else |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 1711 | return &xgifb_lcddes_1400x1050[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1712 | break; |
| 1713 | case 8: |
| 1714 | return &XGI_CetLCDDes1400x1050Data[tempal]; |
| 1715 | break; |
| 1716 | case 9: |
| 1717 | return &XGI_CetLCDDes1400x1050Data2[tempal]; |
| 1718 | break; |
| 1719 | case 10: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1720 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 1721 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1722 | return &XGI_ExtLCDDLDes1600x1200Data[tempal]; |
| 1723 | else |
| 1724 | return &XGI_ExtLCDDes1600x1200Data[tempal]; |
| 1725 | break; |
| 1726 | case 11: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1727 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 1728 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1729 | return &XGI_StLCDDLDes1600x1200Data[tempal]; |
| 1730 | else |
| 1731 | return &XGI_StLCDDes1600x1200Data[tempal]; |
| 1732 | break; |
| 1733 | case 12: |
| 1734 | return &XGI_NoScalingDesData[tempal]; |
| 1735 | break; |
| 1736 | case 13: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1737 | case 14: |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 1738 | return &xgifb_lcddes_1024x768x75[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1739 | break; |
| 1740 | case 15: |
| 1741 | return &XGI_CetLCDDes1024x768x75Data[tempal]; |
| 1742 | break; |
| 1743 | case 16: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1744 | case 17: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1745 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 1746 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 1747 | return &xgifb_lcddldes_1280x1024x75[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1748 | else |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 1749 | return &xgifb_lcddes_1280x1024x75[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1750 | break; |
| 1751 | case 18: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1752 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 1753 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1754 | return &XGI_CetLCDDLDes1280x1024x75Data[tempal]; |
| 1755 | else |
| 1756 | return &XGI_CetLCDDes1280x1024x75Data[tempal]; |
| 1757 | break; |
| 1758 | case 19: |
| 1759 | return &XGI_NoScalingDesDatax75[tempal]; |
| 1760 | break; |
| 1761 | default: |
| 1762 | break; |
| 1763 | } |
| 1764 | } else if (table == 6) { |
| 1765 | switch (tempdi[i].DATAPTR) { |
| 1766 | case 0: |
| 1767 | return &XGI_CH7017LV1024x768[tempal]; |
| 1768 | break; |
| 1769 | case 1: |
| 1770 | return &XGI_CH7017LV1400x1050[tempal]; |
| 1771 | break; |
| 1772 | default: |
| 1773 | break; |
| 1774 | } |
| 1775 | } |
| 1776 | return NULL; |
| 1777 | } |
| 1778 | |
| 1779 | static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, |
| 1780 | unsigned short ModeIdIndex, |
| 1781 | unsigned short RefreshRateTableIndex, |
| 1782 | struct vb_device_info *pVBInfo) |
| 1783 | { |
| 1784 | unsigned short i, tempdx, tempbx, tempal, modeflag, table; |
| 1785 | struct XGI330_TVDataTablStruct *tempdi = NULL; |
| 1786 | |
| 1787 | tempbx = BX; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1788 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1789 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1790 | tempal = tempal & 0x3f; |
| 1791 | table = tempbx; |
| 1792 | |
| 1793 | switch (tempbx) { |
| 1794 | case 0: |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 1795 | tempdi = NULL; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1796 | break; |
| 1797 | case 1: |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 1798 | tempdi = NULL; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1799 | break; |
| 1800 | case 2: |
Aaro Koskinen | 0c23b6d | 2011-08-31 21:46:09 +0300 | [diff] [blame] | 1801 | case 6: |
| 1802 | tempdi = xgifb_chrontel_tv; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1803 | break; |
| 1804 | case 3: |
| 1805 | tempdi = NULL; |
| 1806 | break; |
| 1807 | case 4: |
| 1808 | tempdi = XGI_TVDataTable; |
| 1809 | break; |
| 1810 | case 5: |
| 1811 | tempdi = NULL; |
| 1812 | break; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1813 | default: |
| 1814 | break; |
| 1815 | } |
| 1816 | |
| 1817 | if (tempdi == NULL) /* OEMUtil */ |
| 1818 | return NULL; |
| 1819 | |
| 1820 | tempdx = pVBInfo->TVInfo; |
| 1821 | |
| 1822 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 1823 | tempdx = tempdx | SetTVLockMode; |
| 1824 | |
| 1825 | if (modeflag & HalfDCLK) |
| 1826 | tempdx = tempdx | SetTVLowResolution; |
| 1827 | |
| 1828 | i = 0; |
| 1829 | |
| 1830 | while (tempdi[i].MASK != 0xffff) { |
| 1831 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) |
| 1832 | break; |
| 1833 | i++; |
| 1834 | } |
| 1835 | |
Aaro Koskinen | ebe3302 | 2011-11-27 23:03:18 +0200 | [diff] [blame] | 1836 | if (table == 0x04) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1837 | switch (tempdi[i].DATAPTR) { |
| 1838 | case 0: |
| 1839 | return &XGI_ExtPALData[tempal]; |
| 1840 | break; |
| 1841 | case 1: |
| 1842 | return &XGI_ExtNTSCData[tempal]; |
| 1843 | break; |
| 1844 | case 2: |
| 1845 | return &XGI_StPALData[tempal]; |
| 1846 | break; |
| 1847 | case 3: |
| 1848 | return &XGI_StNTSCData[tempal]; |
| 1849 | break; |
| 1850 | case 4: |
| 1851 | return &XGI_ExtHiTVData[tempal]; |
| 1852 | break; |
| 1853 | case 5: |
| 1854 | return &XGI_St2HiTVData[tempal]; |
| 1855 | break; |
| 1856 | case 6: |
| 1857 | return &XGI_ExtYPbPr525iData[tempal]; |
| 1858 | break; |
| 1859 | case 7: |
| 1860 | return &XGI_ExtYPbPr525pData[tempal]; |
| 1861 | break; |
| 1862 | case 8: |
| 1863 | return &XGI_ExtYPbPr750pData[tempal]; |
| 1864 | break; |
| 1865 | case 9: |
| 1866 | return &XGI_StYPbPr525iData[tempal]; |
| 1867 | break; |
| 1868 | case 10: |
| 1869 | return &XGI_StYPbPr525pData[tempal]; |
| 1870 | break; |
| 1871 | case 11: |
| 1872 | return &XGI_StYPbPr750pData[tempal]; |
| 1873 | break; |
| 1874 | case 12: /* avoid system hang */ |
| 1875 | return &XGI_ExtNTSCData[tempal]; |
| 1876 | break; |
| 1877 | case 13: |
| 1878 | return &XGI_St1HiTVData[tempal]; |
| 1879 | break; |
| 1880 | default: |
| 1881 | break; |
| 1882 | } |
| 1883 | } else if (table == 0x02) { |
| 1884 | switch (tempdi[i].DATAPTR) { |
| 1885 | case 0: |
| 1886 | return &XGI_CHTVUNTSCData[tempal]; |
| 1887 | break; |
| 1888 | case 1: |
| 1889 | return &XGI_CHTVONTSCData[tempal]; |
| 1890 | break; |
| 1891 | case 2: |
| 1892 | return &XGI_CHTVUPALData[tempal]; |
| 1893 | break; |
| 1894 | case 3: |
| 1895 | return &XGI_CHTVOPALData[tempal]; |
| 1896 | break; |
| 1897 | default: |
| 1898 | break; |
| 1899 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1900 | } |
| 1901 | return NULL; |
| 1902 | } |
| 1903 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1904 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1905 | unsigned short RefreshRateTableIndex, |
| 1906 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1907 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1908 | unsigned short tempbx; |
Peter Huewe | 51f984b | 2012-06-14 00:21:51 +0200 | [diff] [blame] | 1909 | struct SiS_LVDSData *LCDPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1910 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1911 | tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1912 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1913 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | 51f984b | 2012-06-14 00:21:51 +0200 | [diff] [blame] | 1914 | LCDPtr = (struct SiS_LVDSData *)XGI_GetLcdPtr(tempbx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1915 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 1916 | pVBInfo); |
| 1917 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 1918 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 1919 | pVBInfo->HT = LCDPtr->LCDHT; |
| 1920 | pVBInfo->VT = LCDPtr->LCDVT; |
| 1921 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1922 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1923 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1924 | if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding |
| 1925 | | EnableScalingLCD))) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1926 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1927 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1928 | pVBInfo->HDE = 1024; |
| 1929 | pVBInfo->VDE = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1930 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1931 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1932 | pVBInfo->HDE = 1280; |
| 1933 | pVBInfo->VDE = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1934 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1935 | pVBInfo->HDE = 1400; |
| 1936 | pVBInfo->VDE = 1050; |
| 1937 | } else { |
| 1938 | pVBInfo->HDE = 1600; |
| 1939 | pVBInfo->VDE = 1200; |
| 1940 | } |
| 1941 | } |
| 1942 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1943 | } |
| 1944 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1945 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1946 | unsigned short RefreshRateTableIndex, |
| 1947 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1948 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1949 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1950 | unsigned char index; |
| 1951 | unsigned short tempbx, i; |
| 1952 | struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL; |
| 1953 | struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1954 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1955 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1956 | index = index & IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1957 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1958 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1959 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1960 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1961 | LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) |
| 1962 | XGI_GetLcdPtr(tempbx, ModeNo, |
| 1963 | ModeIdIndex, |
| 1964 | RefreshRateTableIndex, |
| 1965 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1966 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1967 | for (i = 0; i < 8; i++) |
| 1968 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1969 | } |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1970 | |
| 1971 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 1972 | |
| 1973 | tempbx = 1; |
| 1974 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1975 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1976 | LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) |
| 1977 | XGI_GetLcdPtr( |
| 1978 | tempbx, |
| 1979 | ModeNo, |
| 1980 | ModeIdIndex, |
| 1981 | RefreshRateTableIndex, |
| 1982 | pVBInfo); |
| 1983 | for (i = 0; i < 7; i++) |
| 1984 | pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; |
| 1985 | } |
| 1986 | |
| 1987 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1988 | } |
| 1989 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1990 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 1991 | { |
| 1992 | unsigned char tempal, tempah, tempbl, i; |
| 1993 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1994 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1995 | tempal = tempah & 0x0F; |
| 1996 | tempah = tempah & 0xF0; |
| 1997 | i = 0; |
| 1998 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1999 | |
| 2000 | while (tempbl != 0xFF) { |
| 2001 | if (tempbl & 0x80) { /* OEMUtil */ |
| 2002 | tempal = tempah; |
| 2003 | tempbl = tempbl & ~(0x80); |
| 2004 | } |
| 2005 | |
| 2006 | if (tempal == tempbl) |
| 2007 | break; |
| 2008 | |
| 2009 | i++; |
| 2010 | |
| 2011 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2012 | } |
| 2013 | |
| 2014 | return i; |
| 2015 | } |
| 2016 | |
| 2017 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 2018 | { |
| 2019 | unsigned short tempah, tempal, tempbl, i; |
| 2020 | |
| 2021 | tempal = pVBInfo->LCDResInfo; |
| 2022 | tempah = pVBInfo->LCDTypeInfo; |
| 2023 | |
| 2024 | i = 0; |
| 2025 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2026 | |
| 2027 | while (tempbl != 0xFF) { |
| 2028 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 2029 | tempal = tempah; |
| 2030 | tempbl &= ~0x80; |
| 2031 | } |
| 2032 | |
| 2033 | if (tempal == tempbl) |
| 2034 | break; |
| 2035 | |
| 2036 | i++; |
| 2037 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2038 | } |
| 2039 | |
| 2040 | if (tempbl == 0xFF) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2041 | pVBInfo->LCDResInfo = Panel_1024x768; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2042 | pVBInfo->LCDTypeInfo = 0; |
| 2043 | i = 0; |
| 2044 | } |
| 2045 | |
| 2046 | return i; |
| 2047 | } |
| 2048 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2049 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 2050 | unsigned short *VSyncWidth, |
| 2051 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2052 | { |
| 2053 | unsigned short Index; |
| 2054 | |
| 2055 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 2056 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 2057 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
| 2058 | |
| 2059 | return; |
| 2060 | } |
| 2061 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2062 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2063 | unsigned short RefreshRateTableIndex, |
| 2064 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2065 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2066 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 2067 | unsigned long temp, temp1, temp2, temp3, push3; |
Aaro Koskinen | d00d12f | 2012-04-07 01:14:10 +0300 | [diff] [blame] | 2068 | struct XGI_LCDDesStruct *LCDPtr = NULL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2069 | struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2070 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2071 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 2072 | tempbx = 3; |
| 2073 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2074 | LCDPtr1 = |
| 2075 | (struct XGI330_LCDDataDesStruct2 *) |
| 2076 | XGI_GetLcdPtr( |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2077 | tempbx, |
| 2078 | ModeNo, |
| 2079 | ModeIdIndex, |
| 2080 | RefreshRateTableIndex, |
| 2081 | pVBInfo); |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 2082 | else |
| 2083 | LCDPtr = |
Aaro Koskinen | d00d12f | 2012-04-07 01:14:10 +0300 | [diff] [blame] | 2084 | (struct XGI_LCDDesStruct *) |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 2085 | XGI_GetLcdPtr( |
| 2086 | tempbx, |
| 2087 | ModeNo, |
| 2088 | ModeIdIndex, |
| 2089 | RefreshRateTableIndex, |
| 2090 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2091 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2092 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 2093 | push1 = tempbx; |
| 2094 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2095 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2096 | /* GetLCDResInfo */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2097 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 2098 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2099 | tempax = 1024; |
| 2100 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2101 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 2102 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2103 | tempax = 1280; |
| 2104 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2105 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2106 | tempax = 1400; |
| 2107 | tempbx = 1050; |
| 2108 | } else { |
| 2109 | tempax = 1600; |
| 2110 | tempbx = 1200; |
| 2111 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2112 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2113 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 2114 | pVBInfo->HDE = tempax; |
| 2115 | pVBInfo->VDE = tempbx; |
| 2116 | pVBInfo->VGAHDE = tempax; |
| 2117 | pVBInfo->VGAVDE = tempbx; |
| 2118 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2119 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2120 | tempax = pVBInfo->HT; |
| 2121 | |
| 2122 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2123 | tempbx = LCDPtr1->LCDHDES; |
| 2124 | else |
| 2125 | tempbx = LCDPtr->LCDHDES; |
| 2126 | |
| 2127 | tempcx = pVBInfo->HDE; |
| 2128 | tempbx = tempbx & 0x0fff; |
| 2129 | tempcx += tempbx; |
| 2130 | |
| 2131 | if (tempcx >= tempax) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2132 | tempcx -= tempax; |
| 2133 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2134 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2135 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2136 | tempcx = tempcx >> 3; |
| 2137 | tempbx = tempbx >> 3; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2138 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2139 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 2140 | (unsigned short) (tempbx & 0xff)); |
| 2141 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 2142 | (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2143 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2144 | tempax = pVBInfo->HT; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2145 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2146 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2147 | tempbx = LCDPtr1->LCDHRS; |
| 2148 | else |
| 2149 | tempbx = LCDPtr->LCDHRS; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2150 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2151 | tempcx = push2; |
| 2152 | |
| 2153 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2154 | tempcx = LCDPtr1->LCDHSync; |
| 2155 | |
| 2156 | tempcx += tempbx; |
| 2157 | |
| 2158 | if (tempcx >= tempax) |
| 2159 | tempcx -= tempax; |
| 2160 | |
| 2161 | tempax = tempbx & 0x07; |
| 2162 | tempax = tempax >> 5; |
| 2163 | tempcx = tempcx >> 3; |
| 2164 | tempbx = tempbx >> 3; |
| 2165 | |
| 2166 | tempcx &= 0x1f; |
| 2167 | tempax |= tempcx; |
| 2168 | |
| 2169 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 2170 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 2171 | (unsigned short) (tempbx & 0xff)); |
| 2172 | |
| 2173 | tempax = pVBInfo->VT; |
| 2174 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2175 | tempbx = LCDPtr1->LCDVDES; |
| 2176 | else |
| 2177 | tempbx = LCDPtr->LCDVDES; |
| 2178 | tempcx = pVBInfo->VDE; |
| 2179 | |
| 2180 | tempbx = tempbx & 0x0fff; |
| 2181 | tempcx += tempbx; |
| 2182 | if (tempcx >= tempax) |
| 2183 | tempcx -= tempax; |
| 2184 | |
| 2185 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 2186 | (unsigned short) (tempbx & 0xff)); |
| 2187 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 2188 | (unsigned short) (tempcx & 0xff)); |
| 2189 | |
| 2190 | tempbx = (tempbx >> 8) & 0x07; |
| 2191 | tempcx = (tempcx >> 8) & 0x07; |
| 2192 | |
| 2193 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 2194 | (unsigned short) ((tempcx << 3) |
| 2195 | | tempbx)); |
| 2196 | |
| 2197 | tempax = pVBInfo->VT; |
| 2198 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2199 | tempbx = LCDPtr1->LCDVRS; |
| 2200 | else |
| 2201 | tempbx = LCDPtr->LCDVRS; |
| 2202 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2203 | tempcx = push1; |
| 2204 | |
| 2205 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2206 | tempcx = LCDPtr1->LCDVSync; |
| 2207 | |
| 2208 | tempcx += tempbx; |
| 2209 | if (tempcx >= tempax) |
| 2210 | tempcx -= tempax; |
| 2211 | |
| 2212 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 2213 | (unsigned short) (tempbx & 0xff)); |
| 2214 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 2215 | (unsigned short) (tempcx & 0x0f)); |
| 2216 | |
| 2217 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 2218 | |
| 2219 | tempbx = pVBInfo->VGAVDE; |
| 2220 | if (tempbx != pVBInfo->VDE) |
| 2221 | tempax |= 0x40; |
| 2222 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2223 | if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2224 | tempax |= 0x40; |
| 2225 | |
| 2226 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 2227 | tempax); |
| 2228 | |
| 2229 | tempcx = pVBInfo->VGAVT; |
| 2230 | tempbx = pVBInfo->VDE; |
| 2231 | tempax = pVBInfo->VGAVDE; |
| 2232 | tempcx -= tempax; |
| 2233 | |
| 2234 | temp = tempax; /* 0430 ylshieh */ |
| 2235 | temp1 = (temp << 18) / tempbx; |
| 2236 | |
| 2237 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 2238 | |
| 2239 | if (tempdx != 0) |
| 2240 | temp1 += 1; |
| 2241 | |
| 2242 | temp2 = temp1; |
| 2243 | push3 = temp2; |
| 2244 | |
| 2245 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 2246 | (unsigned short) (temp2 & 0xff)); |
| 2247 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 2248 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 2249 | |
| 2250 | tempbx = (unsigned short) (temp2 >> 16); |
| 2251 | tempax = tempbx & 0x03; |
| 2252 | |
| 2253 | tempbx = pVBInfo->VGAVDE; |
| 2254 | if (tempbx == pVBInfo->VDE) |
| 2255 | tempax |= 0x04; |
| 2256 | |
| 2257 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 2258 | |
| 2259 | if (pVBInfo->VBType & VB_XGI301C) { |
| 2260 | temp2 = push3; |
| 2261 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2262 | 0x3c, |
| 2263 | (unsigned short) (temp2 & 0xff)); |
| 2264 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2265 | 0x3b, |
| 2266 | (unsigned short) ((temp2 >> 8) & |
| 2267 | 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2268 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2269 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 2270 | ~0xc0, |
| 2271 | (unsigned short) ((tempbx & |
| 2272 | 0xff) << 6)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2273 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2274 | tempcx = pVBInfo->VGAVDE; |
| 2275 | if (tempcx == pVBInfo->VDE) |
| 2276 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2277 | 0x30, ~0x0c, 0x00); |
| 2278 | else |
| 2279 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2280 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2281 | } |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2282 | |
| 2283 | tempcx = pVBInfo->VGAHDE; |
| 2284 | tempbx = pVBInfo->HDE; |
| 2285 | |
| 2286 | temp1 = tempcx << 16; |
| 2287 | |
| 2288 | tempax = (unsigned short) (temp1 / tempbx); |
| 2289 | |
| 2290 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 2291 | tempax = 65535; |
| 2292 | |
| 2293 | temp3 = tempax; |
| 2294 | temp1 = pVBInfo->VGAHDE << 16; |
| 2295 | |
| 2296 | temp1 /= temp3; |
| 2297 | temp3 = temp3 << 16; |
| 2298 | temp1 -= 1; |
| 2299 | |
| 2300 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 2301 | |
| 2302 | tempax = (unsigned short) (temp3 & 0xff); |
| 2303 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 2304 | |
| 2305 | temp1 = pVBInfo->VGAVDE << 18; |
| 2306 | temp1 = temp1 / push3; |
| 2307 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 2308 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2309 | if (pVBInfo->LCDResInfo == Panel_1024x768) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2310 | tempbx -= 1; |
| 2311 | |
| 2312 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 2313 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 2314 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 2315 | (unsigned short) (tempax & 0xff)); |
| 2316 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 2317 | (unsigned short) (tempbx & 0xff)); |
| 2318 | |
| 2319 | temp3 = temp3 >> 16; |
| 2320 | |
| 2321 | if (modeflag & HalfDCLK) |
| 2322 | temp3 = temp3 >> 1; |
| 2323 | |
| 2324 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 2325 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 2326 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 2327 | (unsigned short) (temp3 & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2328 | } |
| 2329 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2330 | /* --------------------------------------------------------------------- */ |
| 2331 | /* Function : XGI_GETLCDVCLKPtr */ |
| 2332 | /* Input : */ |
| 2333 | /* Output : al -> VCLK Index */ |
| 2334 | /* Description : */ |
| 2335 | /* --------------------------------------------------------------------- */ |
| 2336 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 2337 | struct vb_device_info *pVBInfo) |
| 2338 | { |
| 2339 | unsigned short index; |
| 2340 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2341 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2342 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 2343 | |
| 2344 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 2345 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 2346 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 2347 | } else { /* LCDA */ |
| 2348 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 2349 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 2350 | } |
| 2351 | } |
| 2352 | return; |
| 2353 | } |
| 2354 | |
| 2355 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
| 2356 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 2357 | struct vb_device_info *pVBInfo) |
| 2358 | { |
| 2359 | |
| 2360 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2361 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2362 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2363 | /* si+Ext_ResInfo */ |
| 2364 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2365 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2366 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 2367 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2368 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 2369 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 2370 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2371 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2372 | return tempal; |
| 2373 | |
| 2374 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2375 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2376 | (VB_SIS301B | |
| 2377 | VB_SIS302B | |
| 2378 | VB_SIS301LV | |
| 2379 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2380 | VB_XGI301C)) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2381 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 2382 | tempal = TVCLKBASE_315 + HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2383 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 2384 | tempal = TVCLKBASE_315 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2385 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 2386 | tempal = TVCLKBASE_315 + HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2387 | if (!(modeflag & Charx8Dot)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 2388 | tempal = TVCLKBASE_315 + HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2389 | |
| 2390 | } |
| 2391 | return tempal; |
| 2392 | } |
| 2393 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2394 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2395 | tempal = XGI_YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2396 | return tempal; |
| 2397 | } |
| 2398 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2399 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2400 | tempal = YPbPr525pVCLK; |
| 2401 | return tempal; |
| 2402 | } |
| 2403 | |
| 2404 | tempal = NTSC1024VCLK; |
| 2405 | |
| 2406 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 2407 | tempal = TVCLKBASE_315 + TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2408 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 2409 | tempal = TVCLKBASE_315 + TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2410 | } |
| 2411 | |
| 2412 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 2413 | return tempal; |
| 2414 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2415 | } /* {End of VB} */ |
| 2416 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2417 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2418 | tempal = tempal >> 2; |
| 2419 | tempal &= 0x03; |
| 2420 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2421 | /* for Dot8 Scaling LCD */ |
| 2422 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2423 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
| 2424 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2425 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 2426 | return tempal; |
| 2427 | } |
| 2428 | |
| 2429 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 2430 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 2431 | { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2432 | if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B |
| 2433 | | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2434 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && (pVBInfo->SetFlag |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2435 | & ProgrammingCRT2)) { |
| 2436 | *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B; |
| 2437 | *di_1 = XGI_VBVCLKData[tempal].SR2C; |
| 2438 | } |
| 2439 | } else { |
| 2440 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 2441 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 2442 | } |
| 2443 | } |
| 2444 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2445 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2446 | unsigned short RefreshRateTableIndex, |
| 2447 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2448 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2449 | unsigned char di_0, di_1, tempal; |
| 2450 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2451 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2452 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 2453 | pVBInfo); |
| 2454 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 2455 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2456 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2457 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2458 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2459 | (unsigned short) (0x10 * i)); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2460 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2461 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2462 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 2463 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2464 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2465 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 2466 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2467 | } |
| 2468 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2469 | } |
| 2470 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2471 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2472 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2473 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2474 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2475 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2476 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 2477 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2478 | tempcl = 0; |
| 2479 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2480 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2481 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2482 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2483 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2484 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2485 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2486 | if (!(temp & 0x40)) |
| 2487 | tempcl |= ActiveCRT1; |
| 2488 | } |
| 2489 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2490 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2491 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2492 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2493 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2494 | if (!(temp == 0x08)) { |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 2495 | /* Check ChannelA */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2496 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2497 | if (tempax & 0x04) |
| 2498 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2499 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2500 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2501 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2502 | if (!(tempcl & ActiveLCD)) |
| 2503 | if (temp == 0x01) |
| 2504 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2505 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2506 | if (temp == 0x04) |
| 2507 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2508 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2509 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2510 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2511 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2512 | if (!(temp & 0x08)) |
| 2513 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2514 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2515 | if (!(temp & 0x04)) |
| 2516 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2517 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2518 | if (temp & 0x02) |
| 2519 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2520 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2521 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2522 | if (temp & 0x01) |
| 2523 | tempch |= ActiveHiTV; |
| 2524 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2525 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2526 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2527 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2528 | pVBInfo->Part2Port, |
| 2529 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2530 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2531 | if (temp & 0x10) |
| 2532 | tempch |= ActiveYPbPr; |
| 2533 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2534 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2535 | if (tempch != 0) |
| 2536 | tempcl |= ActiveTV; |
| 2537 | } |
| 2538 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2539 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2540 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2541 | if (tempcl & ActiveLCD) { |
| 2542 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 2543 | if (temp & ActiveTV) |
| 2544 | tempcl |= ActiveTV; |
| 2545 | } |
| 2546 | } |
| 2547 | temp = tempcl; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2548 | tempbl = ~XGI_ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2549 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2550 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2551 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2552 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2553 | } else { |
| 2554 | return; |
| 2555 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2556 | } |
| 2557 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 2558 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2559 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2560 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2561 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 2562 | if (pVBInfo->IF_DEF_LVDS != 0) |
| 2563 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2564 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 2565 | tempbx = VB_SIS302B; |
| 2566 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
| 2567 | if (flag == 0x02) |
| 2568 | goto finish; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2569 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 2570 | tempbx = VB_SIS301; |
| 2571 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
| 2572 | if (flag < 0xB0) |
| 2573 | goto finish; |
| 2574 | |
| 2575 | tempbx = VB_SIS301B; |
| 2576 | if (flag < 0xC0) |
| 2577 | goto bigger_than_0xB0; |
| 2578 | |
| 2579 | tempbx = VB_XGI301C; |
| 2580 | if (flag < 0xD0) |
| 2581 | goto bigger_than_0xB0; |
| 2582 | |
| 2583 | tempbx = VB_SIS301LV; |
| 2584 | if (flag < 0xE0) |
| 2585 | goto bigger_than_0xB0; |
| 2586 | |
| 2587 | tempbx = VB_SIS302LV; |
| 2588 | tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39); |
| 2589 | if (tempah != 0xFF) |
| 2590 | tempbx = VB_XGI301C; |
| 2591 | |
| 2592 | bigger_than_0xB0: |
| 2593 | if (tempbx & (VB_SIS301B | VB_SIS302B)) { |
| 2594 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23); |
| 2595 | if (!(flag & 0x02)) |
| 2596 | tempbx = tempbx | VB_NoLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2597 | } |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 2598 | |
| 2599 | finish: |
| 2600 | pVBInfo->VBType = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2601 | } |
| 2602 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2603 | static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2604 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2605 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2606 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2607 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2608 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2609 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2610 | pVBInfo->SetFlag = 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2611 | pVBInfo->ModeType = modeflag & ModeTypeMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2612 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2613 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2614 | if (!(pVBInfo->VBType & 0xFFFF)) |
| 2615 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2616 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2617 | /* Check Display Device */ |
| 2618 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
| 2619 | tempbx = tempbx | temp; |
| 2620 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
| 2621 | push = temp; |
| 2622 | push = push << 8; |
| 2623 | tempax = temp << 8; |
| 2624 | tempbx = tempbx | tempax; |
| 2625 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA |
| 2626 | | SetInSlaveMode | DisableCRT2Display); |
| 2627 | temp = 0xFFFF ^ temp; |
| 2628 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2629 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2630 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2631 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2632 | if (pVBInfo->IF_DEF_LCDA == 1) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2633 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2634 | if (((HwDeviceExtension->jChipType >= XG20) || |
| 2635 | (HwDeviceExtension->jChipType >= XG40)) && |
| 2636 | (pVBInfo->IF_DEF_LVDS == 0)) { |
| 2637 | if (pVBInfo->VBType & |
| 2638 | (VB_SIS302B | |
| 2639 | VB_SIS301LV | |
| 2640 | VB_SIS302LV | |
| 2641 | VB_XGI301C)) { |
| 2642 | if (temp & EnableDualEdge) { |
| 2643 | tempbx |= SetCRT2ToDualEdge; |
| 2644 | if (temp & SetToLCDA) |
| 2645 | tempbx |= XGI_SetCRT2ToLCDA; |
| 2646 | } |
| 2647 | } |
| 2648 | } |
| 2649 | } |
| 2650 | |
| 2651 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 2652 | if (((pVBInfo->IF_DEF_LVDS == 0) && |
| 2653 | ((pVBInfo->VBType & VB_SIS301LV) || |
| 2654 | (pVBInfo->VBType & VB_SIS302LV) || |
| 2655 | (pVBInfo->VBType & VB_XGI301C)))) { |
| 2656 | if (temp & SetYPbPr) { |
| 2657 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2658 | /* shampoo add for new |
| 2659 | * scratch */ |
| 2660 | temp = xgifb_reg_get( |
| 2661 | pVBInfo->P3d4, |
| 2662 | 0x35); |
| 2663 | temp &= YPbPrMode; |
| 2664 | tempbx |= SetCRT2ToHiVision; |
| 2665 | |
| 2666 | if (temp != YPbPrMode1080i) { |
| 2667 | tempbx &= |
| 2668 | (~SetCRT2ToHiVision); |
| 2669 | tempbx |= |
| 2670 | SetCRT2ToYPbPr525750; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2671 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2672 | } |
| 2673 | } |
| 2674 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2675 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2676 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2677 | tempax = push; /* restore CR31 */ |
| 2678 | |
| 2679 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2680 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2681 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 2682 | temp = 0x09FC; |
| 2683 | else |
| 2684 | temp = 0x097C; |
| 2685 | } else { |
| 2686 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 2687 | temp = 0x01FC; |
| 2688 | else |
| 2689 | temp = 0x017C; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2690 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2691 | } else { /* 3nd party chip */ |
| 2692 | temp = SetCRT2ToLCD; |
| 2693 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2694 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2695 | if (!(tempbx & temp)) { |
| 2696 | tempax |= DisableCRT2Display; |
| 2697 | tempbx = 0; |
| 2698 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2699 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2700 | if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2701 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2702 | if (tempbx & XGI_SetCRT2ToLCDA) { |
| 2703 | if (tempbx & SetSimuScanMode) |
| 2704 | tempbx &= (~(SetCRT2ToLCD | |
| 2705 | SetCRT2ToRAMDAC | |
| 2706 | SwitchCRT2)); |
| 2707 | else |
| 2708 | tempbx &= (~(SetCRT2ToLCD | |
| 2709 | SetCRT2ToRAMDAC | |
| 2710 | SetCRT2ToTV | |
| 2711 | SwitchCRT2)); |
| 2712 | } |
| 2713 | } |
| 2714 | } |
| 2715 | |
| 2716 | /* shampoo add */ |
| 2717 | /* for driver abnormal */ |
| 2718 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { |
| 2719 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 2720 | if (tempbx & SetCRT2ToRAMDAC) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2721 | tempbx &= (0xFF00 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2722 | SetCRT2ToRAMDAC | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2723 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2724 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2725 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2726 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2727 | } else { |
| 2728 | tempbx &= (~(SetCRT2ToRAMDAC | |
| 2729 | SetCRT2ToLCD | |
| 2730 | SetCRT2ToTV)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2731 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2732 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2733 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2734 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 2735 | if (tempbx & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2736 | tempbx &= (0xFF00 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2737 | SetCRT2ToLCD | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2738 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2739 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2740 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2741 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2742 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2743 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2744 | if (tempbx & SetCRT2ToSCART) { |
| 2745 | tempbx &= (0xFF00 | |
| 2746 | SetCRT2ToSCART | |
| 2747 | SwitchCRT2 | |
| 2748 | SetSimuScanMode); |
| 2749 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
| 2750 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2751 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2752 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 2753 | if (tempbx & SetCRT2ToYPbPr525750) |
| 2754 | tempbx &= (0xFF00 | |
| 2755 | SwitchCRT2 | |
| 2756 | SetSimuScanMode); |
| 2757 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2758 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2759 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2760 | if (tempbx & SetCRT2ToHiVision) |
| 2761 | tempbx &= (0xFF00 | |
| 2762 | SetCRT2ToHiVision | |
| 2763 | SwitchCRT2 | |
| 2764 | SetSimuScanMode); |
| 2765 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2766 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2767 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 2768 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) |
| 2769 | tempbx = DisableCRT2Display; |
| 2770 | } |
| 2771 | |
| 2772 | if (!(tempbx & DisableCRT2Display)) { |
| 2773 | if ((!(tempbx & DriverMode)) || |
| 2774 | (!(modeflag & CRT2Mode))) { |
| 2775 | if (pVBInfo->IF_DEF_LCDA == 1) { |
| 2776 | if (!(tempbx & XGI_SetCRT2ToLCDA)) |
| 2777 | tempbx |= (SetInSlaveMode | |
| 2778 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2779 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2780 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2781 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2782 | /* LCD+TV can't support in slave mode |
| 2783 | * (Force LCDA+TV->LCDB) */ |
| 2784 | if ((tempbx & SetInSlaveMode) && |
| 2785 | (tempbx & XGI_SetCRT2ToLCDA)) { |
| 2786 | tempbx ^= (SetCRT2ToLCD | |
| 2787 | XGI_SetCRT2ToLCDA | |
| 2788 | SetCRT2ToDualEdge); |
| 2789 | pVBInfo->SetFlag |= ReserveTVOption; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2790 | } |
| 2791 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2792 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2793 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2794 | } |
| 2795 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2796 | static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2797 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2798 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2799 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2800 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2801 | tempbx = 0; |
| 2802 | resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2803 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2804 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2805 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2806 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2807 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2808 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2809 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2810 | tempbx = temp; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2811 | if (tempbx & TVSetPAL) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2812 | tempbx &= (SetCHTVOverScan | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2813 | TVSetPALM | |
| 2814 | TVSetPALN | |
| 2815 | TVSetPAL); |
| 2816 | if (tempbx & TVSetPALM) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2817 | /* set to NTSC if PAL-M */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2818 | tempbx &= ~TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2819 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2820 | tempbx &= (SetCHTVOverScan | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2821 | TVSetNTSCJ | |
| 2822 | TVSetPAL); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2823 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2824 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2825 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 2826 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2827 | tempbx |= TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2828 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2829 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2830 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2831 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2832 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2833 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2834 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2835 | if (index1 == YPbPrMode525i) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2836 | tempbx |= TVSetYPbPr525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2837 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2838 | if (index1 == YPbPrMode525p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2839 | tempbx = tempbx | TVSetYPbPr525p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2840 | if (index1 == YPbPrMode750p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2841 | tempbx = tempbx | TVSetYPbPr750p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2842 | } |
| 2843 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2844 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2845 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2846 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
| 2847 | tempbx = tempbx | TVSetHiVision | TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2848 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2849 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2850 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2851 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 2852 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2853 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2854 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2855 | if (!(tempbx & TVSetPAL) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2856 | (modeflag > 13) && |
| 2857 | (resinfo == 8)) /* NTSC 1024x768, */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2858 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2859 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2860 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2861 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2862 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2863 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2864 | tempbx &= (~RPLLDIV2XO); |
| 2865 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2866 | if (tempbx & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2867 | (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2868 | tempbx &= (~RPLLDIV2XO); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2869 | else if (!(pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2870 | (VB_SIS301B | |
| 2871 | VB_SIS302B | |
| 2872 | VB_SIS301LV | |
| 2873 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2874 | VB_XGI301C))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2875 | if (tempbx & TVSimuMode) |
| 2876 | tempbx &= (~RPLLDIV2XO); |
| 2877 | } |
| 2878 | } |
| 2879 | } |
| 2880 | } |
| 2881 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2882 | } |
| 2883 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2884 | static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, |
| 2885 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2886 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2887 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2888 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2889 | pVBInfo->LCDResInfo = 0; |
| 2890 | pVBInfo->LCDTypeInfo = 0; |
| 2891 | pVBInfo->LCDInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2892 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2893 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2894 | /* si+Ext_ResInfo // */ |
| 2895 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2896 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2897 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2898 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2899 | if (tempbx == 0) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2900 | tempbx = Panel_1024x768; /* default */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2901 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 2902 | /* LCD75 */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2903 | if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2904 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2905 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2906 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2907 | tempax &= 0x0F; |
| 2908 | else |
| 2909 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2910 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2911 | if ((resinfo == 6) || (resinfo == 9)) { |
| 2912 | if (tempax >= 3) |
| 2913 | tempbx |= PanelRef75Hz; |
| 2914 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 2915 | if (tempax >= 4) |
| 2916 | tempbx |= PanelRef75Hz; |
| 2917 | } |
| 2918 | } |
| 2919 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2920 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2921 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2922 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2923 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2924 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2925 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2926 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2927 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2928 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2929 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2930 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2931 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2932 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2933 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2934 | tempbx |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2935 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2936 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2937 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2938 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2939 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2940 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2941 | if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2942 | & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2943 | tempbx |= SetLCDDualLink; |
| 2944 | } |
| 2945 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2946 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2947 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2948 | if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2949 | & SetCRT2ToLCD) && (resinfo == 9) && |
| 2950 | (!(tempbx & EnableScalingLCD))) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2951 | /* set to center in 1280x1024 LCDB for Panel_1400x1050 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2952 | tempbx |= SetLCDtoNonExpanding; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2953 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2954 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2955 | if (pVBInfo->IF_DEF_ExpLink == 1) { |
| 2956 | if (modeflag & HalfDCLK) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2957 | if (!(tempbx & SetLCDtoNonExpanding)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2958 | tempbx |= XGI_EnableLVDSDDA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2959 | } else { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2960 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
| 2961 | if (resinfo == 4) {/* 512x384 */ |
| 2962 | tempbx |= XGI_EnableLVDSDDA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2963 | } |
| 2964 | } |
| 2965 | } |
| 2966 | } |
| 2967 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2968 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2969 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2970 | if (pVBInfo->VBInfo & SetNotSimuMode) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2971 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2972 | } else { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2973 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2974 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2975 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2976 | pVBInfo->LCDInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2977 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2978 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2979 | } |
| 2980 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2981 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2982 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2983 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2984 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
| 2985 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo) |
| 2986 | break; |
| 2987 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) |
| 2988 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2989 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2990 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2991 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2992 | } |
| 2993 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2994 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 2995 | { |
| 2996 | unsigned char ujRet = 0; |
| 2997 | unsigned char i = 0; |
| 2998 | |
| 2999 | for (i = 0; i < 8; i++) { |
| 3000 | ujRet = ujRet << 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3001 | ujRet |= (ujDate >> i) & 1; |
| 3002 | } |
| 3003 | |
| 3004 | return ujRet; |
| 3005 | } |
| 3006 | |
| 3007 | /*----------------------------------------------------------------------------*/ |
| 3008 | /* output */ |
| 3009 | /* bl[5] : LVDS signal */ |
| 3010 | /* bl[1] : LVDS backlight */ |
| 3011 | /* bl[0] : LVDS VDD */ |
| 3012 | /*----------------------------------------------------------------------------*/ |
| 3013 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 3014 | { |
| 3015 | unsigned char CR4A, temp; |
| 3016 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3017 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3018 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3019 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3020 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3021 | |
| 3022 | temp = XG21GPIODataTransfer(temp); |
| 3023 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3024 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3025 | return temp; |
| 3026 | } |
| 3027 | |
| 3028 | /*----------------------------------------------------------------------------*/ |
| 3029 | /* output */ |
| 3030 | /* bl[5] : LVDS signal */ |
| 3031 | /* bl[1] : LVDS backlight */ |
| 3032 | /* bl[0] : LVDS VDD */ |
| 3033 | /*----------------------------------------------------------------------------*/ |
| 3034 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 3035 | { |
| 3036 | unsigned char CR4A, CRB4, temp; |
| 3037 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3038 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3039 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3040 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3041 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3042 | |
| 3043 | temp &= 0x0C; |
| 3044 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3045 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3046 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3047 | temp |= ((CRB4 & 0x04) << 3); |
| 3048 | return temp; |
| 3049 | } |
| 3050 | |
Aaro Koskinen | 0ebf538 | 2011-11-27 23:03:09 +0200 | [diff] [blame] | 3051 | /*----------------------------------------------------------------------------*/ |
| 3052 | /* input */ |
| 3053 | /* bl[5] : 1;LVDS signal on */ |
| 3054 | /* bl[1] : 1;LVDS backlight on */ |
| 3055 | /* bl[0] : 1:LVDS VDD on */ |
| 3056 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 3057 | /* 000010b : clear bit 1, to set bit1 */ |
| 3058 | /* 000001b : clear bit 0, to set bit0 */ |
| 3059 | /*----------------------------------------------------------------------------*/ |
| 3060 | static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 3061 | struct vb_device_info *pVBInfo) |
| 3062 | { |
| 3063 | unsigned char CR4A, temp; |
| 3064 | |
| 3065 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 3066 | tempbh &= 0x23; |
| 3067 | tempbl &= 0x23; |
| 3068 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 3069 | |
| 3070 | if (tempbh & 0x20) { |
| 3071 | temp = (tempbl >> 4) & 0x02; |
| 3072 | |
| 3073 | /* CR B4[1] */ |
| 3074 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 3075 | |
| 3076 | } |
| 3077 | |
| 3078 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
| 3079 | |
| 3080 | temp = XG21GPIODataTransfer(temp); |
| 3081 | temp &= ~tempbh; |
| 3082 | temp |= tempbl; |
| 3083 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
| 3084 | } |
| 3085 | |
Aaro Koskinen | 776115a | 2011-11-27 23:03:10 +0200 | [diff] [blame] | 3086 | static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 3087 | struct vb_device_info *pVBInfo) |
| 3088 | { |
| 3089 | unsigned char CR4A, temp; |
| 3090 | unsigned short tempbh0, tempbl0; |
| 3091 | |
| 3092 | tempbh0 = tempbh; |
| 3093 | tempbl0 = tempbl; |
| 3094 | tempbh0 &= 0x20; |
| 3095 | tempbl0 &= 0x20; |
| 3096 | tempbh0 >>= 3; |
| 3097 | tempbl0 >>= 3; |
| 3098 | |
| 3099 | if (tempbh & 0x20) { |
| 3100 | temp = (tempbl >> 4) & 0x02; |
| 3101 | |
| 3102 | /* CR B4[1] */ |
| 3103 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 3104 | |
| 3105 | } |
| 3106 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
| 3107 | |
| 3108 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 3109 | tempbh &= 0x03; |
| 3110 | tempbl &= 0x03; |
| 3111 | tempbh <<= 2; |
| 3112 | tempbl <<= 2; /* GPIOC,GPIOD */ |
| 3113 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 3114 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
| 3115 | } |
| 3116 | |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3117 | /* --------------------------------------------------------------------- */ |
| 3118 | /* Function : XGI_XG21SetPanelDelay */ |
| 3119 | /* Input : */ |
| 3120 | /* Output : */ |
| 3121 | /* Description : */ |
| 3122 | /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */ |
| 3123 | /* : bl : 2 ; T2 : the duration signal on and Vdd on */ |
| 3124 | /* : bl : 3 ; T3 : the duration between CPL off and signal off */ |
| 3125 | /* : bl : 4 ; T4 : the duration signal off and Vdd off */ |
| 3126 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3127 | static void XGI_XG21SetPanelDelay(struct xgifb_video_info *xgifb_info, |
| 3128 | unsigned short tempbl, |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3129 | struct vb_device_info *pVBInfo) |
| 3130 | { |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3131 | if (tempbl == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3132 | mdelay(xgifb_info->lvds_data.PSC_S1); |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3133 | |
| 3134 | if (tempbl == 2) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3135 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3136 | |
| 3137 | if (tempbl == 3) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3138 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3139 | |
| 3140 | if (tempbl == 4) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3141 | mdelay(xgifb_info->lvds_data.PSC_S4); |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3142 | } |
| 3143 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3144 | static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info, |
| 3145 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3146 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3147 | { |
| 3148 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3149 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3150 | if (pXGIHWDE->jChipType == XG21) { |
| 3151 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 3152 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3153 | /* LVDS VDD on */ |
| 3154 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3155 | XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3156 | } |
| 3157 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3158 | /* LVDS signal on */ |
| 3159 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3160 | XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3161 | /* LVDS backlight on */ |
| 3162 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3163 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3164 | /* DVO/DVI signal on */ |
| 3165 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3166 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3167 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3168 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3169 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3170 | if (pXGIHWDE->jChipType == XG27) { |
| 3171 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 3172 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3173 | /* LVDS VDD on */ |
| 3174 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3175 | XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3176 | } |
| 3177 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3178 | /* LVDS signal on */ |
| 3179 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3180 | XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3181 | /* LVDS backlight on */ |
| 3182 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3183 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3184 | /* DVO/DVI signal on */ |
| 3185 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3186 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3187 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3188 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3189 | } |
| 3190 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3191 | void XGI_DisplayOff(struct xgifb_video_info *xgifb_info, |
| 3192 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3193 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3194 | { |
| 3195 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3196 | if (pXGIHWDE->jChipType == XG21) { |
| 3197 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3198 | /* LVDS backlight off */ |
| 3199 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3200 | XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3201 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3202 | /* DVO/DVI signal off */ |
| 3203 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3204 | } |
| 3205 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3206 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3207 | if (pXGIHWDE->jChipType == XG27) { |
| 3208 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3209 | /* LVDS backlight off */ |
| 3210 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3211 | XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3212 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3213 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3214 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3215 | /* DVO/DVI signal off */ |
| 3216 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3217 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3218 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3219 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3220 | } |
| 3221 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3222 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3223 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3224 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3225 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3226 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3227 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3228 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3229 | } |
| 3230 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3231 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3232 | { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 3233 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3234 | } |
| 3235 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3236 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 3237 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3238 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3239 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3240 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3241 | /* reserve CR34 for CRT1 Mode No */ |
| 3242 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3243 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 3244 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3245 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3246 | } |
| 3247 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3248 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
| 3249 | unsigned short ModeIdIndex, |
| 3250 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3251 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3252 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3253 | |
Aaro Koskinen | 6c0965f | 2012-04-07 01:14:11 +0300 | [diff] [blame] | 3254 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3255 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 3256 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
| 3257 | /* si+St_ModeFlag */ |
| 3258 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3259 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3260 | if (modeflag & HalfDCLK) |
| 3261 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3262 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3263 | if (modeflag & DoubleScanMode) |
| 3264 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3265 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 3266 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3267 | goto exit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3268 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 3269 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3270 | if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
| 3271 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 3272 | if (yres == 1024) |
| 3273 | yres = 1056; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3274 | } |
| 3275 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3276 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 3277 | if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
| 3278 | if (yres == 400) |
| 3279 | yres = 405; |
| 3280 | else if (yres == 350) |
| 3281 | yres = 360; |
| 3282 | |
| 3283 | if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { |
| 3284 | if (yres == 360) |
| 3285 | yres = 375; |
| 3286 | } |
| 3287 | } |
| 3288 | |
| 3289 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
| 3290 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 3291 | if (!(pVBInfo->LCDInfo & LCDNonExpanding)) { |
| 3292 | if (yres == 350) |
| 3293 | yres = 357; |
| 3294 | else if (yres == 400) |
| 3295 | yres = 420; |
| 3296 | else if (yres == 480) |
| 3297 | yres = 525; |
| 3298 | } |
| 3299 | } |
| 3300 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3301 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3302 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 3303 | if (xres == 720) |
| 3304 | xres = 640; |
| 3305 | |
| 3306 | exit: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3307 | pVBInfo->VGAHDE = xres; |
| 3308 | pVBInfo->HDE = xres; |
| 3309 | pVBInfo->VGAVDE = yres; |
| 3310 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3311 | } |
| 3312 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3313 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3314 | { |
| 3315 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3316 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) && |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 3317 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3318 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3319 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3320 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3321 | } |
| 3322 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3323 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
| 3324 | unsigned short ModeIdIndex, |
| 3325 | unsigned short RefreshRateTableIndex, |
| 3326 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3327 | { |
| 3328 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3329 | CRT1Index; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3330 | |
| 3331 | pVBInfo->RVBHCMAX = 1; |
| 3332 | pVBInfo->RVBHCFACT = 1; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3333 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3334 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
| 3335 | CRT1Index &= IndexMask; |
| 3336 | temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0]; |
| 3337 | temp2 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
| 3338 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
| 3339 | tempbx = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8]; |
| 3340 | tempcx = (unsigned short) |
| 3341 | pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8; |
| 3342 | tempcx &= 0x0100; |
| 3343 | tempcx = tempcx << 2; |
| 3344 | tempbx |= tempcx; |
| 3345 | temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3346 | |
| 3347 | if (temp1 & 0x01) |
| 3348 | tempbx |= 0x0100; |
| 3349 | |
| 3350 | if (temp1 & 0x20) |
| 3351 | tempbx |= 0x0200; |
| 3352 | tempax += 5; |
| 3353 | |
| 3354 | if (modeflag & Charx8Dot) |
| 3355 | tempax *= 8; |
| 3356 | else |
| 3357 | tempax *= 9; |
| 3358 | |
| 3359 | pVBInfo->VGAHT = tempax; |
| 3360 | pVBInfo->HT = tempax; |
| 3361 | tempbx++; |
| 3362 | pVBInfo->VGAVT = tempbx; |
| 3363 | pVBInfo->VT = tempbx; |
| 3364 | } |
| 3365 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3366 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3367 | unsigned short RefreshRateTableIndex, |
| 3368 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3369 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3370 | unsigned short tempax = 0, tempbx, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3371 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 3372 | struct SiS_LCDData *LCDPtr = NULL; |
| 3373 | struct SiS_TVData *TVPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3374 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3375 | /* si+Ext_ResInfo */ |
| 3376 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3377 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3378 | pVBInfo->NewFlickerMode = 0; |
| 3379 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3380 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3381 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 3382 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3383 | pVBInfo); |
| 3384 | return; |
| 3385 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3386 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3387 | tempbx = 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3388 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3389 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 3390 | LCDPtr = (struct SiS_LCDData *) XGI_GetLcdPtr(tempbx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3391 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3392 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3393 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3394 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 3395 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 3396 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 3397 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 3398 | pVBInfo->HT = LCDPtr->LCDHT; |
| 3399 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3400 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3401 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3402 | tempax = 1024; |
| 3403 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3404 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3405 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3406 | if (pVBInfo->VGAVDE == 357) |
| 3407 | tempbx = 527; |
| 3408 | else if (pVBInfo->VGAVDE == 420) |
| 3409 | tempbx = 620; |
| 3410 | else if (pVBInfo->VGAVDE == 525) |
| 3411 | tempbx = 775; |
| 3412 | else if (pVBInfo->VGAVDE == 600) |
| 3413 | tempbx = 775; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3414 | else |
| 3415 | tempbx = 768; |
| 3416 | } else |
| 3417 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3418 | } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3419 | tempax = 1024; |
| 3420 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3421 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3422 | tempax = 1280; |
| 3423 | if (pVBInfo->VGAVDE == 360) |
| 3424 | tempbx = 768; |
| 3425 | else if (pVBInfo->VGAVDE == 375) |
| 3426 | tempbx = 800; |
| 3427 | else if (pVBInfo->VGAVDE == 405) |
| 3428 | tempbx = 864; |
| 3429 | else |
| 3430 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3431 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3432 | tempax = 1280; |
| 3433 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3434 | } else if (pVBInfo->LCDResInfo == Panel_1280x960) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3435 | tempax = 1280; |
| 3436 | if (pVBInfo->VGAVDE == 350) |
| 3437 | tempbx = 700; |
| 3438 | else if (pVBInfo->VGAVDE == 400) |
| 3439 | tempbx = 800; |
| 3440 | else if (pVBInfo->VGAVDE == 1024) |
| 3441 | tempbx = 960; |
| 3442 | else |
| 3443 | tempbx = 960; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3444 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3445 | tempax = 1400; |
| 3446 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3447 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3448 | if (pVBInfo->VGAVDE == 1024) { |
| 3449 | tempax = 1280; |
| 3450 | tempbx = 1024; |
| 3451 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3452 | } else if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3453 | tempax = 1600; |
| 3454 | tempbx = 1200; /* alan 10/14/2003 */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3455 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3456 | if (pVBInfo->VGAVDE == 350) |
| 3457 | tempbx = 875; |
| 3458 | else if (pVBInfo->VGAVDE == 400) |
| 3459 | tempbx = 1000; |
| 3460 | } |
| 3461 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3462 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3463 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 3464 | tempax = pVBInfo->VGAHDE; |
| 3465 | tempbx = pVBInfo->VGAVDE; |
| 3466 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3467 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3468 | pVBInfo->HDE = tempax; |
| 3469 | pVBInfo->VDE = tempbx; |
| 3470 | return; |
| 3471 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3472 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3473 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
| 3474 | tempbx = 4; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 3475 | TVPtr = (struct SiS_TVData *) XGI_GetTVPtr(tempbx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3476 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3477 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3478 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3479 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 3480 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 3481 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 3482 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 3483 | pVBInfo->HDE = TVPtr->TVHDE; |
| 3484 | pVBInfo->VDE = TVPtr->TVVDE; |
| 3485 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 3486 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3487 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3488 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3489 | if (resinfo == 0x08) |
| 3490 | pVBInfo->NewFlickerMode = 0x40; |
| 3491 | else if (resinfo == 0x09) |
| 3492 | pVBInfo->NewFlickerMode = 0x40; |
| 3493 | else if (resinfo == 0x12) |
| 3494 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3495 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3496 | if (pVBInfo->VGAVDE == 350) |
| 3497 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3498 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3499 | tempax = ExtHiTVHT; |
| 3500 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3501 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3502 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3503 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3504 | tempax = StHiTVHT; |
| 3505 | tempbx = StHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3506 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3507 | if (!(modeflag & Charx8Dot)) { |
| 3508 | tempax = StHiTextTVHT; |
| 3509 | tempbx = StHiTextTVVT; |
| 3510 | } |
| 3511 | } |
| 3512 | } |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3513 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 3514 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3515 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 3516 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 3517 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3518 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3519 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3520 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 3521 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3522 | } else if (pVBInfo->TVInfo & TVSetYPbPr525i) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3523 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 3524 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 3525 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 3526 | tempax = NTSC1024x768HT; |
| 3527 | } |
| 3528 | } else { |
| 3529 | tempax = PALHT; |
| 3530 | tempbx = PALVT; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3531 | if (!(pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3532 | tempax = NTSCHT; |
| 3533 | tempbx = NTSCVT; |
| 3534 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 3535 | tempax = NTSC1024x768HT; |
| 3536 | } |
| 3537 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3538 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3539 | pVBInfo->HT = tempax; |
| 3540 | pVBInfo->VT = tempbx; |
| 3541 | return; |
| 3542 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3543 | } |
| 3544 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3545 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3546 | unsigned short RefreshRateTableIndex, |
| 3547 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3548 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 3549 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3550 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3551 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 3552 | pVBInfo); |
| 3553 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 3554 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3555 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3556 | if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3557 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3558 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 3559 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 3560 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3561 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3562 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 3563 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3564 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3565 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3566 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3567 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3568 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 3569 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3570 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 3571 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3572 | } |
| 3573 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3574 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
| 3575 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3576 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3577 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 3578 | short index; |
| 3579 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3580 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3581 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3582 | index = (modeflag & ModeTypeMask) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3583 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3584 | if (index < 0) |
| 3585 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3586 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3587 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3588 | } |
| 3589 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3590 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 3591 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3592 | unsigned short RefreshRateTableIndex, |
| 3593 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3594 | struct vb_device_info *pVBInfo) |
| 3595 | { |
| 3596 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 3597 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 3598 | |
| 3599 | modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3600 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3601 | |
| 3602 | index = (modeinfo >> 8) & 0xFF; |
| 3603 | |
| 3604 | temp = pVBInfo->ScreenOffset[index]; |
| 3605 | |
| 3606 | if (infoflag & InterlaceMode) |
| 3607 | temp = temp << 1; |
| 3608 | |
| 3609 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 3610 | |
| 3611 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 3612 | temp = ModeNo - 0x7C; |
| 3613 | colordepth = ColorDepth[temp]; |
| 3614 | temp = 0x6B; |
| 3615 | if (infoflag & InterlaceMode) |
| 3616 | temp = temp << 1; |
| 3617 | return temp * colordepth; |
| 3618 | } else { |
| 3619 | return temp * colordepth; |
| 3620 | } |
| 3621 | } |
| 3622 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3623 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 3624 | unsigned short ModeIdIndex, |
| 3625 | unsigned short RefreshRateTableIndex, |
| 3626 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3627 | struct vb_device_info *pVBInfo) |
| 3628 | { |
| 3629 | unsigned short offset; |
| 3630 | unsigned char temp; |
| 3631 | |
| 3632 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 3633 | return; |
| 3634 | |
| 3635 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3636 | HwDeviceExtension, pVBInfo); |
| 3637 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3638 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3639 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3640 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3641 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3642 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3643 | } |
| 3644 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3645 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3646 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3647 | /* threshold high ,disable auto threshold */ |
| 3648 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 3649 | /* threshold low default 04h */ |
| 3650 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3651 | } |
| 3652 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3653 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3654 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3655 | unsigned short RefreshRateTableIndex, |
| 3656 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3657 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3658 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3659 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3660 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
| 3661 | CRT1Index &= IndexMask; |
| 3662 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3663 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3664 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3665 | HwDeviceExtension, pVBInfo); |
| 3666 | XGI_SetCRT2FIFO(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3667 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3668 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3669 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3670 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3671 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 3672 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3673 | } |
| 3674 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3675 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3676 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3677 | unsigned short RefreshRateTableIndex, |
| 3678 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3679 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3680 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
| 3681 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3682 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3683 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
| 3684 | CRT1Index &= IndexMask; |
| 3685 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 3686 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3687 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3688 | /* bainy change table name */ |
| 3689 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3690 | /* BTVGA2HT 0x08,0x09 */ |
| 3691 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3692 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3693 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3694 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3695 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 3696 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3697 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3698 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 3699 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 3700 | tempcx = tempcx >> 1; |
| 3701 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 3702 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3703 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3704 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 3705 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3706 | tempbx |= ((pVBInfo-> |
| 3707 | XGINEWUB_CRT1Table[CRT1Index].CR[14] & |
| 3708 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3709 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 3710 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
| 3711 | tempcx &= 0x1F; |
| 3712 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15]; |
| 3713 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 3714 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 3715 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3716 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3717 | tempbx += 4; |
| 3718 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3719 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3720 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 3721 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3722 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3723 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3724 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3725 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3726 | } else { |
| 3727 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3728 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3729 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3730 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3731 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 3732 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3733 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3734 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 3735 | pushbx = pVBInfo->VGAHDE + 16; |
| 3736 | tempcx = tempcx >> 1; |
| 3737 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 3738 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3739 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3740 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 3741 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3742 | tempbx |= ((pVBInfo-> |
| 3743 | XGINEWUB_CRT1Table[CRT1Index].CR[5] & |
| 3744 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3745 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 3746 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
| 3747 | tempcx &= 0x1F; |
| 3748 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6]; |
| 3749 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 3750 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 3751 | tempbx += 16; |
| 3752 | tempcx += 16; |
| 3753 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3754 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3755 | if (tempcx > pVBInfo->VGAHT) |
| 3756 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3757 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3758 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3759 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3760 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3761 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3762 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 3763 | tempbx = pushbx; |
| 3764 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 3765 | tempax |= (tempbx & 0xFF00); |
| 3766 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3767 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3768 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3769 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3770 | tempcx = (pVBInfo->VGAVT - 1); |
| 3771 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3772 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3773 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3774 | tempbx = pVBInfo->VGAVDE - 1; |
| 3775 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3776 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3777 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 3778 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3779 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3780 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3781 | tempax = pVBInfo->VGAVDE; |
| 3782 | tempbx = pVBInfo->VGAVDE; |
| 3783 | tempcx = pVBInfo->VGAVT; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3784 | /* BTVGA2VRS 0x10,0x11 */ |
| 3785 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 3786 | /* BTVGA2VRE 0x11 */ |
| 3787 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3788 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3789 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 3790 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; |
| 3791 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3792 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3793 | if (temp & 0x04) |
| 3794 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3795 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3796 | if (temp & 0x080) |
| 3797 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3798 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3799 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3800 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3801 | if (temp & 0x08) |
| 3802 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3803 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3804 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; |
| 3805 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 3806 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3807 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3808 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3809 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3810 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 3811 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3812 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3813 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3814 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3815 | if (modeflag & DoubleScanMode) |
| 3816 | tempax |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3817 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3818 | if (modeflag & HalfDCLK) |
| 3819 | tempax |= 0x40; |
| 3820 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3821 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3822 | } |
| 3823 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3824 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 3825 | { |
| 3826 | unsigned long tempax, tempbx; |
| 3827 | |
| 3828 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 3829 | & 0xFFFF; |
| 3830 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 3831 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 3832 | |
| 3833 | return (unsigned short) tempax; |
| 3834 | } |
| 3835 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3836 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3837 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3838 | unsigned short RefreshRateTableIndex, |
| 3839 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3840 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3841 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
| 3842 | modeflag, CRT1Index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3843 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3844 | /* si+Ext_ResInfo */ |
| 3845 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3846 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 3847 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
| 3848 | CRT1Index &= IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3849 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3850 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 3851 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3852 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3853 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3854 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3855 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3856 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3857 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3858 | modeflag |= Charx8Dot; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3859 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3860 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3861 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3862 | if (modeflag & HalfDCLK) |
| 3863 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3864 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3865 | tempax = (tempax / tempcx) - 1; |
| 3866 | tempbx |= ((tempax & 0x00FF) << 8); |
| 3867 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3868 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3869 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3870 | temp = (tempbx & 0xFF00) >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3871 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3872 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3873 | if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3874 | | VB_SIS302LV | VB_XGI301C))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3875 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3876 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3877 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3878 | if (pVBInfo->VBType & VB_SIS301LV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3879 | if (pVBInfo->VBExtInfo == VB_YPbPr1080i) { |
| 3880 | if (resinfo == 7) |
| 3881 | temp -= 2; |
| 3882 | } |
| 3883 | } else if (resinfo == 7) { |
| 3884 | temp -= 2; |
| 3885 | } |
| 3886 | } |
| 3887 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3888 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3889 | /* 0x05 Horizontal Display Start */ |
| 3890 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 3891 | /* 0x06 Horizontal Blank end */ |
| 3892 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3893 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3894 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 3895 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3896 | tempax = pVBInfo->VGAHT; |
| 3897 | else |
| 3898 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3899 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3900 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3901 | if (tempax >= pVBInfo->VGAHT) |
| 3902 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3903 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3904 | if (modeflag & HalfDCLK) |
| 3905 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3906 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3907 | tempax = (tempax / tempcx) - 5; |
| 3908 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3909 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3910 | temp = (tempbx & 0x00FF) - 1; |
| 3911 | if (!(modeflag & HalfDCLK)) { |
| 3912 | temp -= 6; |
| 3913 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3914 | temp -= 4; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3915 | temp -= 10; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3916 | } |
| 3917 | } |
| 3918 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3919 | tempbx = (tempbx & 0xFF00) >> 8; |
| 3920 | tempcx = (tempcx + tempbx) >> 1; |
| 3921 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3922 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3923 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3924 | temp -= 1; |
| 3925 | if (!(modeflag & HalfDCLK)) { |
| 3926 | if ((modeflag & Charx8Dot)) { |
| 3927 | temp += 4; |
| 3928 | if (pVBInfo->VGAHDE >= 800) |
| 3929 | temp -= 6; |
| 3930 | } |
| 3931 | } |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3932 | } else if (!(modeflag & HalfDCLK)) { |
| 3933 | temp -= 4; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3934 | if (pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3935 | pVBInfo->VGAHDE >= 800) { |
| 3936 | temp -= 7; |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3937 | if (pVBInfo->VGAHDE >= 1280 && |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3938 | pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3939 | (pVBInfo->LCDInfo & LCDNonExpanding)) |
| 3940 | temp += 28; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3941 | } |
| 3942 | } |
| 3943 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3944 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3945 | /* 0x07 Horizontal Retrace Start */ |
| 3946 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 3947 | /* 0x08 Horizontal Retrace End */ |
| 3948 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3949 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3950 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3951 | if (pVBInfo->TVInfo & TVSimuMode) { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3952 | if (ModeNo == 0x50) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3953 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3954 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3955 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3956 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3957 | 0x08, 0x03); |
| 3958 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3959 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3960 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3961 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3962 | 0x08, 0x02); |
| 3963 | } |
| 3964 | } |
| 3965 | } |
| 3966 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3967 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3968 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3969 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3970 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3971 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3972 | tempbx = pVBInfo->VGAVT; |
| 3973 | push1 = tempbx; |
| 3974 | tempcx = 0x121; |
| 3975 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3976 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3977 | if (tempbx == 357) |
| 3978 | tempbx = 350; |
| 3979 | if (tempbx == 360) |
| 3980 | tempbx = 350; |
| 3981 | if (tempbx == 375) |
| 3982 | tempbx = 350; |
| 3983 | if (tempbx == 405) |
| 3984 | tempbx = 400; |
| 3985 | if (tempbx == 525) |
| 3986 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3987 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3988 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3989 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3990 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3991 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3992 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3993 | if (tempbx == 350) |
| 3994 | tempbx += 5; |
| 3995 | if (tempbx == 480) |
| 3996 | tempbx += 5; |
| 3997 | } |
| 3998 | } |
| 3999 | } |
| 4000 | tempbx--; |
| 4001 | temp = tempbx & 0x00FF; |
| 4002 | tempbx--; |
| 4003 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4004 | /* 0x10 vertical Blank Start */ |
| 4005 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4006 | tempbx = push2; |
| 4007 | tempbx--; |
| 4008 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4009 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4010 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4011 | if (tempbx & 0x0100) |
| 4012 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4013 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4014 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4015 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4016 | if (modeflag & DoubleScanMode) |
| 4017 | tempax |= 0x08000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4018 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4019 | if (tempbx & 0x0200) |
| 4020 | tempcx |= 0x0040; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4021 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4022 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4023 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4024 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4025 | if (tempbx & 0x0400) |
| 4026 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4027 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4028 | /* 0x11 Vertival Blank End */ |
| 4029 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4030 | |
| 4031 | tempax = push1; |
| 4032 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 4033 | tempax = tempax >> 2; |
| 4034 | push1 = tempax; /* push ax */ |
| 4035 | |
| 4036 | if (resinfo != 0x09) { |
| 4037 | tempax = tempax << 1; |
| 4038 | tempbx += tempax; |
| 4039 | } |
| 4040 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4041 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Miguel Gómez | 470c533 | 2012-07-06 12:40:50 +0200 | [diff] [blame] | 4042 | if ((pVBInfo->VBType & VB_SIS301LV) && |
| 4043 | !(pVBInfo->TVInfo & TVSetHiVision)) { |
| 4044 | if ((pVBInfo->TVInfo & TVSimuMode) && |
| 4045 | (pVBInfo->TVInfo & TVSetPAL)) { |
| 4046 | if (!(pVBInfo->VBType & VB_SIS301LV) || |
| 4047 | !(pVBInfo->TVInfo & |
| 4048 | (TVSetYPbPr525p | |
| 4049 | TVSetYPbPr750p | |
| 4050 | TVSetHiVision))) |
| 4051 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4052 | } |
| 4053 | } else { |
| 4054 | tempbx -= 10; |
| 4055 | } |
| 4056 | } else { |
| 4057 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4058 | if (pVBInfo->TVInfo & TVSetPAL) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4059 | if (pVBInfo->VBType & VB_SIS301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4060 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4061 | (TVSetYPbPr525p | |
| 4062 | TVSetYPbPr750p | |
| 4063 | TVSetHiVision))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4064 | tempbx += 40; |
| 4065 | } else { |
| 4066 | tempbx += 40; |
| 4067 | } |
| 4068 | } |
| 4069 | } |
| 4070 | } |
| 4071 | tempax = push1; |
| 4072 | tempax = tempax >> 2; |
| 4073 | tempax++; |
| 4074 | tempax += tempbx; |
| 4075 | push1 = tempax; /* push ax */ |
| 4076 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4077 | if ((pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4078 | if (tempbx <= 513) { |
| 4079 | if (tempax >= 513) |
| 4080 | tempbx = 513; |
| 4081 | } |
| 4082 | } |
| 4083 | |
| 4084 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4085 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4086 | tempbx--; |
| 4087 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4088 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4089 | |
| 4090 | if (tempbx & 0x0100) |
| 4091 | tempcx |= 0x0008; |
| 4092 | |
| 4093 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4094 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4095 | |
| 4096 | tempbx++; |
| 4097 | |
| 4098 | if (tempbx & 0x0100) |
| 4099 | tempcx |= 0x0004; |
| 4100 | |
| 4101 | if (tempbx & 0x0200) |
| 4102 | tempcx |= 0x0080; |
| 4103 | |
| 4104 | if (tempbx & 0x0400) |
| 4105 | tempcx |= 0x0C00; |
| 4106 | |
| 4107 | tempbx = push1; /* pop ax */ |
| 4108 | temp = tempbx & 0x00FF; |
| 4109 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4110 | /* 0x0D vertical Retrace End */ |
| 4111 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4112 | |
| 4113 | if (tempbx & 0x0010) |
| 4114 | tempcx |= 0x2000; |
| 4115 | |
| 4116 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4117 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4118 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4119 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4120 | tempax = modeflag; |
| 4121 | temp = (tempax & 0xFF00) >> 8; |
| 4122 | |
| 4123 | temp = (temp >> 1) & 0x09; |
| 4124 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4125 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4126 | temp |= 0x01; |
| 4127 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4128 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 4129 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 4130 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4131 | |
| 4132 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 4133 | temp = 0x80; |
| 4134 | else |
| 4135 | temp = 0x00; |
| 4136 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4137 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4138 | |
| 4139 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4140 | } |
| 4141 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4142 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4143 | unsigned short RefreshRateTableIndex, |
| 4144 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4145 | struct vb_device_info *pVBInfo) |
| 4146 | { |
| 4147 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
| 4148 | modeflag, resinfo, crt2crtc; |
| 4149 | unsigned char *TimingPoint; |
| 4150 | |
| 4151 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 4152 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4153 | /* si+Ext_ResInfo */ |
| 4154 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 4155 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4156 | crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4157 | |
| 4158 | tempax = 0; |
| 4159 | |
| 4160 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 4161 | tempax |= 0x0800; |
| 4162 | |
| 4163 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 4164 | tempax |= 0x0400; |
| 4165 | |
| 4166 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 4167 | tempax |= 0x0200; |
| 4168 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4169 | if (!(pVBInfo->TVInfo & TVSetPAL)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4170 | tempax |= 0x1000; |
| 4171 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4172 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4173 | tempax |= 0x0100; |
| 4174 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4175 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4176 | tempax &= 0xfe00; |
| 4177 | |
| 4178 | tempax = (tempax & 0xff00) >> 8; |
| 4179 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4180 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4181 | TimingPoint = pVBInfo->NTSCTiming; |
| 4182 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4183 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4184 | TimingPoint = pVBInfo->PALTiming; |
| 4185 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4186 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4187 | TimingPoint = pVBInfo->HiTVExtTiming; |
| 4188 | |
| 4189 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 4190 | TimingPoint = pVBInfo->HiTVSt2Timing; |
| 4191 | |
| 4192 | if (pVBInfo->SetFlag & TVSimuMode) |
| 4193 | TimingPoint = pVBInfo->HiTVSt1Timing; |
| 4194 | |
| 4195 | if (!(modeflag & Charx8Dot)) |
| 4196 | TimingPoint = pVBInfo->HiTVTextTiming; |
| 4197 | } |
| 4198 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4199 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 4200 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4201 | TimingPoint = pVBInfo->YPbPr525iTiming; |
| 4202 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4203 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4204 | TimingPoint = pVBInfo->YPbPr525pTiming; |
| 4205 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4206 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4207 | TimingPoint = pVBInfo->YPbPr750pTiming; |
| 4208 | } |
| 4209 | |
| 4210 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4211 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4212 | |
| 4213 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4214 | /* di->temp2[j] */ |
| 4215 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4216 | |
| 4217 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4218 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4219 | |
| 4220 | temp = pVBInfo->NewFlickerMode; |
| 4221 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4222 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4223 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4224 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4225 | tempax = 950; |
| 4226 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4227 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4228 | tempax = 520; |
| 4229 | else |
| 4230 | tempax = 440; |
| 4231 | |
| 4232 | if (pVBInfo->VDE <= tempax) { |
| 4233 | tempax -= pVBInfo->VDE; |
| 4234 | tempax = tempax >> 2; |
| 4235 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 4236 | push1 = tempax; |
| 4237 | temp = (tempax & 0xFF00) >> 8; |
| 4238 | temp += (unsigned short) TimingPoint[0]; |
| 4239 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4240 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4241 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4242 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 4243 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4244 | | SetCRT2ToYPbPr525750)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4245 | tempcx = pVBInfo->VGAHDE; |
| 4246 | if (tempcx >= 1024) { |
| 4247 | temp = 0x17; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4248 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4249 | temp = 0x19; /* PAL */ |
| 4250 | } |
| 4251 | } |
| 4252 | } |
| 4253 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4254 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4255 | tempax = push1; |
| 4256 | temp = (tempax & 0xFF00) >> 8; |
| 4257 | temp += TimingPoint[1]; |
| 4258 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4259 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4260 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4261 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 4262 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4263 | | SetCRT2ToYPbPr525750))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4264 | tempcx = pVBInfo->VGAHDE; |
| 4265 | if (tempcx >= 1024) { |
| 4266 | temp = 0x1D; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4267 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4268 | temp = 0x52; /* PAL */ |
| 4269 | } |
| 4270 | } |
| 4271 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4272 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4273 | } |
| 4274 | |
| 4275 | /* 301b */ |
| 4276 | tempcx = pVBInfo->HT; |
| 4277 | |
| 4278 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4279 | tempcx = tempcx >> 1; |
| 4280 | |
| 4281 | tempcx -= 2; |
| 4282 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4283 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4284 | |
| 4285 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4286 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4287 | |
| 4288 | tempcx = pVBInfo->HT >> 1; |
| 4289 | push1 = tempcx; /* push cx */ |
| 4290 | tempcx += 7; |
| 4291 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4292 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4293 | tempcx -= 4; |
| 4294 | |
| 4295 | temp = tempcx & 0x00FF; |
| 4296 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4297 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4298 | |
| 4299 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 4300 | tempbx += tempcx; |
| 4301 | push2 = tempbx; |
| 4302 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4303 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4304 | temp = (tempbx & 0xFF00) >> 8; |
| 4305 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4306 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4307 | |
| 4308 | tempbx = push2; |
| 4309 | tempbx = tempbx + 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4310 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4311 | tempbx = tempbx - 4; |
| 4312 | tempcx = tempbx; |
| 4313 | } |
| 4314 | |
| 4315 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4316 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4317 | |
| 4318 | j += 2; |
| 4319 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 4320 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4321 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4322 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4323 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4324 | |
| 4325 | tempcx += 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4326 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4327 | tempcx -= 4; |
| 4328 | |
| 4329 | temp = tempcx & 0xFF; |
| 4330 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4331 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4332 | |
| 4333 | tempcx = push1; /* pop cx */ |
| 4334 | j += 2; |
| 4335 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 4336 | tempcx -= temp; |
| 4337 | temp = tempcx & 0x00FF; |
| 4338 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4339 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4340 | |
| 4341 | tempcx -= 11; |
| 4342 | |
| 4343 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 4344 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 4345 | tempcx = tempax - 1; |
| 4346 | } |
| 4347 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4348 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4349 | |
| 4350 | tempbx = pVBInfo->VDE; |
| 4351 | |
| 4352 | if (pVBInfo->VGAVDE == 360) |
| 4353 | tempbx = 746; |
| 4354 | if (pVBInfo->VGAVDE == 375) |
| 4355 | tempbx = 746; |
| 4356 | if (pVBInfo->VGAVDE == 405) |
| 4357 | tempbx = 853; |
| 4358 | |
| 4359 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4360 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4361 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4362 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4363 | (TVSetYPbPr525p | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4364 | tempbx = tempbx >> 1; |
| 4365 | } else |
| 4366 | tempbx = tempbx >> 1; |
| 4367 | } |
| 4368 | |
| 4369 | tempbx -= 2; |
| 4370 | temp = tempbx & 0x00FF; |
| 4371 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4372 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4373 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4374 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4375 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 4376 | if (ModeNo == 0x2f) |
| 4377 | temp += 1; |
| 4378 | } |
| 4379 | } |
| 4380 | } else { |
| 4381 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 4382 | if (ModeNo == 0x2f) |
| 4383 | temp += 1; |
| 4384 | } |
| 4385 | } |
| 4386 | } |
| 4387 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4388 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4389 | |
| 4390 | temp = (tempcx & 0xFF00) >> 8; |
| 4391 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 4392 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4393 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4394 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4395 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4396 | temp |= 0x10; |
| 4397 | |
| 4398 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 4399 | temp |= 0x20; |
| 4400 | } |
| 4401 | } else { |
| 4402 | temp |= 0x10; |
| 4403 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 4404 | temp |= 0x20; |
| 4405 | } |
| 4406 | } |
| 4407 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4408 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4409 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4410 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4411 | | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4412 | tempbx = pVBInfo->VDE; |
| 4413 | tempcx = tempbx - 2; |
| 4414 | |
| 4415 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4416 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p |
| 4417 | | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4418 | tempbx = tempbx >> 1; |
| 4419 | } |
| 4420 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4421 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4422 | temp = 0; |
| 4423 | if (tempcx & 0x0400) |
| 4424 | temp |= 0x20; |
| 4425 | |
| 4426 | if (tempbx & 0x0400) |
| 4427 | temp |= 0x40; |
| 4428 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4429 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4430 | } |
| 4431 | |
| 4432 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4433 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4434 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4435 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4436 | } |
| 4437 | |
| 4438 | tempbx = tempbx & 0x00FF; |
| 4439 | |
| 4440 | if (!(modeflag & HalfDCLK)) { |
| 4441 | tempcx = pVBInfo->VGAHDE; |
| 4442 | if (tempcx >= pVBInfo->HDE) { |
| 4443 | tempbx |= 0x2000; |
| 4444 | tempax &= 0x00FF; |
| 4445 | } |
| 4446 | } |
| 4447 | |
| 4448 | tempcx = 0x0101; |
| 4449 | |
| 4450 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 4451 | if (pVBInfo->VGAHDE >= 1024) { |
| 4452 | tempcx = 0x1920; |
| 4453 | if (pVBInfo->VGAHDE >= 1280) { |
| 4454 | tempcx = 0x1420; |
| 4455 | tempbx = tempbx & 0xDFFF; |
| 4456 | } |
| 4457 | } |
| 4458 | } |
| 4459 | |
| 4460 | if (!(tempbx & 0x2000)) { |
| 4461 | if (modeflag & HalfDCLK) |
| 4462 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 4463 | |
| 4464 | push1 = tempbx; |
| 4465 | tempeax = pVBInfo->VGAHDE; |
| 4466 | tempebx = (tempcx & 0xFF00) >> 8; |
| 4467 | longtemp = tempeax * tempebx; |
| 4468 | tempecx = tempcx & 0x00FF; |
| 4469 | longtemp = longtemp / tempecx; |
| 4470 | |
| 4471 | /* 301b */ |
| 4472 | tempecx = 8 * 1024; |
| 4473 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4474 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4475 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4476 | tempecx = tempecx * 8; |
| 4477 | } |
| 4478 | |
| 4479 | longtemp = longtemp * tempecx; |
| 4480 | tempecx = pVBInfo->HDE; |
| 4481 | temp2 = longtemp % tempecx; |
| 4482 | tempeax = longtemp / tempecx; |
| 4483 | if (temp2 != 0) |
| 4484 | tempeax += 1; |
| 4485 | |
| 4486 | tempax = (unsigned short) tempeax; |
| 4487 | |
| 4488 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4489 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4490 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4491 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 4492 | } |
| 4493 | /* end 301b */ |
| 4494 | |
| 4495 | tempbx = push1; |
| 4496 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 4497 | | (tempbx & 0x00FF)); |
| 4498 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 4499 | | (tempax & 0x00FF)); |
| 4500 | temp = (tempax & 0xFF00) >> 8; |
| 4501 | } else { |
| 4502 | temp = (tempax & 0x00FF) >> 8; |
| 4503 | } |
| 4504 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4505 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4506 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4507 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4508 | temp = tempcx & 0x00FF; |
| 4509 | |
| 4510 | if (tempbx & 0x2000) |
| 4511 | temp = 0; |
| 4512 | |
| 4513 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 4514 | temp |= 0x18; |
| 4515 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4516 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4517 | if (pVBInfo->TVInfo & TVSetPAL) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4518 | tempbx = 0x0382; |
| 4519 | tempcx = 0x007e; |
| 4520 | } else { |
| 4521 | tempbx = 0x0369; |
| 4522 | tempcx = 0x0061; |
| 4523 | } |
| 4524 | |
| 4525 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4526 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4527 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4528 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4529 | |
| 4530 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 4531 | temp = temp << 2; |
| 4532 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 4533 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4534 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4535 | temp |= 0x10; |
| 4536 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4537 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4538 | temp |= 0x20; |
| 4539 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4540 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4541 | temp |= 0x60; |
| 4542 | } |
| 4543 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4544 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4545 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4546 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4547 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4548 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4549 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 4550 | TimingPoint = XGI_NTSC1024AdjTime; |
| 4551 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4552 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4553 | TimingPoint[j]); |
| 4554 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4555 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4556 | } |
| 4557 | } |
| 4558 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 4559 | /* Modify for 301C PALM Support */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4560 | if (pVBInfo->VBType & VB_XGI301C) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4561 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4562 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4563 | 0x08); /* PALM Mode */ |
| 4564 | } |
| 4565 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4566 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4567 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4568 | 0x01); |
| 4569 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 4570 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4571 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 4572 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4573 | } |
| 4574 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4575 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4576 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4577 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4578 | } |
| 4579 | |
| 4580 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 4581 | return; |
| 4582 | } |
| 4583 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4584 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4585 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4586 | unsigned short RefreshRateTableIndex, |
| 4587 | struct vb_device_info *pVBInfo) |
| 4588 | { |
| 4589 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
| 4590 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; |
| 4591 | |
| 4592 | struct XGI_LCDDesStruct *LCDBDesPtr = NULL; |
| 4593 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4594 | /* si+Ext_ResInfo */ |
| 4595 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 4596 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4597 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
| 4598 | CRT1Index &= IndexMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4599 | |
| 4600 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 4601 | return; |
| 4602 | |
| 4603 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 4604 | |
| 4605 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4606 | tempbx = tempbx >> 1; |
| 4607 | |
| 4608 | tempbx -= 1; |
| 4609 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4610 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4611 | temp = (tempbx & 0xFF00) >> 8; |
| 4612 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4613 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4614 | temp = 0x01; |
| 4615 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4616 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4617 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
| 4618 | push1 = tempbx; |
| 4619 | tempbx--; |
| 4620 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4621 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4622 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4623 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4624 | |
| 4625 | tempcx = pVBInfo->VT - 1; |
| 4626 | push2 = tempcx + 1; |
| 4627 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4628 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4629 | temp = (tempcx & 0xFF00) >> 8; |
| 4630 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4631 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4632 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 4633 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 4634 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 4635 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4636 | |
| 4637 | /* Customized LCDB Des no add */ |
| 4638 | tempbx = 5; |
| 4639 | LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo, |
| 4640 | ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 4641 | tempah = pVBInfo->LCDResInfo; |
| 4642 | tempah &= PanelResInfo; |
| 4643 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4644 | if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4645 | tempbx = 1024; |
| 4646 | tempcx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4647 | } else if ((tempah == Panel_1280x1024) || |
| 4648 | (tempah == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4649 | tempbx = 1280; |
| 4650 | tempcx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4651 | } else if (tempah == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4652 | tempbx = 1400; |
| 4653 | tempcx = 1050; |
| 4654 | } else { |
| 4655 | tempbx = 1600; |
| 4656 | tempcx = 1200; |
| 4657 | } |
| 4658 | |
| 4659 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 4660 | tempbx = pVBInfo->HDE; |
| 4661 | tempcx = pVBInfo->VDE; |
| 4662 | } |
| 4663 | |
| 4664 | pushbx = tempbx; |
| 4665 | tempax = pVBInfo->VT; |
| 4666 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 4667 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 4668 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 4669 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 4670 | tempbx = pVBInfo->LCDVDES; |
| 4671 | tempcx += tempbx; |
| 4672 | |
| 4673 | if (tempcx >= tempax) |
| 4674 | tempcx -= tempax; /* lcdvdes */ |
| 4675 | |
| 4676 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4677 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4678 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4679 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4680 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 4681 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 4682 | tempah = tempch; |
| 4683 | tempah = tempah << 3; |
| 4684 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4685 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4686 | |
| 4687 | /* getlcdsync() */ |
| 4688 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 4689 | tempcx = tempbx; |
| 4690 | tempax = pVBInfo->VT; |
| 4691 | tempbx = pVBInfo->LCDVRS; |
| 4692 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4693 | tempcx += tempbx; |
| 4694 | if (tempcx >= tempax) |
| 4695 | tempcx -= tempax; |
| 4696 | |
| 4697 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4698 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4699 | temp = (tempbx & 0xFF00) >> 8; |
| 4700 | temp = temp << 4; |
| 4701 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4702 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4703 | tempcx = pushbx; |
| 4704 | tempax = pVBInfo->HT; |
| 4705 | tempbx = pVBInfo->LCDHDES; |
| 4706 | tempbx &= 0x0FFF; |
| 4707 | |
| 4708 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 4709 | tempax = tempax >> 1; |
| 4710 | tempbx = tempbx >> 1; |
| 4711 | tempcx = tempcx >> 1; |
| 4712 | } |
| 4713 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4714 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4715 | tempbx += 1; |
| 4716 | |
| 4717 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 4718 | tempbx += 1; |
| 4719 | |
| 4720 | tempcx += tempbx; |
| 4721 | |
| 4722 | if (tempcx >= tempax) |
| 4723 | tempcx -= tempax; |
| 4724 | |
| 4725 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4726 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4727 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4728 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4729 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4730 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4731 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4732 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4733 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4734 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 4735 | tempcx = tempax; |
| 4736 | tempax = pVBInfo->HT; |
| 4737 | tempbx = pVBInfo->LCDHRS; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4738 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 4739 | tempax = tempax >> 1; |
| 4740 | tempbx = tempbx >> 1; |
| 4741 | tempcx = tempcx >> 1; |
| 4742 | } |
| 4743 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4744 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4745 | tempbx += 1; |
| 4746 | |
| 4747 | tempcx += tempbx; |
| 4748 | |
| 4749 | if (tempcx >= tempax) |
| 4750 | tempcx -= tempax; |
| 4751 | |
| 4752 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4753 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4754 | |
| 4755 | temp = (tempbx & 0xFF00) >> 8; |
| 4756 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4757 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4758 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4759 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4760 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4761 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4762 | if (pVBInfo->VGAVDE == 525) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4763 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 4764 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4765 | | VB_XGI301C)) { |
| 4766 | temp = 0xC6; |
| 4767 | } else |
| 4768 | temp = 0xC4; |
| 4769 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4770 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 4771 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4772 | } |
| 4773 | |
| 4774 | if (pVBInfo->VGAVDE == 420) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4775 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 4776 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4777 | | VB_XGI301C)) { |
| 4778 | temp = 0x4F; |
| 4779 | } else |
| 4780 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4781 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4782 | } |
| 4783 | } |
| 4784 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4785 | |
| 4786 | /* --------------------------------------------------------------------- */ |
| 4787 | /* Function : XGI_GetTap4Ptr */ |
| 4788 | /* Input : */ |
| 4789 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 4790 | /* Description : */ |
| 4791 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4792 | static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4793 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4794 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4795 | unsigned short tempax, tempbx, i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4796 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4797 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4798 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4799 | if (tempcx == 0) { |
| 4800 | tempax = pVBInfo->VGAHDE; |
| 4801 | tempbx = pVBInfo->HDE; |
| 4802 | } else { |
| 4803 | tempax = pVBInfo->VGAVDE; |
| 4804 | tempbx = pVBInfo->VDE; |
| 4805 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4806 | |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4807 | if (tempax <= tempbx) |
| 4808 | return &xgifb_tap4_timing[0]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4809 | else |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4810 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4811 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4812 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4813 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4814 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4815 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 4816 | if ((pVBInfo->TVInfo & TVSetYPbPr525i) || |
| 4817 | (pVBInfo->TVInfo & TVSetYPbPr525p)) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4818 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4819 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4820 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 4821 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4822 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4823 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4824 | Tap4TimingPtr = xgifb_tap4_timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4825 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4826 | i = 0; |
| 4827 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 4828 | if (Tap4TimingPtr[i].DE == tempax) |
| 4829 | break; |
| 4830 | i++; |
| 4831 | } |
| 4832 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4833 | } |
| 4834 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4835 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4836 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4837 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4838 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4839 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4840 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4841 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 4842 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4843 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4844 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 4845 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4846 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4847 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4848 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4849 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4850 | /* Set Vertical Scaling */ |
| 4851 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4852 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4853 | xgifb_reg_set(pVBInfo->Part2Port, |
| 4854 | i, |
| 4855 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4856 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4857 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4858 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4859 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4860 | /* Enable V.Scaling */ |
| 4861 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4862 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4863 | /* Enable H.Scaling */ |
| 4864 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4865 | } |
| 4866 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4867 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4868 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4869 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4870 | unsigned short i; |
| 4871 | unsigned char *tempdi; |
| 4872 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4873 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4874 | /* si+Ext_ResInfo */ |
| 4875 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4876 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4877 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4878 | if (pVBInfo->TVInfo & TVSetPAL) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4879 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 4880 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4881 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4882 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 4883 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4884 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4885 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4886 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4887 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4888 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4889 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4890 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 4891 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 4892 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4893 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4894 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4895 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo |
| 4896 | & SetCRT2ToYPbPr525750)) { |
| 4897 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4898 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4899 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4900 | tempdi = pVBInfo->HiTVGroup3Data; |
| 4901 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 4902 | tempdi = pVBInfo->HiTVGroup3Simu; |
| 4903 | if (!(modeflag & Charx8Dot)) |
| 4904 | tempdi = pVBInfo->HiTVGroup3Text; |
| 4905 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4906 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4907 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4908 | tempdi = pVBInfo->Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4909 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4910 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4911 | tempdi = pVBInfo->Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4912 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4913 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4914 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4915 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4916 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4917 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4918 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4919 | } |
| 4920 | } |
| 4921 | return; |
| 4922 | } /* {end of XGI_SetGroup3} */ |
| 4923 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4924 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4925 | unsigned short RefreshRateTableIndex, |
| 4926 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4927 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4928 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4929 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4930 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4931 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4932 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4933 | /* si+Ext_ResInfo */ |
| 4934 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4935 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4936 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4937 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4938 | tempbx = pVBInfo->RVBHCMAX; |
| 4939 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4940 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4941 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 4942 | tempcx = pVBInfo->VGAHT - 1; |
| 4943 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4944 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4945 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4946 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 4947 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4948 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4949 | tempcx = pVBInfo->VGAVT - 1; |
| 4950 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4951 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4952 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4953 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4954 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4955 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4956 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4957 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4958 | tempcx = pVBInfo->VBInfo; |
| 4959 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4960 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4961 | if (modeflag & HalfDCLK) |
| 4962 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4963 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4964 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4965 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4966 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4967 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4968 | temp = 0; |
| 4969 | if (tempbx <= 1024) |
| 4970 | temp = 0xA0; |
| 4971 | if (tempbx == 1280) |
| 4972 | temp = 0xC0; |
| 4973 | } else if (tempcx & SetCRT2ToTV) { |
| 4974 | temp = 0xA0; |
| 4975 | if (tempbx <= 800) |
| 4976 | temp = 0x80; |
| 4977 | } else { |
| 4978 | temp = 0x80; |
| 4979 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4980 | temp = 0; |
| 4981 | if (tempbx > 800) |
| 4982 | temp = 0x60; |
| 4983 | } |
| 4984 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4985 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4986 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4987 | temp = 0x00; |
| 4988 | if (pVBInfo->VGAHDE == 1280) |
| 4989 | temp = 0x40; |
| 4990 | if (pVBInfo->VGAHDE == 1024) |
| 4991 | temp = 0x20; |
| 4992 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4993 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4994 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4995 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4996 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4997 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4998 | if (!(temp & 0xE000)) |
| 4999 | tempbx = tempbx >> 1; |
| 5000 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5001 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5002 | tempcx = pVBInfo->RVBHRS; |
| 5003 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5004 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5005 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5006 | tempeax = pVBInfo->VGAVDE; |
| 5007 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5008 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5009 | if (tempeax <= tempebx) { |
| 5010 | tempcx = (tempcx & (~0x4000)); |
| 5011 | tempeax = pVBInfo->VGAVDE; |
| 5012 | } else { |
| 5013 | tempeax -= tempebx; |
| 5014 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5015 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5016 | templong = (tempeax * 256 * 1024) % tempebx; |
| 5017 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 5018 | tempebx = tempeax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5019 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5020 | if (templong != 0) |
| 5021 | tempebx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5022 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5023 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5024 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5025 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5026 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5027 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5028 | tempbx = (unsigned short) (tempebx >> 16); |
| 5029 | temp = tempbx & 0x00FF; |
| 5030 | temp = temp << 4; |
| 5031 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5032 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5033 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5034 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5035 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5036 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5037 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5038 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5039 | tempax = pVBInfo->VGAHDE; |
| 5040 | if (modeflag & HalfDCLK) |
| 5041 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5042 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5043 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5044 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5045 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5046 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 5047 | if (tempax > 800) |
| 5048 | tempax -= 800; |
| 5049 | } else { |
| 5050 | if (pVBInfo->VGAHDE > 800) { |
| 5051 | if (pVBInfo->VGAHDE == 1024) |
| 5052 | tempax = (tempax * 25 / 32) - 1; |
| 5053 | else |
| 5054 | tempax = (tempax * 20 / 32) - 1; |
| 5055 | } |
| 5056 | } |
| 5057 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5058 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5059 | temp = (tempax & 0xFF00) >> 8; |
| 5060 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5061 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5062 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5063 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5064 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5065 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5066 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5067 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5068 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5069 | } |
| 5070 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5071 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5072 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 5073 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5074 | | TVSetYPbPr525p | TVSetYPbPr750p |
| 5075 | | TVSetHiVision))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5076 | temp |= 0x0001; |
| 5077 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 5078 | && (!(pVBInfo->TVInfo |
| 5079 | & TVSimuMode))) |
| 5080 | temp &= (~0x0001); |
| 5081 | } |
| 5082 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5083 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5084 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5085 | tempbx = pVBInfo->HT; |
| 5086 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5087 | tempbx = tempbx >> 1; |
| 5088 | tempbx = (tempbx >> 1) - 2; |
| 5089 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5090 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5091 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5092 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5093 | } |
| 5094 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5095 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5096 | if (pVBInfo->ISXPDOS == 0) |
| 5097 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5098 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5099 | } |
| 5100 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5101 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 5102 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5103 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5104 | } |
| 5105 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5106 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5107 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5108 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5109 | unsigned short Pindex, Pdata; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5110 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5111 | Pindex = pVBInfo->Part5Port; |
| 5112 | Pdata = pVBInfo->Part5Port + 1; |
| 5113 | if (pVBInfo->ModeType == ModeVGA) { |
| 5114 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5115 | | DisableCRT2Display))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5116 | XGINew_EnableCRT2(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5117 | } |
| 5118 | } |
| 5119 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5120 | } |
| 5121 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5122 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5123 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5124 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5125 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5126 | } |
| 5127 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5128 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5129 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5130 | { |
| 5131 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5132 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5133 | } |
| 5134 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5135 | static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, |
| 5136 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5137 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5138 | { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5139 | unsigned short xres, yres, colordepth, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5140 | |
Aaro Koskinen | 6c0965f | 2012-04-07 01:14:11 +0300 | [diff] [blame] | 5141 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5142 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 5143 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
| 5144 | /* si+St_ModeFlag */ |
| 5145 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5146 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5147 | if (!(modeflag & Charx8Dot)) { |
| 5148 | xres /= 9; |
| 5149 | xres *= 8; |
| 5150 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5151 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5152 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 5153 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5154 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5155 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 5156 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5157 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5158 | if (xres > xgifb_info->lvds_data.LVDSHDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5159 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 5160 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5161 | if (yres > xgifb_info->lvds_data.LVDSVDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5162 | return 0; |
| 5163 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5164 | if (xres != xgifb_info->lvds_data.LVDSHDE || |
| 5165 | yres != xgifb_info->lvds_data.LVDSVDE) { |
| 5166 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 5167 | if (colordepth > 2) |
| 5168 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5169 | } |
| 5170 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5171 | } |
| 5172 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5173 | static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, |
| 5174 | int chip_id, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5175 | unsigned short ModeNo, |
| 5176 | unsigned short ModeIdIndex, |
| 5177 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5178 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5179 | unsigned char temp, Miscdata; |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5180 | unsigned short xres, yres, modeflag, resindex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5181 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 5182 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 5183 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5184 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5185 | temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5186 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5187 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5188 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5189 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5190 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5191 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5192 | temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5193 | /* SR35[7] FP VSync polarity */ |
| 5194 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 5195 | /* SR30[5] FP HSync polarity */ |
| 5196 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5197 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5198 | if (chip_id == XG27) |
| 5199 | XGI_SetXG27FPBits(pVBInfo); |
| 5200 | else |
| 5201 | XGI_SetXG21FPBits(pVBInfo); |
| 5202 | |
Aaro Koskinen | 6c0965f | 2012-04-07 01:14:11 +0300 | [diff] [blame] | 5203 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5204 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 5205 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
| 5206 | /* si+St_ModeFlag */ |
| 5207 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5208 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5209 | if (!(modeflag & Charx8Dot)) |
| 5210 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5211 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5212 | LVDSHT = xgifb_info->lvds_data.LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5213 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5214 | LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5215 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5216 | if (LVDSHBS > LVDSHT) |
| 5217 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5218 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5219 | LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5220 | if (LVDSHRS > LVDSHT) |
| 5221 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5222 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5223 | LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5224 | if (LVDSHRE > LVDSHT) |
| 5225 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5226 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5227 | LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5228 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5229 | LVDSVT = xgifb_info->lvds_data.LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5230 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5231 | LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5232 | if (modeflag & DoubleScanMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5233 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5234 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5235 | if (LVDSVBS > LVDSVT) |
| 5236 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5237 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5238 | LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5239 | if (LVDSVRS > LVDSVT) |
| 5240 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5241 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5242 | LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5243 | if (LVDSVRE > LVDSVT) |
| 5244 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5245 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5246 | LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5247 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5248 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5249 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5250 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5251 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5252 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5253 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5254 | /* HT SR0B[1:0] CR00 */ |
| 5255 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5256 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5257 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5258 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5259 | /* HBS SR0B[5:4] CR02 */ |
| 5260 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5261 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5262 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5263 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5264 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 5265 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5266 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 5267 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 5268 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5269 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5270 | /* HRS SR0B[7:6] CR04 */ |
| 5271 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5272 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5273 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5274 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5275 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 5276 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5277 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5278 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5279 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5280 | /* HRE SR0C[2] CR05[4:0] */ |
| 5281 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5282 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 5283 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5284 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5285 | /* Panel HRE SR2F[7:2] */ |
| 5286 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5287 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5288 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5289 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 5290 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5291 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 5292 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 5293 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5294 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5295 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5296 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 5297 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5298 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 5299 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 5300 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5301 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5302 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5303 | /* VBE SR0A[4] CR16 */ |
| 5304 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5305 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5306 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5307 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5308 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 5309 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5310 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 5311 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 5312 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5313 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5314 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5315 | if (chip_id == XG27) { |
| 5316 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
| 5317 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, |
| 5318 | (value & 0x700) >> 8); |
| 5319 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
| 5320 | } else { |
| 5321 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
| 5322 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, |
| 5323 | (value & 0x600) >> 9); |
| 5324 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
| 5325 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
| 5326 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5327 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5328 | /* VRE SR0A[5] CR11[3:0] */ |
| 5329 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5330 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 5331 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5332 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5333 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5334 | if (chip_id == XG27) |
| 5335 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 5336 | (value << 2) & 0xFC); |
| 5337 | else |
| 5338 | /* SR3F[7] has to be 0, h/w bug */ |
| 5339 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 5340 | (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5341 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5342 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5343 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5344 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5345 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5346 | 0x2B, xgifb_info->lvds_data.VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5347 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5348 | 0x2C, xgifb_info->lvds_data.VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5349 | value += 0x10; |
| 5350 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5351 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5352 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5353 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5354 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5355 | /* set data, panning = 0, shift left 1 dot*/ |
| 5356 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5357 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5358 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5359 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5360 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5361 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5362 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5363 | |
| 5364 | } |
| 5365 | |
| 5366 | /* --------------------------------------------------------------------- */ |
| 5367 | /* Function : XGI_IsLCDON */ |
| 5368 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 5369 | /* Output : 0 : Skip PSC Control */ |
| 5370 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5371 | /* Description : */ |
| 5372 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5373 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5374 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5375 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5376 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5377 | tempax = pVBInfo->VBInfo; |
| 5378 | if (tempax & SetCRT2ToDualEdge) |
| 5379 | return 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5380 | else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5381 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5382 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5383 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5384 | } |
| 5385 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5386 | /* --------------------------------------------------------------------- */ |
| 5387 | /* Function : XGI_DisableChISLCD */ |
| 5388 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 5389 | /* Output : 0 -> Not LCD Mode */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5390 | /* Description : */ |
| 5391 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5392 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5393 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5394 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5395 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5396 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5397 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5398 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5399 | if (tempbx & (EnableChA | DisableChA)) { |
| 5400 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 5401 | return 0; |
| 5402 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5403 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5404 | if (!(tempbx & (EnableChB | DisableChB))) |
| 5405 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5406 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5407 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 5408 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5409 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5410 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5411 | } |
| 5412 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5413 | /* --------------------------------------------------------------------- */ |
| 5414 | /* Function : XGI_EnableChISLCD */ |
| 5415 | /* Input : */ |
| 5416 | /* Output : 0 -> Not LCD mode */ |
| 5417 | /* Description : */ |
| 5418 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5419 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5420 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5421 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5422 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5423 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5424 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5425 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5426 | if (tempbx & (EnableChA | DisableChA)) { |
| 5427 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 5428 | return 0; |
| 5429 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5430 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5431 | if (!(tempbx & (EnableChB | DisableChB))) |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 5432 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5433 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5434 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 5435 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5436 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5437 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5438 | } |
| 5439 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5440 | static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, |
| 5441 | struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5442 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5443 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 5444 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5445 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5446 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5447 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5448 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5449 | if (!(pVBInfo->VBInfo & |
| 5450 | (DisableCRT2Display | SetSimuScanMode))) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5451 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5452 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 5453 | tempah = 0x7F; /* Disable Channel A */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5454 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5455 | /* Disable Channel B */ |
| 5456 | tempah = 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5457 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5458 | if (pVBInfo->SetFlag & DisableChB) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5459 | /* force to disable Cahnnel */ |
| 5460 | tempah &= 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5461 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5462 | if (pVBInfo->SetFlag & DisableChA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5463 | /* Force to disable Channel B */ |
| 5464 | tempah &= 0x7F; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5465 | } |
| 5466 | } |
| 5467 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5468 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5469 | /* disable part4_1f */ |
| 5470 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5471 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5472 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5473 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5474 | || (XGI_DisableChISLCD(pVBInfo)) |
| 5475 | || (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5476 | /* LVDS Driver power down */ |
| 5477 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5478 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5479 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5480 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5481 | & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5482 | | SetSimuScanMode))) { |
| 5483 | if (pVBInfo->SetFlag & GatingCRT) |
| 5484 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5485 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5486 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5487 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5488 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5489 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5490 | & XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5491 | /* Power down */ |
| 5492 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5493 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5494 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5495 | /* disable TV as primary VGA swap */ |
| 5496 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5497 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5498 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5499 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5500 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5501 | if ((pVBInfo->SetFlag & DisableChB) || |
| 5502 | (pVBInfo->VBInfo & |
| 5503 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5504 | ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5505 | (pVBInfo->VBInfo & |
| 5506 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5507 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5508 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5509 | if ((pVBInfo->SetFlag & DisableChB) || |
| 5510 | (pVBInfo->VBInfo & |
| 5511 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5512 | (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) || |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5513 | (pVBInfo->VBInfo & |
| 5514 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 5515 | /* save Part1 index 0 */ |
| 5516 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 5517 | /* BTDAC = 1, avoid VB reset */ |
| 5518 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 5519 | /* disable CRT2 */ |
| 5520 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 5521 | /* restore Part1 index 0 */ |
| 5522 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5523 | } |
| 5524 | } else { /* {301} */ |
| 5525 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5526 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 5527 | /* Disable CRT2 */ |
| 5528 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 5529 | /* Disable TV asPrimary VGA swap */ |
| 5530 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5531 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5532 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5533 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5534 | | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5535 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5536 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5537 | } |
| 5538 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5539 | /* --------------------------------------------------------------------- */ |
| 5540 | /* Function : XGI_GetTVPtrIndex */ |
| 5541 | /* Input : */ |
| 5542 | /* Output : */ |
| 5543 | /* Description : bx 0 : ExtNTSC */ |
| 5544 | /* 1 : StNTSC */ |
| 5545 | /* 2 : ExtPAL */ |
| 5546 | /* 3 : StPAL */ |
| 5547 | /* 4 : ExtHiTV */ |
| 5548 | /* 5 : StHiTV */ |
| 5549 | /* 6 : Ext525i */ |
| 5550 | /* 7 : St525i */ |
| 5551 | /* 8 : Ext525p */ |
| 5552 | /* 9 : St525p */ |
| 5553 | /* A : Ext750p */ |
| 5554 | /* B : St750p */ |
| 5555 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5556 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5557 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5558 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5559 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5560 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5561 | tempbx = 2; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5562 | if (pVBInfo->TVInfo & TVSetHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5563 | tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5564 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5565 | tempbx = 6; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5566 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5567 | tempbx = 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5568 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5569 | tempbx = 10; |
| 5570 | if (pVBInfo->TVInfo & TVSimuMode) |
| 5571 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5572 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5573 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5574 | } |
| 5575 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5576 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5577 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5578 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5579 | /* Output : bx 0 : NTSC */ |
| 5580 | /* 1 : PAL */ |
| 5581 | /* 2 : PALM */ |
| 5582 | /* 3 : PALN */ |
| 5583 | /* 4 : NTSC1024x768 */ |
| 5584 | /* 5 : PAL-M 1024x768 */ |
| 5585 | /* 6-7: reserved */ |
| 5586 | /* cl 0 : YFilter1 */ |
| 5587 | /* 1 : YFilter2 */ |
| 5588 | /* ch 0 : 301A */ |
| 5589 | /* 1 : 301B/302B/301LV/302LV */ |
| 5590 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5591 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5592 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 5593 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5594 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5595 | *tempbx = 0; |
| 5596 | *tempcl = 0; |
| 5597 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5598 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5599 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5600 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5601 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5602 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5603 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5604 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5605 | if (pVBInfo->TVInfo & TVSetPALN) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5606 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5607 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5608 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 5609 | *tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5610 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5611 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5612 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5613 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5614 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5615 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5616 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 5617 | & TVSimuMode)) { |
| 5618 | *tempbx += 8; |
| 5619 | *tempcl += 1; |
| 5620 | } |
| 5621 | } |
| 5622 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5623 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5624 | | VB_SIS302LV | VB_XGI301C)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5625 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5626 | } |
| 5627 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5628 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5629 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5630 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5631 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5632 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5633 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5634 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5635 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5636 | tempbh = 0; |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 5637 | tempbl = XGI301TVDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5638 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5639 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5640 | tempbl = tempbl >> 4; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5641 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 5642 | tempbh = XGI301LCDDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5643 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5644 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5645 | tempbl = tempbh; |
| 5646 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5647 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5648 | tempbl &= 0x0F; |
| 5649 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5650 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5651 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5652 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 5653 | | SetCRT2ToTV)) { /* Channel B */ |
| 5654 | tempah &= 0xF0; |
| 5655 | tempah |= tempbl; |
| 5656 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5657 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5658 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { /* Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5659 | tempah &= 0x0F; |
| 5660 | tempah |= tempbh; |
| 5661 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5662 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5663 | } |
| 5664 | } else if (pVBInfo->IF_DEF_LVDS == 1) { |
| 5665 | tempbl = 0; |
| 5666 | tempbh = 0; |
| 5667 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 5668 | tempah = XGI301LCDDelay; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5669 | tempah &= 0x0f; |
| 5670 | tempah = tempah << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5671 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5672 | tempah); |
| 5673 | } |
| 5674 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5675 | } |
| 5676 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5677 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 5678 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5679 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5680 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5681 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5682 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5683 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5684 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5685 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5686 | /* Enable Dither */ |
| 5687 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5688 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5689 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5690 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5691 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5692 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5693 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5694 | } |
| 5695 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5696 | /* --------------------------------------------------------------------- */ |
| 5697 | /* Function : XGI_SetLCDCap_B */ |
| 5698 | /* Input : cx -> LCD Capability */ |
| 5699 | /* Output : */ |
| 5700 | /* Description : */ |
| 5701 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5702 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 5703 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5704 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5705 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5706 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5707 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 5708 | | 0x0c)); |
| 5709 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5710 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5711 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 5712 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5713 | } |
| 5714 | |
Aaro Koskinen | 7f04ec3 | 2011-11-27 23:03:05 +0200 | [diff] [blame] | 5715 | static void XGI_LongWait(struct vb_device_info *pVBInfo) |
| 5716 | { |
| 5717 | unsigned short i; |
| 5718 | |
| 5719 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
| 5720 | |
| 5721 | if (!(i & 0xC0)) { |
| 5722 | for (i = 0; i < 0xFFFF; i++) { |
| 5723 | if (!(inb(pVBInfo->P3da) & 0x08)) |
| 5724 | break; |
| 5725 | } |
| 5726 | |
| 5727 | for (i = 0; i < 0xFFFF; i++) { |
| 5728 | if ((inb(pVBInfo->P3da) & 0x08)) |
| 5729 | break; |
| 5730 | } |
| 5731 | } |
| 5732 | } |
| 5733 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5734 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5735 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5736 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5737 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5738 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5739 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5740 | /* disable down spectrum D[4] */ |
| 5741 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5742 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5743 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5744 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5745 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5746 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5747 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5748 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5749 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5750 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5751 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5752 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5753 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 5754 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5755 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5756 | } |
| 5757 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5758 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 5759 | { |
| 5760 | unsigned short tempcx; |
| 5761 | |
| 5762 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 5763 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5764 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5765 | (VB_SIS301B | |
| 5766 | VB_SIS302B | |
| 5767 | VB_SIS301LV | |
| 5768 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5769 | VB_XGI301C)) { /* 301LV/302LV only */ |
| 5770 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5771 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5772 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5773 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5774 | (unsigned char) (tempcx & 0x1F)); |
| 5775 | } |
| 5776 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5777 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5778 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 5779 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 5780 | | EnablePLLSPLOW)) >> 8)); |
| 5781 | } |
| 5782 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5783 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5784 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5785 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 5786 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5787 | else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5788 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 5789 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5790 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5791 | if (tempcx & EnableSpectrum) |
| 5792 | SetSpectrum(pVBInfo); |
| 5793 | } |
| 5794 | } else { |
| 5795 | /* LVDS,CH7017 */ |
| 5796 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 5797 | } |
| 5798 | } |
| 5799 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5800 | /* --------------------------------------------------------------------- */ |
| 5801 | /* Function : XGI_SetAntiFlicker */ |
| 5802 | /* Input : */ |
| 5803 | /* Output : */ |
| 5804 | /* Description : Set TV Customized Param. */ |
| 5805 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5806 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
| 5807 | unsigned short ModeIdIndex, |
| 5808 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5809 | { |
Aaro Koskinen | 36ae035 | 2012-04-07 01:14:08 +0300 | [diff] [blame] | 5810 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5811 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5812 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5813 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5814 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5815 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5816 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5817 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 5818 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5819 | tempah = TVAntiFlickList[tempbx]; |
| 5820 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5821 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5822 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5823 | } |
| 5824 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5825 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
| 5826 | unsigned short ModeIdIndex, |
| 5827 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5828 | { |
Aaro Koskinen | 354f49f | 2012-04-07 01:14:09 +0300 | [diff] [blame] | 5829 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5830 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5831 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5832 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5833 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 5834 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5835 | tempah = TVEdgeList[tempbx]; |
| 5836 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5837 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5838 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5839 | } |
| 5840 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5841 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5842 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5843 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5844 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5845 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5846 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5847 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5848 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5849 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 5850 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5851 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5852 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5853 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5854 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5855 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5856 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5857 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5858 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5859 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5860 | } |
| 5861 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5862 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5863 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5864 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5865 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5866 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5867 | unsigned char tempcl, tempch, tempal, *filterPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5868 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5869 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5870 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5871 | switch (tempbx) { |
| 5872 | case 0x00: |
| 5873 | case 0x04: |
| 5874 | filterPtr = NTSCYFilter1; |
| 5875 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5876 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5877 | case 0x01: |
| 5878 | filterPtr = PALYFilter1; |
| 5879 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5880 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5881 | case 0x02: |
| 5882 | case 0x05: |
| 5883 | case 0x0D: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5884 | case 0x03: |
Aaro Koskinen | 2555e94 | 2011-08-31 21:46:06 +0300 | [diff] [blame] | 5885 | filterPtr = xgifb_palmn_yfilter1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5886 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5887 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5888 | case 0x08: |
| 5889 | case 0x0C: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5890 | case 0x0A: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5891 | case 0x0B: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5892 | case 0x09: |
Aaro Koskinen | 80f86f8 | 2011-08-31 21:46:05 +0300 | [diff] [blame] | 5893 | filterPtr = xgifb_yfilter2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5894 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5895 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5896 | default: |
| 5897 | return; |
| 5898 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5899 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5900 | tempal = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5901 | if (tempcl == 0) |
| 5902 | index = tempal * 4; |
| 5903 | else |
| 5904 | index = tempal * 7; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5905 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5906 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5907 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 5908 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 5909 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 5910 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5911 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5912 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 5913 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 5914 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 5915 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5916 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5917 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5918 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5919 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5920 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 5921 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 5922 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5923 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5924 | } |
| 5925 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5926 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5927 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5928 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5929 | /* Output : */ |
| 5930 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5931 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5932 | static void XGI_OEM310Setting(unsigned short ModeNo, |
| 5933 | unsigned short ModeIdIndex, |
| 5934 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5935 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5936 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5937 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5938 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5939 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5940 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5941 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5942 | XGI_SetPhaseIncr(pVBInfo); |
| 5943 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); |
| 5944 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5945 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5946 | if (pVBInfo->VBType & VB_SIS301) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5947 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5948 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5949 | } |
| 5950 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5951 | /* --------------------------------------------------------------------- */ |
| 5952 | /* Function : XGI_SetCRT2ModeRegs */ |
| 5953 | /* Input : */ |
| 5954 | /* Output : */ |
| 5955 | /* Description : Origin code for crt2group */ |
| 5956 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5957 | static void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5958 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5959 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5960 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5961 | unsigned short tempbl; |
| 5962 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5963 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5964 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5965 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5966 | tempah = 0; |
| 5967 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5968 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5969 | tempah &= ~0x10; /* BTRAMDAC */ |
| 5970 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5971 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5972 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 5973 | | SetCRT2ToLCD)) { |
| 5974 | tempah = 0x40; /* BTDRAM */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5975 | tempcl = pVBInfo->ModeType; |
| 5976 | tempcl -= ModeVGA; |
| 5977 | if (tempcl >= 0) { |
| 5978 | /* BT Color */ |
| 5979 | tempah = (0x008 >> tempcl); |
| 5980 | if (tempah == 0) |
| 5981 | tempah = 1; |
| 5982 | tempah |= 0x040; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5983 | } |
| 5984 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 5985 | tempah ^= 0x50; /* BTDAC */ |
| 5986 | } |
| 5987 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5988 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5989 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5990 | tempah = 0x08; |
| 5991 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5992 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame^] | 5993 | if (pVBInfo->VBInfo & DisableCRT2Display) |
| 5994 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5995 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame^] | 5996 | tempah = 0x00; |
| 5997 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5998 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame^] | 5999 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
| 6000 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 6001 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6002 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame^] | 6003 | if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 6004 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
| 6005 | tempbl &= 0xf7; |
| 6006 | tempah |= 0x01; |
| 6007 | goto reg_and_or; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6008 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6009 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame^] | 6010 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 6011 | tempbl &= 0xf7; |
| 6012 | tempah |= 0x01; |
| 6013 | } |
| 6014 | |
| 6015 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD))) |
| 6016 | goto reg_and_or; |
| 6017 | |
| 6018 | tempbl &= 0xf8; |
| 6019 | tempah = 0x01; |
| 6020 | |
| 6021 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 6022 | tempah |= 0x02; |
| 6023 | |
| 6024 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 6025 | tempah = tempah ^ 0x05; |
| 6026 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 6027 | tempah = tempah ^ 0x01; |
| 6028 | } |
| 6029 | |
| 6030 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 6031 | tempah |= 0x08; |
| 6032 | |
| 6033 | reg_and_or: |
| 6034 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
| 6035 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6036 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6037 | | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6038 | tempah &= (~0x08); |
| 6039 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 6040 | & SetInSlaveMode))) { |
| 6041 | tempah |= 0x010; |
| 6042 | } |
| 6043 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6044 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6045 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6046 | tempah |= 0x020; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 6047 | if (pVBInfo->VBInfo & DriverMode) |
| 6048 | tempah = tempah ^ 0x20; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6049 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6050 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6051 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6052 | tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6053 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6054 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 6055 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6056 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6057 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6058 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 6059 | tempah |= 0x40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6060 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6061 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 6062 | if ((pVBInfo->LCDResInfo == Panel_1280x1024) |
| 6063 | || (pVBInfo->LCDResInfo == Panel_1280x1024x75)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6064 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6065 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 6066 | if (pVBInfo->LCDResInfo == Panel_1280x960) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6067 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6068 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6069 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6070 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6071 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6072 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6073 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6074 | tempah = 0; |
| 6075 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6076 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6077 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 6078 | tempbl = 0xff; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6079 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6080 | tempah |= 0x04; /* shampoo 0129 */ |
| 6081 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6082 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6083 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6084 | tempah = 0x00; |
| 6085 | tempbl = 0xcf; |
| 6086 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 6087 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 6088 | tempah |= 0x30; |
| 6089 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6090 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6091 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6092 | tempah = 0; |
| 6093 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6094 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6095 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 6096 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 6097 | tempah |= 0xc0; |
| 6098 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6099 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6100 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6101 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6102 | tempah = 0; |
| 6103 | tempbl = 0x7f; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6104 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6105 | tempbl = 0xff; |
| 6106 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 6107 | tempah |= 0x80; |
| 6108 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6109 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6110 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6111 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6112 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6113 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6114 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 6115 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6116 | } |
| 6117 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6118 | } |
| 6119 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6120 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6121 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 6122 | struct vb_device_info *pVBInfo) |
| 6123 | { |
| 6124 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6125 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6126 | |
| 6127 | } |
| 6128 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6129 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 6130 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6131 | { |
| 6132 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6133 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6134 | |
| 6135 | } |
| 6136 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6137 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6138 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6139 | unsigned short flag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6140 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6141 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 6142 | return 1; |
| 6143 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6144 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6145 | if ((flag == 1) || (flag == 2)) |
| 6146 | return 1; /* 301b */ |
| 6147 | else |
| 6148 | return 0; |
| 6149 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6150 | } |
| 6151 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6152 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 6153 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 6154 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6155 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6156 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, |
| 6157 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, |
| 6158 | 0x01, 0x01 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6159 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6160 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6161 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 6162 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6163 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6164 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6165 | index = index >> pVBInfo->SelectCRT2Rate; |
| 6166 | index &= 0x0F; |
| 6167 | |
| 6168 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 6169 | index = 0; |
| 6170 | |
| 6171 | if (index > 0) |
| 6172 | index--; |
| 6173 | |
| 6174 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6175 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6176 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6177 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 6178 | | VB_SIS301LV | VB_SIS302LV |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6179 | | VB_XGI301C)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6180 | /* 301b */ |
| 6181 | temp = LCDARefreshIndex[ |
| 6182 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6183 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6184 | temp = LCDRefreshIndex[ |
| 6185 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6186 | |
| 6187 | if (index > temp) |
| 6188 | index = temp; |
| 6189 | } else { |
| 6190 | index = 0; |
| 6191 | } |
| 6192 | } |
| 6193 | } |
| 6194 | |
| 6195 | RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex; |
| 6196 | ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID; |
| 6197 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6198 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 6199 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6200 | index++; |
| 6201 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6202 | /* do the similar adjustment like XGISearchCRT1Rate() */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6203 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 6204 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6205 | index++; |
| 6206 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6207 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 6208 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6209 | index++; |
| 6210 | } |
| 6211 | } |
| 6212 | |
| 6213 | i = 0; |
| 6214 | do { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6215 | if (pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 6216 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6217 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6218 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 6219 | Ext_InfoFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6220 | temp &= ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6221 | if (temp < pVBInfo->ModeType) |
| 6222 | break; |
| 6223 | i++; |
| 6224 | index--; |
| 6225 | |
| 6226 | } while (index != 0xFFFF); |
| 6227 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 6228 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6229 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1]. |
| 6230 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6231 | if (temp & InterlaceMode) |
| 6232 | i++; |
| 6233 | } |
| 6234 | } |
| 6235 | i--; |
| 6236 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
| 6237 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, |
| 6238 | RefreshRateTableIndex, &i, pVBInfo); |
| 6239 | } |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 6240 | return RefreshRateTableIndex + i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6241 | } |
| 6242 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6243 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6244 | struct xgi_hw_device_info *HwDeviceExtension, |
| 6245 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6246 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6247 | unsigned short RefreshRateTableIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6248 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6249 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 6250 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 6251 | ModeIdIndex, pVBInfo); |
| 6252 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6253 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 6254 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 6255 | HwDeviceExtension, pVBInfo); |
| 6256 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 6257 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6258 | } |
| 6259 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 6260 | static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6261 | struct xgi_hw_device_info *HwDeviceExtension, |
| 6262 | struct vb_device_info *pVBInfo) |
| 6263 | { |
| 6264 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
| 6265 | |
| 6266 | tempbx = pVBInfo->VBInfo; |
| 6267 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 6268 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 6269 | pVBInfo->SelectCRT2Rate = 4; |
| 6270 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 6271 | ModeIdIndex, pVBInfo); |
| 6272 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
| 6273 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6274 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 6275 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 6276 | RefreshRateTableIndex, pVBInfo); |
| 6277 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 6278 | RefreshRateTableIndex, pVBInfo); |
| 6279 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 6280 | RefreshRateTableIndex, pVBInfo); |
| 6281 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 6282 | HwDeviceExtension, pVBInfo); |
| 6283 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 6284 | RefreshRateTableIndex, pVBInfo); |
| 6285 | XGI_SetTap4Regs(pVBInfo); |
| 6286 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); |
| 6287 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 6288 | HwDeviceExtension, pVBInfo); |
| 6289 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 6290 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); |
| 6291 | XGI_AutoThreshold(pVBInfo); |
| 6292 | return 1; |
| 6293 | } |
| 6294 | |
| 6295 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 6296 | { |
| 6297 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 6298 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 6299 | 0x05, 0x00 }; |
| 6300 | |
| 6301 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 6302 | |
| 6303 | unsigned char CR17, CR63, SR31; |
| 6304 | unsigned short temp; |
| 6305 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; |
| 6306 | |
| 6307 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6308 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6309 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6310 | /* to fix XG42 single LCD sense to CRT+LCD */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6311 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6312 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6313 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 6314 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6315 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 6316 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 6317 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6318 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6319 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 6320 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6321 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6322 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6323 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6324 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6325 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6326 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6327 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6328 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6329 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6330 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6331 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6332 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6333 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6334 | |
| 6335 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6336 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6337 | |
| 6338 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6339 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6340 | CRTCData[i]); |
| 6341 | |
| 6342 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6343 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6344 | CRTCData[i]); |
| 6345 | |
| 6346 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6347 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6348 | CRTCData[i]); |
| 6349 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6350 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6351 | & 0xE0)); |
| 6352 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6353 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 6354 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 6355 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6356 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6357 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6358 | |
| 6359 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6360 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
| 6361 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); |
| 6362 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6363 | } |
| 6364 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6365 | mdelay(1); |
| 6366 | |
| 6367 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6368 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6369 | |
| 6370 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6371 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6372 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6373 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6374 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6375 | /* avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6376 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6377 | |
| 6378 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6379 | outb(0, (pVBInfo->P3c8 + 1)); |
| 6380 | outb(0, (pVBInfo->P3c8 + 1)); |
| 6381 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6382 | } |
| 6383 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6384 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 6385 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 6386 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6387 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6388 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6389 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6390 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6391 | } |
| 6392 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6393 | static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, |
| 6394 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6395 | struct vb_device_info *pVBInfo) |
| 6396 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 6397 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6398 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6399 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6400 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6401 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 6402 | if (pVBInfo->SetFlag & EnableChA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6403 | /* Power on */ |
| 6404 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6405 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6406 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 6407 | /* Power on */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6408 | xgifb_reg_set(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6409 | 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6410 | } |
| 6411 | } |
| 6412 | } |
| 6413 | |
| 6414 | if (!(pVBInfo->SetFlag & DisableChB)) { |
| 6415 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo |
| 6416 | & (SetCRT2ToLCD | SetCRT2ToTV |
| 6417 | | SetCRT2ToRAMDAC))) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6418 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6419 | pVBInfo->P3c4, 0x32); |
| 6420 | tempah &= 0xDF; |
| 6421 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6422 | if (!(pVBInfo->VBInfo & |
| 6423 | SetCRT2ToRAMDAC)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6424 | tempah |= 0x20; |
| 6425 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6426 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6427 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6428 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6429 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6430 | pVBInfo->Part1Port, 0x2E); |
| 6431 | |
| 6432 | if (!(tempah & 0x80)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6433 | xgifb_reg_or(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6434 | 0x2E, 0x80); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6435 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6436 | } |
| 6437 | } |
| 6438 | |
| 6439 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
| 6440 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6441 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6442 | 0x20); /* shampoo 0129 */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6443 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6444 | if (!XGI_DisableChISLCD(pVBInfo)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6445 | if (XGI_EnableChISLCD(pVBInfo) || |
| 6446 | (pVBInfo->VBInfo & |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6447 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6448 | /* LVDS PLL power on */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6449 | xgifb_reg_and( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6450 | pVBInfo->Part4Port, |
| 6451 | 0x2A, |
| 6452 | 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6453 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6454 | /* LVDS Driver power on */ |
| 6455 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6456 | } |
| 6457 | } |
| 6458 | |
| 6459 | tempah = 0x00; |
| 6460 | |
| 6461 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 6462 | tempah = 0xc0; |
| 6463 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 6464 | if (!(pVBInfo->VBInfo & SetSimuScanMode) && |
| 6465 | (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 6466 | (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { |
| 6467 | tempah = tempah & 0x40; |
| 6468 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
| 6469 | tempah = tempah ^ 0xC0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6470 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 6471 | if (pVBInfo->SetFlag & DisableChB) |
| 6472 | tempah &= 0xBF; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6473 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 6474 | if (pVBInfo->SetFlag & DisableChA) |
| 6475 | tempah &= 0x7F; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6476 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 6477 | if (pVBInfo->SetFlag & EnableChB) |
| 6478 | tempah |= 0x40; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6479 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 6480 | if (pVBInfo->SetFlag & EnableChA) |
| 6481 | tempah |= 0x80; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6482 | } |
| 6483 | } |
| 6484 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6485 | /* EnablePart4_1F */ |
| 6486 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6487 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6488 | if (!(pVBInfo->SetFlag & DisableChA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6489 | if (!(pVBInfo->SetFlag & GatingCRT)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6490 | XGI_DisableGatingCRT(HwDeviceExtension, |
| 6491 | pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6492 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, |
| 6493 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6494 | } |
| 6495 | } |
| 6496 | } /* 301 */ |
| 6497 | else { /* LVDS */ |
| 6498 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6499 | | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6500 | /* enable CRT2 */ |
| 6501 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6502 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6503 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6504 | 0x2E); |
| 6505 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6506 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6507 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6508 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6509 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6510 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6511 | } |
| 6512 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6513 | static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, |
| 6514 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6515 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 6516 | struct vb_device_info *pVBInfo) |
| 6517 | { |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 6518 | unsigned short RefreshRateTableIndex, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6519 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 6520 | XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | fb60d0c | 2012-04-07 01:14:04 +0300 | [diff] [blame] | 6521 | outb(pVBInfo->StandTable->MISC, pVBInfo->P3c2); |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 6522 | XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo); |
| 6523 | XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo); |
| 6524 | XGI_SetGRCRegs(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6525 | XGI_ClearExt1Regs(pVBInfo); |
| 6526 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6527 | if (HwDeviceExtension->jChipType == XG27) { |
| 6528 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 6529 | XGI_SetDefaultVCLK(pVBInfo); |
| 6530 | } |
| 6531 | |
| 6532 | temp = ~ProgrammingCRT2; |
| 6533 | pVBInfo->SetFlag &= temp; |
| 6534 | pVBInfo->SelectCRT2Rate = 0; |
| 6535 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6536 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6537 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6538 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6539 | | SetInSlaveMode)) { |
| 6540 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 6541 | } |
| 6542 | } |
| 6543 | |
| 6544 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 6545 | ModeIdIndex, pVBInfo); |
| 6546 | if (RefreshRateTableIndex != 0xFFFF) { |
| 6547 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
| 6548 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 6549 | pVBInfo, HwDeviceExtension); |
| 6550 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 6551 | RefreshRateTableIndex, pVBInfo); |
| 6552 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 6553 | HwDeviceExtension, pVBInfo); |
| 6554 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 6555 | RefreshRateTableIndex, pVBInfo); |
| 6556 | } |
| 6557 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6558 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6559 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6560 | if (temp & 0xA0) { |
| 6561 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6562 | if (HwDeviceExtension->jChipType == XG27) |
| 6563 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, |
| 6564 | RefreshRateTableIndex, pVBInfo); |
| 6565 | else |
| 6566 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, |
| 6567 | RefreshRateTableIndex, pVBInfo); |
| 6568 | |
| 6569 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 6570 | RefreshRateTableIndex); |
| 6571 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 6572 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
| 6573 | pVBInfo, RefreshRateTableIndex, ModeNo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6574 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 6575 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6576 | xgifb_set_lvds(xgifb_info, |
| 6577 | HwDeviceExtension->jChipType, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 6578 | ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6579 | } |
| 6580 | } |
| 6581 | |
| 6582 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
| 6583 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); |
| 6584 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 6585 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6586 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6587 | } |
| 6588 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6589 | unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, |
| 6590 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6591 | unsigned short ModeNo) |
| 6592 | { |
| 6593 | unsigned short ModeIdIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6594 | struct vb_device_info VBINF; |
| 6595 | struct vb_device_info *pVBInfo = &VBINF; |
Dmitry Eremin-Solenikov | 9a801f2 | 2012-03-19 21:50:13 +0400 | [diff] [blame] | 6596 | pVBInfo->BaseAddr = xgifb_info->vga_base; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6597 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6598 | pVBInfo->IF_DEF_LCDA = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6599 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6600 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6601 | pVBInfo->IF_DEF_YPbPr = 0; |
| 6602 | pVBInfo->IF_DEF_HiVision = 0; |
| 6603 | pVBInfo->IF_DEF_CRT2Monitor = 0; |
| 6604 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6605 | } else { |
| 6606 | pVBInfo->IF_DEF_YPbPr = 1; |
| 6607 | pVBInfo->IF_DEF_HiVision = 1; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 6608 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6609 | } |
| 6610 | |
| 6611 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; |
| 6612 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; |
| 6613 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; |
| 6614 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; |
| 6615 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; |
| 6616 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; |
| 6617 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; |
| 6618 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; |
| 6619 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; |
| 6620 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; |
| 6621 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; |
| 6622 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; |
| 6623 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6624 | pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04; |
| 6625 | pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10; |
| 6626 | pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12; |
| 6627 | pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14; |
| 6628 | pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6629 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6630 | /* for x86 Linux, XG21 LVDS */ |
| 6631 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6632 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6633 | pVBInfo->IF_DEF_LVDS = 1; |
| 6634 | } |
| 6635 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6636 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 6637 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6638 | pVBInfo->IF_DEF_LVDS = 1; |
| 6639 | } |
| 6640 | } |
| 6641 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6642 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6643 | XGI_GetVBType(pVBInfo); |
| 6644 | |
| 6645 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
Aaro Koskinen | ef497f4 | 2011-11-27 23:03:21 +0200 | [diff] [blame] | 6646 | if (ModeNo & 0x80) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6647 | ModeNo = ModeNo & 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6648 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6649 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6650 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6651 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
| 6652 | |
| 6653 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 6654 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6655 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6656 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 6657 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6658 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6659 | XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6660 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6661 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6662 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6663 | ModeIdIndex, pVBInfo); |
| 6664 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6665 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6666 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 6667 | HwDeviceExtension, pVBInfo); |
| 6668 | } |
| 6669 | } else { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6670 | if (!(pVBInfo->VBInfo & SwitchCRT2)) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6671 | XGI_SetCRT1Group(xgifb_info, |
| 6672 | HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6673 | ModeIdIndex, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6674 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6675 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 6676 | HwDeviceExtension, |
| 6677 | pVBInfo); |
| 6678 | } |
| 6679 | } |
| 6680 | } |
| 6681 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6682 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6683 | switch (HwDeviceExtension->ujVBChipID) { |
| 6684 | case VB_CHIP_301: |
| 6685 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 6686 | pVBInfo); /*add for CRT2 */ |
| 6687 | break; |
| 6688 | |
| 6689 | case VB_CHIP_302: |
| 6690 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 6691 | pVBInfo); /*add for CRT2 */ |
| 6692 | break; |
| 6693 | |
| 6694 | default: |
| 6695 | break; |
| 6696 | } |
| 6697 | } |
| 6698 | |
| 6699 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
| 6700 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6701 | XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6702 | } /* !XG20 */ |
| 6703 | else { |
| 6704 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6705 | if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6706 | ModeIdIndex, |
| 6707 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6708 | return 0; |
| 6709 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 6710 | pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex]. |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6711 | Ext_ModeFlag & ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6712 | |
| 6713 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 6714 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6715 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6716 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6717 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6718 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
| 6719 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6720 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6721 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6722 | } |
| 6723 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6724 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
| 6725 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6726 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6727 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
| 6728 | } |
| 6729 | |
| 6730 | return 1; |
| 6731 | } |