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 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 991 | /* --------------------------------------------------------------------- */ |
| 992 | /* Function : XGI_SetXG21LCD */ |
| 993 | /* Input : */ |
| 994 | /* Output : FCLK duty cycle, FCLK delay compensation */ |
| 995 | /* Description : All values set zero */ |
| 996 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 997 | static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 998 | unsigned short RefreshRateTableIndex, unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 999 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1000 | unsigned short Data, Temp, b3CC; |
| 1001 | unsigned short XGI_P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1002 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1003 | XGI_P3cc = pVBInfo->P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1004 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1005 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 1006 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 1007 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 1008 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1009 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1010 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); |
| 1011 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); |
| 1012 | xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); |
| 1013 | xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1014 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1015 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1016 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1017 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1018 | if (Temp & 0x01) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1019 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */ |
| 1020 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1021 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1022 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1023 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1024 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 1025 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); |
| 1026 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1027 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1028 | if (ModeNo <= 0x13) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1029 | b3CC = (unsigned char) inb(XGI_P3cc); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1030 | if (b3CC & 0x40) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1031 | /* Hsync polarity */ |
| 1032 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1033 | if (b3CC & 0x80) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1034 | /* Vsync polarity */ |
| 1035 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1036 | } else { |
| 1037 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1038 | if (Data & 0x4000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1039 | /* Hsync polarity */ |
| 1040 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1041 | if (Data & 0x8000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1042 | /* Vsync polarity */ |
| 1043 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1044 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1045 | } |
| 1046 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1047 | static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1048 | unsigned short RefreshRateTableIndex, |
| 1049 | unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1050 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1051 | unsigned short Data, Temp, b3CC; |
| 1052 | unsigned short XGI_P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1053 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1054 | XGI_P3cc = pVBInfo->P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1055 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1056 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 1057 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 1058 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 1059 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1060 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1061 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1062 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1063 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 1064 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1065 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1066 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1067 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1068 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); |
| 1069 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); |
| 1070 | xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); |
| 1071 | xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1072 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1073 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1074 | XGI_SetXG27FPBits(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1075 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1076 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1077 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 1078 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 1079 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1080 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1081 | if (ModeNo <= 0x13) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1082 | b3CC = (unsigned char) inb(XGI_P3cc); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1083 | if (b3CC & 0x40) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1084 | /* Hsync polarity */ |
| 1085 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1086 | if (b3CC & 0x80) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1087 | /* Vsync polarity */ |
| 1088 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1089 | } else { |
| 1090 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1091 | if (Data & 0x4000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1092 | /* Hsync polarity */ |
| 1093 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1094 | if (Data & 0x8000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1095 | /* Vsync polarity */ |
| 1096 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1097 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | /* --------------------------------------------------------------------- */ |
| 1101 | /* Function : XGI_UpdateXG21CRTC */ |
| 1102 | /* Input : */ |
| 1103 | /* Output : CRT1 CRTC */ |
| 1104 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 1105 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1106 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 1107 | struct vb_device_info *pVBInfo, |
| 1108 | unsigned short RefreshRateTableIndex) |
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 | int i, index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1111 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 1112 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1113 | if (ModeNo <= 0x13) { |
| 1114 | for (i = 0; i < 12; i++) { |
| 1115 | if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID) |
| 1116 | index = i; |
| 1117 | } |
| 1118 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1119 | if (ModeNo == 0x2E && |
| 1120 | (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
| 1121 | RES640x480x60)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1122 | index = 12; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1123 | else if (ModeNo == 0x2E && |
| 1124 | (pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1125 | Ext_CRT1CRTC == RES640x480x72)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1126 | index = 13; |
| 1127 | else if (ModeNo == 0x2F) |
| 1128 | index = 14; |
| 1129 | else if (ModeNo == 0x50) |
| 1130 | index = 15; |
| 1131 | else if (ModeNo == 0x59) |
| 1132 | index = 16; |
| 1133 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1134 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1135 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1136 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1137 | pVBInfo->UpdateCRT1[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1138 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1139 | pVBInfo->UpdateCRT1[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1140 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1141 | pVBInfo->UpdateCRT1[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1142 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1143 | pVBInfo->UpdateCRT1[index].CR16); |
| 1144 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1145 | } |
| 1146 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1147 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1148 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1149 | unsigned short RefreshRateTableIndex, |
| 1150 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1151 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1152 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1153 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1154 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1155 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1156 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1157 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1158 | if (ModeNo <= 0x13) { |
| 1159 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1160 | tempax = pVBInfo->StResInfo[resindex].HTotal; |
| 1161 | tempbx = pVBInfo->StResInfo[resindex].VTotal; |
| 1162 | } else { |
| 1163 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1164 | tempax = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1165 | tempbx = pVBInfo->ModeResInfo[resindex].VTotal; |
| 1166 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1167 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1168 | if (modeflag & HalfDCLK) |
| 1169 | tempax = tempax >> 1; |
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 (ModeNo > 0x13) { |
| 1172 | if (modeflag & HalfDCLK) |
| 1173 | tempax = tempax << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1174 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1175 | temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1176 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1177 | if (temp & InterlaceMode) |
| 1178 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1179 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1180 | if (modeflag & DoubleScanMode) |
| 1181 | tempbx = tempbx << 1; |
| 1182 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1183 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1184 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1185 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1186 | /* if (!(modeflag & Charx8Dot)) */ |
| 1187 | /* tempcx = 9; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1188 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1189 | tempax /= tempcx; |
| 1190 | tempax -= 1; |
| 1191 | tempbx -= 1; |
| 1192 | tempcx = tempax; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1193 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 1194 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1195 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1196 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 1197 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1198 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1199 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1200 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1201 | tempax = 0; |
| 1202 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1203 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1204 | if (tempbx & 0x01) |
| 1205 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1206 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1207 | if (tempbx & 0x02) |
| 1208 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1209 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1210 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1211 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1212 | data &= 0xFF; |
| 1213 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1214 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1215 | if (tempbx & 0x04) |
| 1216 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1217 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1218 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1219 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1220 | } |
| 1221 | |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1222 | unsigned short XGI_GetResInfo(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1223 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1224 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1225 | unsigned short resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1226 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1227 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1228 | /* si+St_ResInfo */ |
| 1229 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1230 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1231 | /* si+Ext_ResInfo */ |
| 1232 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1233 | return resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1234 | } |
| 1235 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1236 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 1237 | unsigned short ModeIdIndex, |
| 1238 | unsigned short RefreshRateTableIndex, |
| 1239 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1240 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1241 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1242 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1243 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1244 | /* GetOffset */ |
| 1245 | temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 1246 | temp = temp >> 8; |
| 1247 | temp = pVBInfo->ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1248 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1249 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1250 | temp2 &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1251 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1252 | if (temp2) |
| 1253 | temp = temp << 1; |
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 | temp2 = pVBInfo->ModeType - ModeEGA; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1256 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1257 | switch (temp2) { |
| 1258 | case 0: |
| 1259 | temp2 = 1; |
| 1260 | break; |
| 1261 | case 1: |
| 1262 | temp2 = 2; |
| 1263 | break; |
| 1264 | case 2: |
| 1265 | temp2 = 4; |
| 1266 | break; |
| 1267 | case 3: |
| 1268 | temp2 = 4; |
| 1269 | break; |
| 1270 | case 4: |
| 1271 | temp2 = 6; |
| 1272 | break; |
| 1273 | case 5: |
| 1274 | temp2 = 8; |
| 1275 | break; |
| 1276 | default: |
| 1277 | break; |
| 1278 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1279 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1280 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 1281 | temp = temp * temp2 + temp2 / 2; |
| 1282 | else |
| 1283 | temp *= temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1284 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1285 | /* SetOffset */ |
| 1286 | DisplayUnit = temp; |
| 1287 | temp2 = temp; |
| 1288 | temp = temp >> 8; /* ah */ |
| 1289 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1290 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1291 | i &= 0xF0; |
| 1292 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1293 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1294 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1295 | temp = (unsigned char) temp2; |
| 1296 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1297 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1298 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1299 | /* SetDisplayUnit */ |
| 1300 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1301 | temp2 &= InterlaceMode; |
| 1302 | if (temp2) |
| 1303 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1304 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1305 | DisplayUnit = DisplayUnit << 5; |
| 1306 | ah = (DisplayUnit & 0xff00) >> 8; |
| 1307 | al = DisplayUnit & 0x00ff; |
| 1308 | if (al == 0) |
| 1309 | ah += 1; |
| 1310 | else |
| 1311 | ah += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1312 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1313 | if (HwDeviceExtension->jChipType >= XG20) |
| 1314 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 1315 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1316 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1317 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1318 | } |
| 1319 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1320 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
| 1321 | unsigned short ModeIdIndex, |
| 1322 | unsigned short RefreshRateTableIndex, |
| 1323 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1324 | struct vb_device_info *pVBInfo) |
| 1325 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1326 | unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, |
| 1327 | VCLK65 + 2, |
| 1328 | VCLK65 + 2, |
| 1329 | VCLK65 + 2 }; |
| 1330 | unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, |
| 1331 | VCLK108_2 + 5, |
| 1332 | VCLK108_2 + 5, |
| 1333 | VCLK108_2 + 5 }; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1334 | unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 }; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1335 | unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, |
| 1336 | VCLK65 + 2, |
| 1337 | VCLK65 + 2, |
| 1338 | VCLK65 + 2 }; |
| 1339 | unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, |
| 1340 | VCLK65 + 2, |
| 1341 | VCLK65 + 2, |
| 1342 | VCLK65 + 2 }; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1343 | |
| 1344 | unsigned short CRT2Index, VCLKIndex; |
| 1345 | unsigned short modeflag, resinfo; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1346 | |
| 1347 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1348 | /* si+St_ResInfo */ |
| 1349 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1350 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 1351 | CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 1352 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1353 | /* si+Ext_ResInfo */ |
| 1354 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1355 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1356 | CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1357 | Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 1361 | CRT2Index = CRT2Index >> 6; /* for LCD */ |
| 1362 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/ |
| 1363 | if (pVBInfo->LCDResInfo != Panel1024x768) |
| 1364 | VCLKIndex = LCDXlat2VCLK[CRT2Index]; |
| 1365 | else |
| 1366 | VCLKIndex = LCDXlat1VCLK[CRT2Index]; |
| 1367 | } else { /* for TV */ |
| 1368 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 1369 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 1370 | if (pVBInfo->SetFlag & RPLLDIV2XO) { |
| 1371 | VCLKIndex = HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1372 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1373 | } else { |
| 1374 | VCLKIndex = HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1375 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1376 | } |
| 1377 | |
| 1378 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 1379 | if (modeflag & Charx8Dot) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1380 | VCLKIndex = |
| 1381 | HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1382 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1383 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1384 | VCLKIndex = |
| 1385 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1386 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1387 | } |
| 1388 | } |
| 1389 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1390 | /* 301lv */ |
| 1391 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 1392 | if (!(pVBInfo->VBExtInfo == |
| 1393 | VB_YPbPr1080i)) { |
| 1394 | VCLKIndex = |
| 1395 | YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1396 | if (!(pVBInfo->VBExtInfo |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1397 | == |
| 1398 | VB_YPbPr750p)) { |
| 1399 | VCLKIndex = |
| 1400 | YPbPr525pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1401 | if (!(pVBInfo->VBExtInfo |
| 1402 | == VB_YPbPr525p)) { |
| 1403 | VCLKIndex |
| 1404 | = YPbPr525iVCLK_2; |
| 1405 | if (!(pVBInfo->SetFlag |
| 1406 | & RPLLDIV2XO)) |
| 1407 | VCLKIndex |
| 1408 | = YPbPr525iVCLK; |
| 1409 | } |
| 1410 | } |
| 1411 | } |
| 1412 | } |
| 1413 | } else { |
| 1414 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1415 | if (pVBInfo->SetFlag & |
| 1416 | RPLLDIV2XO) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1417 | VCLKIndex = TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1418 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1419 | } else { |
| 1420 | VCLKIndex = TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1421 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1422 | } |
| 1423 | } |
| 1424 | } |
| 1425 | } else { /* for CRT2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1426 | /* Port 3cch */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1427 | VCLKIndex = (unsigned char) inb( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1428 | (pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1429 | VCLKIndex = ((VCLKIndex >> 2) & 0x03); |
| 1430 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1431 | /* di+Ext_CRTVCLK */ |
| 1432 | VCLKIndex = |
| 1433 | pVBInfo->RefIndex[ |
| 1434 | RefreshRateTableIndex]. |
| 1435 | Ext_CRTVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1436 | VCLKIndex &= IndexMask; |
| 1437 | } |
| 1438 | } |
| 1439 | } |
| 1440 | } else { /* LVDS */ |
| 1441 | if (ModeNo <= 0x13) |
| 1442 | VCLKIndex = CRT2Index; |
| 1443 | else |
| 1444 | VCLKIndex = CRT2Index; |
| 1445 | |
Aaro Koskinen | 4c14bfd | 2011-08-31 21:45:57 +0300 | [diff] [blame] | 1446 | VCLKIndex = VCLKIndex >> 6; |
| 1447 | if ((pVBInfo->LCDResInfo == Panel800x600) || |
| 1448 | (pVBInfo->LCDResInfo == Panel320x480)) |
| 1449 | VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; |
| 1450 | else if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 1451 | (pVBInfo->LCDResInfo == Panel1024x768x75)) |
| 1452 | VCLKIndex = LVDSXlat2VCLK[VCLKIndex]; |
| 1453 | else |
| 1454 | VCLKIndex = LVDSXlat3VCLK[VCLKIndex]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1455 | } |
| 1456 | /* VCLKIndex = VCLKIndex&IndexMask; */ |
| 1457 | |
| 1458 | return VCLKIndex; |
| 1459 | } |
| 1460 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1461 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
| 1462 | unsigned short ModeIdIndex, |
| 1463 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1464 | unsigned short RefreshRateTableIndex, |
| 1465 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1466 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 1467 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1468 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1469 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1470 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 1471 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1472 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1473 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1474 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1475 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1476 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1477 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1478 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1479 | } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 1480 | | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo |
| 1481 | & SetCRT2ToLCDA)) { |
| 1482 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, |
| 1483 | RefreshRateTableIndex, HwDeviceExtension, |
| 1484 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1485 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1486 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1487 | data = pVBInfo->VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1488 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1489 | data = pVBInfo->VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1490 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 1491 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1492 | } else { |
| 1493 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1494 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1495 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1496 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1497 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1498 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1499 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1500 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1501 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1502 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1503 | if (HwDeviceExtension->jChipType >= XG20) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1504 | if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
| 1505 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1506 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1507 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1508 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1509 | index = data; |
| 1510 | index &= 0xE0; |
| 1511 | data &= 0x1F; |
| 1512 | data = data << 1; |
| 1513 | data += 1; |
| 1514 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1515 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1516 | } |
| 1517 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1518 | } |
| 1519 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1520 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1521 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1522 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1523 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1524 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1525 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1526 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1527 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1528 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1529 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1530 | if (ModeNo > 0x13) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1531 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1532 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1533 | data &= 0xC0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1534 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1535 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1536 | data |= 0x01; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1537 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1538 | } else { |
| 1539 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1540 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1541 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1542 | data &= 0xC0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1543 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1544 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1545 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1546 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1547 | data &= 0xF0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1548 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1549 | } |
| 1550 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1551 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1552 | if (HwDeviceExtension->jChipType == XG21) |
| 1553 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1554 | } |
| 1555 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1556 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
| 1557 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, |
| 1558 | struct vb_device_info *pVBInfo) |
| 1559 | { |
| 1560 | unsigned short data, data2 = 0; |
| 1561 | short VCLK; |
| 1562 | |
| 1563 | unsigned char index; |
| 1564 | |
| 1565 | if (ModeNo <= 0x13) |
| 1566 | VCLK = 0; |
| 1567 | else { |
| 1568 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 1569 | index &= IndexMask; |
| 1570 | VCLK = pVBInfo->VCLKData[index].CLOCK; |
| 1571 | } |
| 1572 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1573 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1574 | data &= 0xf3; |
| 1575 | if (VCLK >= 200) |
| 1576 | data |= 0x0c; /* VCLK > 200 */ |
| 1577 | |
| 1578 | if (HwDeviceExtension->jChipType >= XG20) |
| 1579 | data &= ~0x04; /* 2 pixel mode */ |
| 1580 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1581 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1582 | |
| 1583 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1584 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1585 | data &= 0xE7; |
| 1586 | if (VCLK < 200) |
| 1587 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1588 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1589 | } |
| 1590 | |
| 1591 | /* Jong for Adavantech LCD ripple issue |
| 1592 | if ((VCLK >= 0) && (VCLK < 135)) |
| 1593 | data2 = 0x03; |
| 1594 | else if ((VCLK >= 135) && (VCLK < 160)) |
| 1595 | data2 = 0x02; |
| 1596 | else if ((VCLK >= 160) && (VCLK < 260)) |
| 1597 | data2 = 0x01; |
| 1598 | else if (VCLK > 260) |
| 1599 | data2 = 0x00; |
| 1600 | */ |
| 1601 | data2 = 0x00; |
| 1602 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1603 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1604 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1605 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1606 | |
| 1607 | } |
| 1608 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1609 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1610 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1611 | unsigned short RefreshRateTableIndex, |
| 1612 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1613 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1614 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1615 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1616 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1617 | if (ModeNo > 0x13) { |
| 1618 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1619 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1620 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1621 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1622 | /* si+St_ModeFlag */ |
| 1623 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1624 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1625 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1626 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1627 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1628 | if (ModeNo > 0x13) |
| 1629 | data = infoflag; |
| 1630 | else |
| 1631 | data = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1632 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1633 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1634 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1635 | if (ModeNo > 0x13) { |
| 1636 | if (pVBInfo->ModeType > 0x02) { |
| 1637 | data2 |= 0x02; |
| 1638 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1639 | data3 = data3 << 2; |
| 1640 | data2 |= data3; |
| 1641 | } |
| 1642 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1643 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1644 | data &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1645 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1646 | if (data) |
| 1647 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1648 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1649 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1650 | /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1651 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 1652 | if (ModeNo <= 0x13) |
| 1653 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 1654 | else |
| 1655 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1656 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1657 | data = 0x0000; |
| 1658 | if (infoflag & InterlaceMode) { |
| 1659 | if (xres == 1024) |
| 1660 | data = 0x0035; |
| 1661 | else if (xres == 1280) |
| 1662 | data = 0x0048; |
| 1663 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1664 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1665 | data2 = data & 0x00FF; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1666 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1667 | data2 = (data & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1668 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1669 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1670 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1671 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1672 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1673 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1674 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1675 | if (modeflag & LineCompareOff) |
| 1676 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1677 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1678 | if (ModeNo > 0x13) { |
| 1679 | if (pVBInfo->ModeType == ModeEGA) |
| 1680 | data2 |= 0x40; |
| 1681 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1682 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1683 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1684 | data = 0x60; |
| 1685 | if (pVBInfo->ModeType != ModeText) { |
| 1686 | data = data ^ 0x60; |
| 1687 | if (pVBInfo->ModeType != ModeEGA) |
| 1688 | data = data ^ 0xA0; |
| 1689 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1690 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1691 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1692 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, |
| 1693 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1694 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1695 | /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */ |
| 1696 | /* if (XGINew_IF_DEF_NEW_LOWRES) */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1697 | /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); |
| 1698 | * //030305 fix lowresolution bug */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1699 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1700 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1701 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1702 | if (HwDeviceExtension->jChipType == XG27) { |
| 1703 | if (data & 0x40) |
| 1704 | data = 0x2c; |
| 1705 | else |
| 1706 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1707 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1708 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1709 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1710 | if (data & 0x40) |
| 1711 | data = 0x33; |
| 1712 | else |
| 1713 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1714 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1715 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1716 | } else { |
| 1717 | if (data & 0x40) |
| 1718 | data = 0x2c; |
| 1719 | else |
| 1720 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1721 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1722 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1723 | |
| 1724 | } |
| 1725 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1726 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1727 | void XGI_VesaLowResolution(unsigned short ModeNo, |
| 1728 | unsigned short ModeIdIndex, |
| 1729 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1730 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1731 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1732 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1733 | if (ModeNo > 0x13) |
| 1734 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1735 | else |
| 1736 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1737 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1738 | if (ModeNo > 0x13) { |
| 1739 | if (modeflag & DoubleScanMode) { |
| 1740 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1741 | if (pVBInfo->VBType & VB_XGI301B | |
| 1742 | VB_XGI302B | |
| 1743 | VB_XGI301LV | |
| 1744 | VB_XGI302LV | |
| 1745 | VB_XGI301C)) { |
| 1746 | if (!(pVBInfo->VBInfo & |
| 1747 | SetCRT2ToRAMDAC)) { |
| 1748 | if (pVBInfo->VBInfo & |
| 1749 | SetInSlaveMode) { |
| 1750 | xgifb_reg_and_or( |
| 1751 | pVBInfo->P3c4, |
| 1752 | 0x01, |
| 1753 | 0xf7, |
| 1754 | 0x00); |
| 1755 | xgifb_reg_and_or( |
| 1756 | pVBInfo->P3c4, |
| 1757 | 0x0f, |
| 1758 | 0x7f, |
| 1759 | 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1760 | return; |
| 1761 | } |
| 1762 | } |
| 1763 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1764 | xgifb_reg_and_or(pVBInfo->P3c4, |
| 1765 | 0x0f, |
| 1766 | 0xff, |
| 1767 | 0x80); |
| 1768 | xgifb_reg_and_or(pVBInfo->P3c4, |
| 1769 | 0x01, |
| 1770 | 0xf7, |
| 1771 | 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1772 | return; |
| 1773 | } |
| 1774 | } |
| 1775 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1776 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1777 | } |
| 1778 | */ |
| 1779 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1780 | static void XGI_WriteDAC(unsigned short dl, |
| 1781 | unsigned short ah, |
| 1782 | unsigned short al, |
| 1783 | unsigned short dh, |
| 1784 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1785 | { |
| 1786 | unsigned short temp, bh, bl; |
| 1787 | |
| 1788 | bh = ah; |
| 1789 | bl = al; |
| 1790 | |
| 1791 | if (dl != 0) { |
| 1792 | temp = bh; |
| 1793 | bh = dh; |
| 1794 | dh = temp; |
| 1795 | if (dl == 1) { |
| 1796 | temp = bl; |
| 1797 | bl = dh; |
| 1798 | dh = temp; |
| 1799 | } else { |
| 1800 | temp = bl; |
| 1801 | bl = bh; |
| 1802 | bh = temp; |
| 1803 | } |
| 1804 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1805 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1806 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1807 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1808 | } |
| 1809 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1810 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1811 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1812 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1813 | unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al, |
| 1814 | ah, dh, *table = NULL; |
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 (ModeNo <= 0x13) |
| 1817 | data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1818 | else |
| 1819 | data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1820 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1821 | data &= DACInfoFlag; |
| 1822 | time = 64; |
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 | if (data == 0x00) |
| 1825 | table = XGINew_MDA_DAC; |
| 1826 | else if (data == 0x08) |
| 1827 | table = XGINew_CGA_DAC; |
| 1828 | else if (data == 0x10) |
| 1829 | table = XGINew_EGA_DAC; |
| 1830 | else if (data == 0x18) { |
| 1831 | time = 256; |
| 1832 | table = XGINew_VGA_DAC; |
| 1833 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1834 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1835 | if (time == 256) |
| 1836 | j = 16; |
| 1837 | else |
| 1838 | j = time; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1839 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1840 | outb(0xFF, pVBInfo->P3c6); |
| 1841 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1842 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1843 | for (i = 0; i < j; i++) { |
| 1844 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1845 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1846 | for (k = 0; k < 3; k++) { |
| 1847 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1848 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1849 | if (data & 0x01) |
| 1850 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1851 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1852 | if (data & 0x02) |
| 1853 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1854 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1855 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1856 | data = data >> 2; |
| 1857 | } |
| 1858 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1859 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1860 | if (time == 256) { |
| 1861 | for (i = 16; i < 32; i++) { |
| 1862 | data = table[i]; |
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 | for (k = 0; k < 3; k++) |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1865 | outb(data, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1866 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1867 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1868 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1869 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1870 | for (m = 0; m < 9; m++) { |
| 1871 | di = si; |
| 1872 | bx = si + 0x04; |
| 1873 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1874 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1875 | for (n = 0; n < 3; n++) { |
| 1876 | for (o = 0; o < 5; o++) { |
| 1877 | dh = table[si]; |
| 1878 | ah = table[di]; |
| 1879 | al = table[bx]; |
| 1880 | si++; |
| 1881 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1882 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1883 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1884 | si -= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1885 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1886 | for (o = 0; o < 3; o++) { |
| 1887 | dh = table[bx]; |
| 1888 | ah = table[di]; |
| 1889 | al = table[si]; |
| 1890 | si--; |
| 1891 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1892 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1893 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1894 | dl++; |
| 1895 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1896 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1897 | si += 5; |
| 1898 | } |
| 1899 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1900 | } |
| 1901 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1902 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
| 1903 | unsigned short ModeIdIndex, |
| 1904 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1905 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1906 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1907 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1908 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1909 | /* si+St_ResInfo */ |
| 1910 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1911 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1912 | /* si+Ext_ResInfo */ |
| 1913 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1914 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1915 | /* if (ModeNo > 0x13) */ |
| 1916 | /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */ |
| 1917 | /* else */ |
| 1918 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1919 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1920 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1921 | /* si+St_ResInfo */ |
| 1922 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1923 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1924 | /* si+Ext_ResInfo */ |
| 1925 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1926 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1927 | /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1928 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1929 | if (ModeNo <= 0x13) { |
| 1930 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 1931 | yres = pVBInfo->StResInfo[resindex].VTotal; |
| 1932 | } else { |
| 1933 | xres = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1934 | yres = pVBInfo->ModeResInfo[resindex].VTotal; |
| 1935 | } |
| 1936 | if (ModeNo > 0x13) { |
| 1937 | if (modeflag & HalfDCLK) |
| 1938 | xres = xres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1939 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1940 | if (modeflag & DoubleScanMode) |
| 1941 | yres = yres << 1; |
| 1942 | } |
| 1943 | /* if (modeflag & Charx8Dot) */ |
| 1944 | /* { */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1945 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1946 | if (xres == 720) |
| 1947 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1948 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1949 | /* } */ |
| 1950 | pVBInfo->VGAHDE = xres; |
| 1951 | pVBInfo->HDE = xres; |
| 1952 | pVBInfo->VGAVDE = yres; |
| 1953 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1954 | } |
| 1955 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1956 | static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, |
| 1957 | unsigned short ModeIdIndex, |
| 1958 | unsigned short RefreshRateTableIndex, |
| 1959 | struct vb_device_info *pVBInfo) |
| 1960 | { |
| 1961 | unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table; |
| 1962 | |
| 1963 | struct XGI330_LCDDataTablStruct *tempdi = NULL; |
| 1964 | |
| 1965 | tempbx = BX; |
| 1966 | |
| 1967 | if (ModeNo <= 0x13) { |
| 1968 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1969 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 1970 | } else { |
| 1971 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1972 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
| 1973 | } |
| 1974 | |
| 1975 | tempal = tempal & 0x0f; |
| 1976 | |
| 1977 | if (tempbx <= 1) { /* ExpLink */ |
| 1978 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1979 | /* find no Ext_CRT2CRTC2 */ |
| 1980 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1981 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1982 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1983 | Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1984 | } |
| 1985 | |
| 1986 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 1987 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1988 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 1989 | St_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1990 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1991 | tempal = pVBInfo->RefIndex[ |
| 1992 | RefreshRateTableIndex]. |
| 1993 | Ext_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1994 | } |
| 1995 | |
| 1996 | if (tempbx & 0x01) |
| 1997 | tempal = (tempal >> 4); |
| 1998 | |
| 1999 | tempal = (tempal & 0x0f); |
| 2000 | } |
| 2001 | |
| 2002 | tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */ |
| 2003 | |
| 2004 | if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */ |
| 2005 | if ((tempbx == 5) || (tempbx) == 7) |
| 2006 | tempcx = LCDDesDataLen2; |
| 2007 | else if ((tempbx == 3) || (tempbx == 8)) |
| 2008 | tempcx = LVDSDesDataLen2; |
| 2009 | } |
| 2010 | /* mov di, word ptr cs:LCDDataList[bx] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2011 | /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | |
| 2012 | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2013 | |
| 2014 | switch (tempbx) { |
| 2015 | case 0: |
| 2016 | tempdi = XGI_EPLLCDCRT1Ptr_H; |
| 2017 | break; |
| 2018 | case 1: |
| 2019 | tempdi = XGI_EPLLCDCRT1Ptr_V; |
| 2020 | break; |
| 2021 | case 2: |
| 2022 | tempdi = XGI_EPLLCDDataPtr; |
| 2023 | break; |
| 2024 | case 3: |
| 2025 | tempdi = XGI_EPLLCDDesDataPtr; |
| 2026 | break; |
| 2027 | case 4: |
| 2028 | tempdi = XGI_LCDDataTable; |
| 2029 | break; |
| 2030 | case 5: |
| 2031 | tempdi = XGI_LCDDesDataTable; |
| 2032 | break; |
| 2033 | case 6: |
| 2034 | tempdi = XGI_EPLCHLCDRegPtr; |
| 2035 | break; |
| 2036 | case 7: |
| 2037 | case 8: |
| 2038 | case 9: |
| 2039 | tempdi = NULL; |
| 2040 | break; |
| 2041 | default: |
| 2042 | break; |
| 2043 | } |
| 2044 | |
| 2045 | if (tempdi == NULL) /* OEMUtil */ |
| 2046 | return NULL; |
| 2047 | |
| 2048 | table = tempbx; |
| 2049 | i = 0; |
| 2050 | |
| 2051 | while (tempdi[i].PANELID != 0xff) { |
| 2052 | tempdx = pVBInfo->LCDResInfo; |
| 2053 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 2054 | tempbx &= (~0x0080); |
| 2055 | tempdx = pVBInfo->LCDTypeInfo; |
| 2056 | } |
| 2057 | |
| 2058 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2059 | tempdx &= (~PanelResInfo); |
| 2060 | |
| 2061 | if (tempdi[i].PANELID == tempdx) { |
| 2062 | tempbx = tempdi[i].MASK; |
| 2063 | tempdx = pVBInfo->LCDInfo; |
| 2064 | |
| 2065 | if (ModeNo <= 0x13) /* alan 09/10/2003 */ |
| 2066 | tempdx |= SetLCDStdMode; |
| 2067 | |
| 2068 | if (modeflag & HalfDCLK) |
| 2069 | tempdx |= SetLCDLowResolution; |
| 2070 | |
| 2071 | tempbx &= tempdx; |
| 2072 | if (tempbx == tempdi[i].CAP) |
| 2073 | break; |
| 2074 | } |
| 2075 | i++; |
| 2076 | } |
| 2077 | |
| 2078 | if (table == 0) { |
| 2079 | switch (tempdi[i].DATAPTR) { |
| 2080 | case 0: |
| 2081 | return &XGI_LVDSCRT11024x768_1_H[tempal]; |
| 2082 | break; |
| 2083 | case 1: |
| 2084 | return &XGI_LVDSCRT11024x768_2_H[tempal]; |
| 2085 | break; |
| 2086 | case 2: |
| 2087 | return &XGI_LVDSCRT11280x1024_1_H[tempal]; |
| 2088 | break; |
| 2089 | case 3: |
| 2090 | return &XGI_LVDSCRT11280x1024_2_H[tempal]; |
| 2091 | break; |
| 2092 | case 4: |
| 2093 | return &XGI_LVDSCRT11400x1050_1_H[tempal]; |
| 2094 | break; |
| 2095 | case 5: |
| 2096 | return &XGI_LVDSCRT11400x1050_2_H[tempal]; |
| 2097 | break; |
| 2098 | case 6: |
| 2099 | return &XGI_LVDSCRT11600x1200_1_H[tempal]; |
| 2100 | break; |
| 2101 | case 7: |
| 2102 | return &XGI_LVDSCRT11024x768_1_Hx75[tempal]; |
| 2103 | break; |
| 2104 | case 8: |
| 2105 | return &XGI_LVDSCRT11024x768_2_Hx75[tempal]; |
| 2106 | break; |
| 2107 | case 9: |
| 2108 | return &XGI_LVDSCRT11280x1024_1_Hx75[tempal]; |
| 2109 | break; |
| 2110 | case 10: |
| 2111 | return &XGI_LVDSCRT11280x1024_2_Hx75[tempal]; |
| 2112 | break; |
| 2113 | default: |
| 2114 | break; |
| 2115 | } |
| 2116 | } else if (table == 1) { |
| 2117 | switch (tempdi[i].DATAPTR) { |
| 2118 | case 0: |
| 2119 | return &XGI_LVDSCRT11024x768_1_V[tempal]; |
| 2120 | break; |
| 2121 | case 1: |
| 2122 | return &XGI_LVDSCRT11024x768_2_V[tempal]; |
| 2123 | break; |
| 2124 | case 2: |
| 2125 | return &XGI_LVDSCRT11280x1024_1_V[tempal]; |
| 2126 | break; |
| 2127 | case 3: |
| 2128 | return &XGI_LVDSCRT11280x1024_2_V[tempal]; |
| 2129 | break; |
| 2130 | case 4: |
| 2131 | return &XGI_LVDSCRT11400x1050_1_V[tempal]; |
| 2132 | break; |
| 2133 | case 5: |
| 2134 | return &XGI_LVDSCRT11400x1050_2_V[tempal]; |
| 2135 | break; |
| 2136 | case 6: |
| 2137 | return &XGI_LVDSCRT11600x1200_1_V[tempal]; |
| 2138 | break; |
| 2139 | case 7: |
| 2140 | return &XGI_LVDSCRT11024x768_1_Vx75[tempal]; |
| 2141 | break; |
| 2142 | case 8: |
| 2143 | return &XGI_LVDSCRT11024x768_2_Vx75[tempal]; |
| 2144 | break; |
| 2145 | case 9: |
| 2146 | return &XGI_LVDSCRT11280x1024_1_Vx75[tempal]; |
| 2147 | break; |
| 2148 | case 10: |
| 2149 | return &XGI_LVDSCRT11280x1024_2_Vx75[tempal]; |
| 2150 | break; |
| 2151 | default: |
| 2152 | break; |
| 2153 | } |
| 2154 | } else if (table == 2) { |
| 2155 | switch (tempdi[i].DATAPTR) { |
| 2156 | case 0: |
| 2157 | return &XGI_LVDS1024x768Data_1[tempal]; |
| 2158 | break; |
| 2159 | case 1: |
| 2160 | return &XGI_LVDS1024x768Data_2[tempal]; |
| 2161 | break; |
| 2162 | case 2: |
| 2163 | return &XGI_LVDS1280x1024Data_1[tempal]; |
| 2164 | break; |
| 2165 | case 3: |
| 2166 | return &XGI_LVDS1280x1024Data_2[tempal]; |
| 2167 | break; |
| 2168 | case 4: |
| 2169 | return &XGI_LVDS1400x1050Data_1[tempal]; |
| 2170 | break; |
| 2171 | case 5: |
| 2172 | return &XGI_LVDS1400x1050Data_2[tempal]; |
| 2173 | break; |
| 2174 | case 6: |
| 2175 | return &XGI_LVDS1600x1200Data_1[tempal]; |
| 2176 | break; |
| 2177 | case 7: |
| 2178 | return &XGI_LVDSNoScalingData[tempal]; |
| 2179 | break; |
| 2180 | case 8: |
| 2181 | return &XGI_LVDS1024x768Data_1x75[tempal]; |
| 2182 | break; |
| 2183 | case 9: |
| 2184 | return &XGI_LVDS1024x768Data_2x75[tempal]; |
| 2185 | break; |
| 2186 | case 10: |
| 2187 | return &XGI_LVDS1280x1024Data_1x75[tempal]; |
| 2188 | break; |
| 2189 | case 11: |
| 2190 | return &XGI_LVDS1280x1024Data_2x75[tempal]; |
| 2191 | break; |
| 2192 | case 12: |
| 2193 | return &XGI_LVDSNoScalingDatax75[tempal]; |
| 2194 | break; |
| 2195 | default: |
| 2196 | break; |
| 2197 | } |
| 2198 | } else if (table == 3) { |
| 2199 | switch (tempdi[i].DATAPTR) { |
| 2200 | case 0: |
| 2201 | return &XGI_LVDS1024x768Des_1[tempal]; |
| 2202 | break; |
| 2203 | case 1: |
| 2204 | return &XGI_LVDS1024x768Des_3[tempal]; |
| 2205 | break; |
| 2206 | case 2: |
| 2207 | return &XGI_LVDS1024x768Des_2[tempal]; |
| 2208 | break; |
| 2209 | case 3: |
| 2210 | return &XGI_LVDS1280x1024Des_1[tempal]; |
| 2211 | break; |
| 2212 | case 4: |
| 2213 | return &XGI_LVDS1280x1024Des_2[tempal]; |
| 2214 | break; |
| 2215 | case 5: |
| 2216 | return &XGI_LVDS1400x1050Des_1[tempal]; |
| 2217 | break; |
| 2218 | case 6: |
| 2219 | return &XGI_LVDS1400x1050Des_2[tempal]; |
| 2220 | break; |
| 2221 | case 7: |
| 2222 | return &XGI_LVDS1600x1200Des_1[tempal]; |
| 2223 | break; |
| 2224 | case 8: |
| 2225 | return &XGI_LVDSNoScalingDesData[tempal]; |
| 2226 | break; |
| 2227 | case 9: |
| 2228 | return &XGI_LVDS1024x768Des_1x75[tempal]; |
| 2229 | break; |
| 2230 | case 10: |
| 2231 | return &XGI_LVDS1024x768Des_3x75[tempal]; |
| 2232 | break; |
| 2233 | case 11: |
| 2234 | return &XGI_LVDS1024x768Des_2x75[tempal]; |
| 2235 | break; |
| 2236 | case 12: |
| 2237 | return &XGI_LVDS1280x1024Des_1x75[tempal]; |
| 2238 | break; |
| 2239 | case 13: |
| 2240 | return &XGI_LVDS1280x1024Des_2x75[tempal]; |
| 2241 | break; |
| 2242 | case 14: |
| 2243 | return &XGI_LVDSNoScalingDesDatax75[tempal]; |
| 2244 | break; |
| 2245 | default: |
| 2246 | break; |
| 2247 | } |
| 2248 | } else if (table == 4) { |
| 2249 | switch (tempdi[i].DATAPTR) { |
| 2250 | case 0: |
| 2251 | return &XGI_ExtLCD1024x768Data[tempal]; |
| 2252 | break; |
| 2253 | case 1: |
| 2254 | return &XGI_StLCD1024x768Data[tempal]; |
| 2255 | break; |
| 2256 | case 2: |
| 2257 | return &XGI_CetLCD1024x768Data[tempal]; |
| 2258 | break; |
| 2259 | case 3: |
| 2260 | return &XGI_ExtLCD1280x1024Data[tempal]; |
| 2261 | break; |
| 2262 | case 4: |
| 2263 | return &XGI_StLCD1280x1024Data[tempal]; |
| 2264 | break; |
| 2265 | case 5: |
| 2266 | return &XGI_CetLCD1280x1024Data[tempal]; |
| 2267 | break; |
| 2268 | case 6: |
| 2269 | return &XGI_ExtLCD1400x1050Data[tempal]; |
| 2270 | break; |
| 2271 | case 7: |
| 2272 | return &XGI_StLCD1400x1050Data[tempal]; |
| 2273 | break; |
| 2274 | case 8: |
| 2275 | return &XGI_CetLCD1400x1050Data[tempal]; |
| 2276 | break; |
| 2277 | case 9: |
| 2278 | return &XGI_ExtLCD1600x1200Data[tempal]; |
| 2279 | break; |
| 2280 | case 10: |
| 2281 | return &XGI_StLCD1600x1200Data[tempal]; |
| 2282 | break; |
| 2283 | case 11: |
| 2284 | return &XGI_NoScalingData[tempal]; |
| 2285 | break; |
| 2286 | case 12: |
| 2287 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 2288 | break; |
| 2289 | case 13: |
| 2290 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 2291 | break; |
| 2292 | case 14: |
| 2293 | return &XGI_CetLCD1024x768x75Data[tempal]; |
| 2294 | break; |
| 2295 | case 15: |
| 2296 | return &XGI_ExtLCD1280x1024x75Data[tempal]; |
| 2297 | break; |
| 2298 | case 16: |
| 2299 | return &XGI_StLCD1280x1024x75Data[tempal]; |
| 2300 | break; |
| 2301 | case 17: |
| 2302 | return &XGI_CetLCD1280x1024x75Data[tempal]; |
| 2303 | break; |
| 2304 | case 18: |
| 2305 | return &XGI_NoScalingDatax75[tempal]; |
| 2306 | break; |
| 2307 | default: |
| 2308 | break; |
| 2309 | } |
| 2310 | } else if (table == 5) { |
| 2311 | switch (tempdi[i].DATAPTR) { |
| 2312 | case 0: |
| 2313 | return &XGI_ExtLCDDes1024x768Data[tempal]; |
| 2314 | break; |
| 2315 | case 1: |
| 2316 | return &XGI_StLCDDes1024x768Data[tempal]; |
| 2317 | break; |
| 2318 | case 2: |
| 2319 | return &XGI_CetLCDDes1024x768Data[tempal]; |
| 2320 | break; |
| 2321 | case 3: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2322 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2323 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2324 | return &XGI_ExtLCDDLDes1280x1024Data[tempal]; |
| 2325 | else |
| 2326 | return &XGI_ExtLCDDes1280x1024Data[tempal]; |
| 2327 | break; |
| 2328 | case 4: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2329 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2330 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2331 | return &XGI_StLCDDLDes1280x1024Data[tempal]; |
| 2332 | else |
| 2333 | return &XGI_StLCDDes1280x1024Data[tempal]; |
| 2334 | break; |
| 2335 | case 5: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2336 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2337 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2338 | return &XGI_CetLCDDLDes1280x1024Data[tempal]; |
| 2339 | else |
| 2340 | return &XGI_CetLCDDes1280x1024Data[tempal]; |
| 2341 | break; |
| 2342 | case 6: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2343 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2344 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2345 | return &XGI_ExtLCDDLDes1400x1050Data[tempal]; |
| 2346 | else |
| 2347 | return &XGI_ExtLCDDes1400x1050Data[tempal]; |
| 2348 | break; |
| 2349 | case 7: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2350 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2351 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2352 | return &XGI_StLCDDLDes1400x1050Data[tempal]; |
| 2353 | else |
| 2354 | return &XGI_StLCDDes1400x1050Data[tempal]; |
| 2355 | break; |
| 2356 | case 8: |
| 2357 | return &XGI_CetLCDDes1400x1050Data[tempal]; |
| 2358 | break; |
| 2359 | case 9: |
| 2360 | return &XGI_CetLCDDes1400x1050Data2[tempal]; |
| 2361 | break; |
| 2362 | case 10: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2363 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2364 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2365 | return &XGI_ExtLCDDLDes1600x1200Data[tempal]; |
| 2366 | else |
| 2367 | return &XGI_ExtLCDDes1600x1200Data[tempal]; |
| 2368 | break; |
| 2369 | case 11: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2370 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2371 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2372 | return &XGI_StLCDDLDes1600x1200Data[tempal]; |
| 2373 | else |
| 2374 | return &XGI_StLCDDes1600x1200Data[tempal]; |
| 2375 | break; |
| 2376 | case 12: |
| 2377 | return &XGI_NoScalingDesData[tempal]; |
| 2378 | break; |
| 2379 | case 13: |
| 2380 | return &XGI_ExtLCDDes1024x768x75Data[tempal]; |
| 2381 | break; |
| 2382 | case 14: |
| 2383 | return &XGI_StLCDDes1024x768x75Data[tempal]; |
| 2384 | break; |
| 2385 | case 15: |
| 2386 | return &XGI_CetLCDDes1024x768x75Data[tempal]; |
| 2387 | break; |
| 2388 | case 16: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2389 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2390 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2391 | return &XGI_ExtLCDDLDes1280x1024x75Data[tempal]; |
| 2392 | else |
| 2393 | return &XGI_ExtLCDDes1280x1024x75Data[tempal]; |
| 2394 | break; |
| 2395 | case 17: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2396 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2397 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2398 | return &XGI_StLCDDLDes1280x1024x75Data[tempal]; |
| 2399 | else |
| 2400 | return &XGI_StLCDDes1280x1024x75Data[tempal]; |
| 2401 | break; |
| 2402 | case 18: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2403 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2404 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2405 | return &XGI_CetLCDDLDes1280x1024x75Data[tempal]; |
| 2406 | else |
| 2407 | return &XGI_CetLCDDes1280x1024x75Data[tempal]; |
| 2408 | break; |
| 2409 | case 19: |
| 2410 | return &XGI_NoScalingDesDatax75[tempal]; |
| 2411 | break; |
| 2412 | default: |
| 2413 | break; |
| 2414 | } |
| 2415 | } else if (table == 6) { |
| 2416 | switch (tempdi[i].DATAPTR) { |
| 2417 | case 0: |
| 2418 | return &XGI_CH7017LV1024x768[tempal]; |
| 2419 | break; |
| 2420 | case 1: |
| 2421 | return &XGI_CH7017LV1400x1050[tempal]; |
| 2422 | break; |
| 2423 | default: |
| 2424 | break; |
| 2425 | } |
| 2426 | } |
| 2427 | return NULL; |
| 2428 | } |
| 2429 | |
| 2430 | static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, |
| 2431 | unsigned short ModeIdIndex, |
| 2432 | unsigned short RefreshRateTableIndex, |
| 2433 | struct vb_device_info *pVBInfo) |
| 2434 | { |
| 2435 | unsigned short i, tempdx, tempbx, tempal, modeflag, table; |
| 2436 | struct XGI330_TVDataTablStruct *tempdi = NULL; |
| 2437 | |
| 2438 | tempbx = BX; |
| 2439 | |
| 2440 | if (ModeNo <= 0x13) { |
| 2441 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 2442 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 2443 | } else { |
| 2444 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2445 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
| 2446 | } |
| 2447 | |
| 2448 | tempal = tempal & 0x3f; |
| 2449 | table = tempbx; |
| 2450 | |
| 2451 | switch (tempbx) { |
| 2452 | case 0: |
| 2453 | tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2454 | break; |
| 2455 | case 1: |
| 2456 | tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2457 | break; |
| 2458 | case 2: |
| 2459 | tempdi = XGI_EPLCHTVDataPtr; |
| 2460 | break; |
| 2461 | case 3: |
| 2462 | tempdi = NULL; |
| 2463 | break; |
| 2464 | case 4: |
| 2465 | tempdi = XGI_TVDataTable; |
| 2466 | break; |
| 2467 | case 5: |
| 2468 | tempdi = NULL; |
| 2469 | break; |
| 2470 | case 6: |
| 2471 | tempdi = XGI_EPLCHTVRegPtr; |
| 2472 | break; |
| 2473 | default: |
| 2474 | break; |
| 2475 | } |
| 2476 | |
| 2477 | if (tempdi == NULL) /* OEMUtil */ |
| 2478 | return NULL; |
| 2479 | |
| 2480 | tempdx = pVBInfo->TVInfo; |
| 2481 | |
| 2482 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2483 | tempdx = tempdx | SetTVLockMode; |
| 2484 | |
| 2485 | if (modeflag & HalfDCLK) |
| 2486 | tempdx = tempdx | SetTVLowResolution; |
| 2487 | |
| 2488 | i = 0; |
| 2489 | |
| 2490 | while (tempdi[i].MASK != 0xffff) { |
| 2491 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) |
| 2492 | break; |
| 2493 | i++; |
| 2494 | } |
| 2495 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2496 | /* 07/05/22 */ |
| 2497 | if (table == 0x00) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2498 | } else if (table == 0x01) { |
| 2499 | } else if (table == 0x04) { |
| 2500 | switch (tempdi[i].DATAPTR) { |
| 2501 | case 0: |
| 2502 | return &XGI_ExtPALData[tempal]; |
| 2503 | break; |
| 2504 | case 1: |
| 2505 | return &XGI_ExtNTSCData[tempal]; |
| 2506 | break; |
| 2507 | case 2: |
| 2508 | return &XGI_StPALData[tempal]; |
| 2509 | break; |
| 2510 | case 3: |
| 2511 | return &XGI_StNTSCData[tempal]; |
| 2512 | break; |
| 2513 | case 4: |
| 2514 | return &XGI_ExtHiTVData[tempal]; |
| 2515 | break; |
| 2516 | case 5: |
| 2517 | return &XGI_St2HiTVData[tempal]; |
| 2518 | break; |
| 2519 | case 6: |
| 2520 | return &XGI_ExtYPbPr525iData[tempal]; |
| 2521 | break; |
| 2522 | case 7: |
| 2523 | return &XGI_ExtYPbPr525pData[tempal]; |
| 2524 | break; |
| 2525 | case 8: |
| 2526 | return &XGI_ExtYPbPr750pData[tempal]; |
| 2527 | break; |
| 2528 | case 9: |
| 2529 | return &XGI_StYPbPr525iData[tempal]; |
| 2530 | break; |
| 2531 | case 10: |
| 2532 | return &XGI_StYPbPr525pData[tempal]; |
| 2533 | break; |
| 2534 | case 11: |
| 2535 | return &XGI_StYPbPr750pData[tempal]; |
| 2536 | break; |
| 2537 | case 12: /* avoid system hang */ |
| 2538 | return &XGI_ExtNTSCData[tempal]; |
| 2539 | break; |
| 2540 | case 13: |
| 2541 | return &XGI_St1HiTVData[tempal]; |
| 2542 | break; |
| 2543 | default: |
| 2544 | break; |
| 2545 | } |
| 2546 | } else if (table == 0x02) { |
| 2547 | switch (tempdi[i].DATAPTR) { |
| 2548 | case 0: |
| 2549 | return &XGI_CHTVUNTSCData[tempal]; |
| 2550 | break; |
| 2551 | case 1: |
| 2552 | return &XGI_CHTVONTSCData[tempal]; |
| 2553 | break; |
| 2554 | case 2: |
| 2555 | return &XGI_CHTVUPALData[tempal]; |
| 2556 | break; |
| 2557 | case 3: |
| 2558 | return &XGI_CHTVOPALData[tempal]; |
| 2559 | break; |
| 2560 | default: |
| 2561 | break; |
| 2562 | } |
| 2563 | } else if (table == 0x06) { |
| 2564 | } |
| 2565 | return NULL; |
| 2566 | } |
| 2567 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2568 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2569 | unsigned short RefreshRateTableIndex, |
| 2570 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2571 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2572 | unsigned short tempbx; |
| 2573 | struct XGI330_LVDSDataStruct *LCDPtr = 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 | tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2576 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2577 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 2578 | LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx, |
| 2579 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2580 | pVBInfo); |
| 2581 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2582 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2583 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2584 | pVBInfo->VT = LCDPtr->LCDVT; |
| 2585 | } |
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)) { |
| 2588 | if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding |
| 2589 | | EnableScalingLCD))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2590 | if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 2591 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2592 | pVBInfo->HDE = 1024; |
| 2593 | pVBInfo->VDE = 768; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2594 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || |
| 2595 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2596 | pVBInfo->HDE = 1280; |
| 2597 | pVBInfo->VDE = 1024; |
| 2598 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 2599 | pVBInfo->HDE = 1400; |
| 2600 | pVBInfo->VDE = 1050; |
| 2601 | } else { |
| 2602 | pVBInfo->HDE = 1600; |
| 2603 | pVBInfo->VDE = 1200; |
| 2604 | } |
| 2605 | } |
| 2606 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2607 | } |
| 2608 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2609 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2610 | unsigned short RefreshRateTableIndex, |
| 2611 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2612 | struct vb_device_info *pVBInfo) |
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 | unsigned char index; |
| 2615 | unsigned short tempbx, i; |
| 2616 | struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL; |
| 2617 | struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2618 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2619 | if (ModeNo <= 0x13) |
| 2620 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 2621 | else |
| 2622 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2623 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2624 | index = index & IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2625 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2626 | if ((pVBInfo->IF_DEF_ScaleLCD == 0) || |
| 2627 | ((pVBInfo->IF_DEF_ScaleLCD == 1) && |
| 2628 | (!(pVBInfo->LCDInfo & EnableScalingLCD)))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2629 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2630 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2631 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2632 | LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) |
| 2633 | XGI_GetLcdPtr(tempbx, ModeNo, |
| 2634 | ModeIdIndex, |
| 2635 | RefreshRateTableIndex, |
| 2636 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2637 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2638 | for (i = 0; i < 8; i++) |
| 2639 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; |
| 2640 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2641 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2642 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2643 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2644 | tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2645 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2646 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2647 | LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) |
| 2648 | XGI_GetLcdPtr( |
| 2649 | tempbx, |
| 2650 | ModeNo, |
| 2651 | ModeIdIndex, |
| 2652 | RefreshRateTableIndex, |
| 2653 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2654 | for (i = 0; i < 7; i++) |
| 2655 | pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; |
| 2656 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2657 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2658 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2659 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2660 | } |
| 2661 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2662 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 2663 | { |
| 2664 | unsigned char tempal, tempah, tempbl, i; |
| 2665 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2666 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2667 | tempal = tempah & 0x0F; |
| 2668 | tempah = tempah & 0xF0; |
| 2669 | i = 0; |
| 2670 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2671 | |
| 2672 | while (tempbl != 0xFF) { |
| 2673 | if (tempbl & 0x80) { /* OEMUtil */ |
| 2674 | tempal = tempah; |
| 2675 | tempbl = tempbl & ~(0x80); |
| 2676 | } |
| 2677 | |
| 2678 | if (tempal == tempbl) |
| 2679 | break; |
| 2680 | |
| 2681 | i++; |
| 2682 | |
| 2683 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2684 | } |
| 2685 | |
| 2686 | return i; |
| 2687 | } |
| 2688 | |
| 2689 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 2690 | { |
| 2691 | unsigned short tempah, tempal, tempbl, i; |
| 2692 | |
| 2693 | tempal = pVBInfo->LCDResInfo; |
| 2694 | tempah = pVBInfo->LCDTypeInfo; |
| 2695 | |
| 2696 | i = 0; |
| 2697 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2698 | |
| 2699 | while (tempbl != 0xFF) { |
| 2700 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 2701 | tempal = tempah; |
| 2702 | tempbl &= ~0x80; |
| 2703 | } |
| 2704 | |
| 2705 | if (tempal == tempbl) |
| 2706 | break; |
| 2707 | |
| 2708 | i++; |
| 2709 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2710 | } |
| 2711 | |
| 2712 | if (tempbl == 0xFF) { |
| 2713 | pVBInfo->LCDResInfo = Panel1024x768; |
| 2714 | pVBInfo->LCDTypeInfo = 0; |
| 2715 | i = 0; |
| 2716 | } |
| 2717 | |
| 2718 | return i; |
| 2719 | } |
| 2720 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2721 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 2722 | unsigned short *VSyncWidth, |
| 2723 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2724 | { |
| 2725 | unsigned short Index; |
| 2726 | |
| 2727 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 2728 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 2729 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
| 2730 | |
| 2731 | return; |
| 2732 | } |
| 2733 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2734 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2735 | unsigned short RefreshRateTableIndex, |
| 2736 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2737 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2738 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 2739 | unsigned long temp, temp1, temp2, temp3, push3; |
| 2740 | struct XGI330_LCDDataDesStruct *LCDPtr = NULL; |
| 2741 | struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2742 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2743 | if (ModeNo > 0x13) |
| 2744 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2745 | else |
| 2746 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2747 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2748 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) { |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2749 | if (pVBInfo->IF_DEF_OEMUtil == 1) { |
| 2750 | tempbx = 8; |
| 2751 | LCDPtr = (struct XGI330_LCDDataDesStruct *) |
| 2752 | XGI_GetLcdPtr(tempbx, |
| 2753 | ModeNo, |
| 2754 | ModeIdIndex, |
| 2755 | RefreshRateTableIndex, |
| 2756 | pVBInfo); |
| 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->IF_DEF_OEMUtil == 0) || |
| 2760 | (LCDPtr == NULL)) { |
| 2761 | tempbx = 3; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2762 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2763 | LCDPtr1 = |
| 2764 | (struct XGI330_LCDDataDesStruct2 *) |
| 2765 | XGI_GetLcdPtr( |
| 2766 | tempbx, |
| 2767 | ModeNo, |
| 2768 | ModeIdIndex, |
| 2769 | RefreshRateTableIndex, |
| 2770 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2771 | else |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2772 | LCDPtr = |
| 2773 | (struct XGI330_LCDDataDesStruct *) |
| 2774 | XGI_GetLcdPtr( |
| 2775 | tempbx, |
| 2776 | ModeNo, |
| 2777 | ModeIdIndex, |
| 2778 | RefreshRateTableIndex, |
| 2779 | pVBInfo); |
| 2780 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2781 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2782 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 2783 | push1 = tempbx; |
| 2784 | push2 = 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 | /* GetLCDResInfo */ |
| 2787 | if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 2788 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { |
| 2789 | tempax = 1024; |
| 2790 | tempbx = 768; |
| 2791 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || |
| 2792 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { |
| 2793 | tempax = 1280; |
| 2794 | tempbx = 1024; |
| 2795 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 2796 | tempax = 1400; |
| 2797 | tempbx = 1050; |
| 2798 | } else { |
| 2799 | tempax = 1600; |
| 2800 | tempbx = 1200; |
| 2801 | } |
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 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 2804 | pVBInfo->HDE = tempax; |
| 2805 | pVBInfo->VDE = tempbx; |
| 2806 | pVBInfo->VGAHDE = tempax; |
| 2807 | pVBInfo->VGAVDE = tempbx; |
| 2808 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2809 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2810 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && |
| 2811 | (pVBInfo->LCDInfo & EnableScalingLCD)) { |
| 2812 | tempax = pVBInfo->HDE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2813 | tempbx = pVBInfo->VDE; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2814 | } |
| 2815 | |
| 2816 | tempax = pVBInfo->HT; |
| 2817 | |
| 2818 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2819 | tempbx = LCDPtr1->LCDHDES; |
| 2820 | else |
| 2821 | tempbx = LCDPtr->LCDHDES; |
| 2822 | |
| 2823 | tempcx = pVBInfo->HDE; |
| 2824 | tempbx = tempbx & 0x0fff; |
| 2825 | tempcx += tempbx; |
| 2826 | |
| 2827 | if (tempcx >= tempax) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2828 | tempcx -= tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2829 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2830 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2831 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2832 | tempcx = tempcx >> 3; |
| 2833 | tempbx = tempbx >> 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2834 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2835 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 2836 | (unsigned short) (tempbx & 0xff)); |
| 2837 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 2838 | (unsigned short) (tempcx & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2839 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2840 | tempax = pVBInfo->HT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2841 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2842 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2843 | tempbx = LCDPtr1->LCDHRS; |
| 2844 | else |
| 2845 | tempbx = LCDPtr->LCDHRS; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2846 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2847 | tempcx = push2; |
| 2848 | |
| 2849 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2850 | tempcx = LCDPtr1->LCDHSync; |
| 2851 | |
| 2852 | tempcx += tempbx; |
| 2853 | |
| 2854 | if (tempcx >= tempax) |
| 2855 | tempcx -= tempax; |
| 2856 | |
| 2857 | tempax = tempbx & 0x07; |
| 2858 | tempax = tempax >> 5; |
| 2859 | tempcx = tempcx >> 3; |
| 2860 | tempbx = tempbx >> 3; |
| 2861 | |
| 2862 | tempcx &= 0x1f; |
| 2863 | tempax |= tempcx; |
| 2864 | |
| 2865 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 2866 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 2867 | (unsigned short) (tempbx & 0xff)); |
| 2868 | |
| 2869 | tempax = pVBInfo->VT; |
| 2870 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2871 | tempbx = LCDPtr1->LCDVDES; |
| 2872 | else |
| 2873 | tempbx = LCDPtr->LCDVDES; |
| 2874 | tempcx = pVBInfo->VDE; |
| 2875 | |
| 2876 | tempbx = tempbx & 0x0fff; |
| 2877 | tempcx += tempbx; |
| 2878 | if (tempcx >= tempax) |
| 2879 | tempcx -= tempax; |
| 2880 | |
| 2881 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 2882 | (unsigned short) (tempbx & 0xff)); |
| 2883 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 2884 | (unsigned short) (tempcx & 0xff)); |
| 2885 | |
| 2886 | tempbx = (tempbx >> 8) & 0x07; |
| 2887 | tempcx = (tempcx >> 8) & 0x07; |
| 2888 | |
| 2889 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 2890 | (unsigned short) ((tempcx << 3) |
| 2891 | | tempbx)); |
| 2892 | |
| 2893 | tempax = pVBInfo->VT; |
| 2894 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2895 | tempbx = LCDPtr1->LCDVRS; |
| 2896 | else |
| 2897 | tempbx = LCDPtr->LCDVRS; |
| 2898 | |
| 2899 | /* tempbx = tempbx >> 4; */ |
| 2900 | tempcx = push1; |
| 2901 | |
| 2902 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2903 | tempcx = LCDPtr1->LCDVSync; |
| 2904 | |
| 2905 | tempcx += tempbx; |
| 2906 | if (tempcx >= tempax) |
| 2907 | tempcx -= tempax; |
| 2908 | |
| 2909 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 2910 | (unsigned short) (tempbx & 0xff)); |
| 2911 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 2912 | (unsigned short) (tempcx & 0x0f)); |
| 2913 | |
| 2914 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 2915 | |
| 2916 | tempbx = pVBInfo->VGAVDE; |
| 2917 | if (tempbx != pVBInfo->VDE) |
| 2918 | tempax |= 0x40; |
| 2919 | |
| 2920 | if (pVBInfo->LCDInfo & EnableLVDSDDA) |
| 2921 | tempax |= 0x40; |
| 2922 | |
| 2923 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 2924 | tempax); |
| 2925 | |
| 2926 | tempcx = pVBInfo->VGAVT; |
| 2927 | tempbx = pVBInfo->VDE; |
| 2928 | tempax = pVBInfo->VGAVDE; |
| 2929 | tempcx -= tempax; |
| 2930 | |
| 2931 | temp = tempax; /* 0430 ylshieh */ |
| 2932 | temp1 = (temp << 18) / tempbx; |
| 2933 | |
| 2934 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 2935 | |
| 2936 | if (tempdx != 0) |
| 2937 | temp1 += 1; |
| 2938 | |
| 2939 | temp2 = temp1; |
| 2940 | push3 = temp2; |
| 2941 | |
| 2942 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 2943 | (unsigned short) (temp2 & 0xff)); |
| 2944 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 2945 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 2946 | |
| 2947 | tempbx = (unsigned short) (temp2 >> 16); |
| 2948 | tempax = tempbx & 0x03; |
| 2949 | |
| 2950 | tempbx = pVBInfo->VGAVDE; |
| 2951 | if (tempbx == pVBInfo->VDE) |
| 2952 | tempax |= 0x04; |
| 2953 | |
| 2954 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 2955 | |
| 2956 | if (pVBInfo->VBType & VB_XGI301C) { |
| 2957 | temp2 = push3; |
| 2958 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2959 | 0x3c, |
| 2960 | (unsigned short) (temp2 & 0xff)); |
| 2961 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2962 | 0x3b, |
| 2963 | (unsigned short) ((temp2 >> 8) & |
| 2964 | 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2965 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2966 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 2967 | ~0xc0, |
| 2968 | (unsigned short) ((tempbx & |
| 2969 | 0xff) << 6)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2970 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2971 | tempcx = pVBInfo->VGAVDE; |
| 2972 | if (tempcx == pVBInfo->VDE) |
| 2973 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2974 | 0x30, ~0x0c, 0x00); |
| 2975 | else |
| 2976 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2977 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2978 | } |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2979 | |
| 2980 | tempcx = pVBInfo->VGAHDE; |
| 2981 | tempbx = pVBInfo->HDE; |
| 2982 | |
| 2983 | temp1 = tempcx << 16; |
| 2984 | |
| 2985 | tempax = (unsigned short) (temp1 / tempbx); |
| 2986 | |
| 2987 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 2988 | tempax = 65535; |
| 2989 | |
| 2990 | temp3 = tempax; |
| 2991 | temp1 = pVBInfo->VGAHDE << 16; |
| 2992 | |
| 2993 | temp1 /= temp3; |
| 2994 | temp3 = temp3 << 16; |
| 2995 | temp1 -= 1; |
| 2996 | |
| 2997 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 2998 | |
| 2999 | tempax = (unsigned short) (temp3 & 0xff); |
| 3000 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 3001 | |
| 3002 | temp1 = pVBInfo->VGAVDE << 18; |
| 3003 | temp1 = temp1 / push3; |
| 3004 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 3005 | |
| 3006 | if (pVBInfo->LCDResInfo == Panel1024x768) |
| 3007 | tempbx -= 1; |
| 3008 | |
| 3009 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 3010 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 3011 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 3012 | (unsigned short) (tempax & 0xff)); |
| 3013 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 3014 | (unsigned short) (tempbx & 0xff)); |
| 3015 | |
| 3016 | temp3 = temp3 >> 16; |
| 3017 | |
| 3018 | if (modeflag & HalfDCLK) |
| 3019 | temp3 = temp3 >> 1; |
| 3020 | |
| 3021 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 3022 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 3023 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 3024 | (unsigned short) (temp3 & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3025 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3026 | } |
| 3027 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3028 | /* --------------------------------------------------------------------- */ |
| 3029 | /* Function : XGI_GETLCDVCLKPtr */ |
| 3030 | /* Input : */ |
| 3031 | /* Output : al -> VCLK Index */ |
| 3032 | /* Description : */ |
| 3033 | /* --------------------------------------------------------------------- */ |
| 3034 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 3035 | struct vb_device_info *pVBInfo) |
| 3036 | { |
| 3037 | unsigned short index; |
| 3038 | |
| 3039 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 3040 | if (pVBInfo->IF_DEF_ScaleLCD == 1) { |
| 3041 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 3042 | return; |
| 3043 | } |
| 3044 | |
| 3045 | /* index = XGI_GetLCDCapPtr(pVBInfo); */ |
| 3046 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 3047 | |
| 3048 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 3049 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 3050 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 3051 | } else { /* LCDA */ |
| 3052 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 3053 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 3054 | } |
| 3055 | } |
| 3056 | return; |
| 3057 | } |
| 3058 | |
| 3059 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
| 3060 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 3061 | struct vb_device_info *pVBInfo) |
| 3062 | { |
| 3063 | |
| 3064 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3065 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3066 | |
| 3067 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3068 | /* si+St_ResInfo */ |
| 3069 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3070 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3071 | /* si+Ext_ResInfo */ |
| 3072 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3073 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3074 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 3075 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3076 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 3077 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 3078 | |
| 3079 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
| 3080 | return tempal; |
| 3081 | |
| 3082 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3083 | if (pVBInfo->VBType & |
| 3084 | (VB_XGI301B | |
| 3085 | VB_XGI302B | |
| 3086 | VB_XGI301LV | |
| 3087 | VB_XGI302LV | |
| 3088 | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3089 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 3090 | tempal = HiTVVCLKDIV2; |
| 3091 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
| 3092 | tempal = HiTVVCLK; |
| 3093 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3094 | tempal = HiTVSimuVCLK; |
| 3095 | if (!(modeflag & Charx8Dot)) |
| 3096 | tempal = HiTVTextVCLK; |
| 3097 | |
| 3098 | } |
| 3099 | return tempal; |
| 3100 | } |
| 3101 | |
| 3102 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
| 3103 | tempal = YPbPr750pVCLK; |
| 3104 | return tempal; |
| 3105 | } |
| 3106 | |
| 3107 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
| 3108 | tempal = YPbPr525pVCLK; |
| 3109 | return tempal; |
| 3110 | } |
| 3111 | |
| 3112 | tempal = NTSC1024VCLK; |
| 3113 | |
| 3114 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
| 3115 | tempal = TVVCLKDIV2; |
| 3116 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
| 3117 | tempal = TVVCLK; |
| 3118 | } |
| 3119 | |
| 3120 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3121 | return tempal; |
| 3122 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3123 | } /* {End of VB} */ |
| 3124 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3125 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3126 | tempal = tempal >> 2; |
| 3127 | tempal &= 0x03; |
| 3128 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3129 | /* for Dot8 Scaling LCD */ |
| 3130 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3131 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
| 3132 | |
| 3133 | if (ModeNo <= 0x13) |
| 3134 | return tempal; |
| 3135 | |
| 3136 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 3137 | return tempal; |
| 3138 | } |
| 3139 | |
| 3140 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 3141 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 3142 | { |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3143 | if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3144 | | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
| 3145 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag |
| 3146 | & ProgrammingCRT2)) { |
| 3147 | *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B; |
| 3148 | *di_1 = XGI_VBVCLKData[tempal].SR2C; |
| 3149 | } |
| 3150 | } else { |
| 3151 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 3152 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 3153 | } |
| 3154 | } |
| 3155 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3156 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3157 | unsigned short RefreshRateTableIndex, |
| 3158 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3159 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3160 | unsigned char di_0, di_1, tempal; |
| 3161 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3162 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3163 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 3164 | pVBInfo); |
| 3165 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 3166 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3167 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3168 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3169 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3170 | (unsigned short) (0x10 * i)); |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3171 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3172 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3173 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 3174 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3175 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3176 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 3177 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3178 | } |
| 3179 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3180 | } |
| 3181 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3182 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3183 | struct vb_device_info *pVBInfo) |
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 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3186 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3187 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 3188 | | VB_XGI302LV | VB_XGI301C)) { |
| 3189 | tempcl = 0; |
| 3190 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3191 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
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 (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3194 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3195 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3196 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3197 | if (!(temp & 0x40)) |
| 3198 | tempcl |= ActiveCRT1; |
| 3199 | } |
| 3200 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3201 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3202 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3203 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3204 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3205 | if (!(temp == 0x08)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3206 | /* Check ChannelA by Part1_13 [2003/10/03] */ |
| 3207 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3208 | if (tempax & 0x04) |
| 3209 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3210 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3211 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3212 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3213 | if (!(tempcl & ActiveLCD)) |
| 3214 | if (temp == 0x01) |
| 3215 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3216 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3217 | if (temp == 0x04) |
| 3218 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3219 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3220 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3221 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3222 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3223 | if (!(temp & 0x08)) |
| 3224 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3225 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3226 | if (!(temp & 0x04)) |
| 3227 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3228 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3229 | if (temp & 0x02) |
| 3230 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3231 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3232 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 3233 | if (temp & 0x01) |
| 3234 | tempch |= ActiveHiTV; |
| 3235 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3236 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3237 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3238 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3239 | pVBInfo->Part2Port, |
| 3240 | 0x4d); |
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 (temp & 0x10) |
| 3243 | tempch |= ActiveYPbPr; |
| 3244 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3245 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3246 | if (tempch != 0) |
| 3247 | tempcl |= ActiveTV; |
| 3248 | } |
| 3249 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3250 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3251 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3252 | if (tempcl & ActiveLCD) { |
| 3253 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 3254 | if (temp & ActiveTV) |
| 3255 | tempcl |= ActiveTV; |
| 3256 | } |
| 3257 | } |
| 3258 | temp = tempcl; |
| 3259 | tempbl = ~ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3260 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3261 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3262 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3263 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3264 | } else { |
| 3265 | return; |
| 3266 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3267 | } |
| 3268 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3269 | void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, |
| 3270 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3271 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3272 | /* |
| 3273 | if ( HwDeviceExtension->jChipType >= XG20 ) { |
| 3274 | pVBInfo->Set_VGAType = XG20; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 3275 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3276 | pVBInfo->Set_VGAType = VGA_XGI340; |
| 3277 | } |
| 3278 | */ |
| 3279 | pVBInfo->Set_VGAType = HwDeviceExtension->jChipType; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3280 | } |
| 3281 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 3282 | void XGI_GetVBType(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 flag, tempbx, tempah; |
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 (pVBInfo->IF_DEF_LVDS == 0) { |
| 3287 | tempbx = VB_XGI302B; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3288 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3289 | if (flag != 0x02) { |
| 3290 | tempbx = VB_XGI301; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3291 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3292 | if (flag >= 0xB0) { |
| 3293 | tempbx = VB_XGI301B; |
| 3294 | if (flag >= 0xC0) { |
| 3295 | tempbx = VB_XGI301C; |
| 3296 | if (flag >= 0xD0) { |
| 3297 | tempbx = VB_XGI301LV; |
| 3298 | if (flag >= 0xE0) { |
| 3299 | tempbx = VB_XGI302LV; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3300 | tempah = xgifb_reg_get( |
| 3301 | pVBInfo->Part4Port, |
| 3302 | 0x39); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3303 | if (tempah != 0xFF) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3304 | tempbx = |
| 3305 | VB_XGI301C; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3306 | } |
| 3307 | } |
| 3308 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3309 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3310 | if (tempbx & (VB_XGI301B | VB_XGI302B)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3311 | flag = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3312 | pVBInfo->Part4Port, |
| 3313 | 0x23); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3314 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3315 | if (!(flag & 0x02)) |
| 3316 | tempbx = tempbx | VB_NoLCD; |
| 3317 | } |
| 3318 | } |
| 3319 | } |
| 3320 | pVBInfo->VBType = tempbx; |
| 3321 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3322 | } |
| 3323 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3324 | void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 3325 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3326 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3327 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3328 | unsigned short tempax, push, tempbx, temp, modeflag; |
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 (ModeNo <= 0x13) |
| 3331 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 3332 | else |
| 3333 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3334 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3335 | pVBInfo->SetFlag = 0; |
| 3336 | pVBInfo->ModeType = modeflag & ModeInfoFlag; |
| 3337 | tempbx = 0; |
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->VBType & 0xFFFF) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3340 | /* Check Display Device */ |
| 3341 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3342 | tempbx = tempbx | temp; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3343 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3344 | push = temp; |
| 3345 | push = push << 8; |
| 3346 | tempax = temp << 8; |
| 3347 | tempbx = tempbx | tempax; |
| 3348 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA |
| 3349 | | SetInSlaveMode | DisableCRT2Display); |
| 3350 | temp = 0xFFFF ^ temp; |
| 3351 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3352 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3353 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
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 (pVBInfo->IF_DEF_LCDA == 1) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3356 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3357 | if ((pVBInfo->Set_VGAType >= XG20) |
| 3358 | || (pVBInfo->Set_VGAType >= XG40)) { |
| 3359 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3360 | /* if ((pVBInfo->VBType & VB_XGI302B) |
| 3361 | || (pVBInfo->VBType & VB_XGI301LV) |
| 3362 | || (pVBInfo->VBType & VB_XGI302LV) |
| 3363 | || (pVBInfo->VBType & VB_XGI301C)) |
| 3364 | */ |
| 3365 | if (pVBInfo->VBType & |
| 3366 | (VB_XGI302B | |
| 3367 | VB_XGI301LV | |
| 3368 | VB_XGI302LV | |
| 3369 | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3370 | if (temp & EnableDualEdge) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3371 | tempbx |= |
| 3372 | SetCRT2ToDualEdge; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3373 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3374 | if (temp & SetToLCDA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3375 | tempbx |= |
| 3376 | SetCRT2ToLCDA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3377 | } |
| 3378 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3379 | } |
| 3380 | } |
| 3381 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3382 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3383 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3384 | /* [Billy] 07/05/04 */ |
| 3385 | if (((pVBInfo->IF_DEF_LVDS == 0) && |
| 3386 | ((pVBInfo->VBType & VB_XGI301LV) || |
| 3387 | (pVBInfo->VBType & VB_XGI302LV) || |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3388 | (pVBInfo->VBType & VB_XGI301C)))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3389 | if (temp & SetYPbPr) { /* temp = CR38 */ |
| 3390 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3391 | /* shampoo add for new |
| 3392 | * scratch */ |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3393 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3394 | pVBInfo->P3d4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3395 | 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3396 | temp &= YPbPrMode; |
| 3397 | tempbx |= SetCRT2ToHiVisionTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3398 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3399 | if (temp != YPbPrMode1080i) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3400 | tempbx &= |
| 3401 | (~SetCRT2ToHiVisionTV); |
| 3402 | tempbx |= |
| 3403 | SetCRT2ToYPbPr; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 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 | /* tempbx |= SetCRT2ToYPbPr; */ |
| 3408 | } |
| 3409 | } |
| 3410 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3411 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3412 | tempax = push; /* restore CR31 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3413 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3414 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3415 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3416 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 3417 | temp = 0x09FC; |
| 3418 | else |
| 3419 | temp = 0x097C; |
| 3420 | } else { |
| 3421 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 3422 | temp = 0x01FC; |
| 3423 | else |
| 3424 | temp = 0x017C; |
| 3425 | } |
| 3426 | } else { /* 3nd party chip */ |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3427 | temp = SetCRT2ToLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3428 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3429 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3430 | if (!(tempbx & temp)) { |
| 3431 | tempax |= DisableCRT2Display; |
| 3432 | tempbx = 0; |
| 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 (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ |
| 3436 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 3437 | if (tempbx & SetCRT2ToLCDA) { |
| 3438 | if (tempbx & SetSimuScanMode) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3439 | tempbx &= (~(SetCRT2ToLCD | |
| 3440 | SetCRT2ToRAMDAC | |
| 3441 | SwitchToCRT2)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3442 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3443 | tempbx &= (~(SetCRT2ToLCD | |
| 3444 | SetCRT2ToRAMDAC | |
| 3445 | SetCRT2ToTV | |
| 3446 | SwitchToCRT2)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3447 | } |
| 3448 | } |
| 3449 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3450 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3451 | /* shampoo add */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3452 | /* for driver abnormal */ |
| 3453 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3454 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 3455 | if (tempbx & SetCRT2ToRAMDAC) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3456 | tempbx &= (0xFF00 | |
| 3457 | SetCRT2ToRAMDAC | |
| 3458 | SwitchToCRT2 | |
| 3459 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3460 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3461 | } |
| 3462 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3463 | tempbx &= (~(SetCRT2ToRAMDAC | |
| 3464 | SetCRT2ToLCD | |
| 3465 | SetCRT2ToTV)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3466 | } |
| 3467 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3468 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3469 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 3470 | if (tempbx & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3471 | tempbx &= (0xFF00 | |
| 3472 | SetCRT2ToLCD | |
| 3473 | SwitchToCRT2 | |
| 3474 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3475 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3476 | } |
| 3477 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3478 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3479 | if (tempbx & SetCRT2ToSCART) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3480 | tempbx &= (0xFF00 | |
| 3481 | SetCRT2ToSCART | |
| 3482 | SwitchToCRT2 | |
| 3483 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3484 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3485 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3486 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3487 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3488 | if (tempbx & SetCRT2ToYPbPr) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3489 | tempbx &= (0xFF00 | |
| 3490 | SwitchToCRT2 | |
| 3491 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3492 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3493 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3494 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 3495 | if (tempbx & SetCRT2ToHiVisionTV) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3496 | tempbx &= (0xFF00 | |
| 3497 | SetCRT2ToHiVisionTV | |
| 3498 | SwitchToCRT2 | |
| 3499 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3500 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3501 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3502 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 3503 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) |
| 3504 | tempbx = DisableCRT2Display; |
| 3505 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3506 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3507 | if (!(tempbx & DisableCRT2Display)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3508 | if ((!(tempbx & DriverMode)) || |
| 3509 | (!(modeflag & CRT2Mode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3510 | if (pVBInfo->IF_DEF_LCDA == 1) { |
| 3511 | if (!(tempbx & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3512 | tempbx |= (SetInSlaveMode | |
| 3513 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3514 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3515 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3516 | if (pVBInfo->IF_DEF_VideoCapture == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3517 | if (((HwDeviceExtension->jChipType == |
| 3518 | XG40) && |
| 3519 | (pVBInfo->Set_VGAType == XG40)) || |
| 3520 | ((HwDeviceExtension->jChipType == |
| 3521 | XG41) && |
| 3522 | (pVBInfo->Set_VGAType == XG41)) || |
| 3523 | ((HwDeviceExtension->jChipType == |
| 3524 | XG42) && |
| 3525 | (pVBInfo->Set_VGAType == XG42)) || |
| 3526 | ((HwDeviceExtension->jChipType == |
| 3527 | XG45) && |
| 3528 | (pVBInfo->Set_VGAType == XG45))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3529 | if (ModeNo <= 13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3530 | if (!(tempbx & |
| 3531 | SetCRT2ToRAMDAC)) { |
| 3532 | /*CRT2 not need |
| 3533 | * to support*/ |
| 3534 | tempbx &= |
| 3535 | (0x00FF | |
| 3536 | (~SetInSlaveMode)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3537 | pVBInfo->SetFlag |
| 3538 | |= EnableVCMode; |
| 3539 | } |
| 3540 | } |
| 3541 | } |
| 3542 | } |
| 3543 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3544 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3545 | /* LCD+TV can't support in slave mode |
| 3546 | * (Force LCDA+TV->LCDB) */ |
| 3547 | if ((tempbx & SetInSlaveMode) && |
| 3548 | (tempbx & SetCRT2ToLCDA)) { |
| 3549 | tempbx ^= (SetCRT2ToLCD | |
| 3550 | SetCRT2ToLCDA | |
| 3551 | SetCRT2ToDualEdge); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3552 | pVBInfo->SetFlag |= ReserveTVOption; |
| 3553 | } |
| 3554 | } |
| 3555 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3556 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3557 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3558 | } |
| 3559 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3560 | void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 3561 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3562 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3563 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
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 | tempbx = 0; |
| 3566 | resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3567 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3568 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3569 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3570 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 3571 | St_ModeFlag; /* si+St_ModeFlag */ |
| 3572 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 3573 | St_ResInfo; /* si+St_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3574 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3575 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 3576 | Ext_ModeFlag; |
| 3577 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 3578 | Ext_RESINFO; /* si+Ext_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3579 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3580 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3581 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3582 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3583 | tempbx = temp; |
| 3584 | if (tempbx & SetPALTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3585 | tempbx &= (SetCHTVOverScan | |
| 3586 | SetPALMTV | |
| 3587 | SetPALNTV | |
| 3588 | SetPALTV); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3589 | if (tempbx & SetPALMTV) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3590 | /* set to NTSC if PAL-M */ |
| 3591 | tempbx &= ~SetPALTV; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3592 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3593 | tempbx &= (SetCHTVOverScan | |
| 3594 | SetNTSCJ | |
| 3595 | SetPALTV); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3596 | /* |
| 3597 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3598 | //PAL-M/PAL-N Info |
| 3599 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
| 3600 | //00:PAL, 01:PAL-M, 10:PAL-N |
| 3601 | temp2 = (index1 & 0xC0) >> 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3602 | tempbx |= temp2; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3603 | if (temp2 & 0x02) //PAL-M |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3604 | tempbx &= (~SetPALTV); |
| 3605 | } |
| 3606 | */ |
| 3607 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3608 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3609 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3610 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 3611 | tempbx |= SetPALTV; |
| 3612 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3613 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3614 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3615 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3616 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3617 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3618 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3619 | if (index1 == YPbPrMode525i) |
| 3620 | tempbx |= SetYPbPrMode525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3621 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3622 | if (index1 == YPbPrMode525p) |
| 3623 | tempbx = tempbx | SetYPbPrMode525p; |
| 3624 | if (index1 == YPbPrMode750p) |
| 3625 | tempbx = tempbx | SetYPbPrMode750p; |
| 3626 | } |
| 3627 | } |
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 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 3630 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 3631 | tempbx = tempbx | SetYPbPrMode1080i | SetPALTV; |
| 3632 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3633 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3634 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3635 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 3636 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3637 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3638 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3639 | if (!(tempbx & SetPALTV) && |
| 3640 | (modeflag > 13) && |
| 3641 | (resinfo == 8)) /* NTSC 1024x768, */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3642 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3643 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3644 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3645 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3646 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 3647 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 3648 | tempbx &= (~RPLLDIV2XO); |
| 3649 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3650 | if (tempbx & |
| 3651 | (SetYPbPrMode525p | SetYPbPrMode750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3652 | tempbx &= (~RPLLDIV2XO); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3653 | else if (!(pVBInfo->VBType & |
| 3654 | (VB_XGI301B | |
| 3655 | VB_XGI302B | |
| 3656 | VB_XGI301LV | |
| 3657 | VB_XGI302LV | |
| 3658 | VB_XGI301C))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3659 | if (tempbx & TVSimuMode) |
| 3660 | tempbx &= (~RPLLDIV2XO); |
| 3661 | } |
| 3662 | } |
| 3663 | } |
| 3664 | } |
| 3665 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3666 | } |
| 3667 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 3668 | unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3669 | struct vb_device_info *pVBInfo) |
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 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3672 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3673 | pVBInfo->LCDResInfo = 0; |
| 3674 | pVBInfo->LCDTypeInfo = 0; |
| 3675 | pVBInfo->LCDInfo = 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 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3678 | /* si+St_ModeFlag // */ |
| 3679 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3680 | } else { |
| 3681 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3682 | /* si+Ext_ResInfo // */ |
| 3683 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3684 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3685 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3686 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3687 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3688 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3689 | if (tempbx == 0) |
| 3690 | tempbx = Panel1024x768; /* default */ |
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 | /* LCD75 [2003/8/22] Vicent */ |
| 3693 | if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) { |
| 3694 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3695 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3696 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 3697 | tempax &= 0x0F; |
| 3698 | else |
| 3699 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3700 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3701 | if ((resinfo == 6) || (resinfo == 9)) { |
| 3702 | if (tempax >= 3) |
| 3703 | tempbx |= PanelRef75Hz; |
| 3704 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 3705 | if (tempax >= 4) |
| 3706 | tempbx |= PanelRef75Hz; |
| 3707 | } |
| 3708 | } |
| 3709 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3710 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3711 | pVBInfo->LCDResInfo = tempbx; |
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 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3714 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3715 | if (pVBInfo->IF_DEF_OEMUtil == 1) |
| 3716 | pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3717 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3718 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 3719 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3720 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3721 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3722 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3723 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3724 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3725 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3726 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3727 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding)) |
| 3728 | temp &= ~EnableScalingLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3729 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3730 | tempbx |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3731 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3732 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3733 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3734 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3735 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3736 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
| 3737 | if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType |
| 3738 | & VB_XGI301C)) && (tempax & LCDDualLink)) { |
| 3739 | tempbx |= SetLCDDualLink; |
| 3740 | } |
| 3741 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3742 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3743 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3744 | if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo |
| 3745 | & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo |
| 3746 | == 9) && (!(tempbx & EnableScalingLCD))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3747 | /* set to center in 1280x1024 LCDB for Panel1400x1050 */ |
| 3748 | tempbx |= SetLCDtoNonExpanding; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3749 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3750 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3751 | /* |
| 3752 | if (tempax & LCDBToA) { |
| 3753 | tempbx |= SetLCDBToA; |
| 3754 | } |
| 3755 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3756 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3757 | if (pVBInfo->IF_DEF_ExpLink == 1) { |
| 3758 | if (modeflag & HalfDCLK) { |
| 3759 | /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */ |
| 3760 | if (!(tempbx & SetLCDtoNonExpanding)) { |
| 3761 | tempbx |= EnableLVDSDDA; |
| 3762 | } else { |
| 3763 | if (ModeNo > 0x13) { |
| 3764 | if (pVBInfo->LCDResInfo |
| 3765 | == Panel1024x768) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3766 | if (resinfo == 4) {/* 512x384 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3767 | tempbx |= EnableLVDSDDA; |
| 3768 | } |
| 3769 | } |
| 3770 | } |
| 3771 | } |
| 3772 | } |
| 3773 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3774 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3775 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3776 | if (pVBInfo->VBInfo & SetNotSimuMode) |
| 3777 | tempbx |= LCDVESATiming; |
| 3778 | } else { |
| 3779 | tempbx |= LCDVESATiming; |
| 3780 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3781 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3782 | pVBInfo->LCDInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3783 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3784 | if (pVBInfo->IF_DEF_PWD == 1) { |
| 3785 | if (pVBInfo->LCDInfo & SetPWDEnable) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3786 | if ((pVBInfo->VBType & VB_XGI302LV) || |
| 3787 | (pVBInfo->VBType & VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3788 | if (!(tempax & PWDEnable)) |
| 3789 | pVBInfo->LCDInfo &= ~SetPWDEnable; |
| 3790 | } |
| 3791 | } |
| 3792 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3793 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3794 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3795 | if (tempax & (LockLCDBToA | StLCDBToA)) { |
| 3796 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3797 | if (!(tempax & LockLCDBToA)) { |
| 3798 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3799 | pVBInfo->VBInfo &= |
| 3800 | ~(SetSimuScanMode | |
| 3801 | SetInSlaveMode | |
| 3802 | SetCRT2ToLCD); |
| 3803 | pVBInfo->VBInfo |= |
| 3804 | SetCRT2ToLCDA | |
| 3805 | SetCRT2ToDualEdge; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3806 | } |
| 3807 | } |
| 3808 | } |
| 3809 | } |
| 3810 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3811 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3812 | /* |
| 3813 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3814 | if (tempax & (LockLCDBToA | StLCDBToA)) { |
| 3815 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3816 | if (!((!(tempax & LockLCDBToA)) && |
| 3817 | (ModeNo > 0x13))) { |
| 3818 | pVBInfo->VBInfo &= |
| 3819 | ~(SetSimuScanMode | |
| 3820 | SetInSlaveMode | |
| 3821 | SetCRT2ToLCD); |
| 3822 | pVBInfo->VBInfo |= |
| 3823 | SetCRT2ToLCDA | |
| 3824 | SetCRT2ToDualEdge; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3825 | } |
| 3826 | } |
| 3827 | } |
| 3828 | } |
| 3829 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3830 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3831 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3832 | } |
| 3833 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 3834 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3835 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3836 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3837 | if (ModeNo <= 5) |
| 3838 | ModeNo |= 1; |
| 3839 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3840 | /* for (*ModeIdIndex=0; |
| 3841 | *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) |
| 3842 | / sizeof(struct XGI_StStruct); |
| 3843 | (*ModeIdIndex)++) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3844 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3845 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
| 3846 | ModeNo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3847 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3848 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
| 3849 | 0xFF) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3850 | return 0; |
| 3851 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3852 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3853 | if (ModeNo == 0x07) |
| 3854 | (*ModeIdIndex)++; /* 400 lines */ |
| 3855 | if (ModeNo <= 3) |
| 3856 | (*ModeIdIndex) += 2; /* 400 lines */ |
| 3857 | /* else 350 lines */ |
| 3858 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3859 | /* for (*ModeIdIndex=0; |
| 3860 | *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) |
| 3861 | / sizeof(struct XGI_ExtStruct); |
| 3862 | (*ModeIdIndex)++) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3863 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3864 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
| 3865 | ModeNo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3866 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3867 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
| 3868 | 0xFF) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3869 | return 0; |
| 3870 | } |
| 3871 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3872 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3873 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3874 | } |
| 3875 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3876 | /* win2000 MM adapter not support standard mode! */ |
| 3877 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3878 | #if 0 |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3879 | static unsigned char XGINew_CheckMemorySize( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3880 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3881 | unsigned short ModeNo, |
| 3882 | unsigned short ModeIdIndex, |
| 3883 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3884 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3885 | unsigned short memorysize, modeflag, temp, temp1, tmp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3886 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3887 | /* |
| 3888 | if ((HwDeviceExtension->jChipType == XGI_650) || |
| 3889 | (HwDeviceExtension->jChipType == XGI_650M)) { |
| 3890 | return 1; |
| 3891 | } |
| 3892 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3893 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3894 | if (ModeNo <= 0x13) |
| 3895 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 3896 | else |
| 3897 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3898 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3899 | /* ModeType = modeflag&ModeInfoFlag; // Get mode type */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3900 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3901 | memorysize = modeflag & MemoryInfoFlag; |
| 3902 | memorysize = memorysize > MemorySizeShift; |
| 3903 | memorysize++; /* Get memory size */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3904 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3905 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3906 | tmp = temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3907 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3908 | if (HwDeviceExtension->jChipType == XG40) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3909 | /* memory size per channel SR14[7:4] */ |
| 3910 | temp = 1 << ((temp & 0x0F0) >> 4); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3911 | if ((tmp & 0x0c) == 0x0C) { /* Qual channels */ |
| 3912 | temp <<= 2; |
| 3913 | } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */ |
| 3914 | temp <<= 1; |
| 3915 | } |
| 3916 | } else if (HwDeviceExtension->jChipType == XG42) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3917 | /* memory size per channel SR14[7:4] */ |
| 3918 | temp = 1 << ((temp & 0x0F0) >> 4); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3919 | if ((tmp & 0x04) == 0x04) { /* Dual channels */ |
| 3920 | temp <<= 1; |
| 3921 | } |
| 3922 | } else if (HwDeviceExtension->jChipType == XG45) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3923 | /* memory size per channel SR14[7:4] */ |
| 3924 | temp = 1 << ((temp & 0x0F0) >> 4); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3925 | if ((tmp & 0x0c) == 0x0C) { /* Qual channels */ |
| 3926 | temp <<= 2; |
| 3927 | } else if ((tmp & 0x0c) == 0x08) { /* triple channels */ |
| 3928 | temp1 = temp; |
| 3929 | temp <<= 1; |
| 3930 | temp += temp1; |
| 3931 | } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */ |
| 3932 | temp <<= 1; |
| 3933 | } |
| 3934 | } |
| 3935 | if (temp < memorysize) |
| 3936 | return 0; |
| 3937 | else |
| 3938 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3939 | } |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3940 | #endif |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3941 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3942 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3943 | void XGINew_IsLowResolution(unsigned short ModeNo, |
| 3944 | unsigned short ModeIdIndex, |
| 3945 | unsigned char XGINew_CheckMemorySize( |
| 3946 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3947 | unsigned short ModeNo, |
| 3948 | unsigned short ModeIdIndex, |
| 3949 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3950 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3951 | unsigned short data ; |
| 3952 | unsigned short ModeFlag ; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3953 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3954 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3955 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3956 | xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3957 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3958 | if (ModeNo > 0x13) { |
| 3959 | ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3960 | if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3961 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3962 | data |= 0x80; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3963 | xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3964 | data = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3965 | data &= 0xF7; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3966 | xgifb_reg_set(pVBInfo->P3c4, 0x01, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3967 | } |
| 3968 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3969 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3970 | */ |
| 3971 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3972 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 3973 | { |
| 3974 | unsigned char ujRet = 0; |
| 3975 | unsigned char i = 0; |
| 3976 | |
| 3977 | for (i = 0; i < 8; i++) { |
| 3978 | ujRet = ujRet << 1; |
| 3979 | /* ujRet |= GETBITS(ujDate >> i, 0:0); */ |
| 3980 | ujRet |= (ujDate >> i) & 1; |
| 3981 | } |
| 3982 | |
| 3983 | return ujRet; |
| 3984 | } |
| 3985 | |
| 3986 | /*----------------------------------------------------------------------------*/ |
| 3987 | /* output */ |
| 3988 | /* bl[5] : LVDS signal */ |
| 3989 | /* bl[1] : LVDS backlight */ |
| 3990 | /* bl[0] : LVDS VDD */ |
| 3991 | /*----------------------------------------------------------------------------*/ |
| 3992 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 3993 | { |
| 3994 | unsigned char CR4A, temp; |
| 3995 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3996 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3997 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3998 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3999 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4000 | |
| 4001 | temp = XG21GPIODataTransfer(temp); |
| 4002 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4003 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4004 | return temp; |
| 4005 | } |
| 4006 | |
| 4007 | /*----------------------------------------------------------------------------*/ |
| 4008 | /* output */ |
| 4009 | /* bl[5] : LVDS signal */ |
| 4010 | /* bl[1] : LVDS backlight */ |
| 4011 | /* bl[0] : LVDS VDD */ |
| 4012 | /*----------------------------------------------------------------------------*/ |
| 4013 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 4014 | { |
| 4015 | unsigned char CR4A, CRB4, temp; |
| 4016 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4017 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 4018 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4019 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4020 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4021 | |
| 4022 | temp &= 0x0C; |
| 4023 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4024 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4025 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4026 | temp |= ((CRB4 & 0x04) << 3); |
| 4027 | return temp; |
| 4028 | } |
| 4029 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4030 | void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, |
| 4031 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4032 | { |
| 4033 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4034 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4035 | if (pXGIHWDE->jChipType == XG21) { |
| 4036 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 4037 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4038 | /* LVDS VDD on */ |
| 4039 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4040 | XGI_XG21SetPanelDelay(2, pVBInfo); |
| 4041 | } |
| 4042 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4043 | /* LVDS signal on */ |
| 4044 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4045 | XGI_XG21SetPanelDelay(3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4046 | /* LVDS backlight on */ |
| 4047 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4048 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4049 | /* DVO/DVI signal on */ |
| 4050 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4051 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4052 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4053 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4054 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4055 | if (pXGIHWDE->jChipType == XG27) { |
| 4056 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 4057 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4058 | /* LVDS VDD on */ |
| 4059 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4060 | XGI_XG21SetPanelDelay(2, pVBInfo); |
| 4061 | } |
| 4062 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4063 | /* LVDS signal on */ |
| 4064 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4065 | XGI_XG21SetPanelDelay(3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4066 | /* LVDS backlight on */ |
| 4067 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4068 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4069 | /* DVO/DVI signal on */ |
| 4070 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4071 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4072 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4073 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4074 | } |
| 4075 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4076 | void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, |
| 4077 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4078 | { |
| 4079 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4080 | if (pXGIHWDE->jChipType == XG21) { |
| 4081 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4082 | /* LVDS backlight off */ |
| 4083 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4084 | XGI_XG21SetPanelDelay(3, pVBInfo); |
| 4085 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4086 | /* DVO/DVI signal off */ |
| 4087 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4088 | } |
| 4089 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4090 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4091 | if (pXGIHWDE->jChipType == XG27) { |
| 4092 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4093 | /* LVDS backlight off */ |
| 4094 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4095 | XGI_XG21SetPanelDelay(3, pVBInfo); |
| 4096 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4097 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4098 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4099 | /* DVO/DVI signal off */ |
| 4100 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4101 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4102 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4103 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4104 | } |
| 4105 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4106 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4107 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4108 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4109 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4110 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4111 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4112 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4113 | } |
| 4114 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4115 | #if 0 |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4116 | static void XGI_WaitDisplay(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4117 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4118 | while (!(inb(pVBInfo->P3da) & 0x01)) |
| 4119 | ; |
| 4120 | while (inb(pVBInfo->P3da) & 0x01) |
| 4121 | ; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4122 | } |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4123 | #endif |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4124 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4125 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4126 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4127 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4128 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4129 | } |
| 4130 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4131 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 4132 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4133 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4134 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4135 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4136 | /* reserve CR34 for CRT1 Mode No */ |
| 4137 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4138 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 4139 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4140 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4141 | } |
| 4142 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4143 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
| 4144 | unsigned short ModeIdIndex, |
| 4145 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4146 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4147 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4148 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4149 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 4150 | if (ModeNo <= 0x13) { |
| 4151 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 4152 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4153 | /* si+St_ResInfo */ |
| 4154 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4155 | } else { |
| 4156 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4157 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4158 | /* si+St_ModeFlag */ |
| 4159 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4160 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4161 | /* |
| 4162 | if (pVBInfo->IF_DEF_FSTN) { |
| 4163 | xres *= 2; |
| 4164 | yres *= 2; |
| 4165 | } else { |
| 4166 | */ |
| 4167 | if (modeflag & HalfDCLK) |
| 4168 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4169 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4170 | if (modeflag & DoubleScanMode) |
| 4171 | yres *= 2; |
| 4172 | /* } */ |
| 4173 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4174 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4175 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4176 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 4177 | if (pVBInfo->LCDResInfo == Panel1600x1200) { |
| 4178 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4179 | if (yres == 1024) |
| 4180 | yres = 1056; |
| 4181 | } |
| 4182 | } |
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 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 4185 | if (yres == 400) |
| 4186 | yres = 405; |
| 4187 | else if (yres == 350) |
| 4188 | yres = 360; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4189 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4190 | if (pVBInfo->LCDInfo & LCDVESATiming) { |
| 4191 | if (yres == 360) |
| 4192 | yres = 375; |
| 4193 | } |
| 4194 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4195 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4196 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 4197 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4198 | if (!(pVBInfo->LCDInfo |
| 4199 | & LCDNonExpanding)) { |
| 4200 | if (yres == 350) |
| 4201 | yres = 357; |
| 4202 | else if (yres == 400) |
| 4203 | yres = 420; |
| 4204 | else if (yres == 480) |
| 4205 | yres = 525; |
| 4206 | } |
| 4207 | } |
| 4208 | } |
| 4209 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4210 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4211 | if (xres == 720) |
| 4212 | xres = 640; |
| 4213 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4214 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4215 | pVBInfo->VGAHDE = xres; |
| 4216 | pVBInfo->HDE = xres; |
| 4217 | pVBInfo->VGAVDE = yres; |
| 4218 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4219 | } |
| 4220 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4221 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4222 | { |
| 4223 | |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 4224 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && |
| 4225 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4226 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4227 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4228 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4229 | } |
| 4230 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4231 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
| 4232 | unsigned short ModeIdIndex, |
| 4233 | unsigned short RefreshRateTableIndex, |
| 4234 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4235 | { |
| 4236 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
| 4237 | StandTableIndex, CRT1Index; |
| 4238 | |
| 4239 | pVBInfo->RVBHCMAX = 1; |
| 4240 | pVBInfo->RVBHCFACT = 1; |
| 4241 | |
| 4242 | if (ModeNo <= 0x13) { |
| 4243 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 4244 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
| 4245 | tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0]; |
| 4246 | tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6]; |
| 4247 | temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
| 4248 | } else { |
| 4249 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4250 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 4251 | Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4252 | CRT1Index &= IndexMask; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4253 | temp1 = (unsigned short) pVBInfo-> |
| 4254 | XGINEWUB_CRT1Table[CRT1Index].CR[0]; |
| 4255 | temp2 = (unsigned short) pVBInfo-> |
| 4256 | XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4257 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4258 | tempbx = (unsigned short) pVBInfo-> |
| 4259 | XGINEWUB_CRT1Table[CRT1Index].CR[8]; |
| 4260 | tempcx = (unsigned short) pVBInfo-> |
| 4261 | XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4262 | tempcx &= 0x0100; |
| 4263 | tempcx = tempcx << 2; |
| 4264 | tempbx |= tempcx; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4265 | temp1 = (unsigned short) pVBInfo-> |
| 4266 | XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4267 | } |
| 4268 | |
| 4269 | if (temp1 & 0x01) |
| 4270 | tempbx |= 0x0100; |
| 4271 | |
| 4272 | if (temp1 & 0x20) |
| 4273 | tempbx |= 0x0200; |
| 4274 | tempax += 5; |
| 4275 | |
| 4276 | if (modeflag & Charx8Dot) |
| 4277 | tempax *= 8; |
| 4278 | else |
| 4279 | tempax *= 9; |
| 4280 | |
| 4281 | pVBInfo->VGAHT = tempax; |
| 4282 | pVBInfo->HT = tempax; |
| 4283 | tempbx++; |
| 4284 | pVBInfo->VGAVT = tempbx; |
| 4285 | pVBInfo->VT = tempbx; |
| 4286 | } |
| 4287 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4288 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4289 | unsigned short RefreshRateTableIndex, |
| 4290 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4291 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4292 | unsigned short tempax = 0, tempbx, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4293 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4294 | struct XGI_LCDDataStruct *LCDPtr = NULL; |
| 4295 | struct XGI_TVDataStruct *TVPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4296 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4297 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4298 | /* si+St_ResInfo */ |
| 4299 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4300 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4301 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4302 | /* si+Ext_ResInfo */ |
| 4303 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4304 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4305 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4306 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4307 | pVBInfo->NewFlickerMode = 0; |
| 4308 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4309 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4310 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4311 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4312 | pVBInfo); |
| 4313 | return; |
| 4314 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4315 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4316 | tempbx = 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4317 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4318 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 4319 | LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx, |
| 4320 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4321 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4322 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4323 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 4324 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 4325 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 4326 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 4327 | pVBInfo->HT = LCDPtr->LCDHT; |
| 4328 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4329 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4330 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 4331 | tempax = 1024; |
| 4332 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4333 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4334 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4335 | if (pVBInfo->VGAVDE == 357) |
| 4336 | tempbx = 527; |
| 4337 | else if (pVBInfo->VGAVDE == 420) |
| 4338 | tempbx = 620; |
| 4339 | else if (pVBInfo->VGAVDE == 525) |
| 4340 | tempbx = 775; |
| 4341 | else if (pVBInfo->VGAVDE == 600) |
| 4342 | tempbx = 775; |
| 4343 | /* else if (pVBInfo->VGAVDE==350) tempbx=560; */ |
| 4344 | /* else if (pVBInfo->VGAVDE==400) tempbx=640; */ |
| 4345 | else |
| 4346 | tempbx = 768; |
| 4347 | } else |
| 4348 | tempbx = 768; |
| 4349 | } else if (pVBInfo->LCDResInfo == Panel1024x768x75) { |
| 4350 | tempax = 1024; |
| 4351 | tempbx = 768; |
| 4352 | } else if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 4353 | tempax = 1280; |
| 4354 | if (pVBInfo->VGAVDE == 360) |
| 4355 | tempbx = 768; |
| 4356 | else if (pVBInfo->VGAVDE == 375) |
| 4357 | tempbx = 800; |
| 4358 | else if (pVBInfo->VGAVDE == 405) |
| 4359 | tempbx = 864; |
| 4360 | else |
| 4361 | tempbx = 1024; |
| 4362 | } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) { |
| 4363 | tempax = 1280; |
| 4364 | tempbx = 1024; |
| 4365 | } else if (pVBInfo->LCDResInfo == Panel1280x960) { |
| 4366 | tempax = 1280; |
| 4367 | if (pVBInfo->VGAVDE == 350) |
| 4368 | tempbx = 700; |
| 4369 | else if (pVBInfo->VGAVDE == 400) |
| 4370 | tempbx = 800; |
| 4371 | else if (pVBInfo->VGAVDE == 1024) |
| 4372 | tempbx = 960; |
| 4373 | else |
| 4374 | tempbx = 960; |
| 4375 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 4376 | tempax = 1400; |
| 4377 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4378 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4379 | if (pVBInfo->VGAVDE == 1024) { |
| 4380 | tempax = 1280; |
| 4381 | tempbx = 1024; |
| 4382 | } |
| 4383 | } else if (pVBInfo->LCDResInfo == Panel1600x1200) { |
| 4384 | tempax = 1600; |
| 4385 | tempbx = 1200; /* alan 10/14/2003 */ |
| 4386 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4387 | if (pVBInfo->VGAVDE == 350) |
| 4388 | tempbx = 875; |
| 4389 | else if (pVBInfo->VGAVDE == 400) |
| 4390 | tempbx = 1000; |
| 4391 | } |
| 4392 | } |
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 (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 4395 | tempax = pVBInfo->VGAHDE; |
| 4396 | tempbx = pVBInfo->VGAVDE; |
| 4397 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4398 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4399 | pVBInfo->HDE = tempax; |
| 4400 | pVBInfo->VDE = tempbx; |
| 4401 | return; |
| 4402 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4403 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4404 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
| 4405 | tempbx = 4; |
| 4406 | TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx, |
| 4407 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4408 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4409 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4410 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 4411 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 4412 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 4413 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 4414 | pVBInfo->HDE = TVPtr->TVHDE; |
| 4415 | pVBInfo->VDE = TVPtr->TVVDE; |
| 4416 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 4417 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4418 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4419 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4420 | if (resinfo == 0x08) |
| 4421 | pVBInfo->NewFlickerMode = 0x40; |
| 4422 | else if (resinfo == 0x09) |
| 4423 | pVBInfo->NewFlickerMode = 0x40; |
| 4424 | else if (resinfo == 0x12) |
| 4425 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4426 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4427 | if (pVBInfo->VGAVDE == 350) |
| 4428 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4429 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4430 | tempax = ExtHiTVHT; |
| 4431 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4432 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4433 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 4434 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4435 | tempax = StHiTVHT; |
| 4436 | tempbx = StHiTVVT; |
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 | if (!(modeflag & Charx8Dot)) { |
| 4439 | tempax = StHiTextTVHT; |
| 4440 | tempbx = StHiTextTVVT; |
| 4441 | } |
| 4442 | } |
| 4443 | } |
| 4444 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 4445 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
| 4446 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 4447 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 4448 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4449 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4450 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
| 4451 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 4452 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
| 4453 | } else if (pVBInfo->TVInfo & SetYPbPrMode525i) { |
| 4454 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 4455 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 4456 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 4457 | tempax = NTSC1024x768HT; |
| 4458 | } |
| 4459 | } else { |
| 4460 | tempax = PALHT; |
| 4461 | tempbx = PALVT; |
| 4462 | if (!(pVBInfo->TVInfo & SetPALTV)) { |
| 4463 | tempax = NTSCHT; |
| 4464 | tempbx = NTSCVT; |
| 4465 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 4466 | tempax = NTSC1024x768HT; |
| 4467 | } |
| 4468 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4469 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4470 | pVBInfo->HT = tempax; |
| 4471 | pVBInfo->VT = tempbx; |
| 4472 | return; |
| 4473 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4474 | } |
| 4475 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4476 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4477 | unsigned short RefreshRateTableIndex, |
| 4478 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4479 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 4480 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4481 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4482 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 4483 | pVBInfo); |
| 4484 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 4485 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4486 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4487 | if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */ |
| 4488 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4489 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 4490 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 4491 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4492 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4493 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 4494 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4495 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4496 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4497 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4498 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4499 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4500 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4501 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4502 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4503 | } |
| 4504 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4505 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
| 4506 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4507 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4508 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 4509 | short index; |
| 4510 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4511 | |
| 4512 | if (ModeNo <= 0x13) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4513 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4514 | else |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4515 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4516 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4517 | index = (modeflag & ModeInfoFlag) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4518 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4519 | if (index < 0) |
| 4520 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4521 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4522 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4523 | } |
| 4524 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4525 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 4526 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4527 | unsigned short RefreshRateTableIndex, |
| 4528 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4529 | struct vb_device_info *pVBInfo) |
| 4530 | { |
| 4531 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 4532 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 4533 | |
| 4534 | modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 4535 | if (ModeNo <= 0x14) |
| 4536 | infoflag = 0; |
| 4537 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4538 | infoflag = pVBInfo-> |
| 4539 | RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4540 | |
| 4541 | index = (modeinfo >> 8) & 0xFF; |
| 4542 | |
| 4543 | temp = pVBInfo->ScreenOffset[index]; |
| 4544 | |
| 4545 | if (infoflag & InterlaceMode) |
| 4546 | temp = temp << 1; |
| 4547 | |
| 4548 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 4549 | |
| 4550 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 4551 | temp = ModeNo - 0x7C; |
| 4552 | colordepth = ColorDepth[temp]; |
| 4553 | temp = 0x6B; |
| 4554 | if (infoflag & InterlaceMode) |
| 4555 | temp = temp << 1; |
| 4556 | return temp * colordepth; |
| 4557 | } else { |
| 4558 | return temp * colordepth; |
| 4559 | } |
| 4560 | } |
| 4561 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4562 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 4563 | unsigned short ModeIdIndex, |
| 4564 | unsigned short RefreshRateTableIndex, |
| 4565 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4566 | struct vb_device_info *pVBInfo) |
| 4567 | { |
| 4568 | unsigned short offset; |
| 4569 | unsigned char temp; |
| 4570 | |
| 4571 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 4572 | return; |
| 4573 | |
| 4574 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4575 | HwDeviceExtension, pVBInfo); |
| 4576 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4577 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4578 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4579 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4580 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4581 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4582 | } |
| 4583 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4584 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4585 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4586 | /* threshold high ,disable auto threshold */ |
| 4587 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 4588 | /* threshold low default 04h */ |
| 4589 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4590 | } |
| 4591 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4592 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4593 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4594 | unsigned short RefreshRateTableIndex, |
| 4595 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4596 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4597 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4598 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4599 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4600 | CRT1Index = pVBInfo-> |
| 4601 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4602 | CRT1Index &= IndexMask; |
| 4603 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4604 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4605 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4606 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4607 | HwDeviceExtension, pVBInfo); |
| 4608 | XGI_SetCRT2FIFO(pVBInfo); |
| 4609 | /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4610 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4611 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4612 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4613 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4614 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 4615 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4616 | } |
| 4617 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4618 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4619 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4620 | unsigned short RefreshRateTableIndex, |
| 4621 | struct vb_device_info *pVBInfo) |
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 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
| 4624 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; |
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 (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4627 | CRT1Index = pVBInfo-> |
| 4628 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4629 | CRT1Index &= IndexMask; |
| 4630 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4631 | } |
| 4632 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4633 | if (ModeNo <= 0x13) |
| 4634 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 4635 | else |
| 4636 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4637 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4638 | /* bainy change table name */ |
| 4639 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4640 | /* BTVGA2HT 0x08,0x09 */ |
| 4641 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4642 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4643 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4644 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4645 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 4646 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4647 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4648 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 4649 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 4650 | tempcx = tempcx >> 1; |
| 4651 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 4652 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4653 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4654 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4655 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4656 | tempbx |= ((pVBInfo-> |
| 4657 | XGINEWUB_CRT1Table[CRT1Index].CR[14] & |
| 4658 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4659 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 4660 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
| 4661 | tempcx &= 0x1F; |
| 4662 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15]; |
| 4663 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 4664 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 4665 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4666 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4667 | tempbx += 4; |
| 4668 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4669 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4670 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 4671 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4672 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4673 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4674 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4675 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4676 | } else { |
| 4677 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4678 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4679 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4680 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4681 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 4682 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4683 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4684 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 4685 | pushbx = pVBInfo->VGAHDE + 16; |
| 4686 | tempcx = tempcx >> 1; |
| 4687 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 4688 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4689 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4690 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4691 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4692 | tempbx |= ((pVBInfo-> |
| 4693 | XGINEWUB_CRT1Table[CRT1Index].CR[5] & |
| 4694 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4695 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 4696 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
| 4697 | tempcx &= 0x1F; |
| 4698 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6]; |
| 4699 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 4700 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 4701 | tempbx += 16; |
| 4702 | tempcx += 16; |
| 4703 | } |
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 | if (tempcx > pVBInfo->VGAHT) |
| 4706 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4707 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4708 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4709 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4710 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4711 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4712 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 4713 | tempbx = pushbx; |
| 4714 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 4715 | tempax |= (tempbx & 0xFF00); |
| 4716 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4717 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4718 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4719 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4720 | tempcx = (pVBInfo->VGAVT - 1); |
| 4721 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4722 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4723 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4724 | tempbx = pVBInfo->VGAVDE - 1; |
| 4725 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4726 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4727 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 4728 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4729 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4730 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4731 | tempax = pVBInfo->VGAVDE; |
| 4732 | tempbx = pVBInfo->VGAVDE; |
| 4733 | tempcx = pVBInfo->VGAVT; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4734 | /* BTVGA2VRS 0x10,0x11 */ |
| 4735 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 4736 | /* BTVGA2VRE 0x11 */ |
| 4737 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4738 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4739 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4740 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; |
| 4741 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4742 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4743 | if (temp & 0x04) |
| 4744 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4745 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4746 | if (temp & 0x080) |
| 4747 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4748 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4749 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4750 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4751 | if (temp & 0x08) |
| 4752 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4753 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4754 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; |
| 4755 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 4756 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4757 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4758 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4759 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4760 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 4761 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4762 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4763 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4764 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4765 | if (modeflag & DoubleScanMode) |
| 4766 | tempax |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4767 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4768 | if (modeflag & HalfDCLK) |
| 4769 | tempax |= 0x40; |
| 4770 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4771 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4772 | } |
| 4773 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4774 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 4775 | { |
| 4776 | unsigned long tempax, tempbx; |
| 4777 | |
| 4778 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 4779 | & 0xFFFF; |
| 4780 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 4781 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 4782 | |
| 4783 | return (unsigned short) tempax; |
| 4784 | } |
| 4785 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4786 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4787 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4788 | unsigned short RefreshRateTableIndex, |
| 4789 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4790 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4791 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
| 4792 | modeflag, CRT1Index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4793 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4794 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4795 | /* si+St_ResInfo */ |
| 4796 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4797 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4798 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4799 | /* si+Ext_ResInfo */ |
| 4800 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4801 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4802 | CRT1Index = pVBInfo-> |
| 4803 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4804 | CRT1Index &= IndexMask; |
| 4805 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4806 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4807 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 4808 | return; |
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 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4811 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4812 | /* if (modeflag & Charx8Dot) */ |
| 4813 | /* tempcx = 0x08; */ |
| 4814 | /* else */ |
| 4815 | tempcx = 0x08; |
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 (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
| 4818 | modeflag |= Charx8Dot; |
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 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4821 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4822 | if (modeflag & HalfDCLK) |
| 4823 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4824 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4825 | tempax = (tempax / tempcx) - 1; |
| 4826 | tempbx |= ((tempax & 0x00FF) << 8); |
| 4827 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4828 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4829 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4830 | temp = (tempbx & 0xFF00) >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4831 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4832 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4833 | if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 4834 | | VB_XGI302LV | VB_XGI301C))) |
| 4835 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4836 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4837 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4838 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 4839 | if (pVBInfo->VBExtInfo == VB_YPbPr1080i) { |
| 4840 | if (resinfo == 7) |
| 4841 | temp -= 2; |
| 4842 | } |
| 4843 | } else if (resinfo == 7) { |
| 4844 | temp -= 2; |
| 4845 | } |
| 4846 | } |
| 4847 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4848 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4849 | /* 0x05 Horizontal Display Start */ |
| 4850 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 4851 | /* 0x06 Horizontal Blank end */ |
| 4852 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4853 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4854 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 4855 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 4856 | tempax = pVBInfo->VGAHT; |
| 4857 | else |
| 4858 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 4859 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4860 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4861 | if (tempax >= pVBInfo->VGAHT) |
| 4862 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4863 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4864 | if (modeflag & HalfDCLK) |
| 4865 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4866 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4867 | tempax = (tempax / tempcx) - 5; |
| 4868 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
| 4869 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4870 | temp = (tempbx & 0x00FF) - 1; |
| 4871 | if (!(modeflag & HalfDCLK)) { |
| 4872 | temp -= 6; |
| 4873 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4874 | temp -= 4; |
| 4875 | if (ModeNo > 0x13) |
| 4876 | temp -= 10; |
| 4877 | } |
| 4878 | } |
| 4879 | } else { |
| 4880 | /* tempcx = tempbx & 0x00FF ; */ |
| 4881 | tempbx = (tempbx & 0xFF00) >> 8; |
| 4882 | tempcx = (tempcx + tempbx) >> 1; |
| 4883 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4884 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4885 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4886 | temp -= 1; |
| 4887 | if (!(modeflag & HalfDCLK)) { |
| 4888 | if ((modeflag & Charx8Dot)) { |
| 4889 | temp += 4; |
| 4890 | if (pVBInfo->VGAHDE >= 800) |
| 4891 | temp -= 6; |
| 4892 | } |
| 4893 | } |
| 4894 | } else { |
| 4895 | if (!(modeflag & HalfDCLK)) { |
| 4896 | temp -= 4; |
| 4897 | if (pVBInfo->LCDResInfo != Panel1280x960) { |
| 4898 | if (pVBInfo->VGAHDE >= 800) { |
| 4899 | temp -= 7; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4900 | if (pVBInfo->ModeType == |
| 4901 | ModeEGA) { |
| 4902 | if (pVBInfo->VGAVDE == |
| 4903 | 1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4904 | temp += 15; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4905 | if (pVBInfo->LCDResInfo != Panel1280x1024) { |
| 4906 | temp += |
| 4907 | 7; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4908 | } |
| 4909 | } |
| 4910 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4911 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4912 | if (pVBInfo->VGAHDE >= 1280) { |
| 4913 | if (pVBInfo->LCDResInfo |
| 4914 | != Panel1280x960) { |
| 4915 | if (pVBInfo->LCDInfo |
| 4916 | & LCDNonExpanding) { |
| 4917 | temp |
| 4918 | += 28; |
| 4919 | } |
| 4920 | } |
| 4921 | } |
| 4922 | } |
| 4923 | } |
| 4924 | } |
| 4925 | } |
| 4926 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4927 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4928 | /* 0x07 Horizontal Retrace Start */ |
| 4929 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 4930 | /* 0x08 Horizontal Retrace End */ |
| 4931 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4932 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4933 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4934 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4935 | if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo |
| 4936 | == 0x11) || (ModeNo == 0x13) || (ModeNo |
| 4937 | == 0x0F)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4938 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b); |
| 4939 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4940 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4941 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4942 | if ((ModeNo == 0x00) || (ModeNo == 0x01)) { |
| 4943 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4944 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4945 | 0x07, 0x2A); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4946 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4947 | 0x08, 0x61); |
| 4948 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4949 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4950 | 0x07, 0x2A); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4951 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4952 | 0x08, 0x41); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4953 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4954 | 0x0C, 0xF0); |
| 4955 | } |
| 4956 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4957 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4958 | if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo |
| 4959 | == 0x07)) { |
| 4960 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4961 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4962 | 0x07, 0x54); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4963 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4964 | 0x08, 0x00); |
| 4965 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4966 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4967 | 0x07, 0x55); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4968 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4969 | 0x08, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4970 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4971 | 0x0C, 0xF0); |
| 4972 | } |
| 4973 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4974 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4975 | if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo |
| 4976 | == 0x0D) || (ModeNo == 0x50)) { |
| 4977 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4978 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4979 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4980 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4981 | 0x08, 0x03); |
| 4982 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4983 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4984 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4985 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4986 | 0x08, 0x02); |
| 4987 | } |
| 4988 | } |
| 4989 | } |
| 4990 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4991 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4992 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4993 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4994 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
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 | tempbx = pVBInfo->VGAVT; |
| 4997 | push1 = tempbx; |
| 4998 | tempcx = 0x121; |
| 4999 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5000 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5001 | if (tempbx == 357) |
| 5002 | tempbx = 350; |
| 5003 | if (tempbx == 360) |
| 5004 | tempbx = 350; |
| 5005 | if (tempbx == 375) |
| 5006 | tempbx = 350; |
| 5007 | if (tempbx == 405) |
| 5008 | tempbx = 400; |
| 5009 | if (tempbx == 525) |
| 5010 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5011 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5012 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5013 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5014 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 5015 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 5016 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 5017 | if (tempbx == 350) |
| 5018 | tempbx += 5; |
| 5019 | if (tempbx == 480) |
| 5020 | tempbx += 5; |
| 5021 | } |
| 5022 | } |
| 5023 | } |
| 5024 | tempbx--; |
| 5025 | temp = tempbx & 0x00FF; |
| 5026 | tempbx--; |
| 5027 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5028 | /* 0x10 vertical Blank Start */ |
| 5029 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5030 | tempbx = push2; |
| 5031 | tempbx--; |
| 5032 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5033 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5034 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5035 | if (tempbx & 0x0100) |
| 5036 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5037 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5038 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5039 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5040 | if (modeflag & DoubleScanMode) |
| 5041 | tempax |= 0x08000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5042 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5043 | if (tempbx & 0x0200) |
| 5044 | tempcx |= 0x0040; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5045 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5046 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5047 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5048 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5049 | if (tempbx & 0x0400) |
| 5050 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5051 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5052 | /* 0x11 Vertival Blank End */ |
| 5053 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5054 | |
| 5055 | tempax = push1; |
| 5056 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 5057 | tempax = tempax >> 2; |
| 5058 | push1 = tempax; /* push ax */ |
| 5059 | |
| 5060 | if (resinfo != 0x09) { |
| 5061 | tempax = tempax << 1; |
| 5062 | tempbx += tempax; |
| 5063 | } |
| 5064 | |
| 5065 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5066 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 5067 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 5068 | tempbx -= 10; |
| 5069 | } else { |
| 5070 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 5071 | if (pVBInfo->TVInfo & SetPALTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5072 | if (pVBInfo->VBType & |
| 5073 | VB_XGI301LV) { |
| 5074 | if (!(pVBInfo->TVInfo & |
| 5075 | (SetYPbPrMode525p | |
| 5076 | SetYPbPrMode750p | |
| 5077 | SetYPbPrMode1080i))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5078 | tempbx += 40; |
| 5079 | } else { |
| 5080 | tempbx += 40; |
| 5081 | } |
| 5082 | } |
| 5083 | } |
| 5084 | } |
| 5085 | } else { |
| 5086 | tempbx -= 10; |
| 5087 | } |
| 5088 | } else { |
| 5089 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 5090 | if (pVBInfo->TVInfo & SetPALTV) { |
| 5091 | if (pVBInfo->VBType & VB_XGI301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5092 | if (!(pVBInfo->TVInfo & |
| 5093 | (SetYPbPrMode525p | |
| 5094 | SetYPbPrMode750p | |
| 5095 | SetYPbPrMode1080i))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5096 | tempbx += 40; |
| 5097 | } else { |
| 5098 | tempbx += 40; |
| 5099 | } |
| 5100 | } |
| 5101 | } |
| 5102 | } |
| 5103 | tempax = push1; |
| 5104 | tempax = tempax >> 2; |
| 5105 | tempax++; |
| 5106 | tempax += tempbx; |
| 5107 | push1 = tempax; /* push ax */ |
| 5108 | |
| 5109 | if ((pVBInfo->TVInfo & SetPALTV)) { |
| 5110 | if (tempbx <= 513) { |
| 5111 | if (tempax >= 513) |
| 5112 | tempbx = 513; |
| 5113 | } |
| 5114 | } |
| 5115 | |
| 5116 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5117 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5118 | tempbx--; |
| 5119 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5120 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5121 | |
| 5122 | if (tempbx & 0x0100) |
| 5123 | tempcx |= 0x0008; |
| 5124 | |
| 5125 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5126 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5127 | |
| 5128 | tempbx++; |
| 5129 | |
| 5130 | if (tempbx & 0x0100) |
| 5131 | tempcx |= 0x0004; |
| 5132 | |
| 5133 | if (tempbx & 0x0200) |
| 5134 | tempcx |= 0x0080; |
| 5135 | |
| 5136 | if (tempbx & 0x0400) |
| 5137 | tempcx |= 0x0C00; |
| 5138 | |
| 5139 | tempbx = push1; /* pop ax */ |
| 5140 | temp = tempbx & 0x00FF; |
| 5141 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5142 | /* 0x0D vertical Retrace End */ |
| 5143 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5144 | |
| 5145 | if (tempbx & 0x0010) |
| 5146 | tempcx |= 0x2000; |
| 5147 | |
| 5148 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5149 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5150 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5151 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5152 | tempax = modeflag; |
| 5153 | temp = (tempax & 0xFF00) >> 8; |
| 5154 | |
| 5155 | temp = (temp >> 1) & 0x09; |
| 5156 | |
| 5157 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
| 5158 | temp |= 0x01; |
| 5159 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5160 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 5161 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 5162 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5163 | |
| 5164 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 5165 | temp = 0x80; |
| 5166 | else |
| 5167 | temp = 0x00; |
| 5168 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5169 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5170 | |
| 5171 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5172 | } |
| 5173 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5174 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5175 | unsigned short RefreshRateTableIndex, |
| 5176 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5177 | struct vb_device_info *pVBInfo) |
| 5178 | { |
| 5179 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
| 5180 | modeflag, resinfo, crt2crtc; |
| 5181 | unsigned char *TimingPoint; |
| 5182 | |
| 5183 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 5184 | |
| 5185 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5186 | /* si+St_ResInfo */ |
| 5187 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5188 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 5189 | crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 5190 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5191 | /* si+Ext_ResInfo */ |
| 5192 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5193 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5194 | crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 5195 | Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5196 | } |
| 5197 | |
| 5198 | tempax = 0; |
| 5199 | |
| 5200 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 5201 | tempax |= 0x0800; |
| 5202 | |
| 5203 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5204 | tempax |= 0x0400; |
| 5205 | |
| 5206 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 5207 | tempax |= 0x0200; |
| 5208 | |
| 5209 | if (!(pVBInfo->TVInfo & SetPALTV)) |
| 5210 | tempax |= 0x1000; |
| 5211 | |
| 5212 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5213 | tempax |= 0x0100; |
| 5214 | |
| 5215 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
| 5216 | tempax &= 0xfe00; |
| 5217 | |
| 5218 | tempax = (tempax & 0xff00) >> 8; |
| 5219 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5220 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5221 | TimingPoint = pVBInfo->NTSCTiming; |
| 5222 | |
| 5223 | if (pVBInfo->TVInfo & SetPALTV) |
| 5224 | TimingPoint = pVBInfo->PALTiming; |
| 5225 | |
| 5226 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5227 | TimingPoint = pVBInfo->HiTVExtTiming; |
| 5228 | |
| 5229 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 5230 | TimingPoint = pVBInfo->HiTVSt2Timing; |
| 5231 | |
| 5232 | if (pVBInfo->SetFlag & TVSimuMode) |
| 5233 | TimingPoint = pVBInfo->HiTVSt1Timing; |
| 5234 | |
| 5235 | if (!(modeflag & Charx8Dot)) |
| 5236 | TimingPoint = pVBInfo->HiTVTextTiming; |
| 5237 | } |
| 5238 | |
| 5239 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5240 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5241 | TimingPoint = pVBInfo->YPbPr525iTiming; |
| 5242 | |
| 5243 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5244 | TimingPoint = pVBInfo->YPbPr525pTiming; |
| 5245 | |
| 5246 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5247 | TimingPoint = pVBInfo->YPbPr750pTiming; |
| 5248 | } |
| 5249 | |
| 5250 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5251 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5252 | |
| 5253 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5254 | /* di->temp2[j] */ |
| 5255 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5256 | |
| 5257 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5258 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5259 | |
| 5260 | temp = pVBInfo->NewFlickerMode; |
| 5261 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5262 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5263 | |
| 5264 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5265 | tempax = 950; |
| 5266 | |
| 5267 | if (pVBInfo->TVInfo & SetPALTV) |
| 5268 | tempax = 520; |
| 5269 | else |
| 5270 | tempax = 440; |
| 5271 | |
| 5272 | if (pVBInfo->VDE <= tempax) { |
| 5273 | tempax -= pVBInfo->VDE; |
| 5274 | tempax = tempax >> 2; |
| 5275 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 5276 | push1 = tempax; |
| 5277 | temp = (tempax & 0xFF00) >> 8; |
| 5278 | temp += (unsigned short) TimingPoint[0]; |
| 5279 | |
| 5280 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5281 | | VB_XGI302LV | VB_XGI301C)) { |
| 5282 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 5283 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
| 5284 | | SetCRT2ToYPbPr)) { |
| 5285 | tempcx = pVBInfo->VGAHDE; |
| 5286 | if (tempcx >= 1024) { |
| 5287 | temp = 0x17; /* NTSC */ |
| 5288 | if (pVBInfo->TVInfo & SetPALTV) |
| 5289 | temp = 0x19; /* PAL */ |
| 5290 | } |
| 5291 | } |
| 5292 | } |
| 5293 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5294 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5295 | tempax = push1; |
| 5296 | temp = (tempax & 0xFF00) >> 8; |
| 5297 | temp += TimingPoint[1]; |
| 5298 | |
| 5299 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5300 | | VB_XGI302LV | VB_XGI301C)) { |
| 5301 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 5302 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
| 5303 | | SetCRT2ToYPbPr))) { |
| 5304 | tempcx = pVBInfo->VGAHDE; |
| 5305 | if (tempcx >= 1024) { |
| 5306 | temp = 0x1D; /* NTSC */ |
| 5307 | if (pVBInfo->TVInfo & SetPALTV) |
| 5308 | temp = 0x52; /* PAL */ |
| 5309 | } |
| 5310 | } |
| 5311 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5312 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5313 | } |
| 5314 | |
| 5315 | /* 301b */ |
| 5316 | tempcx = pVBInfo->HT; |
| 5317 | |
| 5318 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5319 | tempcx = tempcx >> 1; |
| 5320 | |
| 5321 | tempcx -= 2; |
| 5322 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5323 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5324 | |
| 5325 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5326 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5327 | |
| 5328 | tempcx = pVBInfo->HT >> 1; |
| 5329 | push1 = tempcx; /* push cx */ |
| 5330 | tempcx += 7; |
| 5331 | |
| 5332 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5333 | tempcx -= 4; |
| 5334 | |
| 5335 | temp = tempcx & 0x00FF; |
| 5336 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5337 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5338 | |
| 5339 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 5340 | tempbx += tempcx; |
| 5341 | push2 = tempbx; |
| 5342 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5343 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5344 | temp = (tempbx & 0xFF00) >> 8; |
| 5345 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5346 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5347 | |
| 5348 | tempbx = push2; |
| 5349 | tempbx = tempbx + 8; |
| 5350 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5351 | tempbx = tempbx - 4; |
| 5352 | tempcx = tempbx; |
| 5353 | } |
| 5354 | |
| 5355 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5356 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5357 | |
| 5358 | j += 2; |
| 5359 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 5360 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5361 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5362 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5363 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5364 | |
| 5365 | tempcx += 8; |
| 5366 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5367 | tempcx -= 4; |
| 5368 | |
| 5369 | temp = tempcx & 0xFF; |
| 5370 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5371 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5372 | |
| 5373 | tempcx = push1; /* pop cx */ |
| 5374 | j += 2; |
| 5375 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 5376 | tempcx -= temp; |
| 5377 | temp = tempcx & 0x00FF; |
| 5378 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5379 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5380 | |
| 5381 | tempcx -= 11; |
| 5382 | |
| 5383 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 5384 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 5385 | tempcx = tempax - 1; |
| 5386 | } |
| 5387 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5388 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5389 | |
| 5390 | tempbx = pVBInfo->VDE; |
| 5391 | |
| 5392 | if (pVBInfo->VGAVDE == 360) |
| 5393 | tempbx = 746; |
| 5394 | if (pVBInfo->VGAVDE == 375) |
| 5395 | tempbx = 746; |
| 5396 | if (pVBInfo->VGAVDE == 405) |
| 5397 | tempbx = 853; |
| 5398 | |
| 5399 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5400 | if (pVBInfo->VBType & |
| 5401 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
| 5402 | if (!(pVBInfo->TVInfo & |
| 5403 | (SetYPbPrMode525p | SetYPbPrMode750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5404 | tempbx = tempbx >> 1; |
| 5405 | } else |
| 5406 | tempbx = tempbx >> 1; |
| 5407 | } |
| 5408 | |
| 5409 | tempbx -= 2; |
| 5410 | temp = tempbx & 0x00FF; |
| 5411 | |
| 5412 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5413 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 5414 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 5415 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5416 | if (ModeNo == 0x2f) |
| 5417 | temp += 1; |
| 5418 | } |
| 5419 | } |
| 5420 | } else { |
| 5421 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5422 | if (ModeNo == 0x2f) |
| 5423 | temp += 1; |
| 5424 | } |
| 5425 | } |
| 5426 | } |
| 5427 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5428 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5429 | |
| 5430 | temp = (tempcx & 0xFF00) >> 8; |
| 5431 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 5432 | |
| 5433 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) { |
| 5434 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 5435 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 5436 | temp |= 0x10; |
| 5437 | |
| 5438 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5439 | temp |= 0x20; |
| 5440 | } |
| 5441 | } else { |
| 5442 | temp |= 0x10; |
| 5443 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5444 | temp |= 0x20; |
| 5445 | } |
| 5446 | } |
| 5447 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5448 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5449 | |
| 5450 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5451 | | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */ |
| 5452 | tempbx = pVBInfo->VDE; |
| 5453 | tempcx = tempbx - 2; |
| 5454 | |
| 5455 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 5456 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p |
| 5457 | | SetYPbPrMode750p))) |
| 5458 | tempbx = tempbx >> 1; |
| 5459 | } |
| 5460 | |
| 5461 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 5462 | temp = 0; |
| 5463 | if (tempcx & 0x0400) |
| 5464 | temp |= 0x20; |
| 5465 | |
| 5466 | if (tempbx & 0x0400) |
| 5467 | temp |= 0x40; |
| 5468 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5469 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5470 | } |
| 5471 | |
| 5472 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5473 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5474 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5475 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5476 | } |
| 5477 | |
| 5478 | tempbx = tempbx & 0x00FF; |
| 5479 | |
| 5480 | if (!(modeflag & HalfDCLK)) { |
| 5481 | tempcx = pVBInfo->VGAHDE; |
| 5482 | if (tempcx >= pVBInfo->HDE) { |
| 5483 | tempbx |= 0x2000; |
| 5484 | tempax &= 0x00FF; |
| 5485 | } |
| 5486 | } |
| 5487 | |
| 5488 | tempcx = 0x0101; |
| 5489 | |
| 5490 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 5491 | if (pVBInfo->VGAHDE >= 1024) { |
| 5492 | tempcx = 0x1920; |
| 5493 | if (pVBInfo->VGAHDE >= 1280) { |
| 5494 | tempcx = 0x1420; |
| 5495 | tempbx = tempbx & 0xDFFF; |
| 5496 | } |
| 5497 | } |
| 5498 | } |
| 5499 | |
| 5500 | if (!(tempbx & 0x2000)) { |
| 5501 | if (modeflag & HalfDCLK) |
| 5502 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 5503 | |
| 5504 | push1 = tempbx; |
| 5505 | tempeax = pVBInfo->VGAHDE; |
| 5506 | tempebx = (tempcx & 0xFF00) >> 8; |
| 5507 | longtemp = tempeax * tempebx; |
| 5508 | tempecx = tempcx & 0x00FF; |
| 5509 | longtemp = longtemp / tempecx; |
| 5510 | |
| 5511 | /* 301b */ |
| 5512 | tempecx = 8 * 1024; |
| 5513 | |
| 5514 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5515 | | VB_XGI302LV | VB_XGI301C)) { |
| 5516 | tempecx = tempecx * 8; |
| 5517 | } |
| 5518 | |
| 5519 | longtemp = longtemp * tempecx; |
| 5520 | tempecx = pVBInfo->HDE; |
| 5521 | temp2 = longtemp % tempecx; |
| 5522 | tempeax = longtemp / tempecx; |
| 5523 | if (temp2 != 0) |
| 5524 | tempeax += 1; |
| 5525 | |
| 5526 | tempax = (unsigned short) tempeax; |
| 5527 | |
| 5528 | /* 301b */ |
| 5529 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5530 | | VB_XGI302LV | VB_XGI301C)) { |
| 5531 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 5532 | } |
| 5533 | /* end 301b */ |
| 5534 | |
| 5535 | tempbx = push1; |
| 5536 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 5537 | | (tempbx & 0x00FF)); |
| 5538 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 5539 | | (tempax & 0x00FF)); |
| 5540 | temp = (tempax & 0xFF00) >> 8; |
| 5541 | } else { |
| 5542 | temp = (tempax & 0x00FF) >> 8; |
| 5543 | } |
| 5544 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5545 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5546 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5547 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5548 | temp = tempcx & 0x00FF; |
| 5549 | |
| 5550 | if (tempbx & 0x2000) |
| 5551 | temp = 0; |
| 5552 | |
| 5553 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5554 | temp |= 0x18; |
| 5555 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5556 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5557 | if (pVBInfo->TVInfo & SetPALTV) { |
| 5558 | tempbx = 0x0382; |
| 5559 | tempcx = 0x007e; |
| 5560 | } else { |
| 5561 | tempbx = 0x0369; |
| 5562 | tempcx = 0x0061; |
| 5563 | } |
| 5564 | |
| 5565 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5566 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5567 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5568 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5569 | |
| 5570 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 5571 | temp = temp << 2; |
| 5572 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 5573 | |
| 5574 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5575 | temp |= 0x10; |
| 5576 | |
| 5577 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5578 | temp |= 0x20; |
| 5579 | |
| 5580 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5581 | temp |= 0x60; |
| 5582 | } |
| 5583 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5584 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5585 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5586 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5587 | |
| 5588 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { |
| 5589 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 5590 | TimingPoint = XGI_NTSC1024AdjTime; |
| 5591 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5592 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5593 | TimingPoint[j]); |
| 5594 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5595 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5596 | } |
| 5597 | } |
| 5598 | |
| 5599 | /* [ycchen] 01/14/03 Modify for 301C PALM Support */ |
| 5600 | if (pVBInfo->VBType & VB_XGI301C) { |
| 5601 | if (pVBInfo->TVInfo & SetPALMTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5602 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5603 | 0x08); /* PALM Mode */ |
| 5604 | } |
| 5605 | |
| 5606 | if (pVBInfo->TVInfo & SetPALMTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5607 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5608 | 0x01); |
| 5609 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5610 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5611 | |
| 5612 | /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5613 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5614 | } |
| 5615 | |
| 5616 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5617 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5618 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5619 | } |
| 5620 | |
| 5621 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 5622 | return; |
| 5623 | } |
| 5624 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5625 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5626 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5627 | unsigned short RefreshRateTableIndex, |
| 5628 | struct vb_device_info *pVBInfo) |
| 5629 | { |
| 5630 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
| 5631 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; |
| 5632 | |
| 5633 | struct XGI_LCDDesStruct *LCDBDesPtr = NULL; |
| 5634 | |
| 5635 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5636 | /* si+St_ResInfo */ |
| 5637 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5638 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 5639 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5640 | /* si+Ext_ResInfo */ |
| 5641 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5642 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5643 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 5644 | Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5645 | CRT1Index &= IndexMask; |
| 5646 | } |
| 5647 | |
| 5648 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5649 | return; |
| 5650 | |
| 5651 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 5652 | |
| 5653 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5654 | tempbx = tempbx >> 1; |
| 5655 | |
| 5656 | tempbx -= 1; |
| 5657 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5658 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5659 | temp = (tempbx & 0xFF00) >> 8; |
| 5660 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5661 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5662 | temp = 0x01; |
| 5663 | |
| 5664 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 5665 | if (pVBInfo->ModeType == ModeEGA) { |
| 5666 | if (pVBInfo->VGAHDE >= 1024) { |
| 5667 | temp = 0x02; |
| 5668 | if (pVBInfo->LCDInfo & LCDVESATiming) |
| 5669 | temp = 0x01; |
| 5670 | } |
| 5671 | } |
| 5672 | } |
| 5673 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5674 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5675 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
| 5676 | push1 = tempbx; |
| 5677 | tempbx--; |
| 5678 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5679 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5680 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5681 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5682 | |
| 5683 | tempcx = pVBInfo->VT - 1; |
| 5684 | push2 = tempcx + 1; |
| 5685 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5686 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5687 | temp = (tempcx & 0xFF00) >> 8; |
| 5688 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5689 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5690 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 5691 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 5692 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 5693 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5694 | |
| 5695 | /* Customized LCDB Des no add */ |
| 5696 | tempbx = 5; |
| 5697 | LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo, |
| 5698 | ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5699 | tempah = pVBInfo->LCDResInfo; |
| 5700 | tempah &= PanelResInfo; |
| 5701 | |
| 5702 | if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) { |
| 5703 | tempbx = 1024; |
| 5704 | tempcx = 768; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5705 | } else if ((tempah == Panel1280x1024) || |
| 5706 | (tempah == Panel1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5707 | tempbx = 1280; |
| 5708 | tempcx = 1024; |
| 5709 | } else if (tempah == Panel1400x1050) { |
| 5710 | tempbx = 1400; |
| 5711 | tempcx = 1050; |
| 5712 | } else { |
| 5713 | tempbx = 1600; |
| 5714 | tempcx = 1200; |
| 5715 | } |
| 5716 | |
| 5717 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 5718 | tempbx = pVBInfo->HDE; |
| 5719 | tempcx = pVBInfo->VDE; |
| 5720 | } |
| 5721 | |
| 5722 | pushbx = tempbx; |
| 5723 | tempax = pVBInfo->VT; |
| 5724 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 5725 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 5726 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 5727 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 5728 | tempbx = pVBInfo->LCDVDES; |
| 5729 | tempcx += tempbx; |
| 5730 | |
| 5731 | if (tempcx >= tempax) |
| 5732 | tempcx -= tempax; /* lcdvdes */ |
| 5733 | |
| 5734 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5735 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5736 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5737 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5738 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 5739 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 5740 | tempah = tempch; |
| 5741 | tempah = tempah << 3; |
| 5742 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5743 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5744 | |
| 5745 | /* getlcdsync() */ |
| 5746 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 5747 | tempcx = tempbx; |
| 5748 | tempax = pVBInfo->VT; |
| 5749 | tempbx = pVBInfo->LCDVRS; |
| 5750 | |
| 5751 | /* if (SetLCD_Info & EnableScalingLCD) */ |
| 5752 | tempcx += tempbx; |
| 5753 | if (tempcx >= tempax) |
| 5754 | tempcx -= tempax; |
| 5755 | |
| 5756 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5757 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5758 | temp = (tempbx & 0xFF00) >> 8; |
| 5759 | temp = temp << 4; |
| 5760 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5761 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5762 | tempcx = pushbx; |
| 5763 | tempax = pVBInfo->HT; |
| 5764 | tempbx = pVBInfo->LCDHDES; |
| 5765 | tempbx &= 0x0FFF; |
| 5766 | |
| 5767 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 5768 | tempax = tempax >> 1; |
| 5769 | tempbx = tempbx >> 1; |
| 5770 | tempcx = tempcx >> 1; |
| 5771 | } |
| 5772 | |
| 5773 | if (pVBInfo->VBType & VB_XGI302LV) |
| 5774 | tempbx += 1; |
| 5775 | |
| 5776 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 5777 | tempbx += 1; |
| 5778 | |
| 5779 | tempcx += tempbx; |
| 5780 | |
| 5781 | if (tempcx >= tempax) |
| 5782 | tempcx -= tempax; |
| 5783 | |
| 5784 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5785 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5786 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5787 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5788 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5789 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5790 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5791 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5792 | |
| 5793 | /* getlcdsync() */ |
| 5794 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 5795 | tempcx = tempax; |
| 5796 | tempax = pVBInfo->HT; |
| 5797 | tempbx = pVBInfo->LCDHRS; |
| 5798 | /* if ( SetLCD_Info & EnableScalingLCD) */ |
| 5799 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 5800 | tempax = tempax >> 1; |
| 5801 | tempbx = tempbx >> 1; |
| 5802 | tempcx = tempcx >> 1; |
| 5803 | } |
| 5804 | |
| 5805 | if (pVBInfo->VBType & VB_XGI302LV) |
| 5806 | tempbx += 1; |
| 5807 | |
| 5808 | tempcx += tempbx; |
| 5809 | |
| 5810 | if (tempcx >= tempax) |
| 5811 | tempcx -= tempax; |
| 5812 | |
| 5813 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5814 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5815 | |
| 5816 | temp = (tempbx & 0xFF00) >> 8; |
| 5817 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5818 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5819 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5820 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5821 | |
| 5822 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 5823 | if (pVBInfo->VGAVDE == 525) { |
| 5824 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 5825 | | VB_XGI301LV | VB_XGI302LV |
| 5826 | | VB_XGI301C)) { |
| 5827 | temp = 0xC6; |
| 5828 | } else |
| 5829 | temp = 0xC4; |
| 5830 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5831 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 5832 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5833 | } |
| 5834 | |
| 5835 | if (pVBInfo->VGAVDE == 420) { |
| 5836 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 5837 | | VB_XGI301LV | VB_XGI302LV |
| 5838 | | VB_XGI301C)) { |
| 5839 | temp = 0x4F; |
| 5840 | } else |
| 5841 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5842 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5843 | } |
| 5844 | } |
| 5845 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5846 | |
| 5847 | /* --------------------------------------------------------------------- */ |
| 5848 | /* Function : XGI_GetTap4Ptr */ |
| 5849 | /* Input : */ |
| 5850 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 5851 | /* Description : */ |
| 5852 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5853 | static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5854 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5855 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5856 | unsigned short tempax, tempbx, i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5857 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5858 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5859 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5860 | if (tempcx == 0) { |
| 5861 | tempax = pVBInfo->VGAHDE; |
| 5862 | tempbx = pVBInfo->HDE; |
| 5863 | } else { |
| 5864 | tempax = pVBInfo->VGAVDE; |
| 5865 | tempbx = pVBInfo->VDE; |
| 5866 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5867 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5868 | if (tempax < tempbx) |
| 5869 | return &EnlargeTap4Timing[0]; |
| 5870 | else if (tempax == tempbx) |
| 5871 | return &NoScaleTap4Timing[0]; /* 1:1 */ |
| 5872 | else |
| 5873 | Tap4TimingPtr = NTSCTap4Timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5874 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5875 | if (pVBInfo->TVInfo & SetPALTV) |
| 5876 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5877 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5878 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5879 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5880 | Tap4TimingPtr = YPbPr525iTap4Timing; |
| 5881 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5882 | Tap4TimingPtr = YPbPr525pTap4Timing; |
| 5883 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5884 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 5885 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5886 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5887 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5888 | Tap4TimingPtr = HiTVTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5889 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5890 | i = 0; |
| 5891 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 5892 | if (Tap4TimingPtr[i].DE == tempax) |
| 5893 | break; |
| 5894 | i++; |
| 5895 | } |
| 5896 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5897 | } |
| 5898 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5899 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5900 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5901 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5902 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5903 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5904 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5905 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 5906 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5907 | |
| 5908 | #ifndef Tap4 |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5909 | xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5910 | #else /* Tap4 Setting */ |
| 5911 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5912 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 5913 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5914 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5915 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5916 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
| 5917 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) { |
| 5918 | /* Set Vertical Scaling */ |
| 5919 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5920 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5921 | xgifb_reg_set(pVBInfo->Part2Port, |
| 5922 | i, |
| 5923 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5924 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5925 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5926 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
| 5927 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) |
| 5928 | /* Enable V.Scaling */ |
| 5929 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5930 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5931 | /* Enable H.Scaling */ |
| 5932 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5933 | #endif |
| 5934 | } |
| 5935 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5936 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5937 | struct vb_device_info *pVBInfo) |
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 | unsigned short i; |
| 5940 | unsigned char *tempdi; |
| 5941 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5942 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5943 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5944 | /* si+St_ResInfo */ |
| 5945 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5946 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5947 | /* si+Ext_ResInfo */ |
| 5948 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5949 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5950 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5951 | if (pVBInfo->TVInfo & SetPALTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5952 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 5953 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5954 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5955 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 5956 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5957 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5958 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5959 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 5960 | return; |
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 (pVBInfo->TVInfo & SetPALMTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5963 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 5964 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 5965 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5966 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5967 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5968 | if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo |
| 5969 | & SetCRT2ToYPbPr)) { |
| 5970 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5971 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5972 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5973 | tempdi = pVBInfo->HiTVGroup3Data; |
| 5974 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 5975 | tempdi = pVBInfo->HiTVGroup3Simu; |
| 5976 | if (!(modeflag & Charx8Dot)) |
| 5977 | tempdi = pVBInfo->HiTVGroup3Text; |
| 5978 | } |
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 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5981 | tempdi = pVBInfo->Ren525pGroup3; |
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 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5984 | tempdi = pVBInfo->Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5985 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5986 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5987 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5988 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5989 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
| 5990 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5991 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5992 | } |
| 5993 | } |
| 5994 | return; |
| 5995 | } /* {end of XGI_SetGroup3} */ |
| 5996 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5997 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5998 | unsigned short RefreshRateTableIndex, |
| 5999 | struct xgi_hw_device_info *HwDeviceExtension, |
| 6000 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6001 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6002 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6003 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6004 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6005 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6006 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6007 | /* si+St_ResInfo */ |
| 6008 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6009 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6010 | /* si+Ext_ResInfo */ |
| 6011 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6012 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6013 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6014 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6015 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6016 | tempbx = pVBInfo->RVBHCMAX; |
| 6017 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6018 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6019 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 6020 | tempcx = pVBInfo->VGAHT - 1; |
| 6021 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6022 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6023 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6024 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 6025 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6026 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6027 | tempcx = pVBInfo->VGAVT - 1; |
| 6028 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 6029 | tempcx -= 5; |
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 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6032 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6033 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6034 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6035 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6036 | tempcx = pVBInfo->VBInfo; |
| 6037 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6038 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6039 | if (modeflag & HalfDCLK) |
| 6040 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6041 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6042 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 6043 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6044 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6045 | if (tempcx & SetCRT2ToHiVisionTV) { |
| 6046 | temp = 0; |
| 6047 | if (tempbx <= 1024) |
| 6048 | temp = 0xA0; |
| 6049 | if (tempbx == 1280) |
| 6050 | temp = 0xC0; |
| 6051 | } else if (tempcx & SetCRT2ToTV) { |
| 6052 | temp = 0xA0; |
| 6053 | if (tempbx <= 800) |
| 6054 | temp = 0x80; |
| 6055 | } else { |
| 6056 | temp = 0x80; |
| 6057 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 6058 | temp = 0; |
| 6059 | if (tempbx > 800) |
| 6060 | temp = 0x60; |
| 6061 | } |
| 6062 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6063 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6064 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) { |
| 6065 | temp = 0x00; |
| 6066 | if (pVBInfo->VGAHDE == 1280) |
| 6067 | temp = 0x40; |
| 6068 | if (pVBInfo->VGAHDE == 1024) |
| 6069 | temp = 0x20; |
| 6070 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6071 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6072 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6073 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6074 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6075 | if (tempcx & SetCRT2ToHiVisionTV) { |
| 6076 | if (!(temp & 0xE000)) |
| 6077 | tempbx = tempbx >> 1; |
| 6078 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6079 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6080 | tempcx = pVBInfo->RVBHRS; |
| 6081 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6082 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6083 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6084 | tempeax = pVBInfo->VGAVDE; |
| 6085 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6086 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6087 | if (tempeax <= tempebx) { |
| 6088 | tempcx = (tempcx & (~0x4000)); |
| 6089 | tempeax = pVBInfo->VGAVDE; |
| 6090 | } else { |
| 6091 | tempeax -= tempebx; |
| 6092 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6093 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6094 | templong = (tempeax * 256 * 1024) % tempebx; |
| 6095 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 6096 | tempebx = tempeax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6097 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6098 | if (templong != 0) |
| 6099 | tempebx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6100 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6101 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6102 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6103 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6104 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6105 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6106 | tempbx = (unsigned short) (tempebx >> 16); |
| 6107 | temp = tempbx & 0x00FF; |
| 6108 | temp = temp << 4; |
| 6109 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6110 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6111 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6112 | /* 301b */ |
| 6113 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6114 | | VB_XGI302LV | VB_XGI301C)) { |
| 6115 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6116 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6117 | tempax = pVBInfo->VGAHDE; |
| 6118 | if (modeflag & HalfDCLK) |
| 6119 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6120 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6121 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 6122 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6123 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6124 | /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) || |
| 6125 | ((pVBInfo->TVInfo&SetYPbPrMode525p) || |
| 6126 | (pVBInfo->TVInfo&SetYPbPrMode750p))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6127 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 6128 | if (tempax > 800) |
| 6129 | tempax -= 800; |
| 6130 | } else { |
| 6131 | if (pVBInfo->VGAHDE > 800) { |
| 6132 | if (pVBInfo->VGAHDE == 1024) |
| 6133 | tempax = (tempax * 25 / 32) - 1; |
| 6134 | else |
| 6135 | tempax = (tempax * 20 / 32) - 1; |
| 6136 | } |
| 6137 | } |
| 6138 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6139 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6140 | /* |
| 6141 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
| 6142 | if (pVBInfo->VBType & VB_XGI301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6143 | if (!(pVBInfo->TVInfo & |
| 6144 | (SetYPbPrMode525p | |
| 6145 | SetYPbPrMode750p | |
| 6146 | SetYPbPrMode1080i))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6147 | if (pVBInfo->VGAHDE > 800) { |
| 6148 | if (pVBInfo->VGAHDE == 1024) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6149 | tempax =(tempax * 25 / |
| 6150 | 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6151 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6152 | tempax = (tempax * 20 / |
| 6153 | 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6154 | } |
| 6155 | } |
| 6156 | } else { |
| 6157 | if (pVBInfo->VGAHDE > 800) { |
| 6158 | if (pVBInfo->VGAHDE == 1024) |
| 6159 | tempax = (tempax * 25 / 32) - 1; |
| 6160 | else |
| 6161 | tempax = (tempax * 20 / 32) - 1; |
| 6162 | } |
| 6163 | } |
| 6164 | } |
| 6165 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6166 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6167 | temp = (tempax & 0xFF00) >> 8; |
| 6168 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6169 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6170 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6171 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
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 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
| 6174 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6175 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6176 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6177 | } |
| 6178 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6179 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6180 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 6181 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
| 6182 | | SetYPbPrMode525p | SetYPbPrMode750p |
| 6183 | | SetYPbPrMode1080i))) { |
| 6184 | temp |= 0x0001; |
| 6185 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 6186 | && (!(pVBInfo->TVInfo |
| 6187 | & TVSimuMode))) |
| 6188 | temp &= (~0x0001); |
| 6189 | } |
| 6190 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6191 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6192 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6193 | tempbx = pVBInfo->HT; |
| 6194 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 6195 | tempbx = tempbx >> 1; |
| 6196 | tempbx = (tempbx >> 1) - 2; |
| 6197 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6198 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6199 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6200 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6201 | } |
| 6202 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6203 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6204 | if (pVBInfo->ISXPDOS == 0) |
| 6205 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 6206 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6207 | } |
| 6208 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6209 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 6210 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6211 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6212 | } |
| 6213 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6214 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6215 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6216 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6217 | unsigned short Pindex, Pdata; |
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 | Pindex = pVBInfo->Part5Port; |
| 6220 | Pdata = pVBInfo->Part5Port + 1; |
| 6221 | if (pVBInfo->ModeType == ModeVGA) { |
| 6222 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
| 6223 | | CRT2DisplayFlag))) { |
| 6224 | XGINew_EnableCRT2(pVBInfo); |
| 6225 | /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */ |
| 6226 | } |
| 6227 | } |
| 6228 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6229 | } |
| 6230 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6231 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6232 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6233 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6234 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6235 | } |
| 6236 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6237 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6238 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6239 | { |
| 6240 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6241 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6242 | } |
| 6243 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6244 | /*----------------------------------------------------------------------------*/ |
| 6245 | /* input */ |
| 6246 | /* bl[5] : 1;LVDS signal on */ |
| 6247 | /* bl[1] : 1;LVDS backlight on */ |
| 6248 | /* bl[0] : 1:LVDS VDD on */ |
| 6249 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 6250 | /* 000010b : clear bit 1, to set bit1 */ |
| 6251 | /* 000001b : clear bit 0, to set bit0 */ |
| 6252 | /*----------------------------------------------------------------------------*/ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6253 | void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 6254 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6255 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6256 | unsigned char CR4A, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6257 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6258 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6259 | tempbh &= 0x23; |
| 6260 | tempbl &= 0x23; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6261 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6262 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6263 | if (tempbh & 0x20) { |
| 6264 | temp = (tempbl >> 4) & 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6265 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6266 | /* CR B4[1] */ |
| 6267 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
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 | } |
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 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6272 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6273 | temp = XG21GPIODataTransfer(temp); |
| 6274 | temp &= ~tempbh; |
| 6275 | temp |= tempbl; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6276 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6277 | } |
| 6278 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6279 | void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 6280 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6281 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6282 | unsigned char CR4A, temp; |
| 6283 | unsigned short tempbh0, tempbl0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6284 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6285 | tempbh0 = tempbh; |
| 6286 | tempbl0 = tempbl; |
| 6287 | tempbh0 &= 0x20; |
| 6288 | tempbl0 &= 0x20; |
| 6289 | tempbh0 >>= 3; |
| 6290 | tempbl0 >>= 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6291 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6292 | if (tempbh & 0x20) { |
| 6293 | temp = (tempbl >> 4) & 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6294 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6295 | /* CR B4[1] */ |
| 6296 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6297 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6298 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6299 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6300 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6301 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6302 | tempbh &= 0x03; |
| 6303 | tempbl &= 0x03; |
| 6304 | tempbh <<= 2; |
| 6305 | tempbl <<= 2; /* GPIOC,GPIOD */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6306 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6307 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6308 | } |
| 6309 | |
| 6310 | /* --------------------------------------------------------------------- */ |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6311 | unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo) |
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 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6314 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6315 | index = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6316 | if (index < sizeof(XGI21_LCDCapList) |
| 6317 | / sizeof(struct XGI21_LVDSCapStruct)) |
| 6318 | return index; |
| 6319 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6320 | } |
| 6321 | |
| 6322 | /* --------------------------------------------------------------------- */ |
| 6323 | /* Function : XGI_XG21SetPanelDelay */ |
| 6324 | /* Input : */ |
| 6325 | /* Output : */ |
| 6326 | /* Description : */ |
| 6327 | /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */ |
| 6328 | /* : bl : 2 ; T2 : the duration signal on and Vdd on */ |
| 6329 | /* : bl : 3 ; T3 : the duration between CPL off and signal off */ |
| 6330 | /* : bl : 4 ; T4 : the duration signal off and Vdd off */ |
| 6331 | /* --------------------------------------------------------------------- */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6332 | void XGI_XG21SetPanelDelay(unsigned short tempbl, |
| 6333 | struct vb_device_info *pVBInfo) |
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 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6336 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6337 | index = XGI_GetLVDSOEMTableIndex(pVBInfo); |
| 6338 | if (tempbl == 1) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6339 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6340 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6341 | if (tempbl == 2) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6342 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6343 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6344 | if (tempbl == 3) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6345 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6346 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6347 | if (tempbl == 4) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6348 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6349 | } |
| 6350 | |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 6351 | unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6352 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6353 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6354 | unsigned short xres, yres, colordepth, modeflag, resindex, |
| 6355 | lvdstableindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6356 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6357 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6358 | if (ModeNo <= 0x13) { |
| 6359 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 6360 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6361 | /* si+St_ResInfo */ |
| 6362 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6363 | } else { |
| 6364 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 6365 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6366 | /* si+St_ModeFlag */ |
| 6367 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6368 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6369 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6370 | if (!(modeflag & Charx8Dot)) { |
| 6371 | xres /= 9; |
| 6372 | xres *= 8; |
| 6373 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6374 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6375 | if (ModeNo > 0x13) { |
| 6376 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 6377 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6378 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6379 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 6380 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6381 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6382 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6383 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6384 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); |
| 6385 | if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE)) |
| 6386 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6387 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6388 | if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) |
| 6389 | return 0; |
| 6390 | |
| 6391 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6392 | if ((xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6393 | LVDSHDE)) || |
| 6394 | (yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6395 | LVDSVDE))) { |
| 6396 | colordepth = XGI_GetColorDepth(ModeNo, |
| 6397 | ModeIdIndex, |
| 6398 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6399 | if (colordepth > 2) |
| 6400 | return 0; |
| 6401 | |
| 6402 | } |
| 6403 | } |
| 6404 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6405 | } |
| 6406 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6407 | void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6408 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6409 | unsigned char temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6410 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6411 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6412 | temp = (temp & 1) << 6; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6413 | /* SR06[6] 18bit Dither */ |
| 6414 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 6415 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 6416 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6417 | |
| 6418 | } |
| 6419 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6420 | void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6421 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6422 | unsigned char temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6423 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6424 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 6425 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6426 | temp = (temp & 3) << 6; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6427 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 6428 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 6429 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 6430 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6431 | |
| 6432 | } |
| 6433 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6434 | static void XGI_SetXG21LVDSPara(unsigned short ModeNo, |
| 6435 | unsigned short ModeIdIndex, |
| 6436 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6437 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6438 | unsigned char temp, Miscdata; |
| 6439 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; |
| 6440 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 6441 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 6442 | unsigned short value; |
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 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6445 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6446 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6447 | LVDS_Capability & |
| 6448 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6449 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6450 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6451 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6452 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6453 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6454 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6455 | LVDS_Capability & LCDPolarity); |
| 6456 | /* SR35[7] FP VSync polarity */ |
| 6457 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 6458 | /* SR30[5] FP HSync polarity */ |
| 6459 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6460 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6461 | XGI_SetXG21FPBits(pVBInfo); |
| 6462 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6463 | if (ModeNo <= 0x13) { |
| 6464 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 6465 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6466 | /* si+St_ResInfo */ |
| 6467 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6468 | } else { |
| 6469 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 6470 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6471 | /* si+St_ModeFlag */ |
| 6472 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6473 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6474 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6475 | if (!(modeflag & Charx8Dot)) |
| 6476 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6477 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6478 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6479 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6480 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE |
| 6481 | - xres) / 2; |
| 6482 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) |
| 6483 | LVDSHBS -= xres / 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6484 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6485 | if (LVDSHBS > LVDSHT) |
| 6486 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6487 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6488 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; |
| 6489 | if (LVDSHRS > LVDSHT) |
| 6490 | LVDSHRS -= LVDSHT; |
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 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; |
| 6493 | if (LVDSHRE > LVDSHT) |
| 6494 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6495 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6496 | LVDSHBE = LVDSHBS + LVDSHT |
| 6497 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6498 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6499 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6500 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6501 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE |
| 6502 | - yres) / 2; |
| 6503 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 6504 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6505 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6506 | if (LVDSVBS > LVDSVT) |
| 6507 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6508 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6509 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; |
| 6510 | if (LVDSVRS > LVDSVT) |
| 6511 | LVDSVRS -= LVDSVT; |
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 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC; |
| 6514 | if (LVDSVRE > LVDSVT) |
| 6515 | LVDSVRE -= LVDSVT; |
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 | LVDSVBE = LVDSVBS + LVDSVT |
| 6518 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6519 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6520 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6521 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6522 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6523 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6524 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6525 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6526 | /* HT SR0B[1:0] CR00 */ |
| 6527 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6528 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6529 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (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 | /* HBS SR0B[5:4] CR02 */ |
| 6532 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6533 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6534 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (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 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 6537 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6538 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 6539 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 6540 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6541 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6542 | /* HRS SR0B[7:6] CR04 */ |
| 6543 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6544 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6545 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6546 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6547 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 6548 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6549 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6550 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6551 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6552 | /* HRE SR0C[2] CR05[4:0] */ |
| 6553 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6554 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 6555 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6556 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6557 | /* Panel HRE SR2F[7:2] */ |
| 6558 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6559 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6560 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6561 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 6562 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6563 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 6564 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 6565 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6566 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6567 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6568 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 6569 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6570 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 6571 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 6572 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6573 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6574 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6575 | /* VBE SR0A[4] CR16 */ |
| 6576 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6577 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6578 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6579 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6580 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 6581 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6582 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 6583 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 6584 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6585 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6586 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6587 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6588 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6589 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6590 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6591 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6592 | /* VRE SR0A[5] CR11[3:0] */ |
| 6593 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6594 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 6595 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6596 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6597 | /* 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] | 6598 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6600 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6601 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6602 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6603 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6604 | 0x2B, |
| 6605 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6606 | VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6607 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6608 | 0x2C, |
| 6609 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6610 | VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6611 | value += 0x10; |
| 6612 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6613 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6614 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6615 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6616 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6617 | /* set data, panning = 0, shift left 1 dot*/ |
| 6618 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6619 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6620 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6621 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6622 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6623 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6624 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6625 | |
| 6626 | } |
| 6627 | |
| 6628 | /* no shadow case */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6629 | static void XGI_SetXG27LVDSPara(unsigned short ModeNo, |
| 6630 | unsigned short ModeIdIndex, |
| 6631 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6632 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6633 | unsigned char temp, Miscdata; |
| 6634 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; |
| 6635 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 6636 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 6637 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6638 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6639 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6640 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6641 | LVDS_Capability & |
| 6642 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6643 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6644 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6645 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6646 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6647 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6648 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6649 | LVDS_Capability & LCDPolarity); |
| 6650 | /* SR35[7] FP VSync polarity */ |
| 6651 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 6652 | /* SR30[5] FP HSync polarity */ |
| 6653 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6654 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6655 | XGI_SetXG27FPBits(pVBInfo); |
| 6656 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6657 | if (ModeNo <= 0x13) { |
| 6658 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 6659 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6660 | /* si+St_ResInfo */ |
| 6661 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6662 | } else { |
| 6663 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 6664 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6665 | /* si+St_ModeFlag */ |
| 6666 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6667 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6668 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6669 | if (!(modeflag & Charx8Dot)) |
| 6670 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6671 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6672 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; |
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 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE |
| 6675 | - xres) / 2; |
| 6676 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) |
| 6677 | LVDSHBS -= xres / 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6678 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6679 | if (LVDSHBS > LVDSHT) |
| 6680 | LVDSHBS -= LVDSHT; |
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 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; |
| 6683 | if (LVDSHRS > LVDSHT) |
| 6684 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6685 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6686 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; |
| 6687 | if (LVDSHRE > LVDSHT) |
| 6688 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6689 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6690 | LVDSHBE = LVDSHBS + LVDSHT |
| 6691 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; |
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 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6694 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6695 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE |
| 6696 | - yres) / 2; |
| 6697 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 6698 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6699 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6700 | if (LVDSVBS > LVDSVT) |
| 6701 | LVDSVBS -= LVDSVT; |
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 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; |
| 6704 | if (LVDSVRS > LVDSVT) |
| 6705 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6706 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6707 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6708 | LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6709 | if (LVDSVRE > LVDSVT) |
| 6710 | LVDSVRE -= LVDSVT; |
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 | LVDSVBE = LVDSVBS + LVDSVT |
| 6713 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6714 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6715 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6716 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6717 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6718 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6719 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6720 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6721 | /* HT SR0B[1:0] CR00 */ |
| 6722 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6723 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6724 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (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 | /* HBS SR0B[5:4] CR02 */ |
| 6727 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6728 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6729 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (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 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 6732 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6733 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 6734 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 6735 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6736 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6737 | /* HRS SR0B[7:6] CR04 */ |
| 6738 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6739 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6740 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (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 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 6743 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6744 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6745 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
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 | /* HRE SR0C[2] CR05[4:0] */ |
| 6748 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6749 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 6750 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6751 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6752 | /* Panel HRE SR2F[7:2] */ |
| 6753 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6754 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6755 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6756 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 6757 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6758 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 6759 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 6760 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6761 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6762 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6763 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 6764 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6765 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 6766 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 6767 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6768 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6769 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6770 | /* VBE SR0A[4] CR16 */ |
| 6771 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6772 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6773 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6774 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6775 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 6776 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6777 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 6778 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 6779 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6780 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6781 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6782 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6783 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6784 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6785 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6786 | /* VRE SR0A[5] CR11[3:0] */ |
| 6787 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6788 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 6789 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6790 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6791 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6792 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6793 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6794 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6795 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6796 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6797 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6798 | 0x2B, |
| 6799 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6800 | VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6801 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6802 | 0x2C, |
| 6803 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6804 | VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6805 | value += 0x10; |
| 6806 | } |
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 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6809 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6810 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6811 | /* set data, panning = 0, shift left 1 dot*/ |
| 6812 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6813 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6814 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6815 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6816 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6817 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6818 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6819 | |
| 6820 | } |
| 6821 | |
| 6822 | /* --------------------------------------------------------------------- */ |
| 6823 | /* Function : XGI_IsLCDON */ |
| 6824 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6825 | /* Output : 0 : Skip PSC Control */ |
| 6826 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6827 | /* Description : */ |
| 6828 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6829 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6830 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6831 | unsigned short tempax; |
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 | tempax = pVBInfo->VBInfo; |
| 6834 | if (tempax & SetCRT2ToDualEdge) |
| 6835 | return 0; |
| 6836 | else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode)) |
| 6837 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6838 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6839 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6840 | } |
| 6841 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6842 | /* --------------------------------------------------------------------- */ |
| 6843 | /* Function : XGI_DisableChISLCD */ |
| 6844 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6845 | /* Output : 0 -> Not LCD Mode */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6846 | /* Description : */ |
| 6847 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6848 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6849 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6850 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6851 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6852 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6853 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6854 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6855 | if (tempbx & (EnableChA | DisableChA)) { |
| 6856 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 6857 | return 0; |
| 6858 | } |
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 (!(tempbx & (EnableChB | DisableChB))) |
| 6861 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6862 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6863 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 6864 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6865 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6866 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6867 | } |
| 6868 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6869 | /* --------------------------------------------------------------------- */ |
| 6870 | /* Function : XGI_EnableChISLCD */ |
| 6871 | /* Input : */ |
| 6872 | /* Output : 0 -> Not LCD mode */ |
| 6873 | /* Description : */ |
| 6874 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6875 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6876 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6877 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6878 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6879 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6880 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6881 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6882 | if (tempbx & (EnableChA | DisableChA)) { |
| 6883 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 6884 | return 0; |
| 6885 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6886 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6887 | if (!(tempbx & (EnableChB | DisableChB))) |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6888 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6889 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6890 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 6891 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6892 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6893 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6894 | } |
| 6895 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6896 | void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
| 6897 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6898 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 6899 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6900 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6901 | if (pVBInfo->SetFlag == Win9xDOSMode) |
| 6902 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6903 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6904 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6905 | | VB_XGI302LV | VB_XGI301C)) { |
| 6906 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6907 | if (!(pVBInfo->VBInfo & |
| 6908 | (DisableCRT2Display | SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6909 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 6910 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 6911 | tempah = 0x7F; /* Disable Channel A */ |
| 6912 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6913 | /* Disable Channel B */ |
| 6914 | tempah = 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6915 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6916 | if (pVBInfo->SetFlag & DisableChB) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6917 | /* force to disable Cahnnel */ |
| 6918 | tempah &= 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6919 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6920 | if (pVBInfo->SetFlag & DisableChA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6921 | /* Force to disable Channel B */ |
| 6922 | tempah &= 0x7F; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6923 | } |
| 6924 | } |
| 6925 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6926 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6927 | /* disable part4_1f */ |
| 6928 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6929 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6930 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 6931 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 6932 | || (XGI_DisableChISLCD(pVBInfo)) |
| 6933 | || (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6934 | /* LVDS Driver power down */ |
| 6935 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6936 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6937 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6938 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
| 6939 | & (DisableCRT2Display | SetCRT2ToLCDA |
| 6940 | | SetSimuScanMode))) { |
| 6941 | if (pVBInfo->SetFlag & GatingCRT) |
| 6942 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); |
| 6943 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 6944 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6945 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6946 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 6947 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
| 6948 | & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6949 | /* Power down */ |
| 6950 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6951 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6952 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6953 | /* disable TV as primary VGA swap */ |
| 6954 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6955 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6956 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6957 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6958 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6959 | if ((pVBInfo->SetFlag & DisableChB) || |
| 6960 | (pVBInfo->VBInfo & |
| 6961 | (DisableCRT2Display | SetSimuScanMode)) || |
| 6962 | ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && |
| 6963 | (pVBInfo->VBInfo & |
| 6964 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
| 6965 | /* BScreenOff=1 */ |
| 6966 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6967 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6968 | if ((pVBInfo->SetFlag & DisableChB) || |
| 6969 | (pVBInfo->VBInfo & |
| 6970 | (DisableCRT2Display | SetSimuScanMode)) || |
| 6971 | (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) || |
| 6972 | (pVBInfo->VBInfo & |
| 6973 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 6974 | /* save Part1 index 0 */ |
| 6975 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 6976 | /* BTDAC = 1, avoid VB reset */ |
| 6977 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 6978 | /* disable CRT2 */ |
| 6979 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 6980 | /* restore Part1 index 0 */ |
| 6981 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6982 | } |
| 6983 | } else { /* {301} */ |
| 6984 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6985 | /* BScreenOff=1 */ |
| 6986 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 6987 | /* Disable CRT2 */ |
| 6988 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 6989 | /* Disable TV asPrimary VGA swap */ |
| 6990 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6991 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6992 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6993 | if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA |
| 6994 | | SetSimuScanMode)) |
| 6995 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 6996 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6997 | } |
| 6998 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6999 | /* --------------------------------------------------------------------- */ |
| 7000 | /* Function : XGI_GetTVPtrIndex */ |
| 7001 | /* Input : */ |
| 7002 | /* Output : */ |
| 7003 | /* Description : bx 0 : ExtNTSC */ |
| 7004 | /* 1 : StNTSC */ |
| 7005 | /* 2 : ExtPAL */ |
| 7006 | /* 3 : StPAL */ |
| 7007 | /* 4 : ExtHiTV */ |
| 7008 | /* 5 : StHiTV */ |
| 7009 | /* 6 : Ext525i */ |
| 7010 | /* 7 : St525i */ |
| 7011 | /* 8 : Ext525p */ |
| 7012 | /* 9 : St525p */ |
| 7013 | /* A : Ext750p */ |
| 7014 | /* B : St750p */ |
| 7015 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7016 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7017 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7018 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7019 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7020 | if (pVBInfo->TVInfo & SetPALTV) |
| 7021 | tempbx = 2; |
| 7022 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) |
| 7023 | tempbx = 4; |
| 7024 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 7025 | tempbx = 6; |
| 7026 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 7027 | tempbx = 8; |
| 7028 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 7029 | tempbx = 10; |
| 7030 | if (pVBInfo->TVInfo & TVSimuMode) |
| 7031 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7032 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7033 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7034 | } |
| 7035 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7036 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7037 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7038 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7039 | /* Output : bx 0 : NTSC */ |
| 7040 | /* 1 : PAL */ |
| 7041 | /* 2 : PALM */ |
| 7042 | /* 3 : PALN */ |
| 7043 | /* 4 : NTSC1024x768 */ |
| 7044 | /* 5 : PAL-M 1024x768 */ |
| 7045 | /* 6-7: reserved */ |
| 7046 | /* cl 0 : YFilter1 */ |
| 7047 | /* 1 : YFilter2 */ |
| 7048 | /* ch 0 : 301A */ |
| 7049 | /* 1 : 301B/302B/301LV/302LV */ |
| 7050 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7051 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7052 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 7053 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7054 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7055 | *tempbx = 0; |
| 7056 | *tempcl = 0; |
| 7057 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7058 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7059 | if (pVBInfo->TVInfo & SetPALTV) |
| 7060 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7061 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7062 | if (pVBInfo->TVInfo & SetPALMTV) |
| 7063 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7064 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7065 | if (pVBInfo->TVInfo & SetPALNTV) |
| 7066 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7067 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7068 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 7069 | *tempbx = 4; |
| 7070 | if (pVBInfo->TVInfo & SetPALMTV) |
| 7071 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7072 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7073 | |
| 7074 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7075 | | VB_XGI302LV | VB_XGI301C)) { |
| 7076 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 7077 | & TVSimuMode)) { |
| 7078 | *tempbx += 8; |
| 7079 | *tempcl += 1; |
| 7080 | } |
| 7081 | } |
| 7082 | |
| 7083 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7084 | | VB_XGI302LV | VB_XGI301C)) |
| 7085 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7086 | } |
| 7087 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7088 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7089 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7090 | unsigned short index; |
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 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7093 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7094 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7095 | | VB_XGI302LV | VB_XGI301C)) { |
| 7096 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA |
| 7097 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
| 7098 | tempbl = 0; |
| 7099 | tempbh = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7100 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7101 | index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */ |
| 7102 | tempbl = pVBInfo->XGI_TVDelayList[index]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7103 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7104 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 7105 | | VB_XGI301LV | VB_XGI302LV |
| 7106 | | VB_XGI301C)) |
| 7107 | tempbl = pVBInfo->XGI_TVDelayList2[index]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7108 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7109 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 7110 | tempbl = tempbl >> 4; |
| 7111 | /* |
| 7112 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
| 7113 | tempbl = CRT2Delay1; // Get CRT2 Delay |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7114 | if (pVBInfo->VBType & |
| 7115 | (VB_XGI301B | |
| 7116 | VB_XGI302B | |
| 7117 | VB_XGI301LV | |
| 7118 | VB_XGI302LV | |
| 7119 | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7120 | tempbl = CRT2Delay2; |
| 7121 | */ |
| 7122 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7123 | /* Get LCD Delay */ |
| 7124 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 7125 | tempbh = pVBInfo->LCDCapList[index]. |
| 7126 | LCD_DelayCompensation; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7127 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7128 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
| 7129 | tempbl = tempbh; |
| 7130 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7131 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7132 | tempbl &= 0x0F; |
| 7133 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7134 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7135 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7136 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 7137 | | SetCRT2ToTV)) { /* Channel B */ |
| 7138 | tempah &= 0xF0; |
| 7139 | tempah |= tempbl; |
| 7140 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7141 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7142 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */ |
| 7143 | tempah &= 0x0F; |
| 7144 | tempah |= tempbh; |
| 7145 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7146 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7147 | } |
| 7148 | } else if (pVBInfo->IF_DEF_LVDS == 1) { |
| 7149 | tempbl = 0; |
| 7150 | tempbh = 0; |
| 7151 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7152 | /* / Get LCD Delay */ |
| 7153 | tempah = pVBInfo->LCDCapList[ |
| 7154 | XGI_GetLCDCapPtr(pVBInfo)]. |
| 7155 | LCD_DelayCompensation; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7156 | tempah &= 0x0f; |
| 7157 | tempah = tempah << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7158 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7159 | tempah); |
| 7160 | } |
| 7161 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7162 | } |
| 7163 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7164 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 7165 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7166 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7167 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7168 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7169 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7170 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7171 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7172 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7173 | /* Enable Dither */ |
| 7174 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7175 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7176 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7177 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7178 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7179 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7180 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7181 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7182 | /* |
| 7183 | if (tempcx & EnableLCD24bpp) { // 24bits |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7184 | xgifb_reg_and_or(pVBInfo->Part1Port, |
| 7185 | 0x19, |
| 7186 | 0x0F, |
| 7187 | (unsigned short)(0x30 | (tempcx&0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7188 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7189 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7190 | xgifb_reg_and_or(pVBInfo->Part1Port, |
| 7191 | 0x19, |
| 7192 | 0x0F, |
| 7193 | // Enable Dither |
| 7194 | (unsigned short)(0x20 | (tempcx&0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7195 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7196 | } |
| 7197 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7198 | } |
| 7199 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7200 | /* --------------------------------------------------------------------- */ |
| 7201 | /* Function : XGI_SetLCDCap_B */ |
| 7202 | /* Input : cx -> LCD Capability */ |
| 7203 | /* Output : */ |
| 7204 | /* Description : */ |
| 7205 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7206 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 7207 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7208 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7209 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7210 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7211 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 7212 | | 0x0c)); |
| 7213 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7214 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7215 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 7216 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7217 | } |
| 7218 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7219 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7220 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7221 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7222 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7223 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7224 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7225 | /* disable down spectrum D[4] */ |
| 7226 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7227 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7228 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7229 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7230 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7231 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7232 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7233 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7234 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7235 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7236 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7237 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7238 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 7239 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7240 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7241 | } |
| 7242 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7243 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 7244 | { |
| 7245 | unsigned short tempcx; |
| 7246 | |
| 7247 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 7248 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7249 | if (pVBInfo->VBType & |
| 7250 | (VB_XGI301B | |
| 7251 | VB_XGI302B | |
| 7252 | VB_XGI301LV | |
| 7253 | VB_XGI302LV | |
| 7254 | VB_XGI301C)) { /* 301LV/302LV only */ |
| 7255 | if (pVBInfo->VBType & |
| 7256 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7257 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7258 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7259 | (unsigned char) (tempcx & 0x1F)); |
| 7260 | } |
| 7261 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7262 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7263 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 7264 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 7265 | | EnablePLLSPLOW)) >> 8)); |
| 7266 | } |
| 7267 | |
| 7268 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7269 | | VB_XGI302LV | VB_XGI301C)) { |
| 7270 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 7271 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
| 7272 | else if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 7273 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 7274 | |
| 7275 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 7276 | if (tempcx & EnableSpectrum) |
| 7277 | SetSpectrum(pVBInfo); |
| 7278 | } |
| 7279 | } else { |
| 7280 | /* LVDS,CH7017 */ |
| 7281 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 7282 | } |
| 7283 | } |
| 7284 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7285 | /* --------------------------------------------------------------------- */ |
| 7286 | /* Function : XGI_SetAntiFlicker */ |
| 7287 | /* Input : */ |
| 7288 | /* Output : */ |
| 7289 | /* Description : Set TV Customized Param. */ |
| 7290 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7291 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
| 7292 | unsigned short ModeIdIndex, |
| 7293 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7294 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7295 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7296 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7297 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7298 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7299 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
| 7300 | return; |
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 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 7303 | tempbx &= 0xFE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7304 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7305 | if (ModeNo <= 0x13) |
| 7306 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; |
| 7307 | else |
| 7308 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7309 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7310 | tempbx += index; |
| 7311 | tempah = TVAntiFlickList[tempbx]; |
| 7312 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7313 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7314 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7315 | } |
| 7316 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7317 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
| 7318 | unsigned short ModeIdIndex, |
| 7319 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7320 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7321 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7322 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7323 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7324 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7325 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 7326 | tempbx &= 0xFE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7327 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7328 | if (ModeNo <= 0x13) |
| 7329 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; |
| 7330 | else |
| 7331 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7332 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7333 | tempbx += index; |
| 7334 | tempah = TVEdgeList[tempbx]; |
| 7335 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7336 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7337 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7338 | } |
| 7339 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7340 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
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 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7343 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7344 | unsigned char tempcl, tempch; |
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 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7347 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7348 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 7349 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7350 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7351 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7352 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7353 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7354 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7355 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7356 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7357 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7358 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7359 | } |
| 7360 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7361 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7362 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7363 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7364 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7365 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7366 | unsigned char tempcl, tempch, tempal, *filterPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7367 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7368 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7369 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7370 | switch (tempbx) { |
| 7371 | case 0x00: |
| 7372 | case 0x04: |
| 7373 | filterPtr = NTSCYFilter1; |
| 7374 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7375 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7376 | case 0x01: |
| 7377 | filterPtr = PALYFilter1; |
| 7378 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7379 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7380 | case 0x02: |
| 7381 | case 0x05: |
| 7382 | case 0x0D: |
| 7383 | filterPtr = PALMYFilter1; |
| 7384 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7385 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7386 | case 0x03: |
| 7387 | filterPtr = PALNYFilter1; |
| 7388 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7389 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7390 | case 0x08: |
| 7391 | case 0x0C: |
| 7392 | filterPtr = NTSCYFilter2; |
| 7393 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7394 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7395 | case 0x0A: |
| 7396 | filterPtr = PALMYFilter2; |
| 7397 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7398 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7399 | case 0x0B: |
| 7400 | filterPtr = PALNYFilter2; |
| 7401 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7402 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7403 | case 0x09: |
| 7404 | filterPtr = PALYFilter2; |
| 7405 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7406 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7407 | default: |
| 7408 | return; |
| 7409 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7410 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7411 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7412 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 7413 | VB_StTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7414 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7415 | tempal = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 7416 | VB_ExtTVYFilterIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7417 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7418 | if (tempcl == 0) |
| 7419 | index = tempal * 4; |
| 7420 | else |
| 7421 | index = tempal * 7; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7422 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7423 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7424 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 7425 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 7426 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 7427 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7428 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7429 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 7430 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 7431 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 7432 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7433 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7434 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7435 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7436 | | VB_XGI302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7437 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 7438 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 7439 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7440 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7441 | } |
| 7442 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7443 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7444 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7445 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7446 | /* Output : */ |
| 7447 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7448 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7449 | static void XGI_OEM310Setting(unsigned short ModeNo, |
| 7450 | unsigned short ModeIdIndex, |
| 7451 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7452 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7453 | if (pVBInfo->SetFlag & Win9xDOSMode) |
| 7454 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7455 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7456 | /* GetPart1IO(); */ |
| 7457 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7458 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7459 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
| 7460 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7461 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7462 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 7463 | /* GetPart2IO() */ |
| 7464 | XGI_SetPhaseIncr(pVBInfo); |
| 7465 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); |
| 7466 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7467 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7468 | if (pVBInfo->VBType & VB_XGI301) |
| 7469 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7470 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7471 | } |
| 7472 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7473 | /* --------------------------------------------------------------------- */ |
| 7474 | /* Function : XGI_SetCRT2ModeRegs */ |
| 7475 | /* Input : */ |
| 7476 | /* Output : */ |
| 7477 | /* Description : Origin code for crt2group */ |
| 7478 | /* --------------------------------------------------------------------- */ |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 7479 | void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7480 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7481 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7482 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7483 | unsigned short tempbl; |
| 7484 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7485 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7486 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7487 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7488 | /* // fix write part1 index 0 BTDRAM bit Bug |
| 7489 | * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7490 | tempah = 0; |
| 7491 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7492 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7493 | tempah &= ~0x10; /* BTRAMDAC */ |
| 7494 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7495 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7496 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 7497 | | SetCRT2ToLCD)) { |
| 7498 | tempah = 0x40; /* BTDRAM */ |
| 7499 | if (ModeNo > 0x13) { |
| 7500 | tempcl = pVBInfo->ModeType; |
| 7501 | tempcl -= ModeVGA; |
| 7502 | if (tempcl >= 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7503 | /* BT Color */ |
| 7504 | tempah = (0x008 >> tempcl); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7505 | if (tempah == 0) |
| 7506 | tempah = 1; |
| 7507 | tempah |= 0x040; |
| 7508 | } |
| 7509 | } |
| 7510 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 7511 | tempah ^= 0x50; /* BTDAC */ |
| 7512 | } |
| 7513 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7514 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7515 | /* 0210 shampoo |
| 7516 | if (pVBInfo->VBInfo & DisableCRT2Display) { |
| 7517 | tempah = 0; |
| 7518 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7519 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7520 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7521 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) { |
| 7522 | tempcl = pVBInfo->ModeType; |
| 7523 | if (ModeNo > 0x13) { |
| 7524 | tempcl -= ModeVGA; |
| 7525 | if ((tempcl > 0) || (tempcl == 0)) { |
| 7526 | tempah=(0x008>>tempcl) ; |
| 7527 | if (tempah == 0) |
| 7528 | tempah = 1; |
| 7529 | tempah |= 0x040; |
| 7530 | } |
| 7531 | } else { |
| 7532 | tempah = 0x040; |
| 7533 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7534 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7535 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 7536 | tempah = (tempah ^ 0x050); |
| 7537 | } |
| 7538 | } |
| 7539 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7540 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7541 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7542 | tempah = 0x08; |
| 7543 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7544 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7545 | if (pVBInfo->VBInfo & DisableCRT2Display) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7546 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7547 | } else { |
| 7548 | tempah = 0x00; |
| 7549 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7550 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7551 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 7552 | | SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7553 | if ((pVBInfo->VBInfo & SetCRT2ToLCDA) && |
| 7554 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7555 | tempbl &= 0xf7; |
| 7556 | tempah |= 0x01; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7557 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7558 | tempbl, tempah); |
| 7559 | } else { |
| 7560 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 7561 | tempbl &= 0xf7; |
| 7562 | tempah |= 0x01; |
| 7563 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7564 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7565 | if (pVBInfo->VBInfo & |
| 7566 | (SetCRT2ToRAMDAC | |
| 7567 | SetCRT2ToTV | |
| 7568 | SetCRT2ToLCD)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7569 | tempbl &= 0xf8; |
| 7570 | tempah = 0x01; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7571 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7572 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 7573 | tempah |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7574 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7575 | if (!(pVBInfo->VBInfo & |
| 7576 | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7577 | tempah = tempah ^ 0x05; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7578 | if (!(pVBInfo->VBInfo & |
| 7579 | SetCRT2ToLCD)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7580 | tempah = tempah ^ 0x01; |
| 7581 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7582 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7583 | if (!(pVBInfo->VBInfo & |
| 7584 | SetCRT2ToDualEdge)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7585 | tempah |= 0x08; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7586 | xgifb_reg_and_or(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7587 | 0x2e, tempbl, tempah); |
| 7588 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7589 | xgifb_reg_and_or(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7590 | 0x2e, tempbl, tempah); |
| 7591 | } |
| 7592 | } |
| 7593 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7594 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7595 | tempah); |
| 7596 | } |
| 7597 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7598 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7599 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
| 7600 | | SetCRT2ToLCDA)) { |
| 7601 | tempah &= (~0x08); |
| 7602 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 7603 | & SetInSlaveMode))) { |
| 7604 | tempah |= 0x010; |
| 7605 | } |
| 7606 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7607 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7608 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7609 | /* if (!(pVBInfo->TVInfo & |
| 7610 | (SetYPbPrMode525p | SetYPbPrMode750p))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7611 | tempah |= 0x020; |
| 7612 | if (ModeNo > 0x13) { |
| 7613 | if (pVBInfo->VBInfo & DriverMode) |
| 7614 | tempah = tempah ^ 0x20; |
| 7615 | } |
| 7616 | /* } */ |
| 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->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7620 | tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7621 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7622 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 7623 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7624 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7625 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7626 | /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && |
| 7627 | (!(pVBInfo->TVInfo & |
| 7628 | (SetYPbPrMode525p | SetYPbPrMode750p)))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7629 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 7630 | tempah |= 0x40; |
| 7631 | /* } */ |
| 7632 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7633 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7634 | if ((pVBInfo->LCDResInfo == Panel1280x1024) |
| 7635 | || (pVBInfo->LCDResInfo == Panel1280x1024x75)) |
| 7636 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7637 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7638 | if (pVBInfo->LCDResInfo == Panel1280x960) |
| 7639 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7640 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7641 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7642 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7643 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7644 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7645 | | VB_XGI302LV | VB_XGI301C)) { |
| 7646 | tempah = 0; |
| 7647 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7648 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7649 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 7650 | tempbl = 0xff; |
| 7651 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 7652 | tempah |= 0x04; /* shampoo 0129 */ |
| 7653 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7654 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7655 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7656 | tempah = 0x00; |
| 7657 | tempbl = 0xcf; |
| 7658 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 7659 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 7660 | tempah |= 0x30; |
| 7661 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7662 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7663 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7664 | tempah = 0; |
| 7665 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7666 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7667 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 7668 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 7669 | tempah |= 0xc0; |
| 7670 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7671 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7672 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7673 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7674 | tempah = 0; |
| 7675 | tempbl = 0x7f; |
| 7676 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) { |
| 7677 | tempbl = 0xff; |
| 7678 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 7679 | tempah |= 0x80; |
| 7680 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7681 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7682 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7683 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7684 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 7685 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7686 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 7687 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7688 | } |
| 7689 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7690 | } |
| 7691 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7692 | static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7693 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7694 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7695 | unsigned short tempbx; |
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 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7698 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7699 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 7700 | tempbx = 0x08A0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7701 | |
| 7702 | } |
| 7703 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7704 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 7705 | struct vb_device_info *pVBInfo) |
| 7706 | { |
| 7707 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7708 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7709 | |
| 7710 | } |
| 7711 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7712 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 7713 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7714 | { |
| 7715 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7716 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7717 | |
| 7718 | } |
| 7719 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 7720 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7721 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7722 | unsigned short flag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7723 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7724 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 7725 | return 1; |
| 7726 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7727 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7728 | if ((flag == 1) || (flag == 2)) |
| 7729 | return 1; /* 301b */ |
| 7730 | else |
| 7731 | return 0; |
| 7732 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7733 | } |
| 7734 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 7735 | void XGI_LongWait(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7736 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7737 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7738 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7739 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7740 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7741 | if (!(i & 0xC0)) { |
| 7742 | for (i = 0; i < 0xFFFF; i++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7743 | if (!(inb(pVBInfo->P3da) & 0x08)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7744 | break; |
| 7745 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7746 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7747 | for (i = 0; i < 0xFFFF; i++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7748 | if ((inb(pVBInfo->P3da) & 0x08)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7749 | break; |
| 7750 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7751 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7752 | } |
| 7753 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7754 | static void XGI_VBLongWait(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7755 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7756 | unsigned short tempal, temp, i, j; |
| 7757 | return; |
| 7758 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 7759 | temp = 0; |
| 7760 | for (i = 0; i < 3; i++) { |
| 7761 | for (j = 0; j < 100; j++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7762 | tempal = inb(pVBInfo->P3da); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7763 | if (temp & 0x01) { /* VBWaitMode2 */ |
| 7764 | if ((tempal & 0x08)) |
| 7765 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7766 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7767 | if (!(tempal & 0x08)) |
| 7768 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7769 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7770 | } else { /* VBWaitMode1 */ |
| 7771 | if (!(tempal & 0x08)) |
| 7772 | continue; |
| 7773 | |
| 7774 | if ((tempal & 0x08)) |
| 7775 | break; |
| 7776 | } |
| 7777 | } |
| 7778 | temp = temp ^ 0x01; |
| 7779 | } |
| 7780 | } else { |
| 7781 | XGI_LongWait(pVBInfo); |
| 7782 | } |
| 7783 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7784 | } |
| 7785 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7786 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 7787 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 7788 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7789 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7790 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, |
| 7791 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, |
| 7792 | 0x01, 0x01 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7793 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7794 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7795 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7796 | if (ModeNo <= 0x13) |
| 7797 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 7798 | else |
| 7799 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 7800 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7801 | if (ModeNo < 0x14) |
| 7802 | return 0xFFFF; |
| 7803 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7804 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7805 | index = index >> pVBInfo->SelectCRT2Rate; |
| 7806 | index &= 0x0F; |
| 7807 | |
| 7808 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 7809 | index = 0; |
| 7810 | |
| 7811 | if (index > 0) |
| 7812 | index--; |
| 7813 | |
| 7814 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7815 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 7816 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 7817 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 7818 | | VB_XGI301LV | VB_XGI302LV |
| 7819 | | VB_XGI301C)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7820 | /* 301b */ |
| 7821 | temp = LCDARefreshIndex[ |
| 7822 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7823 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7824 | temp = LCDRefreshIndex[ |
| 7825 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7826 | |
| 7827 | if (index > temp) |
| 7828 | index = temp; |
| 7829 | } else { |
| 7830 | index = 0; |
| 7831 | } |
| 7832 | } |
| 7833 | } |
| 7834 | |
| 7835 | RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex; |
| 7836 | ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID; |
| 7837 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
| 7838 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7839 | if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & |
| 7840 | XG2xNotSupport) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7841 | index++; |
| 7842 | } |
| 7843 | */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7844 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 7845 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7846 | index++; |
| 7847 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7848 | /* Alan 10/19/2007; |
| 7849 | * do the similar adjustment like XGISearchCRT1Rate() */ |
| 7850 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 7851 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7852 | index++; |
| 7853 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7854 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 7855 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7856 | index++; |
| 7857 | } |
| 7858 | } |
| 7859 | |
| 7860 | i = 0; |
| 7861 | do { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7862 | if (pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 7863 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7864 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7865 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 7866 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7867 | temp &= ModeInfoFlag; |
| 7868 | if (temp < pVBInfo->ModeType) |
| 7869 | break; |
| 7870 | i++; |
| 7871 | index--; |
| 7872 | |
| 7873 | } while (index != 0xFFFF); |
| 7874 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 7875 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7876 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1]. |
| 7877 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7878 | if (temp & InterlaceMode) |
| 7879 | i++; |
| 7880 | } |
| 7881 | } |
| 7882 | i--; |
| 7883 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
| 7884 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, |
| 7885 | RefreshRateTableIndex, &i, pVBInfo); |
| 7886 | } |
| 7887 | return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7888 | } |
| 7889 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7890 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7891 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7892 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7893 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7894 | unsigned short RefreshRateTableIndex; |
| 7895 | /* unsigned short temp ; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7896 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7897 | /* pVBInfo->SelectCRT2Rate = 0; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7898 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7899 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7900 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7901 | ModeIdIndex, pVBInfo); |
| 7902 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7903 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7904 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7905 | HwDeviceExtension, pVBInfo); |
| 7906 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7907 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7908 | } |
| 7909 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7910 | unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
| 7911 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7912 | struct vb_device_info *pVBInfo) |
| 7913 | { |
| 7914 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
| 7915 | |
| 7916 | tempbx = pVBInfo->VBInfo; |
| 7917 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7918 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 7919 | pVBInfo->SelectCRT2Rate = 4; |
| 7920 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7921 | ModeIdIndex, pVBInfo); |
| 7922 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
| 7923 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7924 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7925 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7926 | RefreshRateTableIndex, pVBInfo); |
| 7927 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7928 | RefreshRateTableIndex, pVBInfo); |
| 7929 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7930 | RefreshRateTableIndex, pVBInfo); |
| 7931 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7932 | HwDeviceExtension, pVBInfo); |
| 7933 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7934 | RefreshRateTableIndex, pVBInfo); |
| 7935 | XGI_SetTap4Regs(pVBInfo); |
| 7936 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); |
| 7937 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7938 | HwDeviceExtension, pVBInfo); |
| 7939 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7940 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); |
| 7941 | XGI_AutoThreshold(pVBInfo); |
| 7942 | return 1; |
| 7943 | } |
| 7944 | |
| 7945 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 7946 | { |
| 7947 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 7948 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 7949 | 0x05, 0x00 }; |
| 7950 | |
| 7951 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 7952 | |
| 7953 | unsigned char CR17, CR63, SR31; |
| 7954 | unsigned short temp; |
| 7955 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; |
| 7956 | |
| 7957 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7958 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7959 | |
| 7960 | /* [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] | 7961 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7962 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7963 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 7964 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7965 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 7966 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 7967 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7968 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7969 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 7970 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7971 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7972 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7973 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7974 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7975 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7976 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7977 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7978 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7979 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7980 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7981 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7982 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7983 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7984 | |
| 7985 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7986 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7987 | |
| 7988 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7989 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7990 | CRTCData[i]); |
| 7991 | |
| 7992 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7993 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7994 | CRTCData[i]); |
| 7995 | |
| 7996 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7997 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7998 | CRTCData[i]); |
| 7999 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8000 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8001 | & 0xE0)); |
| 8002 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8003 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 8004 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 8005 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8006 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 8007 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8008 | |
| 8009 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 8010 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
| 8011 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); |
| 8012 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8013 | } |
| 8014 | |
| 8015 | XGI_VBLongWait(pVBInfo); |
| 8016 | XGI_VBLongWait(pVBInfo); |
| 8017 | XGI_VBLongWait(pVBInfo); |
| 8018 | |
| 8019 | mdelay(1); |
| 8020 | |
| 8021 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 8022 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8023 | |
| 8024 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 8025 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8026 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 8027 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8028 | |
| 8029 | /* alan, avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 8030 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8031 | |
| 8032 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 8033 | outb(0, (pVBInfo->P3c8 + 1)); |
| 8034 | outb(0, (pVBInfo->P3c8 + 1)); |
| 8035 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8036 | } |
| 8037 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8038 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 8039 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 8040 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8041 | |
| 8042 | /* [2004/05/11] Vicent */ |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8043 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8044 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8045 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8046 | } |
| 8047 | |
| 8048 | void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
| 8049 | struct vb_device_info *pVBInfo) |
| 8050 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 8051 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8052 | |
| 8053 | if (pVBInfo->SetFlag == Win9xDOSMode) { |
| 8054 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 8055 | | VB_XGI302LV | VB_XGI301C)) { |
| 8056 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8057 | return; |
| 8058 | } else |
| 8059 | /* LVDS or CH7017 */ |
| 8060 | return; |
| 8061 | } |
| 8062 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8063 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 8064 | | VB_XGI302LV | VB_XGI301C)) { |
| 8065 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 8066 | if (pVBInfo->SetFlag & EnableChA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8067 | /* Power on */ |
| 8068 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8069 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8070 | /* SetCRT2ToLCDA ) */ |
| 8071 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 8072 | /* Power on */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8073 | xgifb_reg_set(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8074 | 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8075 | } |
| 8076 | } |
| 8077 | } |
| 8078 | |
| 8079 | if (!(pVBInfo->SetFlag & DisableChB)) { |
| 8080 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo |
| 8081 | & (SetCRT2ToLCD | SetCRT2ToTV |
| 8082 | | SetCRT2ToRAMDAC))) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8083 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8084 | pVBInfo->P3c4, 0x32); |
| 8085 | tempah &= 0xDF; |
| 8086 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8087 | if (!(pVBInfo->VBInfo & |
| 8088 | SetCRT2ToRAMDAC)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8089 | tempah |= 0x20; |
| 8090 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8091 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 8092 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8093 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8094 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8095 | pVBInfo->Part1Port, 0x2E); |
| 8096 | |
| 8097 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8098 | /* BVBDOENABLE = 1 */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 8099 | xgifb_reg_or(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8100 | 0x2E, 0x80); |
| 8101 | /* BScreenOFF = 0 */ |
| 8102 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8103 | } |
| 8104 | } |
| 8105 | |
| 8106 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
| 8107 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 8108 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8109 | 0x20); /* shampoo 0129 */ |
| 8110 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 8111 | if (!XGI_DisableChISLCD(pVBInfo)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8112 | if (XGI_EnableChISLCD(pVBInfo) || |
| 8113 | (pVBInfo->VBInfo & |
| 8114 | (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 8115 | /* LVDS PLL power on */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 8116 | xgifb_reg_and( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8117 | pVBInfo->Part4Port, |
| 8118 | 0x2A, |
| 8119 | 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8120 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8121 | /* LVDS Driver power on */ |
| 8122 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8123 | } |
| 8124 | } |
| 8125 | |
| 8126 | tempah = 0x00; |
| 8127 | |
| 8128 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 8129 | tempah = 0xc0; |
| 8130 | |
| 8131 | if (!(pVBInfo->VBInfo & SetSimuScanMode)) { |
| 8132 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8133 | if (pVBInfo->VBInfo & |
| 8134 | SetCRT2ToDualEdge) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8135 | tempah = tempah & 0x40; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8136 | if (pVBInfo->VBInfo & |
| 8137 | SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8138 | tempah = tempah ^ 0xC0; |
| 8139 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8140 | if (pVBInfo->SetFlag & |
| 8141 | DisableChB) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8142 | tempah &= 0xBF; |
| 8143 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8144 | if (pVBInfo->SetFlag & |
| 8145 | DisableChA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8146 | tempah &= 0x7F; |
| 8147 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8148 | if (pVBInfo->SetFlag & |
| 8149 | EnableChB) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8150 | tempah |= 0x40; |
| 8151 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8152 | if (pVBInfo->SetFlag & |
| 8153 | EnableChA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8154 | tempah |= 0x80; |
| 8155 | } |
| 8156 | } |
| 8157 | } |
| 8158 | } |
| 8159 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8160 | /* EnablePart4_1F */ |
| 8161 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8162 | |
| 8163 | if (pVBInfo->SetFlag & Win9xDOSMode) { |
| 8164 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8165 | return; |
| 8166 | } |
| 8167 | |
| 8168 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 8169 | XGI_VBLongWait(pVBInfo); |
| 8170 | if (!(pVBInfo->SetFlag & GatingCRT)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8171 | XGI_DisableGatingCRT(HwDeviceExtension, |
| 8172 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8173 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8174 | XGI_VBLongWait(pVBInfo); |
| 8175 | } |
| 8176 | } |
| 8177 | } /* 301 */ |
| 8178 | else { /* LVDS */ |
| 8179 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
| 8180 | | SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8181 | /* enable CRT2 */ |
| 8182 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8183 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8184 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8185 | 0x2E); |
| 8186 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8187 | /* BVBDOENABLE = 1 */ |
| 8188 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8189 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 8190 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8191 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8192 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8193 | } |
| 8194 | |
| 8195 | static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, |
| 8196 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 8197 | struct vb_device_info *pVBInfo) |
| 8198 | { |
| 8199 | unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp; |
| 8200 | |
| 8201 | unsigned short XGINew_P3cc = pVBInfo->P3cc; |
| 8202 | |
| 8203 | /* XGINew_CRT1Mode = ModeNo; // SaveModeID */ |
| 8204 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
| 8205 | /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */ |
| 8206 | /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */ |
| 8207 | XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); |
| 8208 | XGI_SetMiscRegs(StandTableIndex, pVBInfo); |
| 8209 | XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo); |
| 8210 | XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); |
| 8211 | XGI_SetGRCRegs(StandTableIndex, pVBInfo); |
| 8212 | XGI_ClearExt1Regs(pVBInfo); |
| 8213 | |
| 8214 | /* if (pVBInfo->IF_DEF_ExpLink) */ |
| 8215 | if (HwDeviceExtension->jChipType == XG27) { |
| 8216 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 8217 | XGI_SetDefaultVCLK(pVBInfo); |
| 8218 | } |
| 8219 | |
| 8220 | temp = ~ProgrammingCRT2; |
| 8221 | pVBInfo->SetFlag &= temp; |
| 8222 | pVBInfo->SelectCRT2Rate = 0; |
| 8223 | |
| 8224 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 8225 | | VB_XGI302LV | VB_XGI301C)) { |
| 8226 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA |
| 8227 | | SetInSlaveMode)) { |
| 8228 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 8229 | } |
| 8230 | } |
| 8231 | |
| 8232 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 8233 | ModeIdIndex, pVBInfo); |
| 8234 | if (RefreshRateTableIndex != 0xFFFF) { |
| 8235 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
| 8236 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 8237 | pVBInfo, HwDeviceExtension); |
| 8238 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 8239 | RefreshRateTableIndex, pVBInfo); |
| 8240 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 8241 | HwDeviceExtension, pVBInfo); |
| 8242 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 8243 | RefreshRateTableIndex, pVBInfo); |
| 8244 | } |
| 8245 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8246 | if ((HwDeviceExtension->jChipType >= XG20) && |
| 8247 | (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8248 | if ((ModeNo == 0x00) | (ModeNo == 0x01)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8249 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E); |
| 8250 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 8251 | b3CC = (unsigned char) inb(XGINew_P3cc); |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 8252 | outb((b3CC |= 0x0C), XGINew_P3cc); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8253 | } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo |
| 8254 | == 0x0D)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8255 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 8256 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 8257 | b3CC = (unsigned char) inb(XGINew_P3cc); |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 8258 | outb((b3CC |= 0x0C), XGINew_P3cc); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8259 | } |
| 8260 | } |
| 8261 | |
| 8262 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8263 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8264 | if (temp & 0xA0) { |
| 8265 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8266 | /* Enable write GPIOF */ |
| 8267 | /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */ |
| 8268 | /* P. DWN */ |
| 8269 | /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8270 | /* XG21 CRT1 Timing */ |
| 8271 | if (HwDeviceExtension->jChipType == XG27) |
| 8272 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, |
| 8273 | RefreshRateTableIndex, pVBInfo); |
| 8274 | else |
| 8275 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, |
| 8276 | RefreshRateTableIndex, pVBInfo); |
| 8277 | |
| 8278 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 8279 | RefreshRateTableIndex); |
| 8280 | |
| 8281 | if (HwDeviceExtension->jChipType == XG27) |
| 8282 | XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex, |
| 8283 | ModeNo); |
| 8284 | else |
| 8285 | XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex, |
| 8286 | ModeNo); |
| 8287 | |
| 8288 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 8289 | if (HwDeviceExtension->jChipType == XG27) |
| 8290 | XGI_SetXG27LVDSPara(ModeNo, |
| 8291 | ModeIdIndex, pVBInfo); |
| 8292 | else |
| 8293 | XGI_SetXG21LVDSPara(ModeNo, |
| 8294 | ModeIdIndex, pVBInfo); |
| 8295 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8296 | /* P. ON */ |
| 8297 | /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8298 | } |
| 8299 | } |
| 8300 | |
| 8301 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
| 8302 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); |
| 8303 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 8304 | RefreshRateTableIndex, pVBInfo); |
| 8305 | |
| 8306 | /* XGI_LoadCharacter(); //dif ifdef TVFont */ |
| 8307 | |
| 8308 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
| 8309 | /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */ |
| 8310 | } |
| 8311 | |
| 8312 | unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, |
| 8313 | unsigned short ModeNo) |
| 8314 | { |
| 8315 | unsigned short ModeIdIndex; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8316 | /* unsigned char *pVBInfo->FBAddr = |
| 8317 | HwDeviceExtension->pjVideoMemoryAddress; */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8318 | struct vb_device_info VBINF; |
| 8319 | struct vb_device_info *pVBInfo = &VBINF; |
| 8320 | pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; |
| 8321 | pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; |
| 8322 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8323 | pVBInfo->IF_DEF_LCDA = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8324 | pVBInfo->IF_DEF_VideoCapture = 0; |
| 8325 | pVBInfo->IF_DEF_ScaleLCD = 0; |
| 8326 | pVBInfo->IF_DEF_OEMUtil = 0; |
| 8327 | pVBInfo->IF_DEF_PWD = 0; |
| 8328 | |
| 8329 | if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ |
| 8330 | pVBInfo->IF_DEF_YPbPr = 0; |
| 8331 | pVBInfo->IF_DEF_HiVision = 0; |
| 8332 | pVBInfo->IF_DEF_CRT2Monitor = 0; |
| 8333 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8334 | } else { |
| 8335 | pVBInfo->IF_DEF_YPbPr = 1; |
| 8336 | pVBInfo->IF_DEF_HiVision = 1; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 8337 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8338 | } |
| 8339 | |
| 8340 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; |
| 8341 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; |
| 8342 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; |
| 8343 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; |
| 8344 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; |
| 8345 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; |
| 8346 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; |
| 8347 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; |
| 8348 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; |
| 8349 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; |
| 8350 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; |
| 8351 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; |
| 8352 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; |
| 8353 | pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04; |
| 8354 | pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10; |
| 8355 | pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12; |
| 8356 | pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14; |
| 8357 | pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2; |
| 8358 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8359 | /* for x86 Linux, XG21 LVDS */ |
| 8360 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8361 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8362 | pVBInfo->IF_DEF_LVDS = 1; |
| 8363 | } |
| 8364 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 8365 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 8366 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8367 | pVBInfo->IF_DEF_LVDS = 1; |
| 8368 | } |
| 8369 | } |
| 8370 | |
| 8371 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
| 8372 | XGI_GetVBType(pVBInfo); |
| 8373 | |
| 8374 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
| 8375 | if (ModeNo & 0x80) { |
| 8376 | ModeNo = ModeNo & 0x7F; |
| 8377 | /* XGINew_flag_clearbuffer = 0; */ |
| 8378 | } |
| 8379 | /* else { |
| 8380 | XGINew_flag_clearbuffer = 1; |
| 8381 | } |
| 8382 | */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 8383 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8384 | |
| 8385 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ |
| 8386 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
| 8387 | |
| 8388 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 8389 | |
| 8390 | XGI_GetVGAType(HwDeviceExtension, pVBInfo); |
| 8391 | |
| 8392 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 8393 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 8394 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 8395 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 8396 | XGI_DisableBridge(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8397 | |
| 8398 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { |
| 8399 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, |
| 8400 | ModeIdIndex, pVBInfo); |
| 8401 | |
| 8402 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 8403 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 8404 | HwDeviceExtension, pVBInfo); |
| 8405 | } |
| 8406 | } else { |
| 8407 | if (!(pVBInfo->VBInfo & SwitchToCRT2)) { |
| 8408 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, |
| 8409 | ModeIdIndex, pVBInfo); |
| 8410 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 8411 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 8412 | HwDeviceExtension, |
| 8413 | pVBInfo); |
| 8414 | } |
| 8415 | } |
| 8416 | } |
| 8417 | |
| 8418 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) { |
| 8419 | switch (HwDeviceExtension->ujVBChipID) { |
| 8420 | case VB_CHIP_301: |
| 8421 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 8422 | pVBInfo); /*add for CRT2 */ |
| 8423 | break; |
| 8424 | |
| 8425 | case VB_CHIP_302: |
| 8426 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 8427 | pVBInfo); /*add for CRT2 */ |
| 8428 | break; |
| 8429 | |
| 8430 | default: |
| 8431 | break; |
| 8432 | } |
| 8433 | } |
| 8434 | |
| 8435 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
| 8436 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ |
| 8437 | XGI_CloseCRTC(HwDeviceExtension, pVBInfo); |
| 8438 | XGI_EnableBridge(HwDeviceExtension, pVBInfo); |
| 8439 | } /* !XG20 */ |
| 8440 | else { |
| 8441 | if (pVBInfo->IF_DEF_LVDS == 1) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8442 | if (!XGI_XG21CheckLVDSMode(ModeNo, |
| 8443 | ModeIdIndex, |
| 8444 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8445 | return 0; |
| 8446 | |
| 8447 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8448 | pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 8449 | St_ModeFlag & ModeInfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8450 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8451 | pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 8452 | Ext_ModeFlag & ModeInfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8453 | } |
| 8454 | |
| 8455 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 8456 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8457 | |
| 8458 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 8459 | |
| 8460 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 8461 | pVBInfo); |
| 8462 | |
| 8463 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8464 | /* |
| 8465 | if (HwDeviceExtension->jChipType == XG21) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 8466 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8467 | */ |
| 8468 | } |
| 8469 | |
| 8470 | /* |
| 8471 | if (ModeNo <= 0x13) { |
| 8472 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 8473 | } else { |
| 8474 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 8475 | } |
| 8476 | pVBInfo->ModeType = modeflag&ModeInfoFlag; |
| 8477 | pVBInfo->SetFlag = 0x00; |
| 8478 | pVBInfo->VBInfo = DisableCRT2Display; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8479 | temp = XGINew_CheckMemorySize(HwDeviceExtension, |
| 8480 | ModeNo, |
| 8481 | ModeIdIndex, |
| 8482 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8483 | |
| 8484 | if (temp == 0) |
| 8485 | return (0); |
| 8486 | |
| 8487 | XGI_DisplayOff(HwDeviceExtension, pVBInfo) ; |
| 8488 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); |
| 8489 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8490 | */ |
| 8491 | |
| 8492 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
| 8493 | |
| 8494 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 8495 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
| 8496 | } |
| 8497 | |
| 8498 | return 1; |
| 8499 | } |