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 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 202 | static void XGI_SetSeqRegs(unsigned short ModeNo, |
| 203 | unsigned short StandTableIndex, |
| 204 | unsigned short ModeIdIndex, |
| 205 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 206 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 207 | unsigned char tempah, SRdata; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 208 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 209 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 210 | if (ModeNo <= 0x13) |
| 211 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 212 | else |
| 213 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 214 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 215 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 216 | tempah = pVBInfo->StandTable[StandTableIndex].SR[0]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 217 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 218 | i = SetCRT2ToLCDA; |
| 219 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 220 | tempah |= 0x01; |
| 221 | } else { |
| 222 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { |
| 223 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 224 | tempah |= 0x01; |
| 225 | } |
| 226 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 227 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 228 | tempah |= 0x20; /* screen off */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 229 | xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ |
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 | for (i = 02; i <= 04; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 232 | /* Get SR2,3,4 from file */ |
| 233 | SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 234 | xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 235 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 236 | } |
| 237 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 238 | static void XGI_SetMiscRegs(unsigned short StandTableIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 239 | struct vb_device_info *pVBInfo) |
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 | unsigned char Miscdata; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 242 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 243 | /* Get Misc from file */ |
| 244 | Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 245 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 246 | if (pVBInfo->VBType & (VB_XGI301B | |
| 247 | VB_XGI302B | |
| 248 | VB_XGI301LV | |
| 249 | VB_XGI302LV | |
| 250 | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 251 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 252 | Miscdata |= 0x0C; |
| 253 | } |
| 254 | } |
| 255 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 256 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 257 | outb(Miscdata, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 258 | } |
| 259 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 260 | static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 261 | unsigned short StandTableIndex, |
| 262 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 263 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 264 | unsigned char CRTCdata; |
| 265 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 266 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 267 | CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 268 | CRTCdata &= 0x7f; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 269 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 270 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 271 | for (i = 0; i <= 0x18; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 272 | /* Get CRTC from file */ |
| 273 | CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 274 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 275 | } |
| 276 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 277 | if ((HwDeviceExtension->jChipType == XGI_630) && |
| 278 | (HwDeviceExtension->jChipRevision == 0x30)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 279 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 280 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 281 | xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | } |
| 285 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 286 | } |
| 287 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 288 | static void XGI_SetATTRegs(unsigned short ModeNo, |
| 289 | unsigned short StandTableIndex, |
| 290 | unsigned short ModeIdIndex, |
| 291 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 292 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 293 | unsigned char ARdata; |
| 294 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 295 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 296 | if (ModeNo <= 0x13) |
| 297 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 298 | else |
| 299 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 300 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 301 | for (i = 0; i <= 0x13; i++) { |
| 302 | ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i]; |
| 303 | if (modeflag & Charx8Dot) { /* ifndef Dot9 */ |
| 304 | if (i == 0x13) { |
| 305 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 306 | ARdata = 0; |
| 307 | } else { |
| 308 | if (pVBInfo->VBInfo & (SetCRT2ToTV |
| 309 | | SetCRT2ToLCD)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 310 | if (pVBInfo->VBInfo & |
| 311 | SetInSlaveMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 312 | ARdata = 0; |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 317 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 318 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 319 | outb(i, pVBInfo->P3c0); /* set index */ |
| 320 | outb(ARdata, pVBInfo->P3c0); /* set data */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 321 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 322 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 323 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 324 | outb(0x14, pVBInfo->P3c0); /* set index */ |
| 325 | outb(0x00, pVBInfo->P3c0); /* set data */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 326 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 327 | outb(0x20, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 328 | } |
| 329 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 330 | static void XGI_SetGRCRegs(unsigned short StandTableIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 331 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 332 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 333 | unsigned char GRdata; |
| 334 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 335 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 336 | for (i = 0; i <= 0x08; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 337 | /* Get GR from file */ |
| 338 | GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 339 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 340 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 341 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 342 | if (pVBInfo->ModeType > ModeVGA) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 343 | GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 344 | GRdata &= 0xBF; /* 256 color disable */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 345 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 346 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 347 | } |
| 348 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 349 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 350 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 351 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 352 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 353 | for (i = 0x0A; i <= 0x0E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 354 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 355 | } |
| 356 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 357 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 358 | { |
| 359 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 360 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 361 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B); |
| 362 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 363 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 364 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 365 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B); |
| 366 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 367 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 368 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 369 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 370 | } |
| 371 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 372 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 373 | unsigned short ModeIdIndex, |
| 374 | unsigned short RefreshRateTableIndex, unsigned short *i, |
| 375 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 376 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 377 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 378 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 379 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 380 | /* si+St_ModeFlag */ |
| 381 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 382 | else |
| 383 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 384 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 385 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 386 | tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID; |
| 387 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 388 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 389 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 390 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 391 | tempax |= SupportRAMDAC2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 392 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 393 | if (pVBInfo->VBType & VB_XGI301C) |
| 394 | tempax |= SupportCRT2in301C; |
| 395 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 396 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 397 | /* 301b */ |
| 398 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 399 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 400 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 401 | if (pVBInfo->LCDResInfo != Panel1280x1024) { |
| 402 | if (pVBInfo->LCDResInfo != Panel1280x960) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 403 | if (pVBInfo->LCDInfo & |
| 404 | LCDNonExpanding) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 405 | if (resinfo >= 9) { |
| 406 | tempax = 0; |
| 407 | return 0; |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | } |
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->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 415 | if ((pVBInfo->VBType & VB_XGI301LV) && |
| 416 | (pVBInfo->VBExtInfo == VB_YPbPr1080i)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 417 | tempax |= SupportYPbPr; |
| 418 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 419 | if (resinfo == 4) |
| 420 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 421 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 422 | if (resinfo == 3) |
| 423 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 424 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 425 | if (resinfo > 7) |
| 426 | return 0; |
| 427 | } |
| 428 | } else { |
| 429 | tempax |= SupportHiVisionTV; |
| 430 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 431 | if (resinfo == 4) |
| 432 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 433 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 434 | if (resinfo == 3) { |
| 435 | if (pVBInfo->SetFlag |
| 436 | & TVSimuMode) |
| 437 | return 0; |
| 438 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 439 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 440 | if (resinfo > 7) |
| 441 | return 0; |
| 442 | } |
| 443 | } |
| 444 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 445 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
| 446 | SetCRT2ToSVIDEO | |
| 447 | SetCRT2ToSCART | |
| 448 | SetCRT2ToYPbPr | |
| 449 | SetCRT2ToHiVisionTV)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 450 | tempax |= SupportTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 451 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 452 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 453 | | VB_XGI301LV | VB_XGI302LV |
| 454 | | VB_XGI301C)) { |
| 455 | tempax |= SupportTV1024; |
| 456 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 457 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 458 | if (!(pVBInfo->VBInfo & SetPALTV)) { |
| 459 | if (modeflag & NoSupportSimuTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 460 | if (pVBInfo->VBInfo & |
| 461 | SetInSlaveMode) { |
| 462 | if (!(pVBInfo->VBInfo & |
| 463 | SetNotSimuMode)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 464 | return 0; |
| 465 | } |
| 466 | } |
| 467 | } |
| 468 | } |
| 469 | } |
| 470 | } |
| 471 | } else { /* for LVDS */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 472 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 473 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 474 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 475 | if (resinfo > 0x08) |
| 476 | return 0; /* 1024x768 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 477 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 478 | if (pVBInfo->LCDResInfo < Panel1024x768) { |
| 479 | if (resinfo > 0x07) |
| 480 | return 0; /* 800x600 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 481 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 482 | if (resinfo == 0x04) |
| 483 | return 0; /* 512x384 */ |
| 484 | } |
| 485 | } |
| 486 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 487 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 488 | for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
| 489 | tempbx; (*i)--) { |
| 490 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
| 491 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 492 | if (infoflag & tempax) |
| 493 | return 1; |
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 ((*i) == 0) |
| 496 | break; |
| 497 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 498 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 499 | for ((*i) = 0;; (*i)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 500 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
| 501 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 502 | if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID |
| 503 | != tempbx) { |
| 504 | return 0; |
| 505 | } |
| 506 | |
| 507 | if (infoflag & tempax) |
| 508 | return 1; |
| 509 | } |
| 510 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 511 | } |
| 512 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 513 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 514 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 515 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 516 | unsigned short sync, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 517 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 518 | /* di+0x00 */ |
| 519 | sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 520 | sync &= 0xC0; |
| 521 | temp = 0x2F; |
| 522 | temp |= sync; |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 523 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
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_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 527 | struct xgi_hw_device_info *HwDeviceExtension) |
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 char data, data1, pushax; |
| 530 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 531 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 532 | /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */ |
| 533 | /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 534 | /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 535 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 536 | /* unlock cr0-7 */ |
| 537 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 538 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 539 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 540 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 541 | data = pVBInfo->TimingH[0].data[0]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 542 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 543 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 544 | for (i = 0x01; i <= 0x04; i++) { |
| 545 | data = pVBInfo->TimingH[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 546 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 547 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 548 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 549 | for (i = 0x05; i <= 0x06; i++) { |
| 550 | data = pVBInfo->TimingH[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 551 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 552 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 553 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 554 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 555 | j &= 0x1F; |
| 556 | data = pVBInfo->TimingH[0].data[7]; |
| 557 | data &= 0xE0; |
| 558 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 559 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 560 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 561 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 562 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 563 | data = data - 1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 564 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 565 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 566 | data1 = data; |
| 567 | data1 &= 0xE0; |
| 568 | data &= 0x1F; |
| 569 | if (data == 0) { |
| 570 | pushax = data; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 571 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 572 | 0x0c); |
| 573 | data &= 0xFB; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 574 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 575 | data = pushax; |
| 576 | } |
| 577 | data = data - 1; |
| 578 | data |= data1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 579 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 580 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 581 | data = data >> 5; |
| 582 | data = data + 3; |
| 583 | if (data > 7) |
| 584 | data = data - 7; |
| 585 | data = data << 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 586 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 587 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 588 | } |
| 589 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 590 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
| 591 | unsigned short ModeNo, |
| 592 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 593 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 594 | unsigned char data; |
| 595 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 596 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 597 | /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */ |
| 598 | /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 599 | /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 600 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 601 | for (i = 0x00; i <= 0x01; i++) { |
| 602 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 603 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 604 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 605 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 606 | for (i = 0x02; i <= 0x03; i++) { |
| 607 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 608 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 609 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 610 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 611 | for (i = 0x04; i <= 0x05; i++) { |
| 612 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 613 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 614 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 615 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 616 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 617 | j &= 0xC0; |
| 618 | data = pVBInfo->TimingV[0].data[6]; |
| 619 | data &= 0x3F; |
| 620 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 621 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 622 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 623 | data = pVBInfo->TimingV[0].data[6]; |
| 624 | data &= 0x80; |
| 625 | data = data >> 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 626 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 627 | if (ModeNo <= 0x13) |
| 628 | i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 629 | else |
| 630 | i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 631 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 632 | i &= DoubleScanMode; |
| 633 | if (i) |
| 634 | data |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 635 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 636 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 637 | j &= 0x5F; |
| 638 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 639 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 640 | } |
| 641 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 642 | static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 643 | unsigned short RefreshRateTableIndex, |
| 644 | struct vb_device_info *pVBInfo, |
| 645 | struct xgi_hw_device_info *HwDeviceExtension) |
| 646 | { |
| 647 | unsigned char index, data; |
| 648 | unsigned short i; |
| 649 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 650 | /* Get index */ |
| 651 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 652 | index = index & IndexMask; |
| 653 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 654 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 655 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 656 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 657 | |
| 658 | for (i = 0; i < 8; i++) |
| 659 | pVBInfo->TimingH[0].data[i] |
| 660 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i]; |
| 661 | |
| 662 | for (i = 0; i < 7; i++) |
| 663 | pVBInfo->TimingV[0].data[i] |
| 664 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8]; |
| 665 | |
| 666 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 667 | |
| 668 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
| 669 | |
| 670 | if (pVBInfo->ModeType > 0x03) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 671 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 672 | } |
| 673 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 674 | /* --------------------------------------------------------------------- */ |
| 675 | /* Function : XGI_SetXG21CRTC */ |
| 676 | /* Input : Stand or enhance CRTC table */ |
| 677 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ |
| 678 | /* Description : Set LCD timing */ |
| 679 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 680 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 681 | unsigned short RefreshRateTableIndex, |
| 682 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 683 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 684 | unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
| 685 | unsigned short Temp1, Temp2, Temp3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 686 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 687 | if (ModeNo <= 0x13) { |
| 688 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 689 | /* CR04 HRS */ |
| 690 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; |
| 691 | /* SR2E [7:0]->HRS */ |
| 692 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
| 693 | /* Tempbx: CR05 HRE */ |
| 694 | Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 695 | Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */ |
| 696 | Tempcx = Tempax; |
| 697 | Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */ |
| 698 | Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */ |
| 699 | if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */ |
| 700 | Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */ |
| 701 | Tempdx <<= 2; /* Tempdx << 2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 702 | /* SR2F [7:2]->HRE */ |
| 703 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 704 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 705 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 706 | /* Tempax: CR16 VRS */ |
| 707 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 708 | Tempbx = Tempax; /* Tempbx=Tempax */ |
| 709 | Tempax &= 0x01; /* Tempax: VRS[0] */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 710 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 711 | |
| 712 | /* Tempax: CR7 VRS */ |
| 713 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 714 | Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */ |
| 715 | Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */ |
| 716 | Tempcx <<= 5; /* Tempcx[7]: VRS[8] */ |
| 717 | Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 718 | /* SR34[7:0]: VRS[8:1] */ |
| 719 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 720 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 721 | /* Temp1[8]: VRS[8] unsigned char -> unsigned short */ |
| 722 | Temp1 = Tempcx << 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 723 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 724 | Tempax &= 0x80; /* Tempax[7]: CR7[7] */ |
| 725 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 726 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 727 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 728 | /* CR16 VRE */ |
| 729 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 730 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 731 | Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */ |
| 732 | Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */ |
| 733 | Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */ |
| 734 | if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */ |
| 735 | Temp2 |= 0x10; /* Temp2: VRE + 0x10 */ |
| 736 | Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */ |
| 737 | Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */ |
| 738 | Tempax <<= 2; /* Tempax << 2: VRE[5:0] */ |
| 739 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 740 | Temp1 >>= 9; /* [10:9]->[1:0] */ |
| 741 | Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */ |
| 742 | Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */ |
| 743 | Tempax &= 0x7F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 744 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 745 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 746 | } else { |
| 747 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 748 | /* Tempax: CR4 HRS */ |
| 749 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 750 | Tempcx = Tempax; /* Tempcx: HRS */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 751 | /* SR2E[7:0]->HRS */ |
| 752 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 753 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 754 | Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */ |
| 755 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ |
| 756 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ |
| 757 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ |
| 758 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 759 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 760 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
| 761 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 762 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 763 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
| 764 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ |
| 765 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ |
| 766 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 767 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 768 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
| 769 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 770 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 771 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
| 772 | if (Tempax < Tempcx) /* HRE < HRS */ |
| 773 | Temp2 |= 0x40; /* Temp2 + 0x40 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 774 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 775 | Temp2 &= 0xFF; |
| 776 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ |
| 777 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ |
| 778 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ |
| 779 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 780 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
| 781 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 782 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 783 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 784 | /* CR10 VRS */ |
| 785 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 786 | Tempbx = Tempax; /* Tempbx: VRS */ |
| 787 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 788 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 789 | /* CR7[2][7] VRE */ |
| 790 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 791 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
| 792 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ |
| 793 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ |
| 794 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 795 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 796 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 797 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
| 798 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ |
| 799 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 800 | Tempax &= 0x80; |
| 801 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 802 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 803 | /* Tempax: SRA */ |
| 804 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 805 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
| 806 | Temp2 = Tempax; |
| 807 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ |
| 808 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 809 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 810 | /* Tempax: CR11 VRE */ |
| 811 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 812 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 813 | /* Tempbx: SRA */ |
| 814 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 815 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
| 816 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 817 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 818 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ |
| 819 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 820 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 821 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
| 822 | if (Tempax < Temp3) /* VRE < VRS */ |
| 823 | Temp2 |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 824 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 825 | Temp2 &= 0xFF; |
| 826 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ |
| 827 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ |
| 828 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 829 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ |
| 830 | Tempbx = (unsigned char) Temp1; |
| 831 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ |
| 832 | Tempax &= 0x7F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 833 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 834 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 835 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 836 | } |
| 837 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 838 | static void XGI_SetXG27CRTC(unsigned short ModeNo, |
| 839 | unsigned short ModeIdIndex, |
| 840 | unsigned short RefreshRateTableIndex, |
| 841 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 842 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 843 | unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 844 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 845 | if (ModeNo <= 0x13) { |
| 846 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 847 | /* CR04 HRS */ |
| 848 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; |
| 849 | /* SR2E [7:0]->HRS */ |
| 850 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
| 851 | /* Tempbx: CR05 HRE */ |
| 852 | Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 853 | Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */ |
| 854 | Tempcx = Tempax; |
| 855 | Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */ |
| 856 | Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */ |
| 857 | if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */ |
| 858 | Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */ |
| 859 | Tempdx <<= 2; /* Tempdx << 2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 860 | /* SR2F [7:2]->HRE */ |
| 861 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 862 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 863 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 864 | /* Tempax: CR10 VRS */ |
| 865 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 866 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 867 | Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 868 | /* Tempax[7][2]: CR7[7][2] VRS[9][8] */ |
| 869 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 870 | Tempbx = Tempax; /* Tempbx=CR07 */ |
| 871 | Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */ |
| 872 | Tempax >>= 2; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 873 | /* SR35 D[0]->VRS D[8] */ |
| 874 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 875 | Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */ |
| 876 | Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 877 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 878 | /* CR11 VRE */ |
| 879 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 880 | Tempax &= 0x0F; /* Tempax: VRE[3:0] */ |
| 881 | Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */ |
| 882 | Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */ |
| 883 | Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */ |
| 884 | if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */ |
| 885 | Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 886 | /* Tempax[7:0]: VRE[7:0] */ |
| 887 | Tempax = (unsigned char) Tempbx & 0xFF; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 888 | Tempax <<= 2; /* Tempax << 2: VRE[5:0] */ |
| 889 | Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 890 | /* SR3F D[7:2]->VRE D[5:0] */ |
| 891 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
| 892 | /* SR35 D[2:1]->VRS[10:9] */ |
| 893 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 894 | } else { |
| 895 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 896 | /* Tempax: CR4 HRS */ |
| 897 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 898 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 899 | /* SR2E[7:0]->HRS */ |
| 900 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 901 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 902 | /* SR0B */ |
| 903 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 904 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 905 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 906 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 907 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
| 908 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
| 909 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 910 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 911 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
| 912 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ |
| 913 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ |
| 914 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 915 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 916 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
| 917 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 918 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 919 | /* Tempax: CR4 HRS */ |
| 920 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 921 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
| 922 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ |
| 923 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 924 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 925 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */ |
| 926 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 927 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ |
| 928 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 929 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
| 930 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 931 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 932 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 933 | /* CR10 VRS */ |
| 934 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; |
| 935 | /* SR34[7:0]->VRS[7:0] */ |
| 936 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); |
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 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 939 | /* CR7[7][2] VRS[9][8] */ |
| 940 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 941 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
| 942 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ |
| 943 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 944 | /* SR35[0]: VRS[8] */ |
| 945 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 946 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
| 947 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 948 | /* Tempax: SR0A */ |
| 949 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 950 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
| 951 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 952 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 953 | /* Tempax: CR11 VRE */ |
| 954 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 955 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 956 | /* Tempbx: SR0A */ |
| 957 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 958 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
| 959 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 960 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 961 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ |
| 962 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ |
| 963 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 964 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 965 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
| 966 | Tempbx |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 967 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 968 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
| 969 | Tempax = (Tempbx << 2) & 0xFF; |
| 970 | /* SR3F[7:2]:VRE[5:0] */ |
| 971 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 972 | Tempax = Tempcx >> 8; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 973 | /* SR35[2:0]:VRS[10:8] */ |
| 974 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 975 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 976 | } |
| 977 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 978 | static void xgifb_set_lcd(int chip_id, |
| 979 | struct vb_device_info *pVBInfo, |
| 980 | unsigned short RefreshRateTableIndex, |
| 981 | unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 982 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 983 | unsigned short Data, Temp, b3CC; |
| 984 | unsigned short XGI_P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 985 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 986 | XGI_P3cc = pVBInfo->P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 987 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 988 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 989 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 990 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 991 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 992 | |
| 993 | if (chip_id == XG27) { |
| 994 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 995 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
| 996 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 997 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
| 998 | } |
| 999 | } |
| 1000 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1001 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1002 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); |
| 1003 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); |
| 1004 | xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); |
| 1005 | xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1006 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1007 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 1008 | if (chip_id == XG27) { |
| 1009 | XGI_SetXG27FPBits(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1010 | } else { |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 1011 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 1012 | if (Temp & 0x01) { |
| 1013 | /* 18 bits FP */ |
| 1014 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); |
| 1015 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
| 1016 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1017 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1018 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1019 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1020 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 1021 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 1022 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1023 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1024 | if (ModeNo <= 0x13) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1025 | b3CC = (unsigned char) inb(XGI_P3cc); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1026 | if (b3CC & 0x40) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1027 | /* Hsync polarity */ |
| 1028 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1029 | if (b3CC & 0x80) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1030 | /* Vsync polarity */ |
| 1031 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1032 | } else { |
| 1033 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1034 | if (Data & 0x4000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1035 | /* Hsync polarity */ |
| 1036 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1037 | if (Data & 0x8000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1038 | /* Vsync polarity */ |
| 1039 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1040 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | /* --------------------------------------------------------------------- */ |
| 1044 | /* Function : XGI_UpdateXG21CRTC */ |
| 1045 | /* Input : */ |
| 1046 | /* Output : CRT1 CRTC */ |
| 1047 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 1048 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1049 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 1050 | struct vb_device_info *pVBInfo, |
| 1051 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1052 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1053 | int i, index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1054 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 1055 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1056 | if (ModeNo <= 0x13) { |
| 1057 | for (i = 0; i < 12; i++) { |
| 1058 | if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID) |
| 1059 | index = i; |
| 1060 | } |
| 1061 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1062 | if (ModeNo == 0x2E && |
| 1063 | (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
| 1064 | RES640x480x60)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1065 | index = 12; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1066 | else if (ModeNo == 0x2E && |
| 1067 | (pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1068 | Ext_CRT1CRTC == RES640x480x72)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1069 | index = 13; |
| 1070 | else if (ModeNo == 0x2F) |
| 1071 | index = 14; |
| 1072 | else if (ModeNo == 0x50) |
| 1073 | index = 15; |
| 1074 | else if (ModeNo == 0x59) |
| 1075 | index = 16; |
| 1076 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1077 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1078 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1079 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1080 | pVBInfo->UpdateCRT1[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1081 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1082 | pVBInfo->UpdateCRT1[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1083 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1084 | pVBInfo->UpdateCRT1[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1085 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1086 | pVBInfo->UpdateCRT1[index].CR16); |
| 1087 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1088 | } |
| 1089 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1090 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1091 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1092 | unsigned short RefreshRateTableIndex, |
| 1093 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1094 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1095 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1096 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1097 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1098 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1099 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1100 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1101 | if (ModeNo <= 0x13) { |
| 1102 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1103 | tempax = pVBInfo->StResInfo[resindex].HTotal; |
| 1104 | tempbx = pVBInfo->StResInfo[resindex].VTotal; |
| 1105 | } else { |
| 1106 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1107 | tempax = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1108 | tempbx = pVBInfo->ModeResInfo[resindex].VTotal; |
| 1109 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1110 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1111 | if (modeflag & HalfDCLK) |
| 1112 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1113 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1114 | if (ModeNo > 0x13) { |
| 1115 | if (modeflag & HalfDCLK) |
| 1116 | tempax = tempax << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1117 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1118 | temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1119 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1120 | if (temp & InterlaceMode) |
| 1121 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1122 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1123 | if (modeflag & DoubleScanMode) |
| 1124 | tempbx = tempbx << 1; |
| 1125 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1126 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1127 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1128 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1129 | /* if (!(modeflag & Charx8Dot)) */ |
| 1130 | /* tempcx = 9; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1131 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1132 | tempax /= tempcx; |
| 1133 | tempax -= 1; |
| 1134 | tempbx -= 1; |
| 1135 | tempcx = tempax; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1136 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 1137 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1138 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1139 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 1140 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1141 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1142 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1143 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1144 | tempax = 0; |
| 1145 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1146 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1147 | if (tempbx & 0x01) |
| 1148 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1149 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1150 | if (tempbx & 0x02) |
| 1151 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1152 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1153 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1154 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1155 | data &= 0xFF; |
| 1156 | tempax = 0; |
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 (tempbx & 0x04) |
| 1159 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1160 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1161 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1162 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1163 | } |
| 1164 | |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1165 | unsigned short XGI_GetResInfo(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1166 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1167 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1168 | unsigned short resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1169 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1170 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1171 | /* si+St_ResInfo */ |
| 1172 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1173 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1174 | /* si+Ext_ResInfo */ |
| 1175 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1176 | return resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1177 | } |
| 1178 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1179 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 1180 | unsigned short ModeIdIndex, |
| 1181 | unsigned short RefreshRateTableIndex, |
| 1182 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1183 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1184 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1185 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1186 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1187 | /* GetOffset */ |
| 1188 | temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 1189 | temp = temp >> 8; |
| 1190 | temp = pVBInfo->ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1191 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1192 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1193 | temp2 &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1194 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1195 | if (temp2) |
| 1196 | temp = temp << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1197 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1198 | temp2 = pVBInfo->ModeType - ModeEGA; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1199 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1200 | switch (temp2) { |
| 1201 | case 0: |
| 1202 | temp2 = 1; |
| 1203 | break; |
| 1204 | case 1: |
| 1205 | temp2 = 2; |
| 1206 | break; |
| 1207 | case 2: |
| 1208 | temp2 = 4; |
| 1209 | break; |
| 1210 | case 3: |
| 1211 | temp2 = 4; |
| 1212 | break; |
| 1213 | case 4: |
| 1214 | temp2 = 6; |
| 1215 | break; |
| 1216 | case 5: |
| 1217 | temp2 = 8; |
| 1218 | break; |
| 1219 | default: |
| 1220 | break; |
| 1221 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1222 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1223 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 1224 | temp = temp * temp2 + temp2 / 2; |
| 1225 | else |
| 1226 | temp *= temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1227 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1228 | /* SetOffset */ |
| 1229 | DisplayUnit = temp; |
| 1230 | temp2 = temp; |
| 1231 | temp = temp >> 8; /* ah */ |
| 1232 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1233 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1234 | i &= 0xF0; |
| 1235 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1236 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1237 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1238 | temp = (unsigned char) temp2; |
| 1239 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1240 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
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 | /* SetDisplayUnit */ |
| 1243 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1244 | temp2 &= InterlaceMode; |
| 1245 | if (temp2) |
| 1246 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1247 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1248 | DisplayUnit = DisplayUnit << 5; |
| 1249 | ah = (DisplayUnit & 0xff00) >> 8; |
| 1250 | al = DisplayUnit & 0x00ff; |
| 1251 | if (al == 0) |
| 1252 | ah += 1; |
| 1253 | else |
| 1254 | ah += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1255 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1256 | if (HwDeviceExtension->jChipType >= XG20) |
| 1257 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 1258 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1259 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1260 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1261 | } |
| 1262 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1263 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
| 1264 | unsigned short ModeIdIndex, |
| 1265 | unsigned short RefreshRateTableIndex, |
| 1266 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1267 | struct vb_device_info *pVBInfo) |
| 1268 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1269 | unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, |
| 1270 | VCLK65 + 2, |
| 1271 | VCLK65 + 2, |
| 1272 | VCLK65 + 2 }; |
| 1273 | unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, |
| 1274 | VCLK108_2 + 5, |
| 1275 | VCLK108_2 + 5, |
| 1276 | VCLK108_2 + 5 }; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1277 | unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 }; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1278 | unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, |
| 1279 | VCLK65 + 2, |
| 1280 | VCLK65 + 2, |
| 1281 | VCLK65 + 2 }; |
| 1282 | unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, |
| 1283 | VCLK65 + 2, |
| 1284 | VCLK65 + 2, |
| 1285 | VCLK65 + 2 }; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1286 | |
| 1287 | unsigned short CRT2Index, VCLKIndex; |
| 1288 | unsigned short modeflag, resinfo; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1289 | |
| 1290 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1291 | /* si+St_ResInfo */ |
| 1292 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1293 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 1294 | CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 1295 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1296 | /* si+Ext_ResInfo */ |
| 1297 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1298 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1299 | CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1300 | Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1301 | } |
| 1302 | |
| 1303 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 1304 | CRT2Index = CRT2Index >> 6; /* for LCD */ |
| 1305 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/ |
| 1306 | if (pVBInfo->LCDResInfo != Panel1024x768) |
| 1307 | VCLKIndex = LCDXlat2VCLK[CRT2Index]; |
| 1308 | else |
| 1309 | VCLKIndex = LCDXlat1VCLK[CRT2Index]; |
| 1310 | } else { /* for TV */ |
| 1311 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 1312 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 1313 | if (pVBInfo->SetFlag & RPLLDIV2XO) { |
| 1314 | VCLKIndex = HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1315 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1316 | } else { |
| 1317 | VCLKIndex = HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1318 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1319 | } |
| 1320 | |
| 1321 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 1322 | if (modeflag & Charx8Dot) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1323 | VCLKIndex = |
| 1324 | HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1325 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1326 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1327 | VCLKIndex = |
| 1328 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1329 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1330 | } |
| 1331 | } |
| 1332 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1333 | /* 301lv */ |
| 1334 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 1335 | if (!(pVBInfo->VBExtInfo == |
| 1336 | VB_YPbPr1080i)) { |
| 1337 | VCLKIndex = |
| 1338 | YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1339 | if (!(pVBInfo->VBExtInfo |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1340 | == |
| 1341 | VB_YPbPr750p)) { |
| 1342 | VCLKIndex = |
| 1343 | YPbPr525pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1344 | if (!(pVBInfo->VBExtInfo |
| 1345 | == VB_YPbPr525p)) { |
| 1346 | VCLKIndex |
| 1347 | = YPbPr525iVCLK_2; |
| 1348 | if (!(pVBInfo->SetFlag |
| 1349 | & RPLLDIV2XO)) |
| 1350 | VCLKIndex |
| 1351 | = YPbPr525iVCLK; |
| 1352 | } |
| 1353 | } |
| 1354 | } |
| 1355 | } |
| 1356 | } else { |
| 1357 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1358 | if (pVBInfo->SetFlag & |
| 1359 | RPLLDIV2XO) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1360 | VCLKIndex = TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1361 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1362 | } else { |
| 1363 | VCLKIndex = TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1364 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1365 | } |
| 1366 | } |
| 1367 | } |
| 1368 | } else { /* for CRT2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1369 | /* Port 3cch */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1370 | VCLKIndex = (unsigned char) inb( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1371 | (pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1372 | VCLKIndex = ((VCLKIndex >> 2) & 0x03); |
| 1373 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1374 | /* di+Ext_CRTVCLK */ |
| 1375 | VCLKIndex = |
| 1376 | pVBInfo->RefIndex[ |
| 1377 | RefreshRateTableIndex]. |
| 1378 | Ext_CRTVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1379 | VCLKIndex &= IndexMask; |
| 1380 | } |
| 1381 | } |
| 1382 | } |
| 1383 | } else { /* LVDS */ |
| 1384 | if (ModeNo <= 0x13) |
| 1385 | VCLKIndex = CRT2Index; |
| 1386 | else |
| 1387 | VCLKIndex = CRT2Index; |
| 1388 | |
Aaro Koskinen | 4c14bfd | 2011-08-31 21:45:57 +0300 | [diff] [blame] | 1389 | VCLKIndex = VCLKIndex >> 6; |
| 1390 | if ((pVBInfo->LCDResInfo == Panel800x600) || |
| 1391 | (pVBInfo->LCDResInfo == Panel320x480)) |
| 1392 | VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; |
| 1393 | else if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 1394 | (pVBInfo->LCDResInfo == Panel1024x768x75)) |
| 1395 | VCLKIndex = LVDSXlat2VCLK[VCLKIndex]; |
| 1396 | else |
| 1397 | VCLKIndex = LVDSXlat3VCLK[VCLKIndex]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1398 | } |
| 1399 | /* VCLKIndex = VCLKIndex&IndexMask; */ |
| 1400 | |
| 1401 | return VCLKIndex; |
| 1402 | } |
| 1403 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1404 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
| 1405 | unsigned short ModeIdIndex, |
| 1406 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1407 | unsigned short RefreshRateTableIndex, |
| 1408 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1409 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 1410 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1411 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1412 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1413 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 1414 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1415 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1416 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1417 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1418 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1419 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1420 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1421 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1422 | } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 1423 | | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo |
| 1424 | & SetCRT2ToLCDA)) { |
| 1425 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, |
| 1426 | RefreshRateTableIndex, HwDeviceExtension, |
| 1427 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1428 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1429 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1430 | data = pVBInfo->VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1431 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1432 | data = pVBInfo->VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1433 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 1434 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1435 | } else { |
| 1436 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1437 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1438 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1439 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1440 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1441 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1442 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1443 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1444 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1445 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1446 | if (HwDeviceExtension->jChipType >= XG20) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1447 | if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
| 1448 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1449 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1450 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1451 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1452 | index = data; |
| 1453 | index &= 0xE0; |
| 1454 | data &= 0x1F; |
| 1455 | data = data << 1; |
| 1456 | data += 1; |
| 1457 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1458 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1459 | } |
| 1460 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1461 | } |
| 1462 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1463 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1464 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1465 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1466 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1467 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1468 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1469 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1470 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1471 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1472 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1473 | if (ModeNo > 0x13) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1474 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1475 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1476 | data &= 0xC0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1477 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1478 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1479 | data |= 0x01; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1480 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1481 | } else { |
| 1482 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1483 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1484 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1485 | data &= 0xC0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1486 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1487 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1488 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1489 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1490 | data &= 0xF0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1491 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1492 | } |
| 1493 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1494 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1495 | if (HwDeviceExtension->jChipType == XG21) |
| 1496 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1497 | } |
| 1498 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1499 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
| 1500 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, |
| 1501 | struct vb_device_info *pVBInfo) |
| 1502 | { |
| 1503 | unsigned short data, data2 = 0; |
| 1504 | short VCLK; |
| 1505 | |
| 1506 | unsigned char index; |
| 1507 | |
| 1508 | if (ModeNo <= 0x13) |
| 1509 | VCLK = 0; |
| 1510 | else { |
| 1511 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 1512 | index &= IndexMask; |
| 1513 | VCLK = pVBInfo->VCLKData[index].CLOCK; |
| 1514 | } |
| 1515 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1516 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1517 | data &= 0xf3; |
| 1518 | if (VCLK >= 200) |
| 1519 | data |= 0x0c; /* VCLK > 200 */ |
| 1520 | |
| 1521 | if (HwDeviceExtension->jChipType >= XG20) |
| 1522 | data &= ~0x04; /* 2 pixel mode */ |
| 1523 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1524 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1525 | |
| 1526 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1527 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1528 | data &= 0xE7; |
| 1529 | if (VCLK < 200) |
| 1530 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1531 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1532 | } |
| 1533 | |
| 1534 | /* Jong for Adavantech LCD ripple issue |
| 1535 | if ((VCLK >= 0) && (VCLK < 135)) |
| 1536 | data2 = 0x03; |
| 1537 | else if ((VCLK >= 135) && (VCLK < 160)) |
| 1538 | data2 = 0x02; |
| 1539 | else if ((VCLK >= 160) && (VCLK < 260)) |
| 1540 | data2 = 0x01; |
| 1541 | else if (VCLK > 260) |
| 1542 | data2 = 0x00; |
| 1543 | */ |
| 1544 | data2 = 0x00; |
| 1545 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1546 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1547 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1548 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1549 | |
| 1550 | } |
| 1551 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1552 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1553 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1554 | unsigned short RefreshRateTableIndex, |
| 1555 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1556 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1557 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1558 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1559 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1560 | if (ModeNo > 0x13) { |
| 1561 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1562 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1563 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1564 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1565 | /* si+St_ModeFlag */ |
| 1566 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1567 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1568 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1569 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1570 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1571 | if (ModeNo > 0x13) |
| 1572 | data = infoflag; |
| 1573 | else |
| 1574 | data = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1575 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1576 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1577 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1578 | if (ModeNo > 0x13) { |
| 1579 | if (pVBInfo->ModeType > 0x02) { |
| 1580 | data2 |= 0x02; |
| 1581 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1582 | data3 = data3 << 2; |
| 1583 | data2 |= data3; |
| 1584 | } |
| 1585 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1586 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1587 | data &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1588 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1589 | if (data) |
| 1590 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1591 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1592 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1593 | /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1594 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 1595 | if (ModeNo <= 0x13) |
| 1596 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 1597 | else |
| 1598 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1600 | data = 0x0000; |
| 1601 | if (infoflag & InterlaceMode) { |
| 1602 | if (xres == 1024) |
| 1603 | data = 0x0035; |
| 1604 | else if (xres == 1280) |
| 1605 | data = 0x0048; |
| 1606 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1607 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1608 | data2 = data & 0x00FF; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1609 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1610 | data2 = (data & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1611 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1612 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1613 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1614 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1615 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1616 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1617 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1618 | if (modeflag & LineCompareOff) |
| 1619 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1620 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1621 | if (ModeNo > 0x13) { |
| 1622 | if (pVBInfo->ModeType == ModeEGA) |
| 1623 | data2 |= 0x40; |
| 1624 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1625 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1626 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1627 | data = 0x60; |
| 1628 | if (pVBInfo->ModeType != ModeText) { |
| 1629 | data = data ^ 0x60; |
| 1630 | if (pVBInfo->ModeType != ModeEGA) |
| 1631 | data = data ^ 0xA0; |
| 1632 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1633 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
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 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, |
| 1636 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1637 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1638 | /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */ |
| 1639 | /* if (XGINew_IF_DEF_NEW_LOWRES) */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1640 | /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); |
| 1641 | * //030305 fix lowresolution bug */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1642 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1643 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1644 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1645 | if (HwDeviceExtension->jChipType == XG27) { |
| 1646 | if (data & 0x40) |
| 1647 | data = 0x2c; |
| 1648 | else |
| 1649 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1650 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1651 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1652 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1653 | if (data & 0x40) |
| 1654 | data = 0x33; |
| 1655 | else |
| 1656 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1657 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1658 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1659 | } else { |
| 1660 | if (data & 0x40) |
| 1661 | data = 0x2c; |
| 1662 | else |
| 1663 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1664 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1665 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1666 | |
| 1667 | } |
| 1668 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1669 | static void XGI_WriteDAC(unsigned short dl, |
| 1670 | unsigned short ah, |
| 1671 | unsigned short al, |
| 1672 | unsigned short dh, |
| 1673 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1674 | { |
| 1675 | unsigned short temp, bh, bl; |
| 1676 | |
| 1677 | bh = ah; |
| 1678 | bl = al; |
| 1679 | |
| 1680 | if (dl != 0) { |
| 1681 | temp = bh; |
| 1682 | bh = dh; |
| 1683 | dh = temp; |
| 1684 | if (dl == 1) { |
| 1685 | temp = bl; |
| 1686 | bl = dh; |
| 1687 | dh = temp; |
| 1688 | } else { |
| 1689 | temp = bl; |
| 1690 | bl = bh; |
| 1691 | bh = temp; |
| 1692 | } |
| 1693 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1694 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1695 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1696 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1697 | } |
| 1698 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1699 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1700 | struct vb_device_info *pVBInfo) |
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 | unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al, |
| 1703 | ah, dh, *table = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1704 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1705 | if (ModeNo <= 0x13) |
| 1706 | data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1707 | else |
| 1708 | data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1709 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1710 | data &= DACInfoFlag; |
| 1711 | time = 64; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1712 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1713 | if (data == 0x00) |
| 1714 | table = XGINew_MDA_DAC; |
| 1715 | else if (data == 0x08) |
| 1716 | table = XGINew_CGA_DAC; |
| 1717 | else if (data == 0x10) |
| 1718 | table = XGINew_EGA_DAC; |
| 1719 | else if (data == 0x18) { |
| 1720 | time = 256; |
| 1721 | table = XGINew_VGA_DAC; |
| 1722 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1723 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1724 | if (time == 256) |
| 1725 | j = 16; |
| 1726 | else |
| 1727 | j = time; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1728 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1729 | outb(0xFF, pVBInfo->P3c6); |
| 1730 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1731 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1732 | for (i = 0; i < j; i++) { |
| 1733 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1734 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1735 | for (k = 0; k < 3; k++) { |
| 1736 | data2 = 0; |
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 (data & 0x01) |
| 1739 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1740 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1741 | if (data & 0x02) |
| 1742 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1743 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1744 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1745 | data = data >> 2; |
| 1746 | } |
| 1747 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1748 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1749 | if (time == 256) { |
| 1750 | for (i = 16; i < 32; i++) { |
| 1751 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1752 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1753 | for (k = 0; k < 3; k++) |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1754 | outb(data, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1755 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1756 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1757 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1758 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1759 | for (m = 0; m < 9; m++) { |
| 1760 | di = si; |
| 1761 | bx = si + 0x04; |
| 1762 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1763 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1764 | for (n = 0; n < 3; n++) { |
| 1765 | for (o = 0; o < 5; o++) { |
| 1766 | dh = table[si]; |
| 1767 | ah = table[di]; |
| 1768 | al = table[bx]; |
| 1769 | si++; |
| 1770 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1771 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1772 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1773 | si -= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1774 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1775 | for (o = 0; o < 3; o++) { |
| 1776 | dh = table[bx]; |
| 1777 | ah = table[di]; |
| 1778 | al = table[si]; |
| 1779 | si--; |
| 1780 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1781 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1782 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1783 | dl++; |
| 1784 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1785 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1786 | si += 5; |
| 1787 | } |
| 1788 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1789 | } |
| 1790 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1791 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
| 1792 | unsigned short ModeIdIndex, |
| 1793 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1794 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1795 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1796 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1797 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1798 | /* si+St_ResInfo */ |
| 1799 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1800 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1801 | /* si+Ext_ResInfo */ |
| 1802 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1803 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1804 | /* if (ModeNo > 0x13) */ |
| 1805 | /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */ |
| 1806 | /* else */ |
| 1807 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1808 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1809 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1810 | /* si+St_ResInfo */ |
| 1811 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1812 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1813 | /* si+Ext_ResInfo */ |
| 1814 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
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 | /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1817 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1818 | if (ModeNo <= 0x13) { |
| 1819 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 1820 | yres = pVBInfo->StResInfo[resindex].VTotal; |
| 1821 | } else { |
| 1822 | xres = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1823 | yres = pVBInfo->ModeResInfo[resindex].VTotal; |
| 1824 | } |
| 1825 | if (ModeNo > 0x13) { |
| 1826 | if (modeflag & HalfDCLK) |
| 1827 | xres = xres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1828 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1829 | if (modeflag & DoubleScanMode) |
| 1830 | yres = yres << 1; |
| 1831 | } |
| 1832 | /* if (modeflag & Charx8Dot) */ |
| 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 (xres == 720) |
| 1836 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1837 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1838 | /* } */ |
| 1839 | pVBInfo->VGAHDE = xres; |
| 1840 | pVBInfo->HDE = xres; |
| 1841 | pVBInfo->VGAVDE = yres; |
| 1842 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1843 | } |
| 1844 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1845 | static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, |
| 1846 | unsigned short ModeIdIndex, |
| 1847 | unsigned short RefreshRateTableIndex, |
| 1848 | struct vb_device_info *pVBInfo) |
| 1849 | { |
| 1850 | unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table; |
| 1851 | |
| 1852 | struct XGI330_LCDDataTablStruct *tempdi = NULL; |
| 1853 | |
| 1854 | tempbx = BX; |
| 1855 | |
| 1856 | if (ModeNo <= 0x13) { |
| 1857 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1858 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 1859 | } else { |
| 1860 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1861 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
| 1862 | } |
| 1863 | |
| 1864 | tempal = tempal & 0x0f; |
| 1865 | |
| 1866 | if (tempbx <= 1) { /* ExpLink */ |
| 1867 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1868 | /* find no Ext_CRT2CRTC2 */ |
| 1869 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1870 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1871 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1872 | Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1873 | } |
| 1874 | |
| 1875 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 1876 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1877 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 1878 | St_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1879 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1880 | tempal = pVBInfo->RefIndex[ |
| 1881 | RefreshRateTableIndex]. |
| 1882 | Ext_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1883 | } |
| 1884 | |
| 1885 | if (tempbx & 0x01) |
| 1886 | tempal = (tempal >> 4); |
| 1887 | |
| 1888 | tempal = (tempal & 0x0f); |
| 1889 | } |
| 1890 | |
| 1891 | tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */ |
| 1892 | |
| 1893 | if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */ |
| 1894 | if ((tempbx == 5) || (tempbx) == 7) |
| 1895 | tempcx = LCDDesDataLen2; |
| 1896 | else if ((tempbx == 3) || (tempbx == 8)) |
| 1897 | tempcx = LVDSDesDataLen2; |
| 1898 | } |
| 1899 | /* mov di, word ptr cs:LCDDataList[bx] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1900 | /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | |
| 1901 | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1902 | |
| 1903 | switch (tempbx) { |
| 1904 | case 0: |
| 1905 | tempdi = XGI_EPLLCDCRT1Ptr_H; |
| 1906 | break; |
| 1907 | case 1: |
| 1908 | tempdi = XGI_EPLLCDCRT1Ptr_V; |
| 1909 | break; |
| 1910 | case 2: |
| 1911 | tempdi = XGI_EPLLCDDataPtr; |
| 1912 | break; |
| 1913 | case 3: |
| 1914 | tempdi = XGI_EPLLCDDesDataPtr; |
| 1915 | break; |
| 1916 | case 4: |
| 1917 | tempdi = XGI_LCDDataTable; |
| 1918 | break; |
| 1919 | case 5: |
| 1920 | tempdi = XGI_LCDDesDataTable; |
| 1921 | break; |
| 1922 | case 6: |
| 1923 | tempdi = XGI_EPLCHLCDRegPtr; |
| 1924 | break; |
| 1925 | case 7: |
| 1926 | case 8: |
| 1927 | case 9: |
| 1928 | tempdi = NULL; |
| 1929 | break; |
| 1930 | default: |
| 1931 | break; |
| 1932 | } |
| 1933 | |
| 1934 | if (tempdi == NULL) /* OEMUtil */ |
| 1935 | return NULL; |
| 1936 | |
| 1937 | table = tempbx; |
| 1938 | i = 0; |
| 1939 | |
| 1940 | while (tempdi[i].PANELID != 0xff) { |
| 1941 | tempdx = pVBInfo->LCDResInfo; |
| 1942 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 1943 | tempbx &= (~0x0080); |
| 1944 | tempdx = pVBInfo->LCDTypeInfo; |
| 1945 | } |
| 1946 | |
| 1947 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1948 | tempdx &= (~PanelResInfo); |
| 1949 | |
| 1950 | if (tempdi[i].PANELID == tempdx) { |
| 1951 | tempbx = tempdi[i].MASK; |
| 1952 | tempdx = pVBInfo->LCDInfo; |
| 1953 | |
| 1954 | if (ModeNo <= 0x13) /* alan 09/10/2003 */ |
| 1955 | tempdx |= SetLCDStdMode; |
| 1956 | |
| 1957 | if (modeflag & HalfDCLK) |
| 1958 | tempdx |= SetLCDLowResolution; |
| 1959 | |
| 1960 | tempbx &= tempdx; |
| 1961 | if (tempbx == tempdi[i].CAP) |
| 1962 | break; |
| 1963 | } |
| 1964 | i++; |
| 1965 | } |
| 1966 | |
| 1967 | if (table == 0) { |
| 1968 | switch (tempdi[i].DATAPTR) { |
| 1969 | case 0: |
| 1970 | return &XGI_LVDSCRT11024x768_1_H[tempal]; |
| 1971 | break; |
| 1972 | case 1: |
| 1973 | return &XGI_LVDSCRT11024x768_2_H[tempal]; |
| 1974 | break; |
| 1975 | case 2: |
| 1976 | return &XGI_LVDSCRT11280x1024_1_H[tempal]; |
| 1977 | break; |
| 1978 | case 3: |
| 1979 | return &XGI_LVDSCRT11280x1024_2_H[tempal]; |
| 1980 | break; |
| 1981 | case 4: |
| 1982 | return &XGI_LVDSCRT11400x1050_1_H[tempal]; |
| 1983 | break; |
| 1984 | case 5: |
| 1985 | return &XGI_LVDSCRT11400x1050_2_H[tempal]; |
| 1986 | break; |
| 1987 | case 6: |
| 1988 | return &XGI_LVDSCRT11600x1200_1_H[tempal]; |
| 1989 | break; |
| 1990 | case 7: |
| 1991 | return &XGI_LVDSCRT11024x768_1_Hx75[tempal]; |
| 1992 | break; |
| 1993 | case 8: |
| 1994 | return &XGI_LVDSCRT11024x768_2_Hx75[tempal]; |
| 1995 | break; |
| 1996 | case 9: |
| 1997 | return &XGI_LVDSCRT11280x1024_1_Hx75[tempal]; |
| 1998 | break; |
| 1999 | case 10: |
| 2000 | return &XGI_LVDSCRT11280x1024_2_Hx75[tempal]; |
| 2001 | break; |
| 2002 | default: |
| 2003 | break; |
| 2004 | } |
| 2005 | } else if (table == 1) { |
| 2006 | switch (tempdi[i].DATAPTR) { |
| 2007 | case 0: |
| 2008 | return &XGI_LVDSCRT11024x768_1_V[tempal]; |
| 2009 | break; |
| 2010 | case 1: |
| 2011 | return &XGI_LVDSCRT11024x768_2_V[tempal]; |
| 2012 | break; |
| 2013 | case 2: |
| 2014 | return &XGI_LVDSCRT11280x1024_1_V[tempal]; |
| 2015 | break; |
| 2016 | case 3: |
| 2017 | return &XGI_LVDSCRT11280x1024_2_V[tempal]; |
| 2018 | break; |
| 2019 | case 4: |
| 2020 | return &XGI_LVDSCRT11400x1050_1_V[tempal]; |
| 2021 | break; |
| 2022 | case 5: |
| 2023 | return &XGI_LVDSCRT11400x1050_2_V[tempal]; |
| 2024 | break; |
| 2025 | case 6: |
| 2026 | return &XGI_LVDSCRT11600x1200_1_V[tempal]; |
| 2027 | break; |
| 2028 | case 7: |
| 2029 | return &XGI_LVDSCRT11024x768_1_Vx75[tempal]; |
| 2030 | break; |
| 2031 | case 8: |
| 2032 | return &XGI_LVDSCRT11024x768_2_Vx75[tempal]; |
| 2033 | break; |
| 2034 | case 9: |
| 2035 | return &XGI_LVDSCRT11280x1024_1_Vx75[tempal]; |
| 2036 | break; |
| 2037 | case 10: |
| 2038 | return &XGI_LVDSCRT11280x1024_2_Vx75[tempal]; |
| 2039 | break; |
| 2040 | default: |
| 2041 | break; |
| 2042 | } |
| 2043 | } else if (table == 2) { |
| 2044 | switch (tempdi[i].DATAPTR) { |
| 2045 | case 0: |
| 2046 | return &XGI_LVDS1024x768Data_1[tempal]; |
| 2047 | break; |
| 2048 | case 1: |
| 2049 | return &XGI_LVDS1024x768Data_2[tempal]; |
| 2050 | break; |
| 2051 | case 2: |
| 2052 | return &XGI_LVDS1280x1024Data_1[tempal]; |
| 2053 | break; |
| 2054 | case 3: |
| 2055 | return &XGI_LVDS1280x1024Data_2[tempal]; |
| 2056 | break; |
| 2057 | case 4: |
| 2058 | return &XGI_LVDS1400x1050Data_1[tempal]; |
| 2059 | break; |
| 2060 | case 5: |
| 2061 | return &XGI_LVDS1400x1050Data_2[tempal]; |
| 2062 | break; |
| 2063 | case 6: |
| 2064 | return &XGI_LVDS1600x1200Data_1[tempal]; |
| 2065 | break; |
| 2066 | case 7: |
| 2067 | return &XGI_LVDSNoScalingData[tempal]; |
| 2068 | break; |
| 2069 | case 8: |
| 2070 | return &XGI_LVDS1024x768Data_1x75[tempal]; |
| 2071 | break; |
| 2072 | case 9: |
| 2073 | return &XGI_LVDS1024x768Data_2x75[tempal]; |
| 2074 | break; |
| 2075 | case 10: |
| 2076 | return &XGI_LVDS1280x1024Data_1x75[tempal]; |
| 2077 | break; |
| 2078 | case 11: |
| 2079 | return &XGI_LVDS1280x1024Data_2x75[tempal]; |
| 2080 | break; |
| 2081 | case 12: |
| 2082 | return &XGI_LVDSNoScalingDatax75[tempal]; |
| 2083 | break; |
| 2084 | default: |
| 2085 | break; |
| 2086 | } |
| 2087 | } else if (table == 3) { |
| 2088 | switch (tempdi[i].DATAPTR) { |
| 2089 | case 0: |
| 2090 | return &XGI_LVDS1024x768Des_1[tempal]; |
| 2091 | break; |
| 2092 | case 1: |
| 2093 | return &XGI_LVDS1024x768Des_3[tempal]; |
| 2094 | break; |
| 2095 | case 2: |
| 2096 | return &XGI_LVDS1024x768Des_2[tempal]; |
| 2097 | break; |
| 2098 | case 3: |
| 2099 | return &XGI_LVDS1280x1024Des_1[tempal]; |
| 2100 | break; |
| 2101 | case 4: |
| 2102 | return &XGI_LVDS1280x1024Des_2[tempal]; |
| 2103 | break; |
| 2104 | case 5: |
| 2105 | return &XGI_LVDS1400x1050Des_1[tempal]; |
| 2106 | break; |
| 2107 | case 6: |
| 2108 | return &XGI_LVDS1400x1050Des_2[tempal]; |
| 2109 | break; |
| 2110 | case 7: |
| 2111 | return &XGI_LVDS1600x1200Des_1[tempal]; |
| 2112 | break; |
| 2113 | case 8: |
| 2114 | return &XGI_LVDSNoScalingDesData[tempal]; |
| 2115 | break; |
| 2116 | case 9: |
| 2117 | return &XGI_LVDS1024x768Des_1x75[tempal]; |
| 2118 | break; |
| 2119 | case 10: |
| 2120 | return &XGI_LVDS1024x768Des_3x75[tempal]; |
| 2121 | break; |
| 2122 | case 11: |
| 2123 | return &XGI_LVDS1024x768Des_2x75[tempal]; |
| 2124 | break; |
| 2125 | case 12: |
| 2126 | return &XGI_LVDS1280x1024Des_1x75[tempal]; |
| 2127 | break; |
| 2128 | case 13: |
| 2129 | return &XGI_LVDS1280x1024Des_2x75[tempal]; |
| 2130 | break; |
| 2131 | case 14: |
| 2132 | return &XGI_LVDSNoScalingDesDatax75[tempal]; |
| 2133 | break; |
| 2134 | default: |
| 2135 | break; |
| 2136 | } |
| 2137 | } else if (table == 4) { |
| 2138 | switch (tempdi[i].DATAPTR) { |
| 2139 | case 0: |
| 2140 | return &XGI_ExtLCD1024x768Data[tempal]; |
| 2141 | break; |
| 2142 | case 1: |
| 2143 | return &XGI_StLCD1024x768Data[tempal]; |
| 2144 | break; |
| 2145 | case 2: |
| 2146 | return &XGI_CetLCD1024x768Data[tempal]; |
| 2147 | break; |
| 2148 | case 3: |
| 2149 | return &XGI_ExtLCD1280x1024Data[tempal]; |
| 2150 | break; |
| 2151 | case 4: |
| 2152 | return &XGI_StLCD1280x1024Data[tempal]; |
| 2153 | break; |
| 2154 | case 5: |
| 2155 | return &XGI_CetLCD1280x1024Data[tempal]; |
| 2156 | break; |
| 2157 | case 6: |
| 2158 | return &XGI_ExtLCD1400x1050Data[tempal]; |
| 2159 | break; |
| 2160 | case 7: |
| 2161 | return &XGI_StLCD1400x1050Data[tempal]; |
| 2162 | break; |
| 2163 | case 8: |
| 2164 | return &XGI_CetLCD1400x1050Data[tempal]; |
| 2165 | break; |
| 2166 | case 9: |
| 2167 | return &XGI_ExtLCD1600x1200Data[tempal]; |
| 2168 | break; |
| 2169 | case 10: |
| 2170 | return &XGI_StLCD1600x1200Data[tempal]; |
| 2171 | break; |
| 2172 | case 11: |
| 2173 | return &XGI_NoScalingData[tempal]; |
| 2174 | break; |
| 2175 | case 12: |
| 2176 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 2177 | break; |
| 2178 | case 13: |
| 2179 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 2180 | break; |
| 2181 | case 14: |
| 2182 | return &XGI_CetLCD1024x768x75Data[tempal]; |
| 2183 | break; |
| 2184 | case 15: |
| 2185 | return &XGI_ExtLCD1280x1024x75Data[tempal]; |
| 2186 | break; |
| 2187 | case 16: |
| 2188 | return &XGI_StLCD1280x1024x75Data[tempal]; |
| 2189 | break; |
| 2190 | case 17: |
| 2191 | return &XGI_CetLCD1280x1024x75Data[tempal]; |
| 2192 | break; |
| 2193 | case 18: |
| 2194 | return &XGI_NoScalingDatax75[tempal]; |
| 2195 | break; |
| 2196 | default: |
| 2197 | break; |
| 2198 | } |
| 2199 | } else if (table == 5) { |
| 2200 | switch (tempdi[i].DATAPTR) { |
| 2201 | case 0: |
| 2202 | return &XGI_ExtLCDDes1024x768Data[tempal]; |
| 2203 | break; |
| 2204 | case 1: |
| 2205 | return &XGI_StLCDDes1024x768Data[tempal]; |
| 2206 | break; |
| 2207 | case 2: |
| 2208 | return &XGI_CetLCDDes1024x768Data[tempal]; |
| 2209 | break; |
| 2210 | case 3: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2211 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2212 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2213 | return &XGI_ExtLCDDLDes1280x1024Data[tempal]; |
| 2214 | else |
| 2215 | return &XGI_ExtLCDDes1280x1024Data[tempal]; |
| 2216 | break; |
| 2217 | case 4: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2218 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2219 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2220 | return &XGI_StLCDDLDes1280x1024Data[tempal]; |
| 2221 | else |
| 2222 | return &XGI_StLCDDes1280x1024Data[tempal]; |
| 2223 | break; |
| 2224 | case 5: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2225 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2226 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2227 | return &XGI_CetLCDDLDes1280x1024Data[tempal]; |
| 2228 | else |
| 2229 | return &XGI_CetLCDDes1280x1024Data[tempal]; |
| 2230 | break; |
| 2231 | case 6: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2232 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2233 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2234 | return &XGI_ExtLCDDLDes1400x1050Data[tempal]; |
| 2235 | else |
| 2236 | return &XGI_ExtLCDDes1400x1050Data[tempal]; |
| 2237 | break; |
| 2238 | case 7: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2239 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2240 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2241 | return &XGI_StLCDDLDes1400x1050Data[tempal]; |
| 2242 | else |
| 2243 | return &XGI_StLCDDes1400x1050Data[tempal]; |
| 2244 | break; |
| 2245 | case 8: |
| 2246 | return &XGI_CetLCDDes1400x1050Data[tempal]; |
| 2247 | break; |
| 2248 | case 9: |
| 2249 | return &XGI_CetLCDDes1400x1050Data2[tempal]; |
| 2250 | break; |
| 2251 | case 10: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2252 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2253 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2254 | return &XGI_ExtLCDDLDes1600x1200Data[tempal]; |
| 2255 | else |
| 2256 | return &XGI_ExtLCDDes1600x1200Data[tempal]; |
| 2257 | break; |
| 2258 | case 11: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2259 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2260 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2261 | return &XGI_StLCDDLDes1600x1200Data[tempal]; |
| 2262 | else |
| 2263 | return &XGI_StLCDDes1600x1200Data[tempal]; |
| 2264 | break; |
| 2265 | case 12: |
| 2266 | return &XGI_NoScalingDesData[tempal]; |
| 2267 | break; |
| 2268 | case 13: |
| 2269 | return &XGI_ExtLCDDes1024x768x75Data[tempal]; |
| 2270 | break; |
| 2271 | case 14: |
| 2272 | return &XGI_StLCDDes1024x768x75Data[tempal]; |
| 2273 | break; |
| 2274 | case 15: |
| 2275 | return &XGI_CetLCDDes1024x768x75Data[tempal]; |
| 2276 | break; |
| 2277 | case 16: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2278 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2279 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2280 | return &XGI_ExtLCDDLDes1280x1024x75Data[tempal]; |
| 2281 | else |
| 2282 | return &XGI_ExtLCDDes1280x1024x75Data[tempal]; |
| 2283 | break; |
| 2284 | case 17: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2285 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2286 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2287 | return &XGI_StLCDDLDes1280x1024x75Data[tempal]; |
| 2288 | else |
| 2289 | return &XGI_StLCDDes1280x1024x75Data[tempal]; |
| 2290 | break; |
| 2291 | case 18: |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2292 | if ((pVBInfo->VBType & VB_XGI301LV) || |
| 2293 | (pVBInfo->VBType & VB_XGI302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2294 | return &XGI_CetLCDDLDes1280x1024x75Data[tempal]; |
| 2295 | else |
| 2296 | return &XGI_CetLCDDes1280x1024x75Data[tempal]; |
| 2297 | break; |
| 2298 | case 19: |
| 2299 | return &XGI_NoScalingDesDatax75[tempal]; |
| 2300 | break; |
| 2301 | default: |
| 2302 | break; |
| 2303 | } |
| 2304 | } else if (table == 6) { |
| 2305 | switch (tempdi[i].DATAPTR) { |
| 2306 | case 0: |
| 2307 | return &XGI_CH7017LV1024x768[tempal]; |
| 2308 | break; |
| 2309 | case 1: |
| 2310 | return &XGI_CH7017LV1400x1050[tempal]; |
| 2311 | break; |
| 2312 | default: |
| 2313 | break; |
| 2314 | } |
| 2315 | } |
| 2316 | return NULL; |
| 2317 | } |
| 2318 | |
| 2319 | static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, |
| 2320 | unsigned short ModeIdIndex, |
| 2321 | unsigned short RefreshRateTableIndex, |
| 2322 | struct vb_device_info *pVBInfo) |
| 2323 | { |
| 2324 | unsigned short i, tempdx, tempbx, tempal, modeflag, table; |
| 2325 | struct XGI330_TVDataTablStruct *tempdi = NULL; |
| 2326 | |
| 2327 | tempbx = BX; |
| 2328 | |
| 2329 | if (ModeNo <= 0x13) { |
| 2330 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 2331 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 2332 | } else { |
| 2333 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2334 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
| 2335 | } |
| 2336 | |
| 2337 | tempal = tempal & 0x3f; |
| 2338 | table = tempbx; |
| 2339 | |
| 2340 | switch (tempbx) { |
| 2341 | case 0: |
| 2342 | tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2343 | break; |
| 2344 | case 1: |
| 2345 | tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2346 | break; |
| 2347 | case 2: |
| 2348 | tempdi = XGI_EPLCHTVDataPtr; |
| 2349 | break; |
| 2350 | case 3: |
| 2351 | tempdi = NULL; |
| 2352 | break; |
| 2353 | case 4: |
| 2354 | tempdi = XGI_TVDataTable; |
| 2355 | break; |
| 2356 | case 5: |
| 2357 | tempdi = NULL; |
| 2358 | break; |
| 2359 | case 6: |
| 2360 | tempdi = XGI_EPLCHTVRegPtr; |
| 2361 | break; |
| 2362 | default: |
| 2363 | break; |
| 2364 | } |
| 2365 | |
| 2366 | if (tempdi == NULL) /* OEMUtil */ |
| 2367 | return NULL; |
| 2368 | |
| 2369 | tempdx = pVBInfo->TVInfo; |
| 2370 | |
| 2371 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2372 | tempdx = tempdx | SetTVLockMode; |
| 2373 | |
| 2374 | if (modeflag & HalfDCLK) |
| 2375 | tempdx = tempdx | SetTVLowResolution; |
| 2376 | |
| 2377 | i = 0; |
| 2378 | |
| 2379 | while (tempdi[i].MASK != 0xffff) { |
| 2380 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) |
| 2381 | break; |
| 2382 | i++; |
| 2383 | } |
| 2384 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2385 | /* 07/05/22 */ |
| 2386 | if (table == 0x00) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2387 | } else if (table == 0x01) { |
| 2388 | } else if (table == 0x04) { |
| 2389 | switch (tempdi[i].DATAPTR) { |
| 2390 | case 0: |
| 2391 | return &XGI_ExtPALData[tempal]; |
| 2392 | break; |
| 2393 | case 1: |
| 2394 | return &XGI_ExtNTSCData[tempal]; |
| 2395 | break; |
| 2396 | case 2: |
| 2397 | return &XGI_StPALData[tempal]; |
| 2398 | break; |
| 2399 | case 3: |
| 2400 | return &XGI_StNTSCData[tempal]; |
| 2401 | break; |
| 2402 | case 4: |
| 2403 | return &XGI_ExtHiTVData[tempal]; |
| 2404 | break; |
| 2405 | case 5: |
| 2406 | return &XGI_St2HiTVData[tempal]; |
| 2407 | break; |
| 2408 | case 6: |
| 2409 | return &XGI_ExtYPbPr525iData[tempal]; |
| 2410 | break; |
| 2411 | case 7: |
| 2412 | return &XGI_ExtYPbPr525pData[tempal]; |
| 2413 | break; |
| 2414 | case 8: |
| 2415 | return &XGI_ExtYPbPr750pData[tempal]; |
| 2416 | break; |
| 2417 | case 9: |
| 2418 | return &XGI_StYPbPr525iData[tempal]; |
| 2419 | break; |
| 2420 | case 10: |
| 2421 | return &XGI_StYPbPr525pData[tempal]; |
| 2422 | break; |
| 2423 | case 11: |
| 2424 | return &XGI_StYPbPr750pData[tempal]; |
| 2425 | break; |
| 2426 | case 12: /* avoid system hang */ |
| 2427 | return &XGI_ExtNTSCData[tempal]; |
| 2428 | break; |
| 2429 | case 13: |
| 2430 | return &XGI_St1HiTVData[tempal]; |
| 2431 | break; |
| 2432 | default: |
| 2433 | break; |
| 2434 | } |
| 2435 | } else if (table == 0x02) { |
| 2436 | switch (tempdi[i].DATAPTR) { |
| 2437 | case 0: |
| 2438 | return &XGI_CHTVUNTSCData[tempal]; |
| 2439 | break; |
| 2440 | case 1: |
| 2441 | return &XGI_CHTVONTSCData[tempal]; |
| 2442 | break; |
| 2443 | case 2: |
| 2444 | return &XGI_CHTVUPALData[tempal]; |
| 2445 | break; |
| 2446 | case 3: |
| 2447 | return &XGI_CHTVOPALData[tempal]; |
| 2448 | break; |
| 2449 | default: |
| 2450 | break; |
| 2451 | } |
| 2452 | } else if (table == 0x06) { |
| 2453 | } |
| 2454 | return NULL; |
| 2455 | } |
| 2456 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2457 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2458 | unsigned short RefreshRateTableIndex, |
| 2459 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2460 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2461 | unsigned short tempbx; |
| 2462 | struct XGI330_LVDSDataStruct *LCDPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2463 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2464 | tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2465 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2466 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 2467 | LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx, |
| 2468 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2469 | pVBInfo); |
| 2470 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2471 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2472 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2473 | pVBInfo->VT = LCDPtr->LCDVT; |
| 2474 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2475 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2476 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 2477 | if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding |
| 2478 | | EnableScalingLCD))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2479 | if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 2480 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2481 | pVBInfo->HDE = 1024; |
| 2482 | pVBInfo->VDE = 768; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2483 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || |
| 2484 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2485 | pVBInfo->HDE = 1280; |
| 2486 | pVBInfo->VDE = 1024; |
| 2487 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 2488 | pVBInfo->HDE = 1400; |
| 2489 | pVBInfo->VDE = 1050; |
| 2490 | } else { |
| 2491 | pVBInfo->HDE = 1600; |
| 2492 | pVBInfo->VDE = 1200; |
| 2493 | } |
| 2494 | } |
| 2495 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2496 | } |
| 2497 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2498 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2499 | unsigned short RefreshRateTableIndex, |
| 2500 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2501 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2502 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2503 | unsigned char index; |
| 2504 | unsigned short tempbx, i; |
| 2505 | struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL; |
| 2506 | struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2507 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2508 | if (ModeNo <= 0x13) |
| 2509 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 2510 | else |
| 2511 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2512 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2513 | index = index & IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2514 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2515 | if ((pVBInfo->IF_DEF_ScaleLCD == 0) || |
| 2516 | ((pVBInfo->IF_DEF_ScaleLCD == 1) && |
| 2517 | (!(pVBInfo->LCDInfo & EnableScalingLCD)))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2518 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2519 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2520 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2521 | LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) |
| 2522 | XGI_GetLcdPtr(tempbx, ModeNo, |
| 2523 | ModeIdIndex, |
| 2524 | RefreshRateTableIndex, |
| 2525 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2526 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2527 | for (i = 0; i < 8; i++) |
| 2528 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; |
| 2529 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2530 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2531 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2532 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2533 | tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2534 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2535 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2536 | LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) |
| 2537 | XGI_GetLcdPtr( |
| 2538 | tempbx, |
| 2539 | ModeNo, |
| 2540 | ModeIdIndex, |
| 2541 | RefreshRateTableIndex, |
| 2542 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2543 | for (i = 0; i < 7; i++) |
| 2544 | pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; |
| 2545 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2546 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2547 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2548 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2549 | } |
| 2550 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2551 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 2552 | { |
| 2553 | unsigned char tempal, tempah, tempbl, i; |
| 2554 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2555 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2556 | tempal = tempah & 0x0F; |
| 2557 | tempah = tempah & 0xF0; |
| 2558 | i = 0; |
| 2559 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2560 | |
| 2561 | while (tempbl != 0xFF) { |
| 2562 | if (tempbl & 0x80) { /* OEMUtil */ |
| 2563 | tempal = tempah; |
| 2564 | tempbl = tempbl & ~(0x80); |
| 2565 | } |
| 2566 | |
| 2567 | if (tempal == tempbl) |
| 2568 | break; |
| 2569 | |
| 2570 | i++; |
| 2571 | |
| 2572 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2573 | } |
| 2574 | |
| 2575 | return i; |
| 2576 | } |
| 2577 | |
| 2578 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 2579 | { |
| 2580 | unsigned short tempah, tempal, tempbl, i; |
| 2581 | |
| 2582 | tempal = pVBInfo->LCDResInfo; |
| 2583 | tempah = pVBInfo->LCDTypeInfo; |
| 2584 | |
| 2585 | i = 0; |
| 2586 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2587 | |
| 2588 | while (tempbl != 0xFF) { |
| 2589 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 2590 | tempal = tempah; |
| 2591 | tempbl &= ~0x80; |
| 2592 | } |
| 2593 | |
| 2594 | if (tempal == tempbl) |
| 2595 | break; |
| 2596 | |
| 2597 | i++; |
| 2598 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2599 | } |
| 2600 | |
| 2601 | if (tempbl == 0xFF) { |
| 2602 | pVBInfo->LCDResInfo = Panel1024x768; |
| 2603 | pVBInfo->LCDTypeInfo = 0; |
| 2604 | i = 0; |
| 2605 | } |
| 2606 | |
| 2607 | return i; |
| 2608 | } |
| 2609 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2610 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 2611 | unsigned short *VSyncWidth, |
| 2612 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2613 | { |
| 2614 | unsigned short Index; |
| 2615 | |
| 2616 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 2617 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 2618 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
| 2619 | |
| 2620 | return; |
| 2621 | } |
| 2622 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2623 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2624 | unsigned short RefreshRateTableIndex, |
| 2625 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2626 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2627 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 2628 | unsigned long temp, temp1, temp2, temp3, push3; |
| 2629 | struct XGI330_LCDDataDesStruct *LCDPtr = NULL; |
| 2630 | struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2631 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2632 | if (ModeNo > 0x13) |
| 2633 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2634 | else |
| 2635 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2636 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2637 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) { |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2638 | if (pVBInfo->IF_DEF_OEMUtil == 1) { |
| 2639 | tempbx = 8; |
| 2640 | LCDPtr = (struct XGI330_LCDDataDesStruct *) |
| 2641 | XGI_GetLcdPtr(tempbx, |
| 2642 | ModeNo, |
| 2643 | ModeIdIndex, |
| 2644 | RefreshRateTableIndex, |
| 2645 | pVBInfo); |
| 2646 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2647 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2648 | if ((pVBInfo->IF_DEF_OEMUtil == 0) || |
| 2649 | (LCDPtr == NULL)) { |
| 2650 | tempbx = 3; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2651 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2652 | LCDPtr1 = |
| 2653 | (struct XGI330_LCDDataDesStruct2 *) |
| 2654 | XGI_GetLcdPtr( |
| 2655 | tempbx, |
| 2656 | ModeNo, |
| 2657 | ModeIdIndex, |
| 2658 | RefreshRateTableIndex, |
| 2659 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2660 | else |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2661 | LCDPtr = |
| 2662 | (struct XGI330_LCDDataDesStruct *) |
| 2663 | XGI_GetLcdPtr( |
| 2664 | tempbx, |
| 2665 | ModeNo, |
| 2666 | ModeIdIndex, |
| 2667 | RefreshRateTableIndex, |
| 2668 | pVBInfo); |
| 2669 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2670 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2671 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 2672 | push1 = tempbx; |
| 2673 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2674 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2675 | /* GetLCDResInfo */ |
| 2676 | if ((pVBInfo->LCDResInfo == Panel1024x768) || |
| 2677 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { |
| 2678 | tempax = 1024; |
| 2679 | tempbx = 768; |
| 2680 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || |
| 2681 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { |
| 2682 | tempax = 1280; |
| 2683 | tempbx = 1024; |
| 2684 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 2685 | tempax = 1400; |
| 2686 | tempbx = 1050; |
| 2687 | } else { |
| 2688 | tempax = 1600; |
| 2689 | tempbx = 1200; |
| 2690 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2691 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2692 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 2693 | pVBInfo->HDE = tempax; |
| 2694 | pVBInfo->VDE = tempbx; |
| 2695 | pVBInfo->VGAHDE = tempax; |
| 2696 | pVBInfo->VGAVDE = tempbx; |
| 2697 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2698 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2699 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && |
| 2700 | (pVBInfo->LCDInfo & EnableScalingLCD)) { |
| 2701 | tempax = pVBInfo->HDE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2702 | tempbx = pVBInfo->VDE; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2703 | } |
| 2704 | |
| 2705 | tempax = pVBInfo->HT; |
| 2706 | |
| 2707 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2708 | tempbx = LCDPtr1->LCDHDES; |
| 2709 | else |
| 2710 | tempbx = LCDPtr->LCDHDES; |
| 2711 | |
| 2712 | tempcx = pVBInfo->HDE; |
| 2713 | tempbx = tempbx & 0x0fff; |
| 2714 | tempcx += tempbx; |
| 2715 | |
| 2716 | if (tempcx >= tempax) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2717 | tempcx -= tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2718 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2719 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2720 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2721 | tempcx = tempcx >> 3; |
| 2722 | tempbx = tempbx >> 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2723 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2724 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 2725 | (unsigned short) (tempbx & 0xff)); |
| 2726 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 2727 | (unsigned short) (tempcx & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2728 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2729 | tempax = pVBInfo->HT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2730 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2731 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2732 | tempbx = LCDPtr1->LCDHRS; |
| 2733 | else |
| 2734 | tempbx = LCDPtr->LCDHRS; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2735 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2736 | tempcx = push2; |
| 2737 | |
| 2738 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2739 | tempcx = LCDPtr1->LCDHSync; |
| 2740 | |
| 2741 | tempcx += tempbx; |
| 2742 | |
| 2743 | if (tempcx >= tempax) |
| 2744 | tempcx -= tempax; |
| 2745 | |
| 2746 | tempax = tempbx & 0x07; |
| 2747 | tempax = tempax >> 5; |
| 2748 | tempcx = tempcx >> 3; |
| 2749 | tempbx = tempbx >> 3; |
| 2750 | |
| 2751 | tempcx &= 0x1f; |
| 2752 | tempax |= tempcx; |
| 2753 | |
| 2754 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 2755 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 2756 | (unsigned short) (tempbx & 0xff)); |
| 2757 | |
| 2758 | tempax = pVBInfo->VT; |
| 2759 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2760 | tempbx = LCDPtr1->LCDVDES; |
| 2761 | else |
| 2762 | tempbx = LCDPtr->LCDVDES; |
| 2763 | tempcx = pVBInfo->VDE; |
| 2764 | |
| 2765 | tempbx = tempbx & 0x0fff; |
| 2766 | tempcx += tempbx; |
| 2767 | if (tempcx >= tempax) |
| 2768 | tempcx -= tempax; |
| 2769 | |
| 2770 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 2771 | (unsigned short) (tempbx & 0xff)); |
| 2772 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 2773 | (unsigned short) (tempcx & 0xff)); |
| 2774 | |
| 2775 | tempbx = (tempbx >> 8) & 0x07; |
| 2776 | tempcx = (tempcx >> 8) & 0x07; |
| 2777 | |
| 2778 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 2779 | (unsigned short) ((tempcx << 3) |
| 2780 | | tempbx)); |
| 2781 | |
| 2782 | tempax = pVBInfo->VT; |
| 2783 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2784 | tempbx = LCDPtr1->LCDVRS; |
| 2785 | else |
| 2786 | tempbx = LCDPtr->LCDVRS; |
| 2787 | |
| 2788 | /* tempbx = tempbx >> 4; */ |
| 2789 | tempcx = push1; |
| 2790 | |
| 2791 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2792 | tempcx = LCDPtr1->LCDVSync; |
| 2793 | |
| 2794 | tempcx += tempbx; |
| 2795 | if (tempcx >= tempax) |
| 2796 | tempcx -= tempax; |
| 2797 | |
| 2798 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 2799 | (unsigned short) (tempbx & 0xff)); |
| 2800 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 2801 | (unsigned short) (tempcx & 0x0f)); |
| 2802 | |
| 2803 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 2804 | |
| 2805 | tempbx = pVBInfo->VGAVDE; |
| 2806 | if (tempbx != pVBInfo->VDE) |
| 2807 | tempax |= 0x40; |
| 2808 | |
| 2809 | if (pVBInfo->LCDInfo & EnableLVDSDDA) |
| 2810 | tempax |= 0x40; |
| 2811 | |
| 2812 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 2813 | tempax); |
| 2814 | |
| 2815 | tempcx = pVBInfo->VGAVT; |
| 2816 | tempbx = pVBInfo->VDE; |
| 2817 | tempax = pVBInfo->VGAVDE; |
| 2818 | tempcx -= tempax; |
| 2819 | |
| 2820 | temp = tempax; /* 0430 ylshieh */ |
| 2821 | temp1 = (temp << 18) / tempbx; |
| 2822 | |
| 2823 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 2824 | |
| 2825 | if (tempdx != 0) |
| 2826 | temp1 += 1; |
| 2827 | |
| 2828 | temp2 = temp1; |
| 2829 | push3 = temp2; |
| 2830 | |
| 2831 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 2832 | (unsigned short) (temp2 & 0xff)); |
| 2833 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 2834 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 2835 | |
| 2836 | tempbx = (unsigned short) (temp2 >> 16); |
| 2837 | tempax = tempbx & 0x03; |
| 2838 | |
| 2839 | tempbx = pVBInfo->VGAVDE; |
| 2840 | if (tempbx == pVBInfo->VDE) |
| 2841 | tempax |= 0x04; |
| 2842 | |
| 2843 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 2844 | |
| 2845 | if (pVBInfo->VBType & VB_XGI301C) { |
| 2846 | temp2 = push3; |
| 2847 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2848 | 0x3c, |
| 2849 | (unsigned short) (temp2 & 0xff)); |
| 2850 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2851 | 0x3b, |
| 2852 | (unsigned short) ((temp2 >> 8) & |
| 2853 | 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2854 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2855 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 2856 | ~0xc0, |
| 2857 | (unsigned short) ((tempbx & |
| 2858 | 0xff) << 6)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2859 | |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2860 | tempcx = pVBInfo->VGAVDE; |
| 2861 | if (tempcx == pVBInfo->VDE) |
| 2862 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2863 | 0x30, ~0x0c, 0x00); |
| 2864 | else |
| 2865 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2866 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2867 | } |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2868 | |
| 2869 | tempcx = pVBInfo->VGAHDE; |
| 2870 | tempbx = pVBInfo->HDE; |
| 2871 | |
| 2872 | temp1 = tempcx << 16; |
| 2873 | |
| 2874 | tempax = (unsigned short) (temp1 / tempbx); |
| 2875 | |
| 2876 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 2877 | tempax = 65535; |
| 2878 | |
| 2879 | temp3 = tempax; |
| 2880 | temp1 = pVBInfo->VGAHDE << 16; |
| 2881 | |
| 2882 | temp1 /= temp3; |
| 2883 | temp3 = temp3 << 16; |
| 2884 | temp1 -= 1; |
| 2885 | |
| 2886 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 2887 | |
| 2888 | tempax = (unsigned short) (temp3 & 0xff); |
| 2889 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 2890 | |
| 2891 | temp1 = pVBInfo->VGAVDE << 18; |
| 2892 | temp1 = temp1 / push3; |
| 2893 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 2894 | |
| 2895 | if (pVBInfo->LCDResInfo == Panel1024x768) |
| 2896 | tempbx -= 1; |
| 2897 | |
| 2898 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 2899 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 2900 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 2901 | (unsigned short) (tempax & 0xff)); |
| 2902 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 2903 | (unsigned short) (tempbx & 0xff)); |
| 2904 | |
| 2905 | temp3 = temp3 >> 16; |
| 2906 | |
| 2907 | if (modeflag & HalfDCLK) |
| 2908 | temp3 = temp3 >> 1; |
| 2909 | |
| 2910 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 2911 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 2912 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 2913 | (unsigned short) (temp3 & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2914 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2915 | } |
| 2916 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2917 | /* --------------------------------------------------------------------- */ |
| 2918 | /* Function : XGI_GETLCDVCLKPtr */ |
| 2919 | /* Input : */ |
| 2920 | /* Output : al -> VCLK Index */ |
| 2921 | /* Description : */ |
| 2922 | /* --------------------------------------------------------------------- */ |
| 2923 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 2924 | struct vb_device_info *pVBInfo) |
| 2925 | { |
| 2926 | unsigned short index; |
| 2927 | |
| 2928 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 2929 | if (pVBInfo->IF_DEF_ScaleLCD == 1) { |
| 2930 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2931 | return; |
| 2932 | } |
| 2933 | |
| 2934 | /* index = XGI_GetLCDCapPtr(pVBInfo); */ |
| 2935 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 2936 | |
| 2937 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 2938 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 2939 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 2940 | } else { /* LCDA */ |
| 2941 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 2942 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 2943 | } |
| 2944 | } |
| 2945 | return; |
| 2946 | } |
| 2947 | |
| 2948 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
| 2949 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 2950 | struct vb_device_info *pVBInfo) |
| 2951 | { |
| 2952 | |
| 2953 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2954 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2955 | |
| 2956 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2957 | /* si+St_ResInfo */ |
| 2958 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2959 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2960 | /* si+Ext_ResInfo */ |
| 2961 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2962 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2963 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 2964 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2965 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 2966 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 2967 | |
| 2968 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
| 2969 | return tempal; |
| 2970 | |
| 2971 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2972 | if (pVBInfo->VBType & |
| 2973 | (VB_XGI301B | |
| 2974 | VB_XGI302B | |
| 2975 | VB_XGI301LV | |
| 2976 | VB_XGI302LV | |
| 2977 | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2978 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 2979 | tempal = HiTVVCLKDIV2; |
| 2980 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
| 2981 | tempal = HiTVVCLK; |
| 2982 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 2983 | tempal = HiTVSimuVCLK; |
| 2984 | if (!(modeflag & Charx8Dot)) |
| 2985 | tempal = HiTVTextVCLK; |
| 2986 | |
| 2987 | } |
| 2988 | return tempal; |
| 2989 | } |
| 2990 | |
| 2991 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
| 2992 | tempal = YPbPr750pVCLK; |
| 2993 | return tempal; |
| 2994 | } |
| 2995 | |
| 2996 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
| 2997 | tempal = YPbPr525pVCLK; |
| 2998 | return tempal; |
| 2999 | } |
| 3000 | |
| 3001 | tempal = NTSC1024VCLK; |
| 3002 | |
| 3003 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
| 3004 | tempal = TVVCLKDIV2; |
| 3005 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
| 3006 | tempal = TVVCLK; |
| 3007 | } |
| 3008 | |
| 3009 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3010 | return tempal; |
| 3011 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3012 | } /* {End of VB} */ |
| 3013 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3014 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3015 | tempal = tempal >> 2; |
| 3016 | tempal &= 0x03; |
| 3017 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3018 | /* for Dot8 Scaling LCD */ |
| 3019 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3020 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
| 3021 | |
| 3022 | if (ModeNo <= 0x13) |
| 3023 | return tempal; |
| 3024 | |
| 3025 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 3026 | return tempal; |
| 3027 | } |
| 3028 | |
| 3029 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 3030 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 3031 | { |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3032 | if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3033 | | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
| 3034 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag |
| 3035 | & ProgrammingCRT2)) { |
| 3036 | *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B; |
| 3037 | *di_1 = XGI_VBVCLKData[tempal].SR2C; |
| 3038 | } |
| 3039 | } else { |
| 3040 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 3041 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 3042 | } |
| 3043 | } |
| 3044 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3045 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3046 | unsigned short RefreshRateTableIndex, |
| 3047 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3048 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3049 | unsigned char di_0, di_1, tempal; |
| 3050 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3051 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3052 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 3053 | pVBInfo); |
| 3054 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 3055 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3056 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3057 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3058 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3059 | (unsigned short) (0x10 * i)); |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3060 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3061 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3062 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 3063 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3064 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3065 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 3066 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3067 | } |
| 3068 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3069 | } |
| 3070 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3071 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3072 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3073 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3074 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3075 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3076 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 3077 | | VB_XGI302LV | VB_XGI301C)) { |
| 3078 | tempcl = 0; |
| 3079 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3080 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3081 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3082 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3083 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3084 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3085 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3086 | if (!(temp & 0x40)) |
| 3087 | tempcl |= ActiveCRT1; |
| 3088 | } |
| 3089 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3090 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3091 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3092 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3093 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3094 | if (!(temp == 0x08)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3095 | /* Check ChannelA by Part1_13 [2003/10/03] */ |
| 3096 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3097 | if (tempax & 0x04) |
| 3098 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3099 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3100 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3101 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3102 | if (!(tempcl & ActiveLCD)) |
| 3103 | if (temp == 0x01) |
| 3104 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3105 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3106 | if (temp == 0x04) |
| 3107 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3108 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3109 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3110 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3111 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3112 | if (!(temp & 0x08)) |
| 3113 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3114 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3115 | if (!(temp & 0x04)) |
| 3116 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3117 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3118 | if (temp & 0x02) |
| 3119 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3120 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3121 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 3122 | if (temp & 0x01) |
| 3123 | tempch |= ActiveHiTV; |
| 3124 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3125 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3126 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3127 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3128 | pVBInfo->Part2Port, |
| 3129 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3130 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3131 | if (temp & 0x10) |
| 3132 | tempch |= ActiveYPbPr; |
| 3133 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3134 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3135 | if (tempch != 0) |
| 3136 | tempcl |= ActiveTV; |
| 3137 | } |
| 3138 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3139 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3140 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3141 | if (tempcl & ActiveLCD) { |
| 3142 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 3143 | if (temp & ActiveTV) |
| 3144 | tempcl |= ActiveTV; |
| 3145 | } |
| 3146 | } |
| 3147 | temp = tempcl; |
| 3148 | tempbl = ~ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3149 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3150 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3151 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3152 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3153 | } else { |
| 3154 | return; |
| 3155 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3156 | } |
| 3157 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3158 | void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, |
| 3159 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3160 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3161 | /* |
| 3162 | if ( HwDeviceExtension->jChipType >= XG20 ) { |
| 3163 | pVBInfo->Set_VGAType = XG20; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 3164 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3165 | pVBInfo->Set_VGAType = VGA_XGI340; |
| 3166 | } |
| 3167 | */ |
| 3168 | pVBInfo->Set_VGAType = HwDeviceExtension->jChipType; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3169 | } |
| 3170 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 3171 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3172 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3173 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3174 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3175 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3176 | tempbx = VB_XGI302B; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3177 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3178 | if (flag != 0x02) { |
| 3179 | tempbx = VB_XGI301; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3180 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3181 | if (flag >= 0xB0) { |
| 3182 | tempbx = VB_XGI301B; |
| 3183 | if (flag >= 0xC0) { |
| 3184 | tempbx = VB_XGI301C; |
| 3185 | if (flag >= 0xD0) { |
| 3186 | tempbx = VB_XGI301LV; |
| 3187 | if (flag >= 0xE0) { |
| 3188 | tempbx = VB_XGI302LV; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3189 | tempah = xgifb_reg_get( |
| 3190 | pVBInfo->Part4Port, |
| 3191 | 0x39); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3192 | if (tempah != 0xFF) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3193 | tempbx = |
| 3194 | VB_XGI301C; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3195 | } |
| 3196 | } |
| 3197 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3198 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3199 | if (tempbx & (VB_XGI301B | VB_XGI302B)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3200 | flag = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3201 | pVBInfo->Part4Port, |
| 3202 | 0x23); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3203 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3204 | if (!(flag & 0x02)) |
| 3205 | tempbx = tempbx | VB_NoLCD; |
| 3206 | } |
| 3207 | } |
| 3208 | } |
| 3209 | pVBInfo->VBType = tempbx; |
| 3210 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3211 | } |
| 3212 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3213 | void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 3214 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3215 | struct vb_device_info *pVBInfo) |
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 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3218 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3219 | if (ModeNo <= 0x13) |
| 3220 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 3221 | else |
| 3222 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3223 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3224 | pVBInfo->SetFlag = 0; |
| 3225 | pVBInfo->ModeType = modeflag & ModeInfoFlag; |
| 3226 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3227 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3228 | if (pVBInfo->VBType & 0xFFFF) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3229 | /* Check Display Device */ |
| 3230 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3231 | tempbx = tempbx | temp; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3232 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3233 | push = temp; |
| 3234 | push = push << 8; |
| 3235 | tempax = temp << 8; |
| 3236 | tempbx = tempbx | tempax; |
| 3237 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA |
| 3238 | | SetInSlaveMode | DisableCRT2Display); |
| 3239 | temp = 0xFFFF ^ temp; |
| 3240 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3241 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3242 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3243 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3244 | if (pVBInfo->IF_DEF_LCDA == 1) { |
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 ((pVBInfo->Set_VGAType >= XG20) |
| 3247 | || (pVBInfo->Set_VGAType >= XG40)) { |
| 3248 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3249 | /* if ((pVBInfo->VBType & VB_XGI302B) |
| 3250 | || (pVBInfo->VBType & VB_XGI301LV) |
| 3251 | || (pVBInfo->VBType & VB_XGI302LV) |
| 3252 | || (pVBInfo->VBType & VB_XGI301C)) |
| 3253 | */ |
| 3254 | if (pVBInfo->VBType & |
| 3255 | (VB_XGI302B | |
| 3256 | VB_XGI301LV | |
| 3257 | VB_XGI302LV | |
| 3258 | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3259 | if (temp & EnableDualEdge) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3260 | tempbx |= |
| 3261 | SetCRT2ToDualEdge; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3262 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3263 | if (temp & SetToLCDA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3264 | tempbx |= |
| 3265 | SetCRT2ToLCDA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3266 | } |
| 3267 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3268 | } |
| 3269 | } |
| 3270 | } |
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 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3273 | /* [Billy] 07/05/04 */ |
| 3274 | if (((pVBInfo->IF_DEF_LVDS == 0) && |
| 3275 | ((pVBInfo->VBType & VB_XGI301LV) || |
| 3276 | (pVBInfo->VBType & VB_XGI302LV) || |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3277 | (pVBInfo->VBType & VB_XGI301C)))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3278 | if (temp & SetYPbPr) { /* temp = CR38 */ |
| 3279 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3280 | /* shampoo add for new |
| 3281 | * scratch */ |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3282 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3283 | pVBInfo->P3d4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3284 | 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3285 | temp &= YPbPrMode; |
| 3286 | tempbx |= SetCRT2ToHiVisionTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3287 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3288 | if (temp != YPbPrMode1080i) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3289 | tempbx &= |
| 3290 | (~SetCRT2ToHiVisionTV); |
| 3291 | tempbx |= |
| 3292 | SetCRT2ToYPbPr; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3293 | } |
| 3294 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3295 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3296 | /* tempbx |= SetCRT2ToYPbPr; */ |
| 3297 | } |
| 3298 | } |
| 3299 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3300 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3301 | tempax = push; /* restore CR31 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3302 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3303 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3304 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3305 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 3306 | temp = 0x09FC; |
| 3307 | else |
| 3308 | temp = 0x097C; |
| 3309 | } else { |
| 3310 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 3311 | temp = 0x01FC; |
| 3312 | else |
| 3313 | temp = 0x017C; |
| 3314 | } |
| 3315 | } else { /* 3nd party chip */ |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3316 | temp = SetCRT2ToLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3317 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3318 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3319 | if (!(tempbx & temp)) { |
| 3320 | tempax |= DisableCRT2Display; |
| 3321 | tempbx = 0; |
| 3322 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3323 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3324 | if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ |
| 3325 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 3326 | if (tempbx & SetCRT2ToLCDA) { |
| 3327 | if (tempbx & SetSimuScanMode) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3328 | tempbx &= (~(SetCRT2ToLCD | |
| 3329 | SetCRT2ToRAMDAC | |
| 3330 | SwitchToCRT2)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3331 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3332 | tempbx &= (~(SetCRT2ToLCD | |
| 3333 | SetCRT2ToRAMDAC | |
| 3334 | SetCRT2ToTV | |
| 3335 | SwitchToCRT2)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3336 | } |
| 3337 | } |
| 3338 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3339 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3340 | /* shampoo add */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3341 | /* for driver abnormal */ |
| 3342 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3343 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 3344 | if (tempbx & SetCRT2ToRAMDAC) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3345 | tempbx &= (0xFF00 | |
| 3346 | SetCRT2ToRAMDAC | |
| 3347 | SwitchToCRT2 | |
| 3348 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3349 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3350 | } |
| 3351 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3352 | tempbx &= (~(SetCRT2ToRAMDAC | |
| 3353 | SetCRT2ToLCD | |
| 3354 | SetCRT2ToTV)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3355 | } |
| 3356 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3357 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3358 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 3359 | if (tempbx & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3360 | tempbx &= (0xFF00 | |
| 3361 | SetCRT2ToLCD | |
| 3362 | SwitchToCRT2 | |
| 3363 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3364 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3365 | } |
| 3366 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3367 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3368 | if (tempbx & SetCRT2ToSCART) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3369 | tempbx &= (0xFF00 | |
| 3370 | SetCRT2ToSCART | |
| 3371 | SwitchToCRT2 | |
| 3372 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3373 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
| 3374 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3375 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3376 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3377 | if (tempbx & SetCRT2ToYPbPr) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3378 | tempbx &= (0xFF00 | |
| 3379 | SwitchToCRT2 | |
| 3380 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 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_HiVision == 1) { |
| 3384 | if (tempbx & SetCRT2ToHiVisionTV) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3385 | tempbx &= (0xFF00 | |
| 3386 | SetCRT2ToHiVisionTV | |
| 3387 | SwitchToCRT2 | |
| 3388 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3389 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3390 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3391 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 3392 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) |
| 3393 | tempbx = DisableCRT2Display; |
| 3394 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3395 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3396 | if (!(tempbx & DisableCRT2Display)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3397 | if ((!(tempbx & DriverMode)) || |
| 3398 | (!(modeflag & CRT2Mode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3399 | if (pVBInfo->IF_DEF_LCDA == 1) { |
| 3400 | if (!(tempbx & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3401 | tempbx |= (SetInSlaveMode | |
| 3402 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3403 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3404 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3405 | if (pVBInfo->IF_DEF_VideoCapture == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3406 | if (((HwDeviceExtension->jChipType == |
| 3407 | XG40) && |
| 3408 | (pVBInfo->Set_VGAType == XG40)) || |
| 3409 | ((HwDeviceExtension->jChipType == |
| 3410 | XG41) && |
| 3411 | (pVBInfo->Set_VGAType == XG41)) || |
| 3412 | ((HwDeviceExtension->jChipType == |
| 3413 | XG42) && |
| 3414 | (pVBInfo->Set_VGAType == XG42)) || |
| 3415 | ((HwDeviceExtension->jChipType == |
| 3416 | XG45) && |
| 3417 | (pVBInfo->Set_VGAType == XG45))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3418 | if (ModeNo <= 13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3419 | if (!(tempbx & |
| 3420 | SetCRT2ToRAMDAC)) { |
| 3421 | /*CRT2 not need |
| 3422 | * to support*/ |
| 3423 | tempbx &= |
| 3424 | (0x00FF | |
| 3425 | (~SetInSlaveMode)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3426 | pVBInfo->SetFlag |
| 3427 | |= EnableVCMode; |
| 3428 | } |
| 3429 | } |
| 3430 | } |
| 3431 | } |
| 3432 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3433 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3434 | /* LCD+TV can't support in slave mode |
| 3435 | * (Force LCDA+TV->LCDB) */ |
| 3436 | if ((tempbx & SetInSlaveMode) && |
| 3437 | (tempbx & SetCRT2ToLCDA)) { |
| 3438 | tempbx ^= (SetCRT2ToLCD | |
| 3439 | SetCRT2ToLCDA | |
| 3440 | SetCRT2ToDualEdge); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3441 | pVBInfo->SetFlag |= ReserveTVOption; |
| 3442 | } |
| 3443 | } |
| 3444 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3445 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3446 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3447 | } |
| 3448 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3449 | void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 3450 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3451 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3452 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3453 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3454 | tempbx = 0; |
| 3455 | resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3456 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3457 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3458 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3459 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 3460 | St_ModeFlag; /* si+St_ModeFlag */ |
| 3461 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 3462 | St_ResInfo; /* si+St_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3463 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3464 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 3465 | Ext_ModeFlag; |
| 3466 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 3467 | Ext_RESINFO; /* si+Ext_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3468 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3469 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3470 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3471 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3472 | tempbx = temp; |
| 3473 | if (tempbx & SetPALTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3474 | tempbx &= (SetCHTVOverScan | |
| 3475 | SetPALMTV | |
| 3476 | SetPALNTV | |
| 3477 | SetPALTV); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3478 | if (tempbx & SetPALMTV) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3479 | /* set to NTSC if PAL-M */ |
| 3480 | tempbx &= ~SetPALTV; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3481 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3482 | tempbx &= (SetCHTVOverScan | |
| 3483 | SetNTSCJ | |
| 3484 | SetPALTV); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3485 | /* |
| 3486 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3487 | //PAL-M/PAL-N Info |
| 3488 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
| 3489 | //00:PAL, 01:PAL-M, 10:PAL-N |
| 3490 | temp2 = (index1 & 0xC0) >> 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3491 | tempbx |= temp2; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3492 | if (temp2 & 0x02) //PAL-M |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3493 | tempbx &= (~SetPALTV); |
| 3494 | } |
| 3495 | */ |
| 3496 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3497 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3498 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3499 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 3500 | tempbx |= SetPALTV; |
| 3501 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3502 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3503 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3504 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3505 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3506 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3507 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3508 | if (index1 == YPbPrMode525i) |
| 3509 | tempbx |= SetYPbPrMode525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3510 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3511 | if (index1 == YPbPrMode525p) |
| 3512 | tempbx = tempbx | SetYPbPrMode525p; |
| 3513 | if (index1 == YPbPrMode750p) |
| 3514 | tempbx = tempbx | SetYPbPrMode750p; |
| 3515 | } |
| 3516 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3517 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3518 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 3519 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 3520 | tempbx = tempbx | SetYPbPrMode1080i | SetPALTV; |
| 3521 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3522 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3523 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3524 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 3525 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3526 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3527 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3528 | if (!(tempbx & SetPALTV) && |
| 3529 | (modeflag > 13) && |
| 3530 | (resinfo == 8)) /* NTSC 1024x768, */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3531 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3532 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3533 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3534 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3535 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 3536 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 3537 | tempbx &= (~RPLLDIV2XO); |
| 3538 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3539 | if (tempbx & |
| 3540 | (SetYPbPrMode525p | SetYPbPrMode750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3541 | tempbx &= (~RPLLDIV2XO); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3542 | else if (!(pVBInfo->VBType & |
| 3543 | (VB_XGI301B | |
| 3544 | VB_XGI302B | |
| 3545 | VB_XGI301LV | |
| 3546 | VB_XGI302LV | |
| 3547 | VB_XGI301C))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3548 | if (tempbx & TVSimuMode) |
| 3549 | tempbx &= (~RPLLDIV2XO); |
| 3550 | } |
| 3551 | } |
| 3552 | } |
| 3553 | } |
| 3554 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3555 | } |
| 3556 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 3557 | unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3558 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3559 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3560 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3561 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3562 | pVBInfo->LCDResInfo = 0; |
| 3563 | pVBInfo->LCDTypeInfo = 0; |
| 3564 | pVBInfo->LCDInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3565 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3566 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3567 | /* si+St_ModeFlag // */ |
| 3568 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3569 | } else { |
| 3570 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3571 | /* si+Ext_ResInfo // */ |
| 3572 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3573 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3574 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3575 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3576 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3577 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3578 | if (tempbx == 0) |
| 3579 | tempbx = Panel1024x768; /* default */ |
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 | /* LCD75 [2003/8/22] Vicent */ |
| 3582 | if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) { |
| 3583 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3584 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3585 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 3586 | tempax &= 0x0F; |
| 3587 | else |
| 3588 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3589 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3590 | if ((resinfo == 6) || (resinfo == 9)) { |
| 3591 | if (tempax >= 3) |
| 3592 | tempbx |= PanelRef75Hz; |
| 3593 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 3594 | if (tempax >= 4) |
| 3595 | tempbx |= PanelRef75Hz; |
| 3596 | } |
| 3597 | } |
| 3598 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3600 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3601 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3602 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3603 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3604 | if (pVBInfo->IF_DEF_OEMUtil == 1) |
| 3605 | pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3606 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3607 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 3608 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3609 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3610 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3611 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3612 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
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 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3615 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3616 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding)) |
| 3617 | temp &= ~EnableScalingLCD; |
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 | tempbx |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3620 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3621 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3622 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3623 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3624 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3625 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
| 3626 | if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType |
| 3627 | & VB_XGI301C)) && (tempax & LCDDualLink)) { |
| 3628 | tempbx |= SetLCDDualLink; |
| 3629 | } |
| 3630 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3631 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3632 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3633 | if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo |
| 3634 | & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo |
| 3635 | == 9) && (!(tempbx & EnableScalingLCD))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3636 | /* set to center in 1280x1024 LCDB for Panel1400x1050 */ |
| 3637 | tempbx |= SetLCDtoNonExpanding; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3638 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3639 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3640 | /* |
| 3641 | if (tempax & LCDBToA) { |
| 3642 | tempbx |= SetLCDBToA; |
| 3643 | } |
| 3644 | */ |
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->IF_DEF_ExpLink == 1) { |
| 3647 | if (modeflag & HalfDCLK) { |
| 3648 | /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */ |
| 3649 | if (!(tempbx & SetLCDtoNonExpanding)) { |
| 3650 | tempbx |= EnableLVDSDDA; |
| 3651 | } else { |
| 3652 | if (ModeNo > 0x13) { |
| 3653 | if (pVBInfo->LCDResInfo |
| 3654 | == Panel1024x768) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3655 | if (resinfo == 4) {/* 512x384 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3656 | tempbx |= EnableLVDSDDA; |
| 3657 | } |
| 3658 | } |
| 3659 | } |
| 3660 | } |
| 3661 | } |
| 3662 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3663 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3664 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3665 | if (pVBInfo->VBInfo & SetNotSimuMode) |
| 3666 | tempbx |= LCDVESATiming; |
| 3667 | } else { |
| 3668 | tempbx |= LCDVESATiming; |
| 3669 | } |
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 | pVBInfo->LCDInfo = tempbx; |
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 | if (pVBInfo->IF_DEF_PWD == 1) { |
| 3674 | if (pVBInfo->LCDInfo & SetPWDEnable) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3675 | if ((pVBInfo->VBType & VB_XGI302LV) || |
| 3676 | (pVBInfo->VBType & VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3677 | if (!(tempax & PWDEnable)) |
| 3678 | pVBInfo->LCDInfo &= ~SetPWDEnable; |
| 3679 | } |
| 3680 | } |
| 3681 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3682 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3683 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3684 | if (tempax & (LockLCDBToA | StLCDBToA)) { |
| 3685 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3686 | if (!(tempax & LockLCDBToA)) { |
| 3687 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3688 | pVBInfo->VBInfo &= |
| 3689 | ~(SetSimuScanMode | |
| 3690 | SetInSlaveMode | |
| 3691 | SetCRT2ToLCD); |
| 3692 | pVBInfo->VBInfo |= |
| 3693 | SetCRT2ToLCDA | |
| 3694 | SetCRT2ToDualEdge; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3695 | } |
| 3696 | } |
| 3697 | } |
| 3698 | } |
| 3699 | } |
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 | /* |
| 3702 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3703 | if (tempax & (LockLCDBToA | StLCDBToA)) { |
| 3704 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3705 | if (!((!(tempax & LockLCDBToA)) && |
| 3706 | (ModeNo > 0x13))) { |
| 3707 | pVBInfo->VBInfo &= |
| 3708 | ~(SetSimuScanMode | |
| 3709 | SetInSlaveMode | |
| 3710 | SetCRT2ToLCD); |
| 3711 | pVBInfo->VBInfo |= |
| 3712 | SetCRT2ToLCDA | |
| 3713 | SetCRT2ToDualEdge; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3714 | } |
| 3715 | } |
| 3716 | } |
| 3717 | } |
| 3718 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3719 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3720 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3721 | } |
| 3722 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 3723 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3724 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3725 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3726 | if (ModeNo <= 5) |
| 3727 | ModeNo |= 1; |
| 3728 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3729 | /* for (*ModeIdIndex=0; |
| 3730 | *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) |
| 3731 | / sizeof(struct XGI_StStruct); |
| 3732 | (*ModeIdIndex)++) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3733 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3734 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
| 3735 | ModeNo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3736 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3737 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
| 3738 | 0xFF) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3739 | return 0; |
| 3740 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3741 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3742 | if (ModeNo == 0x07) |
| 3743 | (*ModeIdIndex)++; /* 400 lines */ |
| 3744 | if (ModeNo <= 3) |
| 3745 | (*ModeIdIndex) += 2; /* 400 lines */ |
| 3746 | /* else 350 lines */ |
| 3747 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3748 | /* for (*ModeIdIndex=0; |
| 3749 | *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) |
| 3750 | / sizeof(struct XGI_ExtStruct); |
| 3751 | (*ModeIdIndex)++) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3752 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3753 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
| 3754 | ModeNo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3755 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3756 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
| 3757 | 0xFF) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3758 | return 0; |
| 3759 | } |
| 3760 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3761 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3762 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3763 | } |
| 3764 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3765 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 3766 | { |
| 3767 | unsigned char ujRet = 0; |
| 3768 | unsigned char i = 0; |
| 3769 | |
| 3770 | for (i = 0; i < 8; i++) { |
| 3771 | ujRet = ujRet << 1; |
| 3772 | /* ujRet |= GETBITS(ujDate >> i, 0:0); */ |
| 3773 | ujRet |= (ujDate >> i) & 1; |
| 3774 | } |
| 3775 | |
| 3776 | return ujRet; |
| 3777 | } |
| 3778 | |
| 3779 | /*----------------------------------------------------------------------------*/ |
| 3780 | /* output */ |
| 3781 | /* bl[5] : LVDS signal */ |
| 3782 | /* bl[1] : LVDS backlight */ |
| 3783 | /* bl[0] : LVDS VDD */ |
| 3784 | /*----------------------------------------------------------------------------*/ |
| 3785 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 3786 | { |
| 3787 | unsigned char CR4A, temp; |
| 3788 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3789 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3790 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3791 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3792 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3793 | |
| 3794 | temp = XG21GPIODataTransfer(temp); |
| 3795 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3796 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3797 | return temp; |
| 3798 | } |
| 3799 | |
| 3800 | /*----------------------------------------------------------------------------*/ |
| 3801 | /* output */ |
| 3802 | /* bl[5] : LVDS signal */ |
| 3803 | /* bl[1] : LVDS backlight */ |
| 3804 | /* bl[0] : LVDS VDD */ |
| 3805 | /*----------------------------------------------------------------------------*/ |
| 3806 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 3807 | { |
| 3808 | unsigned char CR4A, CRB4, temp; |
| 3809 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3810 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3811 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3812 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3813 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3814 | |
| 3815 | temp &= 0x0C; |
| 3816 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3817 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3818 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3819 | temp |= ((CRB4 & 0x04) << 3); |
| 3820 | return temp; |
| 3821 | } |
| 3822 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3823 | void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, |
| 3824 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3825 | { |
| 3826 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3827 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3828 | if (pXGIHWDE->jChipType == XG21) { |
| 3829 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 3830 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3831 | /* LVDS VDD on */ |
| 3832 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3833 | XGI_XG21SetPanelDelay(2, pVBInfo); |
| 3834 | } |
| 3835 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3836 | /* LVDS signal on */ |
| 3837 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3838 | XGI_XG21SetPanelDelay(3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3839 | /* LVDS backlight on */ |
| 3840 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3841 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3842 | /* DVO/DVI signal on */ |
| 3843 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3844 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3845 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3846 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3847 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3848 | if (pXGIHWDE->jChipType == XG27) { |
| 3849 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 3850 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3851 | /* LVDS VDD on */ |
| 3852 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3853 | XGI_XG21SetPanelDelay(2, pVBInfo); |
| 3854 | } |
| 3855 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3856 | /* LVDS signal on */ |
| 3857 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3858 | XGI_XG21SetPanelDelay(3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3859 | /* LVDS backlight on */ |
| 3860 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3861 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3862 | /* DVO/DVI signal on */ |
| 3863 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3864 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3865 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3866 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3867 | } |
| 3868 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3869 | void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, |
| 3870 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3871 | { |
| 3872 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3873 | if (pXGIHWDE->jChipType == XG21) { |
| 3874 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3875 | /* LVDS backlight off */ |
| 3876 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3877 | XGI_XG21SetPanelDelay(3, pVBInfo); |
| 3878 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3879 | /* DVO/DVI signal off */ |
| 3880 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3881 | } |
| 3882 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3883 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3884 | if (pXGIHWDE->jChipType == XG27) { |
| 3885 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3886 | /* LVDS backlight off */ |
| 3887 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3888 | XGI_XG21SetPanelDelay(3, pVBInfo); |
| 3889 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3890 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3891 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3892 | /* DVO/DVI signal off */ |
| 3893 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3894 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3895 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3896 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3897 | } |
| 3898 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3899 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3900 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3901 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3902 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3903 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3904 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3905 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3906 | } |
| 3907 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3908 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3909 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3910 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 3911 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3912 | } |
| 3913 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3914 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 3915 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3916 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3917 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3918 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3919 | /* reserve CR34 for CRT1 Mode No */ |
| 3920 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3921 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 3922 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3923 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3924 | } |
| 3925 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3926 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
| 3927 | unsigned short ModeIdIndex, |
| 3928 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3929 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3930 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3931 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3932 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 3933 | if (ModeNo <= 0x13) { |
| 3934 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 3935 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3936 | /* si+St_ResInfo */ |
| 3937 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3938 | } else { |
| 3939 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 3940 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3941 | /* si+St_ModeFlag */ |
| 3942 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3943 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3944 | /* |
| 3945 | if (pVBInfo->IF_DEF_FSTN) { |
| 3946 | xres *= 2; |
| 3947 | yres *= 2; |
| 3948 | } else { |
| 3949 | */ |
| 3950 | if (modeflag & HalfDCLK) |
| 3951 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3952 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3953 | if (modeflag & DoubleScanMode) |
| 3954 | yres *= 2; |
| 3955 | /* } */ |
| 3956 | } |
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 (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 3959 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3960 | if (pVBInfo->LCDResInfo == Panel1600x1200) { |
| 3961 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 3962 | if (yres == 1024) |
| 3963 | yres = 1056; |
| 3964 | } |
| 3965 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3966 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3967 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 3968 | if (yres == 400) |
| 3969 | yres = 405; |
| 3970 | else if (yres == 350) |
| 3971 | yres = 360; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3972 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3973 | if (pVBInfo->LCDInfo & LCDVESATiming) { |
| 3974 | if (yres == 360) |
| 3975 | yres = 375; |
| 3976 | } |
| 3977 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3978 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3979 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 3980 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 3981 | if (!(pVBInfo->LCDInfo |
| 3982 | & LCDNonExpanding)) { |
| 3983 | if (yres == 350) |
| 3984 | yres = 357; |
| 3985 | else if (yres == 400) |
| 3986 | yres = 420; |
| 3987 | else if (yres == 480) |
| 3988 | yres = 525; |
| 3989 | } |
| 3990 | } |
| 3991 | } |
| 3992 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3993 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3994 | if (xres == 720) |
| 3995 | xres = 640; |
| 3996 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3997 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3998 | pVBInfo->VGAHDE = xres; |
| 3999 | pVBInfo->HDE = xres; |
| 4000 | pVBInfo->VGAVDE = yres; |
| 4001 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4002 | } |
| 4003 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4004 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4005 | { |
| 4006 | |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 4007 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && |
| 4008 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4009 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4010 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4011 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4012 | } |
| 4013 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4014 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
| 4015 | unsigned short ModeIdIndex, |
| 4016 | unsigned short RefreshRateTableIndex, |
| 4017 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4018 | { |
| 4019 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
| 4020 | StandTableIndex, CRT1Index; |
| 4021 | |
| 4022 | pVBInfo->RVBHCMAX = 1; |
| 4023 | pVBInfo->RVBHCFACT = 1; |
| 4024 | |
| 4025 | if (ModeNo <= 0x13) { |
| 4026 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 4027 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
| 4028 | tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0]; |
| 4029 | tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6]; |
| 4030 | temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
| 4031 | } else { |
| 4032 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4033 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 4034 | Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4035 | CRT1Index &= IndexMask; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4036 | temp1 = (unsigned short) pVBInfo-> |
| 4037 | XGINEWUB_CRT1Table[CRT1Index].CR[0]; |
| 4038 | temp2 = (unsigned short) pVBInfo-> |
| 4039 | XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4040 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4041 | tempbx = (unsigned short) pVBInfo-> |
| 4042 | XGINEWUB_CRT1Table[CRT1Index].CR[8]; |
| 4043 | tempcx = (unsigned short) pVBInfo-> |
| 4044 | XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4045 | tempcx &= 0x0100; |
| 4046 | tempcx = tempcx << 2; |
| 4047 | tempbx |= tempcx; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4048 | temp1 = (unsigned short) pVBInfo-> |
| 4049 | XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | if (temp1 & 0x01) |
| 4053 | tempbx |= 0x0100; |
| 4054 | |
| 4055 | if (temp1 & 0x20) |
| 4056 | tempbx |= 0x0200; |
| 4057 | tempax += 5; |
| 4058 | |
| 4059 | if (modeflag & Charx8Dot) |
| 4060 | tempax *= 8; |
| 4061 | else |
| 4062 | tempax *= 9; |
| 4063 | |
| 4064 | pVBInfo->VGAHT = tempax; |
| 4065 | pVBInfo->HT = tempax; |
| 4066 | tempbx++; |
| 4067 | pVBInfo->VGAVT = tempbx; |
| 4068 | pVBInfo->VT = tempbx; |
| 4069 | } |
| 4070 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4071 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4072 | unsigned short RefreshRateTableIndex, |
| 4073 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4074 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4075 | unsigned short tempax = 0, tempbx, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4076 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4077 | struct XGI_LCDDataStruct *LCDPtr = NULL; |
| 4078 | struct XGI_TVDataStruct *TVPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4079 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4080 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4081 | /* si+St_ResInfo */ |
| 4082 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4083 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4084 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4085 | /* si+Ext_ResInfo */ |
| 4086 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4087 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4088 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4089 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4090 | pVBInfo->NewFlickerMode = 0; |
| 4091 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4092 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4093 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4094 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4095 | pVBInfo); |
| 4096 | return; |
| 4097 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4098 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4099 | tempbx = 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4100 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4101 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 4102 | LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx, |
| 4103 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4104 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4105 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4106 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 4107 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 4108 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 4109 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 4110 | pVBInfo->HT = LCDPtr->LCDHT; |
| 4111 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4112 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4113 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 4114 | tempax = 1024; |
| 4115 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4116 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4117 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4118 | if (pVBInfo->VGAVDE == 357) |
| 4119 | tempbx = 527; |
| 4120 | else if (pVBInfo->VGAVDE == 420) |
| 4121 | tempbx = 620; |
| 4122 | else if (pVBInfo->VGAVDE == 525) |
| 4123 | tempbx = 775; |
| 4124 | else if (pVBInfo->VGAVDE == 600) |
| 4125 | tempbx = 775; |
| 4126 | /* else if (pVBInfo->VGAVDE==350) tempbx=560; */ |
| 4127 | /* else if (pVBInfo->VGAVDE==400) tempbx=640; */ |
| 4128 | else |
| 4129 | tempbx = 768; |
| 4130 | } else |
| 4131 | tempbx = 768; |
| 4132 | } else if (pVBInfo->LCDResInfo == Panel1024x768x75) { |
| 4133 | tempax = 1024; |
| 4134 | tempbx = 768; |
| 4135 | } else if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 4136 | tempax = 1280; |
| 4137 | if (pVBInfo->VGAVDE == 360) |
| 4138 | tempbx = 768; |
| 4139 | else if (pVBInfo->VGAVDE == 375) |
| 4140 | tempbx = 800; |
| 4141 | else if (pVBInfo->VGAVDE == 405) |
| 4142 | tempbx = 864; |
| 4143 | else |
| 4144 | tempbx = 1024; |
| 4145 | } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) { |
| 4146 | tempax = 1280; |
| 4147 | tempbx = 1024; |
| 4148 | } else if (pVBInfo->LCDResInfo == Panel1280x960) { |
| 4149 | tempax = 1280; |
| 4150 | if (pVBInfo->VGAVDE == 350) |
| 4151 | tempbx = 700; |
| 4152 | else if (pVBInfo->VGAVDE == 400) |
| 4153 | tempbx = 800; |
| 4154 | else if (pVBInfo->VGAVDE == 1024) |
| 4155 | tempbx = 960; |
| 4156 | else |
| 4157 | tempbx = 960; |
| 4158 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { |
| 4159 | tempax = 1400; |
| 4160 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4161 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4162 | if (pVBInfo->VGAVDE == 1024) { |
| 4163 | tempax = 1280; |
| 4164 | tempbx = 1024; |
| 4165 | } |
| 4166 | } else if (pVBInfo->LCDResInfo == Panel1600x1200) { |
| 4167 | tempax = 1600; |
| 4168 | tempbx = 1200; /* alan 10/14/2003 */ |
| 4169 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4170 | if (pVBInfo->VGAVDE == 350) |
| 4171 | tempbx = 875; |
| 4172 | else if (pVBInfo->VGAVDE == 400) |
| 4173 | tempbx = 1000; |
| 4174 | } |
| 4175 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4176 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4177 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 4178 | tempax = pVBInfo->VGAHDE; |
| 4179 | tempbx = pVBInfo->VGAVDE; |
| 4180 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4181 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4182 | pVBInfo->HDE = tempax; |
| 4183 | pVBInfo->VDE = tempbx; |
| 4184 | return; |
| 4185 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4186 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4187 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
| 4188 | tempbx = 4; |
| 4189 | TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx, |
| 4190 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4191 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4192 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4193 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 4194 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 4195 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 4196 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 4197 | pVBInfo->HDE = TVPtr->TVHDE; |
| 4198 | pVBInfo->VDE = TVPtr->TVVDE; |
| 4199 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 4200 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4201 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4202 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4203 | if (resinfo == 0x08) |
| 4204 | pVBInfo->NewFlickerMode = 0x40; |
| 4205 | else if (resinfo == 0x09) |
| 4206 | pVBInfo->NewFlickerMode = 0x40; |
| 4207 | else if (resinfo == 0x12) |
| 4208 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4209 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4210 | if (pVBInfo->VGAVDE == 350) |
| 4211 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4212 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4213 | tempax = ExtHiTVHT; |
| 4214 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4215 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4216 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 4217 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4218 | tempax = StHiTVHT; |
| 4219 | tempbx = StHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4220 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4221 | if (!(modeflag & Charx8Dot)) { |
| 4222 | tempax = StHiTextTVHT; |
| 4223 | tempbx = StHiTextTVVT; |
| 4224 | } |
| 4225 | } |
| 4226 | } |
| 4227 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 4228 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
| 4229 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 4230 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 4231 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4232 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4233 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
| 4234 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 4235 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
| 4236 | } else if (pVBInfo->TVInfo & SetYPbPrMode525i) { |
| 4237 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 4238 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 4239 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 4240 | tempax = NTSC1024x768HT; |
| 4241 | } |
| 4242 | } else { |
| 4243 | tempax = PALHT; |
| 4244 | tempbx = PALVT; |
| 4245 | if (!(pVBInfo->TVInfo & SetPALTV)) { |
| 4246 | tempax = NTSCHT; |
| 4247 | tempbx = NTSCVT; |
| 4248 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 4249 | tempax = NTSC1024x768HT; |
| 4250 | } |
| 4251 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4252 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4253 | pVBInfo->HT = tempax; |
| 4254 | pVBInfo->VT = tempbx; |
| 4255 | return; |
| 4256 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4257 | } |
| 4258 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4259 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4260 | unsigned short RefreshRateTableIndex, |
| 4261 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4262 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 4263 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4264 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4265 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 4266 | pVBInfo); |
| 4267 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 4268 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4269 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4270 | if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */ |
| 4271 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4272 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 4273 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 4274 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4275 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4276 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 4277 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4278 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4279 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4280 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4281 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4282 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4283 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4284 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4285 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4286 | } |
| 4287 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4288 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
| 4289 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4290 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4291 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 4292 | short index; |
| 4293 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4294 | |
| 4295 | if (ModeNo <= 0x13) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4296 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4297 | else |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4298 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4299 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4300 | index = (modeflag & ModeInfoFlag) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4301 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4302 | if (index < 0) |
| 4303 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4304 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4305 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4306 | } |
| 4307 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4308 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 4309 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4310 | unsigned short RefreshRateTableIndex, |
| 4311 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4312 | struct vb_device_info *pVBInfo) |
| 4313 | { |
| 4314 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 4315 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 4316 | |
| 4317 | modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 4318 | if (ModeNo <= 0x14) |
| 4319 | infoflag = 0; |
| 4320 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4321 | infoflag = pVBInfo-> |
| 4322 | RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4323 | |
| 4324 | index = (modeinfo >> 8) & 0xFF; |
| 4325 | |
| 4326 | temp = pVBInfo->ScreenOffset[index]; |
| 4327 | |
| 4328 | if (infoflag & InterlaceMode) |
| 4329 | temp = temp << 1; |
| 4330 | |
| 4331 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 4332 | |
| 4333 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 4334 | temp = ModeNo - 0x7C; |
| 4335 | colordepth = ColorDepth[temp]; |
| 4336 | temp = 0x6B; |
| 4337 | if (infoflag & InterlaceMode) |
| 4338 | temp = temp << 1; |
| 4339 | return temp * colordepth; |
| 4340 | } else { |
| 4341 | return temp * colordepth; |
| 4342 | } |
| 4343 | } |
| 4344 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4345 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 4346 | unsigned short ModeIdIndex, |
| 4347 | unsigned short RefreshRateTableIndex, |
| 4348 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4349 | struct vb_device_info *pVBInfo) |
| 4350 | { |
| 4351 | unsigned short offset; |
| 4352 | unsigned char temp; |
| 4353 | |
| 4354 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 4355 | return; |
| 4356 | |
| 4357 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4358 | HwDeviceExtension, pVBInfo); |
| 4359 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4360 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4361 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4362 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4363 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4364 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4365 | } |
| 4366 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4367 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4368 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4369 | /* threshold high ,disable auto threshold */ |
| 4370 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 4371 | /* threshold low default 04h */ |
| 4372 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4373 | } |
| 4374 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4375 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4376 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4377 | unsigned short RefreshRateTableIndex, |
| 4378 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4379 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4380 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4381 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4382 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4383 | CRT1Index = pVBInfo-> |
| 4384 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4385 | CRT1Index &= IndexMask; |
| 4386 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4387 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4388 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4389 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4390 | HwDeviceExtension, pVBInfo); |
| 4391 | XGI_SetCRT2FIFO(pVBInfo); |
| 4392 | /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */ |
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 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4395 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4396 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4397 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 4398 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4399 | } |
| 4400 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4401 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4402 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4403 | unsigned short RefreshRateTableIndex, |
| 4404 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4405 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4406 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
| 4407 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4408 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4409 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4410 | CRT1Index = pVBInfo-> |
| 4411 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4412 | CRT1Index &= IndexMask; |
| 4413 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4414 | } |
| 4415 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4416 | if (ModeNo <= 0x13) |
| 4417 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 4418 | else |
| 4419 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4420 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4421 | /* bainy change table name */ |
| 4422 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4423 | /* BTVGA2HT 0x08,0x09 */ |
| 4424 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4425 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4426 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4427 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4428 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 4429 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4430 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4431 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 4432 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 4433 | tempcx = tempcx >> 1; |
| 4434 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 4435 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4436 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4437 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4438 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4439 | tempbx |= ((pVBInfo-> |
| 4440 | XGINEWUB_CRT1Table[CRT1Index].CR[14] & |
| 4441 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4442 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 4443 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
| 4444 | tempcx &= 0x1F; |
| 4445 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15]; |
| 4446 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 4447 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 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 | tempbx += 4; |
| 4451 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4452 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4453 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 4454 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4455 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4456 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4457 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4458 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4459 | } else { |
| 4460 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4461 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4462 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4463 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4464 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 4465 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4466 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4467 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 4468 | pushbx = pVBInfo->VGAHDE + 16; |
| 4469 | tempcx = tempcx >> 1; |
| 4470 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 4471 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4472 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4473 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4474 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4475 | tempbx |= ((pVBInfo-> |
| 4476 | XGINEWUB_CRT1Table[CRT1Index].CR[5] & |
| 4477 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4478 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 4479 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
| 4480 | tempcx &= 0x1F; |
| 4481 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6]; |
| 4482 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 4483 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 4484 | tempbx += 16; |
| 4485 | tempcx += 16; |
| 4486 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4487 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4488 | if (tempcx > pVBInfo->VGAHT) |
| 4489 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4490 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4491 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4492 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4493 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4494 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4495 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 4496 | tempbx = pushbx; |
| 4497 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 4498 | tempax |= (tempbx & 0xFF00); |
| 4499 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4500 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4501 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4502 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4503 | tempcx = (pVBInfo->VGAVT - 1); |
| 4504 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4505 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4506 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4507 | tempbx = pVBInfo->VGAVDE - 1; |
| 4508 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4509 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4510 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 4511 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4512 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4513 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4514 | tempax = pVBInfo->VGAVDE; |
| 4515 | tempbx = pVBInfo->VGAVDE; |
| 4516 | tempcx = pVBInfo->VGAVT; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4517 | /* BTVGA2VRS 0x10,0x11 */ |
| 4518 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 4519 | /* BTVGA2VRE 0x11 */ |
| 4520 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4521 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4522 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4523 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; |
| 4524 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4525 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4526 | if (temp & 0x04) |
| 4527 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4528 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4529 | if (temp & 0x080) |
| 4530 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4531 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4532 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4533 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4534 | if (temp & 0x08) |
| 4535 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4536 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4537 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; |
| 4538 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 4539 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4540 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4541 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4542 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4543 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 4544 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4545 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4546 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4547 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4548 | if (modeflag & DoubleScanMode) |
| 4549 | tempax |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4550 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4551 | if (modeflag & HalfDCLK) |
| 4552 | tempax |= 0x40; |
| 4553 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4554 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4555 | } |
| 4556 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4557 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 4558 | { |
| 4559 | unsigned long tempax, tempbx; |
| 4560 | |
| 4561 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 4562 | & 0xFFFF; |
| 4563 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 4564 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 4565 | |
| 4566 | return (unsigned short) tempax; |
| 4567 | } |
| 4568 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4569 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4570 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4571 | unsigned short RefreshRateTableIndex, |
| 4572 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4573 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4574 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
| 4575 | modeflag, CRT1Index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4576 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4577 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4578 | /* si+St_ResInfo */ |
| 4579 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4580 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4581 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4582 | /* si+Ext_ResInfo */ |
| 4583 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4584 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4585 | CRT1Index = pVBInfo-> |
| 4586 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4587 | CRT1Index &= IndexMask; |
| 4588 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4589 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4590 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 4591 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4592 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4593 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4594 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4595 | /* if (modeflag & Charx8Dot) */ |
| 4596 | /* tempcx = 0x08; */ |
| 4597 | /* else */ |
| 4598 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4600 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
| 4601 | modeflag |= Charx8Dot; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4602 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4603 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4604 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4605 | if (modeflag & HalfDCLK) |
| 4606 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4607 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4608 | tempax = (tempax / tempcx) - 1; |
| 4609 | tempbx |= ((tempax & 0x00FF) << 8); |
| 4610 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4611 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4612 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4613 | temp = (tempbx & 0xFF00) >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4614 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4615 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4616 | if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 4617 | | VB_XGI302LV | VB_XGI301C))) |
| 4618 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4619 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4620 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4621 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 4622 | if (pVBInfo->VBExtInfo == VB_YPbPr1080i) { |
| 4623 | if (resinfo == 7) |
| 4624 | temp -= 2; |
| 4625 | } |
| 4626 | } else if (resinfo == 7) { |
| 4627 | temp -= 2; |
| 4628 | } |
| 4629 | } |
| 4630 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4631 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4632 | /* 0x05 Horizontal Display Start */ |
| 4633 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 4634 | /* 0x06 Horizontal Blank end */ |
| 4635 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4636 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4637 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 4638 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 4639 | tempax = pVBInfo->VGAHT; |
| 4640 | else |
| 4641 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 4642 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4643 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4644 | if (tempax >= pVBInfo->VGAHT) |
| 4645 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4646 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4647 | if (modeflag & HalfDCLK) |
| 4648 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4649 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4650 | tempax = (tempax / tempcx) - 5; |
| 4651 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
| 4652 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4653 | temp = (tempbx & 0x00FF) - 1; |
| 4654 | if (!(modeflag & HalfDCLK)) { |
| 4655 | temp -= 6; |
| 4656 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4657 | temp -= 4; |
| 4658 | if (ModeNo > 0x13) |
| 4659 | temp -= 10; |
| 4660 | } |
| 4661 | } |
| 4662 | } else { |
| 4663 | /* tempcx = tempbx & 0x00FF ; */ |
| 4664 | tempbx = (tempbx & 0xFF00) >> 8; |
| 4665 | tempcx = (tempcx + tempbx) >> 1; |
| 4666 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4667 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4668 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4669 | temp -= 1; |
| 4670 | if (!(modeflag & HalfDCLK)) { |
| 4671 | if ((modeflag & Charx8Dot)) { |
| 4672 | temp += 4; |
| 4673 | if (pVBInfo->VGAHDE >= 800) |
| 4674 | temp -= 6; |
| 4675 | } |
| 4676 | } |
| 4677 | } else { |
| 4678 | if (!(modeflag & HalfDCLK)) { |
| 4679 | temp -= 4; |
| 4680 | if (pVBInfo->LCDResInfo != Panel1280x960) { |
| 4681 | if (pVBInfo->VGAHDE >= 800) { |
| 4682 | temp -= 7; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4683 | if (pVBInfo->ModeType == |
| 4684 | ModeEGA) { |
| 4685 | if (pVBInfo->VGAVDE == |
| 4686 | 1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4687 | temp += 15; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4688 | if (pVBInfo->LCDResInfo != Panel1280x1024) { |
| 4689 | temp += |
| 4690 | 7; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4691 | } |
| 4692 | } |
| 4693 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4694 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4695 | if (pVBInfo->VGAHDE >= 1280) { |
| 4696 | if (pVBInfo->LCDResInfo |
| 4697 | != Panel1280x960) { |
| 4698 | if (pVBInfo->LCDInfo |
| 4699 | & LCDNonExpanding) { |
| 4700 | temp |
| 4701 | += 28; |
| 4702 | } |
| 4703 | } |
| 4704 | } |
| 4705 | } |
| 4706 | } |
| 4707 | } |
| 4708 | } |
| 4709 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4710 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4711 | /* 0x07 Horizontal Retrace Start */ |
| 4712 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 4713 | /* 0x08 Horizontal Retrace End */ |
| 4714 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4715 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4716 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4717 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4718 | if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo |
| 4719 | == 0x11) || (ModeNo == 0x13) || (ModeNo |
| 4720 | == 0x0F)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4721 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b); |
| 4722 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4723 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4724 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4725 | if ((ModeNo == 0x00) || (ModeNo == 0x01)) { |
| 4726 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4727 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4728 | 0x07, 0x2A); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4729 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4730 | 0x08, 0x61); |
| 4731 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4732 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4733 | 0x07, 0x2A); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4734 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4735 | 0x08, 0x41); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4736 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4737 | 0x0C, 0xF0); |
| 4738 | } |
| 4739 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4740 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4741 | if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo |
| 4742 | == 0x07)) { |
| 4743 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4744 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4745 | 0x07, 0x54); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4746 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4747 | 0x08, 0x00); |
| 4748 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4749 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4750 | 0x07, 0x55); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4751 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4752 | 0x08, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4753 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4754 | 0x0C, 0xF0); |
| 4755 | } |
| 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 | if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo |
| 4759 | == 0x0D) || (ModeNo == 0x50)) { |
| 4760 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4761 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4762 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4763 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4764 | 0x08, 0x03); |
| 4765 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4766 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4767 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4768 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4769 | 0x08, 0x02); |
| 4770 | } |
| 4771 | } |
| 4772 | } |
| 4773 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4774 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4775 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4776 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4777 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4778 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4779 | tempbx = pVBInfo->VGAVT; |
| 4780 | push1 = tempbx; |
| 4781 | tempcx = 0x121; |
| 4782 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4783 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4784 | if (tempbx == 357) |
| 4785 | tempbx = 350; |
| 4786 | if (tempbx == 360) |
| 4787 | tempbx = 350; |
| 4788 | if (tempbx == 375) |
| 4789 | tempbx = 350; |
| 4790 | if (tempbx == 405) |
| 4791 | tempbx = 400; |
| 4792 | if (tempbx == 525) |
| 4793 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4794 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4795 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4796 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4797 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4798 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
| 4799 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 4800 | if (tempbx == 350) |
| 4801 | tempbx += 5; |
| 4802 | if (tempbx == 480) |
| 4803 | tempbx += 5; |
| 4804 | } |
| 4805 | } |
| 4806 | } |
| 4807 | tempbx--; |
| 4808 | temp = tempbx & 0x00FF; |
| 4809 | tempbx--; |
| 4810 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4811 | /* 0x10 vertical Blank Start */ |
| 4812 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4813 | tempbx = push2; |
| 4814 | tempbx--; |
| 4815 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4816 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4817 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4818 | if (tempbx & 0x0100) |
| 4819 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4820 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4821 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4822 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4823 | if (modeflag & DoubleScanMode) |
| 4824 | tempax |= 0x08000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4825 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4826 | if (tempbx & 0x0200) |
| 4827 | tempcx |= 0x0040; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4828 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4829 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4830 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
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 (tempbx & 0x0400) |
| 4833 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4834 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4835 | /* 0x11 Vertival Blank End */ |
| 4836 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4837 | |
| 4838 | tempax = push1; |
| 4839 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 4840 | tempax = tempax >> 2; |
| 4841 | push1 = tempax; /* push ax */ |
| 4842 | |
| 4843 | if (resinfo != 0x09) { |
| 4844 | tempax = tempax << 1; |
| 4845 | tempbx += tempax; |
| 4846 | } |
| 4847 | |
| 4848 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 4849 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 4850 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 4851 | tempbx -= 10; |
| 4852 | } else { |
| 4853 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4854 | if (pVBInfo->TVInfo & SetPALTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4855 | if (pVBInfo->VBType & |
| 4856 | VB_XGI301LV) { |
| 4857 | if (!(pVBInfo->TVInfo & |
| 4858 | (SetYPbPrMode525p | |
| 4859 | SetYPbPrMode750p | |
| 4860 | SetYPbPrMode1080i))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4861 | tempbx += 40; |
| 4862 | } else { |
| 4863 | tempbx += 40; |
| 4864 | } |
| 4865 | } |
| 4866 | } |
| 4867 | } |
| 4868 | } else { |
| 4869 | tempbx -= 10; |
| 4870 | } |
| 4871 | } else { |
| 4872 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4873 | if (pVBInfo->TVInfo & SetPALTV) { |
| 4874 | if (pVBInfo->VBType & VB_XGI301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4875 | if (!(pVBInfo->TVInfo & |
| 4876 | (SetYPbPrMode525p | |
| 4877 | SetYPbPrMode750p | |
| 4878 | SetYPbPrMode1080i))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4879 | tempbx += 40; |
| 4880 | } else { |
| 4881 | tempbx += 40; |
| 4882 | } |
| 4883 | } |
| 4884 | } |
| 4885 | } |
| 4886 | tempax = push1; |
| 4887 | tempax = tempax >> 2; |
| 4888 | tempax++; |
| 4889 | tempax += tempbx; |
| 4890 | push1 = tempax; /* push ax */ |
| 4891 | |
| 4892 | if ((pVBInfo->TVInfo & SetPALTV)) { |
| 4893 | if (tempbx <= 513) { |
| 4894 | if (tempax >= 513) |
| 4895 | tempbx = 513; |
| 4896 | } |
| 4897 | } |
| 4898 | |
| 4899 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4900 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4901 | tempbx--; |
| 4902 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4903 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4904 | |
| 4905 | if (tempbx & 0x0100) |
| 4906 | tempcx |= 0x0008; |
| 4907 | |
| 4908 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4909 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4910 | |
| 4911 | tempbx++; |
| 4912 | |
| 4913 | if (tempbx & 0x0100) |
| 4914 | tempcx |= 0x0004; |
| 4915 | |
| 4916 | if (tempbx & 0x0200) |
| 4917 | tempcx |= 0x0080; |
| 4918 | |
| 4919 | if (tempbx & 0x0400) |
| 4920 | tempcx |= 0x0C00; |
| 4921 | |
| 4922 | tempbx = push1; /* pop ax */ |
| 4923 | temp = tempbx & 0x00FF; |
| 4924 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4925 | /* 0x0D vertical Retrace End */ |
| 4926 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4927 | |
| 4928 | if (tempbx & 0x0010) |
| 4929 | tempcx |= 0x2000; |
| 4930 | |
| 4931 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4932 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4933 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4934 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4935 | tempax = modeflag; |
| 4936 | temp = (tempax & 0xFF00) >> 8; |
| 4937 | |
| 4938 | temp = (temp >> 1) & 0x09; |
| 4939 | |
| 4940 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
| 4941 | temp |= 0x01; |
| 4942 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4943 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 4944 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 4945 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4946 | |
| 4947 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 4948 | temp = 0x80; |
| 4949 | else |
| 4950 | temp = 0x00; |
| 4951 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4952 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4953 | |
| 4954 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4955 | } |
| 4956 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4957 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4958 | unsigned short RefreshRateTableIndex, |
| 4959 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4960 | struct vb_device_info *pVBInfo) |
| 4961 | { |
| 4962 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
| 4963 | modeflag, resinfo, crt2crtc; |
| 4964 | unsigned char *TimingPoint; |
| 4965 | |
| 4966 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 4967 | |
| 4968 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4969 | /* si+St_ResInfo */ |
| 4970 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4971 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4972 | crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 4973 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4974 | /* si+Ext_ResInfo */ |
| 4975 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4976 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4977 | crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 4978 | Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4979 | } |
| 4980 | |
| 4981 | tempax = 0; |
| 4982 | |
| 4983 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 4984 | tempax |= 0x0800; |
| 4985 | |
| 4986 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 4987 | tempax |= 0x0400; |
| 4988 | |
| 4989 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 4990 | tempax |= 0x0200; |
| 4991 | |
| 4992 | if (!(pVBInfo->TVInfo & SetPALTV)) |
| 4993 | tempax |= 0x1000; |
| 4994 | |
| 4995 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 4996 | tempax |= 0x0100; |
| 4997 | |
| 4998 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
| 4999 | tempax &= 0xfe00; |
| 5000 | |
| 5001 | tempax = (tempax & 0xff00) >> 8; |
| 5002 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5003 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5004 | TimingPoint = pVBInfo->NTSCTiming; |
| 5005 | |
| 5006 | if (pVBInfo->TVInfo & SetPALTV) |
| 5007 | TimingPoint = pVBInfo->PALTiming; |
| 5008 | |
| 5009 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5010 | TimingPoint = pVBInfo->HiTVExtTiming; |
| 5011 | |
| 5012 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 5013 | TimingPoint = pVBInfo->HiTVSt2Timing; |
| 5014 | |
| 5015 | if (pVBInfo->SetFlag & TVSimuMode) |
| 5016 | TimingPoint = pVBInfo->HiTVSt1Timing; |
| 5017 | |
| 5018 | if (!(modeflag & Charx8Dot)) |
| 5019 | TimingPoint = pVBInfo->HiTVTextTiming; |
| 5020 | } |
| 5021 | |
| 5022 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5023 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5024 | TimingPoint = pVBInfo->YPbPr525iTiming; |
| 5025 | |
| 5026 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5027 | TimingPoint = pVBInfo->YPbPr525pTiming; |
| 5028 | |
| 5029 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5030 | TimingPoint = pVBInfo->YPbPr750pTiming; |
| 5031 | } |
| 5032 | |
| 5033 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5034 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5035 | |
| 5036 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5037 | /* di->temp2[j] */ |
| 5038 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5039 | |
| 5040 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5041 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5042 | |
| 5043 | temp = pVBInfo->NewFlickerMode; |
| 5044 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5045 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5046 | |
| 5047 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5048 | tempax = 950; |
| 5049 | |
| 5050 | if (pVBInfo->TVInfo & SetPALTV) |
| 5051 | tempax = 520; |
| 5052 | else |
| 5053 | tempax = 440; |
| 5054 | |
| 5055 | if (pVBInfo->VDE <= tempax) { |
| 5056 | tempax -= pVBInfo->VDE; |
| 5057 | tempax = tempax >> 2; |
| 5058 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 5059 | push1 = tempax; |
| 5060 | temp = (tempax & 0xFF00) >> 8; |
| 5061 | temp += (unsigned short) TimingPoint[0]; |
| 5062 | |
| 5063 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5064 | | VB_XGI302LV | VB_XGI301C)) { |
| 5065 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 5066 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
| 5067 | | SetCRT2ToYPbPr)) { |
| 5068 | tempcx = pVBInfo->VGAHDE; |
| 5069 | if (tempcx >= 1024) { |
| 5070 | temp = 0x17; /* NTSC */ |
| 5071 | if (pVBInfo->TVInfo & SetPALTV) |
| 5072 | temp = 0x19; /* PAL */ |
| 5073 | } |
| 5074 | } |
| 5075 | } |
| 5076 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5077 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5078 | tempax = push1; |
| 5079 | temp = (tempax & 0xFF00) >> 8; |
| 5080 | temp += TimingPoint[1]; |
| 5081 | |
| 5082 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5083 | | VB_XGI302LV | VB_XGI301C)) { |
| 5084 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 5085 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
| 5086 | | SetCRT2ToYPbPr))) { |
| 5087 | tempcx = pVBInfo->VGAHDE; |
| 5088 | if (tempcx >= 1024) { |
| 5089 | temp = 0x1D; /* NTSC */ |
| 5090 | if (pVBInfo->TVInfo & SetPALTV) |
| 5091 | temp = 0x52; /* PAL */ |
| 5092 | } |
| 5093 | } |
| 5094 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5095 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5096 | } |
| 5097 | |
| 5098 | /* 301b */ |
| 5099 | tempcx = pVBInfo->HT; |
| 5100 | |
| 5101 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5102 | tempcx = tempcx >> 1; |
| 5103 | |
| 5104 | tempcx -= 2; |
| 5105 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5106 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5107 | |
| 5108 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5109 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5110 | |
| 5111 | tempcx = pVBInfo->HT >> 1; |
| 5112 | push1 = tempcx; /* push cx */ |
| 5113 | tempcx += 7; |
| 5114 | |
| 5115 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5116 | tempcx -= 4; |
| 5117 | |
| 5118 | temp = tempcx & 0x00FF; |
| 5119 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5120 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5121 | |
| 5122 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 5123 | tempbx += tempcx; |
| 5124 | push2 = tempbx; |
| 5125 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5126 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5127 | temp = (tempbx & 0xFF00) >> 8; |
| 5128 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5129 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5130 | |
| 5131 | tempbx = push2; |
| 5132 | tempbx = tempbx + 8; |
| 5133 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5134 | tempbx = tempbx - 4; |
| 5135 | tempcx = tempbx; |
| 5136 | } |
| 5137 | |
| 5138 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5139 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5140 | |
| 5141 | j += 2; |
| 5142 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 5143 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5144 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5145 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5146 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5147 | |
| 5148 | tempcx += 8; |
| 5149 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5150 | tempcx -= 4; |
| 5151 | |
| 5152 | temp = tempcx & 0xFF; |
| 5153 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5154 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5155 | |
| 5156 | tempcx = push1; /* pop cx */ |
| 5157 | j += 2; |
| 5158 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 5159 | tempcx -= temp; |
| 5160 | temp = tempcx & 0x00FF; |
| 5161 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5162 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5163 | |
| 5164 | tempcx -= 11; |
| 5165 | |
| 5166 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 5167 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 5168 | tempcx = tempax - 1; |
| 5169 | } |
| 5170 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5171 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5172 | |
| 5173 | tempbx = pVBInfo->VDE; |
| 5174 | |
| 5175 | if (pVBInfo->VGAVDE == 360) |
| 5176 | tempbx = 746; |
| 5177 | if (pVBInfo->VGAVDE == 375) |
| 5178 | tempbx = 746; |
| 5179 | if (pVBInfo->VGAVDE == 405) |
| 5180 | tempbx = 853; |
| 5181 | |
| 5182 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5183 | if (pVBInfo->VBType & |
| 5184 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
| 5185 | if (!(pVBInfo->TVInfo & |
| 5186 | (SetYPbPrMode525p | SetYPbPrMode750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5187 | tempbx = tempbx >> 1; |
| 5188 | } else |
| 5189 | tempbx = tempbx >> 1; |
| 5190 | } |
| 5191 | |
| 5192 | tempbx -= 2; |
| 5193 | temp = tempbx & 0x00FF; |
| 5194 | |
| 5195 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5196 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 5197 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 5198 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5199 | if (ModeNo == 0x2f) |
| 5200 | temp += 1; |
| 5201 | } |
| 5202 | } |
| 5203 | } else { |
| 5204 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5205 | if (ModeNo == 0x2f) |
| 5206 | temp += 1; |
| 5207 | } |
| 5208 | } |
| 5209 | } |
| 5210 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5211 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5212 | |
| 5213 | temp = (tempcx & 0xFF00) >> 8; |
| 5214 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 5215 | |
| 5216 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) { |
| 5217 | if (pVBInfo->VBType & VB_XGI301LV) { |
| 5218 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { |
| 5219 | temp |= 0x10; |
| 5220 | |
| 5221 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5222 | temp |= 0x20; |
| 5223 | } |
| 5224 | } else { |
| 5225 | temp |= 0x10; |
| 5226 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5227 | temp |= 0x20; |
| 5228 | } |
| 5229 | } |
| 5230 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5231 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5232 | |
| 5233 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5234 | | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */ |
| 5235 | tempbx = pVBInfo->VDE; |
| 5236 | tempcx = tempbx - 2; |
| 5237 | |
| 5238 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 5239 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p |
| 5240 | | SetYPbPrMode750p))) |
| 5241 | tempbx = tempbx >> 1; |
| 5242 | } |
| 5243 | |
| 5244 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 5245 | temp = 0; |
| 5246 | if (tempcx & 0x0400) |
| 5247 | temp |= 0x20; |
| 5248 | |
| 5249 | if (tempbx & 0x0400) |
| 5250 | temp |= 0x40; |
| 5251 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5252 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5253 | } |
| 5254 | |
| 5255 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5256 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5257 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5258 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5259 | } |
| 5260 | |
| 5261 | tempbx = tempbx & 0x00FF; |
| 5262 | |
| 5263 | if (!(modeflag & HalfDCLK)) { |
| 5264 | tempcx = pVBInfo->VGAHDE; |
| 5265 | if (tempcx >= pVBInfo->HDE) { |
| 5266 | tempbx |= 0x2000; |
| 5267 | tempax &= 0x00FF; |
| 5268 | } |
| 5269 | } |
| 5270 | |
| 5271 | tempcx = 0x0101; |
| 5272 | |
| 5273 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 5274 | if (pVBInfo->VGAHDE >= 1024) { |
| 5275 | tempcx = 0x1920; |
| 5276 | if (pVBInfo->VGAHDE >= 1280) { |
| 5277 | tempcx = 0x1420; |
| 5278 | tempbx = tempbx & 0xDFFF; |
| 5279 | } |
| 5280 | } |
| 5281 | } |
| 5282 | |
| 5283 | if (!(tempbx & 0x2000)) { |
| 5284 | if (modeflag & HalfDCLK) |
| 5285 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 5286 | |
| 5287 | push1 = tempbx; |
| 5288 | tempeax = pVBInfo->VGAHDE; |
| 5289 | tempebx = (tempcx & 0xFF00) >> 8; |
| 5290 | longtemp = tempeax * tempebx; |
| 5291 | tempecx = tempcx & 0x00FF; |
| 5292 | longtemp = longtemp / tempecx; |
| 5293 | |
| 5294 | /* 301b */ |
| 5295 | tempecx = 8 * 1024; |
| 5296 | |
| 5297 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5298 | | VB_XGI302LV | VB_XGI301C)) { |
| 5299 | tempecx = tempecx * 8; |
| 5300 | } |
| 5301 | |
| 5302 | longtemp = longtemp * tempecx; |
| 5303 | tempecx = pVBInfo->HDE; |
| 5304 | temp2 = longtemp % tempecx; |
| 5305 | tempeax = longtemp / tempecx; |
| 5306 | if (temp2 != 0) |
| 5307 | tempeax += 1; |
| 5308 | |
| 5309 | tempax = (unsigned short) tempeax; |
| 5310 | |
| 5311 | /* 301b */ |
| 5312 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5313 | | VB_XGI302LV | VB_XGI301C)) { |
| 5314 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 5315 | } |
| 5316 | /* end 301b */ |
| 5317 | |
| 5318 | tempbx = push1; |
| 5319 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 5320 | | (tempbx & 0x00FF)); |
| 5321 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 5322 | | (tempax & 0x00FF)); |
| 5323 | temp = (tempax & 0xFF00) >> 8; |
| 5324 | } else { |
| 5325 | temp = (tempax & 0x00FF) >> 8; |
| 5326 | } |
| 5327 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5328 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5329 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5330 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5331 | temp = tempcx & 0x00FF; |
| 5332 | |
| 5333 | if (tempbx & 0x2000) |
| 5334 | temp = 0; |
| 5335 | |
| 5336 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5337 | temp |= 0x18; |
| 5338 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5339 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5340 | if (pVBInfo->TVInfo & SetPALTV) { |
| 5341 | tempbx = 0x0382; |
| 5342 | tempcx = 0x007e; |
| 5343 | } else { |
| 5344 | tempbx = 0x0369; |
| 5345 | tempcx = 0x0061; |
| 5346 | } |
| 5347 | |
| 5348 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5349 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5350 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5351 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5352 | |
| 5353 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 5354 | temp = temp << 2; |
| 5355 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 5356 | |
| 5357 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5358 | temp |= 0x10; |
| 5359 | |
| 5360 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5361 | temp |= 0x20; |
| 5362 | |
| 5363 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5364 | temp |= 0x60; |
| 5365 | } |
| 5366 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5367 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5368 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5369 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5370 | |
| 5371 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { |
| 5372 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 5373 | TimingPoint = XGI_NTSC1024AdjTime; |
| 5374 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5375 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5376 | TimingPoint[j]); |
| 5377 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5378 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5379 | } |
| 5380 | } |
| 5381 | |
| 5382 | /* [ycchen] 01/14/03 Modify for 301C PALM Support */ |
| 5383 | if (pVBInfo->VBType & VB_XGI301C) { |
| 5384 | if (pVBInfo->TVInfo & SetPALMTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5385 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5386 | 0x08); /* PALM Mode */ |
| 5387 | } |
| 5388 | |
| 5389 | if (pVBInfo->TVInfo & SetPALMTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5390 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5391 | 0x01); |
| 5392 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5393 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5394 | |
| 5395 | /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5396 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5397 | } |
| 5398 | |
| 5399 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
| 5400 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5401 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5402 | } |
| 5403 | |
| 5404 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 5405 | return; |
| 5406 | } |
| 5407 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5408 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5409 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5410 | unsigned short RefreshRateTableIndex, |
| 5411 | struct vb_device_info *pVBInfo) |
| 5412 | { |
| 5413 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
| 5414 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; |
| 5415 | |
| 5416 | struct XGI_LCDDesStruct *LCDBDesPtr = NULL; |
| 5417 | |
| 5418 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5419 | /* si+St_ResInfo */ |
| 5420 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5421 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 5422 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5423 | /* si+Ext_ResInfo */ |
| 5424 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5425 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5426 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 5427 | Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5428 | CRT1Index &= IndexMask; |
| 5429 | } |
| 5430 | |
| 5431 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5432 | return; |
| 5433 | |
| 5434 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 5435 | |
| 5436 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5437 | tempbx = tempbx >> 1; |
| 5438 | |
| 5439 | tempbx -= 1; |
| 5440 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5441 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5442 | temp = (tempbx & 0xFF00) >> 8; |
| 5443 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5444 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5445 | temp = 0x01; |
| 5446 | |
| 5447 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
| 5448 | if (pVBInfo->ModeType == ModeEGA) { |
| 5449 | if (pVBInfo->VGAHDE >= 1024) { |
| 5450 | temp = 0x02; |
| 5451 | if (pVBInfo->LCDInfo & LCDVESATiming) |
| 5452 | temp = 0x01; |
| 5453 | } |
| 5454 | } |
| 5455 | } |
| 5456 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5457 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5458 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
| 5459 | push1 = tempbx; |
| 5460 | tempbx--; |
| 5461 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5462 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5463 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5464 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5465 | |
| 5466 | tempcx = pVBInfo->VT - 1; |
| 5467 | push2 = tempcx + 1; |
| 5468 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5469 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5470 | temp = (tempcx & 0xFF00) >> 8; |
| 5471 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5472 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5473 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 5474 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 5475 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 5476 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5477 | |
| 5478 | /* Customized LCDB Des no add */ |
| 5479 | tempbx = 5; |
| 5480 | LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo, |
| 5481 | ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5482 | tempah = pVBInfo->LCDResInfo; |
| 5483 | tempah &= PanelResInfo; |
| 5484 | |
| 5485 | if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) { |
| 5486 | tempbx = 1024; |
| 5487 | tempcx = 768; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5488 | } else if ((tempah == Panel1280x1024) || |
| 5489 | (tempah == Panel1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5490 | tempbx = 1280; |
| 5491 | tempcx = 1024; |
| 5492 | } else if (tempah == Panel1400x1050) { |
| 5493 | tempbx = 1400; |
| 5494 | tempcx = 1050; |
| 5495 | } else { |
| 5496 | tempbx = 1600; |
| 5497 | tempcx = 1200; |
| 5498 | } |
| 5499 | |
| 5500 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 5501 | tempbx = pVBInfo->HDE; |
| 5502 | tempcx = pVBInfo->VDE; |
| 5503 | } |
| 5504 | |
| 5505 | pushbx = tempbx; |
| 5506 | tempax = pVBInfo->VT; |
| 5507 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 5508 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 5509 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 5510 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 5511 | tempbx = pVBInfo->LCDVDES; |
| 5512 | tempcx += tempbx; |
| 5513 | |
| 5514 | if (tempcx >= tempax) |
| 5515 | tempcx -= tempax; /* lcdvdes */ |
| 5516 | |
| 5517 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5518 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5519 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5520 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5521 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 5522 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 5523 | tempah = tempch; |
| 5524 | tempah = tempah << 3; |
| 5525 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5526 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5527 | |
| 5528 | /* getlcdsync() */ |
| 5529 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 5530 | tempcx = tempbx; |
| 5531 | tempax = pVBInfo->VT; |
| 5532 | tempbx = pVBInfo->LCDVRS; |
| 5533 | |
| 5534 | /* if (SetLCD_Info & EnableScalingLCD) */ |
| 5535 | tempcx += tempbx; |
| 5536 | if (tempcx >= tempax) |
| 5537 | tempcx -= tempax; |
| 5538 | |
| 5539 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5540 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5541 | temp = (tempbx & 0xFF00) >> 8; |
| 5542 | temp = temp << 4; |
| 5543 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5544 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5545 | tempcx = pushbx; |
| 5546 | tempax = pVBInfo->HT; |
| 5547 | tempbx = pVBInfo->LCDHDES; |
| 5548 | tempbx &= 0x0FFF; |
| 5549 | |
| 5550 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 5551 | tempax = tempax >> 1; |
| 5552 | tempbx = tempbx >> 1; |
| 5553 | tempcx = tempcx >> 1; |
| 5554 | } |
| 5555 | |
| 5556 | if (pVBInfo->VBType & VB_XGI302LV) |
| 5557 | tempbx += 1; |
| 5558 | |
| 5559 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 5560 | tempbx += 1; |
| 5561 | |
| 5562 | tempcx += tempbx; |
| 5563 | |
| 5564 | if (tempcx >= tempax) |
| 5565 | tempcx -= tempax; |
| 5566 | |
| 5567 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5568 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5569 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5570 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5571 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5572 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5573 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5574 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5575 | |
| 5576 | /* getlcdsync() */ |
| 5577 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 5578 | tempcx = tempax; |
| 5579 | tempax = pVBInfo->HT; |
| 5580 | tempbx = pVBInfo->LCDHRS; |
| 5581 | /* if ( SetLCD_Info & EnableScalingLCD) */ |
| 5582 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 5583 | tempax = tempax >> 1; |
| 5584 | tempbx = tempbx >> 1; |
| 5585 | tempcx = tempcx >> 1; |
| 5586 | } |
| 5587 | |
| 5588 | if (pVBInfo->VBType & VB_XGI302LV) |
| 5589 | tempbx += 1; |
| 5590 | |
| 5591 | tempcx += tempbx; |
| 5592 | |
| 5593 | if (tempcx >= tempax) |
| 5594 | tempcx -= tempax; |
| 5595 | |
| 5596 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5597 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5598 | |
| 5599 | temp = (tempbx & 0xFF00) >> 8; |
| 5600 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5601 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5602 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5603 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5604 | |
| 5605 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
| 5606 | if (pVBInfo->VGAVDE == 525) { |
| 5607 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 5608 | | VB_XGI301LV | VB_XGI302LV |
| 5609 | | VB_XGI301C)) { |
| 5610 | temp = 0xC6; |
| 5611 | } else |
| 5612 | temp = 0xC4; |
| 5613 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5614 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 5615 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5616 | } |
| 5617 | |
| 5618 | if (pVBInfo->VGAVDE == 420) { |
| 5619 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 5620 | | VB_XGI301LV | VB_XGI302LV |
| 5621 | | VB_XGI301C)) { |
| 5622 | temp = 0x4F; |
| 5623 | } else |
| 5624 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5625 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5626 | } |
| 5627 | } |
| 5628 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5629 | |
| 5630 | /* --------------------------------------------------------------------- */ |
| 5631 | /* Function : XGI_GetTap4Ptr */ |
| 5632 | /* Input : */ |
| 5633 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 5634 | /* Description : */ |
| 5635 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5636 | static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5637 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5638 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5639 | unsigned short tempax, tempbx, i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5640 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5641 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5642 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5643 | if (tempcx == 0) { |
| 5644 | tempax = pVBInfo->VGAHDE; |
| 5645 | tempbx = pVBInfo->HDE; |
| 5646 | } else { |
| 5647 | tempax = pVBInfo->VGAVDE; |
| 5648 | tempbx = pVBInfo->VDE; |
| 5649 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5650 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5651 | if (tempax < tempbx) |
| 5652 | return &EnlargeTap4Timing[0]; |
| 5653 | else if (tempax == tempbx) |
| 5654 | return &NoScaleTap4Timing[0]; /* 1:1 */ |
| 5655 | else |
| 5656 | Tap4TimingPtr = NTSCTap4Timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5657 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5658 | if (pVBInfo->TVInfo & SetPALTV) |
| 5659 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5660 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5661 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
| 5662 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5663 | Tap4TimingPtr = YPbPr525iTap4Timing; |
| 5664 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5665 | Tap4TimingPtr = YPbPr525pTap4Timing; |
| 5666 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5667 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 5668 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5669 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5670 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
| 5671 | Tap4TimingPtr = HiTVTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5672 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5673 | i = 0; |
| 5674 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 5675 | if (Tap4TimingPtr[i].DE == tempax) |
| 5676 | break; |
| 5677 | i++; |
| 5678 | } |
| 5679 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5680 | } |
| 5681 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5682 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5683 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5684 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5685 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5686 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5687 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5688 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 5689 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5690 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5691 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 5692 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5693 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5694 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5695 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
| 5696 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) { |
| 5697 | /* Set Vertical Scaling */ |
| 5698 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5699 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5700 | xgifb_reg_set(pVBInfo->Part2Port, |
| 5701 | i, |
| 5702 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5703 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5704 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5705 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
| 5706 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) |
| 5707 | /* Enable V.Scaling */ |
| 5708 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5709 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5710 | /* Enable H.Scaling */ |
| 5711 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5712 | } |
| 5713 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5714 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5715 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5716 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5717 | unsigned short i; |
| 5718 | unsigned char *tempdi; |
| 5719 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5720 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5721 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5722 | /* si+St_ResInfo */ |
| 5723 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5724 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5725 | /* si+Ext_ResInfo */ |
| 5726 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5727 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5728 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5729 | if (pVBInfo->TVInfo & SetPALTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5730 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 5731 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5732 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5733 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 5734 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5735 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5736 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5737 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 5738 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5739 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5740 | if (pVBInfo->TVInfo & SetPALMTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5741 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 5742 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 5743 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5744 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5745 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5746 | if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo |
| 5747 | & SetCRT2ToYPbPr)) { |
| 5748 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 5749 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5750 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5751 | tempdi = pVBInfo->HiTVGroup3Data; |
| 5752 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 5753 | tempdi = pVBInfo->HiTVGroup3Simu; |
| 5754 | if (!(modeflag & Charx8Dot)) |
| 5755 | tempdi = pVBInfo->HiTVGroup3Text; |
| 5756 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5757 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5758 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 5759 | tempdi = pVBInfo->Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5760 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5761 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 5762 | tempdi = pVBInfo->Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5763 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5764 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5765 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5766 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5767 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
| 5768 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5769 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5770 | } |
| 5771 | } |
| 5772 | return; |
| 5773 | } /* {end of XGI_SetGroup3} */ |
| 5774 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5775 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5776 | unsigned short RefreshRateTableIndex, |
| 5777 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5778 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5779 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5780 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5781 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5782 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5783 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5784 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5785 | /* si+St_ResInfo */ |
| 5786 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5787 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5788 | /* si+Ext_ResInfo */ |
| 5789 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5790 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5791 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5792 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5793 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5794 | tempbx = pVBInfo->RVBHCMAX; |
| 5795 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5796 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5797 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 5798 | tempcx = pVBInfo->VGAHT - 1; |
| 5799 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5800 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5801 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5802 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 5803 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5804 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5805 | tempcx = pVBInfo->VGAVT - 1; |
| 5806 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 5807 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5808 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5809 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5810 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5811 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5812 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5813 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5814 | tempcx = pVBInfo->VBInfo; |
| 5815 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5816 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5817 | if (modeflag & HalfDCLK) |
| 5818 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5819 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5820 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5821 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5822 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5823 | if (tempcx & SetCRT2ToHiVisionTV) { |
| 5824 | temp = 0; |
| 5825 | if (tempbx <= 1024) |
| 5826 | temp = 0xA0; |
| 5827 | if (tempbx == 1280) |
| 5828 | temp = 0xC0; |
| 5829 | } else if (tempcx & SetCRT2ToTV) { |
| 5830 | temp = 0xA0; |
| 5831 | if (tempbx <= 800) |
| 5832 | temp = 0x80; |
| 5833 | } else { |
| 5834 | temp = 0x80; |
| 5835 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 5836 | temp = 0; |
| 5837 | if (tempbx > 800) |
| 5838 | temp = 0x60; |
| 5839 | } |
| 5840 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5841 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5842 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) { |
| 5843 | temp = 0x00; |
| 5844 | if (pVBInfo->VGAHDE == 1280) |
| 5845 | temp = 0x40; |
| 5846 | if (pVBInfo->VGAHDE == 1024) |
| 5847 | temp = 0x20; |
| 5848 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5849 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5850 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5851 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5852 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5853 | if (tempcx & SetCRT2ToHiVisionTV) { |
| 5854 | if (!(temp & 0xE000)) |
| 5855 | tempbx = tempbx >> 1; |
| 5856 | } |
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 | tempcx = pVBInfo->RVBHRS; |
| 5859 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5860 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5861 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5862 | tempeax = pVBInfo->VGAVDE; |
| 5863 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5864 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5865 | if (tempeax <= tempebx) { |
| 5866 | tempcx = (tempcx & (~0x4000)); |
| 5867 | tempeax = pVBInfo->VGAVDE; |
| 5868 | } else { |
| 5869 | tempeax -= tempebx; |
| 5870 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5871 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5872 | templong = (tempeax * 256 * 1024) % tempebx; |
| 5873 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 5874 | tempebx = tempeax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5875 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5876 | if (templong != 0) |
| 5877 | tempebx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5878 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5879 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5880 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5881 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5882 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5883 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5884 | tempbx = (unsigned short) (tempebx >> 16); |
| 5885 | temp = tempbx & 0x00FF; |
| 5886 | temp = temp << 4; |
| 5887 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5888 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
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 | /* 301b */ |
| 5891 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 5892 | | VB_XGI302LV | VB_XGI301C)) { |
| 5893 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5894 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5895 | tempax = pVBInfo->VGAHDE; |
| 5896 | if (modeflag & HalfDCLK) |
| 5897 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5898 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5899 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5900 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5901 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5902 | /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) || |
| 5903 | ((pVBInfo->TVInfo&SetYPbPrMode525p) || |
| 5904 | (pVBInfo->TVInfo&SetYPbPrMode750p))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5905 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 5906 | if (tempax > 800) |
| 5907 | tempax -= 800; |
| 5908 | } else { |
| 5909 | if (pVBInfo->VGAHDE > 800) { |
| 5910 | if (pVBInfo->VGAHDE == 1024) |
| 5911 | tempax = (tempax * 25 / 32) - 1; |
| 5912 | else |
| 5913 | tempax = (tempax * 20 / 32) - 1; |
| 5914 | } |
| 5915 | } |
| 5916 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5917 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5918 | /* |
| 5919 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
| 5920 | if (pVBInfo->VBType & VB_XGI301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5921 | if (!(pVBInfo->TVInfo & |
| 5922 | (SetYPbPrMode525p | |
| 5923 | SetYPbPrMode750p | |
| 5924 | SetYPbPrMode1080i))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5925 | if (pVBInfo->VGAHDE > 800) { |
| 5926 | if (pVBInfo->VGAHDE == 1024) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5927 | tempax =(tempax * 25 / |
| 5928 | 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5929 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5930 | tempax = (tempax * 20 / |
| 5931 | 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5932 | } |
| 5933 | } |
| 5934 | } else { |
| 5935 | if (pVBInfo->VGAHDE > 800) { |
| 5936 | if (pVBInfo->VGAHDE == 1024) |
| 5937 | tempax = (tempax * 25 / 32) - 1; |
| 5938 | else |
| 5939 | tempax = (tempax * 20 / 32) - 1; |
| 5940 | } |
| 5941 | } |
| 5942 | } |
| 5943 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5944 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5945 | temp = (tempax & 0xFF00) >> 8; |
| 5946 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5947 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5948 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5949 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5950 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5951 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
| 5952 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5953 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5954 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5955 | } |
| 5956 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5957 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5958 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 5959 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
| 5960 | | SetYPbPrMode525p | SetYPbPrMode750p |
| 5961 | | SetYPbPrMode1080i))) { |
| 5962 | temp |= 0x0001; |
| 5963 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 5964 | && (!(pVBInfo->TVInfo |
| 5965 | & TVSimuMode))) |
| 5966 | temp &= (~0x0001); |
| 5967 | } |
| 5968 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5969 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5970 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5971 | tempbx = pVBInfo->HT; |
| 5972 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5973 | tempbx = tempbx >> 1; |
| 5974 | tempbx = (tempbx >> 1) - 2; |
| 5975 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5976 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5977 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5978 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5979 | } |
| 5980 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5981 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5982 | if (pVBInfo->ISXPDOS == 0) |
| 5983 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5984 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5985 | } |
| 5986 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5987 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 5988 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5989 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5990 | } |
| 5991 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5992 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5993 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5994 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5995 | unsigned short Pindex, Pdata; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5996 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5997 | Pindex = pVBInfo->Part5Port; |
| 5998 | Pdata = pVBInfo->Part5Port + 1; |
| 5999 | if (pVBInfo->ModeType == ModeVGA) { |
| 6000 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
| 6001 | | CRT2DisplayFlag))) { |
| 6002 | XGINew_EnableCRT2(pVBInfo); |
| 6003 | /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */ |
| 6004 | } |
| 6005 | } |
| 6006 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6007 | } |
| 6008 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6009 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6010 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6011 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6012 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6013 | } |
| 6014 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6015 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6016 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6017 | { |
| 6018 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6019 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6020 | } |
| 6021 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6022 | /*----------------------------------------------------------------------------*/ |
| 6023 | /* input */ |
| 6024 | /* bl[5] : 1;LVDS signal on */ |
| 6025 | /* bl[1] : 1;LVDS backlight on */ |
| 6026 | /* bl[0] : 1:LVDS VDD on */ |
| 6027 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 6028 | /* 000010b : clear bit 1, to set bit1 */ |
| 6029 | /* 000001b : clear bit 0, to set bit0 */ |
| 6030 | /*----------------------------------------------------------------------------*/ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6031 | void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 6032 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6033 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6034 | unsigned char CR4A, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6035 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6036 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6037 | tempbh &= 0x23; |
| 6038 | tempbl &= 0x23; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6039 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6040 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6041 | if (tempbh & 0x20) { |
| 6042 | temp = (tempbl >> 4) & 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6043 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6044 | /* CR B4[1] */ |
| 6045 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6046 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6047 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6048 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6049 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6050 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6051 | temp = XG21GPIODataTransfer(temp); |
| 6052 | temp &= ~tempbh; |
| 6053 | temp |= tempbl; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6054 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6055 | } |
| 6056 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6057 | void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 6058 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6059 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6060 | unsigned char CR4A, temp; |
| 6061 | unsigned short tempbh0, tempbl0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6062 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6063 | tempbh0 = tempbh; |
| 6064 | tempbl0 = tempbl; |
| 6065 | tempbh0 &= 0x20; |
| 6066 | tempbl0 &= 0x20; |
| 6067 | tempbh0 >>= 3; |
| 6068 | tempbl0 >>= 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6069 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6070 | if (tempbh & 0x20) { |
| 6071 | temp = (tempbl >> 4) & 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6072 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6073 | /* CR B4[1] */ |
| 6074 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6075 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6076 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6077 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6078 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6079 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6080 | tempbh &= 0x03; |
| 6081 | tempbl &= 0x03; |
| 6082 | tempbh <<= 2; |
| 6083 | tempbl <<= 2; /* GPIOC,GPIOD */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6084 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6085 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6086 | } |
| 6087 | |
| 6088 | /* --------------------------------------------------------------------- */ |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6089 | unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6090 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6091 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6092 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6093 | index = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6094 | if (index < sizeof(XGI21_LCDCapList) |
| 6095 | / sizeof(struct XGI21_LVDSCapStruct)) |
| 6096 | return index; |
| 6097 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6098 | } |
| 6099 | |
| 6100 | /* --------------------------------------------------------------------- */ |
| 6101 | /* Function : XGI_XG21SetPanelDelay */ |
| 6102 | /* Input : */ |
| 6103 | /* Output : */ |
| 6104 | /* Description : */ |
| 6105 | /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */ |
| 6106 | /* : bl : 2 ; T2 : the duration signal on and Vdd on */ |
| 6107 | /* : bl : 3 ; T3 : the duration between CPL off and signal off */ |
| 6108 | /* : bl : 4 ; T4 : the duration signal off and Vdd off */ |
| 6109 | /* --------------------------------------------------------------------- */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6110 | void XGI_XG21SetPanelDelay(unsigned short tempbl, |
| 6111 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6112 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6113 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6114 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6115 | index = XGI_GetLVDSOEMTableIndex(pVBInfo); |
| 6116 | if (tempbl == 1) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6117 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6118 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6119 | if (tempbl == 2) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6120 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6121 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6122 | if (tempbl == 3) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6123 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6124 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6125 | if (tempbl == 4) |
Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 6126 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6127 | } |
| 6128 | |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 6129 | unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6130 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6131 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6132 | unsigned short xres, yres, colordepth, modeflag, resindex, |
| 6133 | lvdstableindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6134 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6135 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6136 | if (ModeNo <= 0x13) { |
| 6137 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 6138 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6139 | /* si+St_ResInfo */ |
| 6140 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6141 | } else { |
| 6142 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 6143 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6144 | /* si+St_ModeFlag */ |
| 6145 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6146 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6147 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6148 | if (!(modeflag & Charx8Dot)) { |
| 6149 | xres /= 9; |
| 6150 | xres *= 8; |
| 6151 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6152 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6153 | if (ModeNo > 0x13) { |
| 6154 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 6155 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6156 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6157 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 6158 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6159 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6160 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6161 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6162 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); |
| 6163 | if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE)) |
| 6164 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6165 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6166 | if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) |
| 6167 | return 0; |
| 6168 | |
| 6169 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6170 | if ((xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6171 | LVDSHDE)) || |
| 6172 | (yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6173 | LVDSVDE))) { |
| 6174 | colordepth = XGI_GetColorDepth(ModeNo, |
| 6175 | ModeIdIndex, |
| 6176 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6177 | if (colordepth > 2) |
| 6178 | return 0; |
| 6179 | |
| 6180 | } |
| 6181 | } |
| 6182 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6183 | } |
| 6184 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6185 | void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6186 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6187 | unsigned char temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6188 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6189 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6190 | temp = (temp & 1) << 6; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6191 | /* SR06[6] 18bit Dither */ |
| 6192 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 6193 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 6194 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6195 | |
| 6196 | } |
| 6197 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6198 | void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6199 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6200 | unsigned char temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6201 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6202 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 6203 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6204 | temp = (temp & 3) << 6; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6205 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 6206 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 6207 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 6208 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6209 | |
| 6210 | } |
| 6211 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 6212 | static void xgifb_set_lvds(int chip_id, |
| 6213 | unsigned short ModeNo, |
| 6214 | unsigned short ModeIdIndex, |
| 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 char temp, Miscdata; |
| 6218 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; |
| 6219 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 6220 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 6221 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6222 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6223 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6224 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6225 | LVDS_Capability & |
| 6226 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6227 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6228 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6229 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6230 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6231 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6232 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6233 | LVDS_Capability & LCDPolarity); |
| 6234 | /* SR35[7] FP VSync polarity */ |
| 6235 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 6236 | /* SR30[5] FP HSync polarity */ |
| 6237 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6238 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 6239 | if (chip_id == XG27) |
| 6240 | XGI_SetXG27FPBits(pVBInfo); |
| 6241 | else |
| 6242 | XGI_SetXG21FPBits(pVBInfo); |
| 6243 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6244 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6245 | if (ModeNo <= 0x13) { |
| 6246 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 6247 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6248 | /* si+St_ResInfo */ |
| 6249 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6250 | } else { |
| 6251 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 6252 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6253 | /* si+St_ModeFlag */ |
| 6254 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6255 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6256 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6257 | if (!(modeflag & Charx8Dot)) |
| 6258 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6259 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6260 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6261 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6262 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE |
| 6263 | - xres) / 2; |
| 6264 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) |
| 6265 | LVDSHBS -= xres / 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6266 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6267 | if (LVDSHBS > LVDSHT) |
| 6268 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6269 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6270 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; |
| 6271 | if (LVDSHRS > LVDSHT) |
| 6272 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6273 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6274 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; |
| 6275 | if (LVDSHRE > LVDSHT) |
| 6276 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6277 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6278 | LVDSHBE = LVDSHBS + LVDSHT |
| 6279 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6280 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6281 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6282 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6283 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE |
| 6284 | - yres) / 2; |
| 6285 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 6286 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6287 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6288 | if (LVDSVBS > LVDSVT) |
| 6289 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6290 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6291 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; |
| 6292 | if (LVDSVRS > LVDSVT) |
| 6293 | LVDSVRS -= LVDSVT; |
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 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6296 | LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6297 | if (LVDSVRE > LVDSVT) |
| 6298 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6299 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6300 | LVDSVBE = LVDSVBS + LVDSVT |
| 6301 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6302 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6303 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6304 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6305 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6306 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6307 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6308 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6309 | /* HT SR0B[1:0] CR00 */ |
| 6310 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6311 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6312 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6313 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6314 | /* HBS SR0B[5:4] CR02 */ |
| 6315 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6316 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6317 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6318 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6319 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 6320 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6321 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 6322 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 6323 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6324 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6325 | /* HRS SR0B[7:6] CR04 */ |
| 6326 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6327 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6328 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6329 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6330 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 6331 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6332 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6333 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
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 | /* HRE SR0C[2] CR05[4:0] */ |
| 6336 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6337 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 6338 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6339 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6340 | /* Panel HRE SR2F[7:2] */ |
| 6341 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6342 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
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 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 6345 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6346 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 6347 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 6348 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6349 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6350 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6351 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 6352 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6353 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 6354 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 6355 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6356 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6357 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6358 | /* VBE SR0A[4] CR16 */ |
| 6359 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6360 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6361 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6362 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6363 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 6364 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6365 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 6366 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 6367 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6368 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6369 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 6370 | if (chip_id == XG27) { |
| 6371 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
| 6372 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, |
| 6373 | (value & 0x700) >> 8); |
| 6374 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
| 6375 | } else { |
| 6376 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
| 6377 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, |
| 6378 | (value & 0x600) >> 9); |
| 6379 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
| 6380 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
| 6381 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6382 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6383 | /* VRE SR0A[5] CR11[3:0] */ |
| 6384 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6385 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 6386 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6387 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6388 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 6389 | if (chip_id == XG27) |
| 6390 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 6391 | (value << 2) & 0xFC); |
| 6392 | else |
| 6393 | /* SR3F[7] has to be 0, h/w bug */ |
| 6394 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 6395 | (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6396 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6397 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6398 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6399 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6400 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6401 | 0x2B, |
| 6402 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6403 | VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6404 | xgifb_reg_set(pVBInfo->P3c4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6405 | 0x2C, |
| 6406 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
| 6407 | VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6408 | value += 0x10; |
| 6409 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6410 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6411 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6412 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6413 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6414 | /* set data, panning = 0, shift left 1 dot*/ |
| 6415 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6416 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6417 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6418 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6419 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6420 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6421 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6422 | |
| 6423 | } |
| 6424 | |
| 6425 | /* --------------------------------------------------------------------- */ |
| 6426 | /* Function : XGI_IsLCDON */ |
| 6427 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6428 | /* Output : 0 : Skip PSC Control */ |
| 6429 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6430 | /* Description : */ |
| 6431 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6432 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6433 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6434 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6435 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6436 | tempax = pVBInfo->VBInfo; |
| 6437 | if (tempax & SetCRT2ToDualEdge) |
| 6438 | return 0; |
| 6439 | else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode)) |
| 6440 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6441 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6442 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6443 | } |
| 6444 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6445 | /* --------------------------------------------------------------------- */ |
| 6446 | /* Function : XGI_DisableChISLCD */ |
| 6447 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6448 | /* Output : 0 -> Not LCD Mode */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6449 | /* Description : */ |
| 6450 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6451 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6452 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6453 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6454 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6455 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6456 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6457 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6458 | if (tempbx & (EnableChA | DisableChA)) { |
| 6459 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 6460 | return 0; |
| 6461 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6462 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6463 | if (!(tempbx & (EnableChB | DisableChB))) |
| 6464 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6465 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6466 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 6467 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6468 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6469 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6470 | } |
| 6471 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6472 | /* --------------------------------------------------------------------- */ |
| 6473 | /* Function : XGI_EnableChISLCD */ |
| 6474 | /* Input : */ |
| 6475 | /* Output : 0 -> Not LCD mode */ |
| 6476 | /* Description : */ |
| 6477 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6478 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
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 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6481 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6482 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6483 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
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 (tempbx & (EnableChA | DisableChA)) { |
| 6486 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 6487 | return 0; |
| 6488 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6489 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6490 | if (!(tempbx & (EnableChB | DisableChB))) |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6491 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6492 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6493 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 6494 | return 1; |
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 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6497 | } |
| 6498 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6499 | void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
| 6500 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6501 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 6502 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6503 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6504 | if (pVBInfo->SetFlag == Win9xDOSMode) |
| 6505 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6506 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6507 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6508 | | VB_XGI302LV | VB_XGI301C)) { |
| 6509 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6510 | if (!(pVBInfo->VBInfo & |
| 6511 | (DisableCRT2Display | SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6512 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 6513 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 6514 | tempah = 0x7F; /* Disable Channel A */ |
| 6515 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6516 | /* Disable Channel B */ |
| 6517 | tempah = 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6518 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6519 | if (pVBInfo->SetFlag & DisableChB) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6520 | /* force to disable Cahnnel */ |
| 6521 | tempah &= 0xBF; |
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 (pVBInfo->SetFlag & DisableChA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6524 | /* Force to disable Channel B */ |
| 6525 | tempah &= 0x7F; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6526 | } |
| 6527 | } |
| 6528 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6529 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6530 | /* disable part4_1f */ |
| 6531 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6532 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6533 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 6534 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 6535 | || (XGI_DisableChISLCD(pVBInfo)) |
| 6536 | || (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6537 | /* LVDS Driver power down */ |
| 6538 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6539 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6540 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6541 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
| 6542 | & (DisableCRT2Display | SetCRT2ToLCDA |
| 6543 | | SetSimuScanMode))) { |
| 6544 | if (pVBInfo->SetFlag & GatingCRT) |
| 6545 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); |
| 6546 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 6547 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6548 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6549 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 6550 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
| 6551 | & SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6552 | /* Power down */ |
| 6553 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6554 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6555 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6556 | /* disable TV as primary VGA swap */ |
| 6557 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6558 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6559 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6560 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6561 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6562 | if ((pVBInfo->SetFlag & DisableChB) || |
| 6563 | (pVBInfo->VBInfo & |
| 6564 | (DisableCRT2Display | SetSimuScanMode)) || |
| 6565 | ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && |
| 6566 | (pVBInfo->VBInfo & |
| 6567 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
| 6568 | /* BScreenOff=1 */ |
| 6569 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6570 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6571 | if ((pVBInfo->SetFlag & DisableChB) || |
| 6572 | (pVBInfo->VBInfo & |
| 6573 | (DisableCRT2Display | SetSimuScanMode)) || |
| 6574 | (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) || |
| 6575 | (pVBInfo->VBInfo & |
| 6576 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 6577 | /* save Part1 index 0 */ |
| 6578 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 6579 | /* BTDAC = 1, avoid VB reset */ |
| 6580 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 6581 | /* disable CRT2 */ |
| 6582 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 6583 | /* restore Part1 index 0 */ |
| 6584 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6585 | } |
| 6586 | } else { /* {301} */ |
| 6587 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6588 | /* BScreenOff=1 */ |
| 6589 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 6590 | /* Disable CRT2 */ |
| 6591 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 6592 | /* Disable TV asPrimary VGA swap */ |
| 6593 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6594 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6595 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6596 | if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA |
| 6597 | | SetSimuScanMode)) |
| 6598 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 6599 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6600 | } |
| 6601 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6602 | /* --------------------------------------------------------------------- */ |
| 6603 | /* Function : XGI_GetTVPtrIndex */ |
| 6604 | /* Input : */ |
| 6605 | /* Output : */ |
| 6606 | /* Description : bx 0 : ExtNTSC */ |
| 6607 | /* 1 : StNTSC */ |
| 6608 | /* 2 : ExtPAL */ |
| 6609 | /* 3 : StPAL */ |
| 6610 | /* 4 : ExtHiTV */ |
| 6611 | /* 5 : StHiTV */ |
| 6612 | /* 6 : Ext525i */ |
| 6613 | /* 7 : St525i */ |
| 6614 | /* 8 : Ext525p */ |
| 6615 | /* 9 : St525p */ |
| 6616 | /* A : Ext750p */ |
| 6617 | /* B : St750p */ |
| 6618 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6619 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6620 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6621 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6622 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6623 | if (pVBInfo->TVInfo & SetPALTV) |
| 6624 | tempbx = 2; |
| 6625 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) |
| 6626 | tempbx = 4; |
| 6627 | if (pVBInfo->TVInfo & SetYPbPrMode525i) |
| 6628 | tempbx = 6; |
| 6629 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
| 6630 | tempbx = 8; |
| 6631 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
| 6632 | tempbx = 10; |
| 6633 | if (pVBInfo->TVInfo & TVSimuMode) |
| 6634 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6635 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6636 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6637 | } |
| 6638 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6639 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6640 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6641 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6642 | /* Output : bx 0 : NTSC */ |
| 6643 | /* 1 : PAL */ |
| 6644 | /* 2 : PALM */ |
| 6645 | /* 3 : PALN */ |
| 6646 | /* 4 : NTSC1024x768 */ |
| 6647 | /* 5 : PAL-M 1024x768 */ |
| 6648 | /* 6-7: reserved */ |
| 6649 | /* cl 0 : YFilter1 */ |
| 6650 | /* 1 : YFilter2 */ |
| 6651 | /* ch 0 : 301A */ |
| 6652 | /* 1 : 301B/302B/301LV/302LV */ |
| 6653 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6654 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6655 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 6656 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6657 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6658 | *tempbx = 0; |
| 6659 | *tempcl = 0; |
| 6660 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6661 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6662 | if (pVBInfo->TVInfo & SetPALTV) |
| 6663 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6664 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6665 | if (pVBInfo->TVInfo & SetPALMTV) |
| 6666 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6667 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6668 | if (pVBInfo->TVInfo & SetPALNTV) |
| 6669 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6670 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6671 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 6672 | *tempbx = 4; |
| 6673 | if (pVBInfo->TVInfo & SetPALMTV) |
| 6674 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6675 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6676 | |
| 6677 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6678 | | VB_XGI302LV | VB_XGI301C)) { |
| 6679 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 6680 | & TVSimuMode)) { |
| 6681 | *tempbx += 8; |
| 6682 | *tempcl += 1; |
| 6683 | } |
| 6684 | } |
| 6685 | |
| 6686 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6687 | | VB_XGI302LV | VB_XGI301C)) |
| 6688 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6689 | } |
| 6690 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6691 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
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 | unsigned short index; |
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 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6696 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6697 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6698 | | VB_XGI302LV | VB_XGI301C)) { |
| 6699 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA |
| 6700 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
| 6701 | tempbl = 0; |
| 6702 | tempbh = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6703 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6704 | index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */ |
| 6705 | tempbl = pVBInfo->XGI_TVDelayList[index]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6706 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6707 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 6708 | | VB_XGI301LV | VB_XGI302LV |
| 6709 | | VB_XGI301C)) |
| 6710 | tempbl = pVBInfo->XGI_TVDelayList2[index]; |
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 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 6713 | tempbl = tempbl >> 4; |
| 6714 | /* |
| 6715 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
| 6716 | tempbl = CRT2Delay1; // Get CRT2 Delay |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6717 | if (pVBInfo->VBType & |
| 6718 | (VB_XGI301B | |
| 6719 | VB_XGI302B | |
| 6720 | VB_XGI301LV | |
| 6721 | VB_XGI302LV | |
| 6722 | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6723 | tempbl = CRT2Delay2; |
| 6724 | */ |
| 6725 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6726 | /* Get LCD Delay */ |
| 6727 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 6728 | tempbh = pVBInfo->LCDCapList[index]. |
| 6729 | LCD_DelayCompensation; |
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 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
| 6732 | tempbl = tempbh; |
| 6733 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6734 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6735 | tempbl &= 0x0F; |
| 6736 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6737 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6738 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6739 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 6740 | | SetCRT2ToTV)) { /* Channel B */ |
| 6741 | tempah &= 0xF0; |
| 6742 | tempah |= tempbl; |
| 6743 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6744 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6745 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */ |
| 6746 | tempah &= 0x0F; |
| 6747 | tempah |= tempbh; |
| 6748 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6749 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6750 | } |
| 6751 | } else if (pVBInfo->IF_DEF_LVDS == 1) { |
| 6752 | tempbl = 0; |
| 6753 | tempbh = 0; |
| 6754 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6755 | /* / Get LCD Delay */ |
| 6756 | tempah = pVBInfo->LCDCapList[ |
| 6757 | XGI_GetLCDCapPtr(pVBInfo)]. |
| 6758 | LCD_DelayCompensation; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6759 | tempah &= 0x0f; |
| 6760 | tempah = tempah << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6761 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6762 | tempah); |
| 6763 | } |
| 6764 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6765 | } |
| 6766 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6767 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 6768 | struct vb_device_info *pVBInfo) |
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 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6771 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6772 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6773 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6774 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6775 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6776 | /* Enable Dither */ |
| 6777 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6778 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6779 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6780 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6781 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6782 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6783 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6784 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6785 | /* |
| 6786 | if (tempcx & EnableLCD24bpp) { // 24bits |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6787 | xgifb_reg_and_or(pVBInfo->Part1Port, |
| 6788 | 0x19, |
| 6789 | 0x0F, |
| 6790 | (unsigned short)(0x30 | (tempcx&0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6791 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6792 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6793 | xgifb_reg_and_or(pVBInfo->Part1Port, |
| 6794 | 0x19, |
| 6795 | 0x0F, |
| 6796 | // Enable Dither |
| 6797 | (unsigned short)(0x20 | (tempcx&0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6798 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6799 | } |
| 6800 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6801 | } |
| 6802 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6803 | /* --------------------------------------------------------------------- */ |
| 6804 | /* Function : XGI_SetLCDCap_B */ |
| 6805 | /* Input : cx -> LCD Capability */ |
| 6806 | /* Output : */ |
| 6807 | /* Description : */ |
| 6808 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6809 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 6810 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6811 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6812 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6813 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6814 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 6815 | | 0x0c)); |
| 6816 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6817 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6818 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 6819 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6820 | } |
| 6821 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6822 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6823 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6824 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6825 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6826 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6827 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6828 | /* disable down spectrum D[4] */ |
| 6829 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6830 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6831 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6832 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6833 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6834 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6835 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6836 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6837 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6838 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6839 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6840 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6841 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 6842 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6843 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6844 | } |
| 6845 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6846 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 6847 | { |
| 6848 | unsigned short tempcx; |
| 6849 | |
| 6850 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 6851 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6852 | if (pVBInfo->VBType & |
| 6853 | (VB_XGI301B | |
| 6854 | VB_XGI302B | |
| 6855 | VB_XGI301LV | |
| 6856 | VB_XGI302LV | |
| 6857 | VB_XGI301C)) { /* 301LV/302LV only */ |
| 6858 | if (pVBInfo->VBType & |
| 6859 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6860 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6861 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6862 | (unsigned char) (tempcx & 0x1F)); |
| 6863 | } |
| 6864 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6865 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6866 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 6867 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 6868 | | EnablePLLSPLOW)) >> 8)); |
| 6869 | } |
| 6870 | |
| 6871 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 6872 | | VB_XGI302LV | VB_XGI301C)) { |
| 6873 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 6874 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
| 6875 | else if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 6876 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 6877 | |
| 6878 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 6879 | if (tempcx & EnableSpectrum) |
| 6880 | SetSpectrum(pVBInfo); |
| 6881 | } |
| 6882 | } else { |
| 6883 | /* LVDS,CH7017 */ |
| 6884 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 6885 | } |
| 6886 | } |
| 6887 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6888 | /* --------------------------------------------------------------------- */ |
| 6889 | /* Function : XGI_SetAntiFlicker */ |
| 6890 | /* Input : */ |
| 6891 | /* Output : */ |
| 6892 | /* Description : Set TV Customized Param. */ |
| 6893 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6894 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
| 6895 | unsigned short ModeIdIndex, |
| 6896 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6897 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6898 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6899 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6900 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6901 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6902 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
| 6903 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6904 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6905 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 6906 | tempbx &= 0xFE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6907 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6908 | if (ModeNo <= 0x13) |
| 6909 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; |
| 6910 | else |
| 6911 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6912 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6913 | tempbx += index; |
| 6914 | tempah = TVAntiFlickList[tempbx]; |
| 6915 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6916 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6917 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6918 | } |
| 6919 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6920 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
| 6921 | unsigned short ModeIdIndex, |
| 6922 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6923 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6924 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6925 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6926 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6927 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6928 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 6929 | tempbx &= 0xFE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6930 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6931 | if (ModeNo <= 0x13) |
| 6932 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; |
| 6933 | else |
| 6934 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6935 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6936 | tempbx += index; |
| 6937 | tempah = TVEdgeList[tempbx]; |
| 6938 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6939 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6940 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6941 | } |
| 6942 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6943 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6944 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6945 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6946 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6947 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6948 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6949 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6950 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6951 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 6952 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6953 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6954 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6955 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6956 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6957 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6958 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6959 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6960 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6961 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6962 | } |
| 6963 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6964 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6965 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6966 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6967 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6968 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6969 | unsigned char tempcl, tempch, tempal, *filterPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6970 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6971 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6972 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6973 | switch (tempbx) { |
| 6974 | case 0x00: |
| 6975 | case 0x04: |
| 6976 | filterPtr = NTSCYFilter1; |
| 6977 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6978 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6979 | case 0x01: |
| 6980 | filterPtr = PALYFilter1; |
| 6981 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6982 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6983 | case 0x02: |
| 6984 | case 0x05: |
| 6985 | case 0x0D: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6986 | case 0x03: |
Aaro Koskinen | 2555e94 | 2011-08-31 21:46:06 +0300 | [diff] [blame^] | 6987 | filterPtr = xgifb_palmn_yfilter1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6988 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6989 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6990 | case 0x08: |
| 6991 | case 0x0C: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6992 | case 0x0A: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6993 | case 0x0B: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6994 | case 0x09: |
Aaro Koskinen | 80f86f8 | 2011-08-31 21:46:05 +0300 | [diff] [blame] | 6995 | filterPtr = xgifb_yfilter2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6996 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6997 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6998 | default: |
| 6999 | return; |
| 7000 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7001 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7002 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7003 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 7004 | VB_StTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7005 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7006 | tempal = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 7007 | VB_ExtTVYFilterIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7008 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7009 | if (tempcl == 0) |
| 7010 | index = tempal * 4; |
| 7011 | else |
| 7012 | index = tempal * 7; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7013 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7014 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7015 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 7016 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 7017 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 7018 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7019 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7020 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 7021 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 7022 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 7023 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7024 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7025 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7026 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7027 | | VB_XGI302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7028 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 7029 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 7030 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7031 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7032 | } |
| 7033 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7034 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7035 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7036 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7037 | /* Output : */ |
| 7038 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7039 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7040 | static void XGI_OEM310Setting(unsigned short ModeNo, |
| 7041 | unsigned short ModeIdIndex, |
| 7042 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7043 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7044 | if (pVBInfo->SetFlag & Win9xDOSMode) |
| 7045 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7046 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7047 | /* GetPart1IO(); */ |
| 7048 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7049 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7050 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
| 7051 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7052 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7053 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 7054 | /* GetPart2IO() */ |
| 7055 | XGI_SetPhaseIncr(pVBInfo); |
| 7056 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); |
| 7057 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); |
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->VBType & VB_XGI301) |
| 7060 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7061 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7062 | } |
| 7063 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7064 | /* --------------------------------------------------------------------- */ |
| 7065 | /* Function : XGI_SetCRT2ModeRegs */ |
| 7066 | /* Input : */ |
| 7067 | /* Output : */ |
| 7068 | /* Description : Origin code for crt2group */ |
| 7069 | /* --------------------------------------------------------------------- */ |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 7070 | void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7071 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7072 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7073 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7074 | unsigned short tempbl; |
| 7075 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7076 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7077 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7078 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7079 | /* // fix write part1 index 0 BTDRAM bit Bug |
| 7080 | * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7081 | tempah = 0; |
| 7082 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7083 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7084 | tempah &= ~0x10; /* BTRAMDAC */ |
| 7085 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7086 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7087 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 7088 | | SetCRT2ToLCD)) { |
| 7089 | tempah = 0x40; /* BTDRAM */ |
| 7090 | if (ModeNo > 0x13) { |
| 7091 | tempcl = pVBInfo->ModeType; |
| 7092 | tempcl -= ModeVGA; |
| 7093 | if (tempcl >= 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7094 | /* BT Color */ |
| 7095 | tempah = (0x008 >> tempcl); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7096 | if (tempah == 0) |
| 7097 | tempah = 1; |
| 7098 | tempah |= 0x040; |
| 7099 | } |
| 7100 | } |
| 7101 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 7102 | tempah ^= 0x50; /* BTDAC */ |
| 7103 | } |
| 7104 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7105 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7106 | /* 0210 shampoo |
| 7107 | if (pVBInfo->VBInfo & DisableCRT2Display) { |
| 7108 | tempah = 0; |
| 7109 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7110 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7111 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7112 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) { |
| 7113 | tempcl = pVBInfo->ModeType; |
| 7114 | if (ModeNo > 0x13) { |
| 7115 | tempcl -= ModeVGA; |
| 7116 | if ((tempcl > 0) || (tempcl == 0)) { |
| 7117 | tempah=(0x008>>tempcl) ; |
| 7118 | if (tempah == 0) |
| 7119 | tempah = 1; |
| 7120 | tempah |= 0x040; |
| 7121 | } |
| 7122 | } else { |
| 7123 | tempah = 0x040; |
| 7124 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7125 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7126 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 7127 | tempah = (tempah ^ 0x050); |
| 7128 | } |
| 7129 | } |
| 7130 | */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7131 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7132 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7133 | tempah = 0x08; |
| 7134 | tempbl = 0xf0; |
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 & DisableCRT2Display) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7137 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7138 | } else { |
| 7139 | tempah = 0x00; |
| 7140 | tempbl = 0xff; |
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 & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 7143 | | SetCRT2ToLCD | SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7144 | if ((pVBInfo->VBInfo & SetCRT2ToLCDA) && |
| 7145 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7146 | tempbl &= 0xf7; |
| 7147 | tempah |= 0x01; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7148 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7149 | tempbl, tempah); |
| 7150 | } else { |
| 7151 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 7152 | tempbl &= 0xf7; |
| 7153 | tempah |= 0x01; |
| 7154 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7155 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7156 | if (pVBInfo->VBInfo & |
| 7157 | (SetCRT2ToRAMDAC | |
| 7158 | SetCRT2ToTV | |
| 7159 | SetCRT2ToLCD)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7160 | tempbl &= 0xf8; |
| 7161 | tempah = 0x01; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7162 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7163 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 7164 | tempah |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7165 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7166 | if (!(pVBInfo->VBInfo & |
| 7167 | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7168 | tempah = tempah ^ 0x05; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7169 | if (!(pVBInfo->VBInfo & |
| 7170 | SetCRT2ToLCD)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7171 | tempah = tempah ^ 0x01; |
| 7172 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7173 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7174 | if (!(pVBInfo->VBInfo & |
| 7175 | SetCRT2ToDualEdge)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7176 | tempah |= 0x08; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7177 | xgifb_reg_and_or(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7178 | 0x2e, tempbl, tempah); |
| 7179 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7180 | xgifb_reg_and_or(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7181 | 0x2e, tempbl, tempah); |
| 7182 | } |
| 7183 | } |
| 7184 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7185 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7186 | tempah); |
| 7187 | } |
| 7188 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7189 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7190 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
| 7191 | | SetCRT2ToLCDA)) { |
| 7192 | tempah &= (~0x08); |
| 7193 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 7194 | & SetInSlaveMode))) { |
| 7195 | tempah |= 0x010; |
| 7196 | } |
| 7197 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7198 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7199 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7200 | /* if (!(pVBInfo->TVInfo & |
| 7201 | (SetYPbPrMode525p | SetYPbPrMode750p))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7202 | tempah |= 0x020; |
| 7203 | if (ModeNo > 0x13) { |
| 7204 | if (pVBInfo->VBInfo & DriverMode) |
| 7205 | tempah = tempah ^ 0x20; |
| 7206 | } |
| 7207 | /* } */ |
| 7208 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7209 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7210 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7211 | tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7212 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7213 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 7214 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7215 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7216 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7217 | /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && |
| 7218 | (!(pVBInfo->TVInfo & |
| 7219 | (SetYPbPrMode525p | SetYPbPrMode750p)))) { */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7220 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 7221 | tempah |= 0x40; |
| 7222 | /* } */ |
| 7223 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7224 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7225 | if ((pVBInfo->LCDResInfo == Panel1280x1024) |
| 7226 | || (pVBInfo->LCDResInfo == Panel1280x1024x75)) |
| 7227 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7228 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7229 | if (pVBInfo->LCDResInfo == Panel1280x960) |
| 7230 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7231 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7232 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7233 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7234 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7235 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7236 | | VB_XGI302LV | VB_XGI301C)) { |
| 7237 | tempah = 0; |
| 7238 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7239 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7240 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 7241 | tempbl = 0xff; |
| 7242 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 7243 | tempah |= 0x04; /* shampoo 0129 */ |
| 7244 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7245 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7246 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7247 | tempah = 0x00; |
| 7248 | tempbl = 0xcf; |
| 7249 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 7250 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 7251 | tempah |= 0x30; |
| 7252 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7253 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7254 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7255 | tempah = 0; |
| 7256 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7257 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7258 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 7259 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 7260 | tempah |= 0xc0; |
| 7261 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7262 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7263 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7264 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7265 | tempah = 0; |
| 7266 | tempbl = 0x7f; |
| 7267 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) { |
| 7268 | tempbl = 0xff; |
| 7269 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 7270 | tempah |= 0x80; |
| 7271 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7272 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7273 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7274 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7275 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 7276 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7277 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 7278 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7279 | } |
| 7280 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7281 | } |
| 7282 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7283 | static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7284 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7285 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7286 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7287 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7288 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7289 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7290 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
| 7291 | tempbx = 0x08A0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7292 | |
| 7293 | } |
| 7294 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7295 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 7296 | struct vb_device_info *pVBInfo) |
| 7297 | { |
| 7298 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7299 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7300 | |
| 7301 | } |
| 7302 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7303 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 7304 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7305 | { |
| 7306 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7307 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7308 | |
| 7309 | } |
| 7310 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 7311 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7312 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7313 | unsigned short flag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7314 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7315 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 7316 | return 1; |
| 7317 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7318 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7319 | if ((flag == 1) || (flag == 2)) |
| 7320 | return 1; /* 301b */ |
| 7321 | else |
| 7322 | return 0; |
| 7323 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7324 | } |
| 7325 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 7326 | void XGI_LongWait(struct vb_device_info *pVBInfo) |
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 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7329 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7330 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7331 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7332 | if (!(i & 0xC0)) { |
| 7333 | for (i = 0; i < 0xFFFF; i++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7334 | if (!(inb(pVBInfo->P3da) & 0x08)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7335 | break; |
| 7336 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7337 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7338 | for (i = 0; i < 0xFFFF; i++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7339 | if ((inb(pVBInfo->P3da) & 0x08)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7340 | break; |
| 7341 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7342 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7343 | } |
| 7344 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 7345 | static void XGI_VBLongWait(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7346 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7347 | unsigned short tempal, temp, i, j; |
| 7348 | return; |
| 7349 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 7350 | temp = 0; |
| 7351 | for (i = 0; i < 3; i++) { |
| 7352 | for (j = 0; j < 100; j++) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7353 | tempal = inb(pVBInfo->P3da); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7354 | if (temp & 0x01) { /* VBWaitMode2 */ |
| 7355 | if ((tempal & 0x08)) |
| 7356 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7357 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7358 | if (!(tempal & 0x08)) |
| 7359 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7360 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7361 | } else { /* VBWaitMode1 */ |
| 7362 | if (!(tempal & 0x08)) |
| 7363 | continue; |
| 7364 | |
| 7365 | if ((tempal & 0x08)) |
| 7366 | break; |
| 7367 | } |
| 7368 | } |
| 7369 | temp = temp ^ 0x01; |
| 7370 | } |
| 7371 | } else { |
| 7372 | XGI_LongWait(pVBInfo); |
| 7373 | } |
| 7374 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7375 | } |
| 7376 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7377 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 7378 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 7379 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7380 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7381 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, |
| 7382 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, |
| 7383 | 0x01, 0x01 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7384 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7385 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7386 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7387 | if (ModeNo <= 0x13) |
| 7388 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 7389 | else |
| 7390 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 7391 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7392 | if (ModeNo < 0x14) |
| 7393 | return 0xFFFF; |
| 7394 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7395 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7396 | index = index >> pVBInfo->SelectCRT2Rate; |
| 7397 | index &= 0x0F; |
| 7398 | |
| 7399 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 7400 | index = 0; |
| 7401 | |
| 7402 | if (index > 0) |
| 7403 | index--; |
| 7404 | |
| 7405 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7406 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
| 7407 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 7408 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
| 7409 | | VB_XGI301LV | VB_XGI302LV |
| 7410 | | VB_XGI301C)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7411 | /* 301b */ |
| 7412 | temp = LCDARefreshIndex[ |
| 7413 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7414 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7415 | temp = LCDRefreshIndex[ |
| 7416 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7417 | |
| 7418 | if (index > temp) |
| 7419 | index = temp; |
| 7420 | } else { |
| 7421 | index = 0; |
| 7422 | } |
| 7423 | } |
| 7424 | } |
| 7425 | |
| 7426 | RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex; |
| 7427 | ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID; |
| 7428 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
| 7429 | /* |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7430 | if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & |
| 7431 | XG2xNotSupport) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7432 | index++; |
| 7433 | } |
| 7434 | */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7435 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 7436 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7437 | index++; |
| 7438 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7439 | /* Alan 10/19/2007; |
| 7440 | * do the similar adjustment like XGISearchCRT1Rate() */ |
| 7441 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 7442 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7443 | index++; |
| 7444 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7445 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 7446 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7447 | index++; |
| 7448 | } |
| 7449 | } |
| 7450 | |
| 7451 | i = 0; |
| 7452 | do { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7453 | if (pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 7454 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7455 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7456 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 7457 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7458 | temp &= ModeInfoFlag; |
| 7459 | if (temp < pVBInfo->ModeType) |
| 7460 | break; |
| 7461 | i++; |
| 7462 | index--; |
| 7463 | |
| 7464 | } while (index != 0xFFFF); |
| 7465 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 7466 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7467 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1]. |
| 7468 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7469 | if (temp & InterlaceMode) |
| 7470 | i++; |
| 7471 | } |
| 7472 | } |
| 7473 | i--; |
| 7474 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
| 7475 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, |
| 7476 | RefreshRateTableIndex, &i, pVBInfo); |
| 7477 | } |
| 7478 | return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7479 | } |
| 7480 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7481 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7482 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7483 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7484 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7485 | unsigned short RefreshRateTableIndex; |
| 7486 | /* unsigned short temp ; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7487 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7488 | /* pVBInfo->SelectCRT2Rate = 0; */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7489 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7490 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7491 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7492 | ModeIdIndex, pVBInfo); |
| 7493 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7494 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7495 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7496 | HwDeviceExtension, pVBInfo); |
| 7497 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7498 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7499 | } |
| 7500 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7501 | unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
| 7502 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7503 | struct vb_device_info *pVBInfo) |
| 7504 | { |
| 7505 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
| 7506 | |
| 7507 | tempbx = pVBInfo->VBInfo; |
| 7508 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7509 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 7510 | pVBInfo->SelectCRT2Rate = 4; |
| 7511 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7512 | ModeIdIndex, pVBInfo); |
| 7513 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
| 7514 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7515 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7516 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7517 | RefreshRateTableIndex, pVBInfo); |
| 7518 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7519 | RefreshRateTableIndex, pVBInfo); |
| 7520 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7521 | RefreshRateTableIndex, pVBInfo); |
| 7522 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7523 | HwDeviceExtension, pVBInfo); |
| 7524 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7525 | RefreshRateTableIndex, pVBInfo); |
| 7526 | XGI_SetTap4Regs(pVBInfo); |
| 7527 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); |
| 7528 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7529 | HwDeviceExtension, pVBInfo); |
| 7530 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7531 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); |
| 7532 | XGI_AutoThreshold(pVBInfo); |
| 7533 | return 1; |
| 7534 | } |
| 7535 | |
| 7536 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 7537 | { |
| 7538 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 7539 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 7540 | 0x05, 0x00 }; |
| 7541 | |
| 7542 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 7543 | |
| 7544 | unsigned char CR17, CR63, SR31; |
| 7545 | unsigned short temp; |
| 7546 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; |
| 7547 | |
| 7548 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7549 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7550 | |
| 7551 | /* [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] | 7552 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7553 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7554 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 7555 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7556 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 7557 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 7558 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7559 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7560 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 7561 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7562 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7563 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7564 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7565 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7566 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7567 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7568 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7569 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7570 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7571 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7572 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7573 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7574 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7575 | |
| 7576 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7577 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7578 | |
| 7579 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7580 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7581 | CRTCData[i]); |
| 7582 | |
| 7583 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7584 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7585 | CRTCData[i]); |
| 7586 | |
| 7587 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7588 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7589 | CRTCData[i]); |
| 7590 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7591 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7592 | & 0xE0)); |
| 7593 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7594 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 7595 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 7596 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7597 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7598 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7599 | |
| 7600 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7601 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
| 7602 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); |
| 7603 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7604 | } |
| 7605 | |
| 7606 | XGI_VBLongWait(pVBInfo); |
| 7607 | XGI_VBLongWait(pVBInfo); |
| 7608 | XGI_VBLongWait(pVBInfo); |
| 7609 | |
| 7610 | mdelay(1); |
| 7611 | |
| 7612 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7613 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7614 | |
| 7615 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7616 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7617 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7618 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7619 | |
| 7620 | /* alan, avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7621 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7622 | |
| 7623 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7624 | outb(0, (pVBInfo->P3c8 + 1)); |
| 7625 | outb(0, (pVBInfo->P3c8 + 1)); |
| 7626 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7627 | } |
| 7628 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7629 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 7630 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 7631 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7632 | |
| 7633 | /* [2004/05/11] Vicent */ |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7634 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7635 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7636 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7637 | } |
| 7638 | |
| 7639 | void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
| 7640 | struct vb_device_info *pVBInfo) |
| 7641 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 7642 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7643 | |
| 7644 | if (pVBInfo->SetFlag == Win9xDOSMode) { |
| 7645 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7646 | | VB_XGI302LV | VB_XGI301C)) { |
| 7647 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 7648 | return; |
| 7649 | } else |
| 7650 | /* LVDS or CH7017 */ |
| 7651 | return; |
| 7652 | } |
| 7653 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7654 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7655 | | VB_XGI302LV | VB_XGI301C)) { |
| 7656 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 7657 | if (pVBInfo->SetFlag & EnableChA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7658 | /* Power on */ |
| 7659 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7660 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7661 | /* SetCRT2ToLCDA ) */ |
| 7662 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 7663 | /* Power on */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7664 | xgifb_reg_set(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7665 | 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7666 | } |
| 7667 | } |
| 7668 | } |
| 7669 | |
| 7670 | if (!(pVBInfo->SetFlag & DisableChB)) { |
| 7671 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo |
| 7672 | & (SetCRT2ToLCD | SetCRT2ToTV |
| 7673 | | SetCRT2ToRAMDAC))) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7674 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7675 | pVBInfo->P3c4, 0x32); |
| 7676 | tempah &= 0xDF; |
| 7677 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7678 | if (!(pVBInfo->VBInfo & |
| 7679 | SetCRT2ToRAMDAC)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7680 | tempah |= 0x20; |
| 7681 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7682 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7683 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7684 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7685 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7686 | pVBInfo->Part1Port, 0x2E); |
| 7687 | |
| 7688 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7689 | /* BVBDOENABLE = 1 */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7690 | xgifb_reg_or(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7691 | 0x2E, 0x80); |
| 7692 | /* BScreenOFF = 0 */ |
| 7693 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7694 | } |
| 7695 | } |
| 7696 | |
| 7697 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
| 7698 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7699 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7700 | 0x20); /* shampoo 0129 */ |
| 7701 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
| 7702 | if (!XGI_DisableChISLCD(pVBInfo)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7703 | if (XGI_EnableChISLCD(pVBInfo) || |
| 7704 | (pVBInfo->VBInfo & |
| 7705 | (SetCRT2ToLCD | SetCRT2ToLCDA))) |
| 7706 | /* LVDS PLL power on */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 7707 | xgifb_reg_and( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7708 | pVBInfo->Part4Port, |
| 7709 | 0x2A, |
| 7710 | 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7711 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7712 | /* LVDS Driver power on */ |
| 7713 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7714 | } |
| 7715 | } |
| 7716 | |
| 7717 | tempah = 0x00; |
| 7718 | |
| 7719 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 7720 | tempah = 0xc0; |
| 7721 | |
| 7722 | if (!(pVBInfo->VBInfo & SetSimuScanMode)) { |
| 7723 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7724 | if (pVBInfo->VBInfo & |
| 7725 | SetCRT2ToDualEdge) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7726 | tempah = tempah & 0x40; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7727 | if (pVBInfo->VBInfo & |
| 7728 | SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7729 | tempah = tempah ^ 0xC0; |
| 7730 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7731 | if (pVBInfo->SetFlag & |
| 7732 | DisableChB) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7733 | tempah &= 0xBF; |
| 7734 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7735 | if (pVBInfo->SetFlag & |
| 7736 | DisableChA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7737 | tempah &= 0x7F; |
| 7738 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7739 | if (pVBInfo->SetFlag & |
| 7740 | EnableChB) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7741 | tempah |= 0x40; |
| 7742 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7743 | if (pVBInfo->SetFlag & |
| 7744 | EnableChA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7745 | tempah |= 0x80; |
| 7746 | } |
| 7747 | } |
| 7748 | } |
| 7749 | } |
| 7750 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7751 | /* EnablePart4_1F */ |
| 7752 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7753 | |
| 7754 | if (pVBInfo->SetFlag & Win9xDOSMode) { |
| 7755 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 7756 | return; |
| 7757 | } |
| 7758 | |
| 7759 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 7760 | XGI_VBLongWait(pVBInfo); |
| 7761 | if (!(pVBInfo->SetFlag & GatingCRT)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7762 | XGI_DisableGatingCRT(HwDeviceExtension, |
| 7763 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7764 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 7765 | XGI_VBLongWait(pVBInfo); |
| 7766 | } |
| 7767 | } |
| 7768 | } /* 301 */ |
| 7769 | else { /* LVDS */ |
| 7770 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
| 7771 | | SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7772 | /* enable CRT2 */ |
| 7773 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7774 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7775 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7776 | 0x2E); |
| 7777 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7778 | /* BVBDOENABLE = 1 */ |
| 7779 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7780 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 7781 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7782 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 7783 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7784 | } |
| 7785 | |
| 7786 | static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, |
| 7787 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 7788 | struct vb_device_info *pVBInfo) |
| 7789 | { |
| 7790 | unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp; |
| 7791 | |
| 7792 | unsigned short XGINew_P3cc = pVBInfo->P3cc; |
| 7793 | |
| 7794 | /* XGINew_CRT1Mode = ModeNo; // SaveModeID */ |
| 7795 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
| 7796 | /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */ |
| 7797 | /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */ |
| 7798 | XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); |
| 7799 | XGI_SetMiscRegs(StandTableIndex, pVBInfo); |
| 7800 | XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo); |
| 7801 | XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); |
| 7802 | XGI_SetGRCRegs(StandTableIndex, pVBInfo); |
| 7803 | XGI_ClearExt1Regs(pVBInfo); |
| 7804 | |
| 7805 | /* if (pVBInfo->IF_DEF_ExpLink) */ |
| 7806 | if (HwDeviceExtension->jChipType == XG27) { |
| 7807 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 7808 | XGI_SetDefaultVCLK(pVBInfo); |
| 7809 | } |
| 7810 | |
| 7811 | temp = ~ProgrammingCRT2; |
| 7812 | pVBInfo->SetFlag &= temp; |
| 7813 | pVBInfo->SelectCRT2Rate = 0; |
| 7814 | |
| 7815 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
| 7816 | | VB_XGI302LV | VB_XGI301C)) { |
| 7817 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA |
| 7818 | | SetInSlaveMode)) { |
| 7819 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7820 | } |
| 7821 | } |
| 7822 | |
| 7823 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7824 | ModeIdIndex, pVBInfo); |
| 7825 | if (RefreshRateTableIndex != 0xFFFF) { |
| 7826 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
| 7827 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7828 | pVBInfo, HwDeviceExtension); |
| 7829 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 7830 | RefreshRateTableIndex, pVBInfo); |
| 7831 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7832 | HwDeviceExtension, pVBInfo); |
| 7833 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7834 | RefreshRateTableIndex, pVBInfo); |
| 7835 | } |
| 7836 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7837 | if ((HwDeviceExtension->jChipType >= XG20) && |
| 7838 | (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7839 | if ((ModeNo == 0x00) | (ModeNo == 0x01)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7840 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E); |
| 7841 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7842 | b3CC = (unsigned char) inb(XGINew_P3cc); |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7843 | outb((b3CC |= 0x0C), XGINew_P3cc); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7844 | } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo |
| 7845 | == 0x0D)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7846 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 7847 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7848 | b3CC = (unsigned char) inb(XGINew_P3cc); |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7849 | outb((b3CC |= 0x0C), XGINew_P3cc); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7850 | } |
| 7851 | } |
| 7852 | |
| 7853 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7854 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7855 | if (temp & 0xA0) { |
| 7856 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7857 | /* Enable write GPIOF */ |
| 7858 | /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */ |
| 7859 | /* P. DWN */ |
| 7860 | /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7861 | /* XG21 CRT1 Timing */ |
| 7862 | if (HwDeviceExtension->jChipType == XG27) |
| 7863 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, |
| 7864 | RefreshRateTableIndex, pVBInfo); |
| 7865 | else |
| 7866 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, |
| 7867 | RefreshRateTableIndex, pVBInfo); |
| 7868 | |
| 7869 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 7870 | RefreshRateTableIndex); |
| 7871 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 7872 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
| 7873 | pVBInfo, RefreshRateTableIndex, ModeNo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7874 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 7875 | if (pVBInfo->IF_DEF_LVDS == 1) |
| 7876 | xgifb_set_lvds(HwDeviceExtension->jChipType, |
| 7877 | ModeNo, ModeIdIndex, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7878 | /* P. ON */ |
| 7879 | /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7880 | } |
| 7881 | } |
| 7882 | |
| 7883 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
| 7884 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); |
| 7885 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 7886 | RefreshRateTableIndex, pVBInfo); |
| 7887 | |
| 7888 | /* XGI_LoadCharacter(); //dif ifdef TVFont */ |
| 7889 | |
| 7890 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
| 7891 | /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */ |
| 7892 | } |
| 7893 | |
| 7894 | unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, |
| 7895 | unsigned short ModeNo) |
| 7896 | { |
| 7897 | unsigned short ModeIdIndex; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7898 | /* unsigned char *pVBInfo->FBAddr = |
| 7899 | HwDeviceExtension->pjVideoMemoryAddress; */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7900 | struct vb_device_info VBINF; |
| 7901 | struct vb_device_info *pVBInfo = &VBINF; |
| 7902 | pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; |
| 7903 | pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; |
| 7904 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7905 | pVBInfo->IF_DEF_LCDA = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7906 | pVBInfo->IF_DEF_VideoCapture = 0; |
| 7907 | pVBInfo->IF_DEF_ScaleLCD = 0; |
| 7908 | pVBInfo->IF_DEF_OEMUtil = 0; |
| 7909 | pVBInfo->IF_DEF_PWD = 0; |
| 7910 | |
| 7911 | if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ |
| 7912 | pVBInfo->IF_DEF_YPbPr = 0; |
| 7913 | pVBInfo->IF_DEF_HiVision = 0; |
| 7914 | pVBInfo->IF_DEF_CRT2Monitor = 0; |
| 7915 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7916 | } else { |
| 7917 | pVBInfo->IF_DEF_YPbPr = 1; |
| 7918 | pVBInfo->IF_DEF_HiVision = 1; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 7919 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7920 | } |
| 7921 | |
| 7922 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; |
| 7923 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; |
| 7924 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; |
| 7925 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; |
| 7926 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; |
| 7927 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; |
| 7928 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; |
| 7929 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; |
| 7930 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; |
| 7931 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; |
| 7932 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; |
| 7933 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; |
| 7934 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; |
| 7935 | pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04; |
| 7936 | pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10; |
| 7937 | pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12; |
| 7938 | pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14; |
| 7939 | pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2; |
| 7940 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7941 | /* for x86 Linux, XG21 LVDS */ |
| 7942 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7943 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7944 | pVBInfo->IF_DEF_LVDS = 1; |
| 7945 | } |
| 7946 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7947 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 7948 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7949 | pVBInfo->IF_DEF_LVDS = 1; |
| 7950 | } |
| 7951 | } |
| 7952 | |
| 7953 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
| 7954 | XGI_GetVBType(pVBInfo); |
| 7955 | |
| 7956 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
| 7957 | if (ModeNo & 0x80) { |
| 7958 | ModeNo = ModeNo & 0x7F; |
| 7959 | /* XGINew_flag_clearbuffer = 0; */ |
| 7960 | } |
| 7961 | /* else { |
| 7962 | XGINew_flag_clearbuffer = 1; |
| 7963 | } |
| 7964 | */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7965 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7966 | |
| 7967 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ |
| 7968 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
| 7969 | |
| 7970 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 7971 | |
| 7972 | XGI_GetVGAType(HwDeviceExtension, pVBInfo); |
| 7973 | |
| 7974 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 7975 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 7976 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7977 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7978 | XGI_DisableBridge(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7979 | |
| 7980 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { |
| 7981 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, |
| 7982 | ModeIdIndex, pVBInfo); |
| 7983 | |
| 7984 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 7985 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 7986 | HwDeviceExtension, pVBInfo); |
| 7987 | } |
| 7988 | } else { |
| 7989 | if (!(pVBInfo->VBInfo & SwitchToCRT2)) { |
| 7990 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, |
| 7991 | ModeIdIndex, pVBInfo); |
| 7992 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
| 7993 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 7994 | HwDeviceExtension, |
| 7995 | pVBInfo); |
| 7996 | } |
| 7997 | } |
| 7998 | } |
| 7999 | |
| 8000 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) { |
| 8001 | switch (HwDeviceExtension->ujVBChipID) { |
| 8002 | case VB_CHIP_301: |
| 8003 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 8004 | pVBInfo); /*add for CRT2 */ |
| 8005 | break; |
| 8006 | |
| 8007 | case VB_CHIP_302: |
| 8008 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 8009 | pVBInfo); /*add for CRT2 */ |
| 8010 | break; |
| 8011 | |
| 8012 | default: |
| 8013 | break; |
| 8014 | } |
| 8015 | } |
| 8016 | |
| 8017 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
| 8018 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ |
| 8019 | XGI_CloseCRTC(HwDeviceExtension, pVBInfo); |
| 8020 | XGI_EnableBridge(HwDeviceExtension, pVBInfo); |
| 8021 | } /* !XG20 */ |
| 8022 | else { |
| 8023 | if (pVBInfo->IF_DEF_LVDS == 1) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8024 | if (!XGI_XG21CheckLVDSMode(ModeNo, |
| 8025 | ModeIdIndex, |
| 8026 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8027 | return 0; |
| 8028 | |
| 8029 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8030 | pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 8031 | St_ModeFlag & ModeInfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8032 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8033 | pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 8034 | Ext_ModeFlag & ModeInfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8035 | } |
| 8036 | |
| 8037 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 8038 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8039 | |
| 8040 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 8041 | |
| 8042 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 8043 | pVBInfo); |
| 8044 | |
| 8045 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8046 | /* |
| 8047 | if (HwDeviceExtension->jChipType == XG21) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 8048 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8049 | */ |
| 8050 | } |
| 8051 | |
| 8052 | /* |
| 8053 | if (ModeNo <= 0x13) { |
| 8054 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 8055 | } else { |
| 8056 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 8057 | } |
| 8058 | pVBInfo->ModeType = modeflag&ModeInfoFlag; |
| 8059 | pVBInfo->SetFlag = 0x00; |
| 8060 | pVBInfo->VBInfo = DisableCRT2Display; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 8061 | temp = XGINew_CheckMemorySize(HwDeviceExtension, |
| 8062 | ModeNo, |
| 8063 | ModeIdIndex, |
| 8064 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 8065 | |
| 8066 | if (temp == 0) |
| 8067 | return (0); |
| 8068 | |
| 8069 | XGI_DisplayOff(HwDeviceExtension, pVBInfo) ; |
| 8070 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); |
| 8071 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
| 8072 | */ |
| 8073 | |
| 8074 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
| 8075 | |
| 8076 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 8077 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
| 8078 | } |
| 8079 | |
| 8080 | return 1; |
| 8081 | } |