Aaro Koskinen | d80aaa0 | 2011-02-17 23:29:14 +0200 | [diff] [blame] | 1 | #include <linux/delay.h> |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2 | #include "XGIfb.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4 | #include "vb_def.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5 | #include "vb_util.h" |
| 6 | #include "vb_table.h" |
Miguel Gómez | e054102 | 2012-06-18 13:12:05 +0200 | [diff] [blame] | 7 | #include "vb_setmode.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 8 | |
| 9 | #define IndexMask 0xff |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 10 | #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 11 | |
Aaro Koskinen | 624554d | 2011-10-11 21:47:35 +0300 | [diff] [blame] | 12 | static const unsigned short XGINew_VGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 13 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 14 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 15 | 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18, |
| 16 | 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F, |
| 17 | 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F, |
| 18 | 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00, |
| 19 | 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18, |
| 20 | 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04, |
| 21 | 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10, |
| 22 | 0x0B, 0x0C, 0x0D, 0x0F, 0x10}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 23 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 24 | void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 25 | { |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 26 | pVBInfo->MCLKData = XGI340New_MCLKData; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 27 | pVBInfo->StResInfo = XGI330_StResInfo; |
| 28 | pVBInfo->ModeResInfo = XGI330_ModeResInfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 29 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 30 | pVBInfo->LCDResInfo = 0; |
| 31 | pVBInfo->LCDTypeInfo = 0; |
| 32 | pVBInfo->LCDInfo = 0; |
| 33 | pVBInfo->VBInfo = 0; |
| 34 | pVBInfo->TVInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 35 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 36 | pVBInfo->SR15 = XGI340_SR13; |
| 37 | pVBInfo->CR40 = XGI340_cr41; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 38 | pVBInfo->CR6B = XGI340_CR6B; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 39 | pVBInfo->AGPReg = XGI340_AGPReg; |
| 40 | pVBInfo->SR16 = XGI340_SR16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 41 | |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 42 | pVBInfo->SR21 = 0xa3; |
| 43 | pVBInfo->SR22 = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 44 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 45 | /* 310 customization related */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 46 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 47 | pVBInfo->LCDCapList = XGI_LCDDLCapList; |
| 48 | else |
| 49 | pVBInfo->LCDCapList = XGI_LCDCapList; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 50 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 51 | if (ChipType >= XG20) |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 52 | pVBInfo->XGINew_CR97 = 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 53 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 54 | if (ChipType == XG27) { |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 55 | unsigned char temp; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 56 | pVBInfo->MCLKData = XGI27New_MCLKData; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 57 | pVBInfo->CR40 = XGI27_cr41; |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 58 | pVBInfo->XGINew_CR97 = 0xc1; |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 59 | pVBInfo->SR15 = XG27_SR13; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 60 | |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 61 | /*Z11m DDR*/ |
| 62 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B); |
| 63 | /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */ |
| 64 | if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08)) |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 65 | pVBInfo->XGINew_CR97 = 0x80; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 66 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 67 | |
| 68 | } |
| 69 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 70 | static void XGI_SetSeqRegs(unsigned short ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 71 | unsigned short ModeIdIndex, |
| 72 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 73 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 74 | unsigned char tempah, SRdata; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 75 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 76 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 77 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 78 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 79 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 80 | tempah = XGI330_StandTable.SR[0]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 81 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 82 | i = XGI_SetCRT2ToLCDA; |
| 83 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 84 | tempah |= 0x01; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 85 | } else if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { |
| 86 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 87 | tempah |= 0x01; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 88 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 89 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 90 | tempah |= 0x20; /* screen off */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 91 | xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 92 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 93 | for (i = 02; i <= 04; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 94 | /* Get SR2,3,4 from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 95 | SRdata = XGI330_StandTable.SR[i - 1]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 96 | xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 97 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 98 | } |
| 99 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 100 | static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 101 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 102 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 103 | unsigned char CRTCdata; |
| 104 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 105 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 106 | CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 107 | CRTCdata &= 0x7f; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 108 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
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 | for (i = 0; i <= 0x18; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 111 | /* Get CRTC from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 112 | CRTCdata = XGI330_StandTable.CRTC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 113 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 114 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 115 | } |
| 116 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 117 | static void XGI_SetATTRegs(unsigned short ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 118 | unsigned short ModeIdIndex, |
| 119 | struct vb_device_info *pVBInfo) |
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 | unsigned char ARdata; |
| 122 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 123 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 124 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 125 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 126 | for (i = 0; i <= 0x13; i++) { |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 127 | ARdata = XGI330_StandTable.ATTR[i]; |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 128 | |
| 129 | if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */ |
| 130 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 131 | ARdata = 0; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 132 | } else if ((pVBInfo->VBInfo & |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 133 | (SetCRT2ToTV | SetCRT2ToLCD)) && |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 134 | (pVBInfo->VBInfo & SetInSlaveMode)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 135 | ARdata = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 136 | } |
| 137 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 138 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 139 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 140 | outb(i, pVBInfo->P3c0); /* set index */ |
| 141 | outb(ARdata, pVBInfo->P3c0); /* set data */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 142 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 143 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 144 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 145 | outb(0x14, pVBInfo->P3c0); /* set index */ |
| 146 | outb(0x00, pVBInfo->P3c0); /* set data */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 147 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 148 | outb(0x20, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 149 | } |
| 150 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 151 | static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 152 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 153 | unsigned char GRdata; |
| 154 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 155 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 156 | for (i = 0; i <= 0x08; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 157 | /* Get GR from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 158 | GRdata = XGI330_StandTable.GRC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 159 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 160 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 161 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 162 | if (pVBInfo->ModeType > ModeVGA) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 163 | GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 164 | GRdata &= 0xBF; /* 256 color disable */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 165 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
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 | } |
| 168 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 169 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 170 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 171 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 172 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 173 | for (i = 0x0A; i <= 0x0E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 174 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 175 | } |
| 176 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 177 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 178 | { |
| 179 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 180 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 181 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[0].SR2B); |
| 182 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[0].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 183 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 184 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 185 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[1].SR2B); |
| 186 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[1].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 187 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 188 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 189 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 190 | } |
| 191 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 192 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 193 | unsigned short ModeIdIndex, |
| 194 | unsigned short RefreshRateTableIndex, unsigned short *i, |
| 195 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 196 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 197 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 198 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 199 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 200 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 201 | tempbx = XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 202 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 203 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 204 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 205 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 206 | tempax |= SupportRAMDAC2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 207 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 208 | if (pVBInfo->VBType & VB_XGI301C) |
| 209 | tempax |= SupportCRT2in301C; |
| 210 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 211 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 212 | /* 301b */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 213 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 214 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 215 | |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 216 | if (pVBInfo->LCDResInfo != Panel_1280x1024 && |
| 217 | pVBInfo->LCDResInfo != Panel_1280x960 && |
| 218 | (pVBInfo->LCDInfo & LCDNonExpanding) && |
| 219 | resinfo >= 9) |
| 220 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 221 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 222 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 223 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */ |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 224 | tempax |= SupportHiVision; |
| 225 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 226 | ((resinfo == 4) || |
| 227 | (resinfo == 3 && |
| 228 | (pVBInfo->SetFlag & TVSimuMode)) || |
| 229 | (resinfo > 7))) |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 230 | return 0; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 231 | } else if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 232 | SetCRT2ToSVIDEO | |
| 233 | SetCRT2ToSCART | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 234 | SetCRT2ToYPbPr525750 | |
| 235 | SetCRT2ToHiVision)) { |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 236 | tempax |= SupportTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 237 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 238 | if (pVBInfo->VBType & (VB_SIS301B | |
| 239 | VB_SIS302B | |
| 240 | VB_SIS301LV | |
| 241 | VB_SIS302LV | |
| 242 | VB_XGI301C)) |
| 243 | tempax |= SupportTV1024; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 244 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 245 | if (!(pVBInfo->VBInfo & TVSetPAL) && |
| 246 | (modeflag & NoSupportSimuTV) && |
| 247 | (pVBInfo->VBInfo & SetInSlaveMode) && |
| 248 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
| 249 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 250 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 251 | } else if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* for LVDS */ |
| 252 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 253 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 254 | if (resinfo > 0x08) |
| 255 | return 0; /* 1024x768 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 256 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 257 | if (pVBInfo->LCDResInfo < Panel_1024x768) { |
| 258 | if (resinfo > 0x07) |
| 259 | return 0; /* 800x600 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 260 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 261 | if (resinfo == 0x04) |
| 262 | return 0; /* 512x384 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 263 | } |
| 264 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 265 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 266 | for (; XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 267 | tempbx; (*i)--) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 268 | infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 269 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 270 | if (infoflag & tempax) |
| 271 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 272 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 273 | if ((*i) == 0) |
| 274 | break; |
| 275 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 276 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 277 | for ((*i) = 0;; (*i)++) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 278 | infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 279 | Ext_InfoFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 280 | if (XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 281 | != tempbx) { |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | if (infoflag & tempax) |
| 286 | return 1; |
| 287 | } |
| 288 | return 1; |
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_SetSync(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [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 short sync, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 295 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 296 | /* di+0x00 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 297 | sync = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 298 | sync &= 0xC0; |
| 299 | temp = 0x2F; |
| 300 | temp |= sync; |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 301 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 302 | } |
| 303 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 304 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 305 | struct xgi_hw_device_info *HwDeviceExtension) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 306 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 307 | unsigned char data, data1, pushax; |
| 308 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 309 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 310 | /* unlock cr0-7 */ |
| 311 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 312 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 313 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 314 | |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 315 | data = pVBInfo->TimingH.data[0]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 316 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 317 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 318 | for (i = 0x01; i <= 0x04; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 319 | data = pVBInfo->TimingH.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 320 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 321 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 322 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 323 | for (i = 0x05; i <= 0x06; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 324 | data = pVBInfo->TimingH.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 325 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 326 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 327 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 328 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 329 | j &= 0x1F; |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 330 | data = pVBInfo->TimingH.data[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 331 | data &= 0xE0; |
| 332 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 333 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 334 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 335 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 336 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 337 | data = data - 1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 338 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 339 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 340 | data1 = data; |
| 341 | data1 &= 0xE0; |
| 342 | data &= 0x1F; |
| 343 | if (data == 0) { |
| 344 | pushax = data; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 345 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 346 | 0x0c); |
| 347 | data &= 0xFB; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 348 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 349 | data = pushax; |
| 350 | } |
| 351 | data = data - 1; |
| 352 | data |= data1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 353 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 354 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 355 | data = data >> 5; |
| 356 | data = data + 3; |
| 357 | if (data > 7) |
| 358 | data = data - 7; |
| 359 | data = data << 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 360 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 361 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 362 | } |
| 363 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 364 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
| 365 | unsigned short ModeNo, |
| 366 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 367 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 368 | unsigned char data; |
| 369 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 370 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 371 | for (i = 0x00; i <= 0x01; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 372 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 373 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 374 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 375 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 376 | for (i = 0x02; i <= 0x03; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 377 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 378 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 379 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 380 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 381 | for (i = 0x04; i <= 0x05; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 382 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 383 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 384 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 385 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 386 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 387 | j &= 0xC0; |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 388 | data = pVBInfo->TimingV.data[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 389 | data &= 0x3F; |
| 390 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 391 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 392 | |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 393 | data = pVBInfo->TimingV.data[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 394 | data &= 0x80; |
| 395 | data = data >> 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 396 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 397 | i = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 398 | i &= DoubleScanMode; |
| 399 | if (i) |
| 400 | data |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 401 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 402 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 403 | j &= 0x5F; |
| 404 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 405 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 406 | } |
| 407 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 408 | static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 409 | unsigned short RefreshRateTableIndex, |
| 410 | struct vb_device_info *pVBInfo, |
| 411 | struct xgi_hw_device_info *HwDeviceExtension) |
| 412 | { |
| 413 | unsigned char index, data; |
| 414 | unsigned short i; |
| 415 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 416 | /* Get index */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 417 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 418 | index = index & IndexMask; |
| 419 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 420 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 421 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 422 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 423 | |
| 424 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 425 | pVBInfo->TimingH.data[i] |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 426 | = XGI_CRT1Table[index].CR[i]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 427 | |
| 428 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 429 | pVBInfo->TimingV.data[i] |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 430 | = XGI_CRT1Table[index].CR[i + 8]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 431 | |
| 432 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 433 | |
| 434 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
| 435 | |
| 436 | if (pVBInfo->ModeType > 0x03) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 437 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 438 | } |
| 439 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 440 | /* --------------------------------------------------------------------- */ |
| 441 | /* Function : XGI_SetXG21CRTC */ |
| 442 | /* Input : Stand or enhance CRTC table */ |
| 443 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ |
| 444 | /* Description : Set LCD timing */ |
| 445 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 446 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 447 | unsigned short RefreshRateTableIndex, |
| 448 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 449 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 450 | unsigned char index, Tempax, Tempbx, Tempcx, Tempdx; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 451 | unsigned short Temp1, Temp2, Temp3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 452 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 453 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 454 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 455 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 456 | Tempcx = Tempax; /* Tempcx: HRS */ |
| 457 | /* SR2E[7:0]->HRS */ |
| 458 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 459 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 460 | Tempdx = XGI_CRT1Table[index].CR[5]; /* SRB */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 461 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ |
| 462 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ |
| 463 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ |
| 464 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 465 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 466 | Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 467 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 468 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 469 | Tempbx = XGI_CRT1Table[index].CR[6]; /* SRC */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 470 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ |
| 471 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ |
| 472 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 473 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 474 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
| 475 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 476 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 477 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
| 478 | if (Tempax < Tempcx) /* HRE < HRS */ |
| 479 | Temp2 |= 0x40; /* Temp2 + 0x40 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 480 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 481 | Temp2 &= 0xFF; |
| 482 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ |
| 483 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ |
| 484 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ |
| 485 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ |
| 486 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
| 487 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 488 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 489 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 490 | /* CR10 VRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 491 | Tempax = XGI_CRT1Table[index].CR[10]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 492 | Tempbx = Tempax; /* Tempbx: VRS */ |
| 493 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ |
| 494 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
| 495 | /* CR7[2][7] VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 496 | Tempax = XGI_CRT1Table[index].CR[9]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 497 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
| 498 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ |
| 499 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ |
| 500 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ |
| 501 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 502 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 503 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
| 504 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ |
| 505 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 506 | Tempax &= 0x80; |
| 507 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 508 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
| 509 | /* Tempax: SRA */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 510 | Tempax = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 511 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
| 512 | Temp2 = Tempax; |
| 513 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ |
| 514 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 515 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 516 | /* Tempax: CR11 VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 517 | Tempax = XGI_CRT1Table[index].CR[11]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 518 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 519 | /* Tempbx: SRA */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 520 | Tempbx = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 521 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
| 522 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 523 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 524 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ |
| 525 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 526 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 527 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
| 528 | if (Tempax < Temp3) /* VRE < VRS */ |
| 529 | Temp2 |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 530 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 531 | Temp2 &= 0xFF; |
| 532 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ |
| 533 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ |
| 534 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 535 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ |
| 536 | Tempbx = (unsigned char) Temp1; |
| 537 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ |
| 538 | Tempax &= 0x7F; |
| 539 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 540 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 541 | } |
| 542 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 543 | static void XGI_SetXG27CRTC(unsigned short ModeNo, |
| 544 | unsigned short ModeIdIndex, |
| 545 | unsigned short RefreshRateTableIndex, |
| 546 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 547 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 548 | unsigned short index, Tempax, Tempbx, Tempcx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 549 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 550 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 551 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 552 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 553 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
| 554 | /* SR2E[7:0]->HRS */ |
| 555 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 556 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 557 | /* SR0B */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 558 | Tempax = XGI_CRT1Table[index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 559 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 560 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 561 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 562 | Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 563 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
| 564 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 565 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 566 | Tempax = XGI_CRT1Table[index].CR[6]; /* SRC */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 567 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ |
| 568 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ |
| 569 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 570 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 571 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
| 572 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 573 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 574 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 575 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 576 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
| 577 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ |
| 578 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 579 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 580 | Tempax = XGI_CRT1Table[index].CR[5]; /* SR0B */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 581 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 582 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ |
| 583 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ |
| 584 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
| 585 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 586 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 587 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 588 | /* CR10 VRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 589 | Tempax = XGI_CRT1Table[index].CR[10]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 590 | /* SR34[7:0]->VRS[7:0] */ |
| 591 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 592 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 593 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
| 594 | /* CR7[7][2] VRS[9][8] */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 595 | Tempax = XGI_CRT1Table[index].CR[9]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 596 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
| 597 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ |
| 598 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ |
| 599 | /* SR35[0]: VRS[8] */ |
| 600 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
| 601 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
| 602 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ |
| 603 | /* Tempax: SR0A */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 604 | Tempax = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 605 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
| 606 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 607 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 608 | /* Tempax: CR11 VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 609 | Tempax = XGI_CRT1Table[index].CR[11]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 610 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 611 | /* Tempbx: SR0A */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 612 | Tempbx = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 613 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
| 614 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 615 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 616 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ |
| 617 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ |
| 618 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 619 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 620 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
| 621 | Tempbx |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 622 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 623 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
| 624 | Tempax = (Tempbx << 2) & 0xFF; |
| 625 | /* SR3F[7:2]:VRE[5:0] */ |
| 626 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
| 627 | Tempax = Tempcx >> 8; |
| 628 | /* SR35[2:0]:VRS[10:8] */ |
| 629 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 630 | } |
| 631 | |
Aaro Koskinen | a2d08cf | 2011-11-27 23:03:08 +0200 | [diff] [blame] | 632 | static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
| 633 | { |
| 634 | unsigned char temp; |
| 635 | |
| 636 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 637 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 638 | temp = (temp & 3) << 6; |
| 639 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 640 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 641 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 642 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 643 | |
| 644 | } |
| 645 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 646 | static void xgifb_set_lcd(int chip_id, |
| 647 | struct vb_device_info *pVBInfo, |
| 648 | unsigned short RefreshRateTableIndex, |
| 649 | unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 650 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 651 | unsigned short Data, Temp; |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 652 | unsigned short XGI_P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 653 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 654 | XGI_P3cc = pVBInfo->P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 655 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 656 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 657 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 658 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 659 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 660 | |
| 661 | if (chip_id == XG27) { |
| 662 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 663 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
| 664 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 665 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
| 666 | } |
| 667 | } |
| 668 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 669 | if (chip_id == XG27) { |
| 670 | XGI_SetXG27FPBits(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 671 | } else { |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 672 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 673 | if (Temp & 0x01) { |
| 674 | /* 18 bits FP */ |
| 675 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); |
| 676 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
| 677 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 678 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 679 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 680 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 681 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 682 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 683 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 684 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 685 | Data = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 686 | if (Data & 0x4000) |
| 687 | /* Hsync polarity */ |
| 688 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
| 689 | if (Data & 0x8000) |
| 690 | /* Vsync polarity */ |
| 691 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | /* --------------------------------------------------------------------- */ |
| 695 | /* Function : XGI_UpdateXG21CRTC */ |
| 696 | /* Input : */ |
| 697 | /* Output : CRT1 CRTC */ |
| 698 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 699 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 700 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 701 | struct vb_device_info *pVBInfo, |
| 702 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 703 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 704 | int index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 705 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 706 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 707 | if (ModeNo == 0x2E && |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 708 | (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 709 | RES640x480x60)) |
| 710 | index = 12; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 711 | else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 712 | Ext_CRT1CRTC == RES640x480x72)) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 713 | index = 13; |
| 714 | else if (ModeNo == 0x2F) |
| 715 | index = 14; |
| 716 | else if (ModeNo == 0x50) |
| 717 | index = 15; |
| 718 | else if (ModeNo == 0x59) |
| 719 | index = 16; |
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 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 722 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 723 | XGI_UpdateCRT1Table[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 724 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 725 | XGI_UpdateCRT1Table[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 726 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 727 | XGI_UpdateCRT1Table[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 728 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 729 | XGI_UpdateCRT1Table[index].CR16); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 730 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 731 | } |
| 732 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 733 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 734 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 735 | unsigned short RefreshRateTableIndex, |
| 736 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 737 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 738 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 739 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 740 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 741 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 742 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 743 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 744 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 745 | tempax = pVBInfo->ModeResInfo[resindex].HTotal; |
| 746 | tempbx = pVBInfo->ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 747 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 748 | if (modeflag & HalfDCLK) |
| 749 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 750 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 751 | if (modeflag & HalfDCLK) |
| 752 | tempax = tempax << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 753 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 754 | temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 755 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 756 | if (temp & InterlaceMode) |
| 757 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 758 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 759 | if (modeflag & DoubleScanMode) |
| 760 | tempbx = tempbx << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 761 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 762 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 763 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 764 | tempax /= tempcx; |
| 765 | tempax -= 1; |
| 766 | tempbx -= 1; |
| 767 | tempcx = tempax; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 768 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 769 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 770 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 771 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 772 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 773 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 774 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 775 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 776 | tempax = 0; |
| 777 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 778 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 779 | if (tempbx & 0x01) |
| 780 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 781 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 782 | if (tempbx & 0x02) |
| 783 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 784 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 785 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 786 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 787 | data &= 0xFF; |
| 788 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 789 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 790 | if (tempbx & 0x04) |
| 791 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 792 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 793 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 794 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 795 | } |
| 796 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 797 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 798 | unsigned short ModeIdIndex, |
| 799 | unsigned short RefreshRateTableIndex, |
| 800 | struct xgi_hw_device_info *HwDeviceExtension, |
| 801 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 802 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 803 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 804 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 805 | /* GetOffset */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 806 | temp = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 807 | temp = temp >> 8; |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame^] | 808 | temp = XGI330_ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 809 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 810 | temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 811 | temp2 &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 812 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 813 | if (temp2) |
| 814 | temp = temp << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 815 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 816 | temp2 = pVBInfo->ModeType - ModeEGA; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 817 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 818 | switch (temp2) { |
| 819 | case 0: |
| 820 | temp2 = 1; |
| 821 | break; |
| 822 | case 1: |
| 823 | temp2 = 2; |
| 824 | break; |
| 825 | case 2: |
| 826 | temp2 = 4; |
| 827 | break; |
| 828 | case 3: |
| 829 | temp2 = 4; |
| 830 | break; |
| 831 | case 4: |
| 832 | temp2 = 6; |
| 833 | break; |
| 834 | case 5: |
| 835 | temp2 = 8; |
| 836 | break; |
| 837 | default: |
| 838 | break; |
| 839 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 840 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 841 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 842 | temp = temp * temp2 + temp2 / 2; |
| 843 | else |
| 844 | temp *= temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 845 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 846 | /* SetOffset */ |
| 847 | DisplayUnit = temp; |
| 848 | temp2 = temp; |
| 849 | temp = temp >> 8; /* ah */ |
| 850 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 851 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 852 | i &= 0xF0; |
| 853 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 854 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 855 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 856 | temp = (unsigned char) temp2; |
| 857 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 858 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
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 | /* SetDisplayUnit */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 861 | temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 862 | temp2 &= InterlaceMode; |
| 863 | if (temp2) |
| 864 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 865 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 866 | DisplayUnit = DisplayUnit << 5; |
| 867 | ah = (DisplayUnit & 0xff00) >> 8; |
| 868 | al = DisplayUnit & 0x00ff; |
| 869 | if (al == 0) |
| 870 | ah += 1; |
| 871 | else |
| 872 | ah += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 873 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 874 | if (HwDeviceExtension->jChipType >= XG20) |
| 875 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 876 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 877 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 878 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 879 | } |
| 880 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 881 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
| 882 | unsigned short ModeIdIndex, |
| 883 | unsigned short RefreshRateTableIndex, |
| 884 | struct xgi_hw_device_info *HwDeviceExtension, |
| 885 | struct vb_device_info *pVBInfo) |
| 886 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 887 | unsigned short CRT2Index, VCLKIndex; |
| 888 | unsigned short modeflag, resinfo; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 889 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 890 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 891 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 892 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 893 | CRT2Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 894 | |
| 895 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 896 | CRT2Index = CRT2Index >> 6; /* for LCD */ |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 897 | if (pVBInfo->VBInfo & |
| 898 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 899 | if (pVBInfo->LCDResInfo != Panel_1024x768) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 900 | /* LCDXlat2VCLK */ |
| 901 | VCLKIndex = VCLK108_2_315 + 5; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 902 | else |
Peter Huewe | f477d3e | 2012-06-14 00:21:47 +0200 | [diff] [blame] | 903 | VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 904 | } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 905 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 906 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 907 | else |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 908 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 909 | |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 910 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 911 | if (modeflag & Charx8Dot) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 912 | VCLKIndex = TVCLKBASE_315_25 + |
| 913 | HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 914 | } else { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 915 | VCLKIndex = TVCLKBASE_315_25 + |
| 916 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 917 | } |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | /* 301lv */ |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 921 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 922 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 923 | VCLKIndex = YPbPr525iVCLK_2; |
| 924 | else |
| 925 | VCLKIndex = YPbPr525iVCLK; |
| 926 | } |
| 927 | } else if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 928 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 929 | VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 930 | else |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 931 | VCLKIndex = TVCLKBASE_315_25 + TVVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 932 | } else { /* for CRT2 */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 933 | /* di+Ext_CRTVCLK */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 934 | VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 935 | Ext_CRTVCLK; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 936 | VCLKIndex &= IndexMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 937 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 938 | } else if ((pVBInfo->LCDResInfo == Panel_800x600) || |
| 939 | (pVBInfo->LCDResInfo == Panel_320x480)) { /* LVDS */ |
| 940 | VCLKIndex = VCLK40; /* LVDSXlat1VCLK */ |
| 941 | } else { |
| 942 | VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK, LVDSXlat3VCLK */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 943 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 944 | |
| 945 | return VCLKIndex; |
| 946 | } |
| 947 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 948 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
| 949 | unsigned short ModeIdIndex, |
| 950 | struct xgi_hw_device_info *HwDeviceExtension, |
| 951 | unsigned short RefreshRateTableIndex, |
| 952 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 953 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 954 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 955 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 956 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 957 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 958 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 959 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 960 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 961 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B); |
| 962 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 963 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 964 | } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 965 | | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 966 | & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 967 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, |
| 968 | RefreshRateTableIndex, HwDeviceExtension, |
| 969 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 970 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 971 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 972 | data = XGI_VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 973 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 974 | data = XGI_VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 975 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 976 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 977 | } else { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 978 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 979 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 980 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 981 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B); |
| 982 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 983 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
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 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 986 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 987 | if (XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 988 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 989 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 990 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 991 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 992 | index = data; |
| 993 | index &= 0xE0; |
| 994 | data &= 0x1F; |
| 995 | data = data << 1; |
| 996 | data += 1; |
| 997 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 998 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 999 | } |
| 1000 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1001 | } |
| 1002 | |
Aaro Koskinen | e85f203 | 2011-11-27 23:03:07 +0200 | [diff] [blame] | 1003 | static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
| 1004 | { |
| 1005 | unsigned char temp; |
| 1006 | |
| 1007 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
| 1008 | temp = (temp & 1) << 6; |
| 1009 | /* SR06[6] 18bit Dither */ |
| 1010 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 1011 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 1012 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 1013 | |
| 1014 | } |
| 1015 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1016 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1017 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1018 | struct vb_device_info *pVBInfo) |
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 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1021 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1022 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1023 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1024 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1025 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1026 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
| 1027 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
| 1028 | data &= 0xC0; |
| 1029 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
| 1030 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
| 1031 | data |= 0x01; |
| 1032 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1033 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1034 | if (HwDeviceExtension->jChipType == XG21) |
| 1035 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1036 | } |
| 1037 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1038 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
| 1039 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, |
| 1040 | struct vb_device_info *pVBInfo) |
| 1041 | { |
| 1042 | unsigned short data, data2 = 0; |
| 1043 | short VCLK; |
| 1044 | |
| 1045 | unsigned char index; |
| 1046 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1047 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1048 | index &= IndexMask; |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 1049 | VCLK = XGI_VCLKData[index].CLOCK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1050 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1051 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1052 | data &= 0xf3; |
| 1053 | if (VCLK >= 200) |
| 1054 | data |= 0x0c; /* VCLK > 200 */ |
| 1055 | |
| 1056 | if (HwDeviceExtension->jChipType >= XG20) |
| 1057 | data &= ~0x04; /* 2 pixel mode */ |
| 1058 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1059 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1060 | |
| 1061 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1062 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1063 | data &= 0xE7; |
| 1064 | if (VCLK < 200) |
| 1065 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1066 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1067 | } |
| 1068 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1069 | data2 = 0x00; |
| 1070 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1071 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1072 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1073 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1074 | |
| 1075 | } |
| 1076 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1077 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1078 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1079 | unsigned short RefreshRateTableIndex, |
| 1080 | struct vb_device_info *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 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1083 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1084 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1085 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1086 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1087 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1088 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1089 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1090 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1091 | data = infoflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1092 | data2 = 0; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1093 | data2 |= 0x02; |
| 1094 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1095 | data3 = data3 << 2; |
| 1096 | data2 |= data3; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1097 | data &= InterlaceMode; |
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 | if (data) |
| 1100 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1101 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1102 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1103 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1104 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1105 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1106 | data = 0x0000; |
| 1107 | if (infoflag & InterlaceMode) { |
| 1108 | if (xres == 1024) |
| 1109 | data = 0x0035; |
| 1110 | else if (xres == 1280) |
| 1111 | data = 0x0048; |
| 1112 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1113 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1114 | data2 = data & 0x00FF; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1115 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1116 | data2 = (data & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1117 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1118 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1119 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1120 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1121 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1122 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1123 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1124 | if (modeflag & LineCompareOff) |
| 1125 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1126 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1127 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1128 | data = 0x60; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1129 | data = data ^ 0x60; |
| 1130 | data = data ^ 0xA0; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1131 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1132 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1133 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, |
| 1134 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1135 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1136 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1137 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1138 | if (HwDeviceExtension->jChipType == XG27) { |
| 1139 | if (data & 0x40) |
| 1140 | data = 0x2c; |
| 1141 | else |
| 1142 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1143 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1144 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1145 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1146 | if (data & 0x40) |
| 1147 | data = 0x33; |
| 1148 | else |
| 1149 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1150 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1151 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1152 | } else { |
| 1153 | if (data & 0x40) |
| 1154 | data = 0x2c; |
| 1155 | else |
| 1156 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1157 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1158 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1159 | |
| 1160 | } |
| 1161 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1162 | static void XGI_WriteDAC(unsigned short dl, |
| 1163 | unsigned short ah, |
| 1164 | unsigned short al, |
| 1165 | unsigned short dh, |
| 1166 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1167 | { |
| 1168 | unsigned short temp, bh, bl; |
| 1169 | |
| 1170 | bh = ah; |
| 1171 | bl = al; |
| 1172 | |
| 1173 | if (dl != 0) { |
| 1174 | temp = bh; |
| 1175 | bh = dh; |
| 1176 | dh = temp; |
| 1177 | if (dl == 1) { |
| 1178 | temp = bl; |
| 1179 | bl = dh; |
| 1180 | dh = temp; |
| 1181 | } else { |
| 1182 | temp = bl; |
| 1183 | bl = bh; |
| 1184 | bh = temp; |
| 1185 | } |
| 1186 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1187 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1188 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1189 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1190 | } |
| 1191 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1192 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1193 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1194 | { |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1195 | unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh; |
| 1196 | const unsigned short *table = XGINew_VGA_DAC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1197 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1198 | outb(0xFF, pVBInfo->P3c6); |
| 1199 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1200 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1201 | for (i = 0; i < 16; i++) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1202 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1203 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1204 | for (k = 0; k < 3; k++) { |
| 1205 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1206 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1207 | if (data & 0x01) |
| 1208 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1209 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1210 | if (data & 0x02) |
| 1211 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1212 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1213 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1214 | data = data >> 2; |
| 1215 | } |
| 1216 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1217 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1218 | for (i = 16; i < 32; i++) { |
| 1219 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1220 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1221 | for (k = 0; k < 3; k++) |
| 1222 | outb(data, pVBInfo->P3c9); |
| 1223 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1224 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1225 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1226 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1227 | for (m = 0; m < 9; m++) { |
| 1228 | di = si; |
| 1229 | bx = si + 0x04; |
| 1230 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1231 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1232 | for (n = 0; n < 3; n++) { |
| 1233 | for (o = 0; o < 5; o++) { |
| 1234 | dh = table[si]; |
| 1235 | ah = table[di]; |
| 1236 | al = table[bx]; |
| 1237 | si++; |
| 1238 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1239 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1240 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1241 | si -= 2; |
| 1242 | |
| 1243 | for (o = 0; o < 3; o++) { |
| 1244 | dh = table[bx]; |
| 1245 | ah = table[di]; |
| 1246 | al = table[si]; |
| 1247 | si--; |
| 1248 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1249 | } |
| 1250 | |
| 1251 | dl++; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1252 | } |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1253 | |
| 1254 | si += 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1255 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1256 | } |
| 1257 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1258 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
| 1259 | unsigned short ModeIdIndex, |
| 1260 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1261 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1262 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1263 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1264 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1265 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1266 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1267 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1268 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1269 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1270 | xres = pVBInfo->ModeResInfo[resindex].HTotal; |
| 1271 | yres = pVBInfo->ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1272 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1273 | if (modeflag & HalfDCLK) |
| 1274 | xres = xres << 1; |
| 1275 | |
| 1276 | if (modeflag & DoubleScanMode) |
| 1277 | yres = yres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1278 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1279 | if (xres == 720) |
| 1280 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1281 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1282 | pVBInfo->VGAHDE = xres; |
| 1283 | pVBInfo->HDE = xres; |
| 1284 | pVBInfo->VGAVDE = yres; |
| 1285 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1286 | } |
| 1287 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1288 | static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table, |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1289 | unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1290 | unsigned short ModeIdIndex, |
| 1291 | unsigned short RefreshRateTableIndex, |
| 1292 | struct vb_device_info *pVBInfo) |
| 1293 | { |
Aaro Koskinen | 6c27b37 | 2012-11-04 21:14:45 +0200 | [diff] [blame] | 1294 | unsigned short i, tempdx, tempbx, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1295 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1296 | tempbx = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1297 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1298 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1299 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1300 | i = 0; |
| 1301 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1302 | while (table[i].PANELID != 0xff) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1303 | tempdx = pVBInfo->LCDResInfo; |
| 1304 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 1305 | tempbx &= (~0x0080); |
| 1306 | tempdx = pVBInfo->LCDTypeInfo; |
| 1307 | } |
| 1308 | |
| 1309 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1310 | tempdx &= (~PanelResInfo); |
| 1311 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1312 | if (table[i].PANELID == tempdx) { |
| 1313 | tempbx = table[i].MASK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1314 | tempdx = pVBInfo->LCDInfo; |
| 1315 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1316 | if (modeflag & HalfDCLK) |
| 1317 | tempdx |= SetLCDLowResolution; |
| 1318 | |
| 1319 | tempbx &= tempdx; |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1320 | if (tempbx == table[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1321 | break; |
| 1322 | } |
| 1323 | i++; |
| 1324 | } |
| 1325 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1326 | return table[i].DATAPTR; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1327 | } |
| 1328 | |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 1329 | static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1330 | unsigned short ModeIdIndex, |
| 1331 | unsigned short RefreshRateTableIndex, |
| 1332 | struct vb_device_info *pVBInfo) |
| 1333 | { |
Aaro Koskinen | 56d276c | 2012-09-11 00:15:19 +0300 | [diff] [blame] | 1334 | unsigned short i, tempdx, tempal, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1335 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1336 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1337 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1338 | tempal = tempal & 0x3f; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1339 | tempdx = pVBInfo->TVInfo; |
| 1340 | |
| 1341 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 1342 | tempdx = tempdx | SetTVLockMode; |
| 1343 | |
| 1344 | if (modeflag & HalfDCLK) |
| 1345 | tempdx = tempdx | SetTVLowResolution; |
| 1346 | |
| 1347 | i = 0; |
| 1348 | |
Aaro Koskinen | 6265ee4 | 2012-09-11 00:15:20 +0300 | [diff] [blame] | 1349 | while (XGI_TVDataTable[i].MASK != 0xffff) { |
| 1350 | if ((tempdx & XGI_TVDataTable[i].MASK) == |
| 1351 | XGI_TVDataTable[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1352 | break; |
| 1353 | i++; |
| 1354 | } |
| 1355 | |
Aaro Koskinen | 18ba866 | 2012-09-11 00:15:22 +0300 | [diff] [blame] | 1356 | return &XGI_TVDataTable[i].DATAPTR[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1357 | } |
| 1358 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1359 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1360 | unsigned short RefreshRateTableIndex, |
| 1361 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1362 | { |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1363 | struct SiS_LVDSData const *LCDPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1364 | |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1365 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 1366 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1367 | |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1368 | LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeNo, ModeIdIndex, |
| 1369 | RefreshRateTableIndex, pVBInfo); |
| 1370 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 1371 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 1372 | pVBInfo->HT = LCDPtr->LCDHT; |
| 1373 | pVBInfo->VT = LCDPtr->LCDVT; |
| 1374 | |
| 1375 | if (pVBInfo->LCDInfo & (SetLCDtoNonExpanding | EnableScalingLCD)) |
| 1376 | return; |
| 1377 | |
| 1378 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1379 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
| 1380 | pVBInfo->HDE = 1024; |
| 1381 | pVBInfo->VDE = 768; |
| 1382 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1383 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
| 1384 | pVBInfo->HDE = 1280; |
| 1385 | pVBInfo->VDE = 1024; |
| 1386 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
| 1387 | pVBInfo->HDE = 1400; |
| 1388 | pVBInfo->VDE = 1050; |
| 1389 | } else { |
| 1390 | pVBInfo->HDE = 1600; |
| 1391 | pVBInfo->VDE = 1200; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1392 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1393 | } |
| 1394 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1395 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1396 | unsigned short RefreshRateTableIndex, |
| 1397 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1398 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1399 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1400 | unsigned char index; |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1401 | unsigned short i; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1402 | struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL; |
| 1403 | struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1404 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1405 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1406 | index = index & IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1407 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1408 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1409 | LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeNo, ModeIdIndex, |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1410 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1411 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1412 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1413 | pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1414 | } |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1415 | |
| 1416 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 1417 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1418 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1419 | LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeNo, |
| 1420 | ModeIdIndex, RefreshRateTableIndex, |
| 1421 | pVBInfo); |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1422 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1423 | pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i]; |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1424 | } |
| 1425 | |
| 1426 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1427 | } |
| 1428 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1429 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 1430 | { |
| 1431 | unsigned char tempal, tempah, tempbl, i; |
| 1432 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1433 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1434 | tempal = tempah & 0x0F; |
| 1435 | tempah = tempah & 0xF0; |
| 1436 | i = 0; |
| 1437 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1438 | |
| 1439 | while (tempbl != 0xFF) { |
| 1440 | if (tempbl & 0x80) { /* OEMUtil */ |
| 1441 | tempal = tempah; |
| 1442 | tempbl = tempbl & ~(0x80); |
| 1443 | } |
| 1444 | |
| 1445 | if (tempal == tempbl) |
| 1446 | break; |
| 1447 | |
| 1448 | i++; |
| 1449 | |
| 1450 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1451 | } |
| 1452 | |
| 1453 | return i; |
| 1454 | } |
| 1455 | |
| 1456 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 1457 | { |
| 1458 | unsigned short tempah, tempal, tempbl, i; |
| 1459 | |
| 1460 | tempal = pVBInfo->LCDResInfo; |
| 1461 | tempah = pVBInfo->LCDTypeInfo; |
| 1462 | |
| 1463 | i = 0; |
| 1464 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1465 | |
| 1466 | while (tempbl != 0xFF) { |
| 1467 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 1468 | tempal = tempah; |
| 1469 | tempbl &= ~0x80; |
| 1470 | } |
| 1471 | |
| 1472 | if (tempal == tempbl) |
| 1473 | break; |
| 1474 | |
| 1475 | i++; |
| 1476 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1477 | } |
| 1478 | |
| 1479 | if (tempbl == 0xFF) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1480 | pVBInfo->LCDResInfo = Panel_1024x768; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1481 | pVBInfo->LCDTypeInfo = 0; |
| 1482 | i = 0; |
| 1483 | } |
| 1484 | |
| 1485 | return i; |
| 1486 | } |
| 1487 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1488 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 1489 | unsigned short *VSyncWidth, |
| 1490 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1491 | { |
| 1492 | unsigned short Index; |
| 1493 | |
| 1494 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 1495 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 1496 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
| 1497 | |
| 1498 | return; |
| 1499 | } |
| 1500 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1501 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1502 | unsigned short RefreshRateTableIndex, |
| 1503 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1504 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1505 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 1506 | unsigned long temp, temp1, temp2, temp3, push3; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1507 | struct XGI_LCDDesStruct const *LCDPtr = NULL; |
| 1508 | struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1509 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1510 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 1511 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1512 | LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, |
| 1513 | ModeIdIndex, RefreshRateTableIndex, |
| 1514 | pVBInfo); |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 1515 | else |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1516 | LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, |
| 1517 | ModeIdIndex, RefreshRateTableIndex, |
| 1518 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1519 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1520 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 1521 | push1 = tempbx; |
| 1522 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1523 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1524 | /* GetLCDResInfo */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1525 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1526 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1527 | tempax = 1024; |
| 1528 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1529 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1530 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1531 | tempax = 1280; |
| 1532 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1533 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1534 | tempax = 1400; |
| 1535 | tempbx = 1050; |
| 1536 | } else { |
| 1537 | tempax = 1600; |
| 1538 | tempbx = 1200; |
| 1539 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1540 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1541 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 1542 | pVBInfo->HDE = tempax; |
| 1543 | pVBInfo->VDE = tempbx; |
| 1544 | pVBInfo->VGAHDE = tempax; |
| 1545 | pVBInfo->VGAVDE = tempbx; |
| 1546 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1547 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1548 | tempax = pVBInfo->HT; |
| 1549 | |
| 1550 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1551 | tempbx = LCDPtr1->LCDHDES; |
| 1552 | else |
| 1553 | tempbx = LCDPtr->LCDHDES; |
| 1554 | |
| 1555 | tempcx = pVBInfo->HDE; |
| 1556 | tempbx = tempbx & 0x0fff; |
| 1557 | tempcx += tempbx; |
| 1558 | |
| 1559 | if (tempcx >= tempax) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1560 | tempcx -= tempax; |
| 1561 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1562 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1563 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1564 | tempcx = tempcx >> 3; |
| 1565 | tempbx = tempbx >> 3; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1566 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1567 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 1568 | (unsigned short) (tempbx & 0xff)); |
| 1569 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 1570 | (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1571 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1572 | tempax = pVBInfo->HT; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1573 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1574 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1575 | tempbx = LCDPtr1->LCDHRS; |
| 1576 | else |
| 1577 | tempbx = LCDPtr->LCDHRS; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1578 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1579 | tempcx = push2; |
| 1580 | |
| 1581 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1582 | tempcx = LCDPtr1->LCDHSync; |
| 1583 | |
| 1584 | tempcx += tempbx; |
| 1585 | |
| 1586 | if (tempcx >= tempax) |
| 1587 | tempcx -= tempax; |
| 1588 | |
| 1589 | tempax = tempbx & 0x07; |
| 1590 | tempax = tempax >> 5; |
| 1591 | tempcx = tempcx >> 3; |
| 1592 | tempbx = tempbx >> 3; |
| 1593 | |
| 1594 | tempcx &= 0x1f; |
| 1595 | tempax |= tempcx; |
| 1596 | |
| 1597 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 1598 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 1599 | (unsigned short) (tempbx & 0xff)); |
| 1600 | |
| 1601 | tempax = pVBInfo->VT; |
| 1602 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1603 | tempbx = LCDPtr1->LCDVDES; |
| 1604 | else |
| 1605 | tempbx = LCDPtr->LCDVDES; |
| 1606 | tempcx = pVBInfo->VDE; |
| 1607 | |
| 1608 | tempbx = tempbx & 0x0fff; |
| 1609 | tempcx += tempbx; |
| 1610 | if (tempcx >= tempax) |
| 1611 | tempcx -= tempax; |
| 1612 | |
| 1613 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 1614 | (unsigned short) (tempbx & 0xff)); |
| 1615 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 1616 | (unsigned short) (tempcx & 0xff)); |
| 1617 | |
| 1618 | tempbx = (tempbx >> 8) & 0x07; |
| 1619 | tempcx = (tempcx >> 8) & 0x07; |
| 1620 | |
| 1621 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 1622 | (unsigned short) ((tempcx << 3) |
| 1623 | | tempbx)); |
| 1624 | |
| 1625 | tempax = pVBInfo->VT; |
| 1626 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1627 | tempbx = LCDPtr1->LCDVRS; |
| 1628 | else |
| 1629 | tempbx = LCDPtr->LCDVRS; |
| 1630 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1631 | tempcx = push1; |
| 1632 | |
| 1633 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1634 | tempcx = LCDPtr1->LCDVSync; |
| 1635 | |
| 1636 | tempcx += tempbx; |
| 1637 | if (tempcx >= tempax) |
| 1638 | tempcx -= tempax; |
| 1639 | |
| 1640 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 1641 | (unsigned short) (tempbx & 0xff)); |
| 1642 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 1643 | (unsigned short) (tempcx & 0x0f)); |
| 1644 | |
| 1645 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 1646 | |
| 1647 | tempbx = pVBInfo->VGAVDE; |
| 1648 | if (tempbx != pVBInfo->VDE) |
| 1649 | tempax |= 0x40; |
| 1650 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1651 | if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1652 | tempax |= 0x40; |
| 1653 | |
| 1654 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 1655 | tempax); |
| 1656 | |
| 1657 | tempcx = pVBInfo->VGAVT; |
| 1658 | tempbx = pVBInfo->VDE; |
| 1659 | tempax = pVBInfo->VGAVDE; |
| 1660 | tempcx -= tempax; |
| 1661 | |
| 1662 | temp = tempax; /* 0430 ylshieh */ |
| 1663 | temp1 = (temp << 18) / tempbx; |
| 1664 | |
| 1665 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 1666 | |
| 1667 | if (tempdx != 0) |
| 1668 | temp1 += 1; |
| 1669 | |
| 1670 | temp2 = temp1; |
| 1671 | push3 = temp2; |
| 1672 | |
| 1673 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 1674 | (unsigned short) (temp2 & 0xff)); |
| 1675 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 1676 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 1677 | |
| 1678 | tempbx = (unsigned short) (temp2 >> 16); |
| 1679 | tempax = tempbx & 0x03; |
| 1680 | |
| 1681 | tempbx = pVBInfo->VGAVDE; |
| 1682 | if (tempbx == pVBInfo->VDE) |
| 1683 | tempax |= 0x04; |
| 1684 | |
| 1685 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 1686 | |
| 1687 | if (pVBInfo->VBType & VB_XGI301C) { |
| 1688 | temp2 = push3; |
| 1689 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1690 | 0x3c, |
| 1691 | (unsigned short) (temp2 & 0xff)); |
| 1692 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1693 | 0x3b, |
| 1694 | (unsigned short) ((temp2 >> 8) & |
| 1695 | 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1696 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1697 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 1698 | ~0xc0, |
| 1699 | (unsigned short) ((tempbx & |
| 1700 | 0xff) << 6)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1701 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1702 | tempcx = pVBInfo->VGAVDE; |
| 1703 | if (tempcx == pVBInfo->VDE) |
| 1704 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1705 | 0x30, ~0x0c, 0x00); |
| 1706 | else |
| 1707 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1708 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1709 | } |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1710 | |
| 1711 | tempcx = pVBInfo->VGAHDE; |
| 1712 | tempbx = pVBInfo->HDE; |
| 1713 | |
| 1714 | temp1 = tempcx << 16; |
| 1715 | |
| 1716 | tempax = (unsigned short) (temp1 / tempbx); |
| 1717 | |
| 1718 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 1719 | tempax = 65535; |
| 1720 | |
| 1721 | temp3 = tempax; |
| 1722 | temp1 = pVBInfo->VGAHDE << 16; |
| 1723 | |
| 1724 | temp1 /= temp3; |
| 1725 | temp3 = temp3 << 16; |
| 1726 | temp1 -= 1; |
| 1727 | |
| 1728 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 1729 | |
| 1730 | tempax = (unsigned short) (temp3 & 0xff); |
| 1731 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 1732 | |
| 1733 | temp1 = pVBInfo->VGAVDE << 18; |
| 1734 | temp1 = temp1 / push3; |
| 1735 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 1736 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1737 | if (pVBInfo->LCDResInfo == Panel_1024x768) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1738 | tempbx -= 1; |
| 1739 | |
| 1740 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 1741 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 1742 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 1743 | (unsigned short) (tempax & 0xff)); |
| 1744 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 1745 | (unsigned short) (tempbx & 0xff)); |
| 1746 | |
| 1747 | temp3 = temp3 >> 16; |
| 1748 | |
| 1749 | if (modeflag & HalfDCLK) |
| 1750 | temp3 = temp3 >> 1; |
| 1751 | |
| 1752 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 1753 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 1754 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 1755 | (unsigned short) (temp3 & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1756 | } |
| 1757 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1758 | /* --------------------------------------------------------------------- */ |
| 1759 | /* Function : XGI_GETLCDVCLKPtr */ |
| 1760 | /* Input : */ |
| 1761 | /* Output : al -> VCLK Index */ |
| 1762 | /* Description : */ |
| 1763 | /* --------------------------------------------------------------------- */ |
| 1764 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 1765 | struct vb_device_info *pVBInfo) |
| 1766 | { |
| 1767 | unsigned short index; |
| 1768 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1769 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1770 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 1771 | |
| 1772 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 1773 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 1774 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 1775 | } else { /* LCDA */ |
| 1776 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 1777 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 1778 | } |
| 1779 | } |
| 1780 | return; |
| 1781 | } |
| 1782 | |
| 1783 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
| 1784 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1785 | struct vb_device_info *pVBInfo) |
| 1786 | { |
| 1787 | |
| 1788 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1789 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1790 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1791 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1792 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1793 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1794 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 1795 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1796 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 1797 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 1798 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1799 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1800 | return tempal; |
| 1801 | |
| 1802 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1803 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1804 | (VB_SIS301B | |
| 1805 | VB_SIS302B | |
| 1806 | VB_SIS301LV | |
| 1807 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1808 | VB_XGI301C)) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1809 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1810 | tempal = TVCLKBASE_315 + HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1811 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1812 | tempal = TVCLKBASE_315 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1813 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1814 | tempal = TVCLKBASE_315 + HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1815 | if (!(modeflag & Charx8Dot)) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1816 | tempal = TVCLKBASE_315 + |
| 1817 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1818 | |
| 1819 | } |
| 1820 | return tempal; |
| 1821 | } |
| 1822 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1823 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1824 | tempal = XGI_YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1825 | return tempal; |
| 1826 | } |
| 1827 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1828 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1829 | tempal = YPbPr525pVCLK; |
| 1830 | return tempal; |
| 1831 | } |
| 1832 | |
| 1833 | tempal = NTSC1024VCLK; |
| 1834 | |
| 1835 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1836 | tempal = TVCLKBASE_315 + TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1837 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1838 | tempal = TVCLKBASE_315 + TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1839 | } |
| 1840 | |
| 1841 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 1842 | return tempal; |
| 1843 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1844 | } /* {End of VB} */ |
| 1845 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1846 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1847 | tempal = tempal >> 2; |
| 1848 | tempal &= 0x03; |
| 1849 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1850 | /* for Dot8 Scaling LCD */ |
| 1851 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1852 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
| 1853 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1854 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1855 | return tempal; |
| 1856 | } |
| 1857 | |
| 1858 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 1859 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 1860 | { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1861 | if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B |
| 1862 | | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1863 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
| 1864 | (pVBInfo->SetFlag & ProgrammingCRT2)) { |
Aaro Koskinen | e8cb03d | 2012-09-11 00:15:31 +0300 | [diff] [blame] | 1865 | *di_0 = XGI_VBVCLKData[tempal].Part4_A; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1866 | *di_1 = XGI_VBVCLKData[tempal].Part4_B; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1867 | } |
| 1868 | } else { |
| 1869 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 1870 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 1871 | } |
| 1872 | } |
| 1873 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1874 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1875 | unsigned short RefreshRateTableIndex, |
| 1876 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1877 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1878 | unsigned char di_0, di_1, tempal; |
| 1879 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1880 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1881 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 1882 | pVBInfo); |
| 1883 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 1884 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1885 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1886 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1887 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1888 | (unsigned short) (0x10 * i)); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1889 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1890 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1891 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 1892 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1893 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1894 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 1895 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1896 | } |
| 1897 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1898 | } |
| 1899 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1900 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1901 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1902 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1903 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1904 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1905 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 1906 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1907 | tempcl = 0; |
| 1908 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1909 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1910 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1911 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1912 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1913 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1914 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1915 | if (!(temp & 0x40)) |
| 1916 | tempcl |= ActiveCRT1; |
| 1917 | } |
| 1918 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1919 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1920 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1921 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1922 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1923 | if (!(temp == 0x08)) { |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1924 | /* Check ChannelA */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1925 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1926 | if (tempax & 0x04) |
| 1927 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1928 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1929 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1930 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1931 | if (!(tempcl & ActiveLCD)) |
| 1932 | if (temp == 0x01) |
| 1933 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1934 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1935 | if (temp == 0x04) |
| 1936 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1937 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1938 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1939 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1940 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1941 | if (!(temp & 0x08)) |
| 1942 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1943 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1944 | if (!(temp & 0x04)) |
| 1945 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1946 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1947 | if (temp & 0x02) |
| 1948 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1949 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1950 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1951 | if (temp & 0x01) |
| 1952 | tempch |= ActiveHiTV; |
| 1953 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1954 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1955 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1956 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1957 | pVBInfo->Part2Port, |
| 1958 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1959 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1960 | if (temp & 0x10) |
| 1961 | tempch |= ActiveYPbPr; |
| 1962 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1963 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1964 | if (tempch != 0) |
| 1965 | tempcl |= ActiveTV; |
| 1966 | } |
| 1967 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1968 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1969 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1970 | if (tempcl & ActiveLCD) { |
| 1971 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 1972 | if (temp & ActiveTV) |
| 1973 | tempcl |= ActiveTV; |
| 1974 | } |
| 1975 | } |
| 1976 | temp = tempcl; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1977 | tempbl = ~XGI_ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1978 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1979 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1980 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1981 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1982 | } else { |
| 1983 | return; |
| 1984 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1985 | } |
| 1986 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 1987 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1988 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1989 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1990 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1991 | if (pVBInfo->IF_DEF_LVDS != 0) |
| 1992 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1993 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1994 | tempbx = VB_SIS302B; |
| 1995 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
| 1996 | if (flag == 0x02) |
| 1997 | goto finish; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1998 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1999 | tempbx = VB_SIS301; |
| 2000 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
| 2001 | if (flag < 0xB0) |
| 2002 | goto finish; |
| 2003 | |
| 2004 | tempbx = VB_SIS301B; |
| 2005 | if (flag < 0xC0) |
| 2006 | goto bigger_than_0xB0; |
| 2007 | |
| 2008 | tempbx = VB_XGI301C; |
| 2009 | if (flag < 0xD0) |
| 2010 | goto bigger_than_0xB0; |
| 2011 | |
| 2012 | tempbx = VB_SIS301LV; |
| 2013 | if (flag < 0xE0) |
| 2014 | goto bigger_than_0xB0; |
| 2015 | |
| 2016 | tempbx = VB_SIS302LV; |
| 2017 | tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39); |
| 2018 | if (tempah != 0xFF) |
| 2019 | tempbx = VB_XGI301C; |
| 2020 | |
| 2021 | bigger_than_0xB0: |
| 2022 | if (tempbx & (VB_SIS301B | VB_SIS302B)) { |
| 2023 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23); |
| 2024 | if (!(flag & 0x02)) |
| 2025 | tempbx = tempbx | VB_NoLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2026 | } |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 2027 | |
| 2028 | finish: |
| 2029 | pVBInfo->VBType = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2030 | } |
| 2031 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2032 | static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2033 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2034 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2035 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2036 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2037 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2038 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2039 | pVBInfo->SetFlag = 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2040 | pVBInfo->ModeType = modeflag & ModeTypeMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2041 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2042 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2043 | if (!(pVBInfo->VBType & 0xFFFF)) |
| 2044 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2045 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2046 | /* Check Display Device */ |
| 2047 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
| 2048 | tempbx = tempbx | temp; |
| 2049 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
| 2050 | push = temp; |
| 2051 | push = push << 8; |
| 2052 | tempax = temp << 8; |
| 2053 | tempbx = tempbx | tempax; |
| 2054 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA |
| 2055 | | SetInSlaveMode | DisableCRT2Display); |
| 2056 | temp = 0xFFFF ^ temp; |
| 2057 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2058 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2059 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2060 | |
Aaro Koskinen | 4d8f5ca | 2012-09-11 00:15:17 +0300 | [diff] [blame] | 2061 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2062 | if (pVBInfo->VBType & |
| 2063 | (VB_SIS302B | |
| 2064 | VB_SIS301LV | |
| 2065 | VB_SIS302LV | |
| 2066 | VB_XGI301C)) { |
| 2067 | if (temp & EnableDualEdge) { |
| 2068 | tempbx |= SetCRT2ToDualEdge; |
| 2069 | if (temp & SetToLCDA) |
| 2070 | tempbx |= XGI_SetCRT2ToLCDA; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2071 | } |
| 2072 | } |
| 2073 | } |
| 2074 | |
| 2075 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 2076 | if (((pVBInfo->IF_DEF_LVDS == 0) && |
| 2077 | ((pVBInfo->VBType & VB_SIS301LV) || |
| 2078 | (pVBInfo->VBType & VB_SIS302LV) || |
| 2079 | (pVBInfo->VBType & VB_XGI301C)))) { |
| 2080 | if (temp & SetYPbPr) { |
| 2081 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2082 | /* shampoo add for new |
| 2083 | * scratch */ |
| 2084 | temp = xgifb_reg_get( |
| 2085 | pVBInfo->P3d4, |
| 2086 | 0x35); |
| 2087 | temp &= YPbPrMode; |
| 2088 | tempbx |= SetCRT2ToHiVision; |
| 2089 | |
| 2090 | if (temp != YPbPrMode1080i) { |
| 2091 | tempbx &= |
| 2092 | (~SetCRT2ToHiVision); |
| 2093 | tempbx |= |
| 2094 | SetCRT2ToYPbPr525750; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2095 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2096 | } |
| 2097 | } |
| 2098 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2099 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2100 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2101 | tempax = push; /* restore CR31 */ |
| 2102 | |
| 2103 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2104 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2105 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 2106 | temp = 0x09FC; |
| 2107 | else |
| 2108 | temp = 0x097C; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2109 | } else if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2110 | temp = 0x01FC; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2111 | } else { |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2112 | temp = 0x017C; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2113 | } |
Justin P. Mattock | 558f758 | 2012-10-02 21:17:11 -0700 | [diff] [blame] | 2114 | } else { /* 3rd party chip */ |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2115 | temp = SetCRT2ToLCD; |
| 2116 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2117 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2118 | if (!(tempbx & temp)) { |
| 2119 | tempax |= DisableCRT2Display; |
| 2120 | tempbx = 0; |
| 2121 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2122 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2123 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 2124 | if (tempbx & XGI_SetCRT2ToLCDA) { |
| 2125 | if (tempbx & SetSimuScanMode) |
| 2126 | tempbx &= (~(SetCRT2ToLCD | |
| 2127 | SetCRT2ToRAMDAC | |
| 2128 | SwitchCRT2)); |
| 2129 | else |
| 2130 | tempbx &= (~(SetCRT2ToLCD | |
| 2131 | SetCRT2ToRAMDAC | |
| 2132 | SetCRT2ToTV | |
| 2133 | SwitchCRT2)); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2134 | } |
| 2135 | } |
| 2136 | |
| 2137 | /* shampoo add */ |
| 2138 | /* for driver abnormal */ |
| 2139 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { |
| 2140 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 2141 | if (tempbx & SetCRT2ToRAMDAC) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2142 | tempbx &= (0xFF00 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2143 | SetCRT2ToRAMDAC | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2144 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2145 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2146 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2147 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2148 | } else { |
| 2149 | tempbx &= (~(SetCRT2ToRAMDAC | |
| 2150 | SetCRT2ToLCD | |
| 2151 | SetCRT2ToTV)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2152 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2153 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2154 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2155 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 2156 | if (tempbx & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2157 | tempbx &= (0xFF00 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2158 | SetCRT2ToLCD | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2159 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2160 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2161 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2162 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2163 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2164 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2165 | if (tempbx & SetCRT2ToSCART) { |
| 2166 | tempbx &= (0xFF00 | |
| 2167 | SetCRT2ToSCART | |
| 2168 | SwitchCRT2 | |
| 2169 | SetSimuScanMode); |
| 2170 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
| 2171 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2172 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2173 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 2174 | if (tempbx & SetCRT2ToYPbPr525750) |
| 2175 | tempbx &= (0xFF00 | |
| 2176 | SwitchCRT2 | |
| 2177 | SetSimuScanMode); |
| 2178 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2179 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2180 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2181 | if (tempbx & SetCRT2ToHiVision) |
| 2182 | tempbx &= (0xFF00 | |
| 2183 | SetCRT2ToHiVision | |
| 2184 | SwitchCRT2 | |
| 2185 | SetSimuScanMode); |
| 2186 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2187 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2188 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 2189 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) |
| 2190 | tempbx = DisableCRT2Display; |
| 2191 | } |
| 2192 | |
| 2193 | if (!(tempbx & DisableCRT2Display)) { |
| 2194 | if ((!(tempbx & DriverMode)) || |
| 2195 | (!(modeflag & CRT2Mode))) { |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2196 | if (!(tempbx & XGI_SetCRT2ToLCDA)) |
| 2197 | tempbx |= (SetInSlaveMode | |
| 2198 | SetSimuScanMode); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2199 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2200 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2201 | /* LCD+TV can't support in slave mode |
| 2202 | * (Force LCDA+TV->LCDB) */ |
| 2203 | if ((tempbx & SetInSlaveMode) && |
| 2204 | (tempbx & XGI_SetCRT2ToLCDA)) { |
| 2205 | tempbx ^= (SetCRT2ToLCD | |
| 2206 | XGI_SetCRT2ToLCDA | |
| 2207 | SetCRT2ToDualEdge); |
| 2208 | pVBInfo->SetFlag |= ReserveTVOption; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2209 | } |
| 2210 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2211 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2212 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2213 | } |
| 2214 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2215 | static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2216 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2217 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2218 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2219 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2220 | tempbx = 0; |
| 2221 | resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2222 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2223 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2224 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2225 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2226 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2227 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2228 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2229 | tempbx = temp; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2230 | if (tempbx & TVSetPAL) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2231 | tempbx &= (SetCHTVOverScan | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2232 | TVSetPALM | |
| 2233 | TVSetPALN | |
| 2234 | TVSetPAL); |
| 2235 | if (tempbx & TVSetPALM) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2236 | /* set to NTSC if PAL-M */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2237 | tempbx &= ~TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2238 | } else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2239 | tempbx &= (SetCHTVOverScan | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2240 | TVSetNTSCJ | |
| 2241 | TVSetPAL); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2242 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2243 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2244 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 2245 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2246 | tempbx |= TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2247 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2248 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2249 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2250 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2251 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2252 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2253 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2254 | if (index1 == YPbPrMode525i) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2255 | tempbx |= TVSetYPbPr525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2256 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2257 | if (index1 == YPbPrMode525p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2258 | tempbx = tempbx | TVSetYPbPr525p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2259 | if (index1 == YPbPrMode750p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2260 | tempbx = tempbx | TVSetYPbPr750p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2261 | } |
| 2262 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2263 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2264 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2265 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
| 2266 | tempbx = tempbx | TVSetHiVision | TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2267 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2268 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2269 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2270 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 2271 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2272 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2273 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2274 | if (!(tempbx & TVSetPAL) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2275 | (modeflag > 13) && |
| 2276 | (resinfo == 8)) /* NTSC 1024x768, */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2277 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2278 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2279 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2280 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2281 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2282 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2283 | tempbx &= (~RPLLDIV2XO); |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2284 | } else if (tempbx & |
| 2285 | (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2286 | tempbx &= (~RPLLDIV2XO); |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2287 | } else if (!(pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2288 | (VB_SIS301B | |
| 2289 | VB_SIS302B | |
| 2290 | VB_SIS301LV | |
| 2291 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2292 | VB_XGI301C))) { |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2293 | if (tempbx & TVSimuMode) |
| 2294 | tempbx &= (~RPLLDIV2XO); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2295 | } |
| 2296 | } |
| 2297 | } |
| 2298 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2299 | } |
| 2300 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2301 | static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, |
| 2302 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2303 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2304 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2305 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2306 | pVBInfo->LCDResInfo = 0; |
| 2307 | pVBInfo->LCDTypeInfo = 0; |
| 2308 | pVBInfo->LCDInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2309 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2310 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2311 | /* si+Ext_ResInfo // */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2312 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2313 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2314 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2315 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2316 | if (tempbx == 0) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2317 | tempbx = Panel_1024x768; /* default */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2318 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 2319 | /* LCD75 */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2320 | if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2321 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2322 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2323 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2324 | tempax &= 0x0F; |
| 2325 | else |
| 2326 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2327 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2328 | if ((resinfo == 6) || (resinfo == 9)) { |
| 2329 | if (tempax >= 3) |
| 2330 | tempbx |= PanelRef75Hz; |
| 2331 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 2332 | if (tempax >= 4) |
| 2333 | tempbx |= PanelRef75Hz; |
| 2334 | } |
| 2335 | } |
| 2336 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2337 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2338 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2339 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2340 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2341 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2342 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2343 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2344 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2345 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2346 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2347 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2348 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2349 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2350 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2351 | tempbx |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2352 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2353 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2354 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2355 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2356 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2357 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2358 | if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2359 | & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2360 | tempbx |= SetLCDDualLink; |
| 2361 | } |
| 2362 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2363 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2364 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2365 | if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2366 | & SetCRT2ToLCD) && (resinfo == 9) && |
| 2367 | (!(tempbx & EnableScalingLCD))) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 2368 | /* |
| 2369 | * set to center in 1280x1024 LCDB |
| 2370 | * for Panel_1400x1050 |
| 2371 | */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2372 | tempbx |= SetLCDtoNonExpanding; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2373 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2374 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2375 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2376 | if (pVBInfo->VBInfo & SetNotSimuMode) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2377 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2378 | } else { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2379 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2380 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2381 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2382 | pVBInfo->LCDInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2383 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2384 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2385 | } |
| 2386 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2387 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2388 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2389 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2390 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2391 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2392 | break; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2393 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2394 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2395 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2396 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2397 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2398 | } |
| 2399 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2400 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 2401 | { |
| 2402 | unsigned char ujRet = 0; |
| 2403 | unsigned char i = 0; |
| 2404 | |
| 2405 | for (i = 0; i < 8; i++) { |
| 2406 | ujRet = ujRet << 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2407 | ujRet |= (ujDate >> i) & 1; |
| 2408 | } |
| 2409 | |
| 2410 | return ujRet; |
| 2411 | } |
| 2412 | |
| 2413 | /*----------------------------------------------------------------------------*/ |
| 2414 | /* output */ |
| 2415 | /* bl[5] : LVDS signal */ |
| 2416 | /* bl[1] : LVDS backlight */ |
| 2417 | /* bl[0] : LVDS VDD */ |
| 2418 | /*----------------------------------------------------------------------------*/ |
| 2419 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 2420 | { |
| 2421 | unsigned char CR4A, temp; |
| 2422 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2423 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2424 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2425 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2426 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2427 | |
| 2428 | temp = XG21GPIODataTransfer(temp); |
| 2429 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2430 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2431 | return temp; |
| 2432 | } |
| 2433 | |
| 2434 | /*----------------------------------------------------------------------------*/ |
| 2435 | /* output */ |
| 2436 | /* bl[5] : LVDS signal */ |
| 2437 | /* bl[1] : LVDS backlight */ |
| 2438 | /* bl[0] : LVDS VDD */ |
| 2439 | /*----------------------------------------------------------------------------*/ |
| 2440 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 2441 | { |
| 2442 | unsigned char CR4A, CRB4, temp; |
| 2443 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2444 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2445 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2446 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2447 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2448 | |
| 2449 | temp &= 0x0C; |
| 2450 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2451 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2452 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2453 | temp |= ((CRB4 & 0x04) << 3); |
| 2454 | return temp; |
| 2455 | } |
| 2456 | |
Aaro Koskinen | 0ebf538 | 2011-11-27 23:03:09 +0200 | [diff] [blame] | 2457 | /*----------------------------------------------------------------------------*/ |
| 2458 | /* input */ |
| 2459 | /* bl[5] : 1;LVDS signal on */ |
| 2460 | /* bl[1] : 1;LVDS backlight on */ |
| 2461 | /* bl[0] : 1:LVDS VDD on */ |
| 2462 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 2463 | /* 000010b : clear bit 1, to set bit1 */ |
| 2464 | /* 000001b : clear bit 0, to set bit0 */ |
| 2465 | /*----------------------------------------------------------------------------*/ |
| 2466 | static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2467 | struct vb_device_info *pVBInfo) |
| 2468 | { |
| 2469 | unsigned char CR4A, temp; |
| 2470 | |
| 2471 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2472 | tempbh &= 0x23; |
| 2473 | tempbl &= 0x23; |
| 2474 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2475 | |
| 2476 | if (tempbh & 0x20) { |
| 2477 | temp = (tempbl >> 4) & 0x02; |
| 2478 | |
| 2479 | /* CR B4[1] */ |
| 2480 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2481 | |
| 2482 | } |
| 2483 | |
| 2484 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
| 2485 | |
| 2486 | temp = XG21GPIODataTransfer(temp); |
| 2487 | temp &= ~tempbh; |
| 2488 | temp |= tempbl; |
| 2489 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
| 2490 | } |
| 2491 | |
Aaro Koskinen | 776115a | 2011-11-27 23:03:10 +0200 | [diff] [blame] | 2492 | static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2493 | struct vb_device_info *pVBInfo) |
| 2494 | { |
| 2495 | unsigned char CR4A, temp; |
| 2496 | unsigned short tempbh0, tempbl0; |
| 2497 | |
| 2498 | tempbh0 = tempbh; |
| 2499 | tempbl0 = tempbl; |
| 2500 | tempbh0 &= 0x20; |
| 2501 | tempbl0 &= 0x20; |
| 2502 | tempbh0 >>= 3; |
| 2503 | tempbl0 >>= 3; |
| 2504 | |
| 2505 | if (tempbh & 0x20) { |
| 2506 | temp = (tempbl >> 4) & 0x02; |
| 2507 | |
| 2508 | /* CR B4[1] */ |
| 2509 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2510 | |
| 2511 | } |
| 2512 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
| 2513 | |
| 2514 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2515 | tempbh &= 0x03; |
| 2516 | tempbl &= 0x03; |
| 2517 | tempbh <<= 2; |
| 2518 | tempbl <<= 2; /* GPIOC,GPIOD */ |
| 2519 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2520 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
| 2521 | } |
| 2522 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2523 | static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info, |
| 2524 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2525 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2526 | { |
| 2527 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2528 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2529 | if (pXGIHWDE->jChipType == XG21) { |
| 2530 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2531 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2532 | /* LVDS VDD on */ |
| 2533 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2534 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2535 | } |
| 2536 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2537 | /* LVDS signal on */ |
| 2538 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2539 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2540 | /* LVDS backlight on */ |
| 2541 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2542 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2543 | /* DVO/DVI signal on */ |
| 2544 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2545 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2546 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2547 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2548 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2549 | if (pXGIHWDE->jChipType == XG27) { |
| 2550 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2551 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2552 | /* LVDS VDD on */ |
| 2553 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2554 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2555 | } |
| 2556 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2557 | /* LVDS signal on */ |
| 2558 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2559 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2560 | /* LVDS backlight on */ |
| 2561 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2562 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2563 | /* DVO/DVI signal on */ |
| 2564 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2565 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2566 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2567 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2568 | } |
| 2569 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2570 | void XGI_DisplayOff(struct xgifb_video_info *xgifb_info, |
| 2571 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2572 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2573 | { |
| 2574 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2575 | if (pXGIHWDE->jChipType == XG21) { |
| 2576 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2577 | /* LVDS backlight off */ |
| 2578 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2579 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2580 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2581 | /* DVO/DVI signal off */ |
| 2582 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2583 | } |
| 2584 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2585 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2586 | if (pXGIHWDE->jChipType == XG27) { |
| 2587 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2588 | /* LVDS backlight off */ |
| 2589 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2590 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2591 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2592 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2593 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2594 | /* DVO/DVI signal off */ |
| 2595 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2596 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2597 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2598 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2599 | } |
| 2600 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2601 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2602 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2603 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2604 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2605 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2606 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2607 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2608 | } |
| 2609 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2610 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2611 | { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2612 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2613 | } |
| 2614 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2615 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 2616 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2617 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2618 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2619 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2620 | /* reserve CR34 for CRT1 Mode No */ |
| 2621 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2622 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 2623 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2624 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2625 | } |
| 2626 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2627 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
| 2628 | unsigned short ModeIdIndex, |
| 2629 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2630 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2631 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2632 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2633 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2634 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 2635 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
| 2636 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2637 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2638 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2639 | if (modeflag & HalfDCLK) |
| 2640 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2641 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2642 | if (modeflag & DoubleScanMode) |
| 2643 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2644 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2645 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 2646 | goto exit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2647 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2648 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 2649 | if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
| 2650 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2651 | if (yres == 1024) |
| 2652 | yres = 1056; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2653 | } |
| 2654 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2655 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2656 | if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
| 2657 | if (yres == 400) |
| 2658 | yres = 405; |
| 2659 | else if (yres == 350) |
| 2660 | yres = 360; |
| 2661 | |
| 2662 | if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { |
| 2663 | if (yres == 360) |
| 2664 | yres = 375; |
| 2665 | } |
| 2666 | } |
| 2667 | |
| 2668 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
| 2669 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2670 | if (!(pVBInfo->LCDInfo & LCDNonExpanding)) { |
| 2671 | if (yres == 350) |
| 2672 | yres = 357; |
| 2673 | else if (yres == 400) |
| 2674 | yres = 420; |
| 2675 | else if (yres == 480) |
| 2676 | yres = 525; |
| 2677 | } |
| 2678 | } |
| 2679 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2680 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2681 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2682 | if (xres == 720) |
| 2683 | xres = 640; |
| 2684 | |
| 2685 | exit: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2686 | pVBInfo->VGAHDE = xres; |
| 2687 | pVBInfo->HDE = xres; |
| 2688 | pVBInfo->VGAVDE = yres; |
| 2689 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2690 | } |
| 2691 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2692 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2693 | { |
| 2694 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2695 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) && |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 2696 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2697 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2698 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2699 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2700 | } |
| 2701 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2702 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
| 2703 | unsigned short ModeIdIndex, |
| 2704 | unsigned short RefreshRateTableIndex, |
| 2705 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2706 | { |
| 2707 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2708 | CRT1Index; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2709 | |
| 2710 | pVBInfo->RVBHCMAX = 1; |
| 2711 | pVBInfo->RVBHCFACT = 1; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2712 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2713 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2714 | CRT1Index &= IndexMask; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2715 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[0]; |
| 2716 | temp2 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2717 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2718 | tempbx = (unsigned short) XGI_CRT1Table[CRT1Index].CR[8]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2719 | tempcx = (unsigned short) |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2720 | XGI_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2721 | tempcx &= 0x0100; |
| 2722 | tempcx = tempcx << 2; |
| 2723 | tempbx |= tempcx; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2724 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2725 | |
| 2726 | if (temp1 & 0x01) |
| 2727 | tempbx |= 0x0100; |
| 2728 | |
| 2729 | if (temp1 & 0x20) |
| 2730 | tempbx |= 0x0200; |
| 2731 | tempax += 5; |
| 2732 | |
| 2733 | if (modeflag & Charx8Dot) |
| 2734 | tempax *= 8; |
| 2735 | else |
| 2736 | tempax *= 9; |
| 2737 | |
| 2738 | pVBInfo->VGAHT = tempax; |
| 2739 | pVBInfo->HT = tempax; |
| 2740 | tempbx++; |
| 2741 | pVBInfo->VGAVT = tempbx; |
| 2742 | pVBInfo->VT = tempbx; |
| 2743 | } |
| 2744 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2745 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2746 | unsigned short RefreshRateTableIndex, |
| 2747 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2748 | { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 2749 | unsigned short tempax = 0, tempbx = 0, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2750 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 2751 | struct SiS_LCDData const *LCDPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2752 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2753 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2754 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2755 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2756 | pVBInfo->NewFlickerMode = 0; |
| 2757 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2758 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2759 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 2760 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2761 | pVBInfo); |
| 2762 | return; |
| 2763 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2764 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2765 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 2766 | LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeNo, ModeIdIndex, |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 2767 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2768 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2769 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 2770 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 2771 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2772 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2773 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2774 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2775 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2776 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2777 | tempax = 1024; |
| 2778 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2779 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2780 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2781 | if (pVBInfo->VGAVDE == 357) |
| 2782 | tempbx = 527; |
| 2783 | else if (pVBInfo->VGAVDE == 420) |
| 2784 | tempbx = 620; |
| 2785 | else if (pVBInfo->VGAVDE == 525) |
| 2786 | tempbx = 775; |
| 2787 | else if (pVBInfo->VGAVDE == 600) |
| 2788 | tempbx = 775; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2789 | else |
| 2790 | tempbx = 768; |
| 2791 | } else |
| 2792 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2793 | } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2794 | tempax = 1024; |
| 2795 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2796 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2797 | tempax = 1280; |
| 2798 | if (pVBInfo->VGAVDE == 360) |
| 2799 | tempbx = 768; |
| 2800 | else if (pVBInfo->VGAVDE == 375) |
| 2801 | tempbx = 800; |
| 2802 | else if (pVBInfo->VGAVDE == 405) |
| 2803 | tempbx = 864; |
| 2804 | else |
| 2805 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2806 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2807 | tempax = 1280; |
| 2808 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2809 | } else if (pVBInfo->LCDResInfo == Panel_1280x960) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2810 | tempax = 1280; |
| 2811 | if (pVBInfo->VGAVDE == 350) |
| 2812 | tempbx = 700; |
| 2813 | else if (pVBInfo->VGAVDE == 400) |
| 2814 | tempbx = 800; |
| 2815 | else if (pVBInfo->VGAVDE == 1024) |
| 2816 | tempbx = 960; |
| 2817 | else |
| 2818 | tempbx = 960; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2819 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2820 | tempax = 1400; |
| 2821 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2822 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2823 | if (pVBInfo->VGAVDE == 1024) { |
| 2824 | tempax = 1280; |
| 2825 | tempbx = 1024; |
| 2826 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2827 | } else if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2828 | tempax = 1600; |
| 2829 | tempbx = 1200; /* alan 10/14/2003 */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2830 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2831 | if (pVBInfo->VGAVDE == 350) |
| 2832 | tempbx = 875; |
| 2833 | else if (pVBInfo->VGAVDE == 400) |
| 2834 | tempbx = 1000; |
| 2835 | } |
| 2836 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2837 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2838 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 2839 | tempax = pVBInfo->VGAHDE; |
| 2840 | tempbx = pVBInfo->VGAVDE; |
| 2841 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2842 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2843 | pVBInfo->HDE = tempax; |
| 2844 | pVBInfo->VDE = tempbx; |
| 2845 | return; |
| 2846 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2847 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2848 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 2849 | struct SiS_TVData const *TVPtr; |
| 2850 | |
| 2851 | TVPtr = XGI_GetTVPtr(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2852 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2853 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2854 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 2855 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 2856 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 2857 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 2858 | pVBInfo->HDE = TVPtr->TVHDE; |
| 2859 | pVBInfo->VDE = TVPtr->TVVDE; |
| 2860 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 2861 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2862 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2863 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2864 | if (resinfo == 0x08) |
| 2865 | pVBInfo->NewFlickerMode = 0x40; |
| 2866 | else if (resinfo == 0x09) |
| 2867 | pVBInfo->NewFlickerMode = 0x40; |
| 2868 | else if (resinfo == 0x12) |
| 2869 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2870 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2871 | if (pVBInfo->VGAVDE == 350) |
| 2872 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2873 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2874 | tempax = ExtHiTVHT; |
| 2875 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2876 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2877 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2878 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 2879 | tempax = StHiTVHT; |
| 2880 | tempbx = StHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2881 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2882 | if (!(modeflag & Charx8Dot)) { |
| 2883 | tempax = StHiTextTVHT; |
| 2884 | tempbx = StHiTextTVVT; |
| 2885 | } |
| 2886 | } |
| 2887 | } |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2888 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 2889 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2890 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 2891 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 2892 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2893 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2894 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2895 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 2896 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2897 | } else if (pVBInfo->TVInfo & TVSetYPbPr525i) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2898 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 2899 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 2900 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2901 | tempax = NTSC1024x768HT; |
| 2902 | } |
| 2903 | } else { |
| 2904 | tempax = PALHT; |
| 2905 | tempbx = PALVT; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2906 | if (!(pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2907 | tempax = NTSCHT; |
| 2908 | tempbx = NTSCVT; |
| 2909 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2910 | tempax = NTSC1024x768HT; |
| 2911 | } |
| 2912 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2913 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2914 | pVBInfo->HT = tempax; |
| 2915 | pVBInfo->VT = tempbx; |
| 2916 | return; |
| 2917 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2918 | } |
| 2919 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2920 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2921 | unsigned short RefreshRateTableIndex, |
| 2922 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2923 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2924 | unsigned char di_0, di_1, tempal; |
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 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 2927 | pVBInfo); |
| 2928 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 2929 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2930 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2931 | if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2932 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2933 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 2934 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 2935 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2936 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2937 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 2938 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2939 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2940 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2941 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
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 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2944 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2945 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2946 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2947 | } |
| 2948 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2949 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
| 2950 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2951 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2952 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 2953 | short index; |
| 2954 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2955 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2956 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2957 | index = (modeflag & ModeTypeMask) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2958 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2959 | if (index < 0) |
| 2960 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2961 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2962 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2963 | } |
| 2964 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2965 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 2966 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2967 | unsigned short RefreshRateTableIndex, |
| 2968 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2969 | struct vb_device_info *pVBInfo) |
| 2970 | { |
| 2971 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 2972 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 2973 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2974 | modeinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2975 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2976 | |
| 2977 | index = (modeinfo >> 8) & 0xFF; |
| 2978 | |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame^] | 2979 | temp = XGI330_ScreenOffset[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2980 | |
| 2981 | if (infoflag & InterlaceMode) |
| 2982 | temp = temp << 1; |
| 2983 | |
| 2984 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 2985 | |
| 2986 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 2987 | temp = ModeNo - 0x7C; |
| 2988 | colordepth = ColorDepth[temp]; |
| 2989 | temp = 0x6B; |
| 2990 | if (infoflag & InterlaceMode) |
| 2991 | temp = temp << 1; |
| 2992 | return temp * colordepth; |
| 2993 | } else { |
| 2994 | return temp * colordepth; |
| 2995 | } |
| 2996 | } |
| 2997 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2998 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 2999 | unsigned short ModeIdIndex, |
| 3000 | unsigned short RefreshRateTableIndex, |
| 3001 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3002 | struct vb_device_info *pVBInfo) |
| 3003 | { |
| 3004 | unsigned short offset; |
| 3005 | unsigned char temp; |
| 3006 | |
| 3007 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 3008 | return; |
| 3009 | |
| 3010 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3011 | HwDeviceExtension, pVBInfo); |
| 3012 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3013 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3014 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3015 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3016 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3017 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3018 | } |
| 3019 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3020 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3021 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3022 | /* threshold high ,disable auto threshold */ |
| 3023 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 3024 | /* threshold low default 04h */ |
| 3025 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3026 | } |
| 3027 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3028 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3029 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3030 | unsigned short RefreshRateTableIndex, |
| 3031 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3032 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3033 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3034 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3035 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3036 | CRT1Index &= IndexMask; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3037 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3038 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3039 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3040 | HwDeviceExtension, pVBInfo); |
| 3041 | XGI_SetCRT2FIFO(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3042 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3043 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3044 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3045 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3046 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 3047 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3048 | } |
| 3049 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3050 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3051 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3052 | unsigned short RefreshRateTableIndex, |
| 3053 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3054 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3055 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
| 3056 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3057 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3058 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3059 | CRT1Index &= IndexMask; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3060 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 3061 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3062 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3063 | /* bainy change table name */ |
| 3064 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3065 | /* BTVGA2HT 0x08,0x09 */ |
| 3066 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3067 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3068 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3069 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3070 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 3071 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3072 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3073 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 3074 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 3075 | tempcx = tempcx >> 1; |
| 3076 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 3077 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3078 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3079 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3080 | tempbx = XGI_CRT1Table[CRT1Index].CR[4]; |
| 3081 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[14] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3082 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3083 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3084 | tempcx = XGI_CRT1Table[CRT1Index].CR[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3085 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3086 | temp = XGI_CRT1Table[CRT1Index].CR[15]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3087 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 3088 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 3089 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3090 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3091 | tempbx += 4; |
| 3092 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3093 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3094 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 3095 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3096 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3097 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3098 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3099 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3100 | } else { |
| 3101 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3102 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3103 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3104 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3105 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 3106 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3107 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3108 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 3109 | pushbx = pVBInfo->VGAHDE + 16; |
| 3110 | tempcx = tempcx >> 1; |
| 3111 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 3112 | tempcx += tempbx; |
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 (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3115 | tempbx = XGI_CRT1Table[CRT1Index].CR[3]; |
| 3116 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[5] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3117 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3118 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3119 | tempcx = XGI_CRT1Table[CRT1Index].CR[4]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3120 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3121 | temp = XGI_CRT1Table[CRT1Index].CR[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3122 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 3123 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 3124 | tempbx += 16; |
| 3125 | tempcx += 16; |
| 3126 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3127 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3128 | if (tempcx > pVBInfo->VGAHT) |
| 3129 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3130 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3131 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3132 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3133 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3134 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3135 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 3136 | tempbx = pushbx; |
| 3137 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 3138 | tempax |= (tempbx & 0xFF00); |
| 3139 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3140 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3141 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3142 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3143 | tempcx = (pVBInfo->VGAVT - 1); |
| 3144 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3145 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3146 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3147 | tempbx = pVBInfo->VGAVDE - 1; |
| 3148 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3149 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3150 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 3151 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3152 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3153 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3154 | tempax = pVBInfo->VGAVDE; |
| 3155 | tempbx = pVBInfo->VGAVDE; |
| 3156 | tempcx = pVBInfo->VGAVT; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3157 | /* BTVGA2VRS 0x10,0x11 */ |
| 3158 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 3159 | /* BTVGA2VRE 0x11 */ |
| 3160 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3161 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3162 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3163 | tempbx = XGI_CRT1Table[CRT1Index].CR[10]; |
| 3164 | temp = XGI_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3165 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3166 | if (temp & 0x04) |
| 3167 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3168 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3169 | if (temp & 0x080) |
| 3170 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3171 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3172 | temp = XGI_CRT1Table[CRT1Index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3173 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3174 | if (temp & 0x08) |
| 3175 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3176 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3177 | temp = XGI_CRT1Table[CRT1Index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3178 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 3179 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3180 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3181 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3182 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3183 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 3184 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3185 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3186 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3187 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3188 | if (modeflag & DoubleScanMode) |
| 3189 | tempax |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3190 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3191 | if (modeflag & HalfDCLK) |
| 3192 | tempax |= 0x40; |
| 3193 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3194 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3195 | } |
| 3196 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3197 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 3198 | { |
| 3199 | unsigned long tempax, tempbx; |
| 3200 | |
| 3201 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 3202 | & 0xFFFF; |
| 3203 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 3204 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 3205 | |
| 3206 | return (unsigned short) tempax; |
| 3207 | } |
| 3208 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3209 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3210 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3211 | unsigned short RefreshRateTableIndex, |
| 3212 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3213 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3214 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
| 3215 | modeflag, CRT1Index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3216 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3217 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3218 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3219 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3220 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3221 | CRT1Index &= IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3222 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3223 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 3224 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3225 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3226 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3227 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3228 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3229 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3230 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3231 | modeflag |= Charx8Dot; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3232 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3233 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3234 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3235 | if (modeflag & HalfDCLK) |
| 3236 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3237 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3238 | tempax = (tempax / tempcx) - 1; |
| 3239 | tempbx |= ((tempax & 0x00FF) << 8); |
| 3240 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3241 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3242 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3243 | temp = (tempbx & 0xFF00) >> 8; |
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 (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3246 | if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3247 | | VB_SIS302LV | VB_XGI301C))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3248 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3249 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 3250 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) && |
| 3251 | !(pVBInfo->VBType & VB_SIS301LV) && (resinfo == 7)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3252 | temp -= 2; |
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 | /* 0x05 Horizontal Display Start */ |
| 3256 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 3257 | /* 0x06 Horizontal Blank end */ |
| 3258 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3259 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3260 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 3261 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3262 | tempax = pVBInfo->VGAHT; |
| 3263 | else |
| 3264 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 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 | if (tempax >= pVBInfo->VGAHT) |
| 3268 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3269 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3270 | if (modeflag & HalfDCLK) |
| 3271 | tempax = tempax >> 1; |
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 | tempax = (tempax / tempcx) - 5; |
| 3274 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3275 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3276 | temp = (tempbx & 0x00FF) - 1; |
| 3277 | if (!(modeflag & HalfDCLK)) { |
| 3278 | temp -= 6; |
| 3279 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3280 | temp -= 4; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3281 | temp -= 10; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3282 | } |
| 3283 | } |
| 3284 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3285 | tempbx = (tempbx & 0xFF00) >> 8; |
| 3286 | tempcx = (tempcx + tempbx) >> 1; |
| 3287 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3288 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3289 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3290 | temp -= 1; |
| 3291 | if (!(modeflag & HalfDCLK)) { |
| 3292 | if ((modeflag & Charx8Dot)) { |
| 3293 | temp += 4; |
| 3294 | if (pVBInfo->VGAHDE >= 800) |
| 3295 | temp -= 6; |
| 3296 | } |
| 3297 | } |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3298 | } else if (!(modeflag & HalfDCLK)) { |
| 3299 | temp -= 4; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3300 | if (pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3301 | pVBInfo->VGAHDE >= 800) { |
| 3302 | temp -= 7; |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3303 | if (pVBInfo->VGAHDE >= 1280 && |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3304 | pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3305 | (pVBInfo->LCDInfo & LCDNonExpanding)) |
| 3306 | temp += 28; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3307 | } |
| 3308 | } |
| 3309 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3310 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3311 | /* 0x07 Horizontal Retrace Start */ |
| 3312 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 3313 | /* 0x08 Horizontal Retrace End */ |
| 3314 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3315 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3316 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3317 | if (pVBInfo->TVInfo & TVSimuMode) { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3318 | if (ModeNo == 0x50) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3319 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3320 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3321 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3322 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3323 | 0x08, 0x03); |
| 3324 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3325 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3326 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3327 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3328 | 0x08, 0x02); |
| 3329 | } |
| 3330 | } |
| 3331 | } |
| 3332 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3333 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3334 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3335 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3336 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3337 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3338 | tempbx = pVBInfo->VGAVT; |
| 3339 | push1 = tempbx; |
| 3340 | tempcx = 0x121; |
| 3341 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
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 | if (tempbx == 357) |
| 3344 | tempbx = 350; |
| 3345 | if (tempbx == 360) |
| 3346 | tempbx = 350; |
| 3347 | if (tempbx == 375) |
| 3348 | tempbx = 350; |
| 3349 | if (tempbx == 405) |
| 3350 | tempbx = 400; |
| 3351 | if (tempbx == 525) |
| 3352 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3353 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3354 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3355 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3356 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3357 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3358 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3359 | if (tempbx == 350) |
| 3360 | tempbx += 5; |
| 3361 | if (tempbx == 480) |
| 3362 | tempbx += 5; |
| 3363 | } |
| 3364 | } |
| 3365 | } |
| 3366 | tempbx--; |
| 3367 | temp = tempbx & 0x00FF; |
| 3368 | tempbx--; |
| 3369 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3370 | /* 0x10 vertical Blank Start */ |
| 3371 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3372 | tempbx = push2; |
| 3373 | tempbx--; |
| 3374 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3375 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3376 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3377 | if (tempbx & 0x0100) |
| 3378 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3379 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3380 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3381 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3382 | if (modeflag & DoubleScanMode) |
| 3383 | tempax |= 0x08000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3384 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3385 | if (tempbx & 0x0200) |
| 3386 | tempcx |= 0x0040; |
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 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3389 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3390 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3391 | if (tempbx & 0x0400) |
| 3392 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3393 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3394 | /* 0x11 Vertival Blank End */ |
| 3395 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3396 | |
| 3397 | tempax = push1; |
| 3398 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 3399 | tempax = tempax >> 2; |
| 3400 | push1 = tempax; /* push ax */ |
| 3401 | |
| 3402 | if (resinfo != 0x09) { |
| 3403 | tempax = tempax << 1; |
| 3404 | tempbx += tempax; |
| 3405 | } |
| 3406 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3407 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Miguel Gómez | 470c533 | 2012-07-06 12:40:50 +0200 | [diff] [blame] | 3408 | if ((pVBInfo->VBType & VB_SIS301LV) && |
| 3409 | !(pVBInfo->TVInfo & TVSetHiVision)) { |
| 3410 | if ((pVBInfo->TVInfo & TVSimuMode) && |
| 3411 | (pVBInfo->TVInfo & TVSetPAL)) { |
| 3412 | if (!(pVBInfo->VBType & VB_SIS301LV) || |
| 3413 | !(pVBInfo->TVInfo & |
| 3414 | (TVSetYPbPr525p | |
| 3415 | TVSetYPbPr750p | |
| 3416 | TVSetHiVision))) |
| 3417 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3418 | } |
| 3419 | } else { |
| 3420 | tempbx -= 10; |
| 3421 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3422 | } else if (pVBInfo->TVInfo & TVSimuMode) { |
| 3423 | if (pVBInfo->TVInfo & TVSetPAL) { |
| 3424 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 3425 | if (!(pVBInfo->TVInfo & |
| 3426 | (TVSetYPbPr525p | |
| 3427 | TVSetYPbPr750p | |
| 3428 | TVSetHiVision))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3429 | tempbx += 40; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3430 | } else { |
| 3431 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3432 | } |
| 3433 | } |
| 3434 | } |
| 3435 | tempax = push1; |
| 3436 | tempax = tempax >> 2; |
| 3437 | tempax++; |
| 3438 | tempax += tempbx; |
| 3439 | push1 = tempax; /* push ax */ |
| 3440 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3441 | if ((pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3442 | if (tempbx <= 513) { |
| 3443 | if (tempax >= 513) |
| 3444 | tempbx = 513; |
| 3445 | } |
| 3446 | } |
| 3447 | |
| 3448 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3449 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3450 | tempbx--; |
| 3451 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3452 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3453 | |
| 3454 | if (tempbx & 0x0100) |
| 3455 | tempcx |= 0x0008; |
| 3456 | |
| 3457 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3458 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3459 | |
| 3460 | tempbx++; |
| 3461 | |
| 3462 | if (tempbx & 0x0100) |
| 3463 | tempcx |= 0x0004; |
| 3464 | |
| 3465 | if (tempbx & 0x0200) |
| 3466 | tempcx |= 0x0080; |
| 3467 | |
| 3468 | if (tempbx & 0x0400) |
| 3469 | tempcx |= 0x0C00; |
| 3470 | |
| 3471 | tempbx = push1; /* pop ax */ |
| 3472 | temp = tempbx & 0x00FF; |
| 3473 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3474 | /* 0x0D vertical Retrace End */ |
| 3475 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3476 | |
| 3477 | if (tempbx & 0x0010) |
| 3478 | tempcx |= 0x2000; |
| 3479 | |
| 3480 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3481 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3482 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3483 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3484 | tempax = modeflag; |
| 3485 | temp = (tempax & 0xFF00) >> 8; |
| 3486 | |
| 3487 | temp = (temp >> 1) & 0x09; |
| 3488 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3489 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3490 | temp |= 0x01; |
| 3491 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3492 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 3493 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 3494 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3495 | |
| 3496 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 3497 | temp = 0x80; |
| 3498 | else |
| 3499 | temp = 0x00; |
| 3500 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3501 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3502 | |
| 3503 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3504 | } |
| 3505 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3506 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3507 | unsigned short RefreshRateTableIndex, |
| 3508 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3509 | struct vb_device_info *pVBInfo) |
| 3510 | { |
| 3511 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
| 3512 | modeflag, resinfo, crt2crtc; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 3513 | unsigned char const *TimingPoint; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3514 | |
| 3515 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 3516 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3517 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3518 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3519 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3520 | crt2crtc = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3521 | |
| 3522 | tempax = 0; |
| 3523 | |
| 3524 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 3525 | tempax |= 0x0800; |
| 3526 | |
| 3527 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3528 | tempax |= 0x0400; |
| 3529 | |
| 3530 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 3531 | tempax |= 0x0200; |
| 3532 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3533 | if (!(pVBInfo->TVInfo & TVSetPAL)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3534 | tempax |= 0x1000; |
| 3535 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3536 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3537 | tempax |= 0x0100; |
| 3538 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3539 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3540 | tempax &= 0xfe00; |
| 3541 | |
| 3542 | tempax = (tempax & 0xff00) >> 8; |
| 3543 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3544 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3545 | TimingPoint = XGI330_NTSCTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3546 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3547 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3548 | TimingPoint = XGI330_PALTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3549 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3550 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3551 | TimingPoint = XGI330_HiTVExtTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3552 | |
| 3553 | if (pVBInfo->VBInfo & SetInSlaveMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3554 | TimingPoint = XGI330_HiTVSt2Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3555 | |
| 3556 | if (pVBInfo->SetFlag & TVSimuMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3557 | TimingPoint = XGI330_HiTVSt1Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3558 | |
| 3559 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3560 | TimingPoint = XGI330_HiTVTextTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3561 | } |
| 3562 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3563 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 3564 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3565 | TimingPoint = XGI330_YPbPr525iTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3566 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3567 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3568 | TimingPoint = XGI330_YPbPr525pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3569 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3570 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3571 | TimingPoint = XGI330_YPbPr750pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3572 | } |
| 3573 | |
| 3574 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3575 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3576 | |
| 3577 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3578 | /* di->temp2[j] */ |
| 3579 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3580 | |
| 3581 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3582 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3583 | |
| 3584 | temp = pVBInfo->NewFlickerMode; |
| 3585 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3586 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3587 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3588 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3589 | tempax = 950; |
| 3590 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3591 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3592 | tempax = 520; |
| 3593 | else |
| 3594 | tempax = 440; |
| 3595 | |
| 3596 | if (pVBInfo->VDE <= tempax) { |
| 3597 | tempax -= pVBInfo->VDE; |
| 3598 | tempax = tempax >> 2; |
| 3599 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 3600 | push1 = tempax; |
| 3601 | temp = (tempax & 0xFF00) >> 8; |
| 3602 | temp += (unsigned short) TimingPoint[0]; |
| 3603 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3604 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3605 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3606 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3607 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3608 | | SetCRT2ToYPbPr525750)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3609 | tempcx = pVBInfo->VGAHDE; |
| 3610 | if (tempcx >= 1024) { |
| 3611 | temp = 0x17; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3612 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3613 | temp = 0x19; /* PAL */ |
| 3614 | } |
| 3615 | } |
| 3616 | } |
| 3617 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3618 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3619 | tempax = push1; |
| 3620 | temp = (tempax & 0xFF00) >> 8; |
| 3621 | temp += TimingPoint[1]; |
| 3622 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3623 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3624 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3625 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3626 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3627 | | SetCRT2ToYPbPr525750))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3628 | tempcx = pVBInfo->VGAHDE; |
| 3629 | if (tempcx >= 1024) { |
| 3630 | temp = 0x1D; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3631 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3632 | temp = 0x52; /* PAL */ |
| 3633 | } |
| 3634 | } |
| 3635 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3636 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3637 | } |
| 3638 | |
| 3639 | /* 301b */ |
| 3640 | tempcx = pVBInfo->HT; |
| 3641 | |
| 3642 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3643 | tempcx = tempcx >> 1; |
| 3644 | |
| 3645 | tempcx -= 2; |
| 3646 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3647 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3648 | |
| 3649 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3650 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3651 | |
| 3652 | tempcx = pVBInfo->HT >> 1; |
| 3653 | push1 = tempcx; /* push cx */ |
| 3654 | tempcx += 7; |
| 3655 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3656 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3657 | tempcx -= 4; |
| 3658 | |
| 3659 | temp = tempcx & 0x00FF; |
| 3660 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3661 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3662 | |
| 3663 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3664 | tempbx += tempcx; |
| 3665 | push2 = tempbx; |
| 3666 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3667 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3668 | temp = (tempbx & 0xFF00) >> 8; |
| 3669 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3670 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3671 | |
| 3672 | tempbx = push2; |
| 3673 | tempbx = tempbx + 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3674 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3675 | tempbx = tempbx - 4; |
| 3676 | tempcx = tempbx; |
| 3677 | } |
| 3678 | |
| 3679 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3680 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3681 | |
| 3682 | j += 2; |
| 3683 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 3684 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3685 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3686 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3687 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3688 | |
| 3689 | tempcx += 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3690 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3691 | tempcx -= 4; |
| 3692 | |
| 3693 | temp = tempcx & 0xFF; |
| 3694 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3695 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3696 | |
| 3697 | tempcx = push1; /* pop cx */ |
| 3698 | j += 2; |
| 3699 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3700 | tempcx -= temp; |
| 3701 | temp = tempcx & 0x00FF; |
| 3702 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3703 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3704 | |
| 3705 | tempcx -= 11; |
| 3706 | |
| 3707 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 3708 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3709 | tempcx = tempax - 1; |
| 3710 | } |
| 3711 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3712 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3713 | |
| 3714 | tempbx = pVBInfo->VDE; |
| 3715 | |
| 3716 | if (pVBInfo->VGAVDE == 360) |
| 3717 | tempbx = 746; |
| 3718 | if (pVBInfo->VGAVDE == 375) |
| 3719 | tempbx = 746; |
| 3720 | if (pVBInfo->VGAVDE == 405) |
| 3721 | tempbx = 853; |
| 3722 | |
| 3723 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3724 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3725 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3726 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3727 | (TVSetYPbPr525p | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3728 | tempbx = tempbx >> 1; |
| 3729 | } else |
| 3730 | tempbx = tempbx >> 1; |
| 3731 | } |
| 3732 | |
| 3733 | tempbx -= 2; |
| 3734 | temp = tempbx & 0x00FF; |
| 3735 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3736 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3737 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3738 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3739 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3740 | if (ModeNo == 0x2f) |
| 3741 | temp += 1; |
| 3742 | } |
| 3743 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3744 | } else if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3745 | if (ModeNo == 0x2f) |
| 3746 | temp += 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3747 | } |
| 3748 | } |
| 3749 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3750 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3751 | |
| 3752 | temp = (tempcx & 0xFF00) >> 8; |
| 3753 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 3754 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3755 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3756 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3757 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3758 | temp |= 0x10; |
| 3759 | |
| 3760 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3761 | temp |= 0x20; |
| 3762 | } |
| 3763 | } else { |
| 3764 | temp |= 0x10; |
| 3765 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3766 | temp |= 0x20; |
| 3767 | } |
| 3768 | } |
| 3769 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3770 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3771 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3772 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3773 | | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3774 | tempbx = pVBInfo->VDE; |
| 3775 | tempcx = tempbx - 2; |
| 3776 | |
| 3777 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3778 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p |
| 3779 | | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3780 | tempbx = tempbx >> 1; |
| 3781 | } |
| 3782 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3783 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3784 | temp = 0; |
| 3785 | if (tempcx & 0x0400) |
| 3786 | temp |= 0x20; |
| 3787 | |
| 3788 | if (tempbx & 0x0400) |
| 3789 | temp |= 0x40; |
| 3790 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3791 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3792 | } |
| 3793 | |
| 3794 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3795 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3796 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3797 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3798 | } |
| 3799 | |
| 3800 | tempbx = tempbx & 0x00FF; |
| 3801 | |
| 3802 | if (!(modeflag & HalfDCLK)) { |
| 3803 | tempcx = pVBInfo->VGAHDE; |
| 3804 | if (tempcx >= pVBInfo->HDE) { |
| 3805 | tempbx |= 0x2000; |
| 3806 | tempax &= 0x00FF; |
| 3807 | } |
| 3808 | } |
| 3809 | |
| 3810 | tempcx = 0x0101; |
| 3811 | |
| 3812 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 3813 | if (pVBInfo->VGAHDE >= 1024) { |
| 3814 | tempcx = 0x1920; |
| 3815 | if (pVBInfo->VGAHDE >= 1280) { |
| 3816 | tempcx = 0x1420; |
| 3817 | tempbx = tempbx & 0xDFFF; |
| 3818 | } |
| 3819 | } |
| 3820 | } |
| 3821 | |
| 3822 | if (!(tempbx & 0x2000)) { |
| 3823 | if (modeflag & HalfDCLK) |
| 3824 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 3825 | |
| 3826 | push1 = tempbx; |
| 3827 | tempeax = pVBInfo->VGAHDE; |
| 3828 | tempebx = (tempcx & 0xFF00) >> 8; |
| 3829 | longtemp = tempeax * tempebx; |
| 3830 | tempecx = tempcx & 0x00FF; |
| 3831 | longtemp = longtemp / tempecx; |
| 3832 | |
| 3833 | /* 301b */ |
| 3834 | tempecx = 8 * 1024; |
| 3835 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3836 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3837 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3838 | tempecx = tempecx * 8; |
| 3839 | } |
| 3840 | |
| 3841 | longtemp = longtemp * tempecx; |
| 3842 | tempecx = pVBInfo->HDE; |
| 3843 | temp2 = longtemp % tempecx; |
| 3844 | tempeax = longtemp / tempecx; |
| 3845 | if (temp2 != 0) |
| 3846 | tempeax += 1; |
| 3847 | |
| 3848 | tempax = (unsigned short) tempeax; |
| 3849 | |
| 3850 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3851 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3852 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3853 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 3854 | } |
| 3855 | /* end 301b */ |
| 3856 | |
| 3857 | tempbx = push1; |
| 3858 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 3859 | | (tempbx & 0x00FF)); |
| 3860 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 3861 | | (tempax & 0x00FF)); |
| 3862 | temp = (tempax & 0xFF00) >> 8; |
| 3863 | } else { |
| 3864 | temp = (tempax & 0x00FF) >> 8; |
| 3865 | } |
| 3866 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3867 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3868 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3869 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3870 | temp = tempcx & 0x00FF; |
| 3871 | |
| 3872 | if (tempbx & 0x2000) |
| 3873 | temp = 0; |
| 3874 | |
| 3875 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3876 | temp |= 0x18; |
| 3877 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3878 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3879 | if (pVBInfo->TVInfo & TVSetPAL) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3880 | tempbx = 0x0382; |
| 3881 | tempcx = 0x007e; |
| 3882 | } else { |
| 3883 | tempbx = 0x0369; |
| 3884 | tempcx = 0x0061; |
| 3885 | } |
| 3886 | |
| 3887 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3888 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3889 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3890 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3891 | |
| 3892 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 3893 | temp = temp << 2; |
| 3894 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 3895 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3896 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3897 | temp |= 0x10; |
| 3898 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3899 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3900 | temp |= 0x20; |
| 3901 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3902 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3903 | temp |= 0x60; |
| 3904 | } |
| 3905 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3906 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3907 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3908 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3909 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3910 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3911 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 3912 | TimingPoint = XGI_NTSC1024AdjTime; |
| 3913 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3914 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3915 | TimingPoint[j]); |
| 3916 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3917 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3918 | } |
| 3919 | } |
| 3920 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 3921 | /* Modify for 301C PALM Support */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3922 | if (pVBInfo->VBType & VB_XGI301C) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3923 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3924 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3925 | 0x08); /* PALM Mode */ |
| 3926 | } |
| 3927 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3928 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3929 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3930 | 0x01); |
| 3931 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3932 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3933 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3934 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3935 | } |
| 3936 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3937 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3938 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3939 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3940 | } |
| 3941 | |
| 3942 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3943 | return; |
| 3944 | } |
| 3945 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3946 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3947 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3948 | unsigned short RefreshRateTableIndex, |
| 3949 | struct vb_device_info *pVBInfo) |
| 3950 | { |
| 3951 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
| 3952 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; |
| 3953 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 3954 | struct XGI_LCDDesStruct const *LCDBDesPtr = NULL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3955 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3956 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3957 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3958 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3959 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3960 | CRT1Index &= IndexMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3961 | |
| 3962 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3963 | return; |
| 3964 | |
| 3965 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 3966 | |
| 3967 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3968 | tempbx = tempbx >> 1; |
| 3969 | |
| 3970 | tempbx -= 1; |
| 3971 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3972 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3973 | temp = (tempbx & 0xFF00) >> 8; |
| 3974 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3975 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3976 | temp = 0x01; |
| 3977 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3978 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3979 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
| 3980 | push1 = tempbx; |
| 3981 | tempbx--; |
| 3982 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3983 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3984 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3985 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3986 | |
| 3987 | tempcx = pVBInfo->VT - 1; |
| 3988 | push2 = tempcx + 1; |
| 3989 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3990 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3991 | temp = (tempcx & 0xFF00) >> 8; |
| 3992 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3993 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3994 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 3995 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 3996 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 3997 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3998 | |
Justin P. Mattock | 558f758 | 2012-10-02 21:17:11 -0700 | [diff] [blame] | 3999 | /* Customized LCDB Does not add */ |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 4000 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
| 4001 | LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeNo, ModeIdIndex, |
| 4002 | RefreshRateTableIndex, pVBInfo); |
| 4003 | else |
| 4004 | LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeNo, |
| 4005 | ModeIdIndex, RefreshRateTableIndex, |
| 4006 | pVBInfo); |
| 4007 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4008 | tempah = pVBInfo->LCDResInfo; |
| 4009 | tempah &= PanelResInfo; |
| 4010 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4011 | if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4012 | tempbx = 1024; |
| 4013 | tempcx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4014 | } else if ((tempah == Panel_1280x1024) || |
| 4015 | (tempah == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4016 | tempbx = 1280; |
| 4017 | tempcx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4018 | } else if (tempah == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4019 | tempbx = 1400; |
| 4020 | tempcx = 1050; |
| 4021 | } else { |
| 4022 | tempbx = 1600; |
| 4023 | tempcx = 1200; |
| 4024 | } |
| 4025 | |
| 4026 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 4027 | tempbx = pVBInfo->HDE; |
| 4028 | tempcx = pVBInfo->VDE; |
| 4029 | } |
| 4030 | |
| 4031 | pushbx = tempbx; |
| 4032 | tempax = pVBInfo->VT; |
| 4033 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 4034 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 4035 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 4036 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 4037 | tempbx = pVBInfo->LCDVDES; |
| 4038 | tempcx += tempbx; |
| 4039 | |
| 4040 | if (tempcx >= tempax) |
| 4041 | tempcx -= tempax; /* lcdvdes */ |
| 4042 | |
| 4043 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4044 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4045 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4046 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4047 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 4048 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 4049 | tempah = tempch; |
| 4050 | tempah = tempah << 3; |
| 4051 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4052 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4053 | |
| 4054 | /* getlcdsync() */ |
| 4055 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 4056 | tempcx = tempbx; |
| 4057 | tempax = pVBInfo->VT; |
| 4058 | tempbx = pVBInfo->LCDVRS; |
| 4059 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4060 | tempcx += tempbx; |
| 4061 | if (tempcx >= tempax) |
| 4062 | tempcx -= tempax; |
| 4063 | |
| 4064 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4065 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4066 | temp = (tempbx & 0xFF00) >> 8; |
| 4067 | temp = temp << 4; |
| 4068 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4069 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4070 | tempcx = pushbx; |
| 4071 | tempax = pVBInfo->HT; |
| 4072 | tempbx = pVBInfo->LCDHDES; |
| 4073 | tempbx &= 0x0FFF; |
| 4074 | |
| 4075 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 4076 | tempax = tempax >> 1; |
| 4077 | tempbx = tempbx >> 1; |
| 4078 | tempcx = tempcx >> 1; |
| 4079 | } |
| 4080 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4081 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4082 | tempbx += 1; |
| 4083 | |
| 4084 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 4085 | tempbx += 1; |
| 4086 | |
| 4087 | tempcx += tempbx; |
| 4088 | |
| 4089 | if (tempcx >= tempax) |
| 4090 | tempcx -= tempax; |
| 4091 | |
| 4092 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4093 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4094 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4095 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4096 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4097 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4098 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4099 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4100 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4101 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 4102 | tempcx = tempax; |
| 4103 | tempax = pVBInfo->HT; |
| 4104 | tempbx = pVBInfo->LCDHRS; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4105 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 4106 | tempax = tempax >> 1; |
| 4107 | tempbx = tempbx >> 1; |
| 4108 | tempcx = tempcx >> 1; |
| 4109 | } |
| 4110 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4111 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4112 | tempbx += 1; |
| 4113 | |
| 4114 | tempcx += tempbx; |
| 4115 | |
| 4116 | if (tempcx >= tempax) |
| 4117 | tempcx -= tempax; |
| 4118 | |
| 4119 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4120 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4121 | |
| 4122 | temp = (tempbx & 0xFF00) >> 8; |
| 4123 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4124 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4125 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4126 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4127 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4128 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4129 | if (pVBInfo->VGAVDE == 525) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4130 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 4131 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4132 | | VB_XGI301C)) { |
| 4133 | temp = 0xC6; |
| 4134 | } else |
| 4135 | temp = 0xC4; |
| 4136 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4137 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 4138 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4139 | } |
| 4140 | |
| 4141 | if (pVBInfo->VGAVDE == 420) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4142 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 4143 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4144 | | VB_XGI301C)) { |
| 4145 | temp = 0x4F; |
| 4146 | } else |
| 4147 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4148 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4149 | } |
| 4150 | } |
| 4151 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4152 | |
| 4153 | /* --------------------------------------------------------------------- */ |
| 4154 | /* Function : XGI_GetTap4Ptr */ |
| 4155 | /* Input : */ |
| 4156 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 4157 | /* Description : */ |
| 4158 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4159 | static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4160 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4161 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4162 | unsigned short tempax, tempbx, i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4163 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4164 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4165 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4166 | if (tempcx == 0) { |
| 4167 | tempax = pVBInfo->VGAHDE; |
| 4168 | tempbx = pVBInfo->HDE; |
| 4169 | } else { |
| 4170 | tempax = pVBInfo->VGAVDE; |
| 4171 | tempbx = pVBInfo->VDE; |
| 4172 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4173 | |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4174 | if (tempax <= tempbx) |
| 4175 | return &xgifb_tap4_timing[0]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4176 | else |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4177 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4178 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4179 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4180 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4181 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4182 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 4183 | if ((pVBInfo->TVInfo & TVSetYPbPr525i) || |
| 4184 | (pVBInfo->TVInfo & TVSetYPbPr525p)) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4185 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4186 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4187 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 4188 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4189 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4190 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4191 | Tap4TimingPtr = xgifb_tap4_timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4192 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4193 | i = 0; |
| 4194 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 4195 | if (Tap4TimingPtr[i].DE == tempax) |
| 4196 | break; |
| 4197 | i++; |
| 4198 | } |
| 4199 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4200 | } |
| 4201 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4202 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4203 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4204 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4205 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4206 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4207 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4208 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 4209 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4210 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4211 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 4212 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4213 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4214 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4215 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4216 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4217 | /* Set Vertical Scaling */ |
| 4218 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4219 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4220 | xgifb_reg_set(pVBInfo->Part2Port, |
| 4221 | i, |
| 4222 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4223 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4224 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4225 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4226 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4227 | /* Enable V.Scaling */ |
| 4228 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4229 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4230 | /* Enable H.Scaling */ |
| 4231 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4232 | } |
| 4233 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4234 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4235 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4236 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4237 | unsigned short i; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 4238 | unsigned char const *tempdi; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4239 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4240 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4241 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4242 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4243 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4244 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4245 | if (pVBInfo->TVInfo & TVSetPAL) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4246 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 4247 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4248 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4249 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 4250 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4251 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4252 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4253 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4254 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4255 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4256 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4257 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 4258 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 4259 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4260 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4261 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4262 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo |
| 4263 | & SetCRT2ToYPbPr525750)) { |
| 4264 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4265 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4266 | |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4267 | tempdi = XGI330_HiTVGroup3Data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4268 | if (pVBInfo->SetFlag & TVSimuMode) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4269 | tempdi = XGI330_HiTVGroup3Simu; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4270 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4271 | tempdi = XGI330_HiTVGroup3Text; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4272 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4273 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4274 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4275 | tempdi = XGI330_Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4276 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4277 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4278 | tempdi = XGI330_Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4279 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4280 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4281 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4282 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4283 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4284 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4285 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4286 | } |
| 4287 | } |
| 4288 | return; |
| 4289 | } /* {end of XGI_SetGroup3} */ |
| 4290 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4291 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4292 | unsigned short RefreshRateTableIndex, |
| 4293 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4294 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4295 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4296 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4297 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4298 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4299 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4300 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4301 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4302 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4303 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4304 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4305 | tempbx = pVBInfo->RVBHCMAX; |
| 4306 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4307 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4308 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 4309 | tempcx = pVBInfo->VGAHT - 1; |
| 4310 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4311 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4312 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4313 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 4314 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4315 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4316 | tempcx = pVBInfo->VGAVT - 1; |
| 4317 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4318 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4319 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4320 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4321 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4322 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4323 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4324 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4325 | tempcx = pVBInfo->VBInfo; |
| 4326 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4327 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4328 | if (modeflag & HalfDCLK) |
| 4329 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4330 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4331 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4332 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4333 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4334 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4335 | temp = 0; |
| 4336 | if (tempbx <= 1024) |
| 4337 | temp = 0xA0; |
| 4338 | if (tempbx == 1280) |
| 4339 | temp = 0xC0; |
| 4340 | } else if (tempcx & SetCRT2ToTV) { |
| 4341 | temp = 0xA0; |
| 4342 | if (tempbx <= 800) |
| 4343 | temp = 0x80; |
| 4344 | } else { |
| 4345 | temp = 0x80; |
| 4346 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4347 | temp = 0; |
| 4348 | if (tempbx > 800) |
| 4349 | temp = 0x60; |
| 4350 | } |
| 4351 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4352 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4353 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4354 | temp = 0x00; |
| 4355 | if (pVBInfo->VGAHDE == 1280) |
| 4356 | temp = 0x40; |
| 4357 | if (pVBInfo->VGAHDE == 1024) |
| 4358 | temp = 0x20; |
| 4359 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4360 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4361 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4362 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4363 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4364 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4365 | if (!(temp & 0xE000)) |
| 4366 | tempbx = tempbx >> 1; |
| 4367 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4368 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4369 | tempcx = pVBInfo->RVBHRS; |
| 4370 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4371 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
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 | tempeax = pVBInfo->VGAVDE; |
| 4374 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4375 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4376 | if (tempeax <= tempebx) { |
| 4377 | tempcx = (tempcx & (~0x4000)); |
| 4378 | tempeax = pVBInfo->VGAVDE; |
| 4379 | } else { |
| 4380 | tempeax -= tempebx; |
| 4381 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4382 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4383 | templong = (tempeax * 256 * 1024) % tempebx; |
| 4384 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 4385 | tempebx = tempeax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4386 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4387 | if (templong != 0) |
| 4388 | tempebx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4389 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4390 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4391 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4392 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4393 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4394 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4395 | tempbx = (unsigned short) (tempebx >> 16); |
| 4396 | temp = tempbx & 0x00FF; |
| 4397 | temp = temp << 4; |
| 4398 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4399 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4400 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4401 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4402 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4403 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4404 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4405 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4406 | tempax = pVBInfo->VGAHDE; |
| 4407 | if (modeflag & HalfDCLK) |
| 4408 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4409 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4410 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4411 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4412 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4413 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4414 | if (tempax > 800) |
| 4415 | tempax -= 800; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 4416 | } else if (pVBInfo->VGAHDE > 800) { |
| 4417 | if (pVBInfo->VGAHDE == 1024) |
| 4418 | tempax = (tempax * 25 / 32) - 1; |
| 4419 | else |
| 4420 | tempax = (tempax * 20 / 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4421 | } |
| 4422 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4423 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4424 | temp = (tempax & 0xFF00) >> 8; |
| 4425 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4426 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4427 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4428 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4429 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4430 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4431 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4432 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
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 | } |
| 4435 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4436 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4437 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4438 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4439 | | TVSetYPbPr525p | TVSetYPbPr750p |
| 4440 | | TVSetHiVision))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4441 | temp |= 0x0001; |
| 4442 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 4443 | && (!(pVBInfo->TVInfo |
| 4444 | & TVSimuMode))) |
| 4445 | temp &= (~0x0001); |
| 4446 | } |
| 4447 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4448 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4449 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4450 | tempbx = pVBInfo->HT; |
| 4451 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4452 | tempbx = tempbx >> 1; |
| 4453 | tempbx = (tempbx >> 1) - 2; |
| 4454 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4455 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4456 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4457 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4458 | } |
| 4459 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4460 | |
Aaro Koskinen | 8951dad | 2012-09-11 00:15:30 +0300 | [diff] [blame] | 4461 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4462 | } |
| 4463 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4464 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 4465 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4466 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4467 | } |
| 4468 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4469 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4470 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4471 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4472 | unsigned short Pindex, Pdata; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4473 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4474 | Pindex = pVBInfo->Part5Port; |
| 4475 | Pdata = pVBInfo->Part5Port + 1; |
| 4476 | if (pVBInfo->ModeType == ModeVGA) { |
| 4477 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4478 | | DisableCRT2Display))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4479 | XGINew_EnableCRT2(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4480 | } |
| 4481 | } |
| 4482 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4483 | } |
| 4484 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4485 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4486 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4487 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4488 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4489 | } |
| 4490 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4491 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4492 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4493 | { |
| 4494 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4495 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4496 | } |
| 4497 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4498 | static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, |
| 4499 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 4500 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4501 | { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4502 | unsigned short xres, yres, colordepth, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4503 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4504 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4505 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4506 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
| 4507 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4508 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4509 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4510 | if (!(modeflag & Charx8Dot)) { |
| 4511 | xres /= 9; |
| 4512 | xres *= 8; |
| 4513 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4514 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4515 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 4516 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4517 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4518 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 4519 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4520 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4521 | if (xres > xgifb_info->lvds_data.LVDSHDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4522 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4523 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4524 | if (yres > xgifb_info->lvds_data.LVDSVDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4525 | return 0; |
| 4526 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4527 | if (xres != xgifb_info->lvds_data.LVDSHDE || |
| 4528 | yres != xgifb_info->lvds_data.LVDSVDE) { |
| 4529 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 4530 | if (colordepth > 2) |
| 4531 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4532 | } |
| 4533 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4534 | } |
| 4535 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4536 | static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, |
| 4537 | int chip_id, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4538 | unsigned short ModeNo, |
| 4539 | unsigned short ModeIdIndex, |
| 4540 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4541 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4542 | unsigned char temp, Miscdata; |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4543 | unsigned short xres, yres, modeflag, resindex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4544 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 4545 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 4546 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4547 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4548 | temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4549 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4550 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4551 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4552 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4553 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4554 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4555 | temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4556 | /* SR35[7] FP VSync polarity */ |
| 4557 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 4558 | /* SR30[5] FP HSync polarity */ |
| 4559 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4560 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4561 | if (chip_id == XG27) |
| 4562 | XGI_SetXG27FPBits(pVBInfo); |
| 4563 | else |
| 4564 | XGI_SetXG21FPBits(pVBInfo); |
| 4565 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4566 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4567 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4568 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ |
| 4569 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4570 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4571 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4572 | if (!(modeflag & Charx8Dot)) |
| 4573 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4574 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4575 | LVDSHT = xgifb_info->lvds_data.LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4576 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4577 | LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4578 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4579 | if (LVDSHBS > LVDSHT) |
| 4580 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4581 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4582 | LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4583 | if (LVDSHRS > LVDSHT) |
| 4584 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4585 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4586 | LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4587 | if (LVDSHRE > LVDSHT) |
| 4588 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4589 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4590 | LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4591 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4592 | LVDSVT = xgifb_info->lvds_data.LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4593 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4594 | LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4595 | if (modeflag & DoubleScanMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4596 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4597 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4598 | if (LVDSVBS > LVDSVT) |
| 4599 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4600 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4601 | LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4602 | if (LVDSVRS > LVDSVT) |
| 4603 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4604 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4605 | LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4606 | if (LVDSVRE > LVDSVT) |
| 4607 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4608 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4609 | LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4610 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4611 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4612 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4613 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4614 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4615 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4616 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4617 | /* HT SR0B[1:0] CR00 */ |
| 4618 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4619 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4620 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4621 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4622 | /* HBS SR0B[5:4] CR02 */ |
| 4623 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4624 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4625 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4626 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4627 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 4628 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4629 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 4630 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 4631 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4632 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4633 | /* HRS SR0B[7:6] CR04 */ |
| 4634 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4635 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4636 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4637 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4638 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 4639 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4640 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4641 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4642 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4643 | /* HRE SR0C[2] CR05[4:0] */ |
| 4644 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4645 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 4646 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4647 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4648 | /* Panel HRE SR2F[7:2] */ |
| 4649 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4650 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4651 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4652 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 4653 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4654 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 4655 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 4656 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4657 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4658 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4659 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 4660 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4661 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 4662 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 4663 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4664 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4665 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4666 | /* VBE SR0A[4] CR16 */ |
| 4667 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4668 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4669 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4670 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4671 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 4672 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4673 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 4674 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 4675 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4676 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4677 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4678 | if (chip_id == XG27) { |
| 4679 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
| 4680 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, |
| 4681 | (value & 0x700) >> 8); |
| 4682 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
| 4683 | } else { |
| 4684 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
| 4685 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, |
| 4686 | (value & 0x600) >> 9); |
| 4687 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
| 4688 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
| 4689 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4690 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4691 | /* VRE SR0A[5] CR11[3:0] */ |
| 4692 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4693 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 4694 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4695 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4696 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4697 | if (chip_id == XG27) |
| 4698 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4699 | (value << 2) & 0xFC); |
| 4700 | else |
| 4701 | /* SR3F[7] has to be 0, h/w bug */ |
| 4702 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4703 | (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4704 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4705 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4706 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4707 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4708 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4709 | 0x2B, xgifb_info->lvds_data.VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4710 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4711 | 0x2C, xgifb_info->lvds_data.VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4712 | value += 0x10; |
| 4713 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4714 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4715 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4716 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4717 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4718 | /* set data, panning = 0, shift left 1 dot*/ |
| 4719 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4720 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4721 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4722 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4723 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4724 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4725 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4726 | |
| 4727 | } |
| 4728 | |
| 4729 | /* --------------------------------------------------------------------- */ |
| 4730 | /* Function : XGI_IsLCDON */ |
| 4731 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4732 | /* Output : 0 : Skip PSC Control */ |
| 4733 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4734 | /* Description : */ |
| 4735 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4736 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4737 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4738 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4739 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4740 | tempax = pVBInfo->VBInfo; |
| 4741 | if (tempax & SetCRT2ToDualEdge) |
| 4742 | return 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4743 | else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4744 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4745 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4746 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4747 | } |
| 4748 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4749 | /* --------------------------------------------------------------------- */ |
| 4750 | /* Function : XGI_DisableChISLCD */ |
| 4751 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4752 | /* Output : 0 -> Not LCD Mode */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4753 | /* Description : */ |
| 4754 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4755 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4756 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4757 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4758 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4759 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4760 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4761 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4762 | if (tempbx & (EnableChA | DisableChA)) { |
| 4763 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 4764 | return 0; |
| 4765 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4766 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4767 | if (!(tempbx & (EnableChB | DisableChB))) |
| 4768 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4769 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4770 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 4771 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4772 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4773 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4774 | } |
| 4775 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4776 | /* --------------------------------------------------------------------- */ |
| 4777 | /* Function : XGI_EnableChISLCD */ |
| 4778 | /* Input : */ |
| 4779 | /* Output : 0 -> Not LCD mode */ |
| 4780 | /* Description : */ |
| 4781 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4782 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4783 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4784 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4785 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4786 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4787 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4788 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4789 | if (tempbx & (EnableChA | DisableChA)) { |
| 4790 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 4791 | return 0; |
| 4792 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4793 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4794 | if (!(tempbx & (EnableChB | DisableChB))) |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4795 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4796 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4797 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 4798 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4799 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4800 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4801 | } |
| 4802 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4803 | static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, |
| 4804 | struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4805 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4806 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 4807 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4808 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4809 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4810 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4811 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4812 | if (!(pVBInfo->VBInfo & |
| 4813 | (DisableCRT2Display | SetSimuScanMode))) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4814 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4815 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 4816 | tempah = 0x7F; /* Disable Channel A */ |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4817 | if (!(pVBInfo->VBInfo & |
| 4818 | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4819 | /* Disable Channel B */ |
| 4820 | tempah = 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4821 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4822 | if (pVBInfo->SetFlag & DisableChB) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4823 | /* force to disable Cahnnel */ |
| 4824 | tempah &= 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4825 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4826 | if (pVBInfo->SetFlag & DisableChA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4827 | /* Force to disable Channel B */ |
| 4828 | tempah &= 0x7F; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4829 | } |
| 4830 | } |
| 4831 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4832 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4833 | /* disable part4_1f */ |
| 4834 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4835 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4836 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4837 | if (((pVBInfo->VBInfo & |
| 4838 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 4839 | || (XGI_DisableChISLCD(pVBInfo)) |
| 4840 | || (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4841 | /* LVDS Driver power down */ |
| 4842 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4843 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4844 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4845 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4846 | & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4847 | | SetSimuScanMode))) { |
| 4848 | if (pVBInfo->SetFlag & GatingCRT) |
| 4849 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4850 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4851 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4852 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4853 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4854 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4855 | & XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4856 | /* Power down */ |
| 4857 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4858 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4859 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4860 | /* disable TV as primary VGA swap */ |
| 4861 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4862 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4863 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 4864 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4865 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4866 | if ((pVBInfo->SetFlag & DisableChB) || |
| 4867 | (pVBInfo->VBInfo & |
| 4868 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4869 | ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4870 | (pVBInfo->VBInfo & |
| 4871 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4872 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4873 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4874 | if ((pVBInfo->SetFlag & DisableChB) || |
| 4875 | (pVBInfo->VBInfo & |
| 4876 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4877 | (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) || |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4878 | (pVBInfo->VBInfo & |
| 4879 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 4880 | /* save Part1 index 0 */ |
| 4881 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 4882 | /* BTDAC = 1, avoid VB reset */ |
| 4883 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 4884 | /* disable CRT2 */ |
| 4885 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4886 | /* restore Part1 index 0 */ |
| 4887 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4888 | } |
| 4889 | } else { /* {301} */ |
| 4890 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4891 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 4892 | /* Disable CRT2 */ |
| 4893 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4894 | /* Disable TV asPrimary VGA swap */ |
| 4895 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4896 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4897 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4898 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4899 | | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4900 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4901 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4902 | } |
| 4903 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4904 | /* --------------------------------------------------------------------- */ |
| 4905 | /* Function : XGI_GetTVPtrIndex */ |
| 4906 | /* Input : */ |
| 4907 | /* Output : */ |
| 4908 | /* Description : bx 0 : ExtNTSC */ |
| 4909 | /* 1 : StNTSC */ |
| 4910 | /* 2 : ExtPAL */ |
| 4911 | /* 3 : StPAL */ |
| 4912 | /* 4 : ExtHiTV */ |
| 4913 | /* 5 : StHiTV */ |
| 4914 | /* 6 : Ext525i */ |
| 4915 | /* 7 : St525i */ |
| 4916 | /* 8 : Ext525p */ |
| 4917 | /* 9 : St525p */ |
| 4918 | /* A : Ext750p */ |
| 4919 | /* B : St750p */ |
| 4920 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4921 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4922 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4923 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4924 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4925 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4926 | tempbx = 2; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4927 | if (pVBInfo->TVInfo & TVSetHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4928 | tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4929 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4930 | tempbx = 6; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4931 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4932 | tempbx = 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4933 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4934 | tempbx = 10; |
| 4935 | if (pVBInfo->TVInfo & TVSimuMode) |
| 4936 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4937 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4938 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4939 | } |
| 4940 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4941 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4942 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4943 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4944 | /* Output : bx 0 : NTSC */ |
| 4945 | /* 1 : PAL */ |
| 4946 | /* 2 : PALM */ |
| 4947 | /* 3 : PALN */ |
| 4948 | /* 4 : NTSC1024x768 */ |
| 4949 | /* 5 : PAL-M 1024x768 */ |
| 4950 | /* 6-7: reserved */ |
| 4951 | /* cl 0 : YFilter1 */ |
| 4952 | /* 1 : YFilter2 */ |
| 4953 | /* ch 0 : 301A */ |
| 4954 | /* 1 : 301B/302B/301LV/302LV */ |
| 4955 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4956 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4957 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 4958 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4959 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4960 | *tempbx = 0; |
| 4961 | *tempcl = 0; |
| 4962 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4963 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4964 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4965 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4966 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4967 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4968 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4969 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4970 | if (pVBInfo->TVInfo & TVSetPALN) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4971 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4972 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4973 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 4974 | *tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4975 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4976 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4977 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4978 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4979 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4980 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4981 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 4982 | & TVSimuMode)) { |
| 4983 | *tempbx += 8; |
| 4984 | *tempcl += 1; |
| 4985 | } |
| 4986 | } |
| 4987 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4988 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4989 | | VB_SIS302LV | VB_XGI301C)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4990 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4991 | } |
| 4992 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4993 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4994 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4995 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4996 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4997 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4998 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4999 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5000 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5001 | tempbh = 0; |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 5002 | tempbl = XGI301TVDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5003 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5004 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5005 | tempbl = tempbl >> 4; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 5006 | if (pVBInfo->VBInfo & |
| 5007 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 5008 | tempbh = XGI301LCDDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5009 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5010 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5011 | tempbl = tempbh; |
| 5012 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5013 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5014 | tempbl &= 0x0F; |
| 5015 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5016 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5017 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5018 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 5019 | | SetCRT2ToTV)) { /* Channel B */ |
| 5020 | tempah &= 0xF0; |
| 5021 | tempah |= tempbl; |
| 5022 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5023 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 5024 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 5025 | /* Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5026 | tempah &= 0x0F; |
| 5027 | tempah |= tempbh; |
| 5028 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5029 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5030 | } |
| 5031 | } else if (pVBInfo->IF_DEF_LVDS == 1) { |
| 5032 | tempbl = 0; |
| 5033 | tempbh = 0; |
| 5034 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 5035 | tempah = XGI301LCDDelay; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5036 | tempah &= 0x0f; |
| 5037 | tempah = tempah << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5038 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5039 | tempah); |
| 5040 | } |
| 5041 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5042 | } |
| 5043 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5044 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 5045 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5046 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5047 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5048 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5049 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5050 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5051 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5052 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5053 | /* Enable Dither */ |
| 5054 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5055 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5056 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5057 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5058 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5059 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5060 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5061 | } |
| 5062 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5063 | /* --------------------------------------------------------------------- */ |
| 5064 | /* Function : XGI_SetLCDCap_B */ |
| 5065 | /* Input : cx -> LCD Capability */ |
| 5066 | /* Output : */ |
| 5067 | /* Description : */ |
| 5068 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5069 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 5070 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5071 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5072 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5073 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5074 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 5075 | | 0x0c)); |
| 5076 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5077 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5078 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 5079 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5080 | } |
| 5081 | |
Aaro Koskinen | 7f04ec3 | 2011-11-27 23:03:05 +0200 | [diff] [blame] | 5082 | static void XGI_LongWait(struct vb_device_info *pVBInfo) |
| 5083 | { |
| 5084 | unsigned short i; |
| 5085 | |
| 5086 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
| 5087 | |
| 5088 | if (!(i & 0xC0)) { |
| 5089 | for (i = 0; i < 0xFFFF; i++) { |
| 5090 | if (!(inb(pVBInfo->P3da) & 0x08)) |
| 5091 | break; |
| 5092 | } |
| 5093 | |
| 5094 | for (i = 0; i < 0xFFFF; i++) { |
| 5095 | if ((inb(pVBInfo->P3da) & 0x08)) |
| 5096 | break; |
| 5097 | } |
| 5098 | } |
| 5099 | } |
| 5100 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5101 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5102 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5103 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5104 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5105 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5106 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5107 | /* disable down spectrum D[4] */ |
| 5108 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5109 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5110 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5111 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5112 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5113 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5114 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5115 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5116 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5117 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5118 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5119 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5120 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 5121 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5122 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5123 | } |
| 5124 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5125 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 5126 | { |
| 5127 | unsigned short tempcx; |
| 5128 | |
| 5129 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 5130 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5131 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5132 | (VB_SIS301B | |
| 5133 | VB_SIS302B | |
| 5134 | VB_SIS301LV | |
| 5135 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5136 | VB_XGI301C)) { /* 301LV/302LV only */ |
| 5137 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5138 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5139 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5140 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5141 | (unsigned char) (tempcx & 0x1F)); |
| 5142 | } |
| 5143 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5144 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5145 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 5146 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 5147 | | EnablePLLSPLOW)) >> 8)); |
| 5148 | } |
| 5149 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5150 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5151 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5152 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 5153 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5154 | else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5155 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 5156 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5157 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5158 | if (tempcx & EnableSpectrum) |
| 5159 | SetSpectrum(pVBInfo); |
| 5160 | } |
| 5161 | } else { |
| 5162 | /* LVDS,CH7017 */ |
| 5163 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 5164 | } |
| 5165 | } |
| 5166 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5167 | /* --------------------------------------------------------------------- */ |
| 5168 | /* Function : XGI_SetAntiFlicker */ |
| 5169 | /* Input : */ |
| 5170 | /* Output : */ |
| 5171 | /* Description : Set TV Customized Param. */ |
| 5172 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5173 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
| 5174 | unsigned short ModeIdIndex, |
| 5175 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5176 | { |
Aaro Koskinen | 36ae035 | 2012-04-07 01:14:08 +0300 | [diff] [blame] | 5177 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5178 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5179 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5180 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5181 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5182 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5183 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5184 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 5185 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5186 | tempah = TVAntiFlickList[tempbx]; |
| 5187 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5188 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5189 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5190 | } |
| 5191 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5192 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
| 5193 | unsigned short ModeIdIndex, |
| 5194 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5195 | { |
Aaro Koskinen | 354f49f | 2012-04-07 01:14:09 +0300 | [diff] [blame] | 5196 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5197 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5198 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5199 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5200 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 5201 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5202 | tempah = TVEdgeList[tempbx]; |
| 5203 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5204 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5205 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5206 | } |
| 5207 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5208 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5209 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5210 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5211 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5212 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5213 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5214 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5215 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5216 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 5217 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5218 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5219 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5220 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5221 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5222 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5223 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5224 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5225 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5226 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5227 | } |
| 5228 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5229 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5230 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5231 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5232 | unsigned short tempbx, index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5233 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5234 | unsigned char tempcl, tempch, tempal, *filterPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5235 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5236 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5237 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5238 | switch (tempbx) { |
| 5239 | case 0x00: |
| 5240 | case 0x04: |
| 5241 | filterPtr = NTSCYFilter1; |
| 5242 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5243 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5244 | case 0x01: |
| 5245 | filterPtr = PALYFilter1; |
| 5246 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5247 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5248 | case 0x02: |
| 5249 | case 0x05: |
| 5250 | case 0x0D: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5251 | case 0x03: |
Aaro Koskinen | 2555e94 | 2011-08-31 21:46:06 +0300 | [diff] [blame] | 5252 | filterPtr = xgifb_palmn_yfilter1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5253 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5254 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5255 | case 0x08: |
| 5256 | case 0x0C: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5257 | case 0x0A: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5258 | case 0x0B: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5259 | case 0x09: |
Aaro Koskinen | 80f86f8 | 2011-08-31 21:46:05 +0300 | [diff] [blame] | 5260 | filterPtr = xgifb_yfilter2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5261 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5262 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5263 | default: |
| 5264 | return; |
| 5265 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5266 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5267 | tempal = XGI330_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5268 | if (tempcl == 0) |
| 5269 | index = tempal * 4; |
| 5270 | else |
| 5271 | index = tempal * 7; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5272 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5273 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5274 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 5275 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 5276 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 5277 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5278 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5279 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 5280 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 5281 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 5282 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5283 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5284 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5285 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5286 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5287 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 5288 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 5289 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5290 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5291 | } |
| 5292 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5293 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5294 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5295 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5296 | /* Output : */ |
| 5297 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5298 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5299 | static void XGI_OEM310Setting(unsigned short ModeNo, |
| 5300 | unsigned short ModeIdIndex, |
| 5301 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5302 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5303 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5304 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5305 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5306 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5307 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5308 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5309 | XGI_SetPhaseIncr(pVBInfo); |
| 5310 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); |
| 5311 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5312 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5313 | if (pVBInfo->VBType & VB_SIS301) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5314 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5315 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5316 | } |
| 5317 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5318 | /* --------------------------------------------------------------------- */ |
| 5319 | /* Function : XGI_SetCRT2ModeRegs */ |
| 5320 | /* Input : */ |
| 5321 | /* Output : */ |
| 5322 | /* Description : Origin code for crt2group */ |
| 5323 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5324 | static void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5325 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5326 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5327 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5328 | unsigned short tempbl; |
| 5329 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5330 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5331 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5332 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5333 | tempah = 0; |
| 5334 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5335 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5336 | tempah &= ~0x10; /* BTRAMDAC */ |
| 5337 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5338 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5339 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 5340 | | SetCRT2ToLCD)) { |
| 5341 | tempah = 0x40; /* BTDRAM */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5342 | tempcl = pVBInfo->ModeType; |
| 5343 | tempcl -= ModeVGA; |
| 5344 | if (tempcl >= 0) { |
| 5345 | /* BT Color */ |
| 5346 | tempah = (0x008 >> tempcl); |
| 5347 | if (tempah == 0) |
| 5348 | tempah = 1; |
| 5349 | tempah |= 0x040; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5350 | } |
| 5351 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 5352 | tempah ^= 0x50; /* BTDAC */ |
| 5353 | } |
| 5354 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5355 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5356 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5357 | tempah = 0x08; |
| 5358 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5359 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5360 | if (pVBInfo->VBInfo & DisableCRT2Display) |
| 5361 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5362 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5363 | tempah = 0x00; |
| 5364 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5365 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5366 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
| 5367 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 5368 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5369 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5370 | if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 5371 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
| 5372 | tempbl &= 0xf7; |
| 5373 | tempah |= 0x01; |
| 5374 | goto reg_and_or; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5375 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5376 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5377 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 5378 | tempbl &= 0xf7; |
| 5379 | tempah |= 0x01; |
| 5380 | } |
| 5381 | |
| 5382 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD))) |
| 5383 | goto reg_and_or; |
| 5384 | |
| 5385 | tempbl &= 0xf8; |
| 5386 | tempah = 0x01; |
| 5387 | |
| 5388 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 5389 | tempah |= 0x02; |
| 5390 | |
| 5391 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5392 | tempah = tempah ^ 0x05; |
| 5393 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5394 | tempah = tempah ^ 0x01; |
| 5395 | } |
| 5396 | |
| 5397 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5398 | tempah |= 0x08; |
| 5399 | |
| 5400 | reg_and_or: |
| 5401 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
| 5402 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5403 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5404 | | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5405 | tempah &= (~0x08); |
| 5406 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 5407 | & SetInSlaveMode))) { |
| 5408 | tempah |= 0x010; |
| 5409 | } |
| 5410 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5411 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5412 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5413 | tempah |= 0x020; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5414 | if (pVBInfo->VBInfo & DriverMode) |
| 5415 | tempah = tempah ^ 0x20; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5416 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5417 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5418 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5419 | tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5420 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5421 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 5422 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5423 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5424 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5425 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 5426 | tempah |= 0x40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5427 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5428 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5429 | if ((pVBInfo->LCDResInfo == Panel_1280x1024) |
| 5430 | || (pVBInfo->LCDResInfo == Panel_1280x1024x75)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5431 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5432 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5433 | if (pVBInfo->LCDResInfo == Panel_1280x960) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5434 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5435 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5436 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5437 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5438 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5439 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5440 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5441 | tempah = 0; |
| 5442 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5443 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5444 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 5445 | tempbl = 0xff; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5446 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5447 | tempah |= 0x04; /* shampoo 0129 */ |
| 5448 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5449 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5450 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5451 | tempah = 0x00; |
| 5452 | tempbl = 0xcf; |
| 5453 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5454 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5455 | tempah |= 0x30; |
| 5456 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5457 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5458 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5459 | tempah = 0; |
| 5460 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5461 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5462 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5463 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5464 | tempah |= 0xc0; |
| 5465 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5466 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5467 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5468 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5469 | tempah = 0; |
| 5470 | tempbl = 0x7f; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5471 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5472 | tempbl = 0xff; |
| 5473 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5474 | tempah |= 0x80; |
| 5475 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5476 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5477 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5478 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5479 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5480 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5481 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 5482 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5483 | } |
| 5484 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5485 | } |
| 5486 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5487 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5488 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 5489 | struct vb_device_info *pVBInfo) |
| 5490 | { |
| 5491 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5492 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5493 | |
| 5494 | } |
| 5495 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5496 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 5497 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5498 | { |
| 5499 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5500 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5501 | |
| 5502 | } |
| 5503 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 5504 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5505 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5506 | unsigned short flag; |
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 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 5509 | return 1; |
| 5510 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5511 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5512 | if ((flag == 1) || (flag == 2)) |
| 5513 | return 1; /* 301b */ |
| 5514 | else |
| 5515 | return 0; |
| 5516 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5517 | } |
| 5518 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5519 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 5520 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5521 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5522 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5523 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, |
| 5524 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, |
| 5525 | 0x01, 0x01 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5526 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5527 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5528 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5529 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5530 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5531 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5532 | index = index >> pVBInfo->SelectCRT2Rate; |
| 5533 | index &= 0x0F; |
| 5534 | |
| 5535 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 5536 | index = 0; |
| 5537 | |
| 5538 | if (index > 0) |
| 5539 | index--; |
| 5540 | |
| 5541 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5542 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5543 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5544 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 5545 | | VB_SIS301LV | VB_SIS302LV |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5546 | | VB_XGI301C)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5547 | /* 301b */ |
| 5548 | temp = LCDARefreshIndex[ |
| 5549 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5550 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5551 | temp = LCDRefreshIndex[ |
| 5552 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5553 | |
| 5554 | if (index > temp) |
| 5555 | index = temp; |
| 5556 | } else { |
| 5557 | index = 0; |
| 5558 | } |
| 5559 | } |
| 5560 | } |
| 5561 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5562 | RefreshRateTableIndex = XGI330_EModeIDTable[ModeIdIndex].REFindex; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5563 | ModeNo = XGI330_RefIndex[RefreshRateTableIndex].ModeID; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5564 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5565 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 5566 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5567 | index++; |
| 5568 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5569 | /* do the similar adjustment like XGISearchCRT1Rate() */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5570 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 5571 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5572 | index++; |
| 5573 | } |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5574 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 5575 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5576 | index++; |
| 5577 | } |
| 5578 | } |
| 5579 | |
| 5580 | i = 0; |
| 5581 | do { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5582 | if (XGI330_RefIndex[RefreshRateTableIndex + i]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5583 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5584 | break; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5585 | temp = XGI330_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5586 | temp &= ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5587 | if (temp < pVBInfo->ModeType) |
| 5588 | break; |
| 5589 | i++; |
| 5590 | index--; |
| 5591 | |
| 5592 | } while (index != 0xFFFF); |
| 5593 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5594 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5595 | temp = XGI330_RefIndex[RefreshRateTableIndex + i - 1]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5596 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5597 | if (temp & InterlaceMode) |
| 5598 | i++; |
| 5599 | } |
| 5600 | } |
| 5601 | i--; |
| 5602 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
| 5603 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, |
| 5604 | RefreshRateTableIndex, &i, pVBInfo); |
| 5605 | } |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 5606 | return RefreshRateTableIndex + i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5607 | } |
| 5608 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5609 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5610 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5611 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5612 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5613 | unsigned short RefreshRateTableIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5614 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5615 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5616 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5617 | ModeIdIndex, pVBInfo); |
| 5618 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5619 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5620 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5621 | HwDeviceExtension, pVBInfo); |
| 5622 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5623 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5624 | } |
| 5625 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5626 | static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5627 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5628 | struct vb_device_info *pVBInfo) |
| 5629 | { |
| 5630 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
| 5631 | |
| 5632 | tempbx = pVBInfo->VBInfo; |
| 5633 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5634 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 5635 | pVBInfo->SelectCRT2Rate = 4; |
| 5636 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5637 | ModeIdIndex, pVBInfo); |
| 5638 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
| 5639 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5640 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5641 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5642 | RefreshRateTableIndex, pVBInfo); |
| 5643 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5644 | RefreshRateTableIndex, pVBInfo); |
| 5645 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5646 | RefreshRateTableIndex, pVBInfo); |
| 5647 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5648 | HwDeviceExtension, pVBInfo); |
| 5649 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5650 | RefreshRateTableIndex, pVBInfo); |
| 5651 | XGI_SetTap4Regs(pVBInfo); |
| 5652 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); |
| 5653 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5654 | HwDeviceExtension, pVBInfo); |
| 5655 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5656 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); |
| 5657 | XGI_AutoThreshold(pVBInfo); |
| 5658 | return 1; |
| 5659 | } |
| 5660 | |
| 5661 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 5662 | { |
| 5663 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 5664 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 5665 | 0x05, 0x00 }; |
| 5666 | |
| 5667 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 5668 | |
| 5669 | unsigned char CR17, CR63, SR31; |
| 5670 | unsigned short temp; |
| 5671 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; |
| 5672 | |
| 5673 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5674 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5675 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5676 | /* to fix XG42 single LCD sense to CRT+LCD */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5677 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5678 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5679 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 5680 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5681 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 5682 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 5683 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5684 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5685 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 5686 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5687 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5688 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5689 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5690 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5691 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5692 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5693 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5694 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5695 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5696 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5697 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5698 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5699 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5700 | |
| 5701 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5702 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5703 | |
| 5704 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5705 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5706 | CRTCData[i]); |
| 5707 | |
| 5708 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5709 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5710 | CRTCData[i]); |
| 5711 | |
| 5712 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5713 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5714 | CRTCData[i]); |
| 5715 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5716 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5717 | & 0xE0)); |
| 5718 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5719 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 5720 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 5721 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5722 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5723 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5724 | |
| 5725 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5726 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
| 5727 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); |
| 5728 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5729 | } |
| 5730 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5731 | mdelay(1); |
| 5732 | |
| 5733 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5734 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5735 | |
| 5736 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5737 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5738 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5739 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5740 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5741 | /* avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5742 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5743 | |
| 5744 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5745 | outb(0, (pVBInfo->P3c8 + 1)); |
| 5746 | outb(0, (pVBInfo->P3c8 + 1)); |
| 5747 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5748 | } |
| 5749 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5750 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 5751 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 5752 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5753 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5754 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5755 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5756 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5757 | } |
| 5758 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5759 | static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, |
| 5760 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5761 | struct vb_device_info *pVBInfo) |
| 5762 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 5763 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5764 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5765 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5766 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5767 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 5768 | if (pVBInfo->SetFlag & EnableChA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5769 | /* Power on */ |
| 5770 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 5771 | } else if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 5772 | /* Power on */ |
| 5773 | xgifb_reg_set(pVBInfo->Part1Port, |
| 5774 | 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5775 | } |
| 5776 | } |
| 5777 | |
| 5778 | if (!(pVBInfo->SetFlag & DisableChB)) { |
| 5779 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo |
| 5780 | & (SetCRT2ToLCD | SetCRT2ToTV |
| 5781 | | SetCRT2ToRAMDAC))) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5782 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5783 | pVBInfo->P3c4, 0x32); |
| 5784 | tempah &= 0xDF; |
| 5785 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5786 | if (!(pVBInfo->VBInfo & |
| 5787 | SetCRT2ToRAMDAC)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5788 | tempah |= 0x20; |
| 5789 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5790 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5791 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5792 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5793 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5794 | pVBInfo->Part1Port, 0x2E); |
| 5795 | |
| 5796 | if (!(tempah & 0x80)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5797 | xgifb_reg_or(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5798 | 0x2E, 0x80); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5799 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5800 | } |
| 5801 | } |
| 5802 | |
| 5803 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
| 5804 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5805 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5806 | 0x20); /* shampoo 0129 */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5807 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5808 | if (!XGI_DisableChISLCD(pVBInfo)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5809 | if (XGI_EnableChISLCD(pVBInfo) || |
| 5810 | (pVBInfo->VBInfo & |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5811 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5812 | /* LVDS PLL power on */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5813 | xgifb_reg_and( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5814 | pVBInfo->Part4Port, |
| 5815 | 0x2A, |
| 5816 | 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5817 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5818 | /* LVDS Driver power on */ |
| 5819 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5820 | } |
| 5821 | } |
| 5822 | |
| 5823 | tempah = 0x00; |
| 5824 | |
| 5825 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5826 | tempah = 0xc0; |
| 5827 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5828 | if (!(pVBInfo->VBInfo & SetSimuScanMode) && |
| 5829 | (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 5830 | (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { |
| 5831 | tempah = tempah & 0x40; |
| 5832 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
| 5833 | tempah = tempah ^ 0xC0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5834 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5835 | if (pVBInfo->SetFlag & DisableChB) |
| 5836 | tempah &= 0xBF; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5837 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5838 | if (pVBInfo->SetFlag & DisableChA) |
| 5839 | tempah &= 0x7F; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5840 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5841 | if (pVBInfo->SetFlag & EnableChB) |
| 5842 | tempah |= 0x40; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5843 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5844 | if (pVBInfo->SetFlag & EnableChA) |
| 5845 | tempah |= 0x80; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5846 | } |
| 5847 | } |
| 5848 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5849 | /* EnablePart4_1F */ |
| 5850 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5851 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5852 | if (!(pVBInfo->SetFlag & DisableChA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5853 | if (!(pVBInfo->SetFlag & GatingCRT)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5854 | XGI_DisableGatingCRT(HwDeviceExtension, |
| 5855 | pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5856 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, |
| 5857 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5858 | } |
| 5859 | } |
| 5860 | } /* 301 */ |
| 5861 | else { /* LVDS */ |
| 5862 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5863 | | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5864 | /* enable CRT2 */ |
| 5865 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5866 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5867 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5868 | 0x2E); |
| 5869 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5870 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5871 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5872 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5873 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5874 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5875 | } |
| 5876 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5877 | static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, |
| 5878 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5879 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5880 | struct vb_device_info *pVBInfo) |
| 5881 | { |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5882 | unsigned short RefreshRateTableIndex, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5883 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5884 | XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 5885 | outb(XGI330_StandTable.MISC, pVBInfo->P3c2); |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5886 | XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo); |
| 5887 | XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo); |
| 5888 | XGI_SetGRCRegs(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5889 | XGI_ClearExt1Regs(pVBInfo); |
| 5890 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5891 | if (HwDeviceExtension->jChipType == XG27) { |
| 5892 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 5893 | XGI_SetDefaultVCLK(pVBInfo); |
| 5894 | } |
| 5895 | |
| 5896 | temp = ~ProgrammingCRT2; |
| 5897 | pVBInfo->SetFlag &= temp; |
| 5898 | pVBInfo->SelectCRT2Rate = 0; |
| 5899 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5900 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5901 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5902 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5903 | | SetInSlaveMode)) { |
| 5904 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5905 | } |
| 5906 | } |
| 5907 | |
| 5908 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5909 | ModeIdIndex, pVBInfo); |
| 5910 | if (RefreshRateTableIndex != 0xFFFF) { |
| 5911 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
| 5912 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5913 | pVBInfo, HwDeviceExtension); |
| 5914 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 5915 | RefreshRateTableIndex, pVBInfo); |
| 5916 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5917 | HwDeviceExtension, pVBInfo); |
| 5918 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5919 | RefreshRateTableIndex, pVBInfo); |
| 5920 | } |
| 5921 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5922 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5923 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5924 | if (temp & 0xA0) { |
| 5925 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5926 | if (HwDeviceExtension->jChipType == XG27) |
| 5927 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, |
| 5928 | RefreshRateTableIndex, pVBInfo); |
| 5929 | else |
| 5930 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, |
| 5931 | RefreshRateTableIndex, pVBInfo); |
| 5932 | |
| 5933 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 5934 | RefreshRateTableIndex); |
| 5935 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 5936 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
| 5937 | pVBInfo, RefreshRateTableIndex, ModeNo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5938 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5939 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5940 | xgifb_set_lvds(xgifb_info, |
| 5941 | HwDeviceExtension->jChipType, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5942 | ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5943 | } |
| 5944 | } |
| 5945 | |
| 5946 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
| 5947 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); |
| 5948 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 5949 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5950 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5951 | } |
| 5952 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5953 | unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, |
| 5954 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5955 | unsigned short ModeNo) |
| 5956 | { |
| 5957 | unsigned short ModeIdIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5958 | struct vb_device_info VBINF; |
| 5959 | struct vb_device_info *pVBInfo = &VBINF; |
Dmitry Eremin-Solenikov | 9a801f2 | 2012-03-19 21:50:13 +0400 | [diff] [blame] | 5960 | pVBInfo->BaseAddr = xgifb_info->vga_base; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5961 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5962 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5963 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5964 | pVBInfo->IF_DEF_YPbPr = 0; |
| 5965 | pVBInfo->IF_DEF_HiVision = 0; |
| 5966 | pVBInfo->IF_DEF_CRT2Monitor = 0; |
| 5967 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5968 | } else { |
| 5969 | pVBInfo->IF_DEF_YPbPr = 1; |
| 5970 | pVBInfo->IF_DEF_HiVision = 1; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 5971 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5972 | } |
| 5973 | |
| 5974 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; |
| 5975 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; |
| 5976 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; |
| 5977 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; |
| 5978 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; |
| 5979 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; |
| 5980 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; |
| 5981 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; |
| 5982 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; |
| 5983 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; |
| 5984 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; |
| 5985 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; |
| 5986 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5987 | pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04; |
| 5988 | pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10; |
| 5989 | pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12; |
| 5990 | pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14; |
| 5991 | pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5992 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5993 | /* for x86 Linux, XG21 LVDS */ |
| 5994 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5995 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5996 | pVBInfo->IF_DEF_LVDS = 1; |
| 5997 | } |
| 5998 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5999 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 6000 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6001 | pVBInfo->IF_DEF_LVDS = 1; |
| 6002 | } |
| 6003 | } |
| 6004 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6005 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6006 | XGI_GetVBType(pVBInfo); |
| 6007 | |
| 6008 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
Aaro Koskinen | ef497f4 | 2011-11-27 23:03:21 +0200 | [diff] [blame] | 6009 | if (ModeNo & 0x80) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6010 | ModeNo = ModeNo & 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6011 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6012 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6013 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6014 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
| 6015 | |
| 6016 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 6017 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6018 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6019 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 6020 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6021 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6022 | XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6023 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6024 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6025 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6026 | ModeIdIndex, pVBInfo); |
| 6027 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6028 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6029 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 6030 | HwDeviceExtension, pVBInfo); |
| 6031 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 6032 | } else if (!(pVBInfo->VBInfo & SwitchCRT2)) { |
| 6033 | XGI_SetCRT1Group(xgifb_info, |
| 6034 | HwDeviceExtension, ModeNo, |
| 6035 | ModeIdIndex, pVBInfo); |
| 6036 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 6037 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 6038 | HwDeviceExtension, |
| 6039 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6040 | } |
| 6041 | } |
| 6042 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6043 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6044 | switch (HwDeviceExtension->ujVBChipID) { |
| 6045 | case VB_CHIP_301: |
| 6046 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 6047 | pVBInfo); /*add for CRT2 */ |
| 6048 | break; |
| 6049 | |
| 6050 | case VB_CHIP_302: |
| 6051 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 6052 | pVBInfo); /*add for CRT2 */ |
| 6053 | break; |
| 6054 | |
| 6055 | default: |
| 6056 | break; |
| 6057 | } |
| 6058 | } |
| 6059 | |
| 6060 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
| 6061 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6062 | XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6063 | } /* !XG20 */ |
| 6064 | else { |
| 6065 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6066 | if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6067 | ModeIdIndex, |
| 6068 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6069 | return 0; |
| 6070 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 6071 | pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex]. |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6072 | Ext_ModeFlag & ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6073 | |
| 6074 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 6075 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6076 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6077 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6078 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6079 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
| 6080 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6081 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6082 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6083 | } |
| 6084 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6085 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
| 6086 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 6087 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6088 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6089 | |
| 6090 | return 1; |
| 6091 | } |