apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2 | #include <linux/io.h> |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 3 | #include <linux/delay.h> |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4 | #include <linux/types.h> |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5 | #include "XGIfb.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7 | |
| 8 | #include "vb_def.h" |
| 9 | #include "vgatypes.h" |
| 10 | #include "vb_struct.h" |
| 11 | #include "vb_util.h" |
| 12 | #include "vb_table.h" |
Aaro Koskinen | 5e60b97 | 2011-03-08 22:16:14 +0200 | [diff] [blame] | 13 | #include "vb_setmode.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 14 | |
| 15 | |
| 16 | #define IndexMask 0xff |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 17 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 18 | static unsigned short XGINew_MDA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 20 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, |
| 21 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, |
| 22 | 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 24 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, |
| 25 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, |
| 26 | 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 27 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 28 | static unsigned short XGINew_CGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 29 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 30 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 31 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 32 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 33 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 34 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 35 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 36 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 37 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 38 | static unsigned short XGINew_EGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 39 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15, |
| 40 | 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35, |
| 41 | 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D, |
| 42 | 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D, |
| 43 | 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17, |
| 44 | 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37, |
| 45 | 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F, |
| 46 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 47 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 48 | static unsigned short XGINew_VGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 49 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 50 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 51 | 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18, |
| 52 | 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F, |
| 53 | 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F, |
| 54 | 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00, |
| 55 | 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18, |
| 56 | 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04, |
| 57 | 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10, |
| 58 | 0x0B, 0x0C, 0x0D, 0x0F, 0x10}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 59 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 60 | void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 61 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 62 | pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable; |
| 63 | pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable; |
| 64 | pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable; |
| 65 | pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex; |
| 66 | pVBInfo->XGINEWUB_CRT1Table |
| 67 | = (struct XGI_CRT1TableStruct *) XGI_CRT1Table; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 68 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 69 | /* add for new UNIVGABIOS */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 70 | /* XGINew_UBLCDDataTable = |
| 71 | * (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 72 | /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 73 | |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 74 | pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData; |
| 75 | pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 76 | pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData; |
| 77 | pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData; |
| 78 | pVBInfo->ScreenOffset = XGI330_ScreenOffset; |
| 79 | pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo; |
| 80 | pVBInfo->ModeResInfo |
| 81 | = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 82 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 83 | pVBInfo->pOutputSelect = &XGI330_OutputSelect; |
| 84 | pVBInfo->pSoftSetting = &XGI330_SoftSetting; |
| 85 | pVBInfo->pSR07 = &XGI330_SR07; |
| 86 | pVBInfo->LCDResInfo = 0; |
| 87 | pVBInfo->LCDTypeInfo = 0; |
| 88 | pVBInfo->LCDInfo = 0; |
| 89 | pVBInfo->VBInfo = 0; |
| 90 | pVBInfo->TVInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 91 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 92 | pVBInfo->SR15 = XGI340_SR13; |
| 93 | pVBInfo->CR40 = XGI340_cr41; |
| 94 | pVBInfo->SR25 = XGI330_sr25; |
| 95 | pVBInfo->pSR31 = &XGI330_sr31; |
| 96 | pVBInfo->pSR32 = &XGI330_sr32; |
| 97 | pVBInfo->CR6B = XGI340_CR6B; |
| 98 | pVBInfo->CR6E = XGI340_CR6E; |
| 99 | pVBInfo->CR6F = XGI340_CR6F; |
| 100 | pVBInfo->CR89 = XGI340_CR89; |
| 101 | pVBInfo->AGPReg = XGI340_AGPReg; |
| 102 | pVBInfo->SR16 = XGI340_SR16; |
| 103 | pVBInfo->pCRCF = &XG40_CRCF; |
| 104 | pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 105 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 106 | pVBInfo->CR49 = XGI330_CR49; |
| 107 | pVBInfo->pSR1F = &XGI330_SR1F; |
| 108 | pVBInfo->pSR21 = &XGI330_SR21; |
| 109 | pVBInfo->pSR22 = &XGI330_SR22; |
| 110 | pVBInfo->pSR23 = &XGI330_SR23; |
| 111 | pVBInfo->pSR24 = &XGI330_SR24; |
| 112 | pVBInfo->pSR33 = &XGI330_SR33; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 113 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 114 | pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2; |
| 115 | pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D; |
| 116 | pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E; |
| 117 | pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10; |
| 118 | pVBInfo->pRGBSenseData = &XGI330_RGBSenseData; |
| 119 | pVBInfo->pVideoSenseData = &XGI330_VideoSenseData; |
| 120 | pVBInfo->pYCSenseData = &XGI330_YCSenseData; |
| 121 | pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2; |
| 122 | pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2; |
| 123 | pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 124 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 125 | pVBInfo->NTSCTiming = XGI330_NTSCTiming; |
| 126 | pVBInfo->PALTiming = XGI330_PALTiming; |
| 127 | pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming; |
| 128 | pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing; |
| 129 | pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing; |
| 130 | pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming; |
| 131 | pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming; |
| 132 | pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming; |
| 133 | pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming; |
| 134 | pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data; |
| 135 | pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu; |
| 136 | pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text; |
| 137 | pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3; |
| 138 | pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 139 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 140 | pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH; |
| 141 | pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV; |
| 142 | pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 143 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 144 | /* 310 customization related */ |
| 145 | if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV)) |
| 146 | pVBInfo->LCDCapList = XGI_LCDDLCapList; |
| 147 | else |
| 148 | pVBInfo->LCDCapList = XGI_LCDCapList; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 149 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 150 | if ((ChipType == XG21) || (ChipType == XG27)) |
| 151 | pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 152 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 153 | pVBInfo->XGI_TVDelayList = XGI301TVDelayList; |
| 154 | pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 155 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 156 | pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 157 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 158 | if (ChipType >= XG20) |
| 159 | pVBInfo->pXGINew_CR97 = &XG20_CR97; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 160 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 161 | if (ChipType == XG27) { |
| 162 | pVBInfo->MCLKData |
| 163 | = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData; |
| 164 | pVBInfo->CR40 = XGI27_cr41; |
| 165 | pVBInfo->pXGINew_CR97 = &XG27_CR97; |
| 166 | pVBInfo->pSR36 = &XG27_SR36; |
| 167 | pVBInfo->pCR8F = &XG27_CR8F; |
| 168 | pVBInfo->pCRD0 = XG27_CRD0; |
| 169 | pVBInfo->pCRDE = XG27_CRDE; |
| 170 | pVBInfo->pSR40 = &XG27_SR40; |
| 171 | pVBInfo->pSR41 = &XG27_SR41; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 172 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 173 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 174 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 175 | if (ChipType >= XG20) { |
| 176 | pVBInfo->pDVOSetting = &XG21_DVOSetting; |
| 177 | pVBInfo->pCR2E = &XG21_CR2E; |
| 178 | pVBInfo->pCR2F = &XG21_CR2F; |
| 179 | pVBInfo->pCR46 = &XG21_CR46; |
| 180 | pVBInfo->pCR47 = &XG21_CR47; |
| 181 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 182 | |
| 183 | } |
| 184 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 185 | static unsigned char XGI_GetModePtr(unsigned short ModeNo, |
| 186 | unsigned short ModeIdIndex, |
| 187 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 188 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 189 | unsigned char index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 190 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 191 | if (ModeNo <= 0x13) |
| 192 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex; |
| 193 | else { |
| 194 | if (pVBInfo->ModeType <= 0x02) |
| 195 | index = 0x1B; /* 02 -> ModeEGA */ |
| 196 | else |
| 197 | index = 0x0F; |
| 198 | } |
| 199 | return index; /* Get pVBInfo->StandTable index */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 200 | } |
| 201 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 202 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 203 | unsigned char XGI_SetBIOSData(unsigned short ModeNo, |
| 204 | unsigned short ModeIdIndex) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 205 | return (0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 206 | } |
| 207 | */ |
| 208 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 209 | /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, |
| 210 | unsigned short ModeIdIndex) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 211 | return( 0 ) ; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 212 | } |
| 213 | */ |
| 214 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 215 | static void XGI_SetSeqRegs(unsigned short ModeNo, |
| 216 | unsigned short StandTableIndex, |
| 217 | unsigned short ModeIdIndex, |
| 218 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 219 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 220 | unsigned char tempah, SRdata; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 221 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 222 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 223 | if (ModeNo <= 0x13) |
| 224 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 225 | else |
| 226 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 227 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 228 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 229 | tempah = pVBInfo->StandTable[StandTableIndex].SR[0]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 230 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 231 | i = SetCRT2ToLCDA; |
| 232 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 233 | tempah |= 0x01; |
| 234 | } else { |
| 235 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { |
| 236 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 237 | tempah |= 0x01; |
| 238 | } |
| 239 | } |
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 | tempah |= 0x20; /* screen off */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 242 | xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 243 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 244 | for (i = 02; i <= 04; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 245 | /* Get SR2,3,4 from file */ |
| 246 | SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 247 | xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 248 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 249 | } |
| 250 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 251 | static void XGI_SetMiscRegs(unsigned short StandTableIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 252 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 253 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 254 | unsigned char Miscdata; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 255 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 256 | /* Get Misc from file */ |
| 257 | Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 258 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 259 | if (pVBInfo->VBType & (VB_XGI301B | |
| 260 | VB_XGI302B | |
| 261 | VB_XGI301LV | |
| 262 | VB_XGI302LV | |
| 263 | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 264 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 265 | Miscdata |= 0x0C; |
| 266 | } |
| 267 | } |
| 268 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 269 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 270 | outb(Miscdata, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 271 | } |
| 272 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 273 | static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 274 | unsigned short StandTableIndex, |
| 275 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 276 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 277 | unsigned char CRTCdata; |
| 278 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 279 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 280 | CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 281 | CRTCdata &= 0x7f; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 282 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 283 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 284 | for (i = 0; i <= 0x18; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 285 | /* Get CRTC from file */ |
| 286 | CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 287 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 288 | } |
| 289 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 290 | if ((HwDeviceExtension->jChipType == XGI_630) && |
| 291 | (HwDeviceExtension->jChipRevision == 0x30)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 292 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 293 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 294 | xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | } |
| 298 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 299 | } |
| 300 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 301 | static void XGI_SetATTRegs(unsigned short ModeNo, |
| 302 | unsigned short StandTableIndex, |
| 303 | unsigned short ModeIdIndex, |
| 304 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 305 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 306 | unsigned char ARdata; |
| 307 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 308 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 309 | if (ModeNo <= 0x13) |
| 310 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 311 | else |
| 312 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 313 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 314 | for (i = 0; i <= 0x13; i++) { |
| 315 | ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i]; |
| 316 | if (modeflag & Charx8Dot) { /* ifndef Dot9 */ |
| 317 | if (i == 0x13) { |
| 318 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 319 | ARdata = 0; |
| 320 | } else { |
| 321 | if (pVBInfo->VBInfo & (SetCRT2ToTV |
| 322 | | SetCRT2ToLCD)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 323 | if (pVBInfo->VBInfo & |
| 324 | SetInSlaveMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 325 | ARdata = 0; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 330 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 331 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 332 | outb(i, pVBInfo->P3c0); /* set index */ |
| 333 | outb(ARdata, pVBInfo->P3c0); /* set data */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 334 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 335 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 336 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 337 | outb(0x14, pVBInfo->P3c0); /* set index */ |
| 338 | outb(0x00, pVBInfo->P3c0); /* set data */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 339 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 340 | outb(0x20, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 341 | } |
| 342 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 343 | static void XGI_SetGRCRegs(unsigned short StandTableIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 344 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 345 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 346 | unsigned char GRdata; |
| 347 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 348 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 349 | for (i = 0; i <= 0x08; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 350 | /* Get GR from file */ |
| 351 | GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 352 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 353 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 354 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 355 | if (pVBInfo->ModeType > ModeVGA) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 356 | GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 357 | GRdata &= 0xBF; /* 256 color disable */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 358 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 359 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 360 | } |
| 361 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 362 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 363 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 364 | unsigned short i; |
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 | for (i = 0x0A; i <= 0x0E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 367 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 368 | } |
| 369 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 370 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 371 | { |
| 372 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 373 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 374 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B); |
| 375 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 376 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 377 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 378 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B); |
| 379 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 380 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 381 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 382 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 383 | } |
| 384 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 385 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 386 | unsigned short ModeIdIndex, |
| 387 | unsigned short RefreshRateTableIndex, unsigned short *i, |
| 388 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 389 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 390 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 391 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 392 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 393 | /* si+St_ModeFlag */ |
| 394 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 395 | else |
| 396 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 397 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 398 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 399 | tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID; |
| 400 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 401 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 402 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 403 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 404 | tempax |= SupportRAMDAC2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 405 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 406 | if (pVBInfo->VBType & VB_XGI301C) |
| 407 | tempax |= SupportCRT2in301C; |
| 408 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 409 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 410 | /* 301b */ |
| 411 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 412 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 413 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 414 | if (pVBInfo->LCDResInfo != Panel1280x1024) { |
| 415 | if (pVBInfo->LCDResInfo != Panel1280x960) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 416 | if (pVBInfo->LCDInfo & |
| 417 | LCDNonExpanding) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 418 | if (resinfo >= 9) { |
| 419 | tempax = 0; |
| 420 | return 0; |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | } |
| 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 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 428 | if ((pVBInfo->VBType & VB_XGI301LV) && |
| 429 | (pVBInfo->VBExtInfo == VB_YPbPr1080i)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 430 | tempax |= SupportYPbPr; |
| 431 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 432 | if (resinfo == 4) |
| 433 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 434 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 435 | if (resinfo == 3) |
| 436 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 437 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 438 | if (resinfo > 7) |
| 439 | return 0; |
| 440 | } |
| 441 | } else { |
| 442 | tempax |= SupportHiVisionTV; |
| 443 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 444 | if (resinfo == 4) |
| 445 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 446 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 447 | if (resinfo == 3) { |
| 448 | if (pVBInfo->SetFlag |
| 449 | & TVSimuMode) |
| 450 | return 0; |
| 451 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 452 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 453 | if (resinfo > 7) |
| 454 | return 0; |
| 455 | } |
| 456 | } |
| 457 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 458 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
| 459 | SetCRT2ToSVIDEO | |
| 460 | SetCRT2ToSCART | |
| 461 | SetCRT2ToYPbPr | |
| 462 | SetCRT2ToHiVisionTV)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 463 | tempax |= SupportTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 464 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 465 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 466 | | VB_XGI301LV | VB_XGI302LV |
| 467 | | VB_XGI301C)) { |
| 468 | tempax |= SupportTV1024; |
| 469 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 470 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 471 | if (!(pVBInfo->VBInfo & SetPALTV)) { |
| 472 | if (modeflag & NoSupportSimuTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 473 | if (pVBInfo->VBInfo & |
| 474 | SetInSlaveMode) { |
| 475 | if (!(pVBInfo->VBInfo & |
| 476 | SetNotSimuMode)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 477 | return 0; |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | } else { /* for LVDS */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 485 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 486 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 487 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 488 | if (resinfo > 0x08) |
| 489 | return 0; /* 1024x768 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 490 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 491 | if (pVBInfo->LCDResInfo < Panel1024x768) { |
| 492 | if (resinfo > 0x07) |
| 493 | return 0; /* 800x600 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 494 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 495 | if (resinfo == 0x04) |
| 496 | return 0; /* 512x384 */ |
| 497 | } |
| 498 | } |
| 499 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 500 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 501 | for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
| 502 | tempbx; (*i)--) { |
| 503 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
| 504 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 505 | if (infoflag & tempax) |
| 506 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 507 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 508 | if ((*i) == 0) |
| 509 | break; |
| 510 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 511 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 512 | for ((*i) = 0;; (*i)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 513 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
| 514 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 515 | if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID |
| 516 | != tempbx) { |
| 517 | return 0; |
| 518 | } |
| 519 | |
| 520 | if (infoflag & tempax) |
| 521 | return 1; |
| 522 | } |
| 523 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 524 | } |
| 525 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 526 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 527 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 528 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 529 | unsigned short sync, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 530 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 531 | /* di+0x00 */ |
| 532 | sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 533 | sync &= 0xC0; |
| 534 | temp = 0x2F; |
| 535 | temp |= sync; |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 536 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 537 | } |
| 538 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 539 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 540 | struct xgi_hw_device_info *HwDeviceExtension) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 541 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 542 | unsigned char data, data1, pushax; |
| 543 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 544 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 545 | /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */ |
| 546 | /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 547 | /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 548 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 549 | /* unlock cr0-7 */ |
| 550 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 551 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 552 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 553 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 554 | data = pVBInfo->TimingH[0].data[0]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 555 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 556 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 557 | for (i = 0x01; i <= 0x04; i++) { |
| 558 | data = pVBInfo->TimingH[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 559 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 560 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 561 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 562 | for (i = 0x05; i <= 0x06; i++) { |
| 563 | data = pVBInfo->TimingH[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 564 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 565 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 566 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 567 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 568 | j &= 0x1F; |
| 569 | data = pVBInfo->TimingH[0].data[7]; |
| 570 | data &= 0xE0; |
| 571 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 572 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 573 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 574 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 575 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 576 | data = data - 1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 577 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 578 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 579 | data1 = data; |
| 580 | data1 &= 0xE0; |
| 581 | data &= 0x1F; |
| 582 | if (data == 0) { |
| 583 | pushax = data; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 584 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 585 | 0x0c); |
| 586 | data &= 0xFB; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 587 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 588 | data = pushax; |
| 589 | } |
| 590 | data = data - 1; |
| 591 | data |= data1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 592 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 593 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 594 | data = data >> 5; |
| 595 | data = data + 3; |
| 596 | if (data > 7) |
| 597 | data = data - 7; |
| 598 | data = data << 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 599 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 600 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 601 | } |
| 602 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 603 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
| 604 | unsigned short ModeNo, |
| 605 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 606 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 607 | unsigned char data; |
| 608 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 609 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 610 | /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */ |
| 611 | /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 612 | /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 613 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 614 | for (i = 0x00; i <= 0x01; i++) { |
| 615 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 616 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 617 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 618 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 619 | for (i = 0x02; i <= 0x03; i++) { |
| 620 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 621 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 622 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 623 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 624 | for (i = 0x04; i <= 0x05; i++) { |
| 625 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 626 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 627 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 628 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 629 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 630 | j &= 0xC0; |
| 631 | data = pVBInfo->TimingV[0].data[6]; |
| 632 | data &= 0x3F; |
| 633 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 634 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 635 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 636 | data = pVBInfo->TimingV[0].data[6]; |
| 637 | data &= 0x80; |
| 638 | data = data >> 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 639 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 640 | if (ModeNo <= 0x13) |
| 641 | i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 642 | else |
| 643 | i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 644 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 645 | i &= DoubleScanMode; |
| 646 | if (i) |
| 647 | data |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 648 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 649 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 650 | j &= 0x5F; |
| 651 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 652 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 653 | } |
| 654 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 655 | static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 656 | unsigned short RefreshRateTableIndex, |
| 657 | struct vb_device_info *pVBInfo, |
| 658 | struct xgi_hw_device_info *HwDeviceExtension) |
| 659 | { |
| 660 | unsigned char index, data; |
| 661 | unsigned short i; |
| 662 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 663 | /* Get index */ |
| 664 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 665 | index = index & IndexMask; |
| 666 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 667 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 668 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 669 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 670 | |
| 671 | for (i = 0; i < 8; i++) |
| 672 | pVBInfo->TimingH[0].data[i] |
| 673 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i]; |
| 674 | |
| 675 | for (i = 0; i < 7; i++) |
| 676 | pVBInfo->TimingV[0].data[i] |
| 677 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8]; |
| 678 | |
| 679 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 680 | |
| 681 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
| 682 | |
| 683 | if (pVBInfo->ModeType > 0x03) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 684 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 685 | } |
| 686 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 687 | /* --------------------------------------------------------------------- */ |
| 688 | /* Function : XGI_SetXG21CRTC */ |
| 689 | /* Input : Stand or enhance CRTC table */ |
| 690 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ |
| 691 | /* Description : Set LCD timing */ |
| 692 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 693 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 694 | unsigned short RefreshRateTableIndex, |
| 695 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 696 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 697 | unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
| 698 | unsigned short Temp1, Temp2, Temp3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 699 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 700 | if (ModeNo <= 0x13) { |
| 701 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 702 | /* CR04 HRS */ |
| 703 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; |
| 704 | /* SR2E [7:0]->HRS */ |
| 705 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
| 706 | /* Tempbx: CR05 HRE */ |
| 707 | Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 708 | Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */ |
| 709 | Tempcx = Tempax; |
| 710 | Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */ |
| 711 | Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */ |
| 712 | if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */ |
| 713 | Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */ |
| 714 | Tempdx <<= 2; /* Tempdx << 2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 715 | /* SR2F [7:2]->HRE */ |
| 716 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 717 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 718 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 719 | /* Tempax: CR16 VRS */ |
| 720 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 721 | Tempbx = Tempax; /* Tempbx=Tempax */ |
| 722 | Tempax &= 0x01; /* Tempax: VRS[0] */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 723 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 724 | |
| 725 | /* Tempax: CR7 VRS */ |
| 726 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 727 | Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */ |
| 728 | Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */ |
| 729 | Tempcx <<= 5; /* Tempcx[7]: VRS[8] */ |
| 730 | Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 731 | /* SR34[7:0]: VRS[8:1] */ |
| 732 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 733 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 734 | /* Temp1[8]: VRS[8] unsigned char -> unsigned short */ |
| 735 | Temp1 = Tempcx << 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 736 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 737 | Tempax &= 0x80; /* Tempax[7]: CR7[7] */ |
| 738 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 739 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 740 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 741 | /* CR16 VRE */ |
| 742 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 743 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 744 | Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */ |
| 745 | Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */ |
| 746 | Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */ |
| 747 | if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */ |
| 748 | Temp2 |= 0x10; /* Temp2: VRE + 0x10 */ |
| 749 | Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */ |
| 750 | Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */ |
| 751 | Tempax <<= 2; /* Tempax << 2: VRE[5:0] */ |
| 752 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 753 | Temp1 >>= 9; /* [10:9]->[1:0] */ |
| 754 | Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */ |
| 755 | Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */ |
| 756 | Tempax &= 0x7F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 757 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 758 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 759 | } else { |
| 760 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 761 | /* Tempax: CR4 HRS */ |
| 762 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 763 | Tempcx = Tempax; /* Tempcx: HRS */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 764 | /* SR2E[7:0]->HRS */ |
| 765 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 766 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 767 | Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */ |
| 768 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ |
| 769 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ |
| 770 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ |
| 771 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 772 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 773 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
| 774 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 775 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 776 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
| 777 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ |
| 778 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ |
| 779 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 780 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 781 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
| 782 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 783 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 784 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
| 785 | if (Tempax < Tempcx) /* HRE < HRS */ |
| 786 | Temp2 |= 0x40; /* Temp2 + 0x40 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 787 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 788 | Temp2 &= 0xFF; |
| 789 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ |
| 790 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ |
| 791 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ |
| 792 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 793 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
| 794 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 795 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 796 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 797 | /* CR10 VRS */ |
| 798 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 799 | Tempbx = Tempax; /* Tempbx: VRS */ |
| 800 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 801 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 802 | /* CR7[2][7] VRE */ |
| 803 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 804 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
| 805 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ |
| 806 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ |
| 807 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 808 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 809 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 810 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
| 811 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ |
| 812 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 813 | Tempax &= 0x80; |
| 814 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 815 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 816 | /* Tempax: SRA */ |
| 817 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 818 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
| 819 | Temp2 = Tempax; |
| 820 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ |
| 821 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 822 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 823 | /* Tempax: CR11 VRE */ |
| 824 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 825 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 826 | /* Tempbx: SRA */ |
| 827 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 828 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
| 829 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 830 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 831 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ |
| 832 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 833 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 834 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
| 835 | if (Tempax < Temp3) /* VRE < VRS */ |
| 836 | Temp2 |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 837 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 838 | Temp2 &= 0xFF; |
| 839 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ |
| 840 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ |
| 841 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 842 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ |
| 843 | Tempbx = (unsigned char) Temp1; |
| 844 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ |
| 845 | Tempax &= 0x7F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 846 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 847 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 848 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 849 | } |
| 850 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 851 | static void XGI_SetXG27CRTC(unsigned short ModeNo, |
| 852 | unsigned short ModeIdIndex, |
| 853 | unsigned short RefreshRateTableIndex, |
| 854 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 855 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 856 | unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 857 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 858 | if (ModeNo <= 0x13) { |
| 859 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 860 | /* CR04 HRS */ |
| 861 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; |
| 862 | /* SR2E [7:0]->HRS */ |
| 863 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
| 864 | /* Tempbx: CR05 HRE */ |
| 865 | Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 866 | Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */ |
| 867 | Tempcx = Tempax; |
| 868 | Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */ |
| 869 | Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */ |
| 870 | if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */ |
| 871 | Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */ |
| 872 | Tempdx <<= 2; /* Tempdx << 2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 873 | /* SR2F [7:2]->HRE */ |
| 874 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 875 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 876 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 877 | /* Tempax: CR10 VRS */ |
| 878 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 879 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 880 | Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 881 | /* Tempax[7][2]: CR7[7][2] VRS[9][8] */ |
| 882 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 883 | Tempbx = Tempax; /* Tempbx=CR07 */ |
| 884 | Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */ |
| 885 | Tempax >>= 2; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 886 | /* SR35 D[0]->VRS D[8] */ |
| 887 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 888 | Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */ |
| 889 | Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 890 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 891 | /* CR11 VRE */ |
| 892 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 893 | Tempax &= 0x0F; /* Tempax: VRE[3:0] */ |
| 894 | Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */ |
| 895 | Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */ |
| 896 | Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */ |
| 897 | if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */ |
| 898 | Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 899 | /* Tempax[7:0]: VRE[7:0] */ |
| 900 | Tempax = (unsigned char) Tempbx & 0xFF; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 901 | Tempax <<= 2; /* Tempax << 2: VRE[5:0] */ |
| 902 | Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 903 | /* SR3F D[7:2]->VRE D[5:0] */ |
| 904 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
| 905 | /* SR35 D[2:1]->VRS[10:9] */ |
| 906 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 907 | } else { |
| 908 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 909 | /* Tempax: CR4 HRS */ |
| 910 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 911 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 912 | /* SR2E[7:0]->HRS */ |
| 913 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 914 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 915 | /* SR0B */ |
| 916 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 917 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 918 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 919 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 920 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
| 921 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
| 922 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 923 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 924 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
| 925 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ |
| 926 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ |
| 927 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 928 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 929 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
| 930 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 931 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 932 | /* Tempax: CR4 HRS */ |
| 933 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 934 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
| 935 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ |
| 936 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 937 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 938 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */ |
| 939 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 940 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ |
| 941 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 942 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
| 943 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 944 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 945 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 946 | /* CR10 VRS */ |
| 947 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; |
| 948 | /* SR34[7:0]->VRS[7:0] */ |
| 949 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 950 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 951 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 952 | /* CR7[7][2] VRS[9][8] */ |
| 953 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 954 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
| 955 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ |
| 956 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 957 | /* SR35[0]: VRS[8] */ |
| 958 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 959 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
| 960 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 961 | /* Tempax: SR0A */ |
| 962 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 963 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
| 964 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 965 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 966 | /* Tempax: CR11 VRE */ |
| 967 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 968 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 969 | /* Tempbx: SR0A */ |
| 970 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 971 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
| 972 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 973 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 974 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ |
| 975 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ |
| 976 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 977 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 978 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
| 979 | Tempbx |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 980 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 981 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
| 982 | Tempax = (Tempbx << 2) & 0xFF; |
| 983 | /* SR3F[7:2]:VRE[5:0] */ |
| 984 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 985 | Tempax = Tempcx >> 8; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 986 | /* SR35[2:0]:VRS[10:8] */ |
| 987 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 988 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 989 | } |
| 990 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame^] | 991 | static void xgifb_set_lcd(int chip_id, |
| 992 | struct vb_device_info *pVBInfo, |
| 993 | unsigned short RefreshRateTableIndex, |
| 994 | unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 995 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 996 | unsigned short Data, Temp, b3CC; |
| 997 | unsigned short XGI_P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 998 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 999 | XGI_P3cc = pVBInfo->P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1000 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1001 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 1002 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 1003 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 1004 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame^] | 1005 | |
| 1006 | if (chip_id == XG27) { |
| 1007 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 1008 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
| 1009 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 1010 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
| 1011 | } |
| 1012 | } |
| 1013 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1014 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1015 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); |
| 1016 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); |
| 1017 | xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); |
| 1018 | xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1019 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1020 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame^] | 1021 | if (chip_id == XG27) { |
| 1022 | XGI_SetXG27FPBits(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1023 | } else { |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame^] | 1024 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 1025 | if (Temp & 0x01) { |
| 1026 | /* 18 bits FP */ |
| 1027 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); |
| 1028 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
| 1029 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1030 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1031 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1032 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1033 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 1034 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 1035 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1036 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1037 | if (ModeNo <= 0x13) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1038 | b3CC = (unsigned char) inb(XGI_P3cc); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1039 | if (b3CC & 0x40) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1040 | /* Hsync polarity */ |
| 1041 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1042 | if (b3CC & 0x80) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1043 | /* Vsync polarity */ |
| 1044 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1045 | } else { |
| 1046 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1047 | if (Data & 0x4000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1048 | /* Hsync polarity */ |
| 1049 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1050 | if (Data & 0x8000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1051 | /* Vsync polarity */ |
| 1052 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1053 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | /* --------------------------------------------------------------------- */ |
| 1057 | /* Function : XGI_UpdateXG21CRTC */ |
| 1058 | /* Input : */ |
| 1059 | /* Output : CRT1 CRTC */ |
| 1060 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 1061 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1062 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 1063 | struct vb_device_info *pVBInfo, |
| 1064 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1065 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1066 | int i, index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1067 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 1068 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1069 | if (ModeNo <= 0x13) { |
| 1070 | for (i = 0; i < 12; i++) { |
| 1071 | if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID) |
| 1072 | index = i; |
| 1073 | } |
| 1074 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1075 | if (ModeNo == 0x2E && |
| 1076 | (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
| 1077 | RES640x480x60)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1078 | index = 12; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1079 | else if (ModeNo == 0x2E && |
| 1080 | (pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1081 | Ext_CRT1CRTC == RES640x480x72)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1082 | index = 13; |
| 1083 | else if (ModeNo == 0x2F) |
| 1084 | index = 14; |
| 1085 | else if (ModeNo == 0x50) |
| 1086 | index = 15; |
| 1087 | else if (ModeNo == 0x59) |
| 1088 | index = 16; |
| 1089 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1090 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1091 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1092 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1093 | pVBInfo->UpdateCRT1[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1094 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1095 | pVBInfo->UpdateCRT1[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1096 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1097 | pVBInfo->UpdateCRT1[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1098 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1099 | pVBInfo->UpdateCRT1[index].CR16); |
| 1100 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1101 | } |
| 1102 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1103 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1104 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1105 | unsigned short RefreshRateTableIndex, |
| 1106 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1107 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1108 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1109 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1110 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1111 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1112 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1113 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1114 | if (ModeNo <= 0x13) { |
| 1115 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1116 | tempax = pVBInfo->StResInfo[resindex].HTotal; |
| 1117 | tempbx = pVBInfo->StResInfo[resindex].VTotal; |
| 1118 | } else { |
| 1119 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1120 | tempax = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1121 | tempbx = pVBInfo->ModeResInfo[resindex].VTotal; |
| 1122 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1123 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1124 | if (modeflag & HalfDCLK) |
| 1125 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1126 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1127 | if (ModeNo > 0x13) { |
| 1128 | if (modeflag & HalfDCLK) |
| 1129 | tempax = tempax << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1130 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1131 | temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1132 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1133 | if (temp & InterlaceMode) |
| 1134 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1135 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1136 | if (modeflag & DoubleScanMode) |
| 1137 | tempbx = tempbx << 1; |
| 1138 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1139 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1140 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1141 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1142 | /* if (!(modeflag & Charx8Dot)) */ |
| 1143 | /* tempcx = 9; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1144 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1145 | tempax /= tempcx; |
| 1146 | tempax -= 1; |
| 1147 | tempbx -= 1; |
| 1148 | tempcx = tempax; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1149 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 1150 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1151 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1152 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 1153 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1154 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1155 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1156 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1157 | tempax = 0; |
| 1158 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1159 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1160 | if (tempbx & 0x01) |
| 1161 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1162 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1163 | if (tempbx & 0x02) |
| 1164 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1165 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1166 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1167 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1168 | data &= 0xFF; |
| 1169 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1170 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1171 | if (tempbx & 0x04) |
| 1172 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1173 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1174 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1175 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1176 | } |
| 1177 | |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1178 | unsigned short XGI_GetResInfo(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1179 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1180 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1181 | unsigned short resindex; |
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 (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1184 | /* si+St_ResInfo */ |
| 1185 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1186 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1187 | /* si+Ext_ResInfo */ |
| 1188 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1189 | return resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1190 | } |
| 1191 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1192 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 1193 | unsigned short ModeIdIndex, |
| 1194 | unsigned short RefreshRateTableIndex, |
| 1195 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1196 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1197 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1198 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1199 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1200 | /* GetOffset */ |
| 1201 | temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 1202 | temp = temp >> 8; |
| 1203 | temp = pVBInfo->ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1204 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1205 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1206 | temp2 &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1207 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1208 | if (temp2) |
| 1209 | temp = temp << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1210 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1211 | temp2 = pVBInfo->ModeType - ModeEGA; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1212 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1213 | switch (temp2) { |
| 1214 | case 0: |
| 1215 | temp2 = 1; |
| 1216 | break; |
| 1217 | case 1: |
| 1218 | temp2 = 2; |
| 1219 | break; |
| 1220 | case 2: |
| 1221 | temp2 = 4; |
| 1222 | break; |
| 1223 | case 3: |
| 1224 | temp2 = 4; |
| 1225 | break; |
| 1226 | case 4: |
| 1227 | temp2 = 6; |
| 1228 | break; |
| 1229 | case 5: |
| 1230 | temp2 = 8; |
| 1231 | break; |
| 1232 | default: |
| 1233 | break; |
| 1234 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1235 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1236 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 1237 | temp = temp * temp2 + temp2 / 2; |
| 1238 | else |
| 1239 | temp *= temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1240 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1241 | /* SetOffset */ |
| 1242 | DisplayUnit = temp; |
| 1243 | temp2 = temp; |
| 1244 | temp = temp >> 8; /* ah */ |
| 1245 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1246 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1247 | i &= 0xF0; |
| 1248 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1249 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1250 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1251 | temp = (unsigned char) temp2; |
| 1252 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1253 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1254 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1255 | /* SetDisplayUnit */ |
| 1256 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1257 | temp2 &= InterlaceMode; |
| 1258 | if (temp2) |
| 1259 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1260 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1261 | DisplayUnit = DisplayUnit << 5; |
| 1262 | ah = (DisplayUnit & 0xff00) >> 8; |
| 1263 | al = DisplayUnit & 0x00ff; |
| 1264 | if (al == 0) |
| 1265 | ah += 1; |
| 1266 | else |
| 1267 | ah += 2; |
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 (HwDeviceExtension->jChipType >= XG20) |
| 1270 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 1271 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1272 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1273 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1274 | } |
| 1275 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1276 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
| 1277 | unsigned short ModeIdIndex, |
| 1278 | unsigned short RefreshRateTableIndex, |
| 1279 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1280 | struct vb_device_info *pVBInfo) |
| 1281 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1282 | unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, |
| 1283 | VCLK65 + 2, |
| 1284 | VCLK65 + 2, |
| 1285 | VCLK65 + 2 }; |
| 1286 | unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, |
| 1287 | VCLK108_2 + 5, |
| 1288 | VCLK108_2 + 5, |
| 1289 | VCLK108_2 + 5 }; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1290 | unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 }; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1291 | unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, |
| 1292 | VCLK65 + 2, |
| 1293 | VCLK65 + 2, |
| 1294 | VCLK65 + 2 }; |
| 1295 | unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, |
| 1296 | VCLK65 + 2, |
| 1297 | VCLK65 + 2, |
| 1298 | VCLK65 + 2 }; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1299 | |
| 1300 | unsigned short CRT2Index, VCLKIndex; |
| 1301 | unsigned short modeflag, resinfo; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1302 | |
| 1303 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1304 | /* si+St_ResInfo */ |
| 1305 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1306 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 1307 | CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 1308 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1309 | /* si+Ext_ResInfo */ |
| 1310 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1311 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1312 | CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1313 | Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1314 | } |
| 1315 | |
| 1316 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 1317 | CRT2Index = CRT2Index >> 6; /* for LCD */ |
| 1318 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/ |
| 1319 | if (pVBInfo->LCDResInfo != Panel1024x768) |
| 1320 | VCLKIndex = LCDXlat2VCLK[CRT2Index]; |
| 1321 | else |
| 1322 | VCLKIndex = LCDXlat1VCLK[CRT2Index]; |
| 1323 | } else { /* for TV */ |
| 1324 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 1325 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 1326 | if (pVBInfo->SetFlag & RPLLDIV2XO) { |
| 1327 | VCLKIndex = HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1328 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1329 | } else { |
| 1330 | VCLKIndex = HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1331 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1332 | } |
| 1333 | |
| 1334 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 1335 | if (modeflag & Charx8Dot) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1336 | VCLKIndex = |
| 1337 | HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1338 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1339 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1340 | VCLKIndex = |
| 1341 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1342 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1343 | } |
| 1344 | } |
| 1345 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1346 | /* 301lv */ |
| 1347 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 1348 | if (!(pVBInfo->VBExtInfo == |
| 1349 | VB_YPbPr1080i)) { |
| 1350 | VCLKIndex = |
| 1351 | YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1352 | if (!(pVBInfo->VBExtInfo |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1353 | == |
| 1354 | VB_YPbPr750p)) { |
| 1355 | VCLKIndex = |
| 1356 | YPbPr525pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1357 | if (!(pVBInfo->VBExtInfo |
| 1358 | == VB_YPbPr525p)) { |
| 1359 | VCLKIndex |
| 1360 | = YPbPr525iVCLK_2; |
| 1361 | if (!(pVBInfo->SetFlag |
| 1362 | & RPLLDIV2XO)) |
| 1363 | VCLKIndex |
| 1364 | = YPbPr525iVCLK; |
| 1365 | } |
| 1366 | } |
| 1367 | } |
| 1368 | } |
| 1369 | } else { |
| 1370 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1371 | if (pVBInfo->SetFlag & |
| 1372 | RPLLDIV2XO) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1373 | VCLKIndex = TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1374 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1375 | } else { |
| 1376 | VCLKIndex = TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1377 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1378 | } |
| 1379 | } |
| 1380 | } |
| 1381 | } else { /* for CRT2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1382 | /* Port 3cch */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1383 | VCLKIndex = (unsigned char) inb( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1384 | (pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1385 | VCLKIndex = ((VCLKIndex >> 2) & 0x03); |
| 1386 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1387 | /* di+Ext_CRTVCLK */ |
| 1388 | VCLKIndex = |
| 1389 | pVBInfo->RefIndex[ |
| 1390 | RefreshRateTableIndex]. |
| 1391 | Ext_CRTVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1392 | VCLKIndex &= IndexMask; |
| 1393 | } |
| 1394 | } |
| 1395 | } |
| 1396 | } else { /* LVDS */ |
| 1397 | if (ModeNo <= 0x13) |
| 1398 | VCLKIndex = CRT2Index; |
| 1399 | else |
| 1400 | VCLKIndex = CRT2Index; |
| 1401 | |
Aaro Koskinen | 4c14bfd | 2011-08-31 21:45:57 +0300 | [diff] [blame] | 1402 | VCLKIndex = VCLKIndex >> 6; |
| 1403 | if ((pVBInfo->LCDResInfo == Panel800x600) || |
| 1404 | (pVBInfo->LCDResInfo == Panel320x480)) |
| 1405 | VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; |
| 1406 | else if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 1407 | (pVBInfo->LCDResInfo == Panel1024x768x75)) |
| 1408 | VCLKIndex = LVDSXlat2VCLK[VCLKIndex]; |
| 1409 | else |
| 1410 | VCLKIndex = LVDSXlat3VCLK[VCLKIndex]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1411 | } |
| 1412 | /* VCLKIndex = VCLKIndex&IndexMask; */ |
| 1413 | |
| 1414 | return VCLKIndex; |
| 1415 | } |
| 1416 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1417 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
| 1418 | unsigned short ModeIdIndex, |
| 1419 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1420 | unsigned short RefreshRateTableIndex, |
| 1421 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1422 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 1423 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1424 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1425 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1426 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 1427 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1428 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1429 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1430 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1431 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1432 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1433 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1434 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1435 | } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 1436 | | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo |
| 1437 | & SetCRT2ToLCDA)) { |
| 1438 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, |
| 1439 | RefreshRateTableIndex, HwDeviceExtension, |
| 1440 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1441 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1442 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1443 | data = pVBInfo->VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1444 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1445 | data = pVBInfo->VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1446 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 1447 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1448 | } else { |
| 1449 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1450 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1451 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1452 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1453 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1454 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1455 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1456 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1457 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1458 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1459 | if (HwDeviceExtension->jChipType >= XG20) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1460 | if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
| 1461 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1462 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1463 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1464 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1465 | index = data; |
| 1466 | index &= 0xE0; |
| 1467 | data &= 0x1F; |
| 1468 | data = data << 1; |
| 1469 | data += 1; |
| 1470 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1471 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1472 | } |
| 1473 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1474 | } |
| 1475 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1476 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1477 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1478 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1479 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1480 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1481 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1482 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1483 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1484 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1485 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1486 | if (ModeNo > 0x13) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1487 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1488 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1489 | data &= 0xC0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1490 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1491 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1492 | data |= 0x01; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1493 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1494 | } else { |
| 1495 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1496 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1497 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1498 | data &= 0xC0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1499 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1500 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1501 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1502 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1503 | data &= 0xF0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1504 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1505 | } |
| 1506 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1507 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1508 | if (HwDeviceExtension->jChipType == XG21) |
| 1509 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1510 | } |
| 1511 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1512 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
| 1513 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, |
| 1514 | struct vb_device_info *pVBInfo) |
| 1515 | { |
| 1516 | unsigned short data, data2 = 0; |
| 1517 | short VCLK; |
| 1518 | |
| 1519 | unsigned char index; |
| 1520 | |
| 1521 | if (ModeNo <= 0x13) |
| 1522 | VCLK = 0; |
| 1523 | else { |
| 1524 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 1525 | index &= IndexMask; |
| 1526 | VCLK = pVBInfo->VCLKData[index].CLOCK; |
| 1527 | } |
| 1528 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1529 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1530 | data &= 0xf3; |
| 1531 | if (VCLK >= 200) |
| 1532 | data |= 0x0c; /* VCLK > 200 */ |
| 1533 | |
| 1534 | if (HwDeviceExtension->jChipType >= XG20) |
| 1535 | data &= ~0x04; /* 2 pixel mode */ |
| 1536 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1537 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1538 | |
| 1539 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1540 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1541 | data &= 0xE7; |
| 1542 | if (VCLK < 200) |
| 1543 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1544 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1545 | } |
| 1546 | |
| 1547 | /* Jong for Adavantech LCD ripple issue |
| 1548 | if ((VCLK >= 0) && (VCLK < 135)) |
| 1549 | data2 = 0x03; |
| 1550 | else if ((VCLK >= 135) && (VCLK < 160)) |
| 1551 | data2 = 0x02; |
| 1552 | else if ((VCLK >= 160) && (VCLK < 260)) |
| 1553 | data2 = 0x01; |
| 1554 | else if (VCLK > 260) |
| 1555 | data2 = 0x00; |
| 1556 | */ |
| 1557 | data2 = 0x00; |
| 1558 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1559 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1560 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1561 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1562 | |
| 1563 | } |
| 1564 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1565 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1566 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1567 | unsigned short RefreshRateTableIndex, |
| 1568 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1569 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1570 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1571 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1572 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1573 | if (ModeNo > 0x13) { |
| 1574 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1575 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1576 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1577 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1578 | /* si+St_ModeFlag */ |
| 1579 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1580 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1581 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1582 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1583 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1584 | if (ModeNo > 0x13) |
| 1585 | data = infoflag; |
| 1586 | else |
| 1587 | data = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1588 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1589 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1590 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1591 | if (ModeNo > 0x13) { |
| 1592 | if (pVBInfo->ModeType > 0x02) { |
| 1593 | data2 |= 0x02; |
| 1594 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1595 | data3 = data3 << 2; |
| 1596 | data2 |= data3; |
| 1597 | } |
| 1598 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1600 | data &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1601 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1602 | if (data) |
| 1603 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1604 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1605 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1606 | /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1607 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 1608 | if (ModeNo <= 0x13) |
| 1609 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 1610 | else |
| 1611 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1612 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1613 | data = 0x0000; |
| 1614 | if (infoflag & InterlaceMode) { |
| 1615 | if (xres == 1024) |
| 1616 | data = 0x0035; |
| 1617 | else if (xres == 1280) |
| 1618 | data = 0x0048; |
| 1619 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1620 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1621 | data2 = data & 0x00FF; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1622 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1623 | data2 = (data & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1624 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1625 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1626 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1627 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1628 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1629 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1630 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1631 | if (modeflag & LineCompareOff) |
| 1632 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1633 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1634 | if (ModeNo > 0x13) { |
| 1635 | if (pVBInfo->ModeType == ModeEGA) |
| 1636 | data2 |= 0x40; |
| 1637 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1638 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1639 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1640 | data = 0x60; |
| 1641 | if (pVBInfo->ModeType != ModeText) { |
| 1642 | data = data ^ 0x60; |
| 1643 | if (pVBInfo->ModeType != ModeEGA) |
| 1644 | data = data ^ 0xA0; |
| 1645 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1646 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1647 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1648 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, |
| 1649 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1650 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1651 | /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */ |
| 1652 | /* if (XGINew_IF_DEF_NEW_LOWRES) */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1653 | /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); |
| 1654 | * //030305 fix lowresolution bug */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1655 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1656 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1657 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1658 | if (HwDeviceExtension->jChipType == XG27) { |
| 1659 | if (data & 0x40) |
| 1660 | data = 0x2c; |
| 1661 | else |
| 1662 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1663 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1664 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1665 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1666 | if (data & 0x40) |
| 1667 | data = 0x33; |
| 1668 | else |
| 1669 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1670 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1671 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1672 | } else { |
| 1673 | if (data & 0x40) |
| 1674 | data = 0x2c; |
| 1675 | else |
| 1676 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1677 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1678 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1679 | |
| 1680 | } |
| 1681 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1682 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1683 | void XGI_VesaLowResolution(unsigned short ModeNo, |
| 1684 | unsigned short ModeIdIndex, |
| 1685 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1686 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1687 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1688 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1689 | if (ModeNo > 0x13) |
| 1690 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1691 | else |
| 1692 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1693 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1694 | if (ModeNo > 0x13) { |
| 1695 | if (modeflag & DoubleScanMode) { |
| 1696 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1697 | if (pVBInfo->VBType & VB_XGI301B | |
| 1698 | VB_XGI302B | |
| 1699 | VB_XGI301LV | |
| 1700 | VB_XGI302LV | |
| 1701 | VB_XGI301C)) { |
| 1702 | if (!(pVBInfo->VBInfo & |
| 1703 | SetCRT2ToRAMDAC)) { |
| 1704 | if (pVBInfo->VBInfo & |
| 1705 | SetInSlaveMode) { |
| 1706 | xgifb_reg_and_or( |
| 1707 | pVBInfo->P3c4, |
| 1708 | 0x01, |
| 1709 | 0xf7, |
| 1710 | 0x00); |
| 1711 | xgifb_reg_and_or( |
| 1712 | pVBInfo->P3c4, |
| 1713 | 0x0f, |
| 1714 | 0x7f, |
| 1715 | 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1716 | return; |
| 1717 | } |
| 1718 | } |
| 1719 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1720 | xgifb_reg_and_or(pVBInfo->P3c4, |
| 1721 | 0x0f, |
| 1722 | 0xff, |
| 1723 | 0x80); |
| 1724 | xgifb_reg_and_or(pVBInfo->P3c4, |
| 1725 | 0x01, |
| 1726 | 0xf7, |
| 1727 | 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1728 | return; |
| 1729 | } |
| 1730 | } |
| 1731 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1732 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1733 | } |
| 1734 | */ |
| 1735 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1736 | static void XGI_WriteDAC(unsigned short dl, |
| 1737 | unsigned short ah, |
| 1738 | unsigned short al, |
| 1739 | unsigned short dh, |
| 1740 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1741 | { |
| 1742 | unsigned short temp, bh, bl; |
| 1743 | |
| 1744 | bh = ah; |
| 1745 | bl = al; |
| 1746 | |
| 1747 | if (dl != 0) { |
| 1748 | temp = bh; |
| 1749 | bh = dh; |
| 1750 | dh = temp; |
| 1751 | if (dl == 1) { |
| 1752 | temp = bl; |
| 1753 | bl = dh; |
| 1754 | dh = temp; |
| 1755 | } else { |
| 1756 | temp = bl; |
| 1757 | bl = bh; |
| 1758 | bh = temp; |
| 1759 | } |
| 1760 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1761 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1762 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1763 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1764 | } |
| 1765 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1766 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1767 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1768 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1769 | unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al, |
| 1770 | ah, dh, *table = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1771 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1772 | if (ModeNo <= 0x13) |
| 1773 | data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1774 | else |
| 1775 | data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1776 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1777 | data &= DACInfoFlag; |
| 1778 | time = 64; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1779 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1780 | if (data == 0x00) |
| 1781 | table = XGINew_MDA_DAC; |
| 1782 | else if (data == 0x08) |
| 1783 | table = XGINew_CGA_DAC; |
| 1784 | else if (data == 0x10) |
| 1785 | table = XGINew_EGA_DAC; |
| 1786 | else if (data == 0x18) { |
| 1787 | time = 256; |
| 1788 | table = XGINew_VGA_DAC; |
| 1789 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1790 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1791 | if (time == 256) |
| 1792 | j = 16; |
| 1793 | else |
| 1794 | j = time; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1795 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1796 | outb(0xFF, pVBInfo->P3c6); |
| 1797 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1798 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1799 | for (i = 0; i < j; i++) { |
| 1800 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1801 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1802 | for (k = 0; k < 3; k++) { |
| 1803 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1804 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1805 | if (data & 0x01) |
| 1806 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1807 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1808 | if (data & 0x02) |
| 1809 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1810 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1811 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1812 | data = data >> 2; |
| 1813 | } |
| 1814 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1815 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1816 | if (time == 256) { |
| 1817 | for (i = 16; i < 32; i++) { |
| 1818 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1819 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1820 | for (k = 0; k < 3; k++) |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1821 | outb(data, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1822 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1823 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1824 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1825 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1826 | for (m = 0; m < 9; m++) { |
| 1827 | di = si; |
| 1828 | bx = si + 0x04; |
| 1829 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1830 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1831 | for (n = 0; n < 3; n++) { |
| 1832 | for (o = 0; o < 5; o++) { |
| 1833 | dh = table[si]; |
| 1834 | ah = table[di]; |
| 1835 | al = table[bx]; |
| 1836 | si++; |
| 1837 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1838 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1839 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1840 | si -= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1841 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1842 | for (o = 0; o < 3; o++) { |
| 1843 | dh = table[bx]; |
| 1844 | ah = table[di]; |
| 1845 | al = table[si]; |
| 1846 | si--; |
| 1847 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1848 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1849 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1850 | dl++; |
| 1851 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1852 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1853 | si += 5; |
| 1854 | } |
| 1855 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1856 | } |
| 1857 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1858 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
| 1859 | unsigned short ModeIdIndex, |
| 1860 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1861 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1862 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1863 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1864 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1865 | /* si+St_ResInfo */ |
| 1866 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1867 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1868 | /* si+Ext_ResInfo */ |
| 1869 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1870 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1871 | /* if (ModeNo > 0x13) */ |
| 1872 | /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */ |
| 1873 | /* else */ |
| 1874 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1875 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1876 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1877 | /* si+St_ResInfo */ |
| 1878 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1879 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1880 | /* si+Ext_ResInfo */ |
| 1881 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1882 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1883 | /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1884 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1885 | if (ModeNo <= 0x13) { |
| 1886 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 1887 | yres = pVBInfo->StResInfo[resindex].VTotal; |
| 1888 | } else { |
| 1889 | xres = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1890 | yres = pVBInfo->ModeResInfo[resindex].VTotal; |
| 1891 | } |
| 1892 | if (ModeNo > 0x13) { |
| 1893 | if (modeflag & HalfDCLK) |
| 1894 | xres = xres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1895 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1896 | if (modeflag & DoubleScanMode) |
| 1897 | yres = yres << 1; |
| 1898 | } |
| 1899 | /* if (modeflag & Charx8Dot) */ |
| 1900 | /* { */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1901 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1902 | if (xres == 720) |
| 1903 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1904 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1905 | /* } */ |
| 1906 | pVBInfo->VGAHDE = xres; |
| 1907 | pVBInfo->HDE = xres; |
| 1908 | pVBInfo->VGAVDE = yres; |
| 1909 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1910 | } |
| 1911 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1912 | static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, |
| 1913 | unsigned short ModeIdIndex, |
| 1914 | unsigned short RefreshRateTableIndex, |
| 1915 | struct vb_device_info *pVBInfo) |
| 1916 | { |
| 1917 | unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table; |
| 1918 | |
| 1919 | struct XGI330_LCDDataTablStruct *tempdi = NULL; |
| 1920 | |
| 1921 | tempbx = BX; |
| 1922 | |
| 1923 | if (ModeNo <= 0x13) { |
| 1924 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1925 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 1926 | } else { |
| 1927 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1928 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
| 1929 | } |
| 1930 | |
| 1931 | tempal = tempal & 0x0f; |
| 1932 | |
| 1933 | if (tempbx <= 1) { /* ExpLink */ |
| 1934 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1935 | /* find no Ext_CRT2CRTC2 */ |
| 1936 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1937 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1938 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1939 | Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1940 | } |
| 1941 | |
| 1942 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 1943 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1944 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 1945 | St_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1946 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1947 | tempal = pVBInfo->RefIndex[ |
| 1948 | RefreshRateTableIndex]. |
| 1949 | Ext_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1950 | } |
| 1951 | |
| 1952 | if (tempbx & 0x01) |
| 1953 | tempal = (tempal >> 4); |
| 1954 | |
| 1955 | tempal = (tempal & 0x0f); |
| 1956 | } |
| 1957 | |
| 1958 | tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */ |
| 1959 | |
| 1960 | if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */ |
| 1961 | if ((tempbx == 5) || (tempbx) == 7) |
| 1962 | tempcx = LCDDesDataLen2; |
| 1963 | else if ((tempbx == 3) || (tempbx == 8)) |
| 1964 | tempcx = LVDSDesDataLen2; |
| 1965 | } |
| 1966 | /* mov di, word ptr cs:LCDDataList[bx] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1967 | /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | |
| 1968 | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1969 | |
| 1970 | switch (tempbx) { |
| 1971 | case 0: |
| 1972 | tempdi = XGI_EPLLCDCRT1Ptr_H; |
| 1973 | break; |
| 1974 | case 1: |
| 1975 | tempdi = XGI_EPLLCDCRT1Ptr_V; |
| 1976 | break; |
| 1977 | case 2: |
| 1978 | tempdi = XGI_EPLLCDDataPtr; |
| 1979 | break; |
| 1980 | case 3: |
| 1981 | tempdi = XGI_EPLLCDDesDataPtr; |
| 1982 | break; |
| 1983 | case 4: |
| 1984 | tempdi = XGI_LCDDataTable; |
| 1985 | break; |
| 1986 | case 5: |
| 1987 | tempdi = XGI_LCDDesDataTable; |
| 1988 | break; |
| 1989 | case 6: |
| 1990 | tempdi = XGI_EPLCHLCDRegPtr; |
| 1991 | break; |
| 1992 | case 7: |
| 1993 | case 8: |
| 1994 | case 9: |
| 1995 | tempdi = NULL; |
| 1996 | break; |
| 1997 | default: |
| 1998 | break; |
| 1999 | } |
| 2000 | |
| 2001 | if (tempdi == NULL) /* OEMUtil */ |
| 2002 | return NULL; |
| 2003 | |
| 2004 | table = tempbx; |
| 2005 | i = 0; |
| 2006 | |
| 2007 | while (tempdi[i].PANELID != 0xff) { |
| 2008 | tempdx = pVBInfo->LCDResInfo; |
| 2009 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 2010 | tempbx &= (~0x0080); |
| 2011 | tempdx = pVBInfo->LCDTypeInfo; |
| 2012 | } |
| 2013 | |
| 2014 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2015 | tempdx &= (~PanelResInfo); |
| 2016 | |
| 2017 | if (tempdi[i].PANELID == tempdx) { |
| 2018 | tempbx = tempdi[i].MASK; |
| 2019 | tempdx = pVBInfo->LCDInfo; |
| 2020 | |
| 2021 | if (ModeNo <= 0x13) /* alan 09/10/2003 */ |
| 2022 | tempdx |= SetLCDStdMode; |
| 2023 | |
| 2024 | if (modeflag & HalfDCLK) |
| 2025 | tempdx |= SetLCDLowResolution; |
| 2026 | |
| 2027 | tempbx &= tempdx; |
| 2028 | if (tempbx == tempdi[i].CAP) |
| 2029 | break; |
| 2030 | } |
| 2031 | i++; |
| 2032 | } |
| 2033 | |
| 2034 | if (table == 0) { |
| 2035 | switch (tempdi[i].DATAPTR) { |
| 2036 | case 0: |
| 2037 | return &XGI_LVDSCRT11024x768_1_H[tempal]; |
| 2038 | break; |
| 2039 | case 1: |
| 2040 | return &XGI_LVDSCRT11024x768_2_H[tempal]; |
| 2041 | break; |
| 2042 | case 2: |
| 2043 | return &XGI_LVDSCRT11280x1024_1_H[tempal]; |
| 2044 | break; |
| 2045 | case 3: |
| 2046 | return &XGI_LVDSCRT11280x1024_2_H[tempal]; |
| 2047 | break; |
| 2048 | case 4: |
| 2049 | return &XGI_LVDSCRT11400x1050_1_H[tempal]; |
| 2050 | break; |
| 2051 | case 5: |
| 2052 | return &XGI_LVDSCRT11400x1050_2_H[tempal]; |
| 2053 | break; |
| 2054 | case 6: |
| 2055 | return &XGI_LVDSCRT11600x1200_1_H[tempal]; |
| 2056 | break; |
| 2057 | case 7: |
| 2058 | return &XGI_LVDSCRT11024x768_1_Hx75[tempal]; |
| 2059 | break; |
| 2060 | case 8: |
| 2061 | return &XGI_LVDSCRT11024x768_2_Hx75[tempal]; |
| 2062 | break; |
| 2063 | case 9: |
| 2064 | return &XGI_LVDSCRT11280x1024_1_Hx75[tempal]; |
| 2065 | break; |
| 2066 | case 10: |
| 2067 | return &XGI_LVDSCRT11280x1024_2_Hx75[tempal]; |
| 2068 | break; |
| 2069 | default: |
| 2070 | break; |
| 2071 | } |
| 2072 | } else if (table == 1) { |
| 2073 | switch (tempdi[i].DATAPTR) { |
| 2074 | case 0: |
| 2075 | return &XGI_LVDSCRT11024x768_1_V[tempal]; |
| 2076 | break; |
| 2077 | case 1: |
| 2078 | return &XGI_LVDSCRT11024x768_2_V[tempal]; |
| 2079 | break; |
| 2080 | case 2: |
| 2081 | return &XGI_LVDSCRT11280x1024_1_V[tempal]; |
| 2082 | break; |
| 2083 | case 3: |
| 2084 | return &XGI_LVDSCRT11280x1024_2_V[tempal]; |
| 2085 | break; |
| 2086 | case 4: |
| 2087 | return &XGI_LVDSCRT11400x1050_1_V[tempal]; |
| 2088 | break; |
| 2089 | case 5: |
| 2090 | return &XGI_LVDSCRT11400x1050_2_V[tempal]; |
| 2091 | break; |
| 2092 | case 6: |
| 2093 | return &XGI_LVDSCRT11600x1200_1_V[tempal]; |
| 2094 | break; |
| 2095 | case 7: |
| 2096 | return &XGI_LVDSCRT11024x768_1_Vx75[tempal]; |
| 2097 | break; |
| 2098 | case 8: |
| 2099 | return &XGI_LVDSCRT11024x768_2_Vx75[tempal]; |
| 2100 | break; |
| 2101 | case 9: |
| 2102 | return &XGI_LVDSCRT11280x1024_1_Vx75[tempal]; |
| 2103 | break; |
| 2104 | case 10: |
| 2105 | return &XGI_LVDSCRT11280x1024_2_Vx75[tempal]; |
| 2106 | break; |
| 2107 | default: |
| 2108 | break; |
| 2109 | } |
| 2110 | } else if (table == 2) { |
| 2111 | switch (tempdi[i].DATAPTR) { |
| 2112 | case 0: |
| 2113 | return &XGI_LVDS1024x768Data_1[tempal]; |
| 2114 | break; |
| 2115 | case 1: |
| 2116 | return &XGI_LVDS1024x768Data_2[tempal]; |
| 2117 | break; |
| 2118 | case 2: |
| 2119 | return &XGI_LVDS1280x1024Data_1[tempal]; |
| 2120 | break; |
| 2121 | case 3: |
| 2122 | return &XGI_LVDS1280x1024Data_2[tempal]; |
| 2123 | break; |
| 2124 | case 4: |
| 2125 | return &XGI_LVDS1400x1050Data_1[tempal]; |
| 2126 | break; |
| 2127 | case 5: |
| 2128 | return &XGI_LVDS1400x1050Data_2[tempal]; |
| 2129 | break; |
| 2130 | case 6: |
| 2131 | return &XGI_LVDS1600x1200Data_1[tempal]; |
| 2132 | break; |
| 2133 | case 7: |
| 2134 | return &XGI_LVDSNoScalingData[tempal]; |
| 2135 | break; |
| 2136 | case 8: |
| 2137 | return &XGI_LVDS1024x768Data_1x75[tempal]; |
| 2138 | break; |
| 2139 | case 9: |
| 2140 | return &XGI_LVDS1024x768Data_2x75[tempal]; |
| 2141 | break; |
| 2142 | case 10: |
| 2143 | return &XGI_LVDS1280x1024Data_1x75[tempal]; |
| 2144 | break; |
| 2145 | case 11: |
| 2146 | return &XGI_LVDS1280x1024Data_2x75[tempal]; |
| 2147 | break; |
| 2148 | case 12: |
| 2149 | return &XGI_LVDSNoScalingDatax75[tempal]; |
| 2150 | break; |
| 2151 | default: |
| 2152 | break; |
| 2153 | } |
| 2154 | } else if (table == 3) { |
| 2155 | switch (tempdi[i].DATAPTR) { |
| 2156 | case 0: |
| 2157 | return &XGI_LVDS1024x768Des_1[tempal]; |
| 2158 | break; |
| 2159 | case 1: |
| 2160 | return &XGI_LVDS1024x768Des_3[tempal]; |
| 2161 | break; |
| 2162 | case 2: |
| 2163 | return &XGI_LVDS1024x768Des_2[tempal]; |
| 2164 | break; |
| 2165 | case 3: |
| 2166 | return &XGI_LVDS1280x1024Des_1[tempal]; |
| 2167 | break; |
| 2168 | case 4: |
| 2169 | return &XGI_LVDS1280x1024Des_2[tempal]; |
| 2170 | break; |
| 2171 | case 5: |
| 2172 | return &XGI_LVDS1400x1050Des_1[tempal]; |
| 2173 | break; |
| 2174 | case 6: |
| 2175 | return &XGI_LVDS1400x1050Des_2[tempal]; |
| 2176 | break; |
| 2177 | case 7: |
| 2178 | return &XGI_LVDS1600x1200Des_1[tempal]; |
| 2179 | break; |
| 2180 | case 8: |
| 2181 | return &XGI_LVDSNoScalingDesData[tempal]; |
| 2182 | break; |
| 2183 | case 9: |
| 2184 | return &XGI_LVDS1024x768Des_1x75[tempal]; |
| 2185 | break; |
| 2186 | case 10: |
| 2187 | return &XGI_LVDS1024x768Des_3x75[tempal]; |
| 2188 | break; |
| 2189 | case 11: |
| 2190 | return &XGI_LVDS1024x768Des_2x75[tempal]; |
| 2191 | break; |
| 2192 | case 12: |
| 2193 | return &XGI_LVDS1280x1024Des_1x75[tempal]; |
| 2194 | break; |
| 2195 | case 13: |
| 2196 | return &XGI_LVDS1280x1024Des_2x75[tempal]; |
| 2197 | break; |
| 2198 | case 14: |
| 2199 | return &XGI_LVDSNoScalingDesDatax75[tempal]; |
| 2200 | break; |
| 2201 | default: |
| 2202 | break; |
| 2203 | } |
| 2204 | } else if (table == 4) { |
| 2205 | switch (tempdi[i].DATAPTR) { |
| 2206 | case 0: |
| 2207 | return &XGI_ExtLCD1024x768Data[tempal]; |
| 2208 | break; |
| 2209 | case 1: |
| 2210 | return &XGI_StLCD1024x768Data[tempal]; |
| 2211 | break; |
| 2212 | case 2: |
| 2213 | return &XGI_CetLCD1024x768Data[tempal]; |
| 2214 | break; |
| 2215 | case 3: |
| 2216 | return &XGI_ExtLCD1280x1024Data[tempal]; |
| 2217 | break; |
| 2218 | case 4: |
| 2219 | return &XGI_StLCD1280x1024Data[tempal]; |
| 2220 | break; |
| 2221 | case 5: |
| 2222 | return &XGI_CetLCD1280x1024Data[tempal]; |
| 2223 | break; |
| 2224 | case 6: |
| 2225 | return &XGI_ExtLCD1400x1050Data[tempal]; |
| 2226 | break; |
| 2227 | case 7: |
| 2228 | return &XGI_StLCD1400x1050Data[tempal]; |
| 2229 | break; |
| 2230 | case 8: |
| 2231 | return &XGI_CetLCD1400x1050Data[tempal]; |
| 2232 | break; |
| 2233 | case 9: |
| 2234 | return &XGI_ExtLCD1600x1200Data[tempal]; |
| 2235 | break; |
| 2236 | case 10: |
| 2237 | return &XGI_StLCD1600x1200Data[tempal]; |
| 2238 | break; |
| 2239 | case 11: |
| 2240 | return &XGI_NoScalingData[tempal]; |
| 2241 | break; |
| 2242 | case 12: |
| 2243 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 2244 | break; |
| 2245 | case 13: |
| 2246 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 2247 | break; |
| 2248 | case 14: |
| 2249 | return &XGI_CetLCD1024x768x75Data[tempal]; |
| 2250 | break; |
| 2251 | case 15: |
| 2252 | return &XGI_ExtLCD1280x1024x75Data[tempal]; |
| 2253 | break; |
| 2254 | case 16: |
| 2255 | return &XGI_StLCD1280x1024x75Data[tempal]; |
| 2256 | break; |
| 2257 | case 17: |
| 2258 | return &XGI_CetLCD1280x1024x75Data[tempal]; |
| 2259 | break; |
| 2260 | case 18: |
| 2261 | return &XGI_NoScalingDatax75[tempal]; |
| 2262 | break; |
| 2263 | default: |
| 2264 | break; |
| 2265 | } |
| 2266 | } else if (table == 5) { |
| 2267 | switch (tempdi[i].DATAPTR) { |
| 2268 | case 0: |
| 2269 | return &XGI_ExtLCDDes1024x768Data[tempal]; |
| 2270 | break; |
| 2271 | case 1: |
| 2272 | return &XGI_StLCDDes1024x768Data[tempal]; |
| 2273 | break; |
| 2274 | case 2: |
| 2275 | return &XGI_CetLCDDes1024x768Data[tempal]; |
| 2276 | break; |
| 2277 | case 3: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2278 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2279 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2280 | return &XGI_ExtLCDDLDes1280x1024Data[tempal]; |
| 2281 | else |
| 2282 | return &XGI_ExtLCDDes1280x1024Data[tempal]; |
| 2283 | break; |
| 2284 | case 4: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2285 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2286 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2287 | return &XGI_StLCDDLDes1280x1024Data[tempal]; |
| 2288 | else |
| 2289 | return &XGI_StLCDDes1280x1024Data[tempal]; |
| 2290 | break; |
| 2291 | case 5: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2292 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2293 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2294 | return &XGI_CetLCDDLDes1280x1024Data[tempal]; |
| 2295 | else |
| 2296 | return &XGI_CetLCDDes1280x1024Data[tempal]; |
| 2297 | break; |
| 2298 | case 6: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2299 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2300 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2301 | return &XGI_ExtLCDDLDes1400x1050Data[tempal]; |
| 2302 | else |
| 2303 | return &XGI_ExtLCDDes1400x1050Data[tempal]; |
| 2304 | break; |
| 2305 | case 7: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2306 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2307 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2308 | return &XGI_StLCDDLDes1400x1050Data[tempal]; |
| 2309 | else |
| 2310 | return &XGI_StLCDDes1400x1050Data[tempal]; |
| 2311 | break; |
| 2312 | case 8: |
| 2313 | return &XGI_CetLCDDes1400x1050Data[tempal]; |
| 2314 | break; |
| 2315 | case 9: |
| 2316 | return &XGI_CetLCDDes1400x1050Data2[tempal]; |
| 2317 | break; |
| 2318 | case 10: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2319 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2320 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2321 | return &XGI_ExtLCDDLDes1600x1200Data[tempal]; |
| 2322 | else |
| 2323 | return &XGI_ExtLCDDes1600x1200Data[tempal]; |
| 2324 | break; |
| 2325 | case 11: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2326 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2327 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2328 | return &XGI_StLCDDLDes1600x1200Data[tempal]; |
| 2329 | else |
| 2330 | return &XGI_StLCDDes1600x1200Data[tempal]; |
| 2331 | break; |
| 2332 | case 12: |
| 2333 | return &XGI_NoScalingDesData[tempal]; |
| 2334 | break; |
| 2335 | case 13: |
| 2336 | return &XGI_ExtLCDDes1024x768x75Data[tempal]; |
| 2337 | break; |
| 2338 | case 14: |
| 2339 | return &XGI_StLCDDes1024x768x75Data[tempal]; |
| 2340 | break; |
| 2341 | case 15: |
| 2342 | return &XGI_CetLCDDes1024x768x75Data[tempal]; |
| 2343 | break; |
| 2344 | case 16: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2345 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2346 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2347 | return &XGI_ExtLCDDLDes1280x1024x75Data[tempal]; |
| 2348 | else |
| 2349 | return &XGI_ExtLCDDes1280x1024x75Data[tempal]; |
| 2350 | break; |
| 2351 | case 17: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2352 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2353 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2354 | return &XGI_StLCDDLDes1280x1024x75Data[tempal]; |
| 2355 | else |
| 2356 | return &XGI_StLCDDes1280x1024x75Data[tempal]; |
| 2357 | break; |
| 2358 | case 18: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2359 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2360 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2361 | return &XGI_CetLCDDLDes1280x1024x75Data[tempal]; |
| 2362 | else |
| 2363 | return &XGI_CetLCDDes1280x1024x75Data[tempal]; |
| 2364 | break; |
| 2365 | case 19: |
| 2366 | return &XGI_NoScalingDesDatax75[tempal]; |
| 2367 | break; |
| 2368 | default: |
| 2369 | break; |
| 2370 | } |
| 2371 | } else if (table == 6) { |
| 2372 | switch (tempdi[i].DATAPTR) { |
| 2373 | case 0: |
| 2374 | return &XGI_CH7017LV1024x768[tempal]; |
| 2375 | break; |
| 2376 | case 1: |
| 2377 | return &XGI_CH7017LV1400x1050[tempal]; |
| 2378 | break; |
| 2379 | default: |
| 2380 | break; |
| 2381 | } |
| 2382 | } |
| 2383 | return NULL; |
| 2384 | } |
| 2385 | |
| 2386 | static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, |
| 2387 | unsigned short ModeIdIndex, |
| 2388 | unsigned short RefreshRateTableIndex, |
| 2389 | struct vb_device_info *pVBInfo) |
| 2390 | { |
| 2391 | unsigned short i, tempdx, tempbx, tempal, modeflag, table; |
| 2392 | struct XGI330_TVDataTablStruct *tempdi = NULL; |
| 2393 | |
| 2394 | tempbx = BX; |
| 2395 | |
| 2396 | if (ModeNo <= 0x13) { |
| 2397 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 2398 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 2399 | } else { |
| 2400 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2401 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
| 2402 | } |
| 2403 | |
| 2404 | tempal = tempal & 0x3f; |
| 2405 | table = tempbx; |
| 2406 | |
| 2407 | switch (tempbx) { |
| 2408 | case 0: |
| 2409 | tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2410 | break; |
| 2411 | case 1: |
| 2412 | tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2413 | break; |
| 2414 | case 2: |
| 2415 | tempdi = XGI_EPLCHTVDataPtr; |
| 2416 | break; |
| 2417 | case 3: |
| 2418 | tempdi = NULL; |
| 2419 | break; |
| 2420 | case 4: |
| 2421 | tempdi = XGI_TVDataTable; |
| 2422 | break; |
| 2423 | case 5: |
| 2424 | tempdi = NULL; |
| 2425 | break; |
| 2426 | case 6: |
| 2427 | tempdi = XGI_EPLCHTVRegPtr; |
| 2428 | break; |
| 2429 | default: |
| 2430 | break; |
| 2431 | } |
| 2432 | |
| 2433 | if (tempdi == NULL) /* OEMUtil */ |
| 2434 | return NULL; |
| 2435 | |
| 2436 | tempdx = pVBInfo->TVInfo; |
| 2437 | |
| 2438 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2439 | tempdx = tempdx | SetTVLockMode; |
| 2440 | |
| 2441 | if (modeflag & HalfDCLK) |
| 2442 | tempdx = tempdx | SetTVLowResolution; |
| 2443 | |
| 2444 | i = 0; |
| 2445 | |
| 2446 | while (tempdi[i].MASK != 0xffff) { |
| 2447 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) |
| 2448 | break; |
| 2449 | i++; |
| 2450 | } |
| 2451 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2452 | /* 07/05/22 */ |
| 2453 | if (table == 0x00) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2454 | } else if (table == 0x01) { |
| 2455 | } else if (table == 0x04) { |
| 2456 | switch (tempdi[i].DATAPTR) { |
| 2457 | case 0: |
| 2458 | return &XGI_ExtPALData[tempal]; |
| 2459 | break; |
| 2460 | case 1: |
| 2461 | return &XGI_ExtNTSCData[tempal]; |
| 2462 | break; |
| 2463 | case 2: |
| 2464 | return &XGI_StPALData[tempal]; |
| 2465 | break; |
| 2466 | case 3: |
| 2467 | return &XGI_StNTSCData[tempal]; |
| 2468 | break; |
| 2469 | case 4: |
| 2470 | return &XGI_ExtHiTVData[tempal]; |
| 2471 | break; |
| 2472 | case 5: |
| 2473 | return &XGI_St2HiTVData[tempal]; |
| 2474 | break; |
| 2475 | case 6: |
| 2476 | return &XGI_ExtYPbPr525iData[tempal]; |
| 2477 | break; |
| 2478 | case 7: |
| 2479 | return &XGI_ExtYPbPr525pData[tempal]; |
| 2480 | break; |
| 2481 | case 8: |
| 2482 | return &XGI_ExtYPbPr750pData[tempal]; |
| 2483 | break; |
| 2484 | case 9: |
| 2485 | return &XGI_StYPbPr525iData[tempal]; |
| 2486 | break; |
| 2487 | case 10: |
| 2488 | return &XGI_StYPbPr525pData[tempal]; |
| 2489 | break; |
| 2490 | case 11: |
| 2491 | return &XGI_StYPbPr750pData[tempal]; |
| 2492 | break; |
| 2493 | case 12: /* avoid system hang */ |
| 2494 | return &XGI_ExtNTSCData[tempal]; |
| 2495 | break; |
| 2496 | case 13: |
| 2497 | return &XGI_St1HiTVData[tempal]; |
| 2498 | break; |
| 2499 | default: |
| 2500 | break; |
| 2501 | } |
| 2502 | } else if (table == 0x02) { |
| 2503 | switch (tempdi[i].DATAPTR) { |
| 2504 | case 0: |
| 2505 | return &XGI_CHTVUNTSCData[tempal]; |
| 2506 | break; |
| 2507 | case 1: |
| 2508 | return &XGI_CHTVONTSCData[tempal]; |
| 2509 | break; |
| 2510 | case 2: |
| 2511 | return &XGI_CHTVUPALData[tempal]; |
| 2512 | break; |
| 2513 | case 3: |
| 2514 | return &XGI_CHTVOPALData[tempal]; |
| 2515 | break; |
| 2516 | default: |
| 2517 | break; |
| 2518 | } |
| 2519 | } else if (table == 0x06) { |
| 2520 | } |
| 2521 | return NULL; |
| 2522 | } |
| 2523 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2524 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2525 | unsigned short RefreshRateTableIndex, |
| 2526 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2527 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2528 | unsigned short tempbx; |
| 2529 | struct XGI330_LVDSDataStruct *LCDPtr = NULL; |
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 | tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2532 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2533 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 2534 | LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx, |
| 2535 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2536 | pVBInfo); |
| 2537 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2538 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2539 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2540 | pVBInfo->VT = LCDPtr->LCDVT; |
| 2541 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2542 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2543 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 2544 | if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding |
| 2545 | | EnableScalingLCD))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2546 | if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 2547 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2548 | pVBInfo->HDE = 1024; |
| 2549 | pVBInfo->VDE = 768; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2550 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || |
| 2551 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2552 | pVBInfo->HDE = 1280; |
| 2553 | pVBInfo->VDE = 1024; |
| 2554 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 2555 | pVBInfo->HDE = 1400; |
| 2556 | pVBInfo->VDE = 1050; |
| 2557 | } else { |
| 2558 | pVBInfo->HDE = 1600; |
| 2559 | pVBInfo->VDE = 1200; |
| 2560 | } |
| 2561 | } |
| 2562 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2563 | } |
| 2564 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2565 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2566 | unsigned short RefreshRateTableIndex, |
| 2567 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2568 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2569 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2570 | unsigned char index; |
| 2571 | unsigned short tempbx, i; |
| 2572 | struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL; |
| 2573 | struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2574 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2575 | if (ModeNo <= 0x13) |
| 2576 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 2577 | else |
| 2578 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2579 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2580 | index = index & IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2581 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2582 | if ((pVBInfo->IF_DEF_ScaleLCD == 0) || |
| 2583 | ((pVBInfo->IF_DEF_ScaleLCD == 1) && |
| 2584 | (!(pVBInfo->LCDInfo & EnableScalingLCD)))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2585 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2586 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2587 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2588 | LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) |
| 2589 | XGI_GetLcdPtr(tempbx, ModeNo, |
| 2590 | ModeIdIndex, |
| 2591 | RefreshRateTableIndex, |
| 2592 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2593 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2594 | for (i = 0; i < 8; i++) |
| 2595 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; |
| 2596 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2597 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2598 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2600 | tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2601 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2602 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2603 | LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) |
| 2604 | XGI_GetLcdPtr( |
| 2605 | tempbx, |
| 2606 | ModeNo, |
| 2607 | ModeIdIndex, |
| 2608 | RefreshRateTableIndex, |
| 2609 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2610 | for (i = 0; i < 7; i++) |
| 2611 | pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; |
| 2612 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2613 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2614 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2615 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2616 | } |
| 2617 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2618 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 2619 | { |
| 2620 | unsigned char tempal, tempah, tempbl, i; |
| 2621 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2622 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2623 | tempal = tempah & 0x0F; |
| 2624 | tempah = tempah & 0xF0; |
| 2625 | i = 0; |
| 2626 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2627 | |
| 2628 | while (tempbl != 0xFF) { |
| 2629 | if (tempbl & 0x80) { /* OEMUtil */ |
| 2630 | tempal = tempah; |
| 2631 | tempbl = tempbl & ~(0x80); |
| 2632 | } |
| 2633 | |
| 2634 | if (tempal == tempbl) |
| 2635 | break; |
| 2636 | |
| 2637 | i++; |
| 2638 | |
| 2639 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2640 | } |
| 2641 | |
| 2642 | return i; |
| 2643 | } |
| 2644 | |
| 2645 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 2646 | { |
| 2647 | unsigned short tempah, tempal, tempbl, i; |
| 2648 | |
| 2649 | tempal = pVBInfo->LCDResInfo; |
| 2650 | tempah = pVBInfo->LCDTypeInfo; |
| 2651 | |
| 2652 | i = 0; |
| 2653 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2654 | |
| 2655 | while (tempbl != 0xFF) { |
| 2656 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 2657 | tempal = tempah; |
| 2658 | tempbl &= ~0x80; |
| 2659 | } |
| 2660 | |
| 2661 | if (tempal == tempbl) |
| 2662 | break; |
| 2663 | |
| 2664 | i++; |
| 2665 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2666 | } |
| 2667 | |
| 2668 | if (tempbl == 0xFF) { |
| 2669 | pVBInfo->LCDResInfo = Panel1024x768; |
| 2670 | pVBInfo->LCDTypeInfo = 0; |
| 2671 | i = 0; |
| 2672 | } |
| 2673 | |
| 2674 | return i; |
| 2675 | } |
| 2676 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2677 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 2678 | unsigned short *VSyncWidth, |
| 2679 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2680 | { |
| 2681 | unsigned short Index; |
| 2682 | |
| 2683 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 2684 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 2685 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
| 2686 | |
| 2687 | return; |
| 2688 | } |
| 2689 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2690 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2691 | unsigned short RefreshRateTableIndex, |
| 2692 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2693 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2694 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 2695 | unsigned long temp, temp1, temp2, temp3, push3; |
| 2696 | struct XGI330_LCDDataDesStruct *LCDPtr = NULL; |
| 2697 | struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2698 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2699 | if (ModeNo > 0x13) |
| 2700 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2701 | else |
| 2702 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2703 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2704 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) { |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2705 | if (pVBInfo->IF_DEF_OEMUtil == 1) { |
| 2706 | tempbx = 8; |
| 2707 | LCDPtr = (struct XGI330_LCDDataDesStruct *) |
| 2708 | XGI_GetLcdPtr(tempbx, |
| 2709 | ModeNo, |
| 2710 | ModeIdIndex, |
| 2711 | RefreshRateTableIndex, |
| 2712 | pVBInfo); |
| 2713 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2714 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2715 | if ((pVBInfo->IF_DEF_OEMUtil == 0) || |
| 2716 | (LCDPtr == NULL)) { |
| 2717 | tempbx = 3; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2718 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2719 | LCDPtr1 = |
| 2720 | (struct XGI330_LCDDataDesStruct2 *) |
| 2721 | XGI_GetLcdPtr( |
| 2722 | tempbx, |
| 2723 | ModeNo, |
| 2724 | ModeIdIndex, |
| 2725 | RefreshRateTableIndex, |
| 2726 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2727 | else |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2728 | LCDPtr = |
| 2729 | (struct XGI330_LCDDataDesStruct *) |
| 2730 | XGI_GetLcdPtr( |
| 2731 | tempbx, |
| 2732 | ModeNo, |
| 2733 | ModeIdIndex, |
| 2734 | RefreshRateTableIndex, |
| 2735 | pVBInfo); |
| 2736 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2737 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2738 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 2739 | push1 = tempbx; |
| 2740 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2741 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2742 | /* GetLCDResInfo */ |
| 2743 | if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 2744 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { |
| 2745 | tempax = 1024; |
| 2746 | tempbx = 768; |
| 2747 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || |
| 2748 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { |
| 2749 | tempax = 1280; |
| 2750 | tempbx = 1024; |
| 2751 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 2752 | tempax = 1400; |
| 2753 | tempbx = 1050; |
| 2754 | } else { |
| 2755 | tempax = 1600; |
| 2756 | tempbx = 1200; |
| 2757 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2758 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2759 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 2760 | pVBInfo->HDE = tempax; |
| 2761 | pVBInfo->VDE = tempbx; |
| 2762 | pVBInfo->VGAHDE = tempax; |
| 2763 | pVBInfo->VGAVDE = tempbx; |
| 2764 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2765 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2766 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && |
| 2767 | (pVBInfo->LCDInfo & EnableScalingLCD)) { |
| 2768 | tempax = pVBInfo->HDE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2769 | tempbx = pVBInfo->VDE; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2770 | } |
| 2771 | |
| 2772 | tempax = pVBInfo->HT; |
| 2773 | |
| 2774 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2775 | tempbx = LCDPtr1->LCDHDES; |
| 2776 | else |
| 2777 | tempbx = LCDPtr->LCDHDES; |
| 2778 | |
| 2779 | tempcx = pVBInfo->HDE; |
| 2780 | tempbx = tempbx & 0x0fff; |
| 2781 | tempcx += tempbx; |
| 2782 | |
| 2783 | if (tempcx >= tempax) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2784 | tempcx -= tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2785 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2786 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2787 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2788 | tempcx = tempcx >> 3; |
| 2789 | tempbx = tempbx >> 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2790 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2791 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 2792 | (unsigned short) (tempbx & 0xff)); |
| 2793 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 2794 | (unsigned short) (tempcx & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2795 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2796 | tempax = pVBInfo->HT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2797 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2798 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2799 | tempbx = LCDPtr1->LCDHRS; |
| 2800 | else |
| 2801 | tempbx = LCDPtr->LCDHRS; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2802 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2803 | tempcx = push2; |
| 2804 | |
| 2805 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2806 | tempcx = LCDPtr1->LCDHSync; |
| 2807 | |
| 2808 | tempcx += tempbx; |
| 2809 | |
| 2810 | if (tempcx >= tempax) |
| 2811 | tempcx -= tempax; |
| 2812 | |
| 2813 | tempax = tempbx & 0x07; |
| 2814 | tempax = tempax >> 5; |
| 2815 | tempcx = tempcx >> 3; |
| 2816 | tempbx = tempbx >> 3; |
| 2817 | |
| 2818 | tempcx &= 0x1f; |
| 2819 | tempax |= tempcx; |
| 2820 | |
| 2821 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 2822 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 2823 | (unsigned short) (tempbx & 0xff)); |
| 2824 | |
| 2825 | tempax = pVBInfo->VT; |
| 2826 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2827 | tempbx = LCDPtr1->LCDVDES; |
| 2828 | else |
| 2829 | tempbx = LCDPtr->LCDVDES; |
| 2830 | tempcx = pVBInfo->VDE; |
| 2831 | |
| 2832 | tempbx = tempbx & 0x0fff; |
| 2833 | tempcx += tempbx; |
| 2834 | if (tempcx >= tempax) |
| 2835 | tempcx -= tempax; |
| 2836 | |
| 2837 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 2838 | (unsigned short) (tempbx & 0xff)); |
| 2839 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 2840 | (unsigned short) (tempcx & 0xff)); |
| 2841 | |
| 2842 | tempbx = (tempbx >> 8) & 0x07; |
| 2843 | tempcx = (tempcx >> 8) & 0x07; |
| 2844 | |
| 2845 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 2846 | (unsigned short) ((tempcx << 3) |
| 2847 | | tempbx)); |
| 2848 | |
| 2849 | tempax = pVBInfo->VT; |
| 2850 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2851 | tempbx = LCDPtr1->LCDVRS; |
| 2852 | else |
| 2853 | tempbx = LCDPtr->LCDVRS; |
| 2854 | |
| 2855 | /* tempbx = tempbx >> 4; */ |
| 2856 | tempcx = push1; |
| 2857 | |
| 2858 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2859 | tempcx = LCDPtr1->LCDVSync; |
| 2860 | |
| 2861 | tempcx += tempbx; |
| 2862 | if (tempcx >= tempax) |
| 2863 | tempcx -= tempax; |
| 2864 | |
| 2865 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 2866 | (unsigned short) (tempbx & 0xff)); |
| 2867 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 2868 | (unsigned short) (tempcx & 0x0f)); |
| 2869 | |
| 2870 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 2871 | |
| 2872 | tempbx = pVBInfo->VGAVDE; |
| 2873 | if (tempbx != pVBInfo->VDE) |
| 2874 | tempax |= 0x40; |
| 2875 | |
| 2876 | if (pVBInfo->LCDInfo & EnableLVDSDDA) |
| 2877 | tempax |= 0x40; |
| 2878 | |
| 2879 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 2880 | tempax); |
| 2881 | |
| 2882 | tempcx = pVBInfo->VGAVT; |
| 2883 | tempbx = pVBInfo->VDE; |
| 2884 | tempax = pVBInfo->VGAVDE; |
| 2885 | tempcx -= tempax; |
| 2886 | |
| 2887 | temp = tempax; /* 0430 ylshieh */ |
| 2888 | temp1 = (temp << 18) / tempbx; |
| 2889 | |
| 2890 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 2891 | |
| 2892 | if (tempdx != 0) |
| 2893 | temp1 += 1; |
| 2894 | |
| 2895 | temp2 = temp1; |
| 2896 | push3 = temp2; |
| 2897 | |
| 2898 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 2899 | (unsigned short) (temp2 & 0xff)); |
| 2900 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 2901 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 2902 | |
| 2903 | tempbx = (unsigned short) (temp2 >> 16); |
| 2904 | tempax = tempbx & 0x03; |
| 2905 | |
| 2906 | tempbx = pVBInfo->VGAVDE; |
| 2907 | if (tempbx == pVBInfo->VDE) |
| 2908 | tempax |= 0x04; |
| 2909 | |
| 2910 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 2911 | |
| 2912 | if (pVBInfo->VBType & VB_XGI301C) { |
| 2913 | temp2 = push3; |
| 2914 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2915 | 0x3c, |
| 2916 | (unsigned short) (temp2 & 0xff)); |
| 2917 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2918 | 0x3b, |
| 2919 | (unsigned short) ((temp2 >> 8) & |
| 2920 | 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2921 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2922 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 2923 | ~0xc0, |
| 2924 | (unsigned short) ((tempbx & |
| 2925 | 0xff) << 6)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2926 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2927 | tempcx = pVBInfo->VGAVDE; |
| 2928 | if (tempcx == pVBInfo->VDE) |
| 2929 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2930 | 0x30, ~0x0c, 0x00); |
| 2931 | else |
| 2932 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2933 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2934 | } |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2935 | |
| 2936 | tempcx = pVBInfo->VGAHDE; |
| 2937 | tempbx = pVBInfo->HDE; |
| 2938 | |
| 2939 | temp1 = tempcx << 16; |
| 2940 | |
| 2941 | tempax = (unsigned short) (temp1 / tempbx); |
| 2942 | |
| 2943 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 2944 | tempax = 65535; |
| 2945 | |
| 2946 | temp3 = tempax; |
| 2947 | temp1 = pVBInfo->VGAHDE << 16; |
| 2948 | |
| 2949 | temp1 /= temp3; |
| 2950 | temp3 = temp3 << 16; |
| 2951 | temp1 -= 1; |
| 2952 | |
| 2953 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 2954 | |
| 2955 | tempax = (unsigned short) (temp3 & 0xff); |
| 2956 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 2957 | |
| 2958 | temp1 = pVBInfo->VGAVDE << 18; |
| 2959 | temp1 = temp1 / push3; |
| 2960 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 2961 | |
| 2962 | if (pVBInfo->LCDResInfo == Panel1024x768) |
| 2963 | tempbx -= 1; |
| 2964 | |
| 2965 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 2966 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 2967 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 2968 | (unsigned short) (tempax & 0xff)); |
| 2969 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 2970 | (unsigned short) (tempbx & 0xff)); |
| 2971 | |
| 2972 | temp3 = temp3 >> 16; |
| 2973 | |
| 2974 | if (modeflag & HalfDCLK) |
| 2975 | temp3 = temp3 >> 1; |
| 2976 | |
| 2977 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 2978 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 2979 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 2980 | (unsigned short) (temp3 & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2981 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2982 | } |
| 2983 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2984 | /* --------------------------------------------------------------------- */ |
| 2985 | /* Function : XGI_GETLCDVCLKPtr */ |
| 2986 | /* Input : */ |
| 2987 | /* Output : al -> VCLK Index */ |
| 2988 | /* Description : */ |
| 2989 | /* --------------------------------------------------------------------- */ |
| 2990 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 2991 | struct vb_device_info *pVBInfo) |
| 2992 | { |
| 2993 | unsigned short index; |
| 2994 | |
| 2995 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 2996 | if (pVBInfo->IF_DEF_ScaleLCD == 1) { |
| 2997 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2998 | return; |
| 2999 | } |
| 3000 | |
| 3001 | /* index = XGI_GetLCDCapPtr(pVBInfo); */ |
| 3002 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 3003 | |
| 3004 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 3005 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 3006 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 3007 | } else { /* LCDA */ |
| 3008 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 3009 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 3010 | } |
| 3011 | } |
| 3012 | return; |
| 3013 | } |
| 3014 | |
| 3015 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
| 3016 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 3017 | struct vb_device_info *pVBInfo) |
| 3018 | { |
| 3019 | |
| 3020 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3021 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3022 | |
| 3023 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3024 | /* si+St_ResInfo */ |
| 3025 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3026 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3027 | /* si+Ext_ResInfo */ |
| 3028 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3029 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3030 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 3031 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3032 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 3033 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 3034 | |
| 3035 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
| 3036 | return tempal; |
| 3037 | |
| 3038 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3039 | if (pVBInfo->VBType & |
| 3040 | (VB_XGI301B | |
| 3041 | VB_XGI302B | |
| 3042 | VB_XGI301LV | |
| 3043 | VB_XGI302LV | |
| 3044 | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3045 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 3046 | tempal = HiTVVCLKDIV2; |
| 3047 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
| 3048 | tempal = HiTVVCLK; |
| 3049 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3050 | tempal = HiTVSimuVCLK; |
| 3051 | if (!(modeflag & Charx8Dot)) |
| 3052 | tempal = HiTVTextVCLK; |
| 3053 | |
| 3054 | } |
| 3055 | return tempal; |
| 3056 | } |
| 3057 | |
| 3058 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
| 3059 | tempal = YPbPr750pVCLK; |
| 3060 | return tempal; |
| 3061 | } |
| 3062 | |
| 3063 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
| 3064 | tempal = YPbPr525pVCLK; |
| 3065 | return tempal; |
| 3066 | } |
| 3067 | |
| 3068 | tempal = NTSC1024VCLK; |
| 3069 | |
| 3070 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
| 3071 | tempal = TVVCLKDIV2; |
| 3072 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
| 3073 | tempal = TVVCLK; |
| 3074 | } |
| 3075 | |
| 3076 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3077 | return tempal; |
| 3078 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3079 | } /* {End of VB} */ |
| 3080 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3081 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3082 | tempal = tempal >> 2; |
| 3083 | tempal &= 0x03; |
| 3084 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3085 | /* for Dot8 Scaling LCD */ |
| 3086 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3087 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
| 3088 | |
| 3089 | if (ModeNo <= 0x13) |
| 3090 | return tempal; |
| 3091 | |
| 3092 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 3093 | return tempal; |
| 3094 | } |
| 3095 | |
| 3096 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 3097 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 3098 | { |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3099 | if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3100 | | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
| 3101 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag |
| 3102 | & ProgrammingCRT2)) { |
| 3103 | *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B; |
| 3104 | *di_1 = XGI_VBVCLKData[tempal].SR2C; |
| 3105 | } |
| 3106 | } else { |
| 3107 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 3108 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 3109 | } |
| 3110 | } |
| 3111 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3112 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3113 | unsigned short RefreshRateTableIndex, |
| 3114 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3115 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3116 | unsigned char di_0, di_1, tempal; |
| 3117 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3118 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3119 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 3120 | pVBInfo); |
| 3121 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 3122 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3123 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3124 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3125 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3126 | (unsigned short) (0x10 * i)); |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3127 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3128 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3129 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 3130 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3131 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3132 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 3133 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3134 | } |
| 3135 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3136 | } |
| 3137 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3138 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3139 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3140 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3141 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3142 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3143 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 3144 | | VB_XGI302LV | VB_XGI301C)) { |
| 3145 | tempcl = 0; |
| 3146 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3147 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3148 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3149 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3150 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3151 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3152 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3153 | if (!(temp & 0x40)) |
| 3154 | tempcl |= ActiveCRT1; |
| 3155 | } |
| 3156 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3157 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3158 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3159 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3160 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3161 | if (!(temp == 0x08)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3162 | /* Check ChannelA by Part1_13 [2003/10/03] */ |
| 3163 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3164 | if (tempax & 0x04) |
| 3165 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3166 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3167 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3168 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3169 | if (!(tempcl & ActiveLCD)) |
| 3170 | if (temp == 0x01) |
| 3171 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3172 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3173 | if (temp == 0x04) |
| 3174 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3175 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3176 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3177 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3178 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3179 | if (!(temp & 0x08)) |
| 3180 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3181 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3182 | if (!(temp & 0x04)) |
| 3183 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3184 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3185 | if (temp & 0x02) |
| 3186 | tempch |= ActiveSCART; |
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 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 3189 | if (temp & 0x01) |
| 3190 | tempch |= ActiveHiTV; |
| 3191 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3192 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3193 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3194 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3195 | pVBInfo->Part2Port, |
| 3196 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3197 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3198 | if (temp & 0x10) |
| 3199 | tempch |= ActiveYPbPr; |
| 3200 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3201 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3202 | if (tempch != 0) |
| 3203 | tempcl |= ActiveTV; |
| 3204 | } |
| 3205 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3206 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3207 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3208 | if (tempcl & ActiveLCD) { |
| 3209 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 3210 | if (temp & ActiveTV) |
| 3211 | tempcl |= ActiveTV; |
| 3212 | } |
| 3213 | } |
| 3214 | temp = tempcl; |
| 3215 | tempbl = ~ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3216 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3217 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3218 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3219 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3220 | } else { |
| 3221 | return; |
| 3222 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3223 | } |
| 3224 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3225 | void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, |
| 3226 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3227 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3228 | /* |
| 3229 | if ( HwDeviceExtension->jChipType >= XG20 ) { |
| 3230 | pVBInfo->Set_VGAType = XG20; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 3231 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3232 | pVBInfo->Set_VGAType = VGA_XGI340; |
| 3233 | } |
| 3234 | */ |
| 3235 | pVBInfo->Set_VGAType = HwDeviceExtension->jChipType; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3236 | } |
| 3237 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 3238 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3239 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3240 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3241 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3242 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3243 | tempbx = VB_XGI302B; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3244 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3245 | if (flag != 0x02) { |
| 3246 | tempbx = VB_XGI301; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3247 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3248 | if (flag >= 0xB0) { |
| 3249 | tempbx = VB_XGI301B; |
| 3250 | if (flag >= 0xC0) { |
| 3251 | tempbx = VB_XGI301C; |
| 3252 | if (flag >= 0xD0) { |
| 3253 | tempbx = VB_XGI301LV; |
| 3254 | if (flag >= 0xE0) { |
| 3255 | tempbx = VB_XGI302LV; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3256 | tempah = xgifb_reg_get( |
| 3257 | pVBInfo->Part4Port, |
| 3258 | 0x39); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3259 | if (tempah != 0xFF) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3260 | tempbx = |
| 3261 | VB_XGI301C; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3262 | } |
| 3263 | } |
| 3264 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3265 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3266 | if (tempbx & (VB_XGI301B | VB_XGI302B)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3267 | flag = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3268 | pVBInfo->Part4Port, |
| 3269 | 0x23); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3270 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3271 | if (!(flag & 0x02)) |
| 3272 | tempbx = tempbx | VB_NoLCD; |
| 3273 | } |
| 3274 | } |
| 3275 | } |
| 3276 | pVBInfo->VBType = tempbx; |
| 3277 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3278 | } |
| 3279 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3280 | void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 3281 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3282 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3283 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3284 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3285 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3286 | if (ModeNo <= 0x13) |
| 3287 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 3288 | else |
| 3289 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3290 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3291 | pVBInfo->SetFlag = 0; |
| 3292 | pVBInfo->ModeType = modeflag & ModeInfoFlag; |
| 3293 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3294 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3295 | if (pVBInfo->VBType & 0xFFFF) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3296 | /* Check Display Device */ |
| 3297 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3298 | tempbx = tempbx | temp; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3299 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3300 | push = temp; |
| 3301 | push = push << 8; |
| 3302 | tempax = temp << 8; |
| 3303 | tempbx = tempbx | tempax; |
| 3304 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA |
| 3305 | | SetInSlaveMode | DisableCRT2Display); |
| 3306 | temp = 0xFFFF ^ temp; |
| 3307 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3308 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3309 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3310 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3311 | if (pVBInfo->IF_DEF_LCDA == 1) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3312 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3313 | if ((pVBInfo->Set_VGAType >= XG20) |
| 3314 | || (pVBInfo->Set_VGAType >= XG40)) { |
| 3315 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3316 | /* if ((pVBInfo->VBType & VB_XGI302B) |
| 3317 | || (pVBInfo->VBType & VB_XGI301LV) |
| 3318 | || (pVBInfo->VBType & VB_XGI302LV) |
| 3319 | || (pVBInfo->VBType & VB_XGI301C)) |
| 3320 | */ |
| 3321 | if (pVBInfo->VBType & |
| 3322 | (VB_XGI302B | |
| 3323 | VB_XGI301LV | |
| 3324 | VB_XGI302LV | |
| 3325 | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3326 | if (temp & EnableDualEdge) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3327 | tempbx |= |
| 3328 | SetCRT2ToDualEdge; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3329 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3330 | if (temp & SetToLCDA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3331 | tempbx |= |
| 3332 | SetCRT2ToLCDA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3333 | } |
| 3334 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3335 | } |
| 3336 | } |
| 3337 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3338 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3339 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3340 | /* [Billy] 07/05/04 */ |
| 3341 | if (((pVBInfo->IF_DEF_LVDS == 0) && |
| 3342 | ((pVBInfo->VBType & VB_XGI301LV) || |
| 3343 | (pVBInfo->VBType & VB_XGI302LV) || |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3344 | (pVBInfo->VBType & VB_XGI301C)))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3345 | if (temp & SetYPbPr) { /* temp = CR38 */ |
| 3346 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3347 | /* shampoo add for new |
| 3348 | * scratch */ |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3349 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3350 | pVBInfo->P3d4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3351 | 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3352 | temp &= YPbPrMode; |
| 3353 | tempbx |= SetCRT2ToHiVisionTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3354 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3355 | if (temp != YPbPrMode1080i) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3356 | tempbx &= |
| 3357 | (~SetCRT2ToHiVisionTV); |
| 3358 | tempbx |= |
| 3359 | SetCRT2ToYPbPr; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3360 | } |
| 3361 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3362 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3363 | /* tempbx |= SetCRT2ToYPbPr; */ |
| 3364 | } |
| 3365 | } |
| 3366 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3367 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3368 | tempax = push; /* restore CR31 */ |
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 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3371 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3372 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 3373 | temp = 0x09FC; |
| 3374 | else |
| 3375 | temp = 0x097C; |
| 3376 | } else { |
| 3377 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 3378 | temp = 0x01FC; |
| 3379 | else |
| 3380 | temp = 0x017C; |
| 3381 | } |
| 3382 | } else { /* 3nd party chip */ |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3383 | temp = SetCRT2ToLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3384 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3385 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3386 | if (!(tempbx & temp)) { |
| 3387 | tempax |= DisableCRT2Display; |
| 3388 | tempbx = 0; |
| 3389 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3390 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3391 | if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ |
| 3392 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 3393 | if (tempbx & SetCRT2ToLCDA) { |
| 3394 | if (tempbx & SetSimuScanMode) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3395 | tempbx &= (~(SetCRT2ToLCD | |
| 3396 | SetCRT2ToRAMDAC | |
| 3397 | SwitchToCRT2)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3398 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3399 | tempbx &= (~(SetCRT2ToLCD | |
| 3400 | SetCRT2ToRAMDAC | |
| 3401 | SetCRT2ToTV | |
| 3402 | SwitchToCRT2)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3403 | } |
| 3404 | } |
| 3405 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3406 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3407 | /* shampoo add */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3408 | /* for driver abnormal */ |
| 3409 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3410 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 3411 | if (tempbx & SetCRT2ToRAMDAC) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3412 | tempbx &= (0xFF00 | |
| 3413 | SetCRT2ToRAMDAC | |
| 3414 | SwitchToCRT2 | |
| 3415 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3416 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3417 | } |
| 3418 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3419 | tempbx &= (~(SetCRT2ToRAMDAC | |
| 3420 | SetCRT2ToLCD | |
| 3421 | SetCRT2ToTV)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3422 | } |
| 3423 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3424 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3425 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 3426 | if (tempbx & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3427 | tempbx &= (0xFF00 | |
| 3428 | SetCRT2ToLCD | |
| 3429 | SwitchToCRT2 | |
| 3430 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3431 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3432 | } |
| 3433 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3434 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3435 | if (tempbx & SetCRT2ToSCART) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3436 | tempbx &= (0xFF00 | |
| 3437 | SetCRT2ToSCART | |
| 3438 | SwitchToCRT2 | |
| 3439 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3440 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3441 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3442 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3443 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3444 | if (tempbx & SetCRT2ToYPbPr) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3445 | tempbx &= (0xFF00 | |
| 3446 | SwitchToCRT2 | |
| 3447 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3448 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3449 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3450 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 3451 | if (tempbx & SetCRT2ToHiVisionTV) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3452 | tempbx &= (0xFF00 | |
| 3453 | SetCRT2ToHiVisionTV | |
| 3454 | SwitchToCRT2 | |
| 3455 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3456 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3457 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3458 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 3459 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) |
| 3460 | tempbx = DisableCRT2Display; |
| 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 (!(tempbx & DisableCRT2Display)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3464 | if ((!(tempbx & DriverMode)) || |
| 3465 | (!(modeflag & CRT2Mode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3466 | if (pVBInfo->IF_DEF_LCDA == 1) { |
| 3467 | if (!(tempbx & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3468 | tempbx |= (SetInSlaveMode | |
| 3469 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3470 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3471 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3472 | if (pVBInfo->IF_DEF_VideoCapture == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3473 | if (((HwDeviceExtension->jChipType == |
| 3474 | XG40) && |
| 3475 | (pVBInfo->Set_VGAType == XG40)) || |
| 3476 | ((HwDeviceExtension->jChipType == |
| 3477 | XG41) && |
| 3478 | (pVBInfo->Set_VGAType == XG41)) || |
| 3479 | ((HwDeviceExtension->jChipType == |
| 3480 | XG42) && |
| 3481 | (pVBInfo->Set_VGAType == XG42)) || |
| 3482 | ((HwDeviceExtension->jChipType == |
| 3483 | XG45) && |
| 3484 | (pVBInfo->Set_VGAType == XG45))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3485 | if (ModeNo <= 13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3486 | if (!(tempbx & |
| 3487 | SetCRT2ToRAMDAC)) { |
| 3488 | /*CRT2 not need |
| 3489 | * to support*/ |
| 3490 | tempbx &= |
| 3491 | (0x00FF | |
| 3492 | (~SetInSlaveMode)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3493 | pVBInfo->SetFlag |
| 3494 | |= EnableVCMode; |
| 3495 | } |
| 3496 | } |
| 3497 | } |
| 3498 | } |
| 3499 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3500 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3501 | /* LCD+TV can't support in slave mode |
| 3502 | * (Force LCDA+TV->LCDB) */ |
| 3503 | if ((tempbx & SetInSlaveMode) && |
| 3504 | (tempbx & SetCRT2ToLCDA)) { |
| 3505 | tempbx ^= (SetCRT2ToLCD | |
| 3506 | SetCRT2ToLCDA | |
| 3507 | SetCRT2ToDualEdge); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3508 | pVBInfo->SetFlag |= ReserveTVOption; |
| 3509 | } |
| 3510 | } |
| 3511 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3512 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3513 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3514 | } |
| 3515 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3516 | void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 3517 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3518 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3519 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3520 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3521 | tempbx = 0; |
| 3522 | resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3523 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3524 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3525 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3526 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 3527 | St_ModeFlag; /* si+St_ModeFlag */ |
| 3528 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 3529 | St_ResInfo; /* si+St_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3530 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3531 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 3532 | Ext_ModeFlag; |
| 3533 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 3534 | Ext_RESINFO; /* si+Ext_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3535 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3536 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3537 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3538 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3539 | tempbx = temp; |
| 3540 | if (tempbx & SetPALTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3541 | tempbx &= (SetCHTVOverScan | |
| 3542 | SetPALMTV | |
| 3543 | SetPALNTV | |
| 3544 | SetPALTV); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3545 | if (tempbx & SetPALMTV) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3546 | /* set to NTSC if PAL-M */ |
| 3547 | tempbx &= ~SetPALTV; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3548 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3549 | tempbx &= (SetCHTVOverScan | |
| 3550 | SetNTSCJ | |
| 3551 | SetPALTV); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3552 | /* |
| 3553 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3554 | //PAL-M/PAL-N Info |
| 3555 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
| 3556 | //00:PAL, 01:PAL-M, 10:PAL-N |
| 3557 | temp2 = (index1 & 0xC0) >> 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3558 | tempbx |= temp2; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3559 | if (temp2 & 0x02) //PAL-M |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3560 | tempbx &= (~SetPALTV); |
| 3561 | } |
| 3562 | */ |
| 3563 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3564 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3565 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3566 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 3567 | tempbx |= SetPALTV; |
| 3568 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3569 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3570 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3571 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3572 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3573 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3574 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3575 | if (index1 == YPbPrMode525i) |
| 3576 | tempbx |= SetYPbPrMode525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3577 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3578 | if (index1 == YPbPrMode525p) |
| 3579 | tempbx = tempbx | SetYPbPrMode525p; |
| 3580 | if (index1 == YPbPrMode750p) |
| 3581 | tempbx = tempbx | SetYPbPrMode750p; |
| 3582 | } |
| 3583 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3584 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3585 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 3586 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 3587 | tempbx = tempbx | SetYPbPrMode1080i | SetPALTV; |
| 3588 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3589 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3590 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3591 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 3592 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3593 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3594 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3595 | if (!(tempbx & SetPALTV) && |
| 3596 | (modeflag > 13) && |
| 3597 | (resinfo == 8)) /* NTSC 1024x768, */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3598 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3600 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3601 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3602 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 3603 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 3604 | tempbx &= (~RPLLDIV2XO); |
| 3605 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3606 | if (tempbx & |
| 3607 | (SetYPbPrMode525p | SetYPbPrMode750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3608 | tempbx &= (~RPLLDIV2XO); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3609 | else if (!(pVBInfo->VBType & |
| 3610 | (VB_XGI301B | |
| 3611 | VB_XGI302B | |
| 3612 | VB_XGI301LV | |
| 3613 | VB_XGI302LV | |
| 3614 | VB_XGI301C))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3615 | if (tempbx & TVSimuMode) |
| 3616 | tempbx &= (~RPLLDIV2XO); |
| 3617 | } |
| 3618 | } |
| 3619 | } |
| 3620 | } |
| 3621 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3622 | } |
| 3623 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 3624 | unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3625 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3626 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3627 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3628 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3629 | pVBInfo->LCDResInfo = 0; |
| 3630 | pVBInfo->LCDTypeInfo = 0; |
| 3631 | pVBInfo->LCDInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3632 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3633 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3634 | /* si+St_ModeFlag // */ |
| 3635 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3636 | } else { |
| 3637 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3638 | /* si+Ext_ResInfo // */ |
| 3639 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3640 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3641 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3642 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3643 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3644 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3645 | if (tempbx == 0) |
| 3646 | tempbx = Panel1024x768; /* default */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3647 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3648 | /* LCD75 [2003/8/22] Vicent */ |
| 3649 | if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) { |
| 3650 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3651 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3652 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 3653 | tempax &= 0x0F; |
| 3654 | else |
| 3655 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3656 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3657 | if ((resinfo == 6) || (resinfo == 9)) { |
| 3658 | if (tempax >= 3) |
| 3659 | tempbx |= PanelRef75Hz; |
| 3660 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 3661 | if (tempax >= 4) |
| 3662 | tempbx |= PanelRef75Hz; |
| 3663 | } |
| 3664 | } |
| 3665 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3666 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3667 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3668 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3669 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3670 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3671 | if (pVBInfo->IF_DEF_OEMUtil == 1) |
| 3672 | pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3673 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3674 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 3675 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3676 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3677 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3678 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3679 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3680 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3681 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3682 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3683 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding)) |
| 3684 | temp &= ~EnableScalingLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3685 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3686 | tempbx |= temp; |
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 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3689 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3690 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3691 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3692 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
| 3693 | if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType |
| 3694 | & VB_XGI301C)) && (tempax & LCDDualLink)) { |
| 3695 | tempbx |= SetLCDDualLink; |
| 3696 | } |
| 3697 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3698 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3699 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3700 | if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo |
| 3701 | & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo |
| 3702 | == 9) && (!(tempbx & EnableScalingLCD))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3703 | /* set to center in 1280x1024 LCDB for Panel1400x1050 */ |
| 3704 | tempbx |= SetLCDtoNonExpanding; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3705 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3706 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3707 | /* |
| 3708 | if (tempax & LCDBToA) { |
| 3709 | tempbx |= SetLCDBToA; |
| 3710 | } |
| 3711 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3712 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3713 | if (pVBInfo->IF_DEF_ExpLink == 1) { |
| 3714 | if (modeflag & HalfDCLK) { |
| 3715 | /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */ |
| 3716 | if (!(tempbx & SetLCDtoNonExpanding)) { |
| 3717 | tempbx |= EnableLVDSDDA; |
| 3718 | } else { |
| 3719 | if (ModeNo > 0x13) { |
| 3720 | if (pVBInfo->LCDResInfo |
| 3721 | == Panel1024x768) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3722 | if (resinfo == 4) {/* 512x384 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3723 | tempbx |= EnableLVDSDDA; |
| 3724 | } |
| 3725 | } |
| 3726 | } |
| 3727 | } |
| 3728 | } |
| 3729 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3730 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3731 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3732 | if (pVBInfo->VBInfo & SetNotSimuMode) |
| 3733 | tempbx |= LCDVESATiming; |
| 3734 | } else { |
| 3735 | tempbx |= LCDVESATiming; |
| 3736 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3737 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3738 | pVBInfo->LCDInfo = 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->IF_DEF_PWD == 1) { |
| 3741 | if (pVBInfo->LCDInfo & SetPWDEnable) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3742 | if ((pVBInfo->VBType & VB_XGI302LV) || |
| 3743 | (pVBInfo->VBType & VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3744 | if (!(tempax & PWDEnable)) |
| 3745 | pVBInfo->LCDInfo &= ~SetPWDEnable; |
| 3746 | } |
| 3747 | } |
| 3748 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3749 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3750 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3751 | if (tempax & (LockLCDBToA | StLCDBToA)) { |
| 3752 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3753 | if (!(tempax & LockLCDBToA)) { |
| 3754 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3755 | pVBInfo->VBInfo &= |
| 3756 | ~(SetSimuScanMode | |
| 3757 | SetInSlaveMode | |
| 3758 | SetCRT2ToLCD); |
| 3759 | pVBInfo->VBInfo |= |
| 3760 | SetCRT2ToLCDA | |
| 3761 | SetCRT2ToDualEdge; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3762 | } |
| 3763 | } |
| 3764 | } |
| 3765 | } |
| 3766 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3767 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3768 | /* |
| 3769 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3770 | if (tempax & (LockLCDBToA | StLCDBToA)) { |
| 3771 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3772 | if (!((!(tempax & LockLCDBToA)) && |
| 3773 | (ModeNo > 0x13))) { |
| 3774 | pVBInfo->VBInfo &= |
| 3775 | ~(SetSimuScanMode | |
| 3776 | SetInSlaveMode | |
| 3777 | SetCRT2ToLCD); |
| 3778 | pVBInfo->VBInfo |= |
| 3779 | SetCRT2ToLCDA | |
| 3780 | SetCRT2ToDualEdge; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3781 | } |
| 3782 | } |
| 3783 | } |
| 3784 | } |
| 3785 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3786 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3787 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3788 | } |
| 3789 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 3790 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3791 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
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 (ModeNo <= 5) |
| 3794 | ModeNo |= 1; |
| 3795 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3796 | /* for (*ModeIdIndex=0; |
| 3797 | *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) |
| 3798 | / sizeof(struct XGI_StStruct); |
| 3799 | (*ModeIdIndex)++) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3800 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3801 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
| 3802 | ModeNo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3803 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3804 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
| 3805 | 0xFF) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3806 | return 0; |
| 3807 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3808 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3809 | if (ModeNo == 0x07) |
| 3810 | (*ModeIdIndex)++; /* 400 lines */ |
| 3811 | if (ModeNo <= 3) |
| 3812 | (*ModeIdIndex) += 2; /* 400 lines */ |
| 3813 | /* else 350 lines */ |
| 3814 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3815 | /* for (*ModeIdIndex=0; |
| 3816 | *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) |
| 3817 | / sizeof(struct XGI_ExtStruct); |
| 3818 | (*ModeIdIndex)++) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3819 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3820 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
| 3821 | ModeNo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3822 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3823 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
| 3824 | 0xFF) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3825 | return 0; |
| 3826 | } |
| 3827 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3828 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3829 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3830 | } |
| 3831 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3832 | /* win2000 MM adapter not support standard mode! */ |
| 3833 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3834 | #if 0 |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3835 | static unsigned char XGINew_CheckMemorySize( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3836 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3837 | unsigned short ModeNo, |
| 3838 | unsigned short ModeIdIndex, |
| 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 memorysize, modeflag, temp, temp1, tmp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3842 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3843 | /* |
| 3844 | if ((HwDeviceExtension->jChipType == XGI_650) || |
| 3845 | (HwDeviceExtension->jChipType == XGI_650M)) { |
| 3846 | return 1; |
| 3847 | } |
| 3848 | */ |
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 (ModeNo <= 0x13) |
| 3851 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 3852 | else |
| 3853 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3854 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3855 | /* ModeType = modeflag&ModeInfoFlag; // Get mode type */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3856 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3857 | memorysize = modeflag & MemoryInfoFlag; |
| 3858 | memorysize = memorysize > MemorySizeShift; |
| 3859 | memorysize++; /* Get memory size */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3860 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3861 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3862 | tmp = temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3863 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3864 | if (HwDeviceExtension->jChipType == XG40) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3865 | /* memory size per channel SR14[7:4] */ |
| 3866 | temp = 1 << ((temp & 0x0F0) >> 4); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3867 | if ((tmp & 0x0c) == 0x0C) { /* Qual channels */ |
| 3868 | temp <<= 2; |
| 3869 | } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */ |
| 3870 | temp <<= 1; |
| 3871 | } |
| 3872 | } else if (HwDeviceExtension->jChipType == XG42) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3873 | /* memory size per channel SR14[7:4] */ |
| 3874 | temp = 1 << ((temp & 0x0F0) >> 4); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3875 | if ((tmp & 0x04) == 0x04) { /* Dual channels */ |
| 3876 | temp <<= 1; |
| 3877 | } |
| 3878 | } else if (HwDeviceExtension->jChipType == XG45) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3879 | /* memory size per channel SR14[7:4] */ |
| 3880 | temp = 1 << ((temp & 0x0F0) >> 4); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3881 | if ((tmp & 0x0c) == 0x0C) { /* Qual channels */ |
| 3882 | temp <<= 2; |
| 3883 | } else if ((tmp & 0x0c) == 0x08) { /* triple channels */ |
| 3884 | temp1 = temp; |
| 3885 | temp <<= 1; |
| 3886 | temp += temp1; |
| 3887 | } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */ |
| 3888 | temp <<= 1; |
| 3889 | } |
| 3890 | } |
| 3891 | if (temp < memorysize) |
| 3892 | return 0; |
| 3893 | else |
| 3894 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3895 | } |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3896 | #endif |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3897 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3898 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3899 | void XGINew_IsLowResolution(unsigned short ModeNo, |
| 3900 | unsigned short ModeIdIndex, |
| 3901 | unsigned char XGINew_CheckMemorySize( |
| 3902 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3903 | unsigned short ModeNo, |
| 3904 | unsigned short ModeIdIndex, |
| 3905 | struct vb_device_info *pVBInfo) |
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 | unsigned short data ; |
| 3908 | unsigned short ModeFlag ; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3909 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3910 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3911 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3912 | xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3913 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3914 | if (ModeNo > 0x13) { |
| 3915 | ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3916 | if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3917 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3918 | data |= 0x80; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3919 | xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3920 | data = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3921 | data &= 0xF7; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3922 | xgifb_reg_set(pVBInfo->P3c4, 0x01, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3923 | } |
| 3924 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3925 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3926 | */ |
| 3927 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3928 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 3929 | { |
| 3930 | unsigned char ujRet = 0; |
| 3931 | unsigned char i = 0; |
| 3932 | |
| 3933 | for (i = 0; i < 8; i++) { |
| 3934 | ujRet = ujRet << 1; |
| 3935 | /* ujRet |= GETBITS(ujDate >> i, 0:0); */ |
| 3936 | ujRet |= (ujDate >> i) & 1; |
| 3937 | } |
| 3938 | |
| 3939 | return ujRet; |
| 3940 | } |
| 3941 | |
| 3942 | /*----------------------------------------------------------------------------*/ |
| 3943 | /* output */ |
| 3944 | /* bl[5] : LVDS signal */ |
| 3945 | /* bl[1] : LVDS backlight */ |
| 3946 | /* bl[0] : LVDS VDD */ |
| 3947 | /*----------------------------------------------------------------------------*/ |
| 3948 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 3949 | { |
| 3950 | unsigned char CR4A, temp; |
| 3951 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3952 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3953 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3954 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3955 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3956 | |
| 3957 | temp = XG21GPIODataTransfer(temp); |
| 3958 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3959 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3960 | return temp; |
| 3961 | } |
| 3962 | |
| 3963 | /*----------------------------------------------------------------------------*/ |
| 3964 | /* output */ |
| 3965 | /* bl[5] : LVDS signal */ |
| 3966 | /* bl[1] : LVDS backlight */ |
| 3967 | /* bl[0] : LVDS VDD */ |
| 3968 | /*----------------------------------------------------------------------------*/ |
| 3969 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 3970 | { |
| 3971 | unsigned char CR4A, CRB4, temp; |
| 3972 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3973 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3974 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3975 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3976 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3977 | |
| 3978 | temp &= 0x0C; |
| 3979 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3980 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3981 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3982 | temp |= ((CRB4 & 0x04) << 3); |
| 3983 | return temp; |
| 3984 | } |
| 3985 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3986 | void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, |
| 3987 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3988 | { |
| 3989 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3990 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3991 | if (pXGIHWDE->jChipType == XG21) { |
| 3992 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 3993 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3994 | /* LVDS VDD on */ |
| 3995 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3996 | XGI_XG21SetPanelDelay(2, pVBInfo); |
| 3997 | } |
| 3998 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3999 | /* LVDS signal on */ |
| 4000 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4001 | XGI_XG21SetPanelDelay(3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4002 | /* LVDS backlight on */ |
| 4003 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4004 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4005 | /* DVO/DVI signal on */ |
| 4006 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4007 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4008 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4009 | } |
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 (pXGIHWDE->jChipType == XG27) { |
| 4012 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 4013 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4014 | /* LVDS VDD on */ |
| 4015 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4016 | XGI_XG21SetPanelDelay(2, pVBInfo); |
| 4017 | } |
| 4018 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4019 | /* LVDS signal on */ |
| 4020 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4021 | XGI_XG21SetPanelDelay(3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4022 | /* LVDS backlight on */ |
| 4023 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4024 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4025 | /* DVO/DVI signal on */ |
| 4026 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4027 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4028 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4029 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4030 | } |
| 4031 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4032 | void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, |
| 4033 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4034 | { |
| 4035 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4036 | if (pXGIHWDE->jChipType == XG21) { |
| 4037 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4038 | /* LVDS backlight off */ |
| 4039 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4040 | XGI_XG21SetPanelDelay(3, pVBInfo); |
| 4041 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4042 | /* DVO/DVI signal off */ |
| 4043 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4044 | } |
| 4045 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4046 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4047 | if (pXGIHWDE->jChipType == XG27) { |
| 4048 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4049 | /* LVDS backlight off */ |
| 4050 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4051 | XGI_XG21SetPanelDelay(3, pVBInfo); |
| 4052 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4053 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4054 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4055 | /* DVO/DVI signal off */ |
| 4056 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4057 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4058 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4059 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4060 | } |
| 4061 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4062 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4063 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4064 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4065 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4066 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4067 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4068 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4069 | } |
| 4070 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4071 | #if 0 |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4072 | static void XGI_WaitDisplay(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4073 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4074 | while (!(inb(pVBInfo->P3da) & 0x01)) |
| 4075 | ; |
| 4076 | while (inb(pVBInfo->P3da) & 0x01) |
| 4077 | ; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4078 | } |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4079 | #endif |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4080 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4081 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4082 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4083 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4084 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4085 | } |
| 4086 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4087 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 4088 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4089 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4090 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4091 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4092 | /* reserve CR34 for CRT1 Mode No */ |
| 4093 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4094 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 4095 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4096 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4097 | } |
| 4098 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4099 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
| 4100 | unsigned short ModeIdIndex, |
| 4101 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4102 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4103 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4104 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4105 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 4106 | if (ModeNo <= 0x13) { |
| 4107 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 4108 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4109 | /* si+St_ResInfo */ |
| 4110 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4111 | } else { |
| 4112 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4113 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4114 | /* si+St_ModeFlag */ |
| 4115 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4116 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4117 | /* |
| 4118 | if (pVBInfo->IF_DEF_FSTN) { |
| 4119 | xres *= 2; |
| 4120 | yres *= 2; |
| 4121 | } else { |
| 4122 | */ |
| 4123 | if (modeflag & HalfDCLK) |
| 4124 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4125 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4126 | if (modeflag & DoubleScanMode) |
| 4127 | yres *= 2; |
| 4128 | /* } */ |
| 4129 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4130 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4131 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4132 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 4133 | if (pVBInfo->LCDResInfo == Panel1600x1200) { |
| 4134 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4135 | if (yres == 1024) |
| 4136 | yres = 1056; |
| 4137 | } |
| 4138 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4139 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4140 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 4141 | if (yres == 400) |
| 4142 | yres = 405; |
| 4143 | else if (yres == 350) |
| 4144 | yres = 360; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4145 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4146 | if (pVBInfo->LCDInfo & LCDVESATiming) { |
| 4147 | if (yres == 360) |
| 4148 | yres = 375; |
| 4149 | } |
| 4150 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4151 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4152 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 4153 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4154 | if (!(pVBInfo->LCDInfo |
| 4155 | & LCDNonExpanding)) { |
| 4156 | if (yres == 350) |
| 4157 | yres = 357; |
| 4158 | else if (yres == 400) |
| 4159 | yres = 420; |
| 4160 | else if (yres == 480) |
| 4161 | yres = 525; |
| 4162 | } |
| 4163 | } |
| 4164 | } |
| 4165 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4166 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4167 | if (xres == 720) |
| 4168 | xres = 640; |
| 4169 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4170 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4171 | pVBInfo->VGAHDE = xres; |
| 4172 | pVBInfo->HDE = xres; |
| 4173 | pVBInfo->VGAVDE = yres; |
| 4174 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4175 | } |
| 4176 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4177 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4178 | { |
| 4179 | |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 4180 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && |
| 4181 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4182 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4183 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4184 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4185 | } |
| 4186 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4187 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
| 4188 | unsigned short ModeIdIndex, |
| 4189 | unsigned short RefreshRateTableIndex, |
| 4190 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4191 | { |
| 4192 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
| 4193 | StandTableIndex, CRT1Index; |
| 4194 | |
| 4195 | pVBInfo->RVBHCMAX = 1; |
| 4196 | pVBInfo->RVBHCFACT = 1; |
| 4197 | |
| 4198 | if (ModeNo <= 0x13) { |
| 4199 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 4200 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
| 4201 | tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0]; |
| 4202 | tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6]; |
| 4203 | temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
| 4204 | } else { |
| 4205 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4206 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 4207 | Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4208 | CRT1Index &= IndexMask; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4209 | temp1 = (unsigned short) pVBInfo-> |
| 4210 | XGINEWUB_CRT1Table[CRT1Index].CR[0]; |
| 4211 | temp2 = (unsigned short) pVBInfo-> |
| 4212 | XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4213 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4214 | tempbx = (unsigned short) pVBInfo-> |
| 4215 | XGINEWUB_CRT1Table[CRT1Index].CR[8]; |
| 4216 | tempcx = (unsigned short) pVBInfo-> |
| 4217 | XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4218 | tempcx &= 0x0100; |
| 4219 | tempcx = tempcx << 2; |
| 4220 | tempbx |= tempcx; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4221 | temp1 = (unsigned short) pVBInfo-> |
| 4222 | XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4223 | } |
| 4224 | |
| 4225 | if (temp1 & 0x01) |
| 4226 | tempbx |= 0x0100; |
| 4227 | |
| 4228 | if (temp1 & 0x20) |
| 4229 | tempbx |= 0x0200; |
| 4230 | tempax += 5; |
| 4231 | |
| 4232 | if (modeflag & Charx8Dot) |
| 4233 | tempax *= 8; |
| 4234 | else |
| 4235 | tempax *= 9; |
| 4236 | |
| 4237 | pVBInfo->VGAHT = tempax; |
| 4238 | pVBInfo->HT = tempax; |
| 4239 | tempbx++; |
| 4240 | pVBInfo->VGAVT = tempbx; |
| 4241 | pVBInfo->VT = tempbx; |
| 4242 | } |
| 4243 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4244 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4245 | unsigned short RefreshRateTableIndex, |
| 4246 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4247 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4248 | unsigned short tempax = 0, tempbx, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4249 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4250 | struct XGI_LCDDataStruct *LCDPtr = NULL; |
| 4251 | struct XGI_TVDataStruct *TVPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4252 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4253 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4254 | /* si+St_ResInfo */ |
| 4255 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4256 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4257 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4258 | /* si+Ext_ResInfo */ |
| 4259 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4260 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4261 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4262 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4263 | pVBInfo->NewFlickerMode = 0; |
| 4264 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4265 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4266 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4267 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4268 | pVBInfo); |
| 4269 | return; |
| 4270 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4271 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4272 | tempbx = 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4273 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4274 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 4275 | LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx, |
| 4276 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4277 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4278 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4279 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 4280 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 4281 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 4282 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 4283 | pVBInfo->HT = LCDPtr->LCDHT; |
| 4284 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4285 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4286 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 4287 | tempax = 1024; |
| 4288 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4289 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4290 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4291 | if (pVBInfo->VGAVDE == 357) |
| 4292 | tempbx = 527; |
| 4293 | else if (pVBInfo->VGAVDE == 420) |
| 4294 | tempbx = 620; |
| 4295 | else if (pVBInfo->VGAVDE == 525) |
| 4296 | tempbx = 775; |
| 4297 | else if (pVBInfo->VGAVDE == 600) |
| 4298 | tempbx = 775; |
| 4299 | /* else if (pVBInfo->VGAVDE==350) tempbx=560; */ |
| 4300 | /* else if (pVBInfo->VGAVDE==400) tempbx=640; */ |
| 4301 | else |
| 4302 | tempbx = 768; |
| 4303 | } else |
| 4304 | tempbx = 768; |
| 4305 | } else if (pVBInfo->LCDResInfo == Panel1024x768x75) { |
| 4306 | tempax = 1024; |
| 4307 | tempbx = 768; |
| 4308 | } else if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 4309 | tempax = 1280; |
| 4310 | if (pVBInfo->VGAVDE == 360) |
| 4311 | tempbx = 768; |
| 4312 | else if (pVBInfo->VGAVDE == 375) |
| 4313 | tempbx = 800; |
| 4314 | else if (pVBInfo->VGAVDE == 405) |
| 4315 | tempbx = 864; |
| 4316 | else |
| 4317 | tempbx = 1024; |
| 4318 | } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) { |
| 4319 | tempax = 1280; |
| 4320 | tempbx = 1024; |
| 4321 | } else if (pVBInfo->LCDResInfo == Panel1280x960) { |
| 4322 | tempax = 1280; |
| 4323 | if (pVBInfo->VGAVDE == 350) |
| 4324 | tempbx = 700; |
| 4325 | else if (pVBInfo->VGAVDE == 400) |
| 4326 | tempbx = 800; |
| 4327 | else if (pVBInfo->VGAVDE == 1024) |
| 4328 | tempbx = 960; |
| 4329 | else |
| 4330 | tempbx = 960; |
| 4331 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 4332 | tempax = 1400; |
| 4333 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4334 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4335 | if (pVBInfo->VGAVDE == 1024) { |
| 4336 | tempax = 1280; |
| 4337 | tempbx = 1024; |
| 4338 | } |
| 4339 | } else if (pVBInfo->LCDResInfo == Panel1600x1200) { |
| 4340 | tempax = 1600; |
| 4341 | tempbx = 1200; /* alan 10/14/2003 */ |
| 4342 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4343 | if (pVBInfo->VGAVDE == 350) |
| 4344 | tempbx = 875; |
| 4345 | else if (pVBInfo->VGAVDE == 400) |
| 4346 | tempbx = 1000; |
| 4347 | } |
| 4348 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4349 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4350 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 4351 | tempax = pVBInfo->VGAHDE; |
| 4352 | tempbx = pVBInfo->VGAVDE; |
| 4353 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4354 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4355 | pVBInfo->HDE = tempax; |
| 4356 | pVBInfo->VDE = tempbx; |
| 4357 | return; |
| 4358 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4359 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4360 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
| 4361 | tempbx = 4; |
| 4362 | TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx, |
| 4363 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4364 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4365 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4366 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 4367 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 4368 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 4369 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 4370 | pVBInfo->HDE = TVPtr->TVHDE; |
| 4371 | pVBInfo->VDE = TVPtr->TVVDE; |
| 4372 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 4373 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4374 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4375 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4376 | if (resinfo == 0x08) |
| 4377 | pVBInfo->NewFlickerMode = 0x40; |
| 4378 | else if (resinfo == 0x09) |
| 4379 | pVBInfo->NewFlickerMode = 0x40; |
| 4380 | else if (resinfo == 0x12) |
| 4381 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4382 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4383 | if (pVBInfo->VGAVDE == 350) |
| 4384 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4385 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4386 | tempax = ExtHiTVHT; |
| 4387 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4388 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4389 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 4390 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4391 | tempax = StHiTVHT; |
| 4392 | tempbx = StHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4393 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4394 | if (!(modeflag & Charx8Dot)) { |
| 4395 | tempax = StHiTextTVHT; |
| 4396 | tempbx = StHiTextTVVT; |
| 4397 | } |
| 4398 | } |
| 4399 | } |
| 4400 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 4401 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
| 4402 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 4403 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 4404 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4405 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4406 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
| 4407 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 4408 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
| 4409 | } else if (pVBInfo->TVInfo & SetYPbPrMode525i) { |
| 4410 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 4411 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 4412 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 4413 | tempax = NTSC1024x768HT; |
| 4414 | } |
| 4415 | } else { |
| 4416 | tempax = PALHT; |
| 4417 | tempbx = PALVT; |
| 4418 | if (!(pVBInfo->TVInfo & SetPALTV)) { |
| 4419 | tempax = NTSCHT; |
| 4420 | tempbx = NTSCVT; |
| 4421 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 4422 | tempax = NTSC1024x768HT; |
| 4423 | } |
| 4424 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4425 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4426 | pVBInfo->HT = tempax; |
| 4427 | pVBInfo->VT = tempbx; |
| 4428 | return; |
| 4429 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4430 | } |
| 4431 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4432 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4433 | unsigned short RefreshRateTableIndex, |
| 4434 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4435 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 4436 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4437 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4438 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 4439 | pVBInfo); |
| 4440 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 4441 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4442 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4443 | if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */ |
| 4444 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4445 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 4446 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 4447 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4448 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4449 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 4450 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4451 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4452 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4453 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4454 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4455 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4456 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4457 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4458 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4459 | } |
| 4460 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4461 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
| 4462 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4463 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4464 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 4465 | short index; |
| 4466 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4467 | |
| 4468 | if (ModeNo <= 0x13) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4469 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4470 | else |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4471 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4472 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4473 | index = (modeflag & ModeInfoFlag) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4474 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4475 | if (index < 0) |
| 4476 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4477 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4478 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4479 | } |
| 4480 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4481 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 4482 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4483 | unsigned short RefreshRateTableIndex, |
| 4484 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4485 | struct vb_device_info *pVBInfo) |
| 4486 | { |
| 4487 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 4488 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 4489 | |
| 4490 | modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 4491 | if (ModeNo <= 0x14) |
| 4492 | infoflag = 0; |
| 4493 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4494 | infoflag = pVBInfo-> |
| 4495 | RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4496 | |
| 4497 | index = (modeinfo >> 8) & 0xFF; |
| 4498 | |
| 4499 | temp = pVBInfo->ScreenOffset[index]; |
| 4500 | |
| 4501 | if (infoflag & InterlaceMode) |
| 4502 | temp = temp << 1; |
| 4503 | |
| 4504 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 4505 | |
| 4506 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 4507 | temp = ModeNo - 0x7C; |
| 4508 | colordepth = ColorDepth[temp]; |
| 4509 | temp = 0x6B; |
| 4510 | if (infoflag & InterlaceMode) |
| 4511 | temp = temp << 1; |
| 4512 | return temp * colordepth; |
| 4513 | } else { |
| 4514 | return temp * colordepth; |
| 4515 | } |
| 4516 | } |
| 4517 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4518 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 4519 | unsigned short ModeIdIndex, |
| 4520 | unsigned short RefreshRateTableIndex, |
| 4521 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4522 | struct vb_device_info *pVBInfo) |
| 4523 | { |
| 4524 | unsigned short offset; |
| 4525 | unsigned char temp; |
| 4526 | |
| 4527 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 4528 | return; |
| 4529 | |
| 4530 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4531 | HwDeviceExtension, pVBInfo); |
| 4532 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4533 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4534 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4535 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4536 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4537 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4538 | } |
| 4539 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4540 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4541 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4542 | /* threshold high ,disable auto threshold */ |
| 4543 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 4544 | /* threshold low default 04h */ |
| 4545 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4546 | } |
| 4547 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4548 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4549 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4550 | unsigned short RefreshRateTableIndex, |
| 4551 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4552 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4553 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4554 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4555 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4556 | CRT1Index = pVBInfo-> |
| 4557 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4558 | CRT1Index &= IndexMask; |
| 4559 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4560 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4561 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4562 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4563 | HwDeviceExtension, pVBInfo); |
| 4564 | XGI_SetCRT2FIFO(pVBInfo); |
| 4565 | /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4566 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4567 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4568 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4569 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4570 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 4571 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4572 | } |
| 4573 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4574 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4575 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4576 | unsigned short RefreshRateTableIndex, |
| 4577 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4578 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4579 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
| 4580 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4581 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4582 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4583 | CRT1Index = pVBInfo-> |
| 4584 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4585 | CRT1Index &= IndexMask; |
| 4586 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4587 | } |
| 4588 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4589 | if (ModeNo <= 0x13) |
| 4590 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 4591 | else |
| 4592 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4593 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4594 | /* bainy change table name */ |
| 4595 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4596 | /* BTVGA2HT 0x08,0x09 */ |
| 4597 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4598 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4599 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4600 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4601 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 4602 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4603 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4604 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 4605 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 4606 | tempcx = tempcx >> 1; |
| 4607 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 4608 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4609 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4610 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4611 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4612 | tempbx |= ((pVBInfo-> |
| 4613 | XGINEWUB_CRT1Table[CRT1Index].CR[14] & |
| 4614 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4615 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 4616 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
| 4617 | tempcx &= 0x1F; |
| 4618 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15]; |
| 4619 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 4620 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 4621 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4622 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4623 | tempbx += 4; |
| 4624 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4625 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4626 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 4627 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4628 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4629 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4630 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4631 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4632 | } else { |
| 4633 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4634 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4635 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4636 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4637 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 4638 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4639 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4640 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 4641 | pushbx = pVBInfo->VGAHDE + 16; |
| 4642 | tempcx = tempcx >> 1; |
| 4643 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 4644 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4645 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4646 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4647 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4648 | tempbx |= ((pVBInfo-> |
| 4649 | XGINEWUB_CRT1Table[CRT1Index].CR[5] & |
| 4650 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4651 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 4652 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
| 4653 | tempcx &= 0x1F; |
| 4654 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6]; |
| 4655 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 4656 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 4657 | tempbx += 16; |
| 4658 | tempcx += 16; |
| 4659 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4660 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4661 | if (tempcx > pVBInfo->VGAHT) |
| 4662 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4663 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4664 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4665 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4666 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4667 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4668 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 4669 | tempbx = pushbx; |
| 4670 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 4671 | tempax |= (tempbx & 0xFF00); |
| 4672 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4673 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4674 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4675 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4676 | tempcx = (pVBInfo->VGAVT - 1); |
| 4677 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4678 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4679 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4680 | tempbx = pVBInfo->VGAVDE - 1; |
| 4681 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4682 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4683 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 4684 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4685 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4686 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4687 | tempax = pVBInfo->VGAVDE; |
| 4688 | tempbx = pVBInfo->VGAVDE; |
| 4689 | tempcx = pVBInfo->VGAVT; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4690 | /* BTVGA2VRS 0x10,0x11 */ |
| 4691 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 4692 | /* BTVGA2VRE 0x11 */ |
| 4693 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4694 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4695 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4696 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; |
| 4697 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4698 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4699 | if (temp & 0x04) |
| 4700 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4701 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4702 | if (temp & 0x080) |
| 4703 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4704 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4705 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4706 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4707 | if (temp & 0x08) |
| 4708 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4709 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4710 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; |
| 4711 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 4712 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4713 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4714 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4715 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4716 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 4717 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4718 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4719 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4720 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4721 | if (modeflag & DoubleScanMode) |
| 4722 | tempax |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4723 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4724 | if (modeflag & HalfDCLK) |
| 4725 | tempax |= 0x40; |
| 4726 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4727 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4728 | } |
| 4729 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4730 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 4731 | { |
| 4732 | unsigned long tempax, tempbx; |
| 4733 | |
| 4734 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 4735 | & 0xFFFF; |
| 4736 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 4737 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 4738 | |
| 4739 | return (unsigned short) tempax; |
| 4740 | } |
| 4741 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4742 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4743 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4744 | unsigned short RefreshRateTableIndex, |
| 4745 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4746 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4747 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
| 4748 | modeflag, CRT1Index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4749 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4750 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4751 | /* si+St_ResInfo */ |
| 4752 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4753 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4754 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4755 | /* si+Ext_ResInfo */ |
| 4756 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4757 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4758 | CRT1Index = pVBInfo-> |
| 4759 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4760 | CRT1Index &= IndexMask; |
| 4761 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4762 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4763 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 4764 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4765 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4766 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4767 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4768 | /* if (modeflag & Charx8Dot) */ |
| 4769 | /* tempcx = 0x08; */ |
| 4770 | /* else */ |
| 4771 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4772 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4773 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
| 4774 | modeflag |= Charx8Dot; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4775 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4776 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4777 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4778 | if (modeflag & HalfDCLK) |
| 4779 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4780 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4781 | tempax = (tempax / tempcx) - 1; |
| 4782 | tempbx |= ((tempax & 0x00FF) << 8); |
| 4783 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4784 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4785 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4786 | temp = (tempbx & 0xFF00) >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4787 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4788 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4789 | if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 4790 | | VB_XGI302LV | VB_XGI301C))) |
| 4791 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4792 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4793 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4794 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 4795 | if (pVBInfo->VBExtInfo == VB_YPbPr1080i) { |
| 4796 | if (resinfo == 7) |
| 4797 | temp -= 2; |
| 4798 | } |
| 4799 | } else if (resinfo == 7) { |
| 4800 | temp -= 2; |
| 4801 | } |
| 4802 | } |
| 4803 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4804 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4805 | /* 0x05 Horizontal Display Start */ |
| 4806 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 4807 | /* 0x06 Horizontal Blank end */ |
| 4808 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4809 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4810 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 4811 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 4812 | tempax = pVBInfo->VGAHT; |
| 4813 | else |
| 4814 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 4815 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4816 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4817 | if (tempax >= pVBInfo->VGAHT) |
| 4818 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4819 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4820 | if (modeflag & HalfDCLK) |
| 4821 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4822 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4823 | tempax = (tempax / tempcx) - 5; |
| 4824 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
| 4825 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4826 | temp = (tempbx & 0x00FF) - 1; |
| 4827 | if (!(modeflag & HalfDCLK)) { |
| 4828 | temp -= 6; |
| 4829 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4830 | temp -= 4; |
| 4831 | if (ModeNo > 0x13) |
| 4832 | temp -= 10; |
| 4833 | } |
| 4834 | } |
| 4835 | } else { |
| 4836 | /* tempcx = tempbx & 0x00FF ; */ |
| 4837 | tempbx = (tempbx & 0xFF00) >> 8; |
| 4838 | tempcx = (tempcx + tempbx) >> 1; |
| 4839 | temp = (tempcx & 0x00FF) + 2; |
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->VBInfo & SetCRT2ToTV) { |
| 4842 | temp -= 1; |
| 4843 | if (!(modeflag & HalfDCLK)) { |
| 4844 | if ((modeflag & Charx8Dot)) { |
| 4845 | temp += 4; |
| 4846 | if (pVBInfo->VGAHDE >= 800) |
| 4847 | temp -= 6; |
| 4848 | } |
| 4849 | } |
| 4850 | } else { |
| 4851 | if (!(modeflag & HalfDCLK)) { |
| 4852 | temp -= 4; |
| 4853 | if (pVBInfo->LCDResInfo != Panel1280x960) { |
| 4854 | if (pVBInfo->VGAHDE >= 800) { |
| 4855 | temp -= 7; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4856 | if (pVBInfo->ModeType == |
| 4857 | ModeEGA) { |
| 4858 | if (pVBInfo->VGAVDE == |
| 4859 | 1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4860 | temp += 15; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4861 | if (pVBInfo->LCDResInfo != Panel1280x1024) { |
| 4862 | temp += |
| 4863 | 7; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4864 | } |
| 4865 | } |
| 4866 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4867 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4868 | if (pVBInfo->VGAHDE >= 1280) { |
| 4869 | if (pVBInfo->LCDResInfo |
| 4870 | != Panel1280x960) { |
| 4871 | if (pVBInfo->LCDInfo |
| 4872 | & LCDNonExpanding) { |
| 4873 | temp |
| 4874 | += 28; |
| 4875 | } |
| 4876 | } |
| 4877 | } |
| 4878 | } |
| 4879 | } |
| 4880 | } |
| 4881 | } |
| 4882 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4883 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4884 | /* 0x07 Horizontal Retrace Start */ |
| 4885 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 4886 | /* 0x08 Horizontal Retrace End */ |
| 4887 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4888 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4889 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4890 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4891 | if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo |
| 4892 | == 0x11) || (ModeNo == 0x13) || (ModeNo |
| 4893 | == 0x0F)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4894 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b); |
| 4895 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4896 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4897 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4898 | if ((ModeNo == 0x00) || (ModeNo == 0x01)) { |
| 4899 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4900 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4901 | 0x07, 0x2A); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4902 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4903 | 0x08, 0x61); |
| 4904 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4905 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4906 | 0x07, 0x2A); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4907 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4908 | 0x08, 0x41); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4909 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4910 | 0x0C, 0xF0); |
| 4911 | } |
| 4912 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4913 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4914 | if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo |
| 4915 | == 0x07)) { |
| 4916 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4917 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4918 | 0x07, 0x54); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4919 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4920 | 0x08, 0x00); |
| 4921 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4922 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4923 | 0x07, 0x55); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4924 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4925 | 0x08, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4926 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4927 | 0x0C, 0xF0); |
| 4928 | } |
| 4929 | } |
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 | if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo |
| 4932 | == 0x0D) || (ModeNo == 0x50)) { |
| 4933 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4934 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4935 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4936 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4937 | 0x08, 0x03); |
| 4938 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4939 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4940 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4941 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4942 | 0x08, 0x02); |
| 4943 | } |
| 4944 | } |
| 4945 | } |
| 4946 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4947 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4948 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4949 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4950 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4951 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4952 | tempbx = pVBInfo->VGAVT; |
| 4953 | push1 = tempbx; |
| 4954 | tempcx = 0x121; |
| 4955 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4956 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4957 | if (tempbx == 357) |
| 4958 | tempbx = 350; |
| 4959 | if (tempbx == 360) |
| 4960 | tempbx = 350; |
| 4961 | if (tempbx == 375) |
| 4962 | tempbx = 350; |
| 4963 | if (tempbx == 405) |
| 4964 | tempbx = 400; |
| 4965 | if (tempbx == 525) |
| 4966 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4967 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4968 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4969 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4970 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4971 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 4972 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4973 | if (tempbx == 350) |
| 4974 | tempbx += 5; |
| 4975 | if (tempbx == 480) |
| 4976 | tempbx += 5; |
| 4977 | } |
| 4978 | } |
| 4979 | } |
| 4980 | tempbx--; |
| 4981 | temp = tempbx & 0x00FF; |
| 4982 | tempbx--; |
| 4983 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4984 | /* 0x10 vertical Blank Start */ |
| 4985 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4986 | tempbx = push2; |
| 4987 | tempbx--; |
| 4988 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4989 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4990 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4991 | if (tempbx & 0x0100) |
| 4992 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4993 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4994 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4995 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4996 | if (modeflag & DoubleScanMode) |
| 4997 | tempax |= 0x08000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4998 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4999 | if (tempbx & 0x0200) |
| 5000 | tempcx |= 0x0040; |
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 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5003 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5004 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5005 | if (tempbx & 0x0400) |
| 5006 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5007 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5008 | /* 0x11 Vertival Blank End */ |
| 5009 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5010 | |
| 5011 | tempax = push1; |
| 5012 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 5013 | tempax = tempax >> 2; |
| 5014 | push1 = tempax; /* push ax */ |
| 5015 | |
| 5016 | if (resinfo != 0x09) { |
| 5017 | tempax = tempax << 1; |
| 5018 | tempbx += tempax; |
| 5019 | } |
| 5020 | |
| 5021 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5022 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 5023 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 5024 | tempbx -= 10; |
| 5025 | } else { |
| 5026 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 5027 | if (pVBInfo->TVInfo & SetPALTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5028 | if (pVBInfo->VBType & |
| 5029 | VB_XGI301LV) { |
| 5030 | if (!(pVBInfo->TVInfo & |
| 5031 | (SetYPbPrMode525p | |
| 5032 | SetYPbPrMode750p | |
| 5033 | SetYPbPrMode1080i))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5034 | tempbx += 40; |
| 5035 | } else { |
| 5036 | tempbx += 40; |
| 5037 | } |
| 5038 | } |
| 5039 | } |
| 5040 | } |
| 5041 | } else { |
| 5042 | tempbx -= 10; |
| 5043 | } |
| 5044 | } else { |
| 5045 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 5046 | if (pVBInfo->TVInfo & SetPALTV) { |
| 5047 | if (pVBInfo->VBType & VB_XGI301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5048 | if (!(pVBInfo->TVInfo & |
| 5049 | (SetYPbPrMode525p | |
| 5050 | SetYPbPrMode750p | |
| 5051 | SetYPbPrMode1080i))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5052 | tempbx += 40; |
| 5053 | } else { |
| 5054 | tempbx += 40; |
| 5055 | } |
| 5056 | } |
| 5057 | } |
| 5058 | } |
| 5059 | tempax = push1; |
| 5060 | tempax = tempax >> 2; |
| 5061 | tempax++; |
| 5062 | tempax += tempbx; |
| 5063 | push1 = tempax; /* push ax */ |
| 5064 | |
| 5065 | if ((pVBInfo->TVInfo & SetPALTV)) { |
| 5066 | if (tempbx <= 513) { |
| 5067 | if (tempax >= 513) |
| 5068 | tempbx = 513; |
| 5069 | } |
| 5070 | } |
| 5071 | |
| 5072 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5073 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5074 | tempbx--; |
| 5075 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5076 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5077 | |
| 5078 | if (tempbx & 0x0100) |
| 5079 | tempcx |= 0x0008; |
| 5080 | |
| 5081 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5082 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5083 | |
| 5084 | tempbx++; |
| 5085 | |
| 5086 | if (tempbx & 0x0100) |
| 5087 | tempcx |= 0x0004; |
| 5088 | |
| 5089 | if (tempbx & 0x0200) |
| 5090 | tempcx |= 0x0080; |
| 5091 | |
| 5092 | if (tempbx & 0x0400) |
| 5093 | tempcx |= 0x0C00; |
| 5094 | |
| 5095 | tempbx = push1; /* pop ax */ |
| 5096 | temp = tempbx & 0x00FF; |
| 5097 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5098 | /* 0x0D vertical Retrace End */ |
| 5099 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5100 | |
| 5101 | if (tempbx & 0x0010) |
| 5102 | tempcx |= 0x2000; |
| 5103 | |
| 5104 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5105 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5106 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5107 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5108 | tempax = modeflag; |
| 5109 | temp = (tempax & 0xFF00) >> 8; |
| 5110 | |
| 5111 | temp = (temp >> 1) & 0x09; |
| 5112 | |
| 5113 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
| 5114 | temp |= 0x01; |
| 5115 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5116 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 5117 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 5118 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5119 | |
| 5120 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 5121 | temp = 0x80; |
| 5122 | else |
| 5123 | temp = 0x00; |
| 5124 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5125 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5126 | |
| 5127 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5128 | } |
| 5129 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5130 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5131 | unsigned short RefreshRateTableIndex, |
| 5132 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5133 | struct vb_device_info *pVBInfo) |
| 5134 | { |
| 5135 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
| 5136 | modeflag, resinfo, crt2crtc; |
| 5137 | unsigned char *TimingPoint; |
| 5138 | |
| 5139 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 5140 | |
| 5141 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5142 | /* si+St_ResInfo */ |
| 5143 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5144 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 5145 | crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 5146 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5147 | /* si+Ext_ResInfo */ |
| 5148 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5149 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5150 | crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 5151 | Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5152 | } |
| 5153 | |
| 5154 | tempax = 0; |
| 5155 | |
| 5156 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 5157 | tempax |= 0x0800; |
| 5158 | |
| 5159 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5160 | tempax |= 0x0400; |
| 5161 | |
| 5162 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 5163 | tempax |= 0x0200; |
| 5164 | |
| 5165 | if (!(pVBInfo->TVInfo & SetPALTV)) |
| 5166 | tempax |= 0x1000; |
| 5167 | |
| 5168 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5169 | tempax |= 0x0100; |
| 5170 | |
| 5171 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
| 5172 | tempax &= 0xfe00; |
| 5173 | |
| 5174 | tempax = (tempax & 0xff00) >> 8; |
| 5175 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5176 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5177 | TimingPoint = pVBInfo->NTSCTiming; |
| 5178 | |
| 5179 | if (pVBInfo->TVInfo & SetPALTV) |
| 5180 | TimingPoint = pVBInfo->PALTiming; |
| 5181 | |
| 5182 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5183 | TimingPoint = pVBInfo->HiTVExtTiming; |
| 5184 | |
| 5185 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 5186 | TimingPoint = pVBInfo->HiTVSt2Timing; |
| 5187 | |
| 5188 | if (pVBInfo->SetFlag & TVSimuMode) |
| 5189 | TimingPoint = pVBInfo->HiTVSt1Timing; |
| 5190 | |
| 5191 | if (!(modeflag & Charx8Dot)) |
| 5192 | TimingPoint = pVBInfo->HiTVTextTiming; |
| 5193 | } |
| 5194 | |
| 5195 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5196 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5197 | TimingPoint = pVBInfo->YPbPr525iTiming; |
| 5198 | |
| 5199 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5200 | TimingPoint = pVBInfo->YPbPr525pTiming; |
| 5201 | |
| 5202 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5203 | TimingPoint = pVBInfo->YPbPr750pTiming; |
| 5204 | } |
| 5205 | |
| 5206 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5207 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5208 | |
| 5209 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5210 | /* di->temp2[j] */ |
| 5211 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5212 | |
| 5213 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5214 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5215 | |
| 5216 | temp = pVBInfo->NewFlickerMode; |
| 5217 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5218 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5219 | |
| 5220 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5221 | tempax = 950; |
| 5222 | |
| 5223 | if (pVBInfo->TVInfo & SetPALTV) |
| 5224 | tempax = 520; |
| 5225 | else |
| 5226 | tempax = 440; |
| 5227 | |
| 5228 | if (pVBInfo->VDE <= tempax) { |
| 5229 | tempax -= pVBInfo->VDE; |
| 5230 | tempax = tempax >> 2; |
| 5231 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 5232 | push1 = tempax; |
| 5233 | temp = (tempax & 0xFF00) >> 8; |
| 5234 | temp += (unsigned short) TimingPoint[0]; |
| 5235 | |
| 5236 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5237 | | VB_XGI302LV | VB_XGI301C)) { |
| 5238 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 5239 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
| 5240 | | SetCRT2ToYPbPr)) { |
| 5241 | tempcx = pVBInfo->VGAHDE; |
| 5242 | if (tempcx >= 1024) { |
| 5243 | temp = 0x17; /* NTSC */ |
| 5244 | if (pVBInfo->TVInfo & SetPALTV) |
| 5245 | temp = 0x19; /* PAL */ |
| 5246 | } |
| 5247 | } |
| 5248 | } |
| 5249 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5250 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5251 | tempax = push1; |
| 5252 | temp = (tempax & 0xFF00) >> 8; |
| 5253 | temp += TimingPoint[1]; |
| 5254 | |
| 5255 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5256 | | VB_XGI302LV | VB_XGI301C)) { |
| 5257 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 5258 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
| 5259 | | SetCRT2ToYPbPr))) { |
| 5260 | tempcx = pVBInfo->VGAHDE; |
| 5261 | if (tempcx >= 1024) { |
| 5262 | temp = 0x1D; /* NTSC */ |
| 5263 | if (pVBInfo->TVInfo & SetPALTV) |
| 5264 | temp = 0x52; /* PAL */ |
| 5265 | } |
| 5266 | } |
| 5267 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5268 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5269 | } |
| 5270 | |
| 5271 | /* 301b */ |
| 5272 | tempcx = pVBInfo->HT; |
| 5273 | |
| 5274 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5275 | tempcx = tempcx >> 1; |
| 5276 | |
| 5277 | tempcx -= 2; |
| 5278 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5279 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5280 | |
| 5281 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5282 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5283 | |
| 5284 | tempcx = pVBInfo->HT >> 1; |
| 5285 | push1 = tempcx; /* push cx */ |
| 5286 | tempcx += 7; |
| 5287 | |
| 5288 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5289 | tempcx -= 4; |
| 5290 | |
| 5291 | temp = tempcx & 0x00FF; |
| 5292 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5293 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5294 | |
| 5295 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 5296 | tempbx += tempcx; |
| 5297 | push2 = tempbx; |
| 5298 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5299 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5300 | temp = (tempbx & 0xFF00) >> 8; |
| 5301 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5302 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5303 | |
| 5304 | tempbx = push2; |
| 5305 | tempbx = tempbx + 8; |
| 5306 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5307 | tempbx = tempbx - 4; |
| 5308 | tempcx = tempbx; |
| 5309 | } |
| 5310 | |
| 5311 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5312 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5313 | |
| 5314 | j += 2; |
| 5315 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 5316 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5317 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5318 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5319 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5320 | |
| 5321 | tempcx += 8; |
| 5322 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5323 | tempcx -= 4; |
| 5324 | |
| 5325 | temp = tempcx & 0xFF; |
| 5326 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5327 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5328 | |
| 5329 | tempcx = push1; /* pop cx */ |
| 5330 | j += 2; |
| 5331 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 5332 | tempcx -= temp; |
| 5333 | temp = tempcx & 0x00FF; |
| 5334 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5335 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5336 | |
| 5337 | tempcx -= 11; |
| 5338 | |
| 5339 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 5340 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 5341 | tempcx = tempax - 1; |
| 5342 | } |
| 5343 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5344 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5345 | |
| 5346 | tempbx = pVBInfo->VDE; |
| 5347 | |
| 5348 | if (pVBInfo->VGAVDE == 360) |
| 5349 | tempbx = 746; |
| 5350 | if (pVBInfo->VGAVDE == 375) |
| 5351 | tempbx = 746; |
| 5352 | if (pVBInfo->VGAVDE == 405) |
| 5353 | tempbx = 853; |
| 5354 | |
| 5355 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5356 | if (pVBInfo->VBType & |
| 5357 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
| 5358 | if (!(pVBInfo->TVInfo & |
| 5359 | (SetYPbPrMode525p | SetYPbPrMode750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5360 | tempbx = tempbx >> 1; |
| 5361 | } else |
| 5362 | tempbx = tempbx >> 1; |
| 5363 | } |
| 5364 | |
| 5365 | tempbx -= 2; |
| 5366 | temp = tempbx & 0x00FF; |
| 5367 | |
| 5368 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5369 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 5370 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 5371 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5372 | if (ModeNo == 0x2f) |
| 5373 | temp += 1; |
| 5374 | } |
| 5375 | } |
| 5376 | } else { |
| 5377 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5378 | if (ModeNo == 0x2f) |
| 5379 | temp += 1; |
| 5380 | } |
| 5381 | } |
| 5382 | } |
| 5383 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5384 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5385 | |
| 5386 | temp = (tempcx & 0xFF00) >> 8; |
| 5387 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 5388 | |
| 5389 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) { |
| 5390 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 5391 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 5392 | temp |= 0x10; |
| 5393 | |
| 5394 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5395 | temp |= 0x20; |
| 5396 | } |
| 5397 | } else { |
| 5398 | temp |= 0x10; |
| 5399 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5400 | temp |= 0x20; |
| 5401 | } |
| 5402 | } |
| 5403 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5404 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5405 | |
| 5406 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5407 | | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */ |
| 5408 | tempbx = pVBInfo->VDE; |
| 5409 | tempcx = tempbx - 2; |
| 5410 | |
| 5411 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 5412 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p |
| 5413 | | SetYPbPrMode750p))) |
| 5414 | tempbx = tempbx >> 1; |
| 5415 | } |
| 5416 | |
| 5417 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 5418 | temp = 0; |
| 5419 | if (tempcx & 0x0400) |
| 5420 | temp |= 0x20; |
| 5421 | |
| 5422 | if (tempbx & 0x0400) |
| 5423 | temp |= 0x40; |
| 5424 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5425 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5426 | } |
| 5427 | |
| 5428 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5429 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5430 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5431 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5432 | } |
| 5433 | |
| 5434 | tempbx = tempbx & 0x00FF; |
| 5435 | |
| 5436 | if (!(modeflag & HalfDCLK)) { |
| 5437 | tempcx = pVBInfo->VGAHDE; |
| 5438 | if (tempcx >= pVBInfo->HDE) { |
| 5439 | tempbx |= 0x2000; |
| 5440 | tempax &= 0x00FF; |
| 5441 | } |
| 5442 | } |
| 5443 | |
| 5444 | tempcx = 0x0101; |
| 5445 | |
| 5446 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 5447 | if (pVBInfo->VGAHDE >= 1024) { |
| 5448 | tempcx = 0x1920; |
| 5449 | if (pVBInfo->VGAHDE >= 1280) { |
| 5450 | tempcx = 0x1420; |
| 5451 | tempbx = tempbx & 0xDFFF; |
| 5452 | } |
| 5453 | } |
| 5454 | } |
| 5455 | |
| 5456 | if (!(tempbx & 0x2000)) { |
| 5457 | if (modeflag & HalfDCLK) |
| 5458 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 5459 | |
| 5460 | push1 = tempbx; |
| 5461 | tempeax = pVBInfo->VGAHDE; |
| 5462 | tempebx = (tempcx & 0xFF00) >> 8; |
| 5463 | longtemp = tempeax * tempebx; |
| 5464 | tempecx = tempcx & 0x00FF; |
| 5465 | longtemp = longtemp / tempecx; |
| 5466 | |
| 5467 | /* 301b */ |
| 5468 | tempecx = 8 * 1024; |
| 5469 | |
| 5470 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5471 | | VB_XGI302LV | VB_XGI301C)) { |
| 5472 | tempecx = tempecx * 8; |
| 5473 | } |
| 5474 | |
| 5475 | longtemp = longtemp * tempecx; |
| 5476 | tempecx = pVBInfo->HDE; |
| 5477 | temp2 = longtemp % tempecx; |
| 5478 | tempeax = longtemp / tempecx; |
| 5479 | if (temp2 != 0) |
| 5480 | tempeax += 1; |
| 5481 | |
| 5482 | tempax = (unsigned short) tempeax; |
| 5483 | |
| 5484 | /* 301b */ |
| 5485 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5486 | | VB_XGI302LV | VB_XGI301C)) { |
| 5487 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 5488 | } |
| 5489 | /* end 301b */ |
| 5490 | |
| 5491 | tempbx = push1; |
| 5492 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 5493 | | (tempbx & 0x00FF)); |
| 5494 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 5495 | | (tempax & 0x00FF)); |
| 5496 | temp = (tempax & 0xFF00) >> 8; |
| 5497 | } else { |
| 5498 | temp = (tempax & 0x00FF) >> 8; |
| 5499 | } |
| 5500 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5501 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5502 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5503 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5504 | temp = tempcx & 0x00FF; |
| 5505 | |
| 5506 | if (tempbx & 0x2000) |
| 5507 | temp = 0; |
| 5508 | |
| 5509 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5510 | temp |= 0x18; |
| 5511 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5512 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5513 | if (pVBInfo->TVInfo & SetPALTV) { |
| 5514 | tempbx = 0x0382; |
| 5515 | tempcx = 0x007e; |
| 5516 | } else { |
| 5517 | tempbx = 0x0369; |
| 5518 | tempcx = 0x0061; |
| 5519 | } |
| 5520 | |
| 5521 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5522 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5523 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5524 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5525 | |
| 5526 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 5527 | temp = temp << 2; |
| 5528 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 5529 | |
| 5530 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5531 | temp |= 0x10; |
| 5532 | |
| 5533 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5534 | temp |= 0x20; |
| 5535 | |
| 5536 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5537 | temp |= 0x60; |
| 5538 | } |
| 5539 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5540 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5541 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5542 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5543 | |
| 5544 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { |
| 5545 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 5546 | TimingPoint = XGI_NTSC1024AdjTime; |
| 5547 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5548 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5549 | TimingPoint[j]); |
| 5550 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5551 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5552 | } |
| 5553 | } |
| 5554 | |
| 5555 | /* [ycchen] 01/14/03 Modify for 301C PALM Support */ |
| 5556 | if (pVBInfo->VBType & VB_XGI301C) { |
| 5557 | if (pVBInfo->TVInfo & SetPALMTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5558 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5559 | 0x08); /* PALM Mode */ |
| 5560 | } |
| 5561 | |
| 5562 | if (pVBInfo->TVInfo & SetPALMTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5563 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5564 | 0x01); |
| 5565 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5566 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5567 | |
| 5568 | /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5569 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5570 | } |
| 5571 | |
| 5572 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5573 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5574 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5575 | } |
| 5576 | |
| 5577 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 5578 | return; |
| 5579 | } |
| 5580 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5581 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5582 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5583 | unsigned short RefreshRateTableIndex, |
| 5584 | struct vb_device_info *pVBInfo) |
| 5585 | { |
| 5586 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
| 5587 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; |
| 5588 | |
| 5589 | struct XGI_LCDDesStruct *LCDBDesPtr = NULL; |
| 5590 | |
| 5591 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5592 | /* si+St_ResInfo */ |
| 5593 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5594 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 5595 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5596 | /* si+Ext_ResInfo */ |
| 5597 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5598 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5599 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 5600 | Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5601 | CRT1Index &= IndexMask; |
| 5602 | } |
| 5603 | |
| 5604 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5605 | return; |
| 5606 | |
| 5607 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 5608 | |
| 5609 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5610 | tempbx = tempbx >> 1; |
| 5611 | |
| 5612 | tempbx -= 1; |
| 5613 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5614 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5615 | temp = (tempbx & 0xFF00) >> 8; |
| 5616 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5617 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5618 | temp = 0x01; |
| 5619 | |
| 5620 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 5621 | if (pVBInfo->ModeType == ModeEGA) { |
| 5622 | if (pVBInfo->VGAHDE >= 1024) { |
| 5623 | temp = 0x02; |
| 5624 | if (pVBInfo->LCDInfo & LCDVESATiming) |
| 5625 | temp = 0x01; |
| 5626 | } |
| 5627 | } |
| 5628 | } |
| 5629 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5630 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5631 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
| 5632 | push1 = tempbx; |
| 5633 | tempbx--; |
| 5634 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5635 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5636 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5637 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5638 | |
| 5639 | tempcx = pVBInfo->VT - 1; |
| 5640 | push2 = tempcx + 1; |
| 5641 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5642 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5643 | temp = (tempcx & 0xFF00) >> 8; |
| 5644 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5645 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5646 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 5647 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 5648 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 5649 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5650 | |
| 5651 | /* Customized LCDB Des no add */ |
| 5652 | tempbx = 5; |
| 5653 | LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo, |
| 5654 | ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5655 | tempah = pVBInfo->LCDResInfo; |
| 5656 | tempah &= PanelResInfo; |
| 5657 | |
| 5658 | if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) { |
| 5659 | tempbx = 1024; |
| 5660 | tempcx = 768; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5661 | } else if ((tempah == Panel1280x1024) || |
| 5662 | (tempah == Panel1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5663 | tempbx = 1280; |
| 5664 | tempcx = 1024; |
| 5665 | } else if (tempah == Panel1400x1050) { |
| 5666 | tempbx = 1400; |
| 5667 | tempcx = 1050; |
| 5668 | } else { |
| 5669 | tempbx = 1600; |
| 5670 | tempcx = 1200; |
| 5671 | } |
| 5672 | |
| 5673 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 5674 | tempbx = pVBInfo->HDE; |
| 5675 | tempcx = pVBInfo->VDE; |
| 5676 | } |
| 5677 | |
| 5678 | pushbx = tempbx; |
| 5679 | tempax = pVBInfo->VT; |
| 5680 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 5681 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 5682 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 5683 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 5684 | tempbx = pVBInfo->LCDVDES; |
| 5685 | tempcx += tempbx; |
| 5686 | |
| 5687 | if (tempcx >= tempax) |
| 5688 | tempcx -= tempax; /* lcdvdes */ |
| 5689 | |
| 5690 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5691 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5692 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5693 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5694 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 5695 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 5696 | tempah = tempch; |
| 5697 | tempah = tempah << 3; |
| 5698 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5699 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5700 | |
| 5701 | /* getlcdsync() */ |
| 5702 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 5703 | tempcx = tempbx; |
| 5704 | tempax = pVBInfo->VT; |
| 5705 | tempbx = pVBInfo->LCDVRS; |
| 5706 | |
| 5707 | /* if (SetLCD_Info & EnableScalingLCD) */ |
| 5708 | tempcx += tempbx; |
| 5709 | if (tempcx >= tempax) |
| 5710 | tempcx -= tempax; |
| 5711 | |
| 5712 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5713 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5714 | temp = (tempbx & 0xFF00) >> 8; |
| 5715 | temp = temp << 4; |
| 5716 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5717 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5718 | tempcx = pushbx; |
| 5719 | tempax = pVBInfo->HT; |
| 5720 | tempbx = pVBInfo->LCDHDES; |
| 5721 | tempbx &= 0x0FFF; |
| 5722 | |
| 5723 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 5724 | tempax = tempax >> 1; |
| 5725 | tempbx = tempbx >> 1; |
| 5726 | tempcx = tempcx >> 1; |
| 5727 | } |
| 5728 | |
| 5729 | if (pVBInfo->VBType & VB_XGI302LV) |
| 5730 | tempbx += 1; |
| 5731 | |
| 5732 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 5733 | tempbx += 1; |
| 5734 | |
| 5735 | tempcx += tempbx; |
| 5736 | |
| 5737 | if (tempcx >= tempax) |
| 5738 | tempcx -= tempax; |
| 5739 | |
| 5740 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5741 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5742 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5743 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5744 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5745 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5746 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5747 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5748 | |
| 5749 | /* getlcdsync() */ |
| 5750 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 5751 | tempcx = tempax; |
| 5752 | tempax = pVBInfo->HT; |
| 5753 | tempbx = pVBInfo->LCDHRS; |
| 5754 | /* if ( SetLCD_Info & EnableScalingLCD) */ |
| 5755 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 5756 | tempax = tempax >> 1; |
| 5757 | tempbx = tempbx >> 1; |
| 5758 | tempcx = tempcx >> 1; |
| 5759 | } |
| 5760 | |
| 5761 | if (pVBInfo->VBType & VB_XGI302LV) |
| 5762 | tempbx += 1; |
| 5763 | |
| 5764 | tempcx += tempbx; |
| 5765 | |
| 5766 | if (tempcx >= tempax) |
| 5767 | tempcx -= tempax; |
| 5768 | |
| 5769 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5770 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5771 | |
| 5772 | temp = (tempbx & 0xFF00) >> 8; |
| 5773 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5774 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5775 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5776 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5777 | |
| 5778 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 5779 | if (pVBInfo->VGAVDE == 525) { |
| 5780 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 5781 | | VB_XGI301LV | VB_XGI302LV |
| 5782 | | VB_XGI301C)) { |
| 5783 | temp = 0xC6; |
| 5784 | } else |
| 5785 | temp = 0xC4; |
| 5786 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5787 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 5788 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5789 | } |
| 5790 | |
| 5791 | if (pVBInfo->VGAVDE == 420) { |
| 5792 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 5793 | | VB_XGI301LV | VB_XGI302LV |
| 5794 | | VB_XGI301C)) { |
| 5795 | temp = 0x4F; |
| 5796 | } else |
| 5797 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5798 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5799 | } |
| 5800 | } |
| 5801 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5802 | |
| 5803 | /* --------------------------------------------------------------------- */ |
| 5804 | /* Function : XGI_GetTap4Ptr */ |
| 5805 | /* Input : */ |
| 5806 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 5807 | /* Description : */ |
| 5808 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5809 | static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5810 | struct vb_device_info *pVBInfo) |
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 short tempax, tempbx, i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5813 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5814 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5815 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5816 | if (tempcx == 0) { |
| 5817 | tempax = pVBInfo->VGAHDE; |
| 5818 | tempbx = pVBInfo->HDE; |
| 5819 | } else { |
| 5820 | tempax = pVBInfo->VGAVDE; |
| 5821 | tempbx = pVBInfo->VDE; |
| 5822 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5823 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5824 | if (tempax < tempbx) |
| 5825 | return &EnlargeTap4Timing[0]; |
| 5826 | else if (tempax == tempbx) |
| 5827 | return &NoScaleTap4Timing[0]; /* 1:1 */ |
| 5828 | else |
| 5829 | Tap4TimingPtr = NTSCTap4Timing; /* NTSC */ |
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 | if (pVBInfo->TVInfo & SetPALTV) |
| 5832 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5833 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5834 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5835 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5836 | Tap4TimingPtr = YPbPr525iTap4Timing; |
| 5837 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5838 | Tap4TimingPtr = YPbPr525pTap4Timing; |
| 5839 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5840 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 5841 | } |
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 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5844 | Tap4TimingPtr = HiTVTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5845 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5846 | i = 0; |
| 5847 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 5848 | if (Tap4TimingPtr[i].DE == tempax) |
| 5849 | break; |
| 5850 | i++; |
| 5851 | } |
| 5852 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5853 | } |
| 5854 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5855 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5856 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5857 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5858 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5859 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5860 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5861 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 5862 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5863 | |
| 5864 | #ifndef Tap4 |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5865 | xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5866 | #else /* Tap4 Setting */ |
| 5867 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5868 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 5869 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5870 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5871 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5872 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
| 5873 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) { |
| 5874 | /* Set Vertical Scaling */ |
| 5875 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5876 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5877 | xgifb_reg_set(pVBInfo->Part2Port, |
| 5878 | i, |
| 5879 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5880 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5881 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5882 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
| 5883 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) |
| 5884 | /* Enable V.Scaling */ |
| 5885 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5886 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5887 | /* Enable H.Scaling */ |
| 5888 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5889 | #endif |
| 5890 | } |
| 5891 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5892 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5893 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5894 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5895 | unsigned short i; |
| 5896 | unsigned char *tempdi; |
| 5897 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5898 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5899 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5900 | /* si+St_ResInfo */ |
| 5901 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5902 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5903 | /* si+Ext_ResInfo */ |
| 5904 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5905 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5906 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5907 | if (pVBInfo->TVInfo & SetPALTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5908 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 5909 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5910 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5911 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 5912 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5913 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5914 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5915 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 5916 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5917 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5918 | if (pVBInfo->TVInfo & SetPALMTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5919 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 5920 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 5921 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5922 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5923 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5924 | if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo |
| 5925 | & SetCRT2ToYPbPr)) { |
| 5926 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5927 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5928 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5929 | tempdi = pVBInfo->HiTVGroup3Data; |
| 5930 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 5931 | tempdi = pVBInfo->HiTVGroup3Simu; |
| 5932 | if (!(modeflag & Charx8Dot)) |
| 5933 | tempdi = pVBInfo->HiTVGroup3Text; |
| 5934 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5935 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5936 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5937 | tempdi = pVBInfo->Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5938 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5939 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5940 | tempdi = pVBInfo->Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5941 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5942 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5943 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5944 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5945 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
| 5946 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5947 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5948 | } |
| 5949 | } |
| 5950 | return; |
| 5951 | } /* {end of XGI_SetGroup3} */ |
| 5952 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5953 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5954 | unsigned short RefreshRateTableIndex, |
| 5955 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5956 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5957 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5958 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5959 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5960 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5961 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5962 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5963 | /* si+St_ResInfo */ |
| 5964 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5965 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5966 | /* si+Ext_ResInfo */ |
| 5967 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5968 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5969 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5970 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
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 | tempbx = pVBInfo->RVBHCMAX; |
| 5973 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5974 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5975 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 5976 | tempcx = pVBInfo->VGAHT - 1; |
| 5977 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5978 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5979 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5980 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 5981 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5982 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5983 | tempcx = pVBInfo->VGAVT - 1; |
| 5984 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 5985 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5986 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5987 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5988 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5989 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5990 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5991 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5992 | tempcx = pVBInfo->VBInfo; |
| 5993 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5994 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5995 | if (modeflag & HalfDCLK) |
| 5996 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5997 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5998 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5999 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6000 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6001 | if (tempcx & SetCRT2ToHiVisionTV) { |
| 6002 | temp = 0; |
| 6003 | if (tempbx <= 1024) |
| 6004 | temp = 0xA0; |
| 6005 | if (tempbx == 1280) |
| 6006 | temp = 0xC0; |
| 6007 | } else if (tempcx & SetCRT2ToTV) { |
| 6008 | temp = 0xA0; |
| 6009 | if (tempbx <= 800) |
| 6010 | temp = 0x80; |
| 6011 | } else { |
| 6012 | temp = 0x80; |
| 6013 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 6014 | temp = 0; |
| 6015 | if (tempbx > 800) |
| 6016 | temp = 0x60; |
| 6017 | } |
| 6018 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6019 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6020 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) { |
| 6021 | temp = 0x00; |
| 6022 | if (pVBInfo->VGAHDE == 1280) |
| 6023 | temp = 0x40; |
| 6024 | if (pVBInfo->VGAHDE == 1024) |
| 6025 | temp = 0x20; |
| 6026 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6027 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6028 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6029 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6030 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6031 | if (tempcx & SetCRT2ToHiVisionTV) { |
| 6032 | if (!(temp & 0xE000)) |
| 6033 | tempbx = tempbx >> 1; |
| 6034 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6035 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6036 | tempcx = pVBInfo->RVBHRS; |
| 6037 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6038 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6039 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6040 | tempeax = pVBInfo->VGAVDE; |
| 6041 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6042 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6043 | if (tempeax <= tempebx) { |
| 6044 | tempcx = (tempcx & (~0x4000)); |
| 6045 | tempeax = pVBInfo->VGAVDE; |
| 6046 | } else { |
| 6047 | tempeax -= tempebx; |
| 6048 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6049 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6050 | templong = (tempeax * 256 * 1024) % tempebx; |
| 6051 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 6052 | tempebx = tempeax; |
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 (templong != 0) |
| 6055 | tempebx++; |
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 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6058 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6059 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6060 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6061 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6062 | tempbx = (unsigned short) (tempebx >> 16); |
| 6063 | temp = tempbx & 0x00FF; |
| 6064 | temp = temp << 4; |
| 6065 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6066 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6067 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6068 | /* 301b */ |
| 6069 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6070 | | VB_XGI302LV | VB_XGI301C)) { |
| 6071 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6072 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6073 | tempax = pVBInfo->VGAHDE; |
| 6074 | if (modeflag & HalfDCLK) |
| 6075 | tempax = tempax >> 1; |
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 (XGI_IsLCDDualLink(pVBInfo)) |
| 6078 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6079 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6080 | /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) || |
| 6081 | ((pVBInfo->TVInfo&SetYPbPrMode525p) || |
| 6082 | (pVBInfo->TVInfo&SetYPbPrMode750p))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6083 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 6084 | if (tempax > 800) |
| 6085 | tempax -= 800; |
| 6086 | } else { |
| 6087 | if (pVBInfo->VGAHDE > 800) { |
| 6088 | if (pVBInfo->VGAHDE == 1024) |
| 6089 | tempax = (tempax * 25 / 32) - 1; |
| 6090 | else |
| 6091 | tempax = (tempax * 20 / 32) - 1; |
| 6092 | } |
| 6093 | } |
| 6094 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6095 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6096 | /* |
| 6097 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
| 6098 | if (pVBInfo->VBType & VB_XGI301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6099 | if (!(pVBInfo->TVInfo & |
| 6100 | (SetYPbPrMode525p | |
| 6101 | SetYPbPrMode750p | |
| 6102 | SetYPbPrMode1080i))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6103 | if (pVBInfo->VGAHDE > 800) { |
| 6104 | if (pVBInfo->VGAHDE == 1024) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6105 | tempax =(tempax * 25 / |
| 6106 | 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6107 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6108 | tempax = (tempax * 20 / |
| 6109 | 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6110 | } |
| 6111 | } |
| 6112 | } else { |
| 6113 | if (pVBInfo->VGAHDE > 800) { |
| 6114 | if (pVBInfo->VGAHDE == 1024) |
| 6115 | tempax = (tempax * 25 / 32) - 1; |
| 6116 | else |
| 6117 | tempax = (tempax * 20 / 32) - 1; |
| 6118 | } |
| 6119 | } |
| 6120 | } |
| 6121 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6122 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6123 | temp = (tempax & 0xFF00) >> 8; |
| 6124 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6125 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6126 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6127 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6128 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6129 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
| 6130 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6131 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6132 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6133 | } |
| 6134 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6135 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6136 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 6137 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
| 6138 | | SetYPbPrMode525p | SetYPbPrMode750p |
| 6139 | | SetYPbPrMode1080i))) { |
| 6140 | temp |= 0x0001; |
| 6141 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 6142 | && (!(pVBInfo->TVInfo |
| 6143 | & TVSimuMode))) |
| 6144 | temp &= (~0x0001); |
| 6145 | } |
| 6146 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6147 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6148 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6149 | tempbx = pVBInfo->HT; |
| 6150 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 6151 | tempbx = tempbx >> 1; |
| 6152 | tempbx = (tempbx >> 1) - 2; |
| 6153 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6154 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6155 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6156 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6157 | } |
| 6158 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6159 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6160 | if (pVBInfo->ISXPDOS == 0) |
| 6161 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 6162 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6163 | } |
| 6164 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6165 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 6166 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6167 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6168 | } |
| 6169 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6170 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6171 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6172 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6173 | unsigned short Pindex, Pdata; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6174 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6175 | Pindex = pVBInfo->Part5Port; |
| 6176 | Pdata = pVBInfo->Part5Port + 1; |
| 6177 | if (pVBInfo->ModeType == ModeVGA) { |
| 6178 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
| 6179 | | CRT2DisplayFlag))) { |
| 6180 | XGINew_EnableCRT2(pVBInfo); |
| 6181 | /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */ |
| 6182 | } |
| 6183 | } |
| 6184 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6185 | } |
| 6186 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6187 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6188 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6189 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6190 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6191 | } |
| 6192 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6193 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6194 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6195 | { |
| 6196 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6197 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6198 | } |
| 6199 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6200 | /*----------------------------------------------------------------------------*/ |
| 6201 | /* input */ |
| 6202 | /* bl[5] : 1;LVDS signal on */ |
| 6203 | /* bl[1] : 1;LVDS backlight on */ |
| 6204 | /* bl[0] : 1:LVDS VDD on */ |
| 6205 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 6206 | /* 000010b : clear bit 1, to set bit1 */ |
| 6207 | /* 000001b : clear bit 0, to set bit0 */ |
| 6208 | /*----------------------------------------------------------------------------*/ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6209 | void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 6210 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6211 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6212 | unsigned char CR4A, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6213 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6214 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6215 | tempbh &= 0x23; |
| 6216 | tempbl &= 0x23; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6217 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6218 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6219 | if (tempbh & 0x20) { |
| 6220 | temp = (tempbl >> 4) & 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6221 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6222 | /* CR B4[1] */ |
| 6223 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6224 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6225 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6226 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6227 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6228 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6229 | temp = XG21GPIODataTransfer(temp); |
| 6230 | temp &= ~tempbh; |
| 6231 | temp |= tempbl; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6232 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6233 | } |
| 6234 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6235 | void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 6236 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6237 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6238 | unsigned char CR4A, temp; |
| 6239 | unsigned short tempbh0, tempbl0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6240 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6241 | tempbh0 = tempbh; |
| 6242 | tempbl0 = tempbl; |
| 6243 | tempbh0 &= 0x20; |
| 6244 | tempbl0 &= 0x20; |
| 6245 | tempbh0 >>= 3; |
| 6246 | tempbl0 >>= 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6247 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6248 | if (tempbh & 0x20) { |
| 6249 | temp = (tempbl >> 4) & 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6250 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6251 | /* CR B4[1] */ |
| 6252 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6253 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6254 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6255 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6256 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6257 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6258 | tempbh &= 0x03; |
| 6259 | tempbl &= 0x03; |
| 6260 | tempbh <<= 2; |
| 6261 | tempbl <<= 2; /* GPIOC,GPIOD */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6262 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6263 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6264 | } |
| 6265 | |
| 6266 | /* --------------------------------------------------------------------- */ |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6267 | unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6268 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6269 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6270 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6271 | index = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6272 | if (index < sizeof(XGI21_LCDCapList) |
| 6273 | / sizeof(struct XGI21_LVDSCapStruct)) |
| 6274 | return index; |
| 6275 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6276 | } |
| 6277 | |
| 6278 | /* --------------------------------------------------------------------- */ |
| 6279 | /* Function : XGI_XG21SetPanelDelay */ |
| 6280 | /* Input : */ |
| 6281 | /* Output : */ |
| 6282 | /* Description : */ |
| 6283 | /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */ |
| 6284 | /* : bl : 2 ; T2 : the duration signal on and Vdd on */ |
| 6285 | /* : bl : 3 ; T3 : the duration between CPL off and signal off */ |
| 6286 | /* : bl : 4 ; T4 : the duration signal off and Vdd off */ |
| 6287 | /* --------------------------------------------------------------------- */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6288 | void XGI_XG21SetPanelDelay(unsigned short tempbl, |
| 6289 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6290 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6291 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6292 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6293 | index = XGI_GetLVDSOEMTableIndex(pVBInfo); |
| 6294 | if (tempbl == 1) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6295 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6296 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6297 | if (tempbl == 2) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6298 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6299 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6300 | if (tempbl == 3) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6301 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6302 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6303 | if (tempbl == 4) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6304 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6305 | } |
| 6306 | |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 6307 | unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6308 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6309 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6310 | unsigned short xres, yres, colordepth, modeflag, resindex, |
| 6311 | lvdstableindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6312 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6313 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6314 | if (ModeNo <= 0x13) { |
| 6315 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 6316 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6317 | /* si+St_ResInfo */ |
| 6318 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6319 | } else { |
| 6320 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 6321 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6322 | /* si+St_ModeFlag */ |
| 6323 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6324 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6325 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6326 | if (!(modeflag & Charx8Dot)) { |
| 6327 | xres /= 9; |
| 6328 | xres *= 8; |
| 6329 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6330 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6331 | if (ModeNo > 0x13) { |
| 6332 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 6333 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6334 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6335 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 6336 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6337 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6338 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6339 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6340 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); |
| 6341 | if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE)) |
| 6342 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6343 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6344 | if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) |
| 6345 | return 0; |
| 6346 | |
| 6347 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6348 | if ((xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6349 | LVDSHDE)) || |
| 6350 | (yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6351 | LVDSVDE))) { |
| 6352 | colordepth = XGI_GetColorDepth(ModeNo, |
| 6353 | ModeIdIndex, |
| 6354 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6355 | if (colordepth > 2) |
| 6356 | return 0; |
| 6357 | |
| 6358 | } |
| 6359 | } |
| 6360 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6361 | } |
| 6362 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6363 | void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6364 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6365 | unsigned char temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6366 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6367 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6368 | temp = (temp & 1) << 6; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6369 | /* SR06[6] 18bit Dither */ |
| 6370 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 6371 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 6372 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6373 | |
| 6374 | } |
| 6375 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6376 | void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6377 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6378 | unsigned char temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6379 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6380 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 6381 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6382 | temp = (temp & 3) << 6; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6383 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 6384 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 6385 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 6386 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6387 | |
| 6388 | } |
| 6389 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6390 | static void XGI_SetXG21LVDSPara(unsigned short ModeNo, |
| 6391 | unsigned short ModeIdIndex, |
| 6392 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6393 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6394 | unsigned char temp, Miscdata; |
| 6395 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; |
| 6396 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 6397 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 6398 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6399 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6400 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6401 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6402 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6403 | LVDS_Capability & |
| 6404 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6405 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6406 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6407 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6408 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6409 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6410 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6411 | LVDS_Capability & LCDPolarity); |
| 6412 | /* SR35[7] FP VSync polarity */ |
| 6413 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 6414 | /* SR30[5] FP HSync polarity */ |
| 6415 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6416 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6417 | XGI_SetXG21FPBits(pVBInfo); |
| 6418 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6419 | if (ModeNo <= 0x13) { |
| 6420 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 6421 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6422 | /* si+St_ResInfo */ |
| 6423 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6424 | } else { |
| 6425 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 6426 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6427 | /* si+St_ModeFlag */ |
| 6428 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6429 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6430 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6431 | if (!(modeflag & Charx8Dot)) |
| 6432 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6433 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6434 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6435 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6436 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE |
| 6437 | - xres) / 2; |
| 6438 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) |
| 6439 | LVDSHBS -= xres / 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6440 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6441 | if (LVDSHBS > LVDSHT) |
| 6442 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6443 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6444 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; |
| 6445 | if (LVDSHRS > LVDSHT) |
| 6446 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6447 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6448 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; |
| 6449 | if (LVDSHRE > LVDSHT) |
| 6450 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6451 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6452 | LVDSHBE = LVDSHBS + LVDSHT |
| 6453 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6454 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6455 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6456 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6457 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE |
| 6458 | - yres) / 2; |
| 6459 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 6460 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6461 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6462 | if (LVDSVBS > LVDSVT) |
| 6463 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6464 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6465 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; |
| 6466 | if (LVDSVRS > LVDSVT) |
| 6467 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6468 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6469 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC; |
| 6470 | if (LVDSVRE > LVDSVT) |
| 6471 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6472 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6473 | LVDSVBE = LVDSVBS + LVDSVT |
| 6474 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6475 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6476 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6477 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6478 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6479 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6480 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6481 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6482 | /* HT SR0B[1:0] CR00 */ |
| 6483 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6484 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6485 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6486 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6487 | /* HBS SR0B[5:4] CR02 */ |
| 6488 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6489 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6490 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6491 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6492 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 6493 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6494 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 6495 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 6496 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6497 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6498 | /* HRS SR0B[7:6] CR04 */ |
| 6499 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6500 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6501 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6502 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6503 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 6504 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6505 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6506 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6507 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6508 | /* HRE SR0C[2] CR05[4:0] */ |
| 6509 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6510 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 6511 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6512 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6513 | /* Panel HRE SR2F[7:2] */ |
| 6514 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6515 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6516 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6517 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 6518 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6519 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 6520 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 6521 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6522 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6523 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6524 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 6525 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6526 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 6527 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 6528 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6529 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6530 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6531 | /* VBE SR0A[4] CR16 */ |
| 6532 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6533 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6534 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6535 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6536 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 6537 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6538 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 6539 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 6540 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6541 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6542 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6543 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6544 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6545 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6546 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6547 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6548 | /* VRE SR0A[5] CR11[3:0] */ |
| 6549 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6550 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 6551 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6552 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6553 | /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6554 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6555 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6556 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6557 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6558 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6559 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6560 | 0x2B, |
| 6561 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6562 | VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6563 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6564 | 0x2C, |
| 6565 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6566 | VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6567 | value += 0x10; |
| 6568 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6569 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6570 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6571 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6572 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6573 | /* set data, panning = 0, shift left 1 dot*/ |
| 6574 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6575 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6576 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6577 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6578 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6579 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6580 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6581 | |
| 6582 | } |
| 6583 | |
| 6584 | /* no shadow case */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6585 | static void XGI_SetXG27LVDSPara(unsigned short ModeNo, |
| 6586 | unsigned short ModeIdIndex, |
| 6587 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6588 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6589 | unsigned char temp, Miscdata; |
| 6590 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; |
| 6591 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 6592 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 6593 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6594 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6595 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6596 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6597 | LVDS_Capability & |
| 6598 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6599 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6600 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6601 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6602 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6603 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6604 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6605 | LVDS_Capability & LCDPolarity); |
| 6606 | /* SR35[7] FP VSync polarity */ |
| 6607 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 6608 | /* SR30[5] FP HSync polarity */ |
| 6609 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6610 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6611 | XGI_SetXG27FPBits(pVBInfo); |
| 6612 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6613 | if (ModeNo <= 0x13) { |
| 6614 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 6615 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6616 | /* si+St_ResInfo */ |
| 6617 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6618 | } else { |
| 6619 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 6620 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6621 | /* si+St_ModeFlag */ |
| 6622 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6623 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6624 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6625 | if (!(modeflag & Charx8Dot)) |
| 6626 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6627 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6628 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6629 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6630 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE |
| 6631 | - xres) / 2; |
| 6632 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) |
| 6633 | LVDSHBS -= xres / 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6634 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6635 | if (LVDSHBS > LVDSHT) |
| 6636 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6637 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6638 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; |
| 6639 | if (LVDSHRS > LVDSHT) |
| 6640 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6641 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6642 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; |
| 6643 | if (LVDSHRE > LVDSHT) |
| 6644 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6645 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6646 | LVDSHBE = LVDSHBS + LVDSHT |
| 6647 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6648 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6649 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6650 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6651 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE |
| 6652 | - yres) / 2; |
| 6653 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 6654 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6655 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6656 | if (LVDSVBS > LVDSVT) |
| 6657 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6658 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6659 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; |
| 6660 | if (LVDSVRS > LVDSVT) |
| 6661 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6662 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6663 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6664 | LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6665 | if (LVDSVRE > LVDSVT) |
| 6666 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6667 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6668 | LVDSVBE = LVDSVBS + LVDSVT |
| 6669 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6670 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6671 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6672 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6673 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6674 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6675 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6676 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6677 | /* HT SR0B[1:0] CR00 */ |
| 6678 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6679 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6680 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6681 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6682 | /* HBS SR0B[5:4] CR02 */ |
| 6683 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6684 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6685 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6686 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6687 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 6688 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6689 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 6690 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 6691 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6692 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6693 | /* HRS SR0B[7:6] CR04 */ |
| 6694 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6695 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6696 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6697 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6698 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 6699 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6700 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6701 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6702 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6703 | /* HRE SR0C[2] CR05[4:0] */ |
| 6704 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6705 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 6706 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6707 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6708 | /* Panel HRE SR2F[7:2] */ |
| 6709 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6710 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6711 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6712 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 6713 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6714 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 6715 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 6716 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6717 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6718 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6719 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 6720 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6721 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 6722 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 6723 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6724 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6725 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6726 | /* VBE SR0A[4] CR16 */ |
| 6727 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6728 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6729 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6730 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6731 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 6732 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6733 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 6734 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 6735 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6736 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6737 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6738 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6739 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6740 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6741 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6742 | /* VRE SR0A[5] CR11[3:0] */ |
| 6743 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6744 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 6745 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6746 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6747 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6748 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6749 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6750 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6751 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6752 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6753 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6754 | 0x2B, |
| 6755 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6756 | VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6757 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6758 | 0x2C, |
| 6759 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6760 | VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6761 | value += 0x10; |
| 6762 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6763 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6764 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6765 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6766 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6767 | /* set data, panning = 0, shift left 1 dot*/ |
| 6768 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6769 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6770 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6771 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6772 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6773 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6774 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6775 | |
| 6776 | } |
| 6777 | |
| 6778 | /* --------------------------------------------------------------------- */ |
| 6779 | /* Function : XGI_IsLCDON */ |
| 6780 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6781 | /* Output : 0 : Skip PSC Control */ |
| 6782 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6783 | /* Description : */ |
| 6784 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6785 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6786 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6787 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6788 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6789 | tempax = pVBInfo->VBInfo; |
| 6790 | if (tempax & SetCRT2ToDualEdge) |
| 6791 | return 0; |
| 6792 | else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode)) |
| 6793 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6794 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6795 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6796 | } |
| 6797 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6798 | /* --------------------------------------------------------------------- */ |
| 6799 | /* Function : XGI_DisableChISLCD */ |
| 6800 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6801 | /* Output : 0 -> Not LCD Mode */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6802 | /* Description : */ |
| 6803 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6804 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6805 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6806 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6807 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6808 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6809 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6810 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6811 | if (tempbx & (EnableChA | DisableChA)) { |
| 6812 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 6813 | return 0; |
| 6814 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6815 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6816 | if (!(tempbx & (EnableChB | DisableChB))) |
| 6817 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6818 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6819 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 6820 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6821 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6822 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6823 | } |
| 6824 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6825 | /* --------------------------------------------------------------------- */ |
| 6826 | /* Function : XGI_EnableChISLCD */ |
| 6827 | /* Input : */ |
| 6828 | /* Output : 0 -> Not LCD mode */ |
| 6829 | /* Description : */ |
| 6830 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6831 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6832 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6833 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6834 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6835 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6836 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6837 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6838 | if (tempbx & (EnableChA | DisableChA)) { |
| 6839 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 6840 | return 0; |
| 6841 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6842 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6843 | if (!(tempbx & (EnableChB | DisableChB))) |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6844 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6845 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6846 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 6847 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6848 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6849 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6850 | } |
| 6851 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6852 | void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
| 6853 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6854 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 6855 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6856 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6857 | if (pVBInfo->SetFlag == Win9xDOSMode) |
| 6858 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6859 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6860 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6861 | | VB_XGI302LV | VB_XGI301C)) { |
| 6862 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6863 | if (!(pVBInfo->VBInfo & |
| 6864 | (DisableCRT2Display | SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6865 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 6866 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 6867 | tempah = 0x7F; /* Disable Channel A */ |
| 6868 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6869 | /* Disable Channel B */ |
| 6870 | tempah = 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6871 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6872 | if (pVBInfo->SetFlag & DisableChB) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6873 | /* force to disable Cahnnel */ |
| 6874 | tempah &= 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6875 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6876 | if (pVBInfo->SetFlag & DisableChA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6877 | /* Force to disable Channel B */ |
| 6878 | tempah &= 0x7F; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6879 | } |
| 6880 | } |
| 6881 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6882 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6883 | /* disable part4_1f */ |
| 6884 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6885 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6886 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 6887 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 6888 | || (XGI_DisableChISLCD(pVBInfo)) |
| 6889 | || (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6890 | /* LVDS Driver power down */ |
| 6891 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6892 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6893 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6894 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
| 6895 | & (DisableCRT2Display | SetCRT2ToLCDA |
| 6896 | | SetSimuScanMode))) { |
| 6897 | if (pVBInfo->SetFlag & GatingCRT) |
| 6898 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); |
| 6899 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 6900 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6901 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6902 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 6903 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
| 6904 | & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6905 | /* Power down */ |
| 6906 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6907 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6908 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6909 | /* disable TV as primary VGA swap */ |
| 6910 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6911 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6912 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6913 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6914 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6915 | if ((pVBInfo->SetFlag & DisableChB) || |
| 6916 | (pVBInfo->VBInfo & |
| 6917 | (DisableCRT2Display | SetSimuScanMode)) || |
| 6918 | ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && |
| 6919 | (pVBInfo->VBInfo & |
| 6920 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
| 6921 | /* BScreenOff=1 */ |
| 6922 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6923 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6924 | if ((pVBInfo->SetFlag & DisableChB) || |
| 6925 | (pVBInfo->VBInfo & |
| 6926 | (DisableCRT2Display | SetSimuScanMode)) || |
| 6927 | (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) || |
| 6928 | (pVBInfo->VBInfo & |
| 6929 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 6930 | /* save Part1 index 0 */ |
| 6931 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 6932 | /* BTDAC = 1, avoid VB reset */ |
| 6933 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 6934 | /* disable CRT2 */ |
| 6935 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 6936 | /* restore Part1 index 0 */ |
| 6937 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6938 | } |
| 6939 | } else { /* {301} */ |
| 6940 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6941 | /* BScreenOff=1 */ |
| 6942 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 6943 | /* Disable CRT2 */ |
| 6944 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 6945 | /* Disable TV asPrimary VGA swap */ |
| 6946 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6947 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6948 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6949 | if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA |
| 6950 | | SetSimuScanMode)) |
| 6951 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 6952 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6953 | } |
| 6954 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6955 | /* --------------------------------------------------------------------- */ |
| 6956 | /* Function : XGI_GetTVPtrIndex */ |
| 6957 | /* Input : */ |
| 6958 | /* Output : */ |
| 6959 | /* Description : bx 0 : ExtNTSC */ |
| 6960 | /* 1 : StNTSC */ |
| 6961 | /* 2 : ExtPAL */ |
| 6962 | /* 3 : StPAL */ |
| 6963 | /* 4 : ExtHiTV */ |
| 6964 | /* 5 : StHiTV */ |
| 6965 | /* 6 : Ext525i */ |
| 6966 | /* 7 : St525i */ |
| 6967 | /* 8 : Ext525p */ |
| 6968 | /* 9 : St525p */ |
| 6969 | /* A : Ext750p */ |
| 6970 | /* B : St750p */ |
| 6971 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6972 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6973 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6974 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6975 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6976 | if (pVBInfo->TVInfo & SetPALTV) |
| 6977 | tempbx = 2; |
| 6978 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) |
| 6979 | tempbx = 4; |
| 6980 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 6981 | tempbx = 6; |
| 6982 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 6983 | tempbx = 8; |
| 6984 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 6985 | tempbx = 10; |
| 6986 | if (pVBInfo->TVInfo & TVSimuMode) |
| 6987 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6988 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6989 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6990 | } |
| 6991 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6992 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6993 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6994 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6995 | /* Output : bx 0 : NTSC */ |
| 6996 | /* 1 : PAL */ |
| 6997 | /* 2 : PALM */ |
| 6998 | /* 3 : PALN */ |
| 6999 | /* 4 : NTSC1024x768 */ |
| 7000 | /* 5 : PAL-M 1024x768 */ |
| 7001 | /* 6-7: reserved */ |
| 7002 | /* cl 0 : YFilter1 */ |
| 7003 | /* 1 : YFilter2 */ |
| 7004 | /* ch 0 : 301A */ |
| 7005 | /* 1 : 301B/302B/301LV/302LV */ |
| 7006 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7007 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7008 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 7009 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7010 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7011 | *tempbx = 0; |
| 7012 | *tempcl = 0; |
| 7013 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7014 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7015 | if (pVBInfo->TVInfo & SetPALTV) |
| 7016 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7017 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7018 | if (pVBInfo->TVInfo & SetPALMTV) |
| 7019 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7020 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7021 | if (pVBInfo->TVInfo & SetPALNTV) |
| 7022 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7023 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7024 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 7025 | *tempbx = 4; |
| 7026 | if (pVBInfo->TVInfo & SetPALMTV) |
| 7027 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7028 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7029 | |
| 7030 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7031 | | VB_XGI302LV | VB_XGI301C)) { |
| 7032 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 7033 | & TVSimuMode)) { |
| 7034 | *tempbx += 8; |
| 7035 | *tempcl += 1; |
| 7036 | } |
| 7037 | } |
| 7038 | |
| 7039 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7040 | | VB_XGI302LV | VB_XGI301C)) |
| 7041 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7042 | } |
| 7043 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7044 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7045 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7046 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7047 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7048 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7049 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7050 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7051 | | VB_XGI302LV | VB_XGI301C)) { |
| 7052 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA |
| 7053 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
| 7054 | tempbl = 0; |
| 7055 | tempbh = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7056 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7057 | index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */ |
| 7058 | tempbl = pVBInfo->XGI_TVDelayList[index]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7059 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7060 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 7061 | | VB_XGI301LV | VB_XGI302LV |
| 7062 | | VB_XGI301C)) |
| 7063 | tempbl = pVBInfo->XGI_TVDelayList2[index]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7064 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7065 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 7066 | tempbl = tempbl >> 4; |
| 7067 | /* |
| 7068 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
| 7069 | tempbl = CRT2Delay1; // Get CRT2 Delay |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7070 | if (pVBInfo->VBType & |
| 7071 | (VB_XGI301B | |
| 7072 | VB_XGI302B | |
| 7073 | VB_XGI301LV | |
| 7074 | VB_XGI302LV | |
| 7075 | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7076 | tempbl = CRT2Delay2; |
| 7077 | */ |
| 7078 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7079 | /* Get LCD Delay */ |
| 7080 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 7081 | tempbh = pVBInfo->LCDCapList[index]. |
| 7082 | LCD_DelayCompensation; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7083 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7084 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
| 7085 | tempbl = tempbh; |
| 7086 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7087 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7088 | tempbl &= 0x0F; |
| 7089 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7090 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7091 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7092 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 7093 | | SetCRT2ToTV)) { /* Channel B */ |
| 7094 | tempah &= 0xF0; |
| 7095 | tempah |= tempbl; |
| 7096 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7097 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7098 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */ |
| 7099 | tempah &= 0x0F; |
| 7100 | tempah |= tempbh; |
| 7101 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7102 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7103 | } |
| 7104 | } else if (pVBInfo->IF_DEF_LVDS == 1) { |
| 7105 | tempbl = 0; |
| 7106 | tempbh = 0; |
| 7107 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7108 | /* / Get LCD Delay */ |
| 7109 | tempah = pVBInfo->LCDCapList[ |
| 7110 | XGI_GetLCDCapPtr(pVBInfo)]. |
| 7111 | LCD_DelayCompensation; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7112 | tempah &= 0x0f; |
| 7113 | tempah = tempah << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7114 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7115 | tempah); |
| 7116 | } |
| 7117 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7118 | } |
| 7119 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7120 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 7121 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7122 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7123 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7124 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7125 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7126 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7127 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7128 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7129 | /* Enable Dither */ |
| 7130 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7131 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7132 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7133 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7134 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7135 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7136 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7137 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7138 | /* |
| 7139 | if (tempcx & EnableLCD24bpp) { // 24bits |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7140 | xgifb_reg_and_or(pVBInfo->Part1Port, |
| 7141 | 0x19, |
| 7142 | 0x0F, |
| 7143 | (unsigned short)(0x30 | (tempcx&0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7144 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7145 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7146 | xgifb_reg_and_or(pVBInfo->Part1Port, |
| 7147 | 0x19, |
| 7148 | 0x0F, |
| 7149 | // Enable Dither |
| 7150 | (unsigned short)(0x20 | (tempcx&0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7151 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7152 | } |
| 7153 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7154 | } |
| 7155 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7156 | /* --------------------------------------------------------------------- */ |
| 7157 | /* Function : XGI_SetLCDCap_B */ |
| 7158 | /* Input : cx -> LCD Capability */ |
| 7159 | /* Output : */ |
| 7160 | /* Description : */ |
| 7161 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7162 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 7163 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7164 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7165 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7166 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7167 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 7168 | | 0x0c)); |
| 7169 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7170 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7171 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 7172 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7173 | } |
| 7174 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7175 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7176 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7177 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7178 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7179 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7180 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7181 | /* disable down spectrum D[4] */ |
| 7182 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7183 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7184 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7185 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7186 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7187 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7188 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7189 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7190 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7191 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7192 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7193 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7194 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 7195 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7196 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7197 | } |
| 7198 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7199 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 7200 | { |
| 7201 | unsigned short tempcx; |
| 7202 | |
| 7203 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 7204 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7205 | if (pVBInfo->VBType & |
| 7206 | (VB_XGI301B | |
| 7207 | VB_XGI302B | |
| 7208 | VB_XGI301LV | |
| 7209 | VB_XGI302LV | |
| 7210 | VB_XGI301C)) { /* 301LV/302LV only */ |
| 7211 | if (pVBInfo->VBType & |
| 7212 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7213 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7214 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7215 | (unsigned char) (tempcx & 0x1F)); |
| 7216 | } |
| 7217 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7218 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7219 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 7220 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 7221 | | EnablePLLSPLOW)) >> 8)); |
| 7222 | } |
| 7223 | |
| 7224 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7225 | | VB_XGI302LV | VB_XGI301C)) { |
| 7226 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 7227 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
| 7228 | else if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 7229 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 7230 | |
| 7231 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 7232 | if (tempcx & EnableSpectrum) |
| 7233 | SetSpectrum(pVBInfo); |
| 7234 | } |
| 7235 | } else { |
| 7236 | /* LVDS,CH7017 */ |
| 7237 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 7238 | } |
| 7239 | } |
| 7240 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7241 | /* --------------------------------------------------------------------- */ |
| 7242 | /* Function : XGI_SetAntiFlicker */ |
| 7243 | /* Input : */ |
| 7244 | /* Output : */ |
| 7245 | /* Description : Set TV Customized Param. */ |
| 7246 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7247 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
| 7248 | unsigned short ModeIdIndex, |
| 7249 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7250 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7251 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7252 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7253 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7254 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7255 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
| 7256 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7257 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7258 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 7259 | tempbx &= 0xFE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7260 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7261 | if (ModeNo <= 0x13) |
| 7262 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; |
| 7263 | else |
| 7264 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7265 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7266 | tempbx += index; |
| 7267 | tempah = TVAntiFlickList[tempbx]; |
| 7268 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7269 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7270 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7271 | } |
| 7272 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7273 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
| 7274 | unsigned short ModeIdIndex, |
| 7275 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7276 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7277 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7278 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7279 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7280 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7281 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 7282 | tempbx &= 0xFE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7283 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7284 | if (ModeNo <= 0x13) |
| 7285 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; |
| 7286 | else |
| 7287 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7288 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7289 | tempbx += index; |
| 7290 | tempah = TVEdgeList[tempbx]; |
| 7291 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7292 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7293 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7294 | } |
| 7295 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7296 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7297 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7298 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7299 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7300 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7301 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7302 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7303 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7304 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 7305 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7306 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7307 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7308 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7309 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7310 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7311 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7312 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7313 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7314 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7315 | } |
| 7316 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7317 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7318 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7319 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7320 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7321 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7322 | unsigned char tempcl, tempch, tempal, *filterPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7323 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7324 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7325 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7326 | switch (tempbx) { |
| 7327 | case 0x00: |
| 7328 | case 0x04: |
| 7329 | filterPtr = NTSCYFilter1; |
| 7330 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7331 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7332 | case 0x01: |
| 7333 | filterPtr = PALYFilter1; |
| 7334 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7335 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7336 | case 0x02: |
| 7337 | case 0x05: |
| 7338 | case 0x0D: |
| 7339 | filterPtr = PALMYFilter1; |
| 7340 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7341 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7342 | case 0x03: |
| 7343 | filterPtr = PALNYFilter1; |
| 7344 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7345 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7346 | case 0x08: |
| 7347 | case 0x0C: |
| 7348 | filterPtr = NTSCYFilter2; |
| 7349 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7350 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7351 | case 0x0A: |
| 7352 | filterPtr = PALMYFilter2; |
| 7353 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7354 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7355 | case 0x0B: |
| 7356 | filterPtr = PALNYFilter2; |
| 7357 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7358 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7359 | case 0x09: |
| 7360 | filterPtr = PALYFilter2; |
| 7361 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7362 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7363 | default: |
| 7364 | return; |
| 7365 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7366 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7367 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7368 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 7369 | VB_StTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7370 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7371 | tempal = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 7372 | VB_ExtTVYFilterIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7373 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7374 | if (tempcl == 0) |
| 7375 | index = tempal * 4; |
| 7376 | else |
| 7377 | index = tempal * 7; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7378 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7379 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7380 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 7381 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 7382 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 7383 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7384 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7385 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 7386 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 7387 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 7388 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7389 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7390 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7391 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7392 | | VB_XGI302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7393 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 7394 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 7395 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7396 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7397 | } |
| 7398 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7399 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7400 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7401 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7402 | /* Output : */ |
| 7403 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7404 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7405 | static void XGI_OEM310Setting(unsigned short ModeNo, |
| 7406 | unsigned short ModeIdIndex, |
| 7407 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7408 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7409 | if (pVBInfo->SetFlag & Win9xDOSMode) |
| 7410 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7411 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7412 | /* GetPart1IO(); */ |
| 7413 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7414 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7415 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
| 7416 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7417 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7418 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 7419 | /* GetPart2IO() */ |
| 7420 | XGI_SetPhaseIncr(pVBInfo); |
| 7421 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); |
| 7422 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7423 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7424 | if (pVBInfo->VBType & VB_XGI301) |
| 7425 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7426 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7427 | } |
| 7428 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7429 | /* --------------------------------------------------------------------- */ |
| 7430 | /* Function : XGI_SetCRT2ModeRegs */ |
| 7431 | /* Input : */ |
| 7432 | /* Output : */ |
| 7433 | /* Description : Origin code for crt2group */ |
| 7434 | /* --------------------------------------------------------------------- */ |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 7435 | void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7436 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7437 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7438 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7439 | unsigned short tempbl; |
| 7440 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7441 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7442 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7443 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7444 | /* // fix write part1 index 0 BTDRAM bit Bug |
| 7445 | * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7446 | tempah = 0; |
| 7447 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7448 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7449 | tempah &= ~0x10; /* BTRAMDAC */ |
| 7450 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7451 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7452 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 7453 | | SetCRT2ToLCD)) { |
| 7454 | tempah = 0x40; /* BTDRAM */ |
| 7455 | if (ModeNo > 0x13) { |
| 7456 | tempcl = pVBInfo->ModeType; |
| 7457 | tempcl -= ModeVGA; |
| 7458 | if (tempcl >= 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7459 | /* BT Color */ |
| 7460 | tempah = (0x008 >> tempcl); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7461 | if (tempah == 0) |
| 7462 | tempah = 1; |
| 7463 | tempah |= 0x040; |
| 7464 | } |
| 7465 | } |
| 7466 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 7467 | tempah ^= 0x50; /* BTDAC */ |
| 7468 | } |
| 7469 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7470 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7471 | /* 0210 shampoo |
| 7472 | if (pVBInfo->VBInfo & DisableCRT2Display) { |
| 7473 | tempah = 0; |
| 7474 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7475 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7476 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7477 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) { |
| 7478 | tempcl = pVBInfo->ModeType; |
| 7479 | if (ModeNo > 0x13) { |
| 7480 | tempcl -= ModeVGA; |
| 7481 | if ((tempcl > 0) || (tempcl == 0)) { |
| 7482 | tempah=(0x008>>tempcl) ; |
| 7483 | if (tempah == 0) |
| 7484 | tempah = 1; |
| 7485 | tempah |= 0x040; |
| 7486 | } |
| 7487 | } else { |
| 7488 | tempah = 0x040; |
| 7489 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7490 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7491 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 7492 | tempah = (tempah ^ 0x050); |
| 7493 | } |
| 7494 | } |
| 7495 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7496 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7497 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7498 | tempah = 0x08; |
| 7499 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7500 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7501 | if (pVBInfo->VBInfo & DisableCRT2Display) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7502 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7503 | } else { |
| 7504 | tempah = 0x00; |
| 7505 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7506 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7507 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 7508 | | SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7509 | if ((pVBInfo->VBInfo & SetCRT2ToLCDA) && |
| 7510 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7511 | tempbl &= 0xf7; |
| 7512 | tempah |= 0x01; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7513 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7514 | tempbl, tempah); |
| 7515 | } else { |
| 7516 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 7517 | tempbl &= 0xf7; |
| 7518 | tempah |= 0x01; |
| 7519 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7520 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7521 | if (pVBInfo->VBInfo & |
| 7522 | (SetCRT2ToRAMDAC | |
| 7523 | SetCRT2ToTV | |
| 7524 | SetCRT2ToLCD)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7525 | tempbl &= 0xf8; |
| 7526 | tempah = 0x01; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7527 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7528 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 7529 | tempah |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7530 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7531 | if (!(pVBInfo->VBInfo & |
| 7532 | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7533 | tempah = tempah ^ 0x05; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7534 | if (!(pVBInfo->VBInfo & |
| 7535 | SetCRT2ToLCD)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7536 | tempah = tempah ^ 0x01; |
| 7537 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7538 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7539 | if (!(pVBInfo->VBInfo & |
| 7540 | SetCRT2ToDualEdge)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7541 | tempah |= 0x08; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7542 | xgifb_reg_and_or(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7543 | 0x2e, tempbl, tempah); |
| 7544 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7545 | xgifb_reg_and_or(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7546 | 0x2e, tempbl, tempah); |
| 7547 | } |
| 7548 | } |
| 7549 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7550 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7551 | tempah); |
| 7552 | } |
| 7553 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7554 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7555 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
| 7556 | | SetCRT2ToLCDA)) { |
| 7557 | tempah &= (~0x08); |
| 7558 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 7559 | & SetInSlaveMode))) { |
| 7560 | tempah |= 0x010; |
| 7561 | } |
| 7562 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7563 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7564 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7565 | /* if (!(pVBInfo->TVInfo & |
| 7566 | (SetYPbPrMode525p | SetYPbPrMode750p))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7567 | tempah |= 0x020; |
| 7568 | if (ModeNo > 0x13) { |
| 7569 | if (pVBInfo->VBInfo & DriverMode) |
| 7570 | tempah = tempah ^ 0x20; |
| 7571 | } |
| 7572 | /* } */ |
| 7573 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7574 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7575 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7576 | tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7577 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7578 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 7579 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7580 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7581 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7582 | /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && |
| 7583 | (!(pVBInfo->TVInfo & |
| 7584 | (SetYPbPrMode525p | SetYPbPrMode750p)))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7585 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 7586 | tempah |= 0x40; |
| 7587 | /* } */ |
| 7588 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7589 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7590 | if ((pVBInfo->LCDResInfo == Panel1280x1024) |
| 7591 | || (pVBInfo->LCDResInfo == Panel1280x1024x75)) |
| 7592 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7593 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7594 | if (pVBInfo->LCDResInfo == Panel1280x960) |
| 7595 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7596 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7597 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7598 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7600 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7601 | | VB_XGI302LV | VB_XGI301C)) { |
| 7602 | tempah = 0; |
| 7603 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7604 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7605 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 7606 | tempbl = 0xff; |
| 7607 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 7608 | tempah |= 0x04; /* shampoo 0129 */ |
| 7609 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7610 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7611 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7612 | tempah = 0x00; |
| 7613 | tempbl = 0xcf; |
| 7614 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 7615 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 7616 | tempah |= 0x30; |
| 7617 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7618 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7619 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7620 | tempah = 0; |
| 7621 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7622 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7623 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 7624 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 7625 | tempah |= 0xc0; |
| 7626 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7627 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7628 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7629 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7630 | tempah = 0; |
| 7631 | tempbl = 0x7f; |
| 7632 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) { |
| 7633 | tempbl = 0xff; |
| 7634 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 7635 | tempah |= 0x80; |
| 7636 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7637 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7638 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7639 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7640 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 7641 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7642 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 7643 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7644 | } |
| 7645 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7646 | } |
| 7647 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7648 | static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7649 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7650 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7651 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7652 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7653 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7654 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7655 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 7656 | tempbx = 0x08A0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7657 | |
| 7658 | } |
| 7659 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7660 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 7661 | struct vb_device_info *pVBInfo) |
| 7662 | { |
| 7663 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7664 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7665 | |
| 7666 | } |
| 7667 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7668 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 7669 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7670 | { |
| 7671 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7672 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7673 | |
| 7674 | } |
| 7675 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 7676 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7677 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7678 | unsigned short flag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7679 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7680 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 7681 | return 1; |
| 7682 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7683 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7684 | if ((flag == 1) || (flag == 2)) |
| 7685 | return 1; /* 301b */ |
| 7686 | else |
| 7687 | return 0; |
| 7688 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7689 | } |
| 7690 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 7691 | void XGI_LongWait(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7692 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7693 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7694 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7695 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7696 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7697 | if (!(i & 0xC0)) { |
| 7698 | for (i = 0; i < 0xFFFF; i++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7699 | if (!(inb(pVBInfo->P3da) & 0x08)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7700 | break; |
| 7701 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7702 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7703 | for (i = 0; i < 0xFFFF; i++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7704 | if ((inb(pVBInfo->P3da) & 0x08)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7705 | break; |
| 7706 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7707 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7708 | } |
| 7709 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7710 | static void XGI_VBLongWait(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7711 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7712 | unsigned short tempal, temp, i, j; |
| 7713 | return; |
| 7714 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 7715 | temp = 0; |
| 7716 | for (i = 0; i < 3; i++) { |
| 7717 | for (j = 0; j < 100; j++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7718 | tempal = inb(pVBInfo->P3da); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7719 | if (temp & 0x01) { /* VBWaitMode2 */ |
| 7720 | if ((tempal & 0x08)) |
| 7721 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7722 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7723 | if (!(tempal & 0x08)) |
| 7724 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7725 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7726 | } else { /* VBWaitMode1 */ |
| 7727 | if (!(tempal & 0x08)) |
| 7728 | continue; |
| 7729 | |
| 7730 | if ((tempal & 0x08)) |
| 7731 | break; |
| 7732 | } |
| 7733 | } |
| 7734 | temp = temp ^ 0x01; |
| 7735 | } |
| 7736 | } else { |
| 7737 | XGI_LongWait(pVBInfo); |
| 7738 | } |
| 7739 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7740 | } |
| 7741 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7742 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 7743 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 7744 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7745 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7746 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, |
| 7747 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, |
| 7748 | 0x01, 0x01 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7749 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7750 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7751 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7752 | if (ModeNo <= 0x13) |
| 7753 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 7754 | else |
| 7755 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 7756 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7757 | if (ModeNo < 0x14) |
| 7758 | return 0xFFFF; |
| 7759 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7760 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7761 | index = index >> pVBInfo->SelectCRT2Rate; |
| 7762 | index &= 0x0F; |
| 7763 | |
| 7764 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 7765 | index = 0; |
| 7766 | |
| 7767 | if (index > 0) |
| 7768 | index--; |
| 7769 | |
| 7770 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7771 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 7772 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 7773 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 7774 | | VB_XGI301LV | VB_XGI302LV |
| 7775 | | VB_XGI301C)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7776 | /* 301b */ |
| 7777 | temp = LCDARefreshIndex[ |
| 7778 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7779 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7780 | temp = LCDRefreshIndex[ |
| 7781 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7782 | |
| 7783 | if (index > temp) |
| 7784 | index = temp; |
| 7785 | } else { |
| 7786 | index = 0; |
| 7787 | } |
| 7788 | } |
| 7789 | } |
| 7790 | |
| 7791 | RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex; |
| 7792 | ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID; |
| 7793 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
| 7794 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7795 | if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & |
| 7796 | XG2xNotSupport) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7797 | index++; |
| 7798 | } |
| 7799 | */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7800 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 7801 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7802 | index++; |
| 7803 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7804 | /* Alan 10/19/2007; |
| 7805 | * do the similar adjustment like XGISearchCRT1Rate() */ |
| 7806 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 7807 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7808 | index++; |
| 7809 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7810 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 7811 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7812 | index++; |
| 7813 | } |
| 7814 | } |
| 7815 | |
| 7816 | i = 0; |
| 7817 | do { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7818 | if (pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 7819 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7820 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7821 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 7822 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7823 | temp &= ModeInfoFlag; |
| 7824 | if (temp < pVBInfo->ModeType) |
| 7825 | break; |
| 7826 | i++; |
| 7827 | index--; |
| 7828 | |
| 7829 | } while (index != 0xFFFF); |
| 7830 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 7831 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7832 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1]. |
| 7833 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7834 | if (temp & InterlaceMode) |
| 7835 | i++; |
| 7836 | } |
| 7837 | } |
| 7838 | i--; |
| 7839 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
| 7840 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, |
| 7841 | RefreshRateTableIndex, &i, pVBInfo); |
| 7842 | } |
| 7843 | return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7844 | } |
| 7845 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7846 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7847 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7848 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7849 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7850 | unsigned short RefreshRateTableIndex; |
| 7851 | /* unsigned short temp ; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7852 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7853 | /* pVBInfo->SelectCRT2Rate = 0; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7854 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7855 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7856 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7857 | ModeIdIndex, pVBInfo); |
| 7858 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7859 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7860 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7861 | HwDeviceExtension, pVBInfo); |
| 7862 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7863 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7864 | } |
| 7865 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7866 | unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
| 7867 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7868 | struct vb_device_info *pVBInfo) |
| 7869 | { |
| 7870 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
| 7871 | |
| 7872 | tempbx = pVBInfo->VBInfo; |
| 7873 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7874 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 7875 | pVBInfo->SelectCRT2Rate = 4; |
| 7876 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7877 | ModeIdIndex, pVBInfo); |
| 7878 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
| 7879 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7880 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7881 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7882 | RefreshRateTableIndex, pVBInfo); |
| 7883 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7884 | RefreshRateTableIndex, pVBInfo); |
| 7885 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7886 | RefreshRateTableIndex, pVBInfo); |
| 7887 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7888 | HwDeviceExtension, pVBInfo); |
| 7889 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7890 | RefreshRateTableIndex, pVBInfo); |
| 7891 | XGI_SetTap4Regs(pVBInfo); |
| 7892 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); |
| 7893 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7894 | HwDeviceExtension, pVBInfo); |
| 7895 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7896 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); |
| 7897 | XGI_AutoThreshold(pVBInfo); |
| 7898 | return 1; |
| 7899 | } |
| 7900 | |
| 7901 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 7902 | { |
| 7903 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 7904 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 7905 | 0x05, 0x00 }; |
| 7906 | |
| 7907 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 7908 | |
| 7909 | unsigned char CR17, CR63, SR31; |
| 7910 | unsigned short temp; |
| 7911 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; |
| 7912 | |
| 7913 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7914 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7915 | |
| 7916 | /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7917 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7918 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7919 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 7920 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7921 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 7922 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 7923 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7924 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7925 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 7926 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7927 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7928 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7929 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7930 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7931 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7932 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7933 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7934 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7935 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7936 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7937 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7938 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7939 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7940 | |
| 7941 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7942 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7943 | |
| 7944 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7945 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7946 | CRTCData[i]); |
| 7947 | |
| 7948 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7949 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7950 | CRTCData[i]); |
| 7951 | |
| 7952 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7953 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7954 | CRTCData[i]); |
| 7955 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7956 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7957 | & 0xE0)); |
| 7958 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7959 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 7960 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 7961 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7962 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7963 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7964 | |
| 7965 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7966 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
| 7967 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); |
| 7968 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7969 | } |
| 7970 | |
| 7971 | XGI_VBLongWait(pVBInfo); |
| 7972 | XGI_VBLongWait(pVBInfo); |
| 7973 | XGI_VBLongWait(pVBInfo); |
| 7974 | |
| 7975 | mdelay(1); |
| 7976 | |
| 7977 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7978 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7979 | |
| 7980 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7981 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7982 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7983 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7984 | |
| 7985 | /* alan, avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7986 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7987 | |
| 7988 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7989 | outb(0, (pVBInfo->P3c8 + 1)); |
| 7990 | outb(0, (pVBInfo->P3c8 + 1)); |
| 7991 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7992 | } |
| 7993 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7994 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 7995 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 7996 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7997 | |
| 7998 | /* [2004/05/11] Vicent */ |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7999 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8000 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8001 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8002 | } |
| 8003 | |
| 8004 | void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
| 8005 | struct vb_device_info *pVBInfo) |
| 8006 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 8007 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8008 | |
| 8009 | if (pVBInfo->SetFlag == Win9xDOSMode) { |
| 8010 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 8011 | | VB_XGI302LV | VB_XGI301C)) { |
| 8012 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8013 | return; |
| 8014 | } else |
| 8015 | /* LVDS or CH7017 */ |
| 8016 | return; |
| 8017 | } |
| 8018 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8019 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 8020 | | VB_XGI302LV | VB_XGI301C)) { |
| 8021 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 8022 | if (pVBInfo->SetFlag & EnableChA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8023 | /* Power on */ |
| 8024 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8025 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8026 | /* SetCRT2ToLCDA ) */ |
| 8027 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 8028 | /* Power on */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8029 | xgifb_reg_set(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8030 | 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8031 | } |
| 8032 | } |
| 8033 | } |
| 8034 | |
| 8035 | if (!(pVBInfo->SetFlag & DisableChB)) { |
| 8036 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo |
| 8037 | & (SetCRT2ToLCD | SetCRT2ToTV |
| 8038 | | SetCRT2ToRAMDAC))) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8039 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8040 | pVBInfo->P3c4, 0x32); |
| 8041 | tempah &= 0xDF; |
| 8042 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8043 | if (!(pVBInfo->VBInfo & |
| 8044 | SetCRT2ToRAMDAC)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8045 | tempah |= 0x20; |
| 8046 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8047 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 8048 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8049 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8050 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8051 | pVBInfo->Part1Port, 0x2E); |
| 8052 | |
| 8053 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8054 | /* BVBDOENABLE = 1 */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 8055 | xgifb_reg_or(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8056 | 0x2E, 0x80); |
| 8057 | /* BScreenOFF = 0 */ |
| 8058 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8059 | } |
| 8060 | } |
| 8061 | |
| 8062 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
| 8063 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 8064 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8065 | 0x20); /* shampoo 0129 */ |
| 8066 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 8067 | if (!XGI_DisableChISLCD(pVBInfo)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8068 | if (XGI_EnableChISLCD(pVBInfo) || |
| 8069 | (pVBInfo->VBInfo & |
| 8070 | (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 8071 | /* LVDS PLL power on */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 8072 | xgifb_reg_and( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8073 | pVBInfo->Part4Port, |
| 8074 | 0x2A, |
| 8075 | 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8076 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8077 | /* LVDS Driver power on */ |
| 8078 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8079 | } |
| 8080 | } |
| 8081 | |
| 8082 | tempah = 0x00; |
| 8083 | |
| 8084 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 8085 | tempah = 0xc0; |
| 8086 | |
| 8087 | if (!(pVBInfo->VBInfo & SetSimuScanMode)) { |
| 8088 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8089 | if (pVBInfo->VBInfo & |
| 8090 | SetCRT2ToDualEdge) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8091 | tempah = tempah & 0x40; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8092 | if (pVBInfo->VBInfo & |
| 8093 | SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8094 | tempah = tempah ^ 0xC0; |
| 8095 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8096 | if (pVBInfo->SetFlag & |
| 8097 | DisableChB) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8098 | tempah &= 0xBF; |
| 8099 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8100 | if (pVBInfo->SetFlag & |
| 8101 | DisableChA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8102 | tempah &= 0x7F; |
| 8103 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8104 | if (pVBInfo->SetFlag & |
| 8105 | EnableChB) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8106 | tempah |= 0x40; |
| 8107 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8108 | if (pVBInfo->SetFlag & |
| 8109 | EnableChA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8110 | tempah |= 0x80; |
| 8111 | } |
| 8112 | } |
| 8113 | } |
| 8114 | } |
| 8115 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8116 | /* EnablePart4_1F */ |
| 8117 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8118 | |
| 8119 | if (pVBInfo->SetFlag & Win9xDOSMode) { |
| 8120 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8121 | return; |
| 8122 | } |
| 8123 | |
| 8124 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 8125 | XGI_VBLongWait(pVBInfo); |
| 8126 | if (!(pVBInfo->SetFlag & GatingCRT)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8127 | XGI_DisableGatingCRT(HwDeviceExtension, |
| 8128 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8129 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8130 | XGI_VBLongWait(pVBInfo); |
| 8131 | } |
| 8132 | } |
| 8133 | } /* 301 */ |
| 8134 | else { /* LVDS */ |
| 8135 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
| 8136 | | SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8137 | /* enable CRT2 */ |
| 8138 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8139 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8140 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8141 | 0x2E); |
| 8142 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8143 | /* BVBDOENABLE = 1 */ |
| 8144 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8145 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 8146 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8147 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8148 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8149 | } |
| 8150 | |
| 8151 | static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, |
| 8152 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 8153 | struct vb_device_info *pVBInfo) |
| 8154 | { |
| 8155 | unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp; |
| 8156 | |
| 8157 | unsigned short XGINew_P3cc = pVBInfo->P3cc; |
| 8158 | |
| 8159 | /* XGINew_CRT1Mode = ModeNo; // SaveModeID */ |
| 8160 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
| 8161 | /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */ |
| 8162 | /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */ |
| 8163 | XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); |
| 8164 | XGI_SetMiscRegs(StandTableIndex, pVBInfo); |
| 8165 | XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo); |
| 8166 | XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); |
| 8167 | XGI_SetGRCRegs(StandTableIndex, pVBInfo); |
| 8168 | XGI_ClearExt1Regs(pVBInfo); |
| 8169 | |
| 8170 | /* if (pVBInfo->IF_DEF_ExpLink) */ |
| 8171 | if (HwDeviceExtension->jChipType == XG27) { |
| 8172 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 8173 | XGI_SetDefaultVCLK(pVBInfo); |
| 8174 | } |
| 8175 | |
| 8176 | temp = ~ProgrammingCRT2; |
| 8177 | pVBInfo->SetFlag &= temp; |
| 8178 | pVBInfo->SelectCRT2Rate = 0; |
| 8179 | |
| 8180 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 8181 | | VB_XGI302LV | VB_XGI301C)) { |
| 8182 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA |
| 8183 | | SetInSlaveMode)) { |
| 8184 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 8185 | } |
| 8186 | } |
| 8187 | |
| 8188 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 8189 | ModeIdIndex, pVBInfo); |
| 8190 | if (RefreshRateTableIndex != 0xFFFF) { |
| 8191 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
| 8192 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 8193 | pVBInfo, HwDeviceExtension); |
| 8194 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 8195 | RefreshRateTableIndex, pVBInfo); |
| 8196 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 8197 | HwDeviceExtension, pVBInfo); |
| 8198 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 8199 | RefreshRateTableIndex, pVBInfo); |
| 8200 | } |
| 8201 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8202 | if ((HwDeviceExtension->jChipType >= XG20) && |
| 8203 | (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8204 | if ((ModeNo == 0x00) | (ModeNo == 0x01)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8205 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E); |
| 8206 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 8207 | b3CC = (unsigned char) inb(XGINew_P3cc); |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 8208 | outb((b3CC |= 0x0C), XGINew_P3cc); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8209 | } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo |
| 8210 | == 0x0D)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8211 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 8212 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 8213 | b3CC = (unsigned char) inb(XGINew_P3cc); |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 8214 | outb((b3CC |= 0x0C), XGINew_P3cc); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8215 | } |
| 8216 | } |
| 8217 | |
| 8218 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8219 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8220 | if (temp & 0xA0) { |
| 8221 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8222 | /* Enable write GPIOF */ |
| 8223 | /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */ |
| 8224 | /* P. DWN */ |
| 8225 | /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8226 | /* XG21 CRT1 Timing */ |
| 8227 | if (HwDeviceExtension->jChipType == XG27) |
| 8228 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, |
| 8229 | RefreshRateTableIndex, pVBInfo); |
| 8230 | else |
| 8231 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, |
| 8232 | RefreshRateTableIndex, pVBInfo); |
| 8233 | |
| 8234 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 8235 | RefreshRateTableIndex); |
| 8236 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame^] | 8237 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
| 8238 | pVBInfo, RefreshRateTableIndex, ModeNo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8239 | |
| 8240 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 8241 | if (HwDeviceExtension->jChipType == XG27) |
| 8242 | XGI_SetXG27LVDSPara(ModeNo, |
| 8243 | ModeIdIndex, pVBInfo); |
| 8244 | else |
| 8245 | XGI_SetXG21LVDSPara(ModeNo, |
| 8246 | ModeIdIndex, pVBInfo); |
| 8247 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8248 | /* P. ON */ |
| 8249 | /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8250 | } |
| 8251 | } |
| 8252 | |
| 8253 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
| 8254 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); |
| 8255 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 8256 | RefreshRateTableIndex, pVBInfo); |
| 8257 | |
| 8258 | /* XGI_LoadCharacter(); //dif ifdef TVFont */ |
| 8259 | |
| 8260 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
| 8261 | /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */ |
| 8262 | } |
| 8263 | |
| 8264 | unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, |
| 8265 | unsigned short ModeNo) |
| 8266 | { |
| 8267 | unsigned short ModeIdIndex; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8268 | /* unsigned char *pVBInfo->FBAddr = |
| 8269 | HwDeviceExtension->pjVideoMemoryAddress; */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8270 | struct vb_device_info VBINF; |
| 8271 | struct vb_device_info *pVBInfo = &VBINF; |
| 8272 | pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; |
| 8273 | pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; |
| 8274 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8275 | pVBInfo->IF_DEF_LCDA = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8276 | pVBInfo->IF_DEF_VideoCapture = 0; |
| 8277 | pVBInfo->IF_DEF_ScaleLCD = 0; |
| 8278 | pVBInfo->IF_DEF_OEMUtil = 0; |
| 8279 | pVBInfo->IF_DEF_PWD = 0; |
| 8280 | |
| 8281 | if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ |
| 8282 | pVBInfo->IF_DEF_YPbPr = 0; |
| 8283 | pVBInfo->IF_DEF_HiVision = 0; |
| 8284 | pVBInfo->IF_DEF_CRT2Monitor = 0; |
| 8285 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8286 | } else { |
| 8287 | pVBInfo->IF_DEF_YPbPr = 1; |
| 8288 | pVBInfo->IF_DEF_HiVision = 1; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 8289 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8290 | } |
| 8291 | |
| 8292 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; |
| 8293 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; |
| 8294 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; |
| 8295 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; |
| 8296 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; |
| 8297 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; |
| 8298 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; |
| 8299 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; |
| 8300 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; |
| 8301 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; |
| 8302 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; |
| 8303 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; |
| 8304 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; |
| 8305 | pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04; |
| 8306 | pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10; |
| 8307 | pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12; |
| 8308 | pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14; |
| 8309 | pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2; |
| 8310 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8311 | /* for x86 Linux, XG21 LVDS */ |
| 8312 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8313 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8314 | pVBInfo->IF_DEF_LVDS = 1; |
| 8315 | } |
| 8316 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8317 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 8318 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8319 | pVBInfo->IF_DEF_LVDS = 1; |
| 8320 | } |
| 8321 | } |
| 8322 | |
| 8323 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
| 8324 | XGI_GetVBType(pVBInfo); |
| 8325 | |
| 8326 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
| 8327 | if (ModeNo & 0x80) { |
| 8328 | ModeNo = ModeNo & 0x7F; |
| 8329 | /* XGINew_flag_clearbuffer = 0; */ |
| 8330 | } |
| 8331 | /* else { |
| 8332 | XGINew_flag_clearbuffer = 1; |
| 8333 | } |
| 8334 | */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8335 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8336 | |
| 8337 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ |
| 8338 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
| 8339 | |
| 8340 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 8341 | |
| 8342 | XGI_GetVGAType(HwDeviceExtension, pVBInfo); |
| 8343 | |
| 8344 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 8345 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 8346 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 8347 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 8348 | XGI_DisableBridge(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8349 | |
| 8350 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { |
| 8351 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, |
| 8352 | ModeIdIndex, pVBInfo); |
| 8353 | |
| 8354 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 8355 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 8356 | HwDeviceExtension, pVBInfo); |
| 8357 | } |
| 8358 | } else { |
| 8359 | if (!(pVBInfo->VBInfo & SwitchToCRT2)) { |
| 8360 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, |
| 8361 | ModeIdIndex, pVBInfo); |
| 8362 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 8363 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 8364 | HwDeviceExtension, |
| 8365 | pVBInfo); |
| 8366 | } |
| 8367 | } |
| 8368 | } |
| 8369 | |
| 8370 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) { |
| 8371 | switch (HwDeviceExtension->ujVBChipID) { |
| 8372 | case VB_CHIP_301: |
| 8373 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 8374 | pVBInfo); /*add for CRT2 */ |
| 8375 | break; |
| 8376 | |
| 8377 | case VB_CHIP_302: |
| 8378 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 8379 | pVBInfo); /*add for CRT2 */ |
| 8380 | break; |
| 8381 | |
| 8382 | default: |
| 8383 | break; |
| 8384 | } |
| 8385 | } |
| 8386 | |
| 8387 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
| 8388 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ |
| 8389 | XGI_CloseCRTC(HwDeviceExtension, pVBInfo); |
| 8390 | XGI_EnableBridge(HwDeviceExtension, pVBInfo); |
| 8391 | } /* !XG20 */ |
| 8392 | else { |
| 8393 | if (pVBInfo->IF_DEF_LVDS == 1) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8394 | if (!XGI_XG21CheckLVDSMode(ModeNo, |
| 8395 | ModeIdIndex, |
| 8396 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8397 | return 0; |
| 8398 | |
| 8399 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8400 | pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 8401 | St_ModeFlag & ModeInfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8402 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8403 | pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 8404 | Ext_ModeFlag & ModeInfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8405 | } |
| 8406 | |
| 8407 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 8408 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8409 | |
| 8410 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 8411 | |
| 8412 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 8413 | pVBInfo); |
| 8414 | |
| 8415 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8416 | /* |
| 8417 | if (HwDeviceExtension->jChipType == XG21) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 8418 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8419 | */ |
| 8420 | } |
| 8421 | |
| 8422 | /* |
| 8423 | if (ModeNo <= 0x13) { |
| 8424 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 8425 | } else { |
| 8426 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 8427 | } |
| 8428 | pVBInfo->ModeType = modeflag&ModeInfoFlag; |
| 8429 | pVBInfo->SetFlag = 0x00; |
| 8430 | pVBInfo->VBInfo = DisableCRT2Display; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8431 | temp = XGINew_CheckMemorySize(HwDeviceExtension, |
| 8432 | ModeNo, |
| 8433 | ModeIdIndex, |
| 8434 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8435 | |
| 8436 | if (temp == 0) |
| 8437 | return (0); |
| 8438 | |
| 8439 | XGI_DisplayOff(HwDeviceExtension, pVBInfo) ; |
| 8440 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); |
| 8441 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8442 | */ |
| 8443 | |
| 8444 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
| 8445 | |
| 8446 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 8447 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
| 8448 | } |
| 8449 | |
| 8450 | return 1; |
| 8451 | } |