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" |
Aaro Koskinen | 09d1cad | 2011-09-13 22:49:34 +0300 | [diff] [blame] | 11 | #include "vb_init.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 12 | #include "vb_util.h" |
| 13 | #include "vb_table.h" |
Aaro Koskinen | 5e60b97 | 2011-03-08 22:16:14 +0200 | [diff] [blame] | 14 | #include "vb_setmode.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 15 | |
| 16 | |
| 17 | #define IndexMask 0xff |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 18 | |
Aaro Koskinen | 624554d | 2011-10-11 21:47:35 +0300 | [diff] [blame] | 19 | static const unsigned short XGINew_MDA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 21 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, |
| 22 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, |
| 23 | 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, |
| 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 25 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, |
| 26 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, |
| 27 | 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 28 | |
Aaro Koskinen | 624554d | 2011-10-11 21:47:35 +0300 | [diff] [blame] | 29 | static const unsigned short XGINew_CGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 30 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 31 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 32 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 33 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 34 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 35 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 36 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 37 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 38 | |
Aaro Koskinen | 624554d | 2011-10-11 21:47:35 +0300 | [diff] [blame] | 39 | static const unsigned short XGINew_EGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 40 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15, |
| 41 | 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35, |
| 42 | 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D, |
| 43 | 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D, |
| 44 | 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17, |
| 45 | 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37, |
| 46 | 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F, |
| 47 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 48 | |
Aaro Koskinen | 624554d | 2011-10-11 21:47:35 +0300 | [diff] [blame] | 49 | static const unsigned short XGINew_VGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 50 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 51 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 52 | 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18, |
| 53 | 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F, |
| 54 | 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F, |
| 55 | 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00, |
| 56 | 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18, |
| 57 | 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04, |
| 58 | 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10, |
| 59 | 0x0B, 0x0C, 0x0D, 0x0F, 0x10}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 60 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 61 | void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 62 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 63 | pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 64 | pVBInfo->StandTable = (struct SiS_StandTable_S *) XGI330_StandTable; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 65 | pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable; |
| 66 | pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex; |
| 67 | pVBInfo->XGINEWUB_CRT1Table |
| 68 | = (struct XGI_CRT1TableStruct *) XGI_CRT1Table; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 69 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 70 | pVBInfo->MCLKData = (struct SiS_MCLKData *) XGI340New_MCLKData; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 71 | pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 72 | pVBInfo->VCLKData = (struct SiS_VCLKData *) XGI_VCLKData; |
| 73 | pVBInfo->VBVCLKData = (struct SiS_VBVCLKData *) XGI_VBVCLKData; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 74 | pVBInfo->ScreenOffset = XGI330_ScreenOffset; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 75 | pVBInfo->StResInfo = (struct SiS_StResInfo_S *) XGI330_StResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 76 | pVBInfo->ModeResInfo |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 77 | = (struct SiS_ModeResInfo_S *) XGI330_ModeResInfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 78 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 79 | pVBInfo->pOutputSelect = &XGI330_OutputSelect; |
| 80 | pVBInfo->pSoftSetting = &XGI330_SoftSetting; |
| 81 | pVBInfo->pSR07 = &XGI330_SR07; |
| 82 | pVBInfo->LCDResInfo = 0; |
| 83 | pVBInfo->LCDTypeInfo = 0; |
| 84 | pVBInfo->LCDInfo = 0; |
| 85 | pVBInfo->VBInfo = 0; |
| 86 | pVBInfo->TVInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 87 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 88 | pVBInfo->SR15 = XGI340_SR13; |
| 89 | pVBInfo->CR40 = XGI340_cr41; |
| 90 | pVBInfo->SR25 = XGI330_sr25; |
| 91 | pVBInfo->pSR31 = &XGI330_sr31; |
| 92 | pVBInfo->pSR32 = &XGI330_sr32; |
| 93 | pVBInfo->CR6B = XGI340_CR6B; |
| 94 | pVBInfo->CR6E = XGI340_CR6E; |
| 95 | pVBInfo->CR6F = XGI340_CR6F; |
| 96 | pVBInfo->CR89 = XGI340_CR89; |
| 97 | pVBInfo->AGPReg = XGI340_AGPReg; |
| 98 | pVBInfo->SR16 = XGI340_SR16; |
| 99 | pVBInfo->pCRCF = &XG40_CRCF; |
| 100 | pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 101 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 102 | pVBInfo->CR49 = XGI330_CR49; |
| 103 | pVBInfo->pSR1F = &XGI330_SR1F; |
| 104 | pVBInfo->pSR21 = &XGI330_SR21; |
| 105 | pVBInfo->pSR22 = &XGI330_SR22; |
| 106 | pVBInfo->pSR23 = &XGI330_SR23; |
| 107 | pVBInfo->pSR24 = &XGI330_SR24; |
| 108 | pVBInfo->pSR33 = &XGI330_SR33; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 109 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 110 | pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2; |
| 111 | pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D; |
| 112 | pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E; |
| 113 | pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10; |
| 114 | pVBInfo->pRGBSenseData = &XGI330_RGBSenseData; |
| 115 | pVBInfo->pVideoSenseData = &XGI330_VideoSenseData; |
| 116 | pVBInfo->pYCSenseData = &XGI330_YCSenseData; |
| 117 | pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2; |
| 118 | pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2; |
| 119 | pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 120 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 121 | pVBInfo->NTSCTiming = XGI330_NTSCTiming; |
| 122 | pVBInfo->PALTiming = XGI330_PALTiming; |
| 123 | pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming; |
| 124 | pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing; |
| 125 | pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing; |
| 126 | pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming; |
| 127 | pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming; |
| 128 | pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming; |
| 129 | pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming; |
| 130 | pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data; |
| 131 | pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu; |
| 132 | pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text; |
| 133 | pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3; |
| 134 | pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 135 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 136 | pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH; |
| 137 | pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV; |
| 138 | pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table; |
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 | /* 310 customization related */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 141 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 142 | pVBInfo->LCDCapList = XGI_LCDDLCapList; |
| 143 | else |
| 144 | pVBInfo->LCDCapList = XGI_LCDCapList; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 145 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 146 | pVBInfo->XGI_TVDelayList = XGI301TVDelayList; |
| 147 | pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 148 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 149 | pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 150 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 151 | if (ChipType >= XG20) |
| 152 | pVBInfo->pXGINew_CR97 = &XG20_CR97; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 153 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 154 | if (ChipType == XG27) { |
| 155 | pVBInfo->MCLKData |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 156 | = (struct SiS_MCLKData *) XGI27New_MCLKData; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 157 | pVBInfo->CR40 = XGI27_cr41; |
| 158 | pVBInfo->pXGINew_CR97 = &XG27_CR97; |
| 159 | pVBInfo->pSR36 = &XG27_SR36; |
| 160 | pVBInfo->pCR8F = &XG27_CR8F; |
| 161 | pVBInfo->pCRD0 = XG27_CRD0; |
| 162 | pVBInfo->pCRDE = XG27_CRDE; |
| 163 | pVBInfo->pSR40 = &XG27_SR40; |
| 164 | pVBInfo->pSR41 = &XG27_SR41; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 165 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 166 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 167 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 168 | if (ChipType >= XG20) { |
| 169 | pVBInfo->pDVOSetting = &XG21_DVOSetting; |
| 170 | pVBInfo->pCR2E = &XG21_CR2E; |
| 171 | pVBInfo->pCR2F = &XG21_CR2F; |
| 172 | pVBInfo->pCR46 = &XG21_CR46; |
| 173 | pVBInfo->pCR47 = &XG21_CR47; |
| 174 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 175 | |
| 176 | } |
| 177 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 178 | static unsigned char XGI_GetModePtr(unsigned short ModeNo, |
| 179 | unsigned short ModeIdIndex, |
| 180 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 181 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 182 | unsigned char index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 183 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 184 | if (ModeNo <= 0x13) |
| 185 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex; |
| 186 | else { |
| 187 | if (pVBInfo->ModeType <= 0x02) |
| 188 | index = 0x1B; /* 02 -> ModeEGA */ |
| 189 | else |
| 190 | index = 0x0F; |
| 191 | } |
| 192 | return index; /* Get pVBInfo->StandTable index */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 193 | } |
| 194 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 195 | static void XGI_SetSeqRegs(unsigned short ModeNo, |
| 196 | unsigned short StandTableIndex, |
| 197 | unsigned short ModeIdIndex, |
| 198 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 199 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 200 | unsigned char tempah, SRdata; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 201 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 202 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 203 | if (ModeNo <= 0x13) |
| 204 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 205 | else |
| 206 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 207 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 208 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 209 | tempah = pVBInfo->StandTable[StandTableIndex].SR[0]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 210 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 211 | i = XGI_SetCRT2ToLCDA; |
| 212 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 213 | tempah |= 0x01; |
| 214 | } else { |
| 215 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { |
| 216 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 217 | tempah |= 0x01; |
| 218 | } |
| 219 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 220 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 221 | tempah |= 0x20; /* screen off */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 222 | xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 223 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 224 | for (i = 02; i <= 04; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 225 | /* Get SR2,3,4 from file */ |
| 226 | SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 227 | xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 228 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 229 | } |
| 230 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 231 | static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 232 | unsigned short StandTableIndex, |
| 233 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 234 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 235 | unsigned char CRTCdata; |
| 236 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 237 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 238 | CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 239 | CRTCdata &= 0x7f; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 240 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 241 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 242 | for (i = 0; i <= 0x18; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 243 | /* Get CRTC from file */ |
| 244 | CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 245 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 246 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 247 | } |
| 248 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 249 | static void XGI_SetATTRegs(unsigned short ModeNo, |
| 250 | unsigned short StandTableIndex, |
| 251 | unsigned short ModeIdIndex, |
| 252 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 253 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 254 | unsigned char ARdata; |
| 255 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 256 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 257 | if (ModeNo <= 0x13) |
| 258 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 259 | else |
| 260 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 261 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 262 | for (i = 0; i <= 0x13; i++) { |
| 263 | ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i]; |
| 264 | if (modeflag & Charx8Dot) { /* ifndef Dot9 */ |
| 265 | if (i == 0x13) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 266 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 267 | ARdata = 0; |
| 268 | } else { |
| 269 | if (pVBInfo->VBInfo & (SetCRT2ToTV |
| 270 | | SetCRT2ToLCD)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 271 | if (pVBInfo->VBInfo & |
| 272 | SetInSlaveMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 273 | ARdata = 0; |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 278 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 279 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 280 | outb(i, pVBInfo->P3c0); /* set index */ |
| 281 | outb(ARdata, pVBInfo->P3c0); /* set data */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 282 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 283 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 284 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 285 | outb(0x14, pVBInfo->P3c0); /* set index */ |
| 286 | outb(0x00, pVBInfo->P3c0); /* set data */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 287 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 288 | outb(0x20, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 291 | static void XGI_SetGRCRegs(unsigned short StandTableIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 292 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 293 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 294 | unsigned char GRdata; |
| 295 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 296 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 297 | for (i = 0; i <= 0x08; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 298 | /* Get GR from file */ |
| 299 | GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 300 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 301 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 302 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 303 | if (pVBInfo->ModeType > ModeVGA) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 304 | GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 305 | GRdata &= 0xBF; /* 256 color disable */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 306 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 307 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 308 | } |
| 309 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 310 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 311 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 312 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 313 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 314 | for (i = 0x0A; i <= 0x0E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 315 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 316 | } |
| 317 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 318 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 319 | { |
| 320 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 321 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 322 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B); |
| 323 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 324 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 325 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 326 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B); |
| 327 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 328 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 329 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 330 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 331 | } |
| 332 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 333 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 334 | unsigned short ModeIdIndex, |
| 335 | unsigned short RefreshRateTableIndex, unsigned short *i, |
| 336 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 337 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 338 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 339 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 340 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 341 | /* si+St_ModeFlag */ |
| 342 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 343 | else |
| 344 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 345 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 346 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 347 | tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID; |
| 348 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 349 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 350 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 351 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 352 | tempax |= SupportRAMDAC2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 353 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 354 | if (pVBInfo->VBType & VB_XGI301C) |
| 355 | tempax |= SupportCRT2in301C; |
| 356 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 357 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 358 | /* 301b */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 359 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 360 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 361 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 362 | if (pVBInfo->LCDResInfo != Panel_1280x1024) { |
| 363 | if (pVBInfo->LCDResInfo != Panel_1280x960) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 364 | if (pVBInfo->LCDInfo & |
| 365 | LCDNonExpanding) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 366 | if (resinfo >= 9) { |
| 367 | tempax = 0; |
| 368 | return 0; |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 374 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 375 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 376 | if ((pVBInfo->VBType & VB_SIS301LV) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 377 | (pVBInfo->VBExtInfo == VB_YPbPr1080i)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 378 | tempax |= SupportYPbPr750p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 379 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 380 | if (resinfo == 4) |
| 381 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 382 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 383 | if (resinfo == 3) |
| 384 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 385 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 386 | if (resinfo > 7) |
| 387 | return 0; |
| 388 | } |
| 389 | } else { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 390 | tempax |= SupportHiVision; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 391 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 392 | if (resinfo == 4) |
| 393 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 394 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 395 | if (resinfo == 3) { |
| 396 | if (pVBInfo->SetFlag |
| 397 | & TVSimuMode) |
| 398 | return 0; |
| 399 | } |
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 (resinfo > 7) |
| 402 | return 0; |
| 403 | } |
| 404 | } |
| 405 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 406 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
| 407 | SetCRT2ToSVIDEO | |
| 408 | SetCRT2ToSCART | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 409 | SetCRT2ToYPbPr525750 | |
| 410 | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 411 | tempax |= SupportTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 412 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 413 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 414 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 415 | | VB_XGI301C)) { |
| 416 | tempax |= SupportTV1024; |
| 417 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 418 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 419 | if (!(pVBInfo->VBInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 420 | if (modeflag & NoSupportSimuTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 421 | if (pVBInfo->VBInfo & |
| 422 | SetInSlaveMode) { |
| 423 | if (!(pVBInfo->VBInfo & |
| 424 | SetNotSimuMode)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 425 | return 0; |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | } else { /* for LVDS */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 433 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 434 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 435 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 436 | if (resinfo > 0x08) |
| 437 | return 0; /* 1024x768 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 438 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 439 | if (pVBInfo->LCDResInfo < Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 440 | if (resinfo > 0x07) |
| 441 | return 0; /* 800x600 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 442 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 443 | if (resinfo == 0x04) |
| 444 | return 0; /* 512x384 */ |
| 445 | } |
| 446 | } |
| 447 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 448 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 449 | for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
| 450 | tempbx; (*i)--) { |
| 451 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
| 452 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 453 | if (infoflag & tempax) |
| 454 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 455 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 456 | if ((*i) == 0) |
| 457 | break; |
| 458 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 459 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 460 | for ((*i) = 0;; (*i)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 461 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
| 462 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 463 | if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID |
| 464 | != tempbx) { |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | if (infoflag & tempax) |
| 469 | return 1; |
| 470 | } |
| 471 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 472 | } |
| 473 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 474 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 475 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 476 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 477 | unsigned short sync, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 478 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 479 | /* di+0x00 */ |
| 480 | sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 481 | sync &= 0xC0; |
| 482 | temp = 0x2F; |
| 483 | temp |= sync; |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 484 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 485 | } |
| 486 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 487 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 488 | struct xgi_hw_device_info *HwDeviceExtension) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 489 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 490 | unsigned char data, data1, pushax; |
| 491 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 492 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 493 | /* unlock cr0-7 */ |
| 494 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 495 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 496 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 497 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 498 | data = pVBInfo->TimingH[0].data[0]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 499 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 500 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 501 | for (i = 0x01; i <= 0x04; i++) { |
| 502 | data = pVBInfo->TimingH[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 503 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 504 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 505 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 506 | for (i = 0x05; i <= 0x06; i++) { |
| 507 | data = pVBInfo->TimingH[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 508 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 509 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 510 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 511 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 512 | j &= 0x1F; |
| 513 | data = pVBInfo->TimingH[0].data[7]; |
| 514 | data &= 0xE0; |
| 515 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 516 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 517 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 518 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 519 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 520 | data = data - 1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 521 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 522 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 523 | data1 = data; |
| 524 | data1 &= 0xE0; |
| 525 | data &= 0x1F; |
| 526 | if (data == 0) { |
| 527 | pushax = data; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 528 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 529 | 0x0c); |
| 530 | data &= 0xFB; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 531 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 532 | data = pushax; |
| 533 | } |
| 534 | data = data - 1; |
| 535 | data |= data1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 536 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 537 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 538 | data = data >> 5; |
| 539 | data = data + 3; |
| 540 | if (data > 7) |
| 541 | data = data - 7; |
| 542 | data = data << 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 543 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 544 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 545 | } |
| 546 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 547 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
| 548 | unsigned short ModeNo, |
| 549 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 550 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 551 | unsigned char data; |
| 552 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 553 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 554 | for (i = 0x00; i <= 0x01; i++) { |
| 555 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 556 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 557 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 558 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 559 | for (i = 0x02; i <= 0x03; i++) { |
| 560 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 561 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 562 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 563 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 564 | for (i = 0x04; i <= 0x05; i++) { |
| 565 | data = pVBInfo->TimingV[0].data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 566 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 567 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 568 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 569 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 570 | j &= 0xC0; |
| 571 | data = pVBInfo->TimingV[0].data[6]; |
| 572 | data &= 0x3F; |
| 573 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 574 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 575 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 576 | data = pVBInfo->TimingV[0].data[6]; |
| 577 | data &= 0x80; |
| 578 | data = data >> 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 579 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 580 | if (ModeNo <= 0x13) |
| 581 | i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 582 | else |
| 583 | i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 584 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 585 | i &= DoubleScanMode; |
| 586 | if (i) |
| 587 | data |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 588 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 589 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 590 | j &= 0x5F; |
| 591 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 592 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 593 | } |
| 594 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 595 | static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 596 | unsigned short RefreshRateTableIndex, |
| 597 | struct vb_device_info *pVBInfo, |
| 598 | struct xgi_hw_device_info *HwDeviceExtension) |
| 599 | { |
| 600 | unsigned char index, data; |
| 601 | unsigned short i; |
| 602 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 603 | /* Get index */ |
| 604 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 605 | index = index & IndexMask; |
| 606 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 607 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 608 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 609 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 610 | |
| 611 | for (i = 0; i < 8; i++) |
| 612 | pVBInfo->TimingH[0].data[i] |
| 613 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i]; |
| 614 | |
| 615 | for (i = 0; i < 7; i++) |
| 616 | pVBInfo->TimingV[0].data[i] |
| 617 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8]; |
| 618 | |
| 619 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 620 | |
| 621 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
| 622 | |
| 623 | if (pVBInfo->ModeType > 0x03) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 624 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 625 | } |
| 626 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 627 | /* --------------------------------------------------------------------- */ |
| 628 | /* Function : XGI_SetXG21CRTC */ |
| 629 | /* Input : Stand or enhance CRTC table */ |
| 630 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ |
| 631 | /* Description : Set LCD timing */ |
| 632 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 633 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 634 | unsigned short RefreshRateTableIndex, |
| 635 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 636 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 637 | unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
| 638 | unsigned short Temp1, Temp2, Temp3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 639 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 640 | if (ModeNo <= 0x13) { |
| 641 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 642 | /* CR04 HRS */ |
| 643 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; |
| 644 | /* SR2E [7:0]->HRS */ |
| 645 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
| 646 | /* Tempbx: CR05 HRE */ |
| 647 | Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 648 | Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */ |
| 649 | Tempcx = Tempax; |
| 650 | Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */ |
| 651 | Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */ |
| 652 | if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */ |
| 653 | Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */ |
| 654 | Tempdx <<= 2; /* Tempdx << 2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 655 | /* SR2F [7:2]->HRE */ |
| 656 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 657 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 658 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 659 | /* Tempax: CR16 VRS */ |
| 660 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 661 | Tempbx = Tempax; /* Tempbx=Tempax */ |
| 662 | Tempax &= 0x01; /* Tempax: VRS[0] */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 663 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 664 | |
| 665 | /* Tempax: CR7 VRS */ |
| 666 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 667 | Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */ |
| 668 | Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */ |
| 669 | Tempcx <<= 5; /* Tempcx[7]: VRS[8] */ |
| 670 | Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 671 | /* SR34[7:0]: VRS[8:1] */ |
| 672 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 673 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 674 | /* Temp1[8]: VRS[8] unsigned char -> unsigned short */ |
| 675 | Temp1 = Tempcx << 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 676 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 677 | Tempax &= 0x80; /* Tempax[7]: CR7[7] */ |
| 678 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 679 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 680 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 681 | /* CR16 VRE */ |
| 682 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 683 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 684 | Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */ |
| 685 | Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */ |
| 686 | Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */ |
| 687 | if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */ |
| 688 | Temp2 |= 0x10; /* Temp2: VRE + 0x10 */ |
| 689 | Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */ |
| 690 | Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */ |
| 691 | Tempax <<= 2; /* Tempax << 2: VRE[5:0] */ |
| 692 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 693 | Temp1 >>= 9; /* [10:9]->[1:0] */ |
| 694 | Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */ |
| 695 | Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */ |
| 696 | Tempax &= 0x7F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 697 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 698 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 699 | } else { |
| 700 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 701 | /* Tempax: CR4 HRS */ |
| 702 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 703 | Tempcx = Tempax; /* Tempcx: HRS */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 704 | /* SR2E[7:0]->HRS */ |
| 705 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 706 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 707 | Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */ |
| 708 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ |
| 709 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ |
| 710 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ |
| 711 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 712 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 713 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
| 714 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 715 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 716 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
| 717 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ |
| 718 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ |
| 719 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 720 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 721 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
| 722 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 723 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 724 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
| 725 | if (Tempax < Tempcx) /* HRE < HRS */ |
| 726 | Temp2 |= 0x40; /* Temp2 + 0x40 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 727 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 728 | Temp2 &= 0xFF; |
| 729 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ |
| 730 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ |
| 731 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ |
| 732 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 733 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
| 734 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 735 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 736 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 737 | /* CR10 VRS */ |
| 738 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 739 | Tempbx = Tempax; /* Tempbx: VRS */ |
| 740 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 741 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 742 | /* CR7[2][7] VRE */ |
| 743 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 744 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
| 745 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ |
| 746 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ |
| 747 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 748 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 749 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 750 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
| 751 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ |
| 752 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 753 | Tempax &= 0x80; |
| 754 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 755 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 756 | /* Tempax: SRA */ |
| 757 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 758 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
| 759 | Temp2 = Tempax; |
| 760 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ |
| 761 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 762 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 763 | /* Tempax: CR11 VRE */ |
| 764 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 765 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 766 | /* Tempbx: SRA */ |
| 767 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 768 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
| 769 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 770 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 771 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ |
| 772 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 773 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 774 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
| 775 | if (Tempax < Temp3) /* VRE < VRS */ |
| 776 | Temp2 |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 777 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 778 | Temp2 &= 0xFF; |
| 779 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ |
| 780 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ |
| 781 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 782 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ |
| 783 | Tempbx = (unsigned char) Temp1; |
| 784 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ |
| 785 | Tempax &= 0x7F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 786 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 787 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 788 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 789 | } |
| 790 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 791 | static void XGI_SetXG27CRTC(unsigned short ModeNo, |
| 792 | unsigned short ModeIdIndex, |
| 793 | unsigned short RefreshRateTableIndex, |
| 794 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 795 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 796 | unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 797 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 798 | if (ModeNo <= 0x13) { |
| 799 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 800 | /* CR04 HRS */ |
| 801 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; |
| 802 | /* SR2E [7:0]->HRS */ |
| 803 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
| 804 | /* Tempbx: CR05 HRE */ |
| 805 | Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 806 | Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */ |
| 807 | Tempcx = Tempax; |
| 808 | Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */ |
| 809 | Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */ |
| 810 | if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */ |
| 811 | Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */ |
| 812 | Tempdx <<= 2; /* Tempdx << 2 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 813 | /* SR2F [7:2]->HRE */ |
| 814 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 815 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 816 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 817 | /* Tempax: CR10 VRS */ |
| 818 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 819 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 820 | Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 821 | /* Tempax[7][2]: CR7[7][2] VRS[9][8] */ |
| 822 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 823 | Tempbx = Tempax; /* Tempbx=CR07 */ |
| 824 | Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */ |
| 825 | Tempax >>= 2; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 826 | /* SR35 D[0]->VRS D[8] */ |
| 827 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 828 | Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */ |
| 829 | Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 830 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 831 | /* CR11 VRE */ |
| 832 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 833 | Tempax &= 0x0F; /* Tempax: VRE[3:0] */ |
| 834 | Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */ |
| 835 | Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */ |
| 836 | Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */ |
| 837 | if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */ |
| 838 | Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 839 | /* Tempax[7:0]: VRE[7:0] */ |
| 840 | Tempax = (unsigned char) Tempbx & 0xFF; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 841 | Tempax <<= 2; /* Tempax << 2: VRE[5:0] */ |
| 842 | Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 843 | /* SR3F D[7:2]->VRE D[5:0] */ |
| 844 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
| 845 | /* SR35 D[2:1]->VRS[10:9] */ |
| 846 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 847 | } else { |
| 848 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 849 | /* Tempax: CR4 HRS */ |
| 850 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 851 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 852 | /* SR2E[7:0]->HRS */ |
| 853 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 854 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 855 | /* SR0B */ |
| 856 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 857 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 858 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 859 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 860 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
| 861 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
| 862 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 863 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 864 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
| 865 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ |
| 866 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ |
| 867 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 868 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 869 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
| 870 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 871 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 872 | /* Tempax: CR4 HRS */ |
| 873 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 874 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
| 875 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ |
| 876 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 877 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 878 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */ |
| 879 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 880 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ |
| 881 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 882 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
| 883 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 884 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 885 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 886 | /* CR10 VRS */ |
| 887 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; |
| 888 | /* SR34[7:0]->VRS[7:0] */ |
| 889 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 890 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 891 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 892 | /* CR7[7][2] VRS[9][8] */ |
| 893 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 894 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
| 895 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ |
| 896 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 897 | /* SR35[0]: VRS[8] */ |
| 898 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 899 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
| 900 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 901 | /* Tempax: SR0A */ |
| 902 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 903 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
| 904 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 905 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 906 | /* Tempax: CR11 VRE */ |
| 907 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 908 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 909 | /* Tempbx: SR0A */ |
| 910 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 911 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
| 912 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 913 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 914 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ |
| 915 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ |
| 916 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 917 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 918 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
| 919 | Tempbx |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 920 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 921 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
| 922 | Tempax = (Tempbx << 2) & 0xFF; |
| 923 | /* SR3F[7:2]:VRE[5:0] */ |
| 924 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 925 | Tempax = Tempcx >> 8; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 926 | /* SR35[2:0]:VRS[10:8] */ |
| 927 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 928 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 929 | } |
| 930 | |
Aaro Koskinen | a2d08cf | 2011-11-27 23:03:08 +0200 | [diff] [blame] | 931 | static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
| 932 | { |
| 933 | unsigned char temp; |
| 934 | |
| 935 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 936 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 937 | temp = (temp & 3) << 6; |
| 938 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 939 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 940 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 941 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 942 | |
| 943 | } |
| 944 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 945 | static void xgifb_set_lcd(int chip_id, |
| 946 | struct vb_device_info *pVBInfo, |
| 947 | unsigned short RefreshRateTableIndex, |
| 948 | unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 949 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 950 | unsigned short Data, Temp, b3CC; |
| 951 | unsigned short XGI_P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 952 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 953 | XGI_P3cc = pVBInfo->P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 954 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 955 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 956 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 957 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 958 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 959 | |
| 960 | if (chip_id == XG27) { |
| 961 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 962 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
| 963 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 964 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
| 965 | } |
| 966 | } |
| 967 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 968 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 969 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); |
| 970 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); |
| 971 | xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); |
| 972 | xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 973 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 974 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 975 | if (chip_id == XG27) { |
| 976 | XGI_SetXG27FPBits(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 977 | } else { |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 978 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 979 | if (Temp & 0x01) { |
| 980 | /* 18 bits FP */ |
| 981 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); |
| 982 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
| 983 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 984 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 985 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 986 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 987 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 988 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 989 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 990 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 991 | if (ModeNo <= 0x13) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 992 | b3CC = (unsigned char) inb(XGI_P3cc); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 993 | if (b3CC & 0x40) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 994 | /* Hsync polarity */ |
| 995 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 996 | if (b3CC & 0x80) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 997 | /* Vsync polarity */ |
| 998 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 999 | } else { |
| 1000 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1001 | if (Data & 0x4000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1002 | /* Hsync polarity */ |
| 1003 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1004 | if (Data & 0x8000) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1005 | /* Vsync polarity */ |
| 1006 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1007 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | /* --------------------------------------------------------------------- */ |
| 1011 | /* Function : XGI_UpdateXG21CRTC */ |
| 1012 | /* Input : */ |
| 1013 | /* Output : CRT1 CRTC */ |
| 1014 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 1015 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1016 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 1017 | struct vb_device_info *pVBInfo, |
| 1018 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1019 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1020 | int i, index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1021 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 1022 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1023 | if (ModeNo <= 0x13) { |
| 1024 | for (i = 0; i < 12; i++) { |
| 1025 | if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID) |
| 1026 | index = i; |
| 1027 | } |
| 1028 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1029 | if (ModeNo == 0x2E && |
| 1030 | (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
| 1031 | RES640x480x60)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1032 | index = 12; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1033 | else if (ModeNo == 0x2E && |
| 1034 | (pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1035 | Ext_CRT1CRTC == RES640x480x72)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1036 | index = 13; |
| 1037 | else if (ModeNo == 0x2F) |
| 1038 | index = 14; |
| 1039 | else if (ModeNo == 0x50) |
| 1040 | index = 15; |
| 1041 | else if (ModeNo == 0x59) |
| 1042 | index = 16; |
| 1043 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1044 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1045 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1046 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1047 | pVBInfo->UpdateCRT1[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1048 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1049 | pVBInfo->UpdateCRT1[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1050 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1051 | pVBInfo->UpdateCRT1[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1052 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1053 | pVBInfo->UpdateCRT1[index].CR16); |
| 1054 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1055 | } |
| 1056 | |
Aaro Koskinen | 0646596 | 2011-11-27 23:03:06 +0200 | [diff] [blame] | 1057 | static unsigned short XGI_GetResInfo(unsigned short ModeNo, |
| 1058 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
| 1059 | { |
| 1060 | unsigned short resindex; |
| 1061 | |
| 1062 | if (ModeNo <= 0x13) |
| 1063 | /* si+St_ResInfo */ |
| 1064 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 1065 | else |
| 1066 | /* si+Ext_ResInfo */ |
| 1067 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 1068 | return resindex; |
| 1069 | } |
| 1070 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1071 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1072 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1073 | unsigned short RefreshRateTableIndex, |
| 1074 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1075 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 1076 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
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 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1079 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1080 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1081 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1082 | if (ModeNo <= 0x13) { |
| 1083 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1084 | tempax = pVBInfo->StResInfo[resindex].HTotal; |
| 1085 | tempbx = pVBInfo->StResInfo[resindex].VTotal; |
| 1086 | } else { |
| 1087 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1088 | tempax = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1089 | tempbx = pVBInfo->ModeResInfo[resindex].VTotal; |
| 1090 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1091 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1092 | if (modeflag & HalfDCLK) |
| 1093 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1094 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1095 | if (ModeNo > 0x13) { |
| 1096 | if (modeflag & HalfDCLK) |
| 1097 | tempax = tempax << 1; |
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 | temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
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 (temp & InterlaceMode) |
| 1102 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1103 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1104 | if (modeflag & DoubleScanMode) |
| 1105 | tempbx = tempbx << 1; |
| 1106 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1107 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1108 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1109 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1110 | tempax /= tempcx; |
| 1111 | tempax -= 1; |
| 1112 | tempbx -= 1; |
| 1113 | tempcx = tempax; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1114 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 1115 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1116 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1117 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 1118 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1119 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1120 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1121 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1122 | tempax = 0; |
| 1123 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1124 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1125 | if (tempbx & 0x01) |
| 1126 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1127 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1128 | if (tempbx & 0x02) |
| 1129 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1130 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1131 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1132 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1133 | data &= 0xFF; |
| 1134 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1135 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1136 | if (tempbx & 0x04) |
| 1137 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1138 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1139 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1140 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1141 | } |
| 1142 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1143 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 1144 | unsigned short ModeIdIndex, |
| 1145 | unsigned short RefreshRateTableIndex, |
| 1146 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1147 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1148 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1149 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1150 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1151 | /* GetOffset */ |
| 1152 | temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 1153 | temp = temp >> 8; |
| 1154 | temp = pVBInfo->ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1155 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1156 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1157 | temp2 &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1158 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1159 | if (temp2) |
| 1160 | temp = temp << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1161 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1162 | temp2 = pVBInfo->ModeType - ModeEGA; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1163 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1164 | switch (temp2) { |
| 1165 | case 0: |
| 1166 | temp2 = 1; |
| 1167 | break; |
| 1168 | case 1: |
| 1169 | temp2 = 2; |
| 1170 | break; |
| 1171 | case 2: |
| 1172 | temp2 = 4; |
| 1173 | break; |
| 1174 | case 3: |
| 1175 | temp2 = 4; |
| 1176 | break; |
| 1177 | case 4: |
| 1178 | temp2 = 6; |
| 1179 | break; |
| 1180 | case 5: |
| 1181 | temp2 = 8; |
| 1182 | break; |
| 1183 | default: |
| 1184 | break; |
| 1185 | } |
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 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 1188 | temp = temp * temp2 + temp2 / 2; |
| 1189 | else |
| 1190 | temp *= temp2; |
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 | /* SetOffset */ |
| 1193 | DisplayUnit = temp; |
| 1194 | temp2 = temp; |
| 1195 | temp = temp >> 8; /* ah */ |
| 1196 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1197 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1198 | i &= 0xF0; |
| 1199 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1200 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1201 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1202 | temp = (unsigned char) temp2; |
| 1203 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1204 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1205 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1206 | /* SetDisplayUnit */ |
| 1207 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 1208 | temp2 &= InterlaceMode; |
| 1209 | if (temp2) |
| 1210 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1211 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1212 | DisplayUnit = DisplayUnit << 5; |
| 1213 | ah = (DisplayUnit & 0xff00) >> 8; |
| 1214 | al = DisplayUnit & 0x00ff; |
| 1215 | if (al == 0) |
| 1216 | ah += 1; |
| 1217 | else |
| 1218 | ah += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1219 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1220 | if (HwDeviceExtension->jChipType >= XG20) |
| 1221 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 1222 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1223 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1224 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1225 | } |
| 1226 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1227 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
| 1228 | unsigned short ModeIdIndex, |
| 1229 | unsigned short RefreshRateTableIndex, |
| 1230 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1231 | struct vb_device_info *pVBInfo) |
| 1232 | { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1233 | unsigned short LCDXlat1VCLK[4] = { VCLK65_315 + 2, |
| 1234 | VCLK65_315 + 2, |
| 1235 | VCLK65_315 + 2, |
| 1236 | VCLK65_315 + 2 }; |
| 1237 | unsigned short LCDXlat2VCLK[4] = { VCLK108_2_315 + 5, |
| 1238 | VCLK108_2_315 + 5, |
| 1239 | VCLK108_2_315 + 5, |
| 1240 | VCLK108_2_315 + 5 }; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1241 | unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 }; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1242 | unsigned short LVDSXlat2VCLK[4] = { VCLK65_315 + 2, |
| 1243 | VCLK65_315 + 2, |
| 1244 | VCLK65_315 + 2, |
| 1245 | VCLK65_315 + 2 }; |
| 1246 | unsigned short LVDSXlat3VCLK[4] = { VCLK65_315 + 2, |
| 1247 | VCLK65_315 + 2, |
| 1248 | VCLK65_315 + 2, |
| 1249 | VCLK65_315 + 2 }; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1250 | |
| 1251 | unsigned short CRT2Index, VCLKIndex; |
| 1252 | unsigned short modeflag, resinfo; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1253 | |
| 1254 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1255 | /* si+St_ResInfo */ |
| 1256 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1257 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 1258 | CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 1259 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1260 | /* si+Ext_ResInfo */ |
| 1261 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1262 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1263 | CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1264 | Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1265 | } |
| 1266 | |
| 1267 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 1268 | CRT2Index = CRT2Index >> 6; /* for LCD */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1269 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1270 | if (pVBInfo->LCDResInfo != Panel_1024x768) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1271 | VCLKIndex = LCDXlat2VCLK[CRT2Index]; |
| 1272 | else |
| 1273 | VCLKIndex = LCDXlat1VCLK[CRT2Index]; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1274 | } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1275 | if (pVBInfo->SetFlag & RPLLDIV2XO) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 1276 | VCLKIndex = TVCLKBASE_315 + HiTVVCLKDIV2; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1277 | VCLKIndex += 25; |
| 1278 | } else { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 1279 | VCLKIndex = TVCLKBASE_315 + HiTVVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1280 | VCLKIndex += 25; |
| 1281 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1282 | |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1283 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 1284 | if (modeflag & Charx8Dot) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 1285 | VCLKIndex = TVCLKBASE_315 + HiTVSimuVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1286 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1287 | } else { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 1288 | VCLKIndex = TVCLKBASE_315 + HiTVTextVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1289 | VCLKIndex += 25; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1290 | } |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1291 | } |
| 1292 | |
| 1293 | /* 301lv */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1294 | if ((pVBInfo->VBType & VB_SIS301LV) && |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1295 | !(pVBInfo->VBExtInfo == VB_YPbPr1080i)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1296 | if (pVBInfo->VBExtInfo == YPbPr750p) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1297 | VCLKIndex = XGI_YPbPr750pVCLK; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1298 | else if (pVBInfo->VBExtInfo == YPbPr525p) |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1299 | VCLKIndex = YPbPr525pVCLK; |
| 1300 | else if (pVBInfo->SetFlag & RPLLDIV2XO) |
| 1301 | VCLKIndex = YPbPr525iVCLK_2; |
| 1302 | else |
| 1303 | VCLKIndex = YPbPr525iVCLK; |
| 1304 | } |
| 1305 | } else if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 1306 | if (pVBInfo->SetFlag & RPLLDIV2XO) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 1307 | VCLKIndex = TVCLKBASE_315 + TVVCLKDIV2; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1308 | VCLKIndex += 25; |
| 1309 | } else { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 1310 | VCLKIndex = TVCLKBASE_315 + TVVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1311 | VCLKIndex += 25; |
| 1312 | } |
| 1313 | } else { /* for CRT2 */ |
| 1314 | /* Port 3cch */ |
| 1315 | VCLKIndex = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
| 1316 | VCLKIndex = ((VCLKIndex >> 2) & 0x03); |
| 1317 | if (ModeNo > 0x13) { |
| 1318 | /* di+Ext_CRTVCLK */ |
| 1319 | VCLKIndex = pVBInfo->RefIndex[ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1320 | RefreshRateTableIndex]. |
| 1321 | Ext_CRTVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 1322 | VCLKIndex &= IndexMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1323 | } |
| 1324 | } |
| 1325 | } else { /* LVDS */ |
| 1326 | if (ModeNo <= 0x13) |
| 1327 | VCLKIndex = CRT2Index; |
| 1328 | else |
| 1329 | VCLKIndex = CRT2Index; |
| 1330 | |
Aaro Koskinen | 4c14bfd | 2011-08-31 21:45:57 +0300 | [diff] [blame] | 1331 | VCLKIndex = VCLKIndex >> 6; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1332 | if ((pVBInfo->LCDResInfo == Panel_800x600) || |
| 1333 | (pVBInfo->LCDResInfo == Panel_320x480)) |
Aaro Koskinen | 4c14bfd | 2011-08-31 21:45:57 +0300 | [diff] [blame] | 1334 | VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1335 | else if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1336 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) |
Aaro Koskinen | 4c14bfd | 2011-08-31 21:45:57 +0300 | [diff] [blame] | 1337 | VCLKIndex = LVDSXlat2VCLK[VCLKIndex]; |
| 1338 | else |
| 1339 | VCLKIndex = LVDSXlat3VCLK[VCLKIndex]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1340 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1341 | |
| 1342 | return VCLKIndex; |
| 1343 | } |
| 1344 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1345 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
| 1346 | unsigned short ModeIdIndex, |
| 1347 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1348 | unsigned short RefreshRateTableIndex, |
| 1349 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1350 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 1351 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1352 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1353 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1354 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 1355 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1356 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1357 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1358 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1359 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1360 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1361 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1362 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1363 | } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 1364 | | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1365 | & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1366 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, |
| 1367 | RefreshRateTableIndex, HwDeviceExtension, |
| 1368 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1369 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1370 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1371 | data = pVBInfo->VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1372 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1373 | data = pVBInfo->VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1374 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 1375 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1376 | } else { |
| 1377 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1378 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1379 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
| 1380 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1381 | pVBInfo->VCLKData[index].SR2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1382 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1383 | pVBInfo->VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1384 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1385 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1386 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1387 | if (HwDeviceExtension->jChipType >= XG20) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1388 | if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
| 1389 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1390 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1391 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1392 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1393 | index = data; |
| 1394 | index &= 0xE0; |
| 1395 | data &= 0x1F; |
| 1396 | data = data << 1; |
| 1397 | data += 1; |
| 1398 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1399 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1400 | } |
| 1401 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1402 | } |
| 1403 | |
Aaro Koskinen | e85f203 | 2011-11-27 23:03:07 +0200 | [diff] [blame] | 1404 | static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
| 1405 | { |
| 1406 | unsigned char temp; |
| 1407 | |
| 1408 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
| 1409 | temp = (temp & 1) << 6; |
| 1410 | /* SR06[6] 18bit Dither */ |
| 1411 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 1412 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 1413 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 1414 | |
| 1415 | } |
| 1416 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1417 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1418 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1419 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1420 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1421 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1422 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1423 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1424 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1425 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1426 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1427 | if (ModeNo > 0x13) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1428 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1429 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1430 | data &= 0xC0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1431 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1432 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1433 | data |= 0x01; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1434 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1435 | } else { |
| 1436 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1437 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1438 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1439 | data &= 0xC0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1440 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1441 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1442 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1443 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1444 | data &= 0xF0; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1445 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1446 | } |
| 1447 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1448 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1449 | if (HwDeviceExtension->jChipType == XG21) |
| 1450 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1451 | } |
| 1452 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1453 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
| 1454 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, |
| 1455 | struct vb_device_info *pVBInfo) |
| 1456 | { |
| 1457 | unsigned short data, data2 = 0; |
| 1458 | short VCLK; |
| 1459 | |
| 1460 | unsigned char index; |
| 1461 | |
| 1462 | if (ModeNo <= 0x13) |
| 1463 | VCLK = 0; |
| 1464 | else { |
| 1465 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 1466 | index &= IndexMask; |
| 1467 | VCLK = pVBInfo->VCLKData[index].CLOCK; |
| 1468 | } |
| 1469 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1470 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1471 | data &= 0xf3; |
| 1472 | if (VCLK >= 200) |
| 1473 | data |= 0x0c; /* VCLK > 200 */ |
| 1474 | |
| 1475 | if (HwDeviceExtension->jChipType >= XG20) |
| 1476 | data &= ~0x04; /* 2 pixel mode */ |
| 1477 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1478 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1479 | |
| 1480 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1481 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1482 | data &= 0xE7; |
| 1483 | if (VCLK < 200) |
| 1484 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1485 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1486 | } |
| 1487 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1488 | data2 = 0x00; |
| 1489 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1490 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1491 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1492 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1493 | |
| 1494 | } |
| 1495 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1496 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1497 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1498 | unsigned short RefreshRateTableIndex, |
| 1499 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1500 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1501 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1502 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1503 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1504 | if (ModeNo > 0x13) { |
| 1505 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1506 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1507 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1508 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1509 | /* si+St_ModeFlag */ |
| 1510 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1511 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1512 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1513 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1514 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1515 | if (ModeNo > 0x13) |
| 1516 | data = infoflag; |
| 1517 | else |
| 1518 | data = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1519 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1520 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1521 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1522 | if (ModeNo > 0x13) { |
| 1523 | if (pVBInfo->ModeType > 0x02) { |
| 1524 | data2 |= 0x02; |
| 1525 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1526 | data3 = data3 << 2; |
| 1527 | data2 |= data3; |
| 1528 | } |
| 1529 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1530 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1531 | data &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1532 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1533 | if (data) |
| 1534 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1535 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1536 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1537 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 1538 | if (ModeNo <= 0x13) |
| 1539 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 1540 | else |
| 1541 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1542 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1543 | data = 0x0000; |
| 1544 | if (infoflag & InterlaceMode) { |
| 1545 | if (xres == 1024) |
| 1546 | data = 0x0035; |
| 1547 | else if (xres == 1280) |
| 1548 | data = 0x0048; |
| 1549 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1550 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1551 | data2 = data & 0x00FF; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1552 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1553 | data2 = (data & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1554 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1555 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1556 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1557 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1558 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1559 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1560 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1561 | if (modeflag & LineCompareOff) |
| 1562 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1563 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1564 | if (ModeNo > 0x13) { |
| 1565 | if (pVBInfo->ModeType == ModeEGA) |
| 1566 | data2 |= 0x40; |
| 1567 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1568 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1569 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1570 | data = 0x60; |
| 1571 | if (pVBInfo->ModeType != ModeText) { |
| 1572 | data = data ^ 0x60; |
| 1573 | if (pVBInfo->ModeType != ModeEGA) |
| 1574 | data = data ^ 0xA0; |
| 1575 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1576 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
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 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, |
| 1579 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1580 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1581 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1582 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1583 | if (HwDeviceExtension->jChipType == XG27) { |
| 1584 | if (data & 0x40) |
| 1585 | data = 0x2c; |
| 1586 | else |
| 1587 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1588 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1589 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1590 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1591 | if (data & 0x40) |
| 1592 | data = 0x33; |
| 1593 | else |
| 1594 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1595 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1596 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1597 | } else { |
| 1598 | if (data & 0x40) |
| 1599 | data = 0x2c; |
| 1600 | else |
| 1601 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1602 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1603 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1604 | |
| 1605 | } |
| 1606 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1607 | static void XGI_WriteDAC(unsigned short dl, |
| 1608 | unsigned short ah, |
| 1609 | unsigned short al, |
| 1610 | unsigned short dh, |
| 1611 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1612 | { |
| 1613 | unsigned short temp, bh, bl; |
| 1614 | |
| 1615 | bh = ah; |
| 1616 | bl = al; |
| 1617 | |
| 1618 | if (dl != 0) { |
| 1619 | temp = bh; |
| 1620 | bh = dh; |
| 1621 | dh = temp; |
| 1622 | if (dl == 1) { |
| 1623 | temp = bl; |
| 1624 | bl = dh; |
| 1625 | dh = temp; |
| 1626 | } else { |
| 1627 | temp = bl; |
| 1628 | bl = bh; |
| 1629 | bh = temp; |
| 1630 | } |
| 1631 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1632 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1633 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1634 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1635 | } |
| 1636 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1637 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1638 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1639 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1640 | unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al, |
Aaro Koskinen | 624554d | 2011-10-11 21:47:35 +0300 | [diff] [blame] | 1641 | ah, dh; |
| 1642 | const unsigned short *table = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1643 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1644 | if (ModeNo <= 0x13) |
| 1645 | data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1646 | else |
| 1647 | data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1648 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1649 | data &= DACInfoFlag; |
| 1650 | time = 64; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1651 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1652 | if (data == 0x00) |
| 1653 | table = XGINew_MDA_DAC; |
| 1654 | else if (data == 0x08) |
| 1655 | table = XGINew_CGA_DAC; |
| 1656 | else if (data == 0x10) |
| 1657 | table = XGINew_EGA_DAC; |
| 1658 | else if (data == 0x18) { |
| 1659 | time = 256; |
| 1660 | table = XGINew_VGA_DAC; |
| 1661 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1662 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1663 | if (time == 256) |
| 1664 | j = 16; |
| 1665 | else |
| 1666 | j = time; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1667 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1668 | outb(0xFF, pVBInfo->P3c6); |
| 1669 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1670 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1671 | for (i = 0; i < j; i++) { |
| 1672 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1673 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1674 | for (k = 0; k < 3; k++) { |
| 1675 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1676 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1677 | if (data & 0x01) |
| 1678 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1679 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1680 | if (data & 0x02) |
| 1681 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1682 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1683 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1684 | data = data >> 2; |
| 1685 | } |
| 1686 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1687 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1688 | if (time == 256) { |
| 1689 | for (i = 16; i < 32; i++) { |
| 1690 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1691 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1692 | for (k = 0; k < 3; k++) |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1693 | outb(data, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1694 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1695 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1696 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1697 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1698 | for (m = 0; m < 9; m++) { |
| 1699 | di = si; |
| 1700 | bx = si + 0x04; |
| 1701 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1702 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1703 | for (n = 0; n < 3; n++) { |
| 1704 | for (o = 0; o < 5; o++) { |
| 1705 | dh = table[si]; |
| 1706 | ah = table[di]; |
| 1707 | al = table[bx]; |
| 1708 | si++; |
| 1709 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1710 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1711 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1712 | si -= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1713 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1714 | for (o = 0; o < 3; o++) { |
| 1715 | dh = table[bx]; |
| 1716 | ah = table[di]; |
| 1717 | al = table[si]; |
| 1718 | si--; |
| 1719 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1720 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1721 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1722 | dl++; |
| 1723 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1724 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1725 | si += 5; |
| 1726 | } |
| 1727 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1728 | } |
| 1729 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1730 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
| 1731 | unsigned short ModeIdIndex, |
| 1732 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1733 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1734 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1735 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1736 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1737 | /* si+St_ResInfo */ |
| 1738 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1739 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1740 | /* si+Ext_ResInfo */ |
| 1741 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1742 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1743 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1744 | /* si+St_ResInfo */ |
| 1745 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1746 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1747 | /* si+Ext_ResInfo */ |
| 1748 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1749 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1750 | if (ModeNo <= 0x13) { |
| 1751 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 1752 | yres = pVBInfo->StResInfo[resindex].VTotal; |
| 1753 | } else { |
| 1754 | xres = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1755 | yres = pVBInfo->ModeResInfo[resindex].VTotal; |
| 1756 | } |
| 1757 | if (ModeNo > 0x13) { |
| 1758 | if (modeflag & HalfDCLK) |
| 1759 | xres = xres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1760 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1761 | if (modeflag & DoubleScanMode) |
| 1762 | yres = yres << 1; |
| 1763 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1764 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1765 | if (xres == 720) |
| 1766 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1767 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1768 | pVBInfo->VGAHDE = xres; |
| 1769 | pVBInfo->HDE = xres; |
| 1770 | pVBInfo->VGAVDE = yres; |
| 1771 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1772 | } |
| 1773 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1774 | static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, |
| 1775 | unsigned short ModeIdIndex, |
| 1776 | unsigned short RefreshRateTableIndex, |
| 1777 | struct vb_device_info *pVBInfo) |
| 1778 | { |
| 1779 | unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table; |
| 1780 | |
| 1781 | struct XGI330_LCDDataTablStruct *tempdi = NULL; |
| 1782 | |
| 1783 | tempbx = BX; |
| 1784 | |
| 1785 | if (ModeNo <= 0x13) { |
| 1786 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 1787 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 1788 | } else { |
| 1789 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 1790 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
| 1791 | } |
| 1792 | |
| 1793 | tempal = tempal & 0x0f; |
| 1794 | |
| 1795 | if (tempbx <= 1) { /* ExpLink */ |
| 1796 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1797 | /* find no Ext_CRT2CRTC2 */ |
| 1798 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1799 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1800 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 1801 | Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1802 | } |
| 1803 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1804 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1805 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1806 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 1807 | St_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1808 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1809 | tempal = pVBInfo->RefIndex[ |
| 1810 | RefreshRateTableIndex]. |
| 1811 | Ext_CRT2CRTC2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1812 | } |
| 1813 | |
| 1814 | if (tempbx & 0x01) |
| 1815 | tempal = (tempal >> 4); |
| 1816 | |
| 1817 | tempal = (tempal & 0x0f); |
| 1818 | } |
| 1819 | |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 1820 | tempcx = LCDLenList[tempbx]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1821 | |
| 1822 | if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */ |
| 1823 | if ((tempbx == 5) || (tempbx) == 7) |
| 1824 | tempcx = LCDDesDataLen2; |
| 1825 | else if ((tempbx == 3) || (tempbx == 8)) |
| 1826 | tempcx = LVDSDesDataLen2; |
| 1827 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1828 | |
| 1829 | switch (tempbx) { |
| 1830 | case 0: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1831 | case 1: |
Aaro Koskinen | cc5c2ae | 2011-08-31 21:46:08 +0300 | [diff] [blame] | 1832 | tempdi = xgifb_epllcd_crt1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1833 | break; |
| 1834 | case 2: |
| 1835 | tempdi = XGI_EPLLCDDataPtr; |
| 1836 | break; |
| 1837 | case 3: |
| 1838 | tempdi = XGI_EPLLCDDesDataPtr; |
| 1839 | break; |
| 1840 | case 4: |
| 1841 | tempdi = XGI_LCDDataTable; |
| 1842 | break; |
| 1843 | case 5: |
| 1844 | tempdi = XGI_LCDDesDataTable; |
| 1845 | break; |
| 1846 | case 6: |
| 1847 | tempdi = XGI_EPLCHLCDRegPtr; |
| 1848 | break; |
| 1849 | case 7: |
| 1850 | case 8: |
| 1851 | case 9: |
| 1852 | tempdi = NULL; |
| 1853 | break; |
| 1854 | default: |
| 1855 | break; |
| 1856 | } |
| 1857 | |
| 1858 | if (tempdi == NULL) /* OEMUtil */ |
| 1859 | return NULL; |
| 1860 | |
| 1861 | table = tempbx; |
| 1862 | i = 0; |
| 1863 | |
| 1864 | while (tempdi[i].PANELID != 0xff) { |
| 1865 | tempdx = pVBInfo->LCDResInfo; |
| 1866 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 1867 | tempbx &= (~0x0080); |
| 1868 | tempdx = pVBInfo->LCDTypeInfo; |
| 1869 | } |
| 1870 | |
| 1871 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1872 | tempdx &= (~PanelResInfo); |
| 1873 | |
| 1874 | if (tempdi[i].PANELID == tempdx) { |
| 1875 | tempbx = tempdi[i].MASK; |
| 1876 | tempdx = pVBInfo->LCDInfo; |
| 1877 | |
| 1878 | if (ModeNo <= 0x13) /* alan 09/10/2003 */ |
| 1879 | tempdx |= SetLCDStdMode; |
| 1880 | |
| 1881 | if (modeflag & HalfDCLK) |
| 1882 | tempdx |= SetLCDLowResolution; |
| 1883 | |
| 1884 | tempbx &= tempdx; |
| 1885 | if (tempbx == tempdi[i].CAP) |
| 1886 | break; |
| 1887 | } |
| 1888 | i++; |
| 1889 | } |
| 1890 | |
| 1891 | if (table == 0) { |
| 1892 | switch (tempdi[i].DATAPTR) { |
| 1893 | case 0: |
| 1894 | return &XGI_LVDSCRT11024x768_1_H[tempal]; |
| 1895 | break; |
| 1896 | case 1: |
| 1897 | return &XGI_LVDSCRT11024x768_2_H[tempal]; |
| 1898 | break; |
| 1899 | case 2: |
| 1900 | return &XGI_LVDSCRT11280x1024_1_H[tempal]; |
| 1901 | break; |
| 1902 | case 3: |
| 1903 | return &XGI_LVDSCRT11280x1024_2_H[tempal]; |
| 1904 | break; |
| 1905 | case 4: |
| 1906 | return &XGI_LVDSCRT11400x1050_1_H[tempal]; |
| 1907 | break; |
| 1908 | case 5: |
| 1909 | return &XGI_LVDSCRT11400x1050_2_H[tempal]; |
| 1910 | break; |
| 1911 | case 6: |
| 1912 | return &XGI_LVDSCRT11600x1200_1_H[tempal]; |
| 1913 | break; |
| 1914 | case 7: |
| 1915 | return &XGI_LVDSCRT11024x768_1_Hx75[tempal]; |
| 1916 | break; |
| 1917 | case 8: |
| 1918 | return &XGI_LVDSCRT11024x768_2_Hx75[tempal]; |
| 1919 | break; |
| 1920 | case 9: |
| 1921 | return &XGI_LVDSCRT11280x1024_1_Hx75[tempal]; |
| 1922 | break; |
| 1923 | case 10: |
| 1924 | return &XGI_LVDSCRT11280x1024_2_Hx75[tempal]; |
| 1925 | break; |
| 1926 | default: |
| 1927 | break; |
| 1928 | } |
| 1929 | } else if (table == 1) { |
| 1930 | switch (tempdi[i].DATAPTR) { |
| 1931 | case 0: |
| 1932 | return &XGI_LVDSCRT11024x768_1_V[tempal]; |
| 1933 | break; |
| 1934 | case 1: |
| 1935 | return &XGI_LVDSCRT11024x768_2_V[tempal]; |
| 1936 | break; |
| 1937 | case 2: |
| 1938 | return &XGI_LVDSCRT11280x1024_1_V[tempal]; |
| 1939 | break; |
| 1940 | case 3: |
| 1941 | return &XGI_LVDSCRT11280x1024_2_V[tempal]; |
| 1942 | break; |
| 1943 | case 4: |
| 1944 | return &XGI_LVDSCRT11400x1050_1_V[tempal]; |
| 1945 | break; |
| 1946 | case 5: |
| 1947 | return &XGI_LVDSCRT11400x1050_2_V[tempal]; |
| 1948 | break; |
| 1949 | case 6: |
| 1950 | return &XGI_LVDSCRT11600x1200_1_V[tempal]; |
| 1951 | break; |
| 1952 | case 7: |
| 1953 | return &XGI_LVDSCRT11024x768_1_Vx75[tempal]; |
| 1954 | break; |
| 1955 | case 8: |
| 1956 | return &XGI_LVDSCRT11024x768_2_Vx75[tempal]; |
| 1957 | break; |
| 1958 | case 9: |
| 1959 | return &XGI_LVDSCRT11280x1024_1_Vx75[tempal]; |
| 1960 | break; |
| 1961 | case 10: |
| 1962 | return &XGI_LVDSCRT11280x1024_2_Vx75[tempal]; |
| 1963 | break; |
| 1964 | default: |
| 1965 | break; |
| 1966 | } |
| 1967 | } else if (table == 2) { |
| 1968 | switch (tempdi[i].DATAPTR) { |
| 1969 | case 0: |
| 1970 | return &XGI_LVDS1024x768Data_1[tempal]; |
| 1971 | break; |
| 1972 | case 1: |
| 1973 | return &XGI_LVDS1024x768Data_2[tempal]; |
| 1974 | break; |
| 1975 | case 2: |
| 1976 | return &XGI_LVDS1280x1024Data_1[tempal]; |
| 1977 | break; |
| 1978 | case 3: |
| 1979 | return &XGI_LVDS1280x1024Data_2[tempal]; |
| 1980 | break; |
| 1981 | case 4: |
| 1982 | return &XGI_LVDS1400x1050Data_1[tempal]; |
| 1983 | break; |
| 1984 | case 5: |
| 1985 | return &XGI_LVDS1400x1050Data_2[tempal]; |
| 1986 | break; |
| 1987 | case 6: |
| 1988 | return &XGI_LVDS1600x1200Data_1[tempal]; |
| 1989 | break; |
| 1990 | case 7: |
| 1991 | return &XGI_LVDSNoScalingData[tempal]; |
| 1992 | break; |
| 1993 | case 8: |
| 1994 | return &XGI_LVDS1024x768Data_1x75[tempal]; |
| 1995 | break; |
| 1996 | case 9: |
| 1997 | return &XGI_LVDS1024x768Data_2x75[tempal]; |
| 1998 | break; |
| 1999 | case 10: |
| 2000 | return &XGI_LVDS1280x1024Data_1x75[tempal]; |
| 2001 | break; |
| 2002 | case 11: |
| 2003 | return &XGI_LVDS1280x1024Data_2x75[tempal]; |
| 2004 | break; |
| 2005 | case 12: |
| 2006 | return &XGI_LVDSNoScalingDatax75[tempal]; |
| 2007 | break; |
| 2008 | default: |
| 2009 | break; |
| 2010 | } |
| 2011 | } else if (table == 3) { |
| 2012 | switch (tempdi[i].DATAPTR) { |
| 2013 | case 0: |
| 2014 | return &XGI_LVDS1024x768Des_1[tempal]; |
| 2015 | break; |
| 2016 | case 1: |
| 2017 | return &XGI_LVDS1024x768Des_3[tempal]; |
| 2018 | break; |
| 2019 | case 2: |
| 2020 | return &XGI_LVDS1024x768Des_2[tempal]; |
| 2021 | break; |
| 2022 | case 3: |
| 2023 | return &XGI_LVDS1280x1024Des_1[tempal]; |
| 2024 | break; |
| 2025 | case 4: |
| 2026 | return &XGI_LVDS1280x1024Des_2[tempal]; |
| 2027 | break; |
| 2028 | case 5: |
| 2029 | return &XGI_LVDS1400x1050Des_1[tempal]; |
| 2030 | break; |
| 2031 | case 6: |
| 2032 | return &XGI_LVDS1400x1050Des_2[tempal]; |
| 2033 | break; |
| 2034 | case 7: |
| 2035 | return &XGI_LVDS1600x1200Des_1[tempal]; |
| 2036 | break; |
| 2037 | case 8: |
| 2038 | return &XGI_LVDSNoScalingDesData[tempal]; |
| 2039 | break; |
| 2040 | case 9: |
| 2041 | return &XGI_LVDS1024x768Des_1x75[tempal]; |
| 2042 | break; |
| 2043 | case 10: |
| 2044 | return &XGI_LVDS1024x768Des_3x75[tempal]; |
| 2045 | break; |
| 2046 | case 11: |
| 2047 | return &XGI_LVDS1024x768Des_2x75[tempal]; |
| 2048 | break; |
| 2049 | case 12: |
| 2050 | return &XGI_LVDS1280x1024Des_1x75[tempal]; |
| 2051 | break; |
| 2052 | case 13: |
| 2053 | return &XGI_LVDS1280x1024Des_2x75[tempal]; |
| 2054 | break; |
| 2055 | case 14: |
| 2056 | return &XGI_LVDSNoScalingDesDatax75[tempal]; |
| 2057 | break; |
| 2058 | default: |
| 2059 | break; |
| 2060 | } |
| 2061 | } else if (table == 4) { |
| 2062 | switch (tempdi[i].DATAPTR) { |
| 2063 | case 0: |
| 2064 | return &XGI_ExtLCD1024x768Data[tempal]; |
| 2065 | break; |
| 2066 | case 1: |
| 2067 | return &XGI_StLCD1024x768Data[tempal]; |
| 2068 | break; |
| 2069 | case 2: |
| 2070 | return &XGI_CetLCD1024x768Data[tempal]; |
| 2071 | break; |
| 2072 | case 3: |
| 2073 | return &XGI_ExtLCD1280x1024Data[tempal]; |
| 2074 | break; |
| 2075 | case 4: |
| 2076 | return &XGI_StLCD1280x1024Data[tempal]; |
| 2077 | break; |
| 2078 | case 5: |
| 2079 | return &XGI_CetLCD1280x1024Data[tempal]; |
| 2080 | break; |
| 2081 | case 6: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2082 | case 7: |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 2083 | return &xgifb_lcd_1400x1050[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2084 | break; |
| 2085 | case 8: |
| 2086 | return &XGI_CetLCD1400x1050Data[tempal]; |
| 2087 | break; |
| 2088 | case 9: |
| 2089 | return &XGI_ExtLCD1600x1200Data[tempal]; |
| 2090 | break; |
| 2091 | case 10: |
| 2092 | return &XGI_StLCD1600x1200Data[tempal]; |
| 2093 | break; |
| 2094 | case 11: |
| 2095 | return &XGI_NoScalingData[tempal]; |
| 2096 | break; |
| 2097 | case 12: |
| 2098 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 2099 | break; |
| 2100 | case 13: |
| 2101 | return &XGI_ExtLCD1024x768x75Data[tempal]; |
| 2102 | break; |
| 2103 | case 14: |
| 2104 | return &XGI_CetLCD1024x768x75Data[tempal]; |
| 2105 | break; |
| 2106 | case 15: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2107 | case 16: |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 2108 | return &xgifb_lcd_1280x1024x75[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2109 | break; |
| 2110 | case 17: |
| 2111 | return &XGI_CetLCD1280x1024x75Data[tempal]; |
| 2112 | break; |
| 2113 | case 18: |
| 2114 | return &XGI_NoScalingDatax75[tempal]; |
| 2115 | break; |
| 2116 | default: |
| 2117 | break; |
| 2118 | } |
| 2119 | } else if (table == 5) { |
| 2120 | switch (tempdi[i].DATAPTR) { |
| 2121 | case 0: |
| 2122 | return &XGI_ExtLCDDes1024x768Data[tempal]; |
| 2123 | break; |
| 2124 | case 1: |
| 2125 | return &XGI_StLCDDes1024x768Data[tempal]; |
| 2126 | break; |
| 2127 | case 2: |
| 2128 | return &XGI_CetLCDDes1024x768Data[tempal]; |
| 2129 | break; |
| 2130 | case 3: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2131 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 2132 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2133 | return &XGI_ExtLCDDLDes1280x1024Data[tempal]; |
| 2134 | else |
| 2135 | return &XGI_ExtLCDDes1280x1024Data[tempal]; |
| 2136 | break; |
| 2137 | case 4: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2138 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 2139 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2140 | return &XGI_StLCDDLDes1280x1024Data[tempal]; |
| 2141 | else |
| 2142 | return &XGI_StLCDDes1280x1024Data[tempal]; |
| 2143 | break; |
| 2144 | case 5: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2145 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 2146 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2147 | return &XGI_CetLCDDLDes1280x1024Data[tempal]; |
| 2148 | else |
| 2149 | return &XGI_CetLCDDes1280x1024Data[tempal]; |
| 2150 | break; |
| 2151 | case 6: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2152 | case 7: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2153 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 2154 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 2155 | return &xgifb_lcddldes_1400x1050[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2156 | else |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 2157 | return &xgifb_lcddes_1400x1050[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2158 | break; |
| 2159 | case 8: |
| 2160 | return &XGI_CetLCDDes1400x1050Data[tempal]; |
| 2161 | break; |
| 2162 | case 9: |
| 2163 | return &XGI_CetLCDDes1400x1050Data2[tempal]; |
| 2164 | break; |
| 2165 | case 10: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2166 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 2167 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2168 | return &XGI_ExtLCDDLDes1600x1200Data[tempal]; |
| 2169 | else |
| 2170 | return &XGI_ExtLCDDes1600x1200Data[tempal]; |
| 2171 | break; |
| 2172 | case 11: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2173 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 2174 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2175 | return &XGI_StLCDDLDes1600x1200Data[tempal]; |
| 2176 | else |
| 2177 | return &XGI_StLCDDes1600x1200Data[tempal]; |
| 2178 | break; |
| 2179 | case 12: |
| 2180 | return &XGI_NoScalingDesData[tempal]; |
| 2181 | break; |
| 2182 | case 13: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2183 | case 14: |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 2184 | return &xgifb_lcddes_1024x768x75[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2185 | break; |
| 2186 | case 15: |
| 2187 | return &XGI_CetLCDDes1024x768x75Data[tempal]; |
| 2188 | break; |
| 2189 | case 16: |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2190 | case 17: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2191 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 2192 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 2193 | return &xgifb_lcddldes_1280x1024x75[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2194 | else |
Aaro Koskinen | ada2bda | 2011-08-31 21:46:07 +0300 | [diff] [blame] | 2195 | return &xgifb_lcddes_1280x1024x75[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2196 | break; |
| 2197 | case 18: |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2198 | if ((pVBInfo->VBType & VB_SIS301LV) || |
| 2199 | (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2200 | return &XGI_CetLCDDLDes1280x1024x75Data[tempal]; |
| 2201 | else |
| 2202 | return &XGI_CetLCDDes1280x1024x75Data[tempal]; |
| 2203 | break; |
| 2204 | case 19: |
| 2205 | return &XGI_NoScalingDesDatax75[tempal]; |
| 2206 | break; |
| 2207 | default: |
| 2208 | break; |
| 2209 | } |
| 2210 | } else if (table == 6) { |
| 2211 | switch (tempdi[i].DATAPTR) { |
| 2212 | case 0: |
| 2213 | return &XGI_CH7017LV1024x768[tempal]; |
| 2214 | break; |
| 2215 | case 1: |
| 2216 | return &XGI_CH7017LV1400x1050[tempal]; |
| 2217 | break; |
| 2218 | default: |
| 2219 | break; |
| 2220 | } |
| 2221 | } |
| 2222 | return NULL; |
| 2223 | } |
| 2224 | |
| 2225 | static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, |
| 2226 | unsigned short ModeIdIndex, |
| 2227 | unsigned short RefreshRateTableIndex, |
| 2228 | struct vb_device_info *pVBInfo) |
| 2229 | { |
| 2230 | unsigned short i, tempdx, tempbx, tempal, modeflag, table; |
| 2231 | struct XGI330_TVDataTablStruct *tempdi = NULL; |
| 2232 | |
| 2233 | tempbx = BX; |
| 2234 | |
| 2235 | if (ModeNo <= 0x13) { |
| 2236 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 2237 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 2238 | } else { |
| 2239 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2240 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
| 2241 | } |
| 2242 | |
| 2243 | tempal = tempal & 0x3f; |
| 2244 | table = tempbx; |
| 2245 | |
| 2246 | switch (tempbx) { |
| 2247 | case 0: |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 2248 | tempdi = NULL; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2249 | break; |
| 2250 | case 1: |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 2251 | tempdi = NULL; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2252 | break; |
| 2253 | case 2: |
Aaro Koskinen | 0c23b6d | 2011-08-31 21:46:09 +0300 | [diff] [blame] | 2254 | case 6: |
| 2255 | tempdi = xgifb_chrontel_tv; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2256 | break; |
| 2257 | case 3: |
| 2258 | tempdi = NULL; |
| 2259 | break; |
| 2260 | case 4: |
| 2261 | tempdi = XGI_TVDataTable; |
| 2262 | break; |
| 2263 | case 5: |
| 2264 | tempdi = NULL; |
| 2265 | break; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2266 | default: |
| 2267 | break; |
| 2268 | } |
| 2269 | |
| 2270 | if (tempdi == NULL) /* OEMUtil */ |
| 2271 | return NULL; |
| 2272 | |
| 2273 | tempdx = pVBInfo->TVInfo; |
| 2274 | |
| 2275 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2276 | tempdx = tempdx | SetTVLockMode; |
| 2277 | |
| 2278 | if (modeflag & HalfDCLK) |
| 2279 | tempdx = tempdx | SetTVLowResolution; |
| 2280 | |
| 2281 | i = 0; |
| 2282 | |
| 2283 | while (tempdi[i].MASK != 0xffff) { |
| 2284 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) |
| 2285 | break; |
| 2286 | i++; |
| 2287 | } |
| 2288 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2289 | /* 07/05/22 */ |
Aaro Koskinen | ebe3302 | 2011-11-27 23:03:18 +0200 | [diff] [blame] | 2290 | if (table == 0x04) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2291 | switch (tempdi[i].DATAPTR) { |
| 2292 | case 0: |
| 2293 | return &XGI_ExtPALData[tempal]; |
| 2294 | break; |
| 2295 | case 1: |
| 2296 | return &XGI_ExtNTSCData[tempal]; |
| 2297 | break; |
| 2298 | case 2: |
| 2299 | return &XGI_StPALData[tempal]; |
| 2300 | break; |
| 2301 | case 3: |
| 2302 | return &XGI_StNTSCData[tempal]; |
| 2303 | break; |
| 2304 | case 4: |
| 2305 | return &XGI_ExtHiTVData[tempal]; |
| 2306 | break; |
| 2307 | case 5: |
| 2308 | return &XGI_St2HiTVData[tempal]; |
| 2309 | break; |
| 2310 | case 6: |
| 2311 | return &XGI_ExtYPbPr525iData[tempal]; |
| 2312 | break; |
| 2313 | case 7: |
| 2314 | return &XGI_ExtYPbPr525pData[tempal]; |
| 2315 | break; |
| 2316 | case 8: |
| 2317 | return &XGI_ExtYPbPr750pData[tempal]; |
| 2318 | break; |
| 2319 | case 9: |
| 2320 | return &XGI_StYPbPr525iData[tempal]; |
| 2321 | break; |
| 2322 | case 10: |
| 2323 | return &XGI_StYPbPr525pData[tempal]; |
| 2324 | break; |
| 2325 | case 11: |
| 2326 | return &XGI_StYPbPr750pData[tempal]; |
| 2327 | break; |
| 2328 | case 12: /* avoid system hang */ |
| 2329 | return &XGI_ExtNTSCData[tempal]; |
| 2330 | break; |
| 2331 | case 13: |
| 2332 | return &XGI_St1HiTVData[tempal]; |
| 2333 | break; |
| 2334 | default: |
| 2335 | break; |
| 2336 | } |
| 2337 | } else if (table == 0x02) { |
| 2338 | switch (tempdi[i].DATAPTR) { |
| 2339 | case 0: |
| 2340 | return &XGI_CHTVUNTSCData[tempal]; |
| 2341 | break; |
| 2342 | case 1: |
| 2343 | return &XGI_CHTVONTSCData[tempal]; |
| 2344 | break; |
| 2345 | case 2: |
| 2346 | return &XGI_CHTVUPALData[tempal]; |
| 2347 | break; |
| 2348 | case 3: |
| 2349 | return &XGI_CHTVOPALData[tempal]; |
| 2350 | break; |
| 2351 | default: |
| 2352 | break; |
| 2353 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2354 | } |
| 2355 | return NULL; |
| 2356 | } |
| 2357 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2358 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2359 | unsigned short RefreshRateTableIndex, |
| 2360 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2361 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2362 | unsigned short tempbx; |
| 2363 | struct XGI330_LVDSDataStruct *LCDPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2364 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2365 | tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2366 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2367 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2368 | LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx, |
| 2369 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2370 | pVBInfo); |
| 2371 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2372 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2373 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2374 | pVBInfo->VT = LCDPtr->LCDVT; |
| 2375 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2376 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2377 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2378 | if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding |
| 2379 | | EnableScalingLCD))) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2380 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 2381 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2382 | pVBInfo->HDE = 1024; |
| 2383 | pVBInfo->VDE = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2384 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 2385 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2386 | pVBInfo->HDE = 1280; |
| 2387 | pVBInfo->VDE = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2388 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2389 | pVBInfo->HDE = 1400; |
| 2390 | pVBInfo->VDE = 1050; |
| 2391 | } else { |
| 2392 | pVBInfo->HDE = 1600; |
| 2393 | pVBInfo->VDE = 1200; |
| 2394 | } |
| 2395 | } |
| 2396 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2397 | } |
| 2398 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2399 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2400 | unsigned short RefreshRateTableIndex, |
| 2401 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2402 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2403 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2404 | unsigned char index; |
| 2405 | unsigned short tempbx, i; |
| 2406 | struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL; |
| 2407 | struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2408 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2409 | if (ModeNo <= 0x13) |
| 2410 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 2411 | else |
| 2412 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2413 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2414 | index = index & IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2415 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 2416 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2417 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2418 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 2419 | LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) |
| 2420 | XGI_GetLcdPtr(tempbx, ModeNo, |
| 2421 | ModeIdIndex, |
| 2422 | RefreshRateTableIndex, |
| 2423 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2424 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 2425 | for (i = 0; i < 8; i++) |
| 2426 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2427 | } |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 2428 | |
| 2429 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 2430 | |
| 2431 | tempbx = 1; |
| 2432 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2433 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 2434 | LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) |
| 2435 | XGI_GetLcdPtr( |
| 2436 | tempbx, |
| 2437 | ModeNo, |
| 2438 | ModeIdIndex, |
| 2439 | RefreshRateTableIndex, |
| 2440 | pVBInfo); |
| 2441 | for (i = 0; i < 7; i++) |
| 2442 | pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; |
| 2443 | } |
| 2444 | |
| 2445 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2446 | } |
| 2447 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2448 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 2449 | { |
| 2450 | unsigned char tempal, tempah, tempbl, i; |
| 2451 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2452 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2453 | tempal = tempah & 0x0F; |
| 2454 | tempah = tempah & 0xF0; |
| 2455 | i = 0; |
| 2456 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2457 | |
| 2458 | while (tempbl != 0xFF) { |
| 2459 | if (tempbl & 0x80) { /* OEMUtil */ |
| 2460 | tempal = tempah; |
| 2461 | tempbl = tempbl & ~(0x80); |
| 2462 | } |
| 2463 | |
| 2464 | if (tempal == tempbl) |
| 2465 | break; |
| 2466 | |
| 2467 | i++; |
| 2468 | |
| 2469 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2470 | } |
| 2471 | |
| 2472 | return i; |
| 2473 | } |
| 2474 | |
| 2475 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 2476 | { |
| 2477 | unsigned short tempah, tempal, tempbl, i; |
| 2478 | |
| 2479 | tempal = pVBInfo->LCDResInfo; |
| 2480 | tempah = pVBInfo->LCDTypeInfo; |
| 2481 | |
| 2482 | i = 0; |
| 2483 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2484 | |
| 2485 | while (tempbl != 0xFF) { |
| 2486 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 2487 | tempal = tempah; |
| 2488 | tempbl &= ~0x80; |
| 2489 | } |
| 2490 | |
| 2491 | if (tempal == tempbl) |
| 2492 | break; |
| 2493 | |
| 2494 | i++; |
| 2495 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 2496 | } |
| 2497 | |
| 2498 | if (tempbl == 0xFF) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2499 | pVBInfo->LCDResInfo = Panel_1024x768; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2500 | pVBInfo->LCDTypeInfo = 0; |
| 2501 | i = 0; |
| 2502 | } |
| 2503 | |
| 2504 | return i; |
| 2505 | } |
| 2506 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2507 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 2508 | unsigned short *VSyncWidth, |
| 2509 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2510 | { |
| 2511 | unsigned short Index; |
| 2512 | |
| 2513 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 2514 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 2515 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
| 2516 | |
| 2517 | return; |
| 2518 | } |
| 2519 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2520 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2521 | unsigned short RefreshRateTableIndex, |
| 2522 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2523 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2524 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 2525 | unsigned long temp, temp1, temp2, temp3, push3; |
| 2526 | struct XGI330_LCDDataDesStruct *LCDPtr = NULL; |
| 2527 | struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2528 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2529 | if (ModeNo > 0x13) |
| 2530 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2531 | else |
| 2532 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2533 | |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 2534 | tempbx = 3; |
| 2535 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2536 | LCDPtr1 = |
| 2537 | (struct XGI330_LCDDataDesStruct2 *) |
| 2538 | XGI_GetLcdPtr( |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2539 | tempbx, |
| 2540 | ModeNo, |
| 2541 | ModeIdIndex, |
| 2542 | RefreshRateTableIndex, |
| 2543 | pVBInfo); |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 2544 | else |
| 2545 | LCDPtr = |
| 2546 | (struct XGI330_LCDDataDesStruct *) |
| 2547 | XGI_GetLcdPtr( |
| 2548 | tempbx, |
| 2549 | ModeNo, |
| 2550 | ModeIdIndex, |
| 2551 | RefreshRateTableIndex, |
| 2552 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2553 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2554 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 2555 | push1 = tempbx; |
| 2556 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2557 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2558 | /* GetLCDResInfo */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2559 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 2560 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2561 | tempax = 1024; |
| 2562 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2563 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 2564 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2565 | tempax = 1280; |
| 2566 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2567 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2568 | tempax = 1400; |
| 2569 | tempbx = 1050; |
| 2570 | } else { |
| 2571 | tempax = 1600; |
| 2572 | tempbx = 1200; |
| 2573 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2574 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2575 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 2576 | pVBInfo->HDE = tempax; |
| 2577 | pVBInfo->VDE = tempbx; |
| 2578 | pVBInfo->VGAHDE = tempax; |
| 2579 | pVBInfo->VGAVDE = tempbx; |
| 2580 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2581 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2582 | tempax = pVBInfo->HT; |
| 2583 | |
| 2584 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2585 | tempbx = LCDPtr1->LCDHDES; |
| 2586 | else |
| 2587 | tempbx = LCDPtr->LCDHDES; |
| 2588 | |
| 2589 | tempcx = pVBInfo->HDE; |
| 2590 | tempbx = tempbx & 0x0fff; |
| 2591 | tempcx += tempbx; |
| 2592 | |
| 2593 | if (tempcx >= tempax) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2594 | tempcx -= tempax; |
| 2595 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2596 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2597 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2598 | tempcx = tempcx >> 3; |
| 2599 | tempbx = tempbx >> 3; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2600 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2601 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 2602 | (unsigned short) (tempbx & 0xff)); |
| 2603 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 2604 | (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2605 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2606 | tempax = pVBInfo->HT; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2607 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2608 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2609 | tempbx = LCDPtr1->LCDHRS; |
| 2610 | else |
| 2611 | tempbx = LCDPtr->LCDHRS; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2612 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2613 | tempcx = push2; |
| 2614 | |
| 2615 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2616 | tempcx = LCDPtr1->LCDHSync; |
| 2617 | |
| 2618 | tempcx += tempbx; |
| 2619 | |
| 2620 | if (tempcx >= tempax) |
| 2621 | tempcx -= tempax; |
| 2622 | |
| 2623 | tempax = tempbx & 0x07; |
| 2624 | tempax = tempax >> 5; |
| 2625 | tempcx = tempcx >> 3; |
| 2626 | tempbx = tempbx >> 3; |
| 2627 | |
| 2628 | tempcx &= 0x1f; |
| 2629 | tempax |= tempcx; |
| 2630 | |
| 2631 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 2632 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 2633 | (unsigned short) (tempbx & 0xff)); |
| 2634 | |
| 2635 | tempax = pVBInfo->VT; |
| 2636 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2637 | tempbx = LCDPtr1->LCDVDES; |
| 2638 | else |
| 2639 | tempbx = LCDPtr->LCDVDES; |
| 2640 | tempcx = pVBInfo->VDE; |
| 2641 | |
| 2642 | tempbx = tempbx & 0x0fff; |
| 2643 | tempcx += tempbx; |
| 2644 | if (tempcx >= tempax) |
| 2645 | tempcx -= tempax; |
| 2646 | |
| 2647 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 2648 | (unsigned short) (tempbx & 0xff)); |
| 2649 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 2650 | (unsigned short) (tempcx & 0xff)); |
| 2651 | |
| 2652 | tempbx = (tempbx >> 8) & 0x07; |
| 2653 | tempcx = (tempcx >> 8) & 0x07; |
| 2654 | |
| 2655 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 2656 | (unsigned short) ((tempcx << 3) |
| 2657 | | tempbx)); |
| 2658 | |
| 2659 | tempax = pVBInfo->VT; |
| 2660 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2661 | tempbx = LCDPtr1->LCDVRS; |
| 2662 | else |
| 2663 | tempbx = LCDPtr->LCDVRS; |
| 2664 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2665 | tempcx = push1; |
| 2666 | |
| 2667 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 2668 | tempcx = LCDPtr1->LCDVSync; |
| 2669 | |
| 2670 | tempcx += tempbx; |
| 2671 | if (tempcx >= tempax) |
| 2672 | tempcx -= tempax; |
| 2673 | |
| 2674 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 2675 | (unsigned short) (tempbx & 0xff)); |
| 2676 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 2677 | (unsigned short) (tempcx & 0x0f)); |
| 2678 | |
| 2679 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 2680 | |
| 2681 | tempbx = pVBInfo->VGAVDE; |
| 2682 | if (tempbx != pVBInfo->VDE) |
| 2683 | tempax |= 0x40; |
| 2684 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2685 | if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2686 | tempax |= 0x40; |
| 2687 | |
| 2688 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 2689 | tempax); |
| 2690 | |
| 2691 | tempcx = pVBInfo->VGAVT; |
| 2692 | tempbx = pVBInfo->VDE; |
| 2693 | tempax = pVBInfo->VGAVDE; |
| 2694 | tempcx -= tempax; |
| 2695 | |
| 2696 | temp = tempax; /* 0430 ylshieh */ |
| 2697 | temp1 = (temp << 18) / tempbx; |
| 2698 | |
| 2699 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 2700 | |
| 2701 | if (tempdx != 0) |
| 2702 | temp1 += 1; |
| 2703 | |
| 2704 | temp2 = temp1; |
| 2705 | push3 = temp2; |
| 2706 | |
| 2707 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 2708 | (unsigned short) (temp2 & 0xff)); |
| 2709 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 2710 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 2711 | |
| 2712 | tempbx = (unsigned short) (temp2 >> 16); |
| 2713 | tempax = tempbx & 0x03; |
| 2714 | |
| 2715 | tempbx = pVBInfo->VGAVDE; |
| 2716 | if (tempbx == pVBInfo->VDE) |
| 2717 | tempax |= 0x04; |
| 2718 | |
| 2719 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 2720 | |
| 2721 | if (pVBInfo->VBType & VB_XGI301C) { |
| 2722 | temp2 = push3; |
| 2723 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2724 | 0x3c, |
| 2725 | (unsigned short) (temp2 & 0xff)); |
| 2726 | xgifb_reg_set(pVBInfo->Part4Port, |
| 2727 | 0x3b, |
| 2728 | (unsigned short) ((temp2 >> 8) & |
| 2729 | 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2730 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2731 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 2732 | ~0xc0, |
| 2733 | (unsigned short) ((tempbx & |
| 2734 | 0xff) << 6)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 2735 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2736 | tempcx = pVBInfo->VGAVDE; |
| 2737 | if (tempcx == pVBInfo->VDE) |
| 2738 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2739 | 0x30, ~0x0c, 0x00); |
| 2740 | else |
| 2741 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 2742 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2743 | } |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2744 | |
| 2745 | tempcx = pVBInfo->VGAHDE; |
| 2746 | tempbx = pVBInfo->HDE; |
| 2747 | |
| 2748 | temp1 = tempcx << 16; |
| 2749 | |
| 2750 | tempax = (unsigned short) (temp1 / tempbx); |
| 2751 | |
| 2752 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 2753 | tempax = 65535; |
| 2754 | |
| 2755 | temp3 = tempax; |
| 2756 | temp1 = pVBInfo->VGAHDE << 16; |
| 2757 | |
| 2758 | temp1 /= temp3; |
| 2759 | temp3 = temp3 << 16; |
| 2760 | temp1 -= 1; |
| 2761 | |
| 2762 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 2763 | |
| 2764 | tempax = (unsigned short) (temp3 & 0xff); |
| 2765 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 2766 | |
| 2767 | temp1 = pVBInfo->VGAVDE << 18; |
| 2768 | temp1 = temp1 / push3; |
| 2769 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 2770 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2771 | if (pVBInfo->LCDResInfo == Panel_1024x768) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2772 | tempbx -= 1; |
| 2773 | |
| 2774 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 2775 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 2776 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 2777 | (unsigned short) (tempax & 0xff)); |
| 2778 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 2779 | (unsigned short) (tempbx & 0xff)); |
| 2780 | |
| 2781 | temp3 = temp3 >> 16; |
| 2782 | |
| 2783 | if (modeflag & HalfDCLK) |
| 2784 | temp3 = temp3 >> 1; |
| 2785 | |
| 2786 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 2787 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 2788 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 2789 | (unsigned short) (temp3 & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2790 | } |
| 2791 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2792 | /* --------------------------------------------------------------------- */ |
| 2793 | /* Function : XGI_GETLCDVCLKPtr */ |
| 2794 | /* Input : */ |
| 2795 | /* Output : al -> VCLK Index */ |
| 2796 | /* Description : */ |
| 2797 | /* --------------------------------------------------------------------- */ |
| 2798 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 2799 | struct vb_device_info *pVBInfo) |
| 2800 | { |
| 2801 | unsigned short index; |
| 2802 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2803 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2804 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 2805 | |
| 2806 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 2807 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 2808 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 2809 | } else { /* LCDA */ |
| 2810 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 2811 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 2812 | } |
| 2813 | } |
| 2814 | return; |
| 2815 | } |
| 2816 | |
| 2817 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
| 2818 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 2819 | struct vb_device_info *pVBInfo) |
| 2820 | { |
| 2821 | |
| 2822 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2823 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2824 | |
| 2825 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2826 | /* si+St_ResInfo */ |
| 2827 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2828 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2829 | /* si+Ext_ResInfo */ |
| 2830 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2831 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2832 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 2833 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2834 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 2835 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 2836 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2837 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2838 | return tempal; |
| 2839 | |
| 2840 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2841 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2842 | (VB_SIS301B | |
| 2843 | VB_SIS302B | |
| 2844 | VB_SIS301LV | |
| 2845 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2846 | VB_XGI301C)) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2847 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 2848 | tempal = TVCLKBASE_315 + HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2849 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 2850 | tempal = TVCLKBASE_315 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2851 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 2852 | tempal = TVCLKBASE_315 + HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2853 | if (!(modeflag & Charx8Dot)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 2854 | tempal = TVCLKBASE_315 + HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2855 | |
| 2856 | } |
| 2857 | return tempal; |
| 2858 | } |
| 2859 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2860 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2861 | tempal = XGI_YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2862 | return tempal; |
| 2863 | } |
| 2864 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2865 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2866 | tempal = YPbPr525pVCLK; |
| 2867 | return tempal; |
| 2868 | } |
| 2869 | |
| 2870 | tempal = NTSC1024VCLK; |
| 2871 | |
| 2872 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 2873 | tempal = TVCLKBASE_315 + TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2874 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame^] | 2875 | tempal = TVCLKBASE_315 + TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2876 | } |
| 2877 | |
| 2878 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 2879 | return tempal; |
| 2880 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2881 | } /* {End of VB} */ |
| 2882 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2883 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2884 | tempal = tempal >> 2; |
| 2885 | tempal &= 0x03; |
| 2886 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2887 | /* for Dot8 Scaling LCD */ |
| 2888 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2889 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
| 2890 | |
| 2891 | if (ModeNo <= 0x13) |
| 2892 | return tempal; |
| 2893 | |
| 2894 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 2895 | return tempal; |
| 2896 | } |
| 2897 | |
| 2898 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 2899 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 2900 | { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2901 | if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B |
| 2902 | | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2903 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && (pVBInfo->SetFlag |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2904 | & ProgrammingCRT2)) { |
| 2905 | *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B; |
| 2906 | *di_1 = XGI_VBVCLKData[tempal].SR2C; |
| 2907 | } |
| 2908 | } else { |
| 2909 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 2910 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 2911 | } |
| 2912 | } |
| 2913 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2914 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2915 | unsigned short RefreshRateTableIndex, |
| 2916 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2917 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2918 | unsigned char di_0, di_1, tempal; |
| 2919 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2920 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2921 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 2922 | pVBInfo); |
| 2923 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 2924 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2925 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2926 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2927 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2928 | (unsigned short) (0x10 * i)); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2929 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2930 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2931 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 2932 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2933 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2934 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 2935 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2936 | } |
| 2937 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2938 | } |
| 2939 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2940 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2941 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2942 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2943 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2944 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2945 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 2946 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2947 | tempcl = 0; |
| 2948 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2949 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2950 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2951 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2952 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2953 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2954 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2955 | if (!(temp & 0x40)) |
| 2956 | tempcl |= ActiveCRT1; |
| 2957 | } |
| 2958 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2959 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2960 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2961 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2962 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2963 | if (!(temp == 0x08)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2964 | /* Check ChannelA by Part1_13 [2003/10/03] */ |
| 2965 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2966 | if (tempax & 0x04) |
| 2967 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2968 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2969 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2970 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2971 | if (!(tempcl & ActiveLCD)) |
| 2972 | if (temp == 0x01) |
| 2973 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2974 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2975 | if (temp == 0x04) |
| 2976 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2977 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2978 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2979 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2980 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2981 | if (!(temp & 0x08)) |
| 2982 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2983 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2984 | if (!(temp & 0x04)) |
| 2985 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2986 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2987 | if (temp & 0x02) |
| 2988 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2989 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2990 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2991 | if (temp & 0x01) |
| 2992 | tempch |= ActiveHiTV; |
| 2993 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2994 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2995 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2996 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2997 | pVBInfo->Part2Port, |
| 2998 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2999 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3000 | if (temp & 0x10) |
| 3001 | tempch |= ActiveYPbPr; |
| 3002 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3003 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3004 | if (tempch != 0) |
| 3005 | tempcl |= ActiveTV; |
| 3006 | } |
| 3007 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3008 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3009 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3010 | if (tempcl & ActiveLCD) { |
| 3011 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 3012 | if (temp & ActiveTV) |
| 3013 | tempcl |= ActiveTV; |
| 3014 | } |
| 3015 | } |
| 3016 | temp = tempcl; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3017 | tempbl = ~XGI_ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3018 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3019 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3020 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3021 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3022 | } else { |
| 3023 | return; |
| 3024 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3025 | } |
| 3026 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 3027 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3028 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3029 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3030 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3031 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3032 | tempbx = VB_SIS302B; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3033 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3034 | if (flag != 0x02) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3035 | tempbx = VB_SIS301; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3036 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3037 | if (flag >= 0xB0) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3038 | tempbx = VB_SIS301B; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3039 | if (flag >= 0xC0) { |
| 3040 | tempbx = VB_XGI301C; |
| 3041 | if (flag >= 0xD0) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3042 | tempbx = VB_SIS301LV; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3043 | if (flag >= 0xE0) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3044 | tempbx = VB_SIS302LV; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3045 | tempah = xgifb_reg_get( |
| 3046 | pVBInfo->Part4Port, |
| 3047 | 0x39); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3048 | if (tempah != 0xFF) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3049 | tempbx = |
| 3050 | VB_XGI301C; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3051 | } |
| 3052 | } |
| 3053 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3054 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3055 | if (tempbx & (VB_SIS301B | VB_SIS302B)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3056 | flag = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3057 | pVBInfo->Part4Port, |
| 3058 | 0x23); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3059 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3060 | if (!(flag & 0x02)) |
| 3061 | tempbx = tempbx | VB_NoLCD; |
| 3062 | } |
| 3063 | } |
| 3064 | } |
| 3065 | pVBInfo->VBType = tempbx; |
| 3066 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3067 | } |
| 3068 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 3069 | static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3070 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3071 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3072 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3073 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3074 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3075 | if (ModeNo <= 0x13) |
| 3076 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 3077 | else |
| 3078 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3079 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3080 | pVBInfo->SetFlag = 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3081 | pVBInfo->ModeType = modeflag & ModeTypeMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3082 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3083 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3084 | if (pVBInfo->VBType & 0xFFFF) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3085 | /* Check Display Device */ |
| 3086 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3087 | tempbx = tempbx | temp; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3088 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3089 | push = temp; |
| 3090 | push = push << 8; |
| 3091 | tempax = temp << 8; |
| 3092 | tempbx = tempbx | tempax; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3093 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3094 | | SetInSlaveMode | DisableCRT2Display); |
| 3095 | temp = 0xFFFF ^ temp; |
| 3096 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3097 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3098 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
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 | if (pVBInfo->IF_DEF_LCDA == 1) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3101 | |
Aaro Koskinen | 9ffc7e9 | 2011-11-27 23:03:14 +0200 | [diff] [blame] | 3102 | if ((HwDeviceExtension->jChipType >= XG20) || |
| 3103 | (HwDeviceExtension->jChipType >= XG40)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3104 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3105 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3106 | (VB_SIS302B | |
| 3107 | VB_SIS301LV | |
| 3108 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3109 | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3110 | if (temp & EnableDualEdge) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3111 | tempbx |= |
| 3112 | SetCRT2ToDualEdge; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3113 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3114 | if (temp & SetToLCDA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3115 | tempbx |= |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3116 | XGI_SetCRT2ToLCDA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3117 | } |
| 3118 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3119 | } |
| 3120 | } |
| 3121 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3122 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3123 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3124 | /* [Billy] 07/05/04 */ |
| 3125 | if (((pVBInfo->IF_DEF_LVDS == 0) && |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3126 | ((pVBInfo->VBType & VB_SIS301LV) || |
| 3127 | (pVBInfo->VBType & VB_SIS302LV) || |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3128 | (pVBInfo->VBType & VB_XGI301C)))) { |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 3129 | if (temp & SetYPbPr) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3130 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3131 | /* shampoo add for new |
| 3132 | * scratch */ |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3133 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3134 | pVBInfo->P3d4, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3135 | 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3136 | temp &= YPbPrMode; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3137 | tempbx |= SetCRT2ToHiVision; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3138 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3139 | if (temp != YPbPrMode1080i) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3140 | tempbx &= |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3141 | (~SetCRT2ToHiVision); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3142 | tempbx |= |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3143 | SetCRT2ToYPbPr525750; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3144 | } |
| 3145 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3146 | } |
| 3147 | } |
| 3148 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3149 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3150 | tempax = push; /* restore CR31 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3151 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3152 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3153 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 3154 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 3155 | temp = 0x09FC; |
| 3156 | else |
| 3157 | temp = 0x097C; |
| 3158 | } else { |
| 3159 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 3160 | temp = 0x01FC; |
| 3161 | else |
| 3162 | temp = 0x017C; |
| 3163 | } |
| 3164 | } else { /* 3nd party chip */ |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 3165 | temp = SetCRT2ToLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3166 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3167 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3168 | if (!(tempbx & temp)) { |
| 3169 | tempax |= DisableCRT2Display; |
| 3170 | tempbx = 0; |
| 3171 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3172 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3173 | if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ |
| 3174 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3175 | if (tempbx & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3176 | if (tempbx & SetSimuScanMode) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3177 | tempbx &= (~(SetCRT2ToLCD | |
| 3178 | SetCRT2ToRAMDAC | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3179 | SwitchCRT2)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3180 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3181 | tempbx &= (~(SetCRT2ToLCD | |
| 3182 | SetCRT2ToRAMDAC | |
| 3183 | SetCRT2ToTV | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3184 | SwitchCRT2)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3185 | } |
| 3186 | } |
| 3187 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3188 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3189 | /* shampoo add */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3190 | /* for driver abnormal */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3191 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3192 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 3193 | if (tempbx & SetCRT2ToRAMDAC) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3194 | tempbx &= (0xFF00 | |
| 3195 | SetCRT2ToRAMDAC | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3196 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3197 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3198 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3199 | } |
| 3200 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3201 | tempbx &= (~(SetCRT2ToRAMDAC | |
| 3202 | SetCRT2ToLCD | |
| 3203 | SetCRT2ToTV)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3204 | } |
| 3205 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3206 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3207 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 3208 | if (tempbx & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3209 | tempbx &= (0xFF00 | |
| 3210 | SetCRT2ToLCD | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3211 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3212 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3213 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3214 | } |
| 3215 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3216 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3217 | if (tempbx & SetCRT2ToSCART) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3218 | tempbx &= (0xFF00 | |
| 3219 | SetCRT2ToSCART | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3220 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3221 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3222 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3223 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3224 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3225 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3226 | if (tempbx & SetCRT2ToYPbPr525750) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3227 | tempbx &= (0xFF00 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3228 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3229 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3230 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3231 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3232 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3233 | if (tempbx & SetCRT2ToHiVision) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3234 | tempbx &= (0xFF00 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3235 | SetCRT2ToHiVision | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3236 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3237 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3238 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3239 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3240 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3241 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3242 | tempbx = DisableCRT2Display; |
| 3243 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3244 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3245 | if (!(tempbx & DisableCRT2Display)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3246 | if ((!(tempbx & DriverMode)) || |
| 3247 | (!(modeflag & CRT2Mode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3248 | if (pVBInfo->IF_DEF_LCDA == 1) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3249 | if (!(tempbx & XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3250 | tempbx |= (SetInSlaveMode | |
| 3251 | SetSimuScanMode); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3252 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3253 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3254 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3255 | /* LCD+TV can't support in slave mode |
| 3256 | * (Force LCDA+TV->LCDB) */ |
| 3257 | if ((tempbx & SetInSlaveMode) && |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3258 | (tempbx & XGI_SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3259 | tempbx ^= (SetCRT2ToLCD | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3260 | XGI_SetCRT2ToLCDA | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3261 | SetCRT2ToDualEdge); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3262 | pVBInfo->SetFlag |= ReserveTVOption; |
| 3263 | } |
| 3264 | } |
| 3265 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3266 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3267 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3268 | } |
| 3269 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 3270 | static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3271 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3272 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3273 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3274 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3275 | tempbx = 0; |
| 3276 | resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3277 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3278 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3279 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3280 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 3281 | St_ModeFlag; /* si+St_ModeFlag */ |
| 3282 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 3283 | St_ResInfo; /* si+St_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3284 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3285 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 3286 | Ext_ModeFlag; |
| 3287 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 3288 | Ext_RESINFO; /* si+Ext_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3289 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3290 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3291 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3292 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3293 | tempbx = temp; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3294 | if (tempbx & TVSetPAL) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3295 | tempbx &= (SetCHTVOverScan | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3296 | TVSetPALM | |
| 3297 | TVSetPALN | |
| 3298 | TVSetPAL); |
| 3299 | if (tempbx & TVSetPALM) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3300 | /* set to NTSC if PAL-M */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3301 | tempbx &= ~TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3302 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3303 | tempbx &= (SetCHTVOverScan | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3304 | TVSetNTSCJ | |
| 3305 | TVSetPAL); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3306 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3307 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3308 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 3309 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3310 | tempbx |= TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3311 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3312 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3313 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3314 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3315 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3316 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3317 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3318 | if (index1 == YPbPrMode525i) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3319 | tempbx |= TVSetYPbPr525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3320 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3321 | if (index1 == YPbPrMode525p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3322 | tempbx = tempbx | TVSetYPbPr525p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3323 | if (index1 == YPbPrMode750p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3324 | tempbx = tempbx | TVSetYPbPr750p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3325 | } |
| 3326 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3327 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3328 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3329 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
| 3330 | tempbx = tempbx | TVSetHiVision | TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3331 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3332 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3333 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3334 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 3335 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3336 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3337 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3338 | if (!(tempbx & TVSetPAL) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3339 | (modeflag > 13) && |
| 3340 | (resinfo == 8)) /* NTSC 1024x768, */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3341 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3342 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3343 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3344 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3345 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3346 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 3347 | tempbx &= (~RPLLDIV2XO); |
| 3348 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3349 | if (tempbx & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3350 | (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3351 | tempbx &= (~RPLLDIV2XO); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3352 | else if (!(pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3353 | (VB_SIS301B | |
| 3354 | VB_SIS302B | |
| 3355 | VB_SIS301LV | |
| 3356 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3357 | VB_XGI301C))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3358 | if (tempbx & TVSimuMode) |
| 3359 | tempbx &= (~RPLLDIV2XO); |
| 3360 | } |
| 3361 | } |
| 3362 | } |
| 3363 | } |
| 3364 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3365 | } |
| 3366 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 3367 | static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, |
| 3368 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3369 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3370 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3371 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3372 | pVBInfo->LCDResInfo = 0; |
| 3373 | pVBInfo->LCDTypeInfo = 0; |
| 3374 | pVBInfo->LCDInfo = 0; |
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 (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3377 | /* si+St_ModeFlag // */ |
| 3378 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3379 | } else { |
| 3380 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3381 | /* si+Ext_ResInfo // */ |
| 3382 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3383 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3384 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3385 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3386 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3387 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3388 | if (tempbx == 0) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3389 | tempbx = Panel_1024x768; /* default */ |
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 | /* LCD75 [2003/8/22] Vicent */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3392 | if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3393 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3394 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3395 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3396 | tempax &= 0x0F; |
| 3397 | else |
| 3398 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3399 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3400 | if ((resinfo == 6) || (resinfo == 9)) { |
| 3401 | if (tempax >= 3) |
| 3402 | tempbx |= PanelRef75Hz; |
| 3403 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 3404 | if (tempax >= 4) |
| 3405 | tempbx |= PanelRef75Hz; |
| 3406 | } |
| 3407 | } |
| 3408 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3409 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3410 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3411 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3412 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3413 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3414 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3415 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3416 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3417 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3418 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3419 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3420 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3421 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3422 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3423 | tempbx |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3424 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3425 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3426 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3427 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3428 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3429 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3430 | if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3431 | & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3432 | tempbx |= SetLCDDualLink; |
| 3433 | } |
| 3434 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3435 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3436 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3437 | if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3438 | & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo |
| 3439 | == 9) && (!(tempbx & EnableScalingLCD))) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3440 | /* set to center in 1280x1024 LCDB for Panel_1400x1050 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3441 | tempbx |= SetLCDtoNonExpanding; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3442 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3443 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3444 | if (pVBInfo->IF_DEF_ExpLink == 1) { |
| 3445 | if (modeflag & HalfDCLK) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3446 | if (!(tempbx & SetLCDtoNonExpanding)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3447 | tempbx |= XGI_EnableLVDSDDA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3448 | } else { |
| 3449 | if (ModeNo > 0x13) { |
| 3450 | if (pVBInfo->LCDResInfo |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3451 | == Panel_1024x768) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3452 | if (resinfo == 4) {/* 512x384 */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3453 | tempbx |= XGI_EnableLVDSDDA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3454 | } |
| 3455 | } |
| 3456 | } |
| 3457 | } |
| 3458 | } |
| 3459 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3460 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3461 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3462 | if (pVBInfo->VBInfo & SetNotSimuMode) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3463 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3464 | } else { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3465 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3466 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3467 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3468 | pVBInfo->LCDInfo = tempbx; |
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->IF_DEF_LVDS == 0) { |
| 3471 | if (tempax & (LockLCDBToA | StLCDBToA)) { |
| 3472 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3473 | if (!(tempax & LockLCDBToA)) { |
| 3474 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3475 | pVBInfo->VBInfo &= |
| 3476 | ~(SetSimuScanMode | |
| 3477 | SetInSlaveMode | |
| 3478 | SetCRT2ToLCD); |
| 3479 | pVBInfo->VBInfo |= |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3480 | XGI_SetCRT2ToLCDA | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3481 | SetCRT2ToDualEdge; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3482 | } |
| 3483 | } |
| 3484 | } |
| 3485 | } |
| 3486 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3487 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3488 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3489 | } |
| 3490 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 3491 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3492 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3493 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3494 | if (ModeNo <= 5) |
| 3495 | ModeNo |= 1; |
| 3496 | if (ModeNo <= 0x13) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3497 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3498 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
| 3499 | ModeNo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3500 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3501 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
| 3502 | 0xFF) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3503 | return 0; |
| 3504 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3505 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3506 | if (ModeNo == 0x07) |
| 3507 | (*ModeIdIndex)++; /* 400 lines */ |
| 3508 | if (ModeNo <= 3) |
| 3509 | (*ModeIdIndex) += 2; /* 400 lines */ |
| 3510 | /* else 350 lines */ |
| 3511 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3512 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3513 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
| 3514 | ModeNo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3515 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3516 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
| 3517 | 0xFF) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3518 | return 0; |
| 3519 | } |
| 3520 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3521 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3522 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3523 | } |
| 3524 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3525 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 3526 | { |
| 3527 | unsigned char ujRet = 0; |
| 3528 | unsigned char i = 0; |
| 3529 | |
| 3530 | for (i = 0; i < 8; i++) { |
| 3531 | ujRet = ujRet << 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3532 | ujRet |= (ujDate >> i) & 1; |
| 3533 | } |
| 3534 | |
| 3535 | return ujRet; |
| 3536 | } |
| 3537 | |
| 3538 | /*----------------------------------------------------------------------------*/ |
| 3539 | /* output */ |
| 3540 | /* bl[5] : LVDS signal */ |
| 3541 | /* bl[1] : LVDS backlight */ |
| 3542 | /* bl[0] : LVDS VDD */ |
| 3543 | /*----------------------------------------------------------------------------*/ |
| 3544 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 3545 | { |
| 3546 | unsigned char CR4A, temp; |
| 3547 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3548 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3549 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3550 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3551 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3552 | |
| 3553 | temp = XG21GPIODataTransfer(temp); |
| 3554 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3555 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3556 | return temp; |
| 3557 | } |
| 3558 | |
| 3559 | /*----------------------------------------------------------------------------*/ |
| 3560 | /* output */ |
| 3561 | /* bl[5] : LVDS signal */ |
| 3562 | /* bl[1] : LVDS backlight */ |
| 3563 | /* bl[0] : LVDS VDD */ |
| 3564 | /*----------------------------------------------------------------------------*/ |
| 3565 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 3566 | { |
| 3567 | unsigned char CR4A, CRB4, temp; |
| 3568 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3569 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3570 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3571 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3572 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3573 | |
| 3574 | temp &= 0x0C; |
| 3575 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3576 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3577 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3578 | temp |= ((CRB4 & 0x04) << 3); |
| 3579 | return temp; |
| 3580 | } |
| 3581 | |
Aaro Koskinen | 0ebf538 | 2011-11-27 23:03:09 +0200 | [diff] [blame] | 3582 | /*----------------------------------------------------------------------------*/ |
| 3583 | /* input */ |
| 3584 | /* bl[5] : 1;LVDS signal on */ |
| 3585 | /* bl[1] : 1;LVDS backlight on */ |
| 3586 | /* bl[0] : 1:LVDS VDD on */ |
| 3587 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 3588 | /* 000010b : clear bit 1, to set bit1 */ |
| 3589 | /* 000001b : clear bit 0, to set bit0 */ |
| 3590 | /*----------------------------------------------------------------------------*/ |
| 3591 | static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 3592 | struct vb_device_info *pVBInfo) |
| 3593 | { |
| 3594 | unsigned char CR4A, temp; |
| 3595 | |
| 3596 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 3597 | tempbh &= 0x23; |
| 3598 | tempbl &= 0x23; |
| 3599 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 3600 | |
| 3601 | if (tempbh & 0x20) { |
| 3602 | temp = (tempbl >> 4) & 0x02; |
| 3603 | |
| 3604 | /* CR B4[1] */ |
| 3605 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 3606 | |
| 3607 | } |
| 3608 | |
| 3609 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
| 3610 | |
| 3611 | temp = XG21GPIODataTransfer(temp); |
| 3612 | temp &= ~tempbh; |
| 3613 | temp |= tempbl; |
| 3614 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
| 3615 | } |
| 3616 | |
Aaro Koskinen | 776115a | 2011-11-27 23:03:10 +0200 | [diff] [blame] | 3617 | static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 3618 | struct vb_device_info *pVBInfo) |
| 3619 | { |
| 3620 | unsigned char CR4A, temp; |
| 3621 | unsigned short tempbh0, tempbl0; |
| 3622 | |
| 3623 | tempbh0 = tempbh; |
| 3624 | tempbl0 = tempbl; |
| 3625 | tempbh0 &= 0x20; |
| 3626 | tempbl0 &= 0x20; |
| 3627 | tempbh0 >>= 3; |
| 3628 | tempbl0 >>= 3; |
| 3629 | |
| 3630 | if (tempbh & 0x20) { |
| 3631 | temp = (tempbl >> 4) & 0x02; |
| 3632 | |
| 3633 | /* CR B4[1] */ |
| 3634 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 3635 | |
| 3636 | } |
| 3637 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
| 3638 | |
| 3639 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 3640 | tempbh &= 0x03; |
| 3641 | tempbl &= 0x03; |
| 3642 | tempbh <<= 2; |
| 3643 | tempbl <<= 2; /* GPIOC,GPIOD */ |
| 3644 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 3645 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
| 3646 | } |
| 3647 | |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3648 | /* --------------------------------------------------------------------- */ |
| 3649 | /* Function : XGI_XG21SetPanelDelay */ |
| 3650 | /* Input : */ |
| 3651 | /* Output : */ |
| 3652 | /* Description : */ |
| 3653 | /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */ |
| 3654 | /* : bl : 2 ; T2 : the duration signal on and Vdd on */ |
| 3655 | /* : bl : 3 ; T3 : the duration between CPL off and signal off */ |
| 3656 | /* : bl : 4 ; T4 : the duration signal off and Vdd off */ |
| 3657 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3658 | static void XGI_XG21SetPanelDelay(struct xgifb_video_info *xgifb_info, |
| 3659 | unsigned short tempbl, |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3660 | struct vb_device_info *pVBInfo) |
| 3661 | { |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3662 | if (tempbl == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3663 | mdelay(xgifb_info->lvds_data.PSC_S1); |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3664 | |
| 3665 | if (tempbl == 2) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3666 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3667 | |
| 3668 | if (tempbl == 3) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3669 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3670 | |
| 3671 | if (tempbl == 4) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3672 | mdelay(xgifb_info->lvds_data.PSC_S4); |
Aaro Koskinen | 9913b6c | 2011-11-27 23:03:11 +0200 | [diff] [blame] | 3673 | } |
| 3674 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3675 | static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info, |
| 3676 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3677 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3678 | { |
| 3679 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3680 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3681 | if (pXGIHWDE->jChipType == XG21) { |
| 3682 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 3683 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3684 | /* LVDS VDD on */ |
| 3685 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3686 | XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3687 | } |
| 3688 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3689 | /* LVDS signal on */ |
| 3690 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3691 | XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3692 | /* LVDS backlight on */ |
| 3693 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3694 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3695 | /* DVO/DVI signal on */ |
| 3696 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3697 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3698 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3699 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3700 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3701 | if (pXGIHWDE->jChipType == XG27) { |
| 3702 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 3703 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3704 | /* LVDS VDD on */ |
| 3705 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3706 | XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3707 | } |
| 3708 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3709 | /* LVDS signal on */ |
| 3710 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3711 | XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3712 | /* LVDS backlight on */ |
| 3713 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3714 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3715 | /* DVO/DVI signal on */ |
| 3716 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3717 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3718 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3719 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3720 | } |
| 3721 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3722 | void XGI_DisplayOff(struct xgifb_video_info *xgifb_info, |
| 3723 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3724 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3725 | { |
| 3726 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3727 | if (pXGIHWDE->jChipType == XG21) { |
| 3728 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3729 | /* LVDS backlight off */ |
| 3730 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3731 | XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3732 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3733 | /* DVO/DVI signal off */ |
| 3734 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3735 | } |
| 3736 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3737 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3738 | if (pXGIHWDE->jChipType == XG27) { |
| 3739 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3740 | /* LVDS backlight off */ |
| 3741 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 3742 | XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3743 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3744 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3745 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3746 | /* DVO/DVI signal off */ |
| 3747 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3748 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3749 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3750 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3751 | } |
| 3752 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3753 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3754 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3755 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3756 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3757 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 3758 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3759 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3760 | } |
| 3761 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3762 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3763 | { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 3764 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3765 | } |
| 3766 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3767 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 3768 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3769 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3770 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3771 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3772 | /* reserve CR34 for CRT1 Mode No */ |
| 3773 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3774 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 3775 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3776 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3777 | } |
| 3778 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3779 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
| 3780 | unsigned short ModeIdIndex, |
| 3781 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3782 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3783 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3784 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3785 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 3786 | if (ModeNo <= 0x13) { |
| 3787 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 3788 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3789 | } else { |
| 3790 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 3791 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3792 | /* si+St_ModeFlag */ |
| 3793 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3794 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3795 | if (modeflag & HalfDCLK) |
| 3796 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3797 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3798 | if (modeflag & DoubleScanMode) |
| 3799 | yres *= 2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3800 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3801 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3802 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 3803 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3804 | if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3805 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3806 | if (yres == 1024) |
| 3807 | yres = 1056; |
| 3808 | } |
| 3809 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3810 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3811 | if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3812 | if (yres == 400) |
| 3813 | yres = 405; |
| 3814 | else if (yres == 350) |
| 3815 | yres = 360; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3816 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3817 | if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3818 | if (yres == 360) |
| 3819 | yres = 375; |
| 3820 | } |
| 3821 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3822 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3823 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3824 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3825 | if (!(pVBInfo->LCDInfo |
| 3826 | & LCDNonExpanding)) { |
| 3827 | if (yres == 350) |
| 3828 | yres = 357; |
| 3829 | else if (yres == 400) |
| 3830 | yres = 420; |
| 3831 | else if (yres == 480) |
| 3832 | yres = 525; |
| 3833 | } |
| 3834 | } |
| 3835 | } |
| 3836 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3837 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3838 | if (xres == 720) |
| 3839 | xres = 640; |
| 3840 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3841 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3842 | pVBInfo->VGAHDE = xres; |
| 3843 | pVBInfo->HDE = xres; |
| 3844 | pVBInfo->VGAVDE = yres; |
| 3845 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3846 | } |
| 3847 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3848 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3849 | { |
| 3850 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3851 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) && |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 3852 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3853 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3854 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3855 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3856 | } |
| 3857 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3858 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
| 3859 | unsigned short ModeIdIndex, |
| 3860 | unsigned short RefreshRateTableIndex, |
| 3861 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3862 | { |
| 3863 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
| 3864 | StandTableIndex, CRT1Index; |
| 3865 | |
| 3866 | pVBInfo->RVBHCMAX = 1; |
| 3867 | pVBInfo->RVBHCFACT = 1; |
| 3868 | |
| 3869 | if (ModeNo <= 0x13) { |
| 3870 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 3871 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
| 3872 | tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0]; |
| 3873 | tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6]; |
| 3874 | temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7]; |
| 3875 | } else { |
| 3876 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3877 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 3878 | Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3879 | CRT1Index &= IndexMask; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3880 | temp1 = (unsigned short) pVBInfo-> |
| 3881 | XGINEWUB_CRT1Table[CRT1Index].CR[0]; |
| 3882 | temp2 = (unsigned short) pVBInfo-> |
| 3883 | XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3884 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3885 | tempbx = (unsigned short) pVBInfo-> |
| 3886 | XGINEWUB_CRT1Table[CRT1Index].CR[8]; |
| 3887 | tempcx = (unsigned short) pVBInfo-> |
| 3888 | XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3889 | tempcx &= 0x0100; |
| 3890 | tempcx = tempcx << 2; |
| 3891 | tempbx |= tempcx; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3892 | temp1 = (unsigned short) pVBInfo-> |
| 3893 | XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3894 | } |
| 3895 | |
| 3896 | if (temp1 & 0x01) |
| 3897 | tempbx |= 0x0100; |
| 3898 | |
| 3899 | if (temp1 & 0x20) |
| 3900 | tempbx |= 0x0200; |
| 3901 | tempax += 5; |
| 3902 | |
| 3903 | if (modeflag & Charx8Dot) |
| 3904 | tempax *= 8; |
| 3905 | else |
| 3906 | tempax *= 9; |
| 3907 | |
| 3908 | pVBInfo->VGAHT = tempax; |
| 3909 | pVBInfo->HT = tempax; |
| 3910 | tempbx++; |
| 3911 | pVBInfo->VGAVT = tempbx; |
| 3912 | pVBInfo->VT = tempbx; |
| 3913 | } |
| 3914 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3915 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3916 | unsigned short RefreshRateTableIndex, |
| 3917 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3918 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3919 | unsigned short tempax = 0, tempbx, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3920 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 3921 | struct SiS_LCDData *LCDPtr = NULL; |
| 3922 | struct SiS_TVData *TVPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3923 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3924 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3925 | /* si+St_ResInfo */ |
| 3926 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3927 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 3928 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3929 | /* si+Ext_ResInfo */ |
| 3930 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3931 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 3932 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3933 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3934 | pVBInfo->NewFlickerMode = 0; |
| 3935 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3936 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3937 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 3938 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3939 | pVBInfo); |
| 3940 | return; |
| 3941 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3942 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3943 | tempbx = 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3944 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3945 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 3946 | LCDPtr = (struct SiS_LCDData *) XGI_GetLcdPtr(tempbx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3947 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3948 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3949 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3950 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 3951 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 3952 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 3953 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 3954 | pVBInfo->HT = LCDPtr->LCDHT; |
| 3955 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3956 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3957 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3958 | tempax = 1024; |
| 3959 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3960 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3961 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3962 | if (pVBInfo->VGAVDE == 357) |
| 3963 | tempbx = 527; |
| 3964 | else if (pVBInfo->VGAVDE == 420) |
| 3965 | tempbx = 620; |
| 3966 | else if (pVBInfo->VGAVDE == 525) |
| 3967 | tempbx = 775; |
| 3968 | else if (pVBInfo->VGAVDE == 600) |
| 3969 | tempbx = 775; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3970 | else |
| 3971 | tempbx = 768; |
| 3972 | } else |
| 3973 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3974 | } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3975 | tempax = 1024; |
| 3976 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3977 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3978 | tempax = 1280; |
| 3979 | if (pVBInfo->VGAVDE == 360) |
| 3980 | tempbx = 768; |
| 3981 | else if (pVBInfo->VGAVDE == 375) |
| 3982 | tempbx = 800; |
| 3983 | else if (pVBInfo->VGAVDE == 405) |
| 3984 | tempbx = 864; |
| 3985 | else |
| 3986 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3987 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3988 | tempax = 1280; |
| 3989 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3990 | } else if (pVBInfo->LCDResInfo == Panel_1280x960) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3991 | tempax = 1280; |
| 3992 | if (pVBInfo->VGAVDE == 350) |
| 3993 | tempbx = 700; |
| 3994 | else if (pVBInfo->VGAVDE == 400) |
| 3995 | tempbx = 800; |
| 3996 | else if (pVBInfo->VGAVDE == 1024) |
| 3997 | tempbx = 960; |
| 3998 | else |
| 3999 | tempbx = 960; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4000 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4001 | tempax = 1400; |
| 4002 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4003 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4004 | if (pVBInfo->VGAVDE == 1024) { |
| 4005 | tempax = 1280; |
| 4006 | tempbx = 1024; |
| 4007 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4008 | } else if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4009 | tempax = 1600; |
| 4010 | tempbx = 1200; /* alan 10/14/2003 */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4011 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4012 | if (pVBInfo->VGAVDE == 350) |
| 4013 | tempbx = 875; |
| 4014 | else if (pVBInfo->VGAVDE == 400) |
| 4015 | tempbx = 1000; |
| 4016 | } |
| 4017 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4018 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4019 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 4020 | tempax = pVBInfo->VGAHDE; |
| 4021 | tempbx = pVBInfo->VGAVDE; |
| 4022 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4023 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4024 | pVBInfo->HDE = tempax; |
| 4025 | pVBInfo->VDE = tempbx; |
| 4026 | return; |
| 4027 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4028 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4029 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
| 4030 | tempbx = 4; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 4031 | TVPtr = (struct SiS_TVData *) XGI_GetTVPtr(tempbx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4032 | ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4033 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4034 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4035 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 4036 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 4037 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 4038 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 4039 | pVBInfo->HDE = TVPtr->TVHDE; |
| 4040 | pVBInfo->VDE = TVPtr->TVVDE; |
| 4041 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 4042 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4043 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4044 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4045 | if (resinfo == 0x08) |
| 4046 | pVBInfo->NewFlickerMode = 0x40; |
| 4047 | else if (resinfo == 0x09) |
| 4048 | pVBInfo->NewFlickerMode = 0x40; |
| 4049 | else if (resinfo == 0x12) |
| 4050 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4051 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4052 | if (pVBInfo->VGAVDE == 350) |
| 4053 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4054 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4055 | tempax = ExtHiTVHT; |
| 4056 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4057 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4058 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 4059 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4060 | tempax = StHiTVHT; |
| 4061 | tempbx = StHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4062 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4063 | if (!(modeflag & Charx8Dot)) { |
| 4064 | tempax = StHiTextTVHT; |
| 4065 | tempbx = StHiTextTVVT; |
| 4066 | } |
| 4067 | } |
| 4068 | } |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4069 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 4070 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4071 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 4072 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 4073 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4074 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4075 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4076 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 4077 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4078 | } else if (pVBInfo->TVInfo & TVSetYPbPr525i) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4079 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 4080 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 4081 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 4082 | tempax = NTSC1024x768HT; |
| 4083 | } |
| 4084 | } else { |
| 4085 | tempax = PALHT; |
| 4086 | tempbx = PALVT; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4087 | if (!(pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4088 | tempax = NTSCHT; |
| 4089 | tempbx = NTSCVT; |
| 4090 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 4091 | tempax = NTSC1024x768HT; |
| 4092 | } |
| 4093 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4094 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4095 | pVBInfo->HT = tempax; |
| 4096 | pVBInfo->VT = tempbx; |
| 4097 | return; |
| 4098 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4099 | } |
| 4100 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4101 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4102 | unsigned short RefreshRateTableIndex, |
| 4103 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4104 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 4105 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4106 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4107 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 4108 | pVBInfo); |
| 4109 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 4110 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4111 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4112 | if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4113 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4114 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 4115 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 4116 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4117 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4118 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 4119 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4120 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4121 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4122 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4123 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4124 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4125 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4126 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4127 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4128 | } |
| 4129 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4130 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
| 4131 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4132 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4133 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 4134 | short index; |
| 4135 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4136 | |
| 4137 | if (ModeNo <= 0x13) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4138 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4139 | else |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4140 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4141 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4142 | index = (modeflag & ModeTypeMask) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4143 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4144 | if (index < 0) |
| 4145 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4146 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4147 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4148 | } |
| 4149 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4150 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 4151 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4152 | unsigned short RefreshRateTableIndex, |
| 4153 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4154 | struct vb_device_info *pVBInfo) |
| 4155 | { |
| 4156 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 4157 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 4158 | |
| 4159 | modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
| 4160 | if (ModeNo <= 0x14) |
| 4161 | infoflag = 0; |
| 4162 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4163 | infoflag = pVBInfo-> |
| 4164 | RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4165 | |
| 4166 | index = (modeinfo >> 8) & 0xFF; |
| 4167 | |
| 4168 | temp = pVBInfo->ScreenOffset[index]; |
| 4169 | |
| 4170 | if (infoflag & InterlaceMode) |
| 4171 | temp = temp << 1; |
| 4172 | |
| 4173 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 4174 | |
| 4175 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 4176 | temp = ModeNo - 0x7C; |
| 4177 | colordepth = ColorDepth[temp]; |
| 4178 | temp = 0x6B; |
| 4179 | if (infoflag & InterlaceMode) |
| 4180 | temp = temp << 1; |
| 4181 | return temp * colordepth; |
| 4182 | } else { |
| 4183 | return temp * colordepth; |
| 4184 | } |
| 4185 | } |
| 4186 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4187 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 4188 | unsigned short ModeIdIndex, |
| 4189 | unsigned short RefreshRateTableIndex, |
| 4190 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4191 | struct vb_device_info *pVBInfo) |
| 4192 | { |
| 4193 | unsigned short offset; |
| 4194 | unsigned char temp; |
| 4195 | |
| 4196 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 4197 | return; |
| 4198 | |
| 4199 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4200 | HwDeviceExtension, pVBInfo); |
| 4201 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4202 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4203 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4204 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4205 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4206 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4207 | } |
| 4208 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 4209 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4210 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4211 | /* threshold high ,disable auto threshold */ |
| 4212 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 4213 | /* threshold low default 04h */ |
| 4214 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4215 | } |
| 4216 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4217 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4218 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4219 | unsigned short RefreshRateTableIndex, |
| 4220 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4221 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4222 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4223 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4224 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4225 | CRT1Index = pVBInfo-> |
| 4226 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4227 | CRT1Index &= IndexMask; |
| 4228 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 4229 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4230 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4231 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 4232 | HwDeviceExtension, pVBInfo); |
| 4233 | XGI_SetCRT2FIFO(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4234 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4235 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4236 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4237 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4238 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 4239 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4240 | } |
| 4241 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4242 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4243 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4244 | unsigned short RefreshRateTableIndex, |
| 4245 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4246 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4247 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
| 4248 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4249 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4250 | if (ModeNo > 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4251 | CRT1Index = pVBInfo-> |
| 4252 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4253 | CRT1Index &= IndexMask; |
| 4254 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4255 | } |
| 4256 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4257 | if (ModeNo <= 0x13) |
| 4258 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 4259 | else |
| 4260 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4261 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4262 | /* bainy change table name */ |
| 4263 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4264 | /* BTVGA2HT 0x08,0x09 */ |
| 4265 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4266 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4267 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4268 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4269 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 4270 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4271 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4272 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 4273 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 4274 | tempcx = tempcx >> 1; |
| 4275 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 4276 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4277 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4278 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4279 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4280 | tempbx |= ((pVBInfo-> |
| 4281 | XGINEWUB_CRT1Table[CRT1Index].CR[14] & |
| 4282 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4283 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 4284 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; |
| 4285 | tempcx &= 0x1F; |
| 4286 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15]; |
| 4287 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 4288 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 4289 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4290 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4291 | tempbx += 4; |
| 4292 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4293 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4294 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 4295 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4296 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4297 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4298 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4299 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4300 | } else { |
| 4301 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4302 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4303 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4304 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4305 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 4306 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4307 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4308 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 4309 | pushbx = pVBInfo->VGAHDE + 16; |
| 4310 | tempcx = tempcx >> 1; |
| 4311 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 4312 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4313 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4314 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4315 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3]; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4316 | tempbx |= ((pVBInfo-> |
| 4317 | XGINEWUB_CRT1Table[CRT1Index].CR[5] & |
| 4318 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4319 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
| 4320 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; |
| 4321 | tempcx &= 0x1F; |
| 4322 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6]; |
| 4323 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 4324 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 4325 | tempbx += 16; |
| 4326 | tempcx += 16; |
| 4327 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4328 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4329 | if (tempcx > pVBInfo->VGAHT) |
| 4330 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4331 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4332 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4333 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4334 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4335 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4336 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 4337 | tempbx = pushbx; |
| 4338 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 4339 | tempax |= (tempbx & 0xFF00); |
| 4340 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4341 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4342 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4343 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4344 | tempcx = (pVBInfo->VGAVT - 1); |
| 4345 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4346 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4347 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4348 | tempbx = pVBInfo->VGAVDE - 1; |
| 4349 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4350 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4351 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 4352 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4353 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4354 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4355 | tempax = pVBInfo->VGAVDE; |
| 4356 | tempbx = pVBInfo->VGAVDE; |
| 4357 | tempcx = pVBInfo->VGAVT; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4358 | /* BTVGA2VRS 0x10,0x11 */ |
| 4359 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 4360 | /* BTVGA2VRE 0x11 */ |
| 4361 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4362 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4363 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 4364 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; |
| 4365 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4366 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4367 | if (temp & 0x04) |
| 4368 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4369 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4370 | if (temp & 0x080) |
| 4371 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4372 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4373 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4374 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4375 | if (temp & 0x08) |
| 4376 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4377 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4378 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; |
| 4379 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 4380 | } |
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 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4383 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4384 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 4385 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4386 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4387 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4388 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4389 | if (modeflag & DoubleScanMode) |
| 4390 | tempax |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4391 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4392 | if (modeflag & HalfDCLK) |
| 4393 | tempax |= 0x40; |
| 4394 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4395 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4396 | } |
| 4397 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4398 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 4399 | { |
| 4400 | unsigned long tempax, tempbx; |
| 4401 | |
| 4402 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 4403 | & 0xFFFF; |
| 4404 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 4405 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 4406 | |
| 4407 | return (unsigned short) tempax; |
| 4408 | } |
| 4409 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4410 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4411 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4412 | unsigned short RefreshRateTableIndex, |
| 4413 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4414 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4415 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
| 4416 | modeflag, CRT1Index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4417 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4418 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4419 | /* si+St_ResInfo */ |
| 4420 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4421 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4422 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4423 | /* si+Ext_ResInfo */ |
| 4424 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4425 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4426 | CRT1Index = pVBInfo-> |
| 4427 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4428 | CRT1Index &= IndexMask; |
| 4429 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4430 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4431 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 4432 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4433 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4434 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4435 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4436 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4437 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4438 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4439 | modeflag |= Charx8Dot; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4440 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4441 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4442 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4443 | if (modeflag & HalfDCLK) |
| 4444 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4445 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4446 | tempax = (tempax / tempcx) - 1; |
| 4447 | tempbx |= ((tempax & 0x00FF) << 8); |
| 4448 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4449 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4450 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4451 | temp = (tempbx & 0xFF00) >> 8; |
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 (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4454 | if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4455 | | VB_SIS302LV | VB_XGI301C))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4456 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4457 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4458 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4459 | if (pVBInfo->VBType & VB_SIS301LV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4460 | if (pVBInfo->VBExtInfo == VB_YPbPr1080i) { |
| 4461 | if (resinfo == 7) |
| 4462 | temp -= 2; |
| 4463 | } |
| 4464 | } else if (resinfo == 7) { |
| 4465 | temp -= 2; |
| 4466 | } |
| 4467 | } |
| 4468 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4469 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4470 | /* 0x05 Horizontal Display Start */ |
| 4471 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 4472 | /* 0x06 Horizontal Blank end */ |
| 4473 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4474 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4475 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 4476 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 4477 | tempax = pVBInfo->VGAHT; |
| 4478 | else |
| 4479 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 4480 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4481 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4482 | if (tempax >= pVBInfo->VGAHT) |
| 4483 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4484 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4485 | if (modeflag & HalfDCLK) |
| 4486 | tempax = tempax >> 1; |
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 | tempax = (tempax / tempcx) - 5; |
| 4489 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4490 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4491 | temp = (tempbx & 0x00FF) - 1; |
| 4492 | if (!(modeflag & HalfDCLK)) { |
| 4493 | temp -= 6; |
| 4494 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4495 | temp -= 4; |
| 4496 | if (ModeNo > 0x13) |
| 4497 | temp -= 10; |
| 4498 | } |
| 4499 | } |
| 4500 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4501 | tempbx = (tempbx & 0xFF00) >> 8; |
| 4502 | tempcx = (tempcx + tempbx) >> 1; |
| 4503 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4504 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4505 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4506 | temp -= 1; |
| 4507 | if (!(modeflag & HalfDCLK)) { |
| 4508 | if ((modeflag & Charx8Dot)) { |
| 4509 | temp += 4; |
| 4510 | if (pVBInfo->VGAHDE >= 800) |
| 4511 | temp -= 6; |
| 4512 | } |
| 4513 | } |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 4514 | } else if (!(modeflag & HalfDCLK)) { |
| 4515 | temp -= 4; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4516 | if (pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 4517 | pVBInfo->VGAHDE >= 800) { |
| 4518 | temp -= 7; |
| 4519 | if (pVBInfo->ModeType == ModeEGA && |
| 4520 | pVBInfo->VGAVDE == 1024) { |
| 4521 | temp += 15; |
| 4522 | if (pVBInfo->LCDResInfo != |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4523 | Panel_1280x1024) |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 4524 | temp += 7; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4525 | } |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 4526 | |
| 4527 | if (pVBInfo->VGAHDE >= 1280 && |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4528 | pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 4529 | (pVBInfo->LCDInfo & LCDNonExpanding)) |
| 4530 | temp += 28; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4531 | } |
| 4532 | } |
| 4533 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4534 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4535 | /* 0x07 Horizontal Retrace Start */ |
| 4536 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 4537 | /* 0x08 Horizontal Retrace End */ |
| 4538 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4539 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4540 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4541 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 4542 | if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo |
| 4543 | == 0x11) || (ModeNo == 0x13) || (ModeNo |
| 4544 | == 0x0F)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4545 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b); |
| 4546 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4547 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4548 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4549 | if ((ModeNo == 0x00) || (ModeNo == 0x01)) { |
| 4550 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4551 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4552 | 0x07, 0x2A); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4553 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4554 | 0x08, 0x61); |
| 4555 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4556 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4557 | 0x07, 0x2A); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4558 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4559 | 0x08, 0x41); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4560 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4561 | 0x0C, 0xF0); |
| 4562 | } |
| 4563 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4564 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4565 | if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo |
| 4566 | == 0x07)) { |
| 4567 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4568 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4569 | 0x07, 0x54); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4570 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4571 | 0x08, 0x00); |
| 4572 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4573 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4574 | 0x07, 0x55); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4575 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4576 | 0x08, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4577 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4578 | 0x0C, 0xF0); |
| 4579 | } |
| 4580 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4581 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4582 | if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo |
| 4583 | == 0x0D) || (ModeNo == 0x50)) { |
| 4584 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4585 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4586 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4587 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4588 | 0x08, 0x03); |
| 4589 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4590 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4591 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4592 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4593 | 0x08, 0x02); |
| 4594 | } |
| 4595 | } |
| 4596 | } |
| 4597 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4598 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4599 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4600 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4601 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
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 | tempbx = pVBInfo->VGAVT; |
| 4604 | push1 = tempbx; |
| 4605 | tempcx = 0x121; |
| 4606 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
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 | if (tempbx == 357) |
| 4609 | tempbx = 350; |
| 4610 | if (tempbx == 360) |
| 4611 | tempbx = 350; |
| 4612 | if (tempbx == 375) |
| 4613 | tempbx = 350; |
| 4614 | if (tempbx == 405) |
| 4615 | tempbx = 400; |
| 4616 | if (tempbx == 525) |
| 4617 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4618 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4619 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4620 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4621 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4622 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4623 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4624 | if (tempbx == 350) |
| 4625 | tempbx += 5; |
| 4626 | if (tempbx == 480) |
| 4627 | tempbx += 5; |
| 4628 | } |
| 4629 | } |
| 4630 | } |
| 4631 | tempbx--; |
| 4632 | temp = tempbx & 0x00FF; |
| 4633 | tempbx--; |
| 4634 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4635 | /* 0x10 vertical Blank Start */ |
| 4636 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4637 | tempbx = push2; |
| 4638 | tempbx--; |
| 4639 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4640 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4641 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4642 | if (tempbx & 0x0100) |
| 4643 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4644 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4645 | tempax = 0x000B; |
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 & DoubleScanMode) |
| 4648 | tempax |= 0x08000; |
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 | if (tempbx & 0x0200) |
| 4651 | tempcx |= 0x0040; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4652 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4653 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4654 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4655 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4656 | if (tempbx & 0x0400) |
| 4657 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4658 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4659 | /* 0x11 Vertival Blank End */ |
| 4660 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4661 | |
| 4662 | tempax = push1; |
| 4663 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 4664 | tempax = tempax >> 2; |
| 4665 | push1 = tempax; /* push ax */ |
| 4666 | |
| 4667 | if (resinfo != 0x09) { |
| 4668 | tempax = tempax << 1; |
| 4669 | tempbx += tempax; |
| 4670 | } |
| 4671 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4672 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4673 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4674 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4675 | tempbx -= 10; |
| 4676 | } else { |
| 4677 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4678 | if (pVBInfo->TVInfo & TVSetPAL) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4679 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4680 | VB_SIS301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4681 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4682 | (TVSetYPbPr525p | |
| 4683 | TVSetYPbPr750p | |
| 4684 | TVSetHiVision))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4685 | tempbx += 40; |
| 4686 | } else { |
| 4687 | tempbx += 40; |
| 4688 | } |
| 4689 | } |
| 4690 | } |
| 4691 | } |
| 4692 | } else { |
| 4693 | tempbx -= 10; |
| 4694 | } |
| 4695 | } else { |
| 4696 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4697 | if (pVBInfo->TVInfo & TVSetPAL) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4698 | if (pVBInfo->VBType & VB_SIS301LV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4699 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4700 | (TVSetYPbPr525p | |
| 4701 | TVSetYPbPr750p | |
| 4702 | TVSetHiVision))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4703 | tempbx += 40; |
| 4704 | } else { |
| 4705 | tempbx += 40; |
| 4706 | } |
| 4707 | } |
| 4708 | } |
| 4709 | } |
| 4710 | tempax = push1; |
| 4711 | tempax = tempax >> 2; |
| 4712 | tempax++; |
| 4713 | tempax += tempbx; |
| 4714 | push1 = tempax; /* push ax */ |
| 4715 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4716 | if ((pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4717 | if (tempbx <= 513) { |
| 4718 | if (tempax >= 513) |
| 4719 | tempbx = 513; |
| 4720 | } |
| 4721 | } |
| 4722 | |
| 4723 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4724 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4725 | tempbx--; |
| 4726 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4727 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4728 | |
| 4729 | if (tempbx & 0x0100) |
| 4730 | tempcx |= 0x0008; |
| 4731 | |
| 4732 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4733 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4734 | |
| 4735 | tempbx++; |
| 4736 | |
| 4737 | if (tempbx & 0x0100) |
| 4738 | tempcx |= 0x0004; |
| 4739 | |
| 4740 | if (tempbx & 0x0200) |
| 4741 | tempcx |= 0x0080; |
| 4742 | |
| 4743 | if (tempbx & 0x0400) |
| 4744 | tempcx |= 0x0C00; |
| 4745 | |
| 4746 | tempbx = push1; /* pop ax */ |
| 4747 | temp = tempbx & 0x00FF; |
| 4748 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4749 | /* 0x0D vertical Retrace End */ |
| 4750 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4751 | |
| 4752 | if (tempbx & 0x0010) |
| 4753 | tempcx |= 0x2000; |
| 4754 | |
| 4755 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4756 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4757 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4758 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4759 | tempax = modeflag; |
| 4760 | temp = (tempax & 0xFF00) >> 8; |
| 4761 | |
| 4762 | temp = (temp >> 1) & 0x09; |
| 4763 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4764 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4765 | temp |= 0x01; |
| 4766 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4767 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 4768 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 4769 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4770 | |
| 4771 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 4772 | temp = 0x80; |
| 4773 | else |
| 4774 | temp = 0x00; |
| 4775 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4776 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4777 | |
| 4778 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4779 | } |
| 4780 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4781 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4782 | unsigned short RefreshRateTableIndex, |
| 4783 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4784 | struct vb_device_info *pVBInfo) |
| 4785 | { |
| 4786 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
| 4787 | modeflag, resinfo, crt2crtc; |
| 4788 | unsigned char *TimingPoint; |
| 4789 | |
| 4790 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 4791 | |
| 4792 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4793 | /* si+St_ResInfo */ |
| 4794 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4795 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 4796 | crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
| 4797 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4798 | /* si+Ext_ResInfo */ |
| 4799 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4800 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4801 | crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 4802 | Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4803 | } |
| 4804 | |
| 4805 | tempax = 0; |
| 4806 | |
| 4807 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 4808 | tempax |= 0x0800; |
| 4809 | |
| 4810 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 4811 | tempax |= 0x0400; |
| 4812 | |
| 4813 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 4814 | tempax |= 0x0200; |
| 4815 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4816 | if (!(pVBInfo->TVInfo & TVSetPAL)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4817 | tempax |= 0x1000; |
| 4818 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4819 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4820 | tempax |= 0x0100; |
| 4821 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4822 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4823 | tempax &= 0xfe00; |
| 4824 | |
| 4825 | tempax = (tempax & 0xff00) >> 8; |
| 4826 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4827 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4828 | TimingPoint = pVBInfo->NTSCTiming; |
| 4829 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4830 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4831 | TimingPoint = pVBInfo->PALTiming; |
| 4832 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4833 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4834 | TimingPoint = pVBInfo->HiTVExtTiming; |
| 4835 | |
| 4836 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 4837 | TimingPoint = pVBInfo->HiTVSt2Timing; |
| 4838 | |
| 4839 | if (pVBInfo->SetFlag & TVSimuMode) |
| 4840 | TimingPoint = pVBInfo->HiTVSt1Timing; |
| 4841 | |
| 4842 | if (!(modeflag & Charx8Dot)) |
| 4843 | TimingPoint = pVBInfo->HiTVTextTiming; |
| 4844 | } |
| 4845 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4846 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 4847 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4848 | TimingPoint = pVBInfo->YPbPr525iTiming; |
| 4849 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4850 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4851 | TimingPoint = pVBInfo->YPbPr525pTiming; |
| 4852 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4853 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4854 | TimingPoint = pVBInfo->YPbPr750pTiming; |
| 4855 | } |
| 4856 | |
| 4857 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4858 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4859 | |
| 4860 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4861 | /* di->temp2[j] */ |
| 4862 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4863 | |
| 4864 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4865 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4866 | |
| 4867 | temp = pVBInfo->NewFlickerMode; |
| 4868 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4869 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4870 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4871 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4872 | tempax = 950; |
| 4873 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4874 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4875 | tempax = 520; |
| 4876 | else |
| 4877 | tempax = 440; |
| 4878 | |
| 4879 | if (pVBInfo->VDE <= tempax) { |
| 4880 | tempax -= pVBInfo->VDE; |
| 4881 | tempax = tempax >> 2; |
| 4882 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 4883 | push1 = tempax; |
| 4884 | temp = (tempax & 0xFF00) >> 8; |
| 4885 | temp += (unsigned short) TimingPoint[0]; |
| 4886 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4887 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4888 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4889 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 4890 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4891 | | SetCRT2ToYPbPr525750)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4892 | tempcx = pVBInfo->VGAHDE; |
| 4893 | if (tempcx >= 1024) { |
| 4894 | temp = 0x17; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4895 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4896 | temp = 0x19; /* PAL */ |
| 4897 | } |
| 4898 | } |
| 4899 | } |
| 4900 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4901 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4902 | tempax = push1; |
| 4903 | temp = (tempax & 0xFF00) >> 8; |
| 4904 | temp += TimingPoint[1]; |
| 4905 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4906 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4907 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4908 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 4909 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4910 | | SetCRT2ToYPbPr525750))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4911 | tempcx = pVBInfo->VGAHDE; |
| 4912 | if (tempcx >= 1024) { |
| 4913 | temp = 0x1D; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4914 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4915 | temp = 0x52; /* PAL */ |
| 4916 | } |
| 4917 | } |
| 4918 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4919 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4920 | } |
| 4921 | |
| 4922 | /* 301b */ |
| 4923 | tempcx = pVBInfo->HT; |
| 4924 | |
| 4925 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4926 | tempcx = tempcx >> 1; |
| 4927 | |
| 4928 | tempcx -= 2; |
| 4929 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4930 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4931 | |
| 4932 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4933 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4934 | |
| 4935 | tempcx = pVBInfo->HT >> 1; |
| 4936 | push1 = tempcx; /* push cx */ |
| 4937 | tempcx += 7; |
| 4938 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4939 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4940 | tempcx -= 4; |
| 4941 | |
| 4942 | temp = tempcx & 0x00FF; |
| 4943 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4944 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4945 | |
| 4946 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 4947 | tempbx += tempcx; |
| 4948 | push2 = tempbx; |
| 4949 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4950 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4951 | temp = (tempbx & 0xFF00) >> 8; |
| 4952 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4953 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4954 | |
| 4955 | tempbx = push2; |
| 4956 | tempbx = tempbx + 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4957 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4958 | tempbx = tempbx - 4; |
| 4959 | tempcx = tempbx; |
| 4960 | } |
| 4961 | |
| 4962 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4963 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4964 | |
| 4965 | j += 2; |
| 4966 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 4967 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4968 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4969 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4970 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4971 | |
| 4972 | tempcx += 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4973 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4974 | tempcx -= 4; |
| 4975 | |
| 4976 | temp = tempcx & 0xFF; |
| 4977 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4978 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4979 | |
| 4980 | tempcx = push1; /* pop cx */ |
| 4981 | j += 2; |
| 4982 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 4983 | tempcx -= temp; |
| 4984 | temp = tempcx & 0x00FF; |
| 4985 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4986 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4987 | |
| 4988 | tempcx -= 11; |
| 4989 | |
| 4990 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 4991 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 4992 | tempcx = tempax - 1; |
| 4993 | } |
| 4994 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4995 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4996 | |
| 4997 | tempbx = pVBInfo->VDE; |
| 4998 | |
| 4999 | if (pVBInfo->VGAVDE == 360) |
| 5000 | tempbx = 746; |
| 5001 | if (pVBInfo->VGAVDE == 375) |
| 5002 | tempbx = 746; |
| 5003 | if (pVBInfo->VGAVDE == 405) |
| 5004 | tempbx = 853; |
| 5005 | |
| 5006 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5007 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5008 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5009 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5010 | (TVSetYPbPr525p | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5011 | tempbx = tempbx >> 1; |
| 5012 | } else |
| 5013 | tempbx = tempbx >> 1; |
| 5014 | } |
| 5015 | |
| 5016 | tempbx -= 2; |
| 5017 | temp = tempbx & 0x00FF; |
| 5018 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5019 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5020 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5021 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5022 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5023 | if (ModeNo == 0x2f) |
| 5024 | temp += 1; |
| 5025 | } |
| 5026 | } |
| 5027 | } else { |
| 5028 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5029 | if (ModeNo == 0x2f) |
| 5030 | temp += 1; |
| 5031 | } |
| 5032 | } |
| 5033 | } |
| 5034 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5035 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5036 | |
| 5037 | temp = (tempcx & 0xFF00) >> 8; |
| 5038 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 5039 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5040 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5041 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5042 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5043 | temp |= 0x10; |
| 5044 | |
| 5045 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5046 | temp |= 0x20; |
| 5047 | } |
| 5048 | } else { |
| 5049 | temp |= 0x10; |
| 5050 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 5051 | temp |= 0x20; |
| 5052 | } |
| 5053 | } |
| 5054 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5055 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5056 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5057 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5058 | | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5059 | tempbx = pVBInfo->VDE; |
| 5060 | tempcx = tempbx - 2; |
| 5061 | |
| 5062 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5063 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p |
| 5064 | | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5065 | tempbx = tempbx >> 1; |
| 5066 | } |
| 5067 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5068 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5069 | temp = 0; |
| 5070 | if (tempcx & 0x0400) |
| 5071 | temp |= 0x20; |
| 5072 | |
| 5073 | if (tempbx & 0x0400) |
| 5074 | temp |= 0x40; |
| 5075 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5076 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5077 | } |
| 5078 | |
| 5079 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5080 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5081 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5082 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5083 | } |
| 5084 | |
| 5085 | tempbx = tempbx & 0x00FF; |
| 5086 | |
| 5087 | if (!(modeflag & HalfDCLK)) { |
| 5088 | tempcx = pVBInfo->VGAHDE; |
| 5089 | if (tempcx >= pVBInfo->HDE) { |
| 5090 | tempbx |= 0x2000; |
| 5091 | tempax &= 0x00FF; |
| 5092 | } |
| 5093 | } |
| 5094 | |
| 5095 | tempcx = 0x0101; |
| 5096 | |
| 5097 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 5098 | if (pVBInfo->VGAHDE >= 1024) { |
| 5099 | tempcx = 0x1920; |
| 5100 | if (pVBInfo->VGAHDE >= 1280) { |
| 5101 | tempcx = 0x1420; |
| 5102 | tempbx = tempbx & 0xDFFF; |
| 5103 | } |
| 5104 | } |
| 5105 | } |
| 5106 | |
| 5107 | if (!(tempbx & 0x2000)) { |
| 5108 | if (modeflag & HalfDCLK) |
| 5109 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 5110 | |
| 5111 | push1 = tempbx; |
| 5112 | tempeax = pVBInfo->VGAHDE; |
| 5113 | tempebx = (tempcx & 0xFF00) >> 8; |
| 5114 | longtemp = tempeax * tempebx; |
| 5115 | tempecx = tempcx & 0x00FF; |
| 5116 | longtemp = longtemp / tempecx; |
| 5117 | |
| 5118 | /* 301b */ |
| 5119 | tempecx = 8 * 1024; |
| 5120 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5121 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5122 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5123 | tempecx = tempecx * 8; |
| 5124 | } |
| 5125 | |
| 5126 | longtemp = longtemp * tempecx; |
| 5127 | tempecx = pVBInfo->HDE; |
| 5128 | temp2 = longtemp % tempecx; |
| 5129 | tempeax = longtemp / tempecx; |
| 5130 | if (temp2 != 0) |
| 5131 | tempeax += 1; |
| 5132 | |
| 5133 | tempax = (unsigned short) tempeax; |
| 5134 | |
| 5135 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5136 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5137 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5138 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 5139 | } |
| 5140 | /* end 301b */ |
| 5141 | |
| 5142 | tempbx = push1; |
| 5143 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 5144 | | (tempbx & 0x00FF)); |
| 5145 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 5146 | | (tempax & 0x00FF)); |
| 5147 | temp = (tempax & 0xFF00) >> 8; |
| 5148 | } else { |
| 5149 | temp = (tempax & 0x00FF) >> 8; |
| 5150 | } |
| 5151 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5152 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5153 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5154 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5155 | temp = tempcx & 0x00FF; |
| 5156 | |
| 5157 | if (tempbx & 0x2000) |
| 5158 | temp = 0; |
| 5159 | |
| 5160 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5161 | temp |= 0x18; |
| 5162 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5163 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5164 | if (pVBInfo->TVInfo & TVSetPAL) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5165 | tempbx = 0x0382; |
| 5166 | tempcx = 0x007e; |
| 5167 | } else { |
| 5168 | tempbx = 0x0369; |
| 5169 | tempcx = 0x0061; |
| 5170 | } |
| 5171 | |
| 5172 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5173 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5174 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5175 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5176 | |
| 5177 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 5178 | temp = temp << 2; |
| 5179 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 5180 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5181 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5182 | temp |= 0x10; |
| 5183 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5184 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5185 | temp |= 0x20; |
| 5186 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5187 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5188 | temp |= 0x60; |
| 5189 | } |
| 5190 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5191 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5192 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5193 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5194 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5195 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5196 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 5197 | TimingPoint = XGI_NTSC1024AdjTime; |
| 5198 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5199 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5200 | TimingPoint[j]); |
| 5201 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5202 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5203 | } |
| 5204 | } |
| 5205 | |
| 5206 | /* [ycchen] 01/14/03 Modify for 301C PALM Support */ |
| 5207 | if (pVBInfo->VBType & VB_XGI301C) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5208 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5209 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5210 | 0x08); /* PALM Mode */ |
| 5211 | } |
| 5212 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5213 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5214 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5215 | 0x01); |
| 5216 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5217 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5218 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5219 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5220 | } |
| 5221 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5222 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5223 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5224 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5225 | } |
| 5226 | |
| 5227 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 5228 | return; |
| 5229 | } |
| 5230 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5231 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5232 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5233 | unsigned short RefreshRateTableIndex, |
| 5234 | struct vb_device_info *pVBInfo) |
| 5235 | { |
| 5236 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
| 5237 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; |
| 5238 | |
| 5239 | struct XGI_LCDDesStruct *LCDBDesPtr = NULL; |
| 5240 | |
| 5241 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5242 | /* si+St_ResInfo */ |
| 5243 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5244 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
| 5245 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5246 | /* si+Ext_ResInfo */ |
| 5247 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5248 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5249 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
| 5250 | Ext_CRT1CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5251 | CRT1Index &= IndexMask; |
| 5252 | } |
| 5253 | |
| 5254 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5255 | return; |
| 5256 | |
| 5257 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 5258 | |
| 5259 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5260 | tempbx = tempbx >> 1; |
| 5261 | |
| 5262 | tempbx -= 1; |
| 5263 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5264 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5265 | temp = (tempbx & 0xFF00) >> 8; |
| 5266 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5267 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5268 | temp = 0x01; |
| 5269 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5270 | if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5271 | if (pVBInfo->ModeType == ModeEGA) { |
| 5272 | if (pVBInfo->VGAHDE >= 1024) { |
| 5273 | temp = 0x02; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5274 | if (pVBInfo->LCDInfo & XGI_LCDVESATiming) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5275 | temp = 0x01; |
| 5276 | } |
| 5277 | } |
| 5278 | } |
| 5279 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5280 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5281 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
| 5282 | push1 = tempbx; |
| 5283 | tempbx--; |
| 5284 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5285 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5286 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5287 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5288 | |
| 5289 | tempcx = pVBInfo->VT - 1; |
| 5290 | push2 = tempcx + 1; |
| 5291 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5292 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5293 | temp = (tempcx & 0xFF00) >> 8; |
| 5294 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5295 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5296 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 5297 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 5298 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 5299 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5300 | |
| 5301 | /* Customized LCDB Des no add */ |
| 5302 | tempbx = 5; |
| 5303 | LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo, |
| 5304 | ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5305 | tempah = pVBInfo->LCDResInfo; |
| 5306 | tempah &= PanelResInfo; |
| 5307 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5308 | if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5309 | tempbx = 1024; |
| 5310 | tempcx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5311 | } else if ((tempah == Panel_1280x1024) || |
| 5312 | (tempah == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5313 | tempbx = 1280; |
| 5314 | tempcx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5315 | } else if (tempah == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5316 | tempbx = 1400; |
| 5317 | tempcx = 1050; |
| 5318 | } else { |
| 5319 | tempbx = 1600; |
| 5320 | tempcx = 1200; |
| 5321 | } |
| 5322 | |
| 5323 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 5324 | tempbx = pVBInfo->HDE; |
| 5325 | tempcx = pVBInfo->VDE; |
| 5326 | } |
| 5327 | |
| 5328 | pushbx = tempbx; |
| 5329 | tempax = pVBInfo->VT; |
| 5330 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 5331 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 5332 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 5333 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 5334 | tempbx = pVBInfo->LCDVDES; |
| 5335 | tempcx += tempbx; |
| 5336 | |
| 5337 | if (tempcx >= tempax) |
| 5338 | tempcx -= tempax; /* lcdvdes */ |
| 5339 | |
| 5340 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5341 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5342 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5343 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5344 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 5345 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 5346 | tempah = tempch; |
| 5347 | tempah = tempah << 3; |
| 5348 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5349 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5350 | |
| 5351 | /* getlcdsync() */ |
| 5352 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 5353 | tempcx = tempbx; |
| 5354 | tempax = pVBInfo->VT; |
| 5355 | tempbx = pVBInfo->LCDVRS; |
| 5356 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5357 | tempcx += tempbx; |
| 5358 | if (tempcx >= tempax) |
| 5359 | tempcx -= tempax; |
| 5360 | |
| 5361 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5362 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5363 | temp = (tempbx & 0xFF00) >> 8; |
| 5364 | temp = temp << 4; |
| 5365 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5366 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5367 | tempcx = pushbx; |
| 5368 | tempax = pVBInfo->HT; |
| 5369 | tempbx = pVBInfo->LCDHDES; |
| 5370 | tempbx &= 0x0FFF; |
| 5371 | |
| 5372 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 5373 | tempax = tempax >> 1; |
| 5374 | tempbx = tempbx >> 1; |
| 5375 | tempcx = tempcx >> 1; |
| 5376 | } |
| 5377 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5378 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5379 | tempbx += 1; |
| 5380 | |
| 5381 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 5382 | tempbx += 1; |
| 5383 | |
| 5384 | tempcx += tempbx; |
| 5385 | |
| 5386 | if (tempcx >= tempax) |
| 5387 | tempcx -= tempax; |
| 5388 | |
| 5389 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5390 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5391 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5392 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5393 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5394 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5395 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5396 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5397 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5398 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 5399 | tempcx = tempax; |
| 5400 | tempax = pVBInfo->HT; |
| 5401 | tempbx = pVBInfo->LCDHRS; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5402 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 5403 | tempax = tempax >> 1; |
| 5404 | tempbx = tempbx >> 1; |
| 5405 | tempcx = tempcx >> 1; |
| 5406 | } |
| 5407 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5408 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5409 | tempbx += 1; |
| 5410 | |
| 5411 | tempcx += tempbx; |
| 5412 | |
| 5413 | if (tempcx >= tempax) |
| 5414 | tempcx -= tempax; |
| 5415 | |
| 5416 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5417 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5418 | |
| 5419 | temp = (tempbx & 0xFF00) >> 8; |
| 5420 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5421 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5422 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5423 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5424 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5425 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5426 | if (pVBInfo->VGAVDE == 525) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5427 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 5428 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5429 | | VB_XGI301C)) { |
| 5430 | temp = 0xC6; |
| 5431 | } else |
| 5432 | temp = 0xC4; |
| 5433 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5434 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 5435 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5436 | } |
| 5437 | |
| 5438 | if (pVBInfo->VGAVDE == 420) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5439 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 5440 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5441 | | VB_XGI301C)) { |
| 5442 | temp = 0x4F; |
| 5443 | } else |
| 5444 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5445 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5446 | } |
| 5447 | } |
| 5448 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5449 | |
| 5450 | /* --------------------------------------------------------------------- */ |
| 5451 | /* Function : XGI_GetTap4Ptr */ |
| 5452 | /* Input : */ |
| 5453 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 5454 | /* Description : */ |
| 5455 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5456 | static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5457 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5458 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5459 | unsigned short tempax, tempbx, i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5460 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5461 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5462 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5463 | if (tempcx == 0) { |
| 5464 | tempax = pVBInfo->VGAHDE; |
| 5465 | tempbx = pVBInfo->HDE; |
| 5466 | } else { |
| 5467 | tempax = pVBInfo->VGAVDE; |
| 5468 | tempbx = pVBInfo->VDE; |
| 5469 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5470 | |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 5471 | if (tempax <= tempbx) |
| 5472 | return &xgifb_tap4_timing[0]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5473 | else |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 5474 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5475 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5476 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5477 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5478 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5479 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 5480 | if ((pVBInfo->TVInfo & TVSetYPbPr525i) || |
| 5481 | (pVBInfo->TVInfo & TVSetYPbPr525p)) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 5482 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5483 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5484 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 5485 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5486 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5487 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 5488 | Tap4TimingPtr = xgifb_tap4_timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5489 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5490 | i = 0; |
| 5491 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 5492 | if (Tap4TimingPtr[i].DE == tempax) |
| 5493 | break; |
| 5494 | i++; |
| 5495 | } |
| 5496 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5497 | } |
| 5498 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5499 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5500 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5501 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5502 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5503 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5504 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5505 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 5506 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5507 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5508 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 5509 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5510 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5511 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5512 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5513 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5514 | /* Set Vertical Scaling */ |
| 5515 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5516 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5517 | xgifb_reg_set(pVBInfo->Part2Port, |
| 5518 | i, |
| 5519 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5520 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5521 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5522 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5523 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5524 | /* Enable V.Scaling */ |
| 5525 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5526 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5527 | /* Enable H.Scaling */ |
| 5528 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5529 | } |
| 5530 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5531 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5532 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5533 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5534 | unsigned short i; |
| 5535 | unsigned char *tempdi; |
| 5536 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5537 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5538 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5539 | /* si+St_ResInfo */ |
| 5540 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5541 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5542 | /* si+Ext_ResInfo */ |
| 5543 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5544 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5545 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5546 | if (pVBInfo->TVInfo & TVSetPAL) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5547 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 5548 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5549 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5550 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 5551 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5552 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5553 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5554 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 5555 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5556 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5557 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5558 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 5559 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 5560 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5561 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5562 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5563 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo |
| 5564 | & SetCRT2ToYPbPr525750)) { |
| 5565 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5566 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5567 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5568 | tempdi = pVBInfo->HiTVGroup3Data; |
| 5569 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 5570 | tempdi = pVBInfo->HiTVGroup3Simu; |
| 5571 | if (!(modeflag & Charx8Dot)) |
| 5572 | tempdi = pVBInfo->HiTVGroup3Text; |
| 5573 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5574 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5575 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5576 | tempdi = pVBInfo->Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5577 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5578 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5579 | tempdi = pVBInfo->Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5580 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5581 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5582 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5583 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5584 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5585 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5586 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5587 | } |
| 5588 | } |
| 5589 | return; |
| 5590 | } /* {end of XGI_SetGroup3} */ |
| 5591 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5592 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5593 | unsigned short RefreshRateTableIndex, |
| 5594 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5595 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5596 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5597 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5598 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5599 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5600 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5601 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5602 | /* si+St_ResInfo */ |
| 5603 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5604 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5605 | /* si+Ext_ResInfo */ |
| 5606 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5607 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5608 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5609 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5610 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5611 | tempbx = pVBInfo->RVBHCMAX; |
| 5612 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5613 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5614 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 5615 | tempcx = pVBInfo->VGAHT - 1; |
| 5616 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5617 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5618 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5619 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 5620 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5621 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5622 | tempcx = pVBInfo->VGAVT - 1; |
| 5623 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 5624 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5625 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5626 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5627 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5628 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5629 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5630 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5631 | tempcx = pVBInfo->VBInfo; |
| 5632 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5633 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5634 | if (modeflag & HalfDCLK) |
| 5635 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5636 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5637 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5638 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5639 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5640 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5641 | temp = 0; |
| 5642 | if (tempbx <= 1024) |
| 5643 | temp = 0xA0; |
| 5644 | if (tempbx == 1280) |
| 5645 | temp = 0xC0; |
| 5646 | } else if (tempcx & SetCRT2ToTV) { |
| 5647 | temp = 0xA0; |
| 5648 | if (tempbx <= 800) |
| 5649 | temp = 0x80; |
| 5650 | } else { |
| 5651 | temp = 0x80; |
| 5652 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 5653 | temp = 0; |
| 5654 | if (tempbx > 800) |
| 5655 | temp = 0x60; |
| 5656 | } |
| 5657 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5658 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5659 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5660 | temp = 0x00; |
| 5661 | if (pVBInfo->VGAHDE == 1280) |
| 5662 | temp = 0x40; |
| 5663 | if (pVBInfo->VGAHDE == 1024) |
| 5664 | temp = 0x20; |
| 5665 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5666 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5667 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5668 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5669 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5670 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5671 | if (!(temp & 0xE000)) |
| 5672 | tempbx = tempbx >> 1; |
| 5673 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5674 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5675 | tempcx = pVBInfo->RVBHRS; |
| 5676 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5677 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5678 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5679 | tempeax = pVBInfo->VGAVDE; |
| 5680 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5681 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5682 | if (tempeax <= tempebx) { |
| 5683 | tempcx = (tempcx & (~0x4000)); |
| 5684 | tempeax = pVBInfo->VGAVDE; |
| 5685 | } else { |
| 5686 | tempeax -= tempebx; |
| 5687 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5688 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5689 | templong = (tempeax * 256 * 1024) % tempebx; |
| 5690 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 5691 | tempebx = tempeax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5692 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5693 | if (templong != 0) |
| 5694 | tempebx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5695 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5696 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5697 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5698 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5699 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5700 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5701 | tempbx = (unsigned short) (tempebx >> 16); |
| 5702 | temp = tempbx & 0x00FF; |
| 5703 | temp = temp << 4; |
| 5704 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5705 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5706 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5707 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5708 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5709 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5710 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5711 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5712 | tempax = pVBInfo->VGAHDE; |
| 5713 | if (modeflag & HalfDCLK) |
| 5714 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5715 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5716 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5717 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5718 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5719 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 5720 | if (tempax > 800) |
| 5721 | tempax -= 800; |
| 5722 | } else { |
| 5723 | if (pVBInfo->VGAHDE > 800) { |
| 5724 | if (pVBInfo->VGAHDE == 1024) |
| 5725 | tempax = (tempax * 25 / 32) - 1; |
| 5726 | else |
| 5727 | tempax = (tempax * 20 / 32) - 1; |
| 5728 | } |
| 5729 | } |
| 5730 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5731 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5732 | temp = (tempax & 0xFF00) >> 8; |
| 5733 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5734 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5735 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5736 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5737 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5738 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5739 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5740 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5741 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5742 | } |
| 5743 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5744 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5745 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 5746 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5747 | | TVSetYPbPr525p | TVSetYPbPr750p |
| 5748 | | TVSetHiVision))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5749 | temp |= 0x0001; |
| 5750 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 5751 | && (!(pVBInfo->TVInfo |
| 5752 | & TVSimuMode))) |
| 5753 | temp &= (~0x0001); |
| 5754 | } |
| 5755 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5756 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5757 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5758 | tempbx = pVBInfo->HT; |
| 5759 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 5760 | tempbx = tempbx >> 1; |
| 5761 | tempbx = (tempbx >> 1) - 2; |
| 5762 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5763 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5764 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5765 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5766 | } |
| 5767 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5768 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5769 | if (pVBInfo->ISXPDOS == 0) |
| 5770 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5771 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5772 | } |
| 5773 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5774 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 5775 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5776 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5777 | } |
| 5778 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5779 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5780 | struct vb_device_info *pVBInfo) |
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 short Pindex, Pdata; |
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 | Pindex = pVBInfo->Part5Port; |
| 5785 | Pdata = pVBInfo->Part5Port + 1; |
| 5786 | if (pVBInfo->ModeType == ModeVGA) { |
| 5787 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5788 | | DisableCRT2Display))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5789 | XGINew_EnableCRT2(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5790 | } |
| 5791 | } |
| 5792 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5793 | } |
| 5794 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5795 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5796 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5797 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5798 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5799 | } |
| 5800 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5801 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5802 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5803 | { |
| 5804 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5805 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5806 | } |
| 5807 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5808 | static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, |
| 5809 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5810 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5811 | { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5812 | unsigned short xres, yres, colordepth, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5813 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5814 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5815 | if (ModeNo <= 0x13) { |
| 5816 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 5817 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5818 | /* si+St_ResInfo */ |
| 5819 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5820 | } else { |
| 5821 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 5822 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5823 | /* si+St_ModeFlag */ |
| 5824 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5825 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5826 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5827 | if (!(modeflag & Charx8Dot)) { |
| 5828 | xres /= 9; |
| 5829 | xres *= 8; |
| 5830 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5831 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5832 | if (ModeNo > 0x13) { |
| 5833 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 5834 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5835 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5836 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 5837 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5838 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5839 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5840 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5841 | if (xres > xgifb_info->lvds_data.LVDSHDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5842 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 5843 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5844 | if (yres > xgifb_info->lvds_data.LVDSVDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5845 | return 0; |
| 5846 | |
| 5847 | if (ModeNo > 0x13) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5848 | if (xres != xgifb_info->lvds_data.LVDSHDE || |
| 5849 | yres != xgifb_info->lvds_data.LVDSVDE) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5850 | colordepth = XGI_GetColorDepth(ModeNo, |
| 5851 | ModeIdIndex, |
| 5852 | pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5853 | if (colordepth > 2) |
| 5854 | return 0; |
| 5855 | |
| 5856 | } |
| 5857 | } |
| 5858 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5859 | } |
| 5860 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5861 | static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, |
| 5862 | int chip_id, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5863 | unsigned short ModeNo, |
| 5864 | unsigned short ModeIdIndex, |
| 5865 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5866 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5867 | unsigned char temp, Miscdata; |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5868 | unsigned short xres, yres, modeflag, resindex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5869 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 5870 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 5871 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5872 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5873 | temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5874 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5875 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5876 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5877 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5878 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5879 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5880 | temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5881 | /* SR35[7] FP VSync polarity */ |
| 5882 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 5883 | /* SR30[5] FP HSync polarity */ |
| 5884 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5885 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5886 | if (chip_id == XG27) |
| 5887 | XGI_SetXG27FPBits(pVBInfo); |
| 5888 | else |
| 5889 | XGI_SetXG21FPBits(pVBInfo); |
| 5890 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5891 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5892 | if (ModeNo <= 0x13) { |
| 5893 | xres = pVBInfo->StResInfo[resindex].HTotal; |
| 5894 | yres = pVBInfo->StResInfo[resindex].VTotal; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5895 | /* si+St_ResInfo */ |
| 5896 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5897 | } else { |
| 5898 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 5899 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5900 | /* si+St_ModeFlag */ |
| 5901 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5902 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5903 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5904 | if (!(modeflag & Charx8Dot)) |
| 5905 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5906 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5907 | LVDSHT = xgifb_info->lvds_data.LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5908 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5909 | LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5910 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) |
| 5911 | LVDSHBS -= xres / 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5912 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5913 | if (LVDSHBS > LVDSHT) |
| 5914 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5915 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5916 | LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5917 | if (LVDSHRS > LVDSHT) |
| 5918 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5919 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5920 | LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5921 | if (LVDSHRE > LVDSHT) |
| 5922 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5923 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5924 | LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5925 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5926 | LVDSVT = xgifb_info->lvds_data.LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5927 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5928 | LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5929 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 5930 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5931 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5932 | if (LVDSVBS > LVDSVT) |
| 5933 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5934 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5935 | LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5936 | if (LVDSVRS > LVDSVT) |
| 5937 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5938 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5939 | LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5940 | if (LVDSVRE > LVDSVT) |
| 5941 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5942 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5943 | LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5944 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5945 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5946 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5947 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5948 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5949 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
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 | /* HT SR0B[1:0] CR00 */ |
| 5952 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5953 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5954 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5955 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5956 | /* HBS SR0B[5:4] CR02 */ |
| 5957 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5958 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5959 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5960 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5961 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 5962 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5963 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 5964 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 5965 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5966 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5967 | /* HRS SR0B[7:6] CR04 */ |
| 5968 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5969 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5970 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5971 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5972 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 5973 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5974 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5975 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5976 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5977 | /* HRE SR0C[2] CR05[4:0] */ |
| 5978 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5979 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 5980 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
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 | /* Panel HRE SR2F[7:2] */ |
| 5983 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5984 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5985 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5986 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 5987 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5988 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 5989 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 5990 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5991 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5992 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5993 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 5994 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5995 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 5996 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 5997 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5998 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5999 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6000 | /* VBE SR0A[4] CR16 */ |
| 6001 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6002 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6003 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6004 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6005 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 6006 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6007 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 6008 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 6009 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6010 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6011 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 6012 | if (chip_id == XG27) { |
| 6013 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
| 6014 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, |
| 6015 | (value & 0x700) >> 8); |
| 6016 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
| 6017 | } else { |
| 6018 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
| 6019 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, |
| 6020 | (value & 0x600) >> 9); |
| 6021 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
| 6022 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
| 6023 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6024 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6025 | /* VRE SR0A[5] CR11[3:0] */ |
| 6026 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6027 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 6028 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6029 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6030 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 6031 | if (chip_id == XG27) |
| 6032 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 6033 | (value << 2) & 0xFC); |
| 6034 | else |
| 6035 | /* SR3F[7] has to be 0, h/w bug */ |
| 6036 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 6037 | (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6038 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6039 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6040 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6041 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6042 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6043 | 0x2B, xgifb_info->lvds_data.VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6044 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6045 | 0x2C, xgifb_info->lvds_data.VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6046 | value += 0x10; |
| 6047 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6048 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6049 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6050 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6051 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6052 | /* set data, panning = 0, shift left 1 dot*/ |
| 6053 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6054 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6055 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 6056 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6057 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 6058 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6059 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6060 | |
| 6061 | } |
| 6062 | |
| 6063 | /* --------------------------------------------------------------------- */ |
| 6064 | /* Function : XGI_IsLCDON */ |
| 6065 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6066 | /* Output : 0 : Skip PSC Control */ |
| 6067 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6068 | /* Description : */ |
| 6069 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6070 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6071 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6072 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6073 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6074 | tempax = pVBInfo->VBInfo; |
| 6075 | if (tempax & SetCRT2ToDualEdge) |
| 6076 | return 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6077 | else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6078 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6079 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6080 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6081 | } |
| 6082 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6083 | /* --------------------------------------------------------------------- */ |
| 6084 | /* Function : XGI_DisableChISLCD */ |
| 6085 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6086 | /* Output : 0 -> Not LCD Mode */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6087 | /* Description : */ |
| 6088 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6089 | static unsigned char XGI_DisableChISLCD(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 tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6092 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6093 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6094 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6095 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6096 | if (tempbx & (EnableChA | DisableChA)) { |
| 6097 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 6098 | return 0; |
| 6099 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6100 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6101 | if (!(tempbx & (EnableChB | DisableChB))) |
| 6102 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6103 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6104 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 6105 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6106 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6107 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6108 | } |
| 6109 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6110 | /* --------------------------------------------------------------------- */ |
| 6111 | /* Function : XGI_EnableChISLCD */ |
| 6112 | /* Input : */ |
| 6113 | /* Output : 0 -> Not LCD mode */ |
| 6114 | /* Description : */ |
| 6115 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6116 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6117 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6118 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6119 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6120 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6121 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6122 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6123 | if (tempbx & (EnableChA | DisableChA)) { |
| 6124 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 6125 | return 0; |
| 6126 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6127 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6128 | if (!(tempbx & (EnableChB | DisableChB))) |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 6129 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6130 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6131 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 6132 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6133 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6134 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6135 | } |
| 6136 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6137 | static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, |
| 6138 | struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6139 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6140 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 6141 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6142 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6143 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6144 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6145 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6146 | if (!(pVBInfo->VBInfo & |
| 6147 | (DisableCRT2Display | SetSimuScanMode))) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6148 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6149 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 6150 | tempah = 0x7F; /* Disable Channel A */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6151 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6152 | /* Disable Channel B */ |
| 6153 | tempah = 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6154 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6155 | if (pVBInfo->SetFlag & DisableChB) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6156 | /* force to disable Cahnnel */ |
| 6157 | tempah &= 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6158 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6159 | if (pVBInfo->SetFlag & DisableChA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6160 | /* Force to disable Channel B */ |
| 6161 | tempah &= 0x7F; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6162 | } |
| 6163 | } |
| 6164 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6165 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6166 | /* disable part4_1f */ |
| 6167 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6168 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6169 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6170 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6171 | || (XGI_DisableChISLCD(pVBInfo)) |
| 6172 | || (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6173 | /* LVDS Driver power down */ |
| 6174 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6175 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6176 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6177 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6178 | & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6179 | | SetSimuScanMode))) { |
| 6180 | if (pVBInfo->SetFlag & GatingCRT) |
| 6181 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6182 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6183 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6184 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6185 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6186 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6187 | & XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6188 | /* Power down */ |
| 6189 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6190 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6191 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6192 | /* disable TV as primary VGA swap */ |
| 6193 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6194 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6195 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 6196 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6197 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6198 | if ((pVBInfo->SetFlag & DisableChB) || |
| 6199 | (pVBInfo->VBInfo & |
| 6200 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6201 | ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6202 | (pVBInfo->VBInfo & |
| 6203 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6204 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6205 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6206 | if ((pVBInfo->SetFlag & DisableChB) || |
| 6207 | (pVBInfo->VBInfo & |
| 6208 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6209 | (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) || |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6210 | (pVBInfo->VBInfo & |
| 6211 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 6212 | /* save Part1 index 0 */ |
| 6213 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 6214 | /* BTDAC = 1, avoid VB reset */ |
| 6215 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 6216 | /* disable CRT2 */ |
| 6217 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 6218 | /* restore Part1 index 0 */ |
| 6219 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6220 | } |
| 6221 | } else { /* {301} */ |
| 6222 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6223 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 6224 | /* Disable CRT2 */ |
| 6225 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 6226 | /* Disable TV asPrimary VGA swap */ |
| 6227 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6228 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6229 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6230 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6231 | | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6232 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6233 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6234 | } |
| 6235 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6236 | /* --------------------------------------------------------------------- */ |
| 6237 | /* Function : XGI_GetTVPtrIndex */ |
| 6238 | /* Input : */ |
| 6239 | /* Output : */ |
| 6240 | /* Description : bx 0 : ExtNTSC */ |
| 6241 | /* 1 : StNTSC */ |
| 6242 | /* 2 : ExtPAL */ |
| 6243 | /* 3 : StPAL */ |
| 6244 | /* 4 : ExtHiTV */ |
| 6245 | /* 5 : StHiTV */ |
| 6246 | /* 6 : Ext525i */ |
| 6247 | /* 7 : St525i */ |
| 6248 | /* 8 : Ext525p */ |
| 6249 | /* 9 : St525p */ |
| 6250 | /* A : Ext750p */ |
| 6251 | /* B : St750p */ |
| 6252 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6253 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6254 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6255 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6256 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6257 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6258 | tempbx = 2; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6259 | if (pVBInfo->TVInfo & TVSetHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6260 | tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6261 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6262 | tempbx = 6; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6263 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6264 | tempbx = 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6265 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6266 | tempbx = 10; |
| 6267 | if (pVBInfo->TVInfo & TVSimuMode) |
| 6268 | tempbx++; |
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 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6271 | } |
| 6272 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6273 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6274 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6275 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6276 | /* Output : bx 0 : NTSC */ |
| 6277 | /* 1 : PAL */ |
| 6278 | /* 2 : PALM */ |
| 6279 | /* 3 : PALN */ |
| 6280 | /* 4 : NTSC1024x768 */ |
| 6281 | /* 5 : PAL-M 1024x768 */ |
| 6282 | /* 6-7: reserved */ |
| 6283 | /* cl 0 : YFilter1 */ |
| 6284 | /* 1 : YFilter2 */ |
| 6285 | /* ch 0 : 301A */ |
| 6286 | /* 1 : 301B/302B/301LV/302LV */ |
| 6287 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6288 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6289 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 6290 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6291 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6292 | *tempbx = 0; |
| 6293 | *tempcl = 0; |
| 6294 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6295 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6296 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6297 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6298 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6299 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6300 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6301 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6302 | if (pVBInfo->TVInfo & TVSetPALN) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6303 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6304 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6305 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 6306 | *tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6307 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6308 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6309 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6310 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6311 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6312 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6313 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 6314 | & TVSimuMode)) { |
| 6315 | *tempbx += 8; |
| 6316 | *tempcl += 1; |
| 6317 | } |
| 6318 | } |
| 6319 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6320 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6321 | | VB_SIS302LV | VB_XGI301C)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6322 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6323 | } |
| 6324 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6325 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6326 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6327 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6328 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6329 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6330 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6331 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6332 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6333 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6334 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
| 6335 | tempbl = 0; |
| 6336 | tempbh = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6337 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6338 | index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */ |
| 6339 | tempbl = pVBInfo->XGI_TVDelayList[index]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6340 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6341 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 6342 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6343 | | VB_XGI301C)) |
| 6344 | tempbl = pVBInfo->XGI_TVDelayList2[index]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6345 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6346 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 6347 | tempbl = tempbl >> 4; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6348 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6349 | /* Get LCD Delay */ |
| 6350 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 6351 | tempbh = pVBInfo->LCDCapList[index]. |
| 6352 | LCD_DelayCompensation; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6353 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6354 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6355 | tempbl = tempbh; |
| 6356 | } |
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 | tempbl &= 0x0F; |
| 6359 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6360 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6361 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6362 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 6363 | | SetCRT2ToTV)) { /* Channel B */ |
| 6364 | tempah &= 0xF0; |
| 6365 | tempah |= tempbl; |
| 6366 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6367 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6368 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { /* Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6369 | tempah &= 0x0F; |
| 6370 | tempah |= tempbh; |
| 6371 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6372 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6373 | } |
| 6374 | } else if (pVBInfo->IF_DEF_LVDS == 1) { |
| 6375 | tempbl = 0; |
| 6376 | tempbh = 0; |
| 6377 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6378 | /* / Get LCD Delay */ |
| 6379 | tempah = pVBInfo->LCDCapList[ |
| 6380 | XGI_GetLCDCapPtr(pVBInfo)]. |
| 6381 | LCD_DelayCompensation; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6382 | tempah &= 0x0f; |
| 6383 | tempah = tempah << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6384 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6385 | tempah); |
| 6386 | } |
| 6387 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6388 | } |
| 6389 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6390 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 6391 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6392 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6393 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6394 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6395 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
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 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6398 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6399 | /* Enable Dither */ |
| 6400 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6401 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6402 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6403 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6404 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6405 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6406 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6407 | } |
| 6408 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6409 | /* --------------------------------------------------------------------- */ |
| 6410 | /* Function : XGI_SetLCDCap_B */ |
| 6411 | /* Input : cx -> LCD Capability */ |
| 6412 | /* Output : */ |
| 6413 | /* Description : */ |
| 6414 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6415 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 6416 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6417 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6418 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6419 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6420 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 6421 | | 0x0c)); |
| 6422 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6423 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6424 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 6425 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6426 | } |
| 6427 | |
Aaro Koskinen | 7f04ec3 | 2011-11-27 23:03:05 +0200 | [diff] [blame] | 6428 | static void XGI_LongWait(struct vb_device_info *pVBInfo) |
| 6429 | { |
| 6430 | unsigned short i; |
| 6431 | |
| 6432 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
| 6433 | |
| 6434 | if (!(i & 0xC0)) { |
| 6435 | for (i = 0; i < 0xFFFF; i++) { |
| 6436 | if (!(inb(pVBInfo->P3da) & 0x08)) |
| 6437 | break; |
| 6438 | } |
| 6439 | |
| 6440 | for (i = 0; i < 0xFFFF; i++) { |
| 6441 | if ((inb(pVBInfo->P3da) & 0x08)) |
| 6442 | break; |
| 6443 | } |
| 6444 | } |
| 6445 | } |
| 6446 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6447 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6448 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6449 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6450 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6451 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6452 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6453 | /* disable down spectrum D[4] */ |
| 6454 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6455 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6456 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6457 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6458 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6459 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6460 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6461 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6462 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6463 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6464 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6465 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6466 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 6467 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6468 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6469 | } |
| 6470 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6471 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 6472 | { |
| 6473 | unsigned short tempcx; |
| 6474 | |
| 6475 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 6476 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6477 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6478 | (VB_SIS301B | |
| 6479 | VB_SIS302B | |
| 6480 | VB_SIS301LV | |
| 6481 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6482 | VB_XGI301C)) { /* 301LV/302LV only */ |
| 6483 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6484 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6485 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6486 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6487 | (unsigned char) (tempcx & 0x1F)); |
| 6488 | } |
| 6489 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6490 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6491 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 6492 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 6493 | | EnablePLLSPLOW)) >> 8)); |
| 6494 | } |
| 6495 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6496 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6497 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6498 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 6499 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6500 | else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6501 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 6502 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6503 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6504 | if (tempcx & EnableSpectrum) |
| 6505 | SetSpectrum(pVBInfo); |
| 6506 | } |
| 6507 | } else { |
| 6508 | /* LVDS,CH7017 */ |
| 6509 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 6510 | } |
| 6511 | } |
| 6512 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6513 | /* --------------------------------------------------------------------- */ |
| 6514 | /* Function : XGI_SetAntiFlicker */ |
| 6515 | /* Input : */ |
| 6516 | /* Output : */ |
| 6517 | /* Description : Set TV Customized Param. */ |
| 6518 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6519 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
| 6520 | unsigned short ModeIdIndex, |
| 6521 | struct vb_device_info *pVBInfo) |
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 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6524 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6525 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6526 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 6527 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6528 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6529 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6530 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 6531 | tempbx &= 0xFE; |
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 (ModeNo <= 0x13) |
| 6534 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; |
| 6535 | else |
| 6536 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6537 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6538 | tempbx += index; |
| 6539 | tempah = TVAntiFlickList[tempbx]; |
| 6540 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6541 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6542 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6543 | } |
| 6544 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6545 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
| 6546 | unsigned short ModeIdIndex, |
| 6547 | struct vb_device_info *pVBInfo) |
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 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6550 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6551 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6552 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6553 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 6554 | tempbx &= 0xFE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6555 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6556 | if (ModeNo <= 0x13) |
| 6557 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; |
| 6558 | else |
| 6559 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6560 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6561 | tempbx += index; |
| 6562 | tempah = TVEdgeList[tempbx]; |
| 6563 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6564 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6565 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6566 | } |
| 6567 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6568 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6569 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6570 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6571 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6572 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6573 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6574 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6575 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6576 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 6577 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6578 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6579 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6580 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6581 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6582 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6583 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6584 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6585 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6586 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6587 | } |
| 6588 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6589 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6590 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6591 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6592 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6593 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6594 | unsigned char tempcl, tempch, tempal, *filterPtr; |
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 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6597 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6598 | switch (tempbx) { |
| 6599 | case 0x00: |
| 6600 | case 0x04: |
| 6601 | filterPtr = NTSCYFilter1; |
| 6602 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6603 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6604 | case 0x01: |
| 6605 | filterPtr = PALYFilter1; |
| 6606 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6607 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6608 | case 0x02: |
| 6609 | case 0x05: |
| 6610 | case 0x0D: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6611 | case 0x03: |
Aaro Koskinen | 2555e94 | 2011-08-31 21:46:06 +0300 | [diff] [blame] | 6612 | filterPtr = xgifb_palmn_yfilter1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6613 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6614 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6615 | case 0x08: |
| 6616 | case 0x0C: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6617 | case 0x0A: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6618 | case 0x0B: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6619 | case 0x09: |
Aaro Koskinen | 80f86f8 | 2011-08-31 21:46:05 +0300 | [diff] [blame] | 6620 | filterPtr = xgifb_yfilter2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6621 | break; |
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 | default: |
| 6624 | return; |
| 6625 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6626 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6627 | if (ModeNo <= 0x13) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6628 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
| 6629 | VB_StTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6630 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6631 | tempal = pVBInfo->EModeIDTable[ModeIdIndex]. |
| 6632 | VB_ExtTVYFilterIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6633 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6634 | if (tempcl == 0) |
| 6635 | index = tempal * 4; |
| 6636 | else |
| 6637 | index = tempal * 7; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6638 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6639 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6640 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 6641 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 6642 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 6643 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6644 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6645 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 6646 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 6647 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 6648 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6649 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6650 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6651 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6652 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6653 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 6654 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 6655 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6656 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6657 | } |
| 6658 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6659 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6660 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6661 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6662 | /* Output : */ |
| 6663 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6664 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6665 | static void XGI_OEM310Setting(unsigned short ModeNo, |
| 6666 | unsigned short ModeIdIndex, |
| 6667 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6668 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6669 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6670 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6671 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6672 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6673 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6674 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6675 | XGI_SetPhaseIncr(pVBInfo); |
| 6676 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); |
| 6677 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6678 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6679 | if (pVBInfo->VBType & VB_SIS301) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6680 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6681 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6682 | } |
| 6683 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6684 | /* --------------------------------------------------------------------- */ |
| 6685 | /* Function : XGI_SetCRT2ModeRegs */ |
| 6686 | /* Input : */ |
| 6687 | /* Output : */ |
| 6688 | /* Description : Origin code for crt2group */ |
| 6689 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 6690 | static void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6691 | struct xgi_hw_device_info *HwDeviceExtension, |
| 6692 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6693 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6694 | unsigned short tempbl; |
| 6695 | short tempcl; |
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 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6698 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6699 | tempah = 0; |
| 6700 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6701 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6702 | tempah &= ~0x10; /* BTRAMDAC */ |
| 6703 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6704 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6705 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 6706 | | SetCRT2ToLCD)) { |
| 6707 | tempah = 0x40; /* BTDRAM */ |
| 6708 | if (ModeNo > 0x13) { |
| 6709 | tempcl = pVBInfo->ModeType; |
| 6710 | tempcl -= ModeVGA; |
| 6711 | if (tempcl >= 0) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6712 | /* BT Color */ |
| 6713 | tempah = (0x008 >> tempcl); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6714 | if (tempah == 0) |
| 6715 | tempah = 1; |
| 6716 | tempah |= 0x040; |
| 6717 | } |
| 6718 | } |
| 6719 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 6720 | tempah ^= 0x50; /* BTDAC */ |
| 6721 | } |
| 6722 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6723 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6724 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6725 | tempah = 0x08; |
| 6726 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6727 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6728 | if (pVBInfo->VBInfo & DisableCRT2Display) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6729 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6730 | } else { |
| 6731 | tempah = 0x00; |
| 6732 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6733 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6734 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6735 | | SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
| 6736 | if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6737 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6738 | tempbl &= 0xf7; |
| 6739 | tempah |= 0x01; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6740 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6741 | tempbl, tempah); |
| 6742 | } else { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6743 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6744 | tempbl &= 0xf7; |
| 6745 | tempah |= 0x01; |
| 6746 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6747 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6748 | if (pVBInfo->VBInfo & |
| 6749 | (SetCRT2ToRAMDAC | |
| 6750 | SetCRT2ToTV | |
| 6751 | SetCRT2ToLCD)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6752 | tempbl &= 0xf8; |
| 6753 | tempah = 0x01; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6754 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6755 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 6756 | tempah |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6757 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6758 | if (!(pVBInfo->VBInfo & |
| 6759 | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6760 | tempah = tempah ^ 0x05; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6761 | if (!(pVBInfo->VBInfo & |
| 6762 | SetCRT2ToLCD)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6763 | tempah = tempah ^ 0x01; |
| 6764 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6765 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6766 | if (!(pVBInfo->VBInfo & |
| 6767 | SetCRT2ToDualEdge)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6768 | tempah |= 0x08; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6769 | xgifb_reg_and_or(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6770 | 0x2e, tempbl, tempah); |
| 6771 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6772 | xgifb_reg_and_or(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6773 | 0x2e, tempbl, tempah); |
| 6774 | } |
| 6775 | } |
| 6776 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6777 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6778 | tempah); |
| 6779 | } |
| 6780 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6781 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6782 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6783 | | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6784 | tempah &= (~0x08); |
| 6785 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 6786 | & SetInSlaveMode))) { |
| 6787 | tempah |= 0x010; |
| 6788 | } |
| 6789 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6790 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6791 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6792 | tempah |= 0x020; |
| 6793 | if (ModeNo > 0x13) { |
| 6794 | if (pVBInfo->VBInfo & DriverMode) |
| 6795 | tempah = tempah ^ 0x20; |
| 6796 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6797 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6798 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6799 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6800 | tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6801 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6802 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 6803 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6804 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6805 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6806 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 6807 | tempah |= 0x40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6808 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6809 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 6810 | if ((pVBInfo->LCDResInfo == Panel_1280x1024) |
| 6811 | || (pVBInfo->LCDResInfo == Panel_1280x1024x75)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6812 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6813 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 6814 | if (pVBInfo->LCDResInfo == Panel_1280x960) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6815 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6816 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6817 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6818 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6819 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6820 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 6821 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6822 | tempah = 0; |
| 6823 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6824 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6825 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 6826 | tempbl = 0xff; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6827 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6828 | tempah |= 0x04; /* shampoo 0129 */ |
| 6829 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6830 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6831 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6832 | tempah = 0x00; |
| 6833 | tempbl = 0xcf; |
| 6834 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 6835 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 6836 | tempah |= 0x30; |
| 6837 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6838 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6839 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6840 | tempah = 0; |
| 6841 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6842 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6843 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 6844 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 6845 | tempah |= 0xc0; |
| 6846 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6847 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6848 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6849 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6850 | tempah = 0; |
| 6851 | tempbl = 0x7f; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6852 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6853 | tempbl = 0xff; |
| 6854 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 6855 | tempah |= 0x80; |
| 6856 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6857 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6858 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6859 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6860 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6861 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 6862 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 6863 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6864 | } |
| 6865 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6866 | } |
| 6867 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 6868 | static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6869 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6870 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6871 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6872 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6873 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6874 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6875 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6876 | tempbx = 0x08A0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6877 | |
| 6878 | } |
| 6879 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6880 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 6881 | struct vb_device_info *pVBInfo) |
| 6882 | { |
| 6883 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6884 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6885 | |
| 6886 | } |
| 6887 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6888 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 6889 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6890 | { |
| 6891 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 6892 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6893 | |
| 6894 | } |
| 6895 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 6896 | unsigned char XGI_BridgeIsOn(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 flag; |
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 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 6901 | return 1; |
| 6902 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6903 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 6904 | if ((flag == 1) || (flag == 2)) |
| 6905 | return 1; /* 301b */ |
| 6906 | else |
| 6907 | return 0; |
| 6908 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6909 | } |
| 6910 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6911 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 6912 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 6913 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6914 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6915 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, |
| 6916 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, |
| 6917 | 0x01, 0x01 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6918 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6919 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6920 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6921 | if (ModeNo <= 0x13) |
| 6922 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
| 6923 | else |
| 6924 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 6925 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6926 | if (ModeNo < 0x14) |
| 6927 | return 0xFFFF; |
| 6928 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 6929 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6930 | index = index >> pVBInfo->SelectCRT2Rate; |
| 6931 | index &= 0x0F; |
| 6932 | |
| 6933 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 6934 | index = 0; |
| 6935 | |
| 6936 | if (index > 0) |
| 6937 | index--; |
| 6938 | |
| 6939 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6940 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6941 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6942 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 6943 | | VB_SIS301LV | VB_SIS302LV |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6944 | | VB_XGI301C)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6945 | /* 301b */ |
| 6946 | temp = LCDARefreshIndex[ |
| 6947 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6948 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6949 | temp = LCDRefreshIndex[ |
| 6950 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6951 | |
| 6952 | if (index > temp) |
| 6953 | index = temp; |
| 6954 | } else { |
| 6955 | index = 0; |
| 6956 | } |
| 6957 | } |
| 6958 | } |
| 6959 | |
| 6960 | RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex; |
| 6961 | ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID; |
| 6962 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6963 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 6964 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6965 | index++; |
| 6966 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6967 | /* Alan 10/19/2007; |
| 6968 | * do the similar adjustment like XGISearchCRT1Rate() */ |
| 6969 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 6970 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6971 | index++; |
| 6972 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6973 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 6974 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6975 | index++; |
| 6976 | } |
| 6977 | } |
| 6978 | |
| 6979 | i = 0; |
| 6980 | do { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6981 | if (pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 6982 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6983 | break; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6984 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
| 6985 | Ext_InfoFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6986 | temp &= ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6987 | if (temp < pVBInfo->ModeType) |
| 6988 | break; |
| 6989 | i++; |
| 6990 | index--; |
| 6991 | |
| 6992 | } while (index != 0xFFFF); |
| 6993 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 6994 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6995 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1]. |
| 6996 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6997 | if (temp & InterlaceMode) |
| 6998 | i++; |
| 6999 | } |
| 7000 | } |
| 7001 | i--; |
| 7002 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
| 7003 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, |
| 7004 | RefreshRateTableIndex, &i, pVBInfo); |
| 7005 | } |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 7006 | return RefreshRateTableIndex + i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7007 | } |
| 7008 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7009 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 7010 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7011 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7012 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7013 | unsigned short RefreshRateTableIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7014 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7015 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7016 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7017 | ModeIdIndex, pVBInfo); |
| 7018 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7019 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7020 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7021 | HwDeviceExtension, pVBInfo); |
| 7022 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7023 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 7024 | } |
| 7025 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 7026 | static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7027 | struct xgi_hw_device_info *HwDeviceExtension, |
| 7028 | struct vb_device_info *pVBInfo) |
| 7029 | { |
| 7030 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
| 7031 | |
| 7032 | tempbx = pVBInfo->VBInfo; |
| 7033 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7034 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 7035 | pVBInfo->SelectCRT2Rate = 4; |
| 7036 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7037 | ModeIdIndex, pVBInfo); |
| 7038 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
| 7039 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7040 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7041 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7042 | RefreshRateTableIndex, pVBInfo); |
| 7043 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7044 | RefreshRateTableIndex, pVBInfo); |
| 7045 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7046 | RefreshRateTableIndex, pVBInfo); |
| 7047 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7048 | HwDeviceExtension, pVBInfo); |
| 7049 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7050 | RefreshRateTableIndex, pVBInfo); |
| 7051 | XGI_SetTap4Regs(pVBInfo); |
| 7052 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); |
| 7053 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7054 | HwDeviceExtension, pVBInfo); |
| 7055 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 7056 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); |
| 7057 | XGI_AutoThreshold(pVBInfo); |
| 7058 | return 1; |
| 7059 | } |
| 7060 | |
| 7061 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 7062 | { |
| 7063 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 7064 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 7065 | 0x05, 0x00 }; |
| 7066 | |
| 7067 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 7068 | |
| 7069 | unsigned char CR17, CR63, SR31; |
| 7070 | unsigned short temp; |
| 7071 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; |
| 7072 | |
| 7073 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7074 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7075 | |
| 7076 | /* [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] | 7077 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7078 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7079 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 7080 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7081 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 7082 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 7083 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7084 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7085 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 7086 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7087 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7088 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7089 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7090 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7091 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7092 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7093 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7094 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7095 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7096 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7097 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7098 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7099 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7100 | |
| 7101 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7102 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7103 | |
| 7104 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7105 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7106 | CRTCData[i]); |
| 7107 | |
| 7108 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7109 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7110 | CRTCData[i]); |
| 7111 | |
| 7112 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7113 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7114 | CRTCData[i]); |
| 7115 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7116 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7117 | & 0xE0)); |
| 7118 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7119 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 7120 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 7121 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7122 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7123 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7124 | |
| 7125 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7126 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
| 7127 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); |
| 7128 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7129 | } |
| 7130 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7131 | mdelay(1); |
| 7132 | |
| 7133 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7134 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7135 | |
| 7136 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7137 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7138 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7139 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7140 | |
| 7141 | /* alan, avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7142 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7143 | |
| 7144 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7145 | outb(0, (pVBInfo->P3c8 + 1)); |
| 7146 | outb(0, (pVBInfo->P3c8 + 1)); |
| 7147 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7148 | } |
| 7149 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7150 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 7151 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 7152 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7153 | |
| 7154 | /* [2004/05/11] Vicent */ |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7155 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7156 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7157 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7158 | } |
| 7159 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7160 | static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, |
| 7161 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7162 | struct vb_device_info *pVBInfo) |
| 7163 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 7164 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7165 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 7166 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 7167 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7168 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 7169 | if (pVBInfo->SetFlag & EnableChA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7170 | /* Power on */ |
| 7171 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7172 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7173 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 7174 | /* Power on */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7175 | xgifb_reg_set(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7176 | 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7177 | } |
| 7178 | } |
| 7179 | } |
| 7180 | |
| 7181 | if (!(pVBInfo->SetFlag & DisableChB)) { |
| 7182 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo |
| 7183 | & (SetCRT2ToLCD | SetCRT2ToTV |
| 7184 | | SetCRT2ToRAMDAC))) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7185 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7186 | pVBInfo->P3c4, 0x32); |
| 7187 | tempah &= 0xDF; |
| 7188 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7189 | if (!(pVBInfo->VBInfo & |
| 7190 | SetCRT2ToRAMDAC)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7191 | tempah |= 0x20; |
| 7192 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7193 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7194 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7195 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7196 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7197 | pVBInfo->Part1Port, 0x2E); |
| 7198 | |
| 7199 | if (!(tempah & 0x80)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 7200 | xgifb_reg_or(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7201 | 0x2E, 0x80); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7202 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7203 | } |
| 7204 | } |
| 7205 | |
| 7206 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
| 7207 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 7208 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7209 | 0x20); /* shampoo 0129 */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 7210 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7211 | if (!XGI_DisableChISLCD(pVBInfo)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7212 | if (XGI_EnableChISLCD(pVBInfo) || |
| 7213 | (pVBInfo->VBInfo & |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 7214 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7215 | /* LVDS PLL power on */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 7216 | xgifb_reg_and( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7217 | pVBInfo->Part4Port, |
| 7218 | 0x2A, |
| 7219 | 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7220 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7221 | /* LVDS Driver power on */ |
| 7222 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7223 | } |
| 7224 | } |
| 7225 | |
| 7226 | tempah = 0x00; |
| 7227 | |
| 7228 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 7229 | tempah = 0xc0; |
| 7230 | |
| 7231 | if (!(pVBInfo->VBInfo & SetSimuScanMode)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 7232 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7233 | if (pVBInfo->VBInfo & |
| 7234 | SetCRT2ToDualEdge) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7235 | tempah = tempah & 0x40; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7236 | if (pVBInfo->VBInfo & |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 7237 | XGI_SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7238 | tempah = tempah ^ 0xC0; |
| 7239 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7240 | if (pVBInfo->SetFlag & |
| 7241 | DisableChB) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7242 | tempah &= 0xBF; |
| 7243 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7244 | if (pVBInfo->SetFlag & |
| 7245 | DisableChA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7246 | tempah &= 0x7F; |
| 7247 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7248 | if (pVBInfo->SetFlag & |
| 7249 | EnableChB) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7250 | tempah |= 0x40; |
| 7251 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7252 | if (pVBInfo->SetFlag & |
| 7253 | EnableChA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7254 | tempah |= 0x80; |
| 7255 | } |
| 7256 | } |
| 7257 | } |
| 7258 | } |
| 7259 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7260 | /* EnablePart4_1F */ |
| 7261 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7262 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7263 | if (!(pVBInfo->SetFlag & DisableChA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7264 | if (!(pVBInfo->SetFlag & GatingCRT)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7265 | XGI_DisableGatingCRT(HwDeviceExtension, |
| 7266 | pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7267 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, |
| 7268 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7269 | } |
| 7270 | } |
| 7271 | } /* 301 */ |
| 7272 | else { /* LVDS */ |
| 7273 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 7274 | | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7275 | /* enable CRT2 */ |
| 7276 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7277 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7278 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7279 | 0x2E); |
| 7280 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7281 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7282 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 7283 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7284 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7285 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7286 | } |
| 7287 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7288 | static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, |
| 7289 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7290 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 7291 | struct vb_device_info *pVBInfo) |
| 7292 | { |
| 7293 | unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp; |
| 7294 | |
| 7295 | unsigned short XGINew_P3cc = pVBInfo->P3cc; |
| 7296 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7297 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7298 | XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); |
Aaro Koskinen | eb9aef1 | 2011-11-27 23:03:15 +0200 | [diff] [blame] | 7299 | outb(pVBInfo->StandTable[StandTableIndex].MISC, pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7300 | XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo); |
| 7301 | XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); |
| 7302 | XGI_SetGRCRegs(StandTableIndex, pVBInfo); |
| 7303 | XGI_ClearExt1Regs(pVBInfo); |
| 7304 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7305 | if (HwDeviceExtension->jChipType == XG27) { |
| 7306 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 7307 | XGI_SetDefaultVCLK(pVBInfo); |
| 7308 | } |
| 7309 | |
| 7310 | temp = ~ProgrammingCRT2; |
| 7311 | pVBInfo->SetFlag &= temp; |
| 7312 | pVBInfo->SelectCRT2Rate = 0; |
| 7313 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 7314 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 7315 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 7316 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7317 | | SetInSlaveMode)) { |
| 7318 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 7319 | } |
| 7320 | } |
| 7321 | |
| 7322 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 7323 | ModeIdIndex, pVBInfo); |
| 7324 | if (RefreshRateTableIndex != 0xFFFF) { |
| 7325 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
| 7326 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7327 | pVBInfo, HwDeviceExtension); |
| 7328 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 7329 | RefreshRateTableIndex, pVBInfo); |
| 7330 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 7331 | HwDeviceExtension, pVBInfo); |
| 7332 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 7333 | RefreshRateTableIndex, pVBInfo); |
| 7334 | } |
| 7335 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7336 | if ((HwDeviceExtension->jChipType >= XG20) && |
| 7337 | (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7338 | if ((ModeNo == 0x00) | (ModeNo == 0x01)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7339 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E); |
| 7340 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7341 | b3CC = (unsigned char) inb(XGINew_P3cc); |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7342 | outb((b3CC |= 0x0C), XGINew_P3cc); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7343 | } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo |
| 7344 | == 0x0D)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7345 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 7346 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 7347 | b3CC = (unsigned char) inb(XGINew_P3cc); |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 7348 | outb((b3CC |= 0x0C), XGINew_P3cc); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7349 | } |
| 7350 | } |
| 7351 | |
| 7352 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7353 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7354 | if (temp & 0xA0) { |
| 7355 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7356 | if (HwDeviceExtension->jChipType == XG27) |
| 7357 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, |
| 7358 | RefreshRateTableIndex, pVBInfo); |
| 7359 | else |
| 7360 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, |
| 7361 | RefreshRateTableIndex, pVBInfo); |
| 7362 | |
| 7363 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 7364 | RefreshRateTableIndex); |
| 7365 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 7366 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
| 7367 | pVBInfo, RefreshRateTableIndex, ModeNo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7368 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 7369 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7370 | xgifb_set_lvds(xgifb_info, |
| 7371 | HwDeviceExtension->jChipType, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 7372 | ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7373 | } |
| 7374 | } |
| 7375 | |
| 7376 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
| 7377 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); |
| 7378 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 7379 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7380 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7381 | } |
| 7382 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7383 | unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, |
| 7384 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7385 | unsigned short ModeNo) |
| 7386 | { |
| 7387 | unsigned short ModeIdIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7388 | struct vb_device_info VBINF; |
| 7389 | struct vb_device_info *pVBInfo = &VBINF; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7390 | pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; |
| 7391 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7392 | pVBInfo->IF_DEF_LCDA = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7393 | |
| 7394 | if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ |
| 7395 | pVBInfo->IF_DEF_YPbPr = 0; |
| 7396 | pVBInfo->IF_DEF_HiVision = 0; |
| 7397 | pVBInfo->IF_DEF_CRT2Monitor = 0; |
| 7398 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7399 | } else { |
| 7400 | pVBInfo->IF_DEF_YPbPr = 1; |
| 7401 | pVBInfo->IF_DEF_HiVision = 1; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 7402 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7403 | } |
| 7404 | |
| 7405 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; |
| 7406 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; |
| 7407 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; |
| 7408 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; |
| 7409 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; |
| 7410 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; |
| 7411 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; |
| 7412 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; |
| 7413 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; |
| 7414 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; |
| 7415 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; |
| 7416 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; |
| 7417 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 7418 | pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04; |
| 7419 | pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10; |
| 7420 | pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12; |
| 7421 | pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14; |
| 7422 | pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7423 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7424 | /* for x86 Linux, XG21 LVDS */ |
| 7425 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7426 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7427 | pVBInfo->IF_DEF_LVDS = 1; |
| 7428 | } |
| 7429 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 7430 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 7431 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7432 | pVBInfo->IF_DEF_LVDS = 1; |
| 7433 | } |
| 7434 | } |
| 7435 | |
| 7436 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
| 7437 | XGI_GetVBType(pVBInfo); |
| 7438 | |
| 7439 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
Aaro Koskinen | ef497f4 | 2011-11-27 23:03:21 +0200 | [diff] [blame] | 7440 | if (ModeNo & 0x80) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7441 | ModeNo = ModeNo & 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 7442 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7443 | |
| 7444 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ |
| 7445 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
| 7446 | |
| 7447 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 7448 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7449 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 7450 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 7451 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 7452 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7453 | XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7454 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 7455 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7456 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7457 | ModeIdIndex, pVBInfo); |
| 7458 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 7459 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7460 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 7461 | HwDeviceExtension, pVBInfo); |
| 7462 | } |
| 7463 | } else { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 7464 | if (!(pVBInfo->VBInfo & SwitchCRT2)) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7465 | XGI_SetCRT1Group(xgifb_info, |
| 7466 | HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7467 | ModeIdIndex, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 7468 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7469 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 7470 | HwDeviceExtension, |
| 7471 | pVBInfo); |
| 7472 | } |
| 7473 | } |
| 7474 | } |
| 7475 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 7476 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7477 | switch (HwDeviceExtension->ujVBChipID) { |
| 7478 | case VB_CHIP_301: |
| 7479 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 7480 | pVBInfo); /*add for CRT2 */ |
| 7481 | break; |
| 7482 | |
| 7483 | case VB_CHIP_302: |
| 7484 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 7485 | pVBInfo); /*add for CRT2 */ |
| 7486 | break; |
| 7487 | |
| 7488 | default: |
| 7489 | break; |
| 7490 | } |
| 7491 | } |
| 7492 | |
| 7493 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
| 7494 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ |
| 7495 | XGI_CloseCRTC(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7496 | XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7497 | } /* !XG20 */ |
| 7498 | else { |
| 7499 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7500 | if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7501 | ModeIdIndex, |
| 7502 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7503 | return 0; |
| 7504 | |
| 7505 | if (ModeNo <= 0x13) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7506 | pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex]. |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 7507 | St_ModeFlag & ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7508 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 7509 | pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex]. |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 7510 | Ext_ModeFlag & ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7511 | } |
| 7512 | |
| 7513 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 7514 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7515 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7516 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7517 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7518 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
| 7519 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7520 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 7521 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7522 | } |
| 7523 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 7524 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
| 7525 | |
| 7526 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 7527 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
| 7528 | } |
| 7529 | |
| 7530 | return 1; |
| 7531 | } |