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; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 27 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 28 | pVBInfo->LCDResInfo = 0; |
| 29 | pVBInfo->LCDTypeInfo = 0; |
| 30 | pVBInfo->LCDInfo = 0; |
| 31 | pVBInfo->VBInfo = 0; |
| 32 | pVBInfo->TVInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 33 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 34 | pVBInfo->SR15 = XGI340_SR13; |
| 35 | pVBInfo->CR40 = XGI340_cr41; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 36 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 37 | /* 310 customization related */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 38 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 39 | pVBInfo->LCDCapList = XGI_LCDDLCapList; |
| 40 | else |
| 41 | pVBInfo->LCDCapList = XGI_LCDCapList; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 42 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 43 | if (ChipType >= XG20) |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 44 | pVBInfo->XGINew_CR97 = 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 45 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 46 | if (ChipType == XG27) { |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 47 | unsigned char temp; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 48 | pVBInfo->MCLKData = XGI27New_MCLKData; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 49 | pVBInfo->CR40 = XGI27_cr41; |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 50 | pVBInfo->XGINew_CR97 = 0xc1; |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 51 | pVBInfo->SR15 = XG27_SR13; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 52 | |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 53 | /*Z11m DDR*/ |
| 54 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B); |
| 55 | /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */ |
| 56 | if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08)) |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 57 | pVBInfo->XGINew_CR97 = 0x80; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 58 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 59 | |
| 60 | } |
| 61 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 62 | static void XGI_SetSeqRegs(unsigned short ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 63 | unsigned short ModeIdIndex, |
| 64 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 65 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 66 | unsigned char tempah, SRdata; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 67 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 68 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 69 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 70 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 71 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 72 | tempah = XGI330_StandTable.SR[0]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 73 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 74 | i = XGI_SetCRT2ToLCDA; |
| 75 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 76 | tempah |= 0x01; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 77 | } else if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { |
| 78 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 79 | tempah |= 0x01; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 80 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 81 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 82 | tempah |= 0x20; /* screen off */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 83 | xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 84 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 85 | for (i = 02; i <= 04; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 86 | /* Get SR2,3,4 from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 87 | SRdata = XGI330_StandTable.SR[i - 1]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 88 | xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 89 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 90 | } |
| 91 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 92 | static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 93 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 94 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 95 | unsigned char CRTCdata; |
| 96 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 97 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 98 | CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 99 | CRTCdata &= 0x7f; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 100 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 101 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 102 | for (i = 0; i <= 0x18; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 103 | /* Get CRTC from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 104 | CRTCdata = XGI330_StandTable.CRTC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 105 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 106 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 107 | } |
| 108 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 109 | static void XGI_SetATTRegs(unsigned short ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 110 | unsigned short ModeIdIndex, |
| 111 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 112 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 113 | unsigned char ARdata; |
| 114 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 115 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 116 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 117 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 118 | for (i = 0; i <= 0x13; i++) { |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 119 | ARdata = XGI330_StandTable.ATTR[i]; |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 120 | |
| 121 | if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */ |
| 122 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 123 | ARdata = 0; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 124 | } else if ((pVBInfo->VBInfo & |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 125 | (SetCRT2ToTV | SetCRT2ToLCD)) && |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 126 | (pVBInfo->VBInfo & SetInSlaveMode)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 127 | ARdata = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 128 | } |
| 129 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 130 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 131 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 132 | outb(i, pVBInfo->P3c0); /* set index */ |
| 133 | outb(ARdata, pVBInfo->P3c0); /* set data */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 134 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 135 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 136 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 137 | outb(0x14, pVBInfo->P3c0); /* set index */ |
| 138 | outb(0x00, pVBInfo->P3c0); /* set data */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 139 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 140 | outb(0x20, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 141 | } |
| 142 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 143 | static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 144 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 145 | unsigned char GRdata; |
| 146 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 147 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 148 | for (i = 0; i <= 0x08; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 149 | /* Get GR from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 150 | GRdata = XGI330_StandTable.GRC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 151 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 152 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 153 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 154 | if (pVBInfo->ModeType > ModeVGA) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 155 | GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 156 | GRdata &= 0xBF; /* 256 color disable */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 157 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 158 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 159 | } |
| 160 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 161 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 162 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 163 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 164 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 165 | for (i = 0x0A; i <= 0x0E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 166 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
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 unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 170 | { |
| 171 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 172 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 173 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[0].SR2B); |
| 174 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[0].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 175 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 176 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 177 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[1].SR2B); |
| 178 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[1].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 179 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 180 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 181 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 182 | } |
| 183 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 184 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 185 | unsigned short ModeIdIndex, |
| 186 | unsigned short RefreshRateTableIndex, unsigned short *i, |
| 187 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 188 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 189 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 190 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 191 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 192 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 193 | tempbx = XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 194 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 195 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 196 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 197 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 198 | tempax |= SupportRAMDAC2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 199 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 200 | if (pVBInfo->VBType & VB_XGI301C) |
| 201 | tempax |= SupportCRT2in301C; |
| 202 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 203 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 204 | /* 301b */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 205 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 206 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 207 | |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 208 | if (pVBInfo->LCDResInfo != Panel_1280x1024 && |
| 209 | pVBInfo->LCDResInfo != Panel_1280x960 && |
| 210 | (pVBInfo->LCDInfo & LCDNonExpanding) && |
| 211 | resinfo >= 9) |
| 212 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 213 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 214 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 215 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */ |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 216 | tempax |= SupportHiVision; |
| 217 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 218 | ((resinfo == 4) || |
| 219 | (resinfo == 3 && |
| 220 | (pVBInfo->SetFlag & TVSimuMode)) || |
| 221 | (resinfo > 7))) |
Miguel Gómez | 3b17562 | 2012-07-06 12:40:46 +0200 | [diff] [blame] | 222 | return 0; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 223 | } else if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 224 | SetCRT2ToSVIDEO | |
| 225 | SetCRT2ToSCART | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 226 | SetCRT2ToYPbPr525750 | |
| 227 | SetCRT2ToHiVision)) { |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 228 | tempax |= SupportTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 229 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 230 | if (pVBInfo->VBType & (VB_SIS301B | |
| 231 | VB_SIS302B | |
| 232 | VB_SIS301LV | |
| 233 | VB_SIS302LV | |
| 234 | VB_XGI301C)) |
| 235 | tempax |= SupportTV1024; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 236 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 237 | if (!(pVBInfo->VBInfo & TVSetPAL) && |
| 238 | (modeflag & NoSupportSimuTV) && |
| 239 | (pVBInfo->VBInfo & SetInSlaveMode) && |
| 240 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
| 241 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 242 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 243 | } else if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* for LVDS */ |
| 244 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 245 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 246 | if (resinfo > 0x08) |
| 247 | return 0; /* 1024x768 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 248 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 249 | if (pVBInfo->LCDResInfo < Panel_1024x768) { |
| 250 | if (resinfo > 0x07) |
| 251 | return 0; /* 800x600 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 252 | |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 253 | if (resinfo == 0x04) |
| 254 | return 0; /* 512x384 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 255 | } |
| 256 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 257 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 258 | for (; XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 259 | tempbx; (*i)--) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 260 | infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 261 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 262 | if (infoflag & tempax) |
| 263 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 264 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 265 | if ((*i) == 0) |
| 266 | break; |
| 267 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 268 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 269 | for ((*i) = 0;; (*i)++) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 270 | infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 271 | Ext_InfoFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 272 | if (XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 273 | != tempbx) { |
| 274 | return 0; |
| 275 | } |
| 276 | |
| 277 | if (infoflag & tempax) |
| 278 | return 1; |
| 279 | } |
| 280 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 281 | } |
| 282 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 283 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 284 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 285 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 286 | unsigned short sync, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 287 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 288 | /* di+0x00 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 289 | sync = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 290 | sync &= 0xC0; |
| 291 | temp = 0x2F; |
| 292 | temp |= sync; |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 293 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 294 | } |
| 295 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 296 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 297 | struct xgi_hw_device_info *HwDeviceExtension) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 298 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 299 | unsigned char data, data1, pushax; |
| 300 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 301 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 302 | /* unlock cr0-7 */ |
| 303 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 304 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 305 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 306 | |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 307 | data = pVBInfo->TimingH.data[0]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 308 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 309 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 310 | for (i = 0x01; i <= 0x04; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 311 | data = pVBInfo->TimingH.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 312 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 313 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 314 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 315 | for (i = 0x05; i <= 0x06; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 316 | data = pVBInfo->TimingH.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 317 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 318 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 319 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 320 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 321 | j &= 0x1F; |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 322 | data = pVBInfo->TimingH.data[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 323 | data &= 0xE0; |
| 324 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 325 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 326 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 327 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 328 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 329 | data = data - 1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 330 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 331 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 332 | data1 = data; |
| 333 | data1 &= 0xE0; |
| 334 | data &= 0x1F; |
| 335 | if (data == 0) { |
| 336 | pushax = data; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 337 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 338 | 0x0c); |
| 339 | data &= 0xFB; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 340 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 341 | data = pushax; |
| 342 | } |
| 343 | data = data - 1; |
| 344 | data |= data1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 345 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 346 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 347 | data = data >> 5; |
| 348 | data = data + 3; |
| 349 | if (data > 7) |
| 350 | data = data - 7; |
| 351 | data = data << 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 352 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 353 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 354 | } |
| 355 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 356 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
| 357 | unsigned short ModeNo, |
| 358 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 359 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 360 | unsigned char data; |
| 361 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 362 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 363 | for (i = 0x00; i <= 0x01; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 364 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 365 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 366 | } |
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 | for (i = 0x02; i <= 0x03; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 369 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 370 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 371 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 372 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 373 | for (i = 0x04; i <= 0x05; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 374 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 375 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 376 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 377 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 378 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 379 | j &= 0xC0; |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 380 | data = pVBInfo->TimingV.data[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 381 | data &= 0x3F; |
| 382 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 383 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 384 | |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 385 | data = pVBInfo->TimingV.data[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 386 | data &= 0x80; |
| 387 | data = data >> 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 388 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 389 | i = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 390 | i &= DoubleScanMode; |
| 391 | if (i) |
| 392 | data |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 393 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 394 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 395 | j &= 0x5F; |
| 396 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 397 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 398 | } |
| 399 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 400 | static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 401 | unsigned short RefreshRateTableIndex, |
| 402 | struct vb_device_info *pVBInfo, |
| 403 | struct xgi_hw_device_info *HwDeviceExtension) |
| 404 | { |
| 405 | unsigned char index, data; |
| 406 | unsigned short i; |
| 407 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 408 | /* Get index */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 409 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 410 | index = index & IndexMask; |
| 411 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 412 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 413 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 414 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 415 | |
| 416 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 417 | pVBInfo->TimingH.data[i] |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 418 | = XGI_CRT1Table[index].CR[i]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 419 | |
| 420 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 421 | pVBInfo->TimingV.data[i] |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 422 | = XGI_CRT1Table[index].CR[i + 8]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 423 | |
| 424 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 425 | |
| 426 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
| 427 | |
| 428 | if (pVBInfo->ModeType > 0x03) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 429 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 430 | } |
| 431 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 432 | /* --------------------------------------------------------------------- */ |
| 433 | /* Function : XGI_SetXG21CRTC */ |
| 434 | /* Input : Stand or enhance CRTC table */ |
| 435 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ |
| 436 | /* Description : Set LCD timing */ |
| 437 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 438 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 439 | unsigned short RefreshRateTableIndex, |
| 440 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 441 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 442 | unsigned char index, Tempax, Tempbx, Tempcx, Tempdx; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 443 | unsigned short Temp1, Temp2, Temp3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 444 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 445 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 446 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 447 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 448 | Tempcx = Tempax; /* Tempcx: HRS */ |
| 449 | /* SR2E[7:0]->HRS */ |
| 450 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 451 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 452 | Tempdx = XGI_CRT1Table[index].CR[5]; /* SRB */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 453 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ |
| 454 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ |
| 455 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ |
| 456 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 457 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 458 | Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 459 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 460 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 461 | Tempbx = XGI_CRT1Table[index].CR[6]; /* SRC */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 462 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ |
| 463 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ |
| 464 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 465 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 466 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
| 467 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 468 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 469 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
| 470 | if (Tempax < Tempcx) /* HRE < HRS */ |
| 471 | Temp2 |= 0x40; /* Temp2 + 0x40 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 472 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 473 | Temp2 &= 0xFF; |
| 474 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ |
| 475 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ |
| 476 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ |
| 477 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ |
| 478 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
| 479 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 480 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 481 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 482 | /* CR10 VRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 483 | Tempax = XGI_CRT1Table[index].CR[10]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 484 | Tempbx = Tempax; /* Tempbx: VRS */ |
| 485 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ |
| 486 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
| 487 | /* CR7[2][7] VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 488 | Tempax = XGI_CRT1Table[index].CR[9]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 489 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
| 490 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ |
| 491 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ |
| 492 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ |
| 493 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 494 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 495 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
| 496 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ |
| 497 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 498 | Tempax &= 0x80; |
| 499 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 500 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
| 501 | /* Tempax: SRA */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 502 | Tempax = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 503 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
| 504 | Temp2 = Tempax; |
| 505 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ |
| 506 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 507 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 508 | /* Tempax: CR11 VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 509 | Tempax = XGI_CRT1Table[index].CR[11]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 510 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 511 | /* Tempbx: SRA */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 512 | Tempbx = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 513 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
| 514 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 515 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 516 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ |
| 517 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 518 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 519 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
| 520 | if (Tempax < Temp3) /* VRE < VRS */ |
| 521 | Temp2 |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 522 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 523 | Temp2 &= 0xFF; |
| 524 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ |
| 525 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ |
| 526 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 527 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ |
| 528 | Tempbx = (unsigned char) Temp1; |
| 529 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ |
| 530 | Tempax &= 0x7F; |
| 531 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 532 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 533 | } |
| 534 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 535 | static void XGI_SetXG27CRTC(unsigned short ModeNo, |
| 536 | unsigned short ModeIdIndex, |
| 537 | unsigned short RefreshRateTableIndex, |
| 538 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 539 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 540 | unsigned short index, Tempax, Tempbx, Tempcx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 541 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 542 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 543 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 544 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 545 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
| 546 | /* SR2E[7:0]->HRS */ |
| 547 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 548 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 549 | /* SR0B */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 550 | Tempax = XGI_CRT1Table[index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 551 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 552 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 553 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 554 | Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 555 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
| 556 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 557 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 558 | Tempax = XGI_CRT1Table[index].CR[6]; /* SRC */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 559 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ |
| 560 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ |
| 561 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 562 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 563 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
| 564 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 565 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 566 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 567 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 568 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
| 569 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ |
| 570 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 571 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 572 | Tempax = XGI_CRT1Table[index].CR[5]; /* SR0B */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 573 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 574 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ |
| 575 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ |
| 576 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
| 577 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 578 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 579 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 580 | /* CR10 VRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 581 | Tempax = XGI_CRT1Table[index].CR[10]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 582 | /* SR34[7:0]->VRS[7:0] */ |
| 583 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 584 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 585 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
| 586 | /* CR7[7][2] VRS[9][8] */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 587 | Tempax = XGI_CRT1Table[index].CR[9]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 588 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
| 589 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ |
| 590 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ |
| 591 | /* SR35[0]: VRS[8] */ |
| 592 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
| 593 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
| 594 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ |
| 595 | /* Tempax: SR0A */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 596 | Tempax = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 597 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
| 598 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 599 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 600 | /* Tempax: CR11 VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 601 | Tempax = XGI_CRT1Table[index].CR[11]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 602 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 603 | /* Tempbx: SR0A */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 604 | Tempbx = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 605 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
| 606 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 607 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 608 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ |
| 609 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ |
| 610 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 611 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 612 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
| 613 | Tempbx |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 614 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 615 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
| 616 | Tempax = (Tempbx << 2) & 0xFF; |
| 617 | /* SR3F[7:2]:VRE[5:0] */ |
| 618 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
| 619 | Tempax = Tempcx >> 8; |
| 620 | /* SR35[2:0]:VRS[10:8] */ |
| 621 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 622 | } |
| 623 | |
Aaro Koskinen | a2d08cf | 2011-11-27 23:03:08 +0200 | [diff] [blame] | 624 | static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
| 625 | { |
| 626 | unsigned char temp; |
| 627 | |
| 628 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 629 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 630 | temp = (temp & 3) << 6; |
| 631 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 632 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 633 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 634 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 635 | |
| 636 | } |
| 637 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 638 | static void xgifb_set_lcd(int chip_id, |
| 639 | struct vb_device_info *pVBInfo, |
| 640 | unsigned short RefreshRateTableIndex, |
| 641 | unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 642 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 643 | unsigned short Data, Temp; |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 644 | unsigned short XGI_P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 645 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 646 | XGI_P3cc = pVBInfo->P3cc; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 647 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 648 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 649 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 650 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 651 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 652 | |
| 653 | if (chip_id == XG27) { |
| 654 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 655 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
| 656 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 657 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
| 658 | } |
| 659 | } |
| 660 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 661 | if (chip_id == XG27) { |
| 662 | XGI_SetXG27FPBits(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 663 | } else { |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 664 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 665 | if (Temp & 0x01) { |
| 666 | /* 18 bits FP */ |
| 667 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); |
| 668 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
| 669 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 670 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 671 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 672 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 673 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 674 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 675 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 676 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 677 | Data = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 678 | if (Data & 0x4000) |
| 679 | /* Hsync polarity */ |
| 680 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
| 681 | if (Data & 0x8000) |
| 682 | /* Vsync polarity */ |
| 683 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | /* --------------------------------------------------------------------- */ |
| 687 | /* Function : XGI_UpdateXG21CRTC */ |
| 688 | /* Input : */ |
| 689 | /* Output : CRT1 CRTC */ |
| 690 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 691 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 692 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 693 | struct vb_device_info *pVBInfo, |
| 694 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 695 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 696 | int index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 697 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 698 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 699 | if (ModeNo == 0x2E && |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 700 | (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 701 | RES640x480x60)) |
| 702 | index = 12; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 703 | else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 704 | Ext_CRT1CRTC == RES640x480x72)) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 705 | index = 13; |
| 706 | else if (ModeNo == 0x2F) |
| 707 | index = 14; |
| 708 | else if (ModeNo == 0x50) |
| 709 | index = 15; |
| 710 | else if (ModeNo == 0x59) |
| 711 | index = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 712 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 713 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 714 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 715 | XGI_UpdateCRT1Table[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 716 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 717 | XGI_UpdateCRT1Table[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 718 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 719 | XGI_UpdateCRT1Table[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 720 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 721 | XGI_UpdateCRT1Table[index].CR16); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 722 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 723 | } |
| 724 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 725 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 726 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 727 | unsigned short RefreshRateTableIndex, |
| 728 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 729 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 730 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 731 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 732 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 733 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 734 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 735 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 736 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 737 | tempax = XGI330_ModeResInfo[resindex].HTotal; |
| 738 | tempbx = XGI330_ModeResInfo[resindex].VTotal; |
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 | if (modeflag & HalfDCLK) |
| 741 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 742 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 743 | if (modeflag & HalfDCLK) |
| 744 | tempax = tempax << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 745 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 746 | temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 747 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 748 | if (temp & InterlaceMode) |
| 749 | tempbx = tempbx >> 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 & DoubleScanMode) |
| 752 | tempbx = tempbx << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 753 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 754 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 755 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 756 | tempax /= tempcx; |
| 757 | tempax -= 1; |
| 758 | tempbx -= 1; |
| 759 | tempcx = tempax; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 760 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 761 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 762 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 763 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 764 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 765 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 766 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 767 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 768 | tempax = 0; |
| 769 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 770 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 771 | if (tempbx & 0x01) |
| 772 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 773 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 774 | if (tempbx & 0x02) |
| 775 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 776 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 777 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 778 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 779 | data &= 0xFF; |
| 780 | tempax = 0; |
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 & 0x04) |
| 783 | tempax |= 0x02; |
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, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 786 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 787 | } |
| 788 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 789 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 790 | unsigned short ModeIdIndex, |
| 791 | unsigned short RefreshRateTableIndex, |
| 792 | struct xgi_hw_device_info *HwDeviceExtension, |
| 793 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 794 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 795 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 796 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 797 | /* GetOffset */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 798 | temp = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 799 | temp = temp >> 8; |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame] | 800 | temp = XGI330_ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 801 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 802 | temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 803 | temp2 &= InterlaceMode; |
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 | if (temp2) |
| 806 | temp = temp << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 807 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 808 | temp2 = pVBInfo->ModeType - ModeEGA; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 809 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 810 | switch (temp2) { |
| 811 | case 0: |
| 812 | temp2 = 1; |
| 813 | break; |
| 814 | case 1: |
| 815 | temp2 = 2; |
| 816 | break; |
| 817 | case 2: |
| 818 | temp2 = 4; |
| 819 | break; |
| 820 | case 3: |
| 821 | temp2 = 4; |
| 822 | break; |
| 823 | case 4: |
| 824 | temp2 = 6; |
| 825 | break; |
| 826 | case 5: |
| 827 | temp2 = 8; |
| 828 | break; |
| 829 | default: |
| 830 | break; |
| 831 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 832 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 833 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 834 | temp = temp * temp2 + temp2 / 2; |
| 835 | else |
| 836 | temp *= temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 837 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 838 | /* SetOffset */ |
| 839 | DisplayUnit = temp; |
| 840 | temp2 = temp; |
| 841 | temp = temp >> 8; /* ah */ |
| 842 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 843 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 844 | i &= 0xF0; |
| 845 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 846 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 847 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 848 | temp = (unsigned char) temp2; |
| 849 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 850 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 851 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 852 | /* SetDisplayUnit */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 853 | temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 854 | temp2 &= InterlaceMode; |
| 855 | if (temp2) |
| 856 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 857 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 858 | DisplayUnit = DisplayUnit << 5; |
| 859 | ah = (DisplayUnit & 0xff00) >> 8; |
| 860 | al = DisplayUnit & 0x00ff; |
| 861 | if (al == 0) |
| 862 | ah += 1; |
| 863 | else |
| 864 | ah += 2; |
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 | if (HwDeviceExtension->jChipType >= XG20) |
| 867 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 868 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 869 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 870 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 871 | } |
| 872 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 873 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
| 874 | unsigned short ModeIdIndex, |
| 875 | unsigned short RefreshRateTableIndex, |
| 876 | struct xgi_hw_device_info *HwDeviceExtension, |
| 877 | struct vb_device_info *pVBInfo) |
| 878 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 879 | unsigned short CRT2Index, VCLKIndex; |
| 880 | unsigned short modeflag, resinfo; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 881 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 882 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 883 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 884 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 885 | CRT2Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 886 | |
| 887 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 888 | CRT2Index = CRT2Index >> 6; /* for LCD */ |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 889 | if (pVBInfo->VBInfo & |
| 890 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 891 | if (pVBInfo->LCDResInfo != Panel_1024x768) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 892 | /* LCDXlat2VCLK */ |
| 893 | VCLKIndex = VCLK108_2_315 + 5; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 894 | else |
Peter Huewe | f477d3e | 2012-06-14 00:21:47 +0200 | [diff] [blame] | 895 | VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 896 | } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 897 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 898 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 899 | else |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 900 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 901 | |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 902 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 903 | if (modeflag & Charx8Dot) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 904 | VCLKIndex = TVCLKBASE_315_25 + |
| 905 | HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 906 | } else { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 907 | VCLKIndex = TVCLKBASE_315_25 + |
| 908 | HiTVTextVCLK; |
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 | } |
| 911 | |
| 912 | /* 301lv */ |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 913 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 914 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 915 | VCLKIndex = YPbPr525iVCLK_2; |
| 916 | else |
| 917 | VCLKIndex = YPbPr525iVCLK; |
| 918 | } |
| 919 | } else if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 920 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 921 | VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 922 | else |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 923 | VCLKIndex = TVCLKBASE_315_25 + TVVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 924 | } else { /* for CRT2 */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 925 | /* di+Ext_CRTVCLK */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 926 | VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 927 | Ext_CRTVCLK; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 928 | VCLKIndex &= IndexMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 929 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 930 | } else if ((pVBInfo->LCDResInfo == Panel_800x600) || |
| 931 | (pVBInfo->LCDResInfo == Panel_320x480)) { /* LVDS */ |
| 932 | VCLKIndex = VCLK40; /* LVDSXlat1VCLK */ |
| 933 | } else { |
| 934 | VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK, LVDSXlat3VCLK */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 935 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 936 | |
| 937 | return VCLKIndex; |
| 938 | } |
| 939 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 940 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
| 941 | unsigned short ModeIdIndex, |
| 942 | struct xgi_hw_device_info *HwDeviceExtension, |
| 943 | unsigned short RefreshRateTableIndex, |
| 944 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 945 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 946 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 947 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 948 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 949 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 950 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 951 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 952 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 953 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B); |
| 954 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 955 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 956 | } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 957 | | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 958 | & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 959 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, |
| 960 | RefreshRateTableIndex, HwDeviceExtension, |
| 961 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 962 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 963 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 964 | data = XGI_VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 965 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 966 | data = XGI_VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 967 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 968 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 969 | } else { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 970 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 971 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 972 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 973 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B); |
| 974 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 975 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 976 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 977 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 978 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 979 | if (XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 980 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 981 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 982 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 983 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 984 | index = data; |
| 985 | index &= 0xE0; |
| 986 | data &= 0x1F; |
| 987 | data = data << 1; |
| 988 | data += 1; |
| 989 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 990 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 991 | } |
| 992 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 993 | } |
| 994 | |
Aaro Koskinen | e85f203 | 2011-11-27 23:03:07 +0200 | [diff] [blame] | 995 | static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
| 996 | { |
| 997 | unsigned char temp; |
| 998 | |
| 999 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
| 1000 | temp = (temp & 1) << 6; |
| 1001 | /* SR06[6] 18bit Dither */ |
| 1002 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 1003 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 1004 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 1005 | |
| 1006 | } |
| 1007 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1008 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1009 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1010 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1011 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1012 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1013 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1014 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1015 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1016 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1017 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1018 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
| 1019 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
| 1020 | data &= 0xC0; |
| 1021 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
| 1022 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
| 1023 | data |= 0x01; |
| 1024 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1025 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1026 | if (HwDeviceExtension->jChipType == XG21) |
| 1027 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1028 | } |
| 1029 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1030 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
| 1031 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, |
| 1032 | struct vb_device_info *pVBInfo) |
| 1033 | { |
| 1034 | unsigned short data, data2 = 0; |
| 1035 | short VCLK; |
| 1036 | |
| 1037 | unsigned char index; |
| 1038 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1039 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1040 | index &= IndexMask; |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 1041 | VCLK = XGI_VCLKData[index].CLOCK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1042 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1043 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1044 | data &= 0xf3; |
| 1045 | if (VCLK >= 200) |
| 1046 | data |= 0x0c; /* VCLK > 200 */ |
| 1047 | |
| 1048 | if (HwDeviceExtension->jChipType >= XG20) |
| 1049 | data &= ~0x04; /* 2 pixel mode */ |
| 1050 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1051 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1052 | |
| 1053 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1054 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1055 | data &= 0xE7; |
| 1056 | if (VCLK < 200) |
| 1057 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1058 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1059 | } |
| 1060 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1061 | data2 = 0x00; |
| 1062 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1063 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1064 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1065 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1066 | |
| 1067 | } |
| 1068 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1069 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1070 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1071 | unsigned short RefreshRateTableIndex, |
| 1072 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1073 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1074 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1075 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1076 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1077 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1078 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1079 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1080 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1081 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1082 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1083 | data = infoflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1084 | data2 = 0; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1085 | data2 |= 0x02; |
| 1086 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1087 | data3 = data3 << 2; |
| 1088 | data2 |= data3; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1089 | data &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1090 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1091 | if (data) |
| 1092 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1093 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1094 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1095 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 1096 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1097 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1098 | data = 0x0000; |
| 1099 | if (infoflag & InterlaceMode) { |
| 1100 | if (xres == 1024) |
| 1101 | data = 0x0035; |
| 1102 | else if (xres == 1280) |
| 1103 | data = 0x0048; |
| 1104 | } |
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 | data2 = data & 0x00FF; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1107 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1108 | data2 = (data & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1109 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1110 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1111 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1112 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
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 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1115 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1116 | if (modeflag & LineCompareOff) |
| 1117 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1118 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1119 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1120 | data = 0x60; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1121 | data = data ^ 0x60; |
| 1122 | data = data ^ 0xA0; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1123 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1124 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1125 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, |
| 1126 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1127 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1128 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1129 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1130 | if (HwDeviceExtension->jChipType == XG27) { |
| 1131 | if (data & 0x40) |
| 1132 | data = 0x2c; |
| 1133 | else |
| 1134 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1135 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1136 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1137 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1138 | if (data & 0x40) |
| 1139 | data = 0x33; |
| 1140 | else |
| 1141 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1142 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1143 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1144 | } else { |
| 1145 | if (data & 0x40) |
| 1146 | data = 0x2c; |
| 1147 | else |
| 1148 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1149 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1150 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1151 | |
| 1152 | } |
| 1153 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1154 | static void XGI_WriteDAC(unsigned short dl, |
| 1155 | unsigned short ah, |
| 1156 | unsigned short al, |
| 1157 | unsigned short dh, |
| 1158 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1159 | { |
| 1160 | unsigned short temp, bh, bl; |
| 1161 | |
| 1162 | bh = ah; |
| 1163 | bl = al; |
| 1164 | |
| 1165 | if (dl != 0) { |
| 1166 | temp = bh; |
| 1167 | bh = dh; |
| 1168 | dh = temp; |
| 1169 | if (dl == 1) { |
| 1170 | temp = bl; |
| 1171 | bl = dh; |
| 1172 | dh = temp; |
| 1173 | } else { |
| 1174 | temp = bl; |
| 1175 | bl = bh; |
| 1176 | bh = temp; |
| 1177 | } |
| 1178 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1179 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1180 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1181 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1182 | } |
| 1183 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1184 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1185 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1186 | { |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1187 | unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh; |
| 1188 | const unsigned short *table = XGINew_VGA_DAC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1189 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1190 | outb(0xFF, pVBInfo->P3c6); |
| 1191 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1192 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1193 | for (i = 0; i < 16; i++) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1194 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1195 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1196 | for (k = 0; k < 3; k++) { |
| 1197 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1198 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1199 | if (data & 0x01) |
| 1200 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1201 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1202 | if (data & 0x02) |
| 1203 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1204 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1205 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1206 | data = data >> 2; |
| 1207 | } |
| 1208 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1209 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1210 | for (i = 16; i < 32; i++) { |
| 1211 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1212 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1213 | for (k = 0; k < 3; k++) |
| 1214 | outb(data, pVBInfo->P3c9); |
| 1215 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1216 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1217 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1218 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1219 | for (m = 0; m < 9; m++) { |
| 1220 | di = si; |
| 1221 | bx = si + 0x04; |
| 1222 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1223 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1224 | for (n = 0; n < 3; n++) { |
| 1225 | for (o = 0; o < 5; o++) { |
| 1226 | dh = table[si]; |
| 1227 | ah = table[di]; |
| 1228 | al = table[bx]; |
| 1229 | si++; |
| 1230 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1231 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1232 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1233 | si -= 2; |
| 1234 | |
| 1235 | for (o = 0; o < 3; o++) { |
| 1236 | dh = table[bx]; |
| 1237 | ah = table[di]; |
| 1238 | al = table[si]; |
| 1239 | si--; |
| 1240 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1241 | } |
| 1242 | |
| 1243 | dl++; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1244 | } |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1245 | |
| 1246 | si += 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1247 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1248 | } |
| 1249 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1250 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
| 1251 | unsigned short ModeIdIndex, |
| 1252 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1253 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1254 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1255 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1256 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1257 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1258 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1259 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1260 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1261 | |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 1262 | xres = XGI330_ModeResInfo[resindex].HTotal; |
| 1263 | yres = XGI330_ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1264 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1265 | if (modeflag & HalfDCLK) |
| 1266 | xres = xres << 1; |
| 1267 | |
| 1268 | if (modeflag & DoubleScanMode) |
| 1269 | yres = yres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1270 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1271 | if (xres == 720) |
| 1272 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1273 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1274 | pVBInfo->VGAHDE = xres; |
| 1275 | pVBInfo->HDE = xres; |
| 1276 | pVBInfo->VGAVDE = yres; |
| 1277 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1278 | } |
| 1279 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1280 | static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table, |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1281 | unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1282 | unsigned short ModeIdIndex, |
| 1283 | unsigned short RefreshRateTableIndex, |
| 1284 | struct vb_device_info *pVBInfo) |
| 1285 | { |
Aaro Koskinen | 6c27b37 | 2012-11-04 21:14:45 +0200 | [diff] [blame] | 1286 | unsigned short i, tempdx, tempbx, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1287 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1288 | tempbx = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1289 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1290 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1291 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1292 | i = 0; |
| 1293 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1294 | while (table[i].PANELID != 0xff) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1295 | tempdx = pVBInfo->LCDResInfo; |
| 1296 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 1297 | tempbx &= (~0x0080); |
| 1298 | tempdx = pVBInfo->LCDTypeInfo; |
| 1299 | } |
| 1300 | |
| 1301 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1302 | tempdx &= (~PanelResInfo); |
| 1303 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1304 | if (table[i].PANELID == tempdx) { |
| 1305 | tempbx = table[i].MASK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1306 | tempdx = pVBInfo->LCDInfo; |
| 1307 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1308 | if (modeflag & HalfDCLK) |
| 1309 | tempdx |= SetLCDLowResolution; |
| 1310 | |
| 1311 | tempbx &= tempdx; |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1312 | if (tempbx == table[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1313 | break; |
| 1314 | } |
| 1315 | i++; |
| 1316 | } |
| 1317 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1318 | return table[i].DATAPTR; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1319 | } |
| 1320 | |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 1321 | static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1322 | unsigned short ModeIdIndex, |
| 1323 | unsigned short RefreshRateTableIndex, |
| 1324 | struct vb_device_info *pVBInfo) |
| 1325 | { |
Aaro Koskinen | 56d276c | 2012-09-11 00:15:19 +0300 | [diff] [blame] | 1326 | unsigned short i, tempdx, tempal, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1327 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1328 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1329 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1330 | tempal = tempal & 0x3f; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1331 | tempdx = pVBInfo->TVInfo; |
| 1332 | |
| 1333 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 1334 | tempdx = tempdx | SetTVLockMode; |
| 1335 | |
| 1336 | if (modeflag & HalfDCLK) |
| 1337 | tempdx = tempdx | SetTVLowResolution; |
| 1338 | |
| 1339 | i = 0; |
| 1340 | |
Aaro Koskinen | 6265ee4 | 2012-09-11 00:15:20 +0300 | [diff] [blame] | 1341 | while (XGI_TVDataTable[i].MASK != 0xffff) { |
| 1342 | if ((tempdx & XGI_TVDataTable[i].MASK) == |
| 1343 | XGI_TVDataTable[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1344 | break; |
| 1345 | i++; |
| 1346 | } |
| 1347 | |
Aaro Koskinen | 18ba866 | 2012-09-11 00:15:22 +0300 | [diff] [blame] | 1348 | return &XGI_TVDataTable[i].DATAPTR[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1349 | } |
| 1350 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1351 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1352 | unsigned short RefreshRateTableIndex, |
| 1353 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1354 | { |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1355 | struct SiS_LVDSData const *LCDPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1356 | |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1357 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 1358 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1359 | |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1360 | LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeNo, ModeIdIndex, |
| 1361 | RefreshRateTableIndex, pVBInfo); |
| 1362 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 1363 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 1364 | pVBInfo->HT = LCDPtr->LCDHT; |
| 1365 | pVBInfo->VT = LCDPtr->LCDVT; |
| 1366 | |
| 1367 | if (pVBInfo->LCDInfo & (SetLCDtoNonExpanding | EnableScalingLCD)) |
| 1368 | return; |
| 1369 | |
| 1370 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1371 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
| 1372 | pVBInfo->HDE = 1024; |
| 1373 | pVBInfo->VDE = 768; |
| 1374 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1375 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
| 1376 | pVBInfo->HDE = 1280; |
| 1377 | pVBInfo->VDE = 1024; |
| 1378 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
| 1379 | pVBInfo->HDE = 1400; |
| 1380 | pVBInfo->VDE = 1050; |
| 1381 | } else { |
| 1382 | pVBInfo->HDE = 1600; |
| 1383 | pVBInfo->VDE = 1200; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1384 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1385 | } |
| 1386 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1387 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1388 | unsigned short RefreshRateTableIndex, |
| 1389 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1390 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1391 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1392 | unsigned char index; |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1393 | unsigned short i; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1394 | struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL; |
| 1395 | struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1396 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1397 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1398 | index = index & IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1399 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1400 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1401 | LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeNo, ModeIdIndex, |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1402 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1403 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1404 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1405 | pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1406 | } |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1407 | |
| 1408 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 1409 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1410 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1411 | LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeNo, |
| 1412 | ModeIdIndex, RefreshRateTableIndex, |
| 1413 | pVBInfo); |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1414 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1415 | pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i]; |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1416 | } |
| 1417 | |
| 1418 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1419 | } |
| 1420 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1421 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 1422 | { |
| 1423 | unsigned char tempal, tempah, tempbl, i; |
| 1424 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1425 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1426 | tempal = tempah & 0x0F; |
| 1427 | tempah = tempah & 0xF0; |
| 1428 | i = 0; |
| 1429 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1430 | |
| 1431 | while (tempbl != 0xFF) { |
| 1432 | if (tempbl & 0x80) { /* OEMUtil */ |
| 1433 | tempal = tempah; |
| 1434 | tempbl = tempbl & ~(0x80); |
| 1435 | } |
| 1436 | |
| 1437 | if (tempal == tempbl) |
| 1438 | break; |
| 1439 | |
| 1440 | i++; |
| 1441 | |
| 1442 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1443 | } |
| 1444 | |
| 1445 | return i; |
| 1446 | } |
| 1447 | |
| 1448 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 1449 | { |
| 1450 | unsigned short tempah, tempal, tempbl, i; |
| 1451 | |
| 1452 | tempal = pVBInfo->LCDResInfo; |
| 1453 | tempah = pVBInfo->LCDTypeInfo; |
| 1454 | |
| 1455 | i = 0; |
| 1456 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1457 | |
| 1458 | while (tempbl != 0xFF) { |
| 1459 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 1460 | tempal = tempah; |
| 1461 | tempbl &= ~0x80; |
| 1462 | } |
| 1463 | |
| 1464 | if (tempal == tempbl) |
| 1465 | break; |
| 1466 | |
| 1467 | i++; |
| 1468 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1469 | } |
| 1470 | |
| 1471 | if (tempbl == 0xFF) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1472 | pVBInfo->LCDResInfo = Panel_1024x768; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1473 | pVBInfo->LCDTypeInfo = 0; |
| 1474 | i = 0; |
| 1475 | } |
| 1476 | |
| 1477 | return i; |
| 1478 | } |
| 1479 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1480 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 1481 | unsigned short *VSyncWidth, |
| 1482 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1483 | { |
| 1484 | unsigned short Index; |
| 1485 | |
| 1486 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 1487 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 1488 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
| 1489 | |
| 1490 | return; |
| 1491 | } |
| 1492 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1493 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1494 | unsigned short RefreshRateTableIndex, |
| 1495 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1496 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1497 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 1498 | unsigned long temp, temp1, temp2, temp3, push3; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1499 | struct XGI_LCDDesStruct const *LCDPtr = NULL; |
| 1500 | struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1501 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1502 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 1503 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1504 | LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, |
| 1505 | ModeIdIndex, RefreshRateTableIndex, |
| 1506 | pVBInfo); |
Aaro Koskinen | 66cface | 2011-08-31 21:46:13 +0300 | [diff] [blame] | 1507 | else |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1508 | LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, |
| 1509 | ModeIdIndex, RefreshRateTableIndex, |
| 1510 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1511 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1512 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 1513 | push1 = tempbx; |
| 1514 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1515 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1516 | /* GetLCDResInfo */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1517 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1518 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1519 | tempax = 1024; |
| 1520 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1521 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1522 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1523 | tempax = 1280; |
| 1524 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1525 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1526 | tempax = 1400; |
| 1527 | tempbx = 1050; |
| 1528 | } else { |
| 1529 | tempax = 1600; |
| 1530 | tempbx = 1200; |
| 1531 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1532 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1533 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 1534 | pVBInfo->HDE = tempax; |
| 1535 | pVBInfo->VDE = tempbx; |
| 1536 | pVBInfo->VGAHDE = tempax; |
| 1537 | pVBInfo->VGAVDE = tempbx; |
| 1538 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1539 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1540 | tempax = pVBInfo->HT; |
| 1541 | |
| 1542 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1543 | tempbx = LCDPtr1->LCDHDES; |
| 1544 | else |
| 1545 | tempbx = LCDPtr->LCDHDES; |
| 1546 | |
| 1547 | tempcx = pVBInfo->HDE; |
| 1548 | tempbx = tempbx & 0x0fff; |
| 1549 | tempcx += tempbx; |
| 1550 | |
| 1551 | if (tempcx >= tempax) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1552 | tempcx -= tempax; |
| 1553 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1554 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1555 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1556 | tempcx = tempcx >> 3; |
| 1557 | tempbx = tempbx >> 3; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1558 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1559 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 1560 | (unsigned short) (tempbx & 0xff)); |
| 1561 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 1562 | (unsigned short) (tempcx & 0xff)); |
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 | tempax = pVBInfo->HT; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1565 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1566 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1567 | tempbx = LCDPtr1->LCDHRS; |
| 1568 | else |
| 1569 | tempbx = LCDPtr->LCDHRS; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1570 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1571 | tempcx = push2; |
| 1572 | |
| 1573 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1574 | tempcx = LCDPtr1->LCDHSync; |
| 1575 | |
| 1576 | tempcx += tempbx; |
| 1577 | |
| 1578 | if (tempcx >= tempax) |
| 1579 | tempcx -= tempax; |
| 1580 | |
| 1581 | tempax = tempbx & 0x07; |
| 1582 | tempax = tempax >> 5; |
| 1583 | tempcx = tempcx >> 3; |
| 1584 | tempbx = tempbx >> 3; |
| 1585 | |
| 1586 | tempcx &= 0x1f; |
| 1587 | tempax |= tempcx; |
| 1588 | |
| 1589 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 1590 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 1591 | (unsigned short) (tempbx & 0xff)); |
| 1592 | |
| 1593 | tempax = pVBInfo->VT; |
| 1594 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1595 | tempbx = LCDPtr1->LCDVDES; |
| 1596 | else |
| 1597 | tempbx = LCDPtr->LCDVDES; |
| 1598 | tempcx = pVBInfo->VDE; |
| 1599 | |
| 1600 | tempbx = tempbx & 0x0fff; |
| 1601 | tempcx += tempbx; |
| 1602 | if (tempcx >= tempax) |
| 1603 | tempcx -= tempax; |
| 1604 | |
| 1605 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 1606 | (unsigned short) (tempbx & 0xff)); |
| 1607 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 1608 | (unsigned short) (tempcx & 0xff)); |
| 1609 | |
| 1610 | tempbx = (tempbx >> 8) & 0x07; |
| 1611 | tempcx = (tempcx >> 8) & 0x07; |
| 1612 | |
| 1613 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 1614 | (unsigned short) ((tempcx << 3) |
| 1615 | | tempbx)); |
| 1616 | |
| 1617 | tempax = pVBInfo->VT; |
| 1618 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1619 | tempbx = LCDPtr1->LCDVRS; |
| 1620 | else |
| 1621 | tempbx = LCDPtr->LCDVRS; |
| 1622 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1623 | tempcx = push1; |
| 1624 | |
| 1625 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1626 | tempcx = LCDPtr1->LCDVSync; |
| 1627 | |
| 1628 | tempcx += tempbx; |
| 1629 | if (tempcx >= tempax) |
| 1630 | tempcx -= tempax; |
| 1631 | |
| 1632 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 1633 | (unsigned short) (tempbx & 0xff)); |
| 1634 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 1635 | (unsigned short) (tempcx & 0x0f)); |
| 1636 | |
| 1637 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 1638 | |
| 1639 | tempbx = pVBInfo->VGAVDE; |
| 1640 | if (tempbx != pVBInfo->VDE) |
| 1641 | tempax |= 0x40; |
| 1642 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1643 | if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1644 | tempax |= 0x40; |
| 1645 | |
| 1646 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 1647 | tempax); |
| 1648 | |
| 1649 | tempcx = pVBInfo->VGAVT; |
| 1650 | tempbx = pVBInfo->VDE; |
| 1651 | tempax = pVBInfo->VGAVDE; |
| 1652 | tempcx -= tempax; |
| 1653 | |
| 1654 | temp = tempax; /* 0430 ylshieh */ |
| 1655 | temp1 = (temp << 18) / tempbx; |
| 1656 | |
| 1657 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 1658 | |
| 1659 | if (tempdx != 0) |
| 1660 | temp1 += 1; |
| 1661 | |
| 1662 | temp2 = temp1; |
| 1663 | push3 = temp2; |
| 1664 | |
| 1665 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 1666 | (unsigned short) (temp2 & 0xff)); |
| 1667 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 1668 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 1669 | |
| 1670 | tempbx = (unsigned short) (temp2 >> 16); |
| 1671 | tempax = tempbx & 0x03; |
| 1672 | |
| 1673 | tempbx = pVBInfo->VGAVDE; |
| 1674 | if (tempbx == pVBInfo->VDE) |
| 1675 | tempax |= 0x04; |
| 1676 | |
| 1677 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 1678 | |
| 1679 | if (pVBInfo->VBType & VB_XGI301C) { |
| 1680 | temp2 = push3; |
| 1681 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1682 | 0x3c, |
| 1683 | (unsigned short) (temp2 & 0xff)); |
| 1684 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1685 | 0x3b, |
| 1686 | (unsigned short) ((temp2 >> 8) & |
| 1687 | 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1688 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1689 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 1690 | ~0xc0, |
| 1691 | (unsigned short) ((tempbx & |
| 1692 | 0xff) << 6)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1693 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1694 | tempcx = pVBInfo->VGAVDE; |
| 1695 | if (tempcx == pVBInfo->VDE) |
| 1696 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1697 | 0x30, ~0x0c, 0x00); |
| 1698 | else |
| 1699 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1700 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1701 | } |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1702 | |
| 1703 | tempcx = pVBInfo->VGAHDE; |
| 1704 | tempbx = pVBInfo->HDE; |
| 1705 | |
| 1706 | temp1 = tempcx << 16; |
| 1707 | |
| 1708 | tempax = (unsigned short) (temp1 / tempbx); |
| 1709 | |
| 1710 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 1711 | tempax = 65535; |
| 1712 | |
| 1713 | temp3 = tempax; |
| 1714 | temp1 = pVBInfo->VGAHDE << 16; |
| 1715 | |
| 1716 | temp1 /= temp3; |
| 1717 | temp3 = temp3 << 16; |
| 1718 | temp1 -= 1; |
| 1719 | |
| 1720 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 1721 | |
| 1722 | tempax = (unsigned short) (temp3 & 0xff); |
| 1723 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 1724 | |
| 1725 | temp1 = pVBInfo->VGAVDE << 18; |
| 1726 | temp1 = temp1 / push3; |
| 1727 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 1728 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1729 | if (pVBInfo->LCDResInfo == Panel_1024x768) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1730 | tempbx -= 1; |
| 1731 | |
| 1732 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 1733 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 1734 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 1735 | (unsigned short) (tempax & 0xff)); |
| 1736 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 1737 | (unsigned short) (tempbx & 0xff)); |
| 1738 | |
| 1739 | temp3 = temp3 >> 16; |
| 1740 | |
| 1741 | if (modeflag & HalfDCLK) |
| 1742 | temp3 = temp3 >> 1; |
| 1743 | |
| 1744 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 1745 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 1746 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 1747 | (unsigned short) (temp3 & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1748 | } |
| 1749 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1750 | /* --------------------------------------------------------------------- */ |
| 1751 | /* Function : XGI_GETLCDVCLKPtr */ |
| 1752 | /* Input : */ |
| 1753 | /* Output : al -> VCLK Index */ |
| 1754 | /* Description : */ |
| 1755 | /* --------------------------------------------------------------------- */ |
| 1756 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 1757 | struct vb_device_info *pVBInfo) |
| 1758 | { |
| 1759 | unsigned short index; |
| 1760 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1761 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1762 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 1763 | |
| 1764 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 1765 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 1766 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 1767 | } else { /* LCDA */ |
| 1768 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 1769 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 1770 | } |
| 1771 | } |
| 1772 | return; |
| 1773 | } |
| 1774 | |
| 1775 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
| 1776 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1777 | struct vb_device_info *pVBInfo) |
| 1778 | { |
| 1779 | |
| 1780 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1781 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1782 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1783 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1784 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1785 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1786 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 1787 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1788 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 1789 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 1790 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1791 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1792 | return tempal; |
| 1793 | |
| 1794 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1795 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1796 | (VB_SIS301B | |
| 1797 | VB_SIS302B | |
| 1798 | VB_SIS301LV | |
| 1799 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1800 | VB_XGI301C)) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1801 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1802 | tempal = TVCLKBASE_315 + HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1803 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1804 | tempal = TVCLKBASE_315 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1805 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1806 | tempal = TVCLKBASE_315 + HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1807 | if (!(modeflag & Charx8Dot)) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1808 | tempal = TVCLKBASE_315 + |
| 1809 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1810 | |
| 1811 | } |
| 1812 | return tempal; |
| 1813 | } |
| 1814 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1815 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1816 | tempal = XGI_YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1817 | return tempal; |
| 1818 | } |
| 1819 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1820 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1821 | tempal = YPbPr525pVCLK; |
| 1822 | return tempal; |
| 1823 | } |
| 1824 | |
| 1825 | tempal = NTSC1024VCLK; |
| 1826 | |
| 1827 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1828 | tempal = TVCLKBASE_315 + TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1829 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1830 | tempal = TVCLKBASE_315 + TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1831 | } |
| 1832 | |
| 1833 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 1834 | return tempal; |
| 1835 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1836 | } /* {End of VB} */ |
| 1837 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 1838 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1839 | tempal = tempal >> 2; |
| 1840 | tempal &= 0x03; |
| 1841 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1842 | /* for Dot8 Scaling LCD */ |
| 1843 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1844 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
| 1845 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1846 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1847 | return tempal; |
| 1848 | } |
| 1849 | |
| 1850 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 1851 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 1852 | { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1853 | if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B |
| 1854 | | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1855 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
| 1856 | (pVBInfo->SetFlag & ProgrammingCRT2)) { |
Aaro Koskinen | e8cb03d | 2012-09-11 00:15:31 +0300 | [diff] [blame] | 1857 | *di_0 = XGI_VBVCLKData[tempal].Part4_A; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1858 | *di_1 = XGI_VBVCLKData[tempal].Part4_B; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1859 | } |
| 1860 | } else { |
| 1861 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 1862 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 1863 | } |
| 1864 | } |
| 1865 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1866 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1867 | unsigned short RefreshRateTableIndex, |
| 1868 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1869 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1870 | unsigned char di_0, di_1, tempal; |
| 1871 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1872 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1873 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 1874 | pVBInfo); |
| 1875 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 1876 | XGI_GetLCDVCLKPtr(&di_0, &di_1, 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 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1879 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1880 | (unsigned short) (0x10 * i)); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1881 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1882 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1883 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 1884 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1885 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1886 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 1887 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1888 | } |
| 1889 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1890 | } |
| 1891 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1892 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1893 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1894 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1895 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1896 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1897 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 1898 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1899 | tempcl = 0; |
| 1900 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1901 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
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 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1904 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1905 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1906 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1907 | if (!(temp & 0x40)) |
| 1908 | tempcl |= ActiveCRT1; |
| 1909 | } |
| 1910 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1911 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1912 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1913 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1914 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1915 | if (!(temp == 0x08)) { |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1916 | /* Check ChannelA */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1917 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1918 | if (tempax & 0x04) |
| 1919 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1920 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1921 | temp &= 0x05; |
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 (!(tempcl & ActiveLCD)) |
| 1924 | if (temp == 0x01) |
| 1925 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1926 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1927 | if (temp == 0x04) |
| 1928 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1929 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1930 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1931 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1932 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1933 | if (!(temp & 0x08)) |
| 1934 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1935 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1936 | if (!(temp & 0x04)) |
| 1937 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1938 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1939 | if (temp & 0x02) |
| 1940 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1941 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1942 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1943 | if (temp & 0x01) |
| 1944 | tempch |= ActiveHiTV; |
| 1945 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1946 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1947 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1948 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1949 | pVBInfo->Part2Port, |
| 1950 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1951 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1952 | if (temp & 0x10) |
| 1953 | tempch |= ActiveYPbPr; |
| 1954 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1955 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1956 | if (tempch != 0) |
| 1957 | tempcl |= ActiveTV; |
| 1958 | } |
| 1959 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1960 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1961 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1962 | if (tempcl & ActiveLCD) { |
| 1963 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 1964 | if (temp & ActiveTV) |
| 1965 | tempcl |= ActiveTV; |
| 1966 | } |
| 1967 | } |
| 1968 | temp = tempcl; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1969 | tempbl = ~XGI_ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1970 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1971 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1972 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1973 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1974 | } else { |
| 1975 | return; |
| 1976 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1977 | } |
| 1978 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 1979 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1980 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1981 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1982 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1983 | if (pVBInfo->IF_DEF_LVDS != 0) |
| 1984 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1985 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1986 | tempbx = VB_SIS302B; |
| 1987 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
| 1988 | if (flag == 0x02) |
| 1989 | goto finish; |
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 | tempbx = VB_SIS301; |
| 1992 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
| 1993 | if (flag < 0xB0) |
| 1994 | goto finish; |
| 1995 | |
| 1996 | tempbx = VB_SIS301B; |
| 1997 | if (flag < 0xC0) |
| 1998 | goto bigger_than_0xB0; |
| 1999 | |
| 2000 | tempbx = VB_XGI301C; |
| 2001 | if (flag < 0xD0) |
| 2002 | goto bigger_than_0xB0; |
| 2003 | |
| 2004 | tempbx = VB_SIS301LV; |
| 2005 | if (flag < 0xE0) |
| 2006 | goto bigger_than_0xB0; |
| 2007 | |
| 2008 | tempbx = VB_SIS302LV; |
| 2009 | tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39); |
| 2010 | if (tempah != 0xFF) |
| 2011 | tempbx = VB_XGI301C; |
| 2012 | |
| 2013 | bigger_than_0xB0: |
| 2014 | if (tempbx & (VB_SIS301B | VB_SIS302B)) { |
| 2015 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23); |
| 2016 | if (!(flag & 0x02)) |
| 2017 | tempbx = tempbx | VB_NoLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2018 | } |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 2019 | |
| 2020 | finish: |
| 2021 | pVBInfo->VBType = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2022 | } |
| 2023 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2024 | static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2025 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2026 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2027 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2028 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2029 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2030 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2031 | pVBInfo->SetFlag = 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2032 | pVBInfo->ModeType = modeflag & ModeTypeMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2033 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2034 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2035 | if (!(pVBInfo->VBType & 0xFFFF)) |
| 2036 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2037 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2038 | /* Check Display Device */ |
| 2039 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
| 2040 | tempbx = tempbx | temp; |
| 2041 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
| 2042 | push = temp; |
| 2043 | push = push << 8; |
| 2044 | tempax = temp << 8; |
| 2045 | tempbx = tempbx | tempax; |
| 2046 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA |
| 2047 | | SetInSlaveMode | DisableCRT2Display); |
| 2048 | temp = 0xFFFF ^ temp; |
| 2049 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2050 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2051 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2052 | |
Aaro Koskinen | 4d8f5ca | 2012-09-11 00:15:17 +0300 | [diff] [blame] | 2053 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2054 | if (pVBInfo->VBType & |
| 2055 | (VB_SIS302B | |
| 2056 | VB_SIS301LV | |
| 2057 | VB_SIS302LV | |
| 2058 | VB_XGI301C)) { |
| 2059 | if (temp & EnableDualEdge) { |
| 2060 | tempbx |= SetCRT2ToDualEdge; |
| 2061 | if (temp & SetToLCDA) |
| 2062 | tempbx |= XGI_SetCRT2ToLCDA; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2063 | } |
| 2064 | } |
| 2065 | } |
| 2066 | |
| 2067 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 2068 | if (((pVBInfo->IF_DEF_LVDS == 0) && |
| 2069 | ((pVBInfo->VBType & VB_SIS301LV) || |
| 2070 | (pVBInfo->VBType & VB_SIS302LV) || |
| 2071 | (pVBInfo->VBType & VB_XGI301C)))) { |
| 2072 | if (temp & SetYPbPr) { |
| 2073 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2074 | /* shampoo add for new |
| 2075 | * scratch */ |
| 2076 | temp = xgifb_reg_get( |
| 2077 | pVBInfo->P3d4, |
| 2078 | 0x35); |
| 2079 | temp &= YPbPrMode; |
| 2080 | tempbx |= SetCRT2ToHiVision; |
| 2081 | |
| 2082 | if (temp != YPbPrMode1080i) { |
| 2083 | tempbx &= |
| 2084 | (~SetCRT2ToHiVision); |
| 2085 | tempbx |= |
| 2086 | SetCRT2ToYPbPr525750; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2087 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2088 | } |
| 2089 | } |
| 2090 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2091 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2092 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2093 | tempax = push; /* restore CR31 */ |
| 2094 | |
| 2095 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2096 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2097 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 2098 | temp = 0x09FC; |
| 2099 | else |
| 2100 | temp = 0x097C; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2101 | } else if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2102 | temp = 0x01FC; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2103 | } else { |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2104 | temp = 0x017C; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2105 | } |
Justin P. Mattock | 558f758 | 2012-10-02 21:17:11 -0700 | [diff] [blame] | 2106 | } else { /* 3rd party chip */ |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2107 | temp = SetCRT2ToLCD; |
| 2108 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2109 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2110 | if (!(tempbx & temp)) { |
| 2111 | tempax |= DisableCRT2Display; |
| 2112 | tempbx = 0; |
| 2113 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2114 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2115 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 2116 | if (tempbx & XGI_SetCRT2ToLCDA) { |
| 2117 | if (tempbx & SetSimuScanMode) |
| 2118 | tempbx &= (~(SetCRT2ToLCD | |
| 2119 | SetCRT2ToRAMDAC | |
| 2120 | SwitchCRT2)); |
| 2121 | else |
| 2122 | tempbx &= (~(SetCRT2ToLCD | |
| 2123 | SetCRT2ToRAMDAC | |
| 2124 | SetCRT2ToTV | |
| 2125 | SwitchCRT2)); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2126 | } |
| 2127 | } |
| 2128 | |
| 2129 | /* shampoo add */ |
| 2130 | /* for driver abnormal */ |
| 2131 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { |
| 2132 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 2133 | if (tempbx & SetCRT2ToRAMDAC) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2134 | tempbx &= (0xFF00 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2135 | SetCRT2ToRAMDAC | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2136 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2137 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2138 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2139 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2140 | } else { |
| 2141 | tempbx &= (~(SetCRT2ToRAMDAC | |
| 2142 | SetCRT2ToLCD | |
| 2143 | SetCRT2ToTV)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2144 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2145 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2146 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2147 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 2148 | if (tempbx & SetCRT2ToLCD) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2149 | tempbx &= (0xFF00 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2150 | SetCRT2ToLCD | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2151 | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2152 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2153 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2154 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2155 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2156 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2157 | if (tempbx & SetCRT2ToSCART) { |
| 2158 | tempbx &= (0xFF00 | |
| 2159 | SetCRT2ToSCART | |
| 2160 | SwitchCRT2 | |
| 2161 | SetSimuScanMode); |
| 2162 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
| 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 (pVBInfo->IF_DEF_YPbPr == 1) { |
| 2166 | if (tempbx & SetCRT2ToYPbPr525750) |
| 2167 | tempbx &= (0xFF00 | |
| 2168 | SwitchCRT2 | |
| 2169 | SetSimuScanMode); |
| 2170 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2171 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2172 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2173 | if (tempbx & SetCRT2ToHiVision) |
| 2174 | tempbx &= (0xFF00 | |
| 2175 | SetCRT2ToHiVision | |
| 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 (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 2181 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) |
| 2182 | tempbx = DisableCRT2Display; |
| 2183 | } |
| 2184 | |
| 2185 | if (!(tempbx & DisableCRT2Display)) { |
| 2186 | if ((!(tempbx & DriverMode)) || |
| 2187 | (!(modeflag & CRT2Mode))) { |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2188 | if (!(tempbx & XGI_SetCRT2ToLCDA)) |
| 2189 | tempbx |= (SetInSlaveMode | |
| 2190 | SetSimuScanMode); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2191 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2192 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2193 | /* LCD+TV can't support in slave mode |
| 2194 | * (Force LCDA+TV->LCDB) */ |
| 2195 | if ((tempbx & SetInSlaveMode) && |
| 2196 | (tempbx & XGI_SetCRT2ToLCDA)) { |
| 2197 | tempbx ^= (SetCRT2ToLCD | |
| 2198 | XGI_SetCRT2ToLCDA | |
| 2199 | SetCRT2ToDualEdge); |
| 2200 | pVBInfo->SetFlag |= ReserveTVOption; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2201 | } |
| 2202 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2203 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2204 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2205 | } |
| 2206 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2207 | static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2208 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2209 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2210 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
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 | tempbx = 0; |
| 2213 | resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2214 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2215 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2216 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2217 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2218 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2219 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2220 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2221 | tempbx = temp; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2222 | if (tempbx & TVSetPAL) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2223 | tempbx &= (SetCHTVOverScan | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2224 | TVSetPALM | |
| 2225 | TVSetPALN | |
| 2226 | TVSetPAL); |
| 2227 | if (tempbx & TVSetPALM) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2228 | /* set to NTSC if PAL-M */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2229 | tempbx &= ~TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2230 | } else |
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 | TVSetNTSCJ | |
| 2233 | TVSetPAL); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2234 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2235 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2236 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 2237 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2238 | tempbx |= TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2239 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2240 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2241 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2242 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2243 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2244 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2245 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2246 | if (index1 == YPbPrMode525i) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2247 | tempbx |= TVSetYPbPr525i; |
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 (index1 == YPbPrMode525p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2250 | tempbx = tempbx | TVSetYPbPr525p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2251 | if (index1 == YPbPrMode750p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2252 | tempbx = tempbx | TVSetYPbPr750p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2253 | } |
| 2254 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2255 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2256 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2257 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
| 2258 | tempbx = tempbx | TVSetHiVision | TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2259 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2260 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2261 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2262 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 2263 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2264 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2265 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2266 | if (!(tempbx & TVSetPAL) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2267 | (modeflag > 13) && |
| 2268 | (resinfo == 8)) /* NTSC 1024x768, */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2269 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2270 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2271 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2272 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2273 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2274 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2275 | tempbx &= (~RPLLDIV2XO); |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2276 | } else if (tempbx & |
| 2277 | (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2278 | tempbx &= (~RPLLDIV2XO); |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2279 | } else if (!(pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2280 | (VB_SIS301B | |
| 2281 | VB_SIS302B | |
| 2282 | VB_SIS301LV | |
| 2283 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2284 | VB_XGI301C))) { |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 2285 | if (tempbx & TVSimuMode) |
| 2286 | tempbx &= (~RPLLDIV2XO); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2287 | } |
| 2288 | } |
| 2289 | } |
| 2290 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2291 | } |
| 2292 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2293 | static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, |
| 2294 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2295 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2296 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2297 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2298 | pVBInfo->LCDResInfo = 0; |
| 2299 | pVBInfo->LCDTypeInfo = 0; |
| 2300 | pVBInfo->LCDInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2301 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2302 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2303 | /* si+Ext_ResInfo // */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2304 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2305 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2306 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2307 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2308 | if (tempbx == 0) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2309 | tempbx = Panel_1024x768; /* default */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2310 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 2311 | /* LCD75 */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2312 | if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2313 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2314 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2315 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2316 | tempax &= 0x0F; |
| 2317 | else |
| 2318 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2319 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2320 | if ((resinfo == 6) || (resinfo == 9)) { |
| 2321 | if (tempax >= 3) |
| 2322 | tempbx |= PanelRef75Hz; |
| 2323 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 2324 | if (tempax >= 4) |
| 2325 | tempbx |= PanelRef75Hz; |
| 2326 | } |
| 2327 | } |
| 2328 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2329 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2330 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2331 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2332 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2333 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2334 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2335 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2336 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2337 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2338 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2339 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2340 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2341 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2342 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2343 | tempbx |= temp; |
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 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2346 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2347 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
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 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2350 | if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2351 | & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2352 | tempbx |= SetLCDDualLink; |
| 2353 | } |
| 2354 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2355 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2356 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2357 | if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2358 | & SetCRT2ToLCD) && (resinfo == 9) && |
| 2359 | (!(tempbx & EnableScalingLCD))) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 2360 | /* |
| 2361 | * set to center in 1280x1024 LCDB |
| 2362 | * for Panel_1400x1050 |
| 2363 | */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2364 | tempbx |= SetLCDtoNonExpanding; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2365 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2366 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2367 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2368 | if (pVBInfo->VBInfo & SetNotSimuMode) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2369 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2370 | } else { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2371 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2372 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2373 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2374 | pVBInfo->LCDInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2375 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2376 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2377 | } |
| 2378 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2379 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2380 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2381 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2382 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2383 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2384 | break; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2385 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2386 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2387 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2388 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2389 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2390 | } |
| 2391 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2392 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 2393 | { |
| 2394 | unsigned char ujRet = 0; |
| 2395 | unsigned char i = 0; |
| 2396 | |
| 2397 | for (i = 0; i < 8; i++) { |
| 2398 | ujRet = ujRet << 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2399 | ujRet |= (ujDate >> i) & 1; |
| 2400 | } |
| 2401 | |
| 2402 | return ujRet; |
| 2403 | } |
| 2404 | |
| 2405 | /*----------------------------------------------------------------------------*/ |
| 2406 | /* output */ |
| 2407 | /* bl[5] : LVDS signal */ |
| 2408 | /* bl[1] : LVDS backlight */ |
| 2409 | /* bl[0] : LVDS VDD */ |
| 2410 | /*----------------------------------------------------------------------------*/ |
| 2411 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 2412 | { |
| 2413 | unsigned char CR4A, temp; |
| 2414 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2415 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2416 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2417 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2418 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2419 | |
| 2420 | temp = XG21GPIODataTransfer(temp); |
| 2421 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2422 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2423 | return temp; |
| 2424 | } |
| 2425 | |
| 2426 | /*----------------------------------------------------------------------------*/ |
| 2427 | /* output */ |
| 2428 | /* bl[5] : LVDS signal */ |
| 2429 | /* bl[1] : LVDS backlight */ |
| 2430 | /* bl[0] : LVDS VDD */ |
| 2431 | /*----------------------------------------------------------------------------*/ |
| 2432 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 2433 | { |
| 2434 | unsigned char CR4A, CRB4, temp; |
| 2435 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2436 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2437 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2438 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2439 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2440 | |
| 2441 | temp &= 0x0C; |
| 2442 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2443 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2444 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2445 | temp |= ((CRB4 & 0x04) << 3); |
| 2446 | return temp; |
| 2447 | } |
| 2448 | |
Aaro Koskinen | 0ebf538 | 2011-11-27 23:03:09 +0200 | [diff] [blame] | 2449 | /*----------------------------------------------------------------------------*/ |
| 2450 | /* input */ |
| 2451 | /* bl[5] : 1;LVDS signal on */ |
| 2452 | /* bl[1] : 1;LVDS backlight on */ |
| 2453 | /* bl[0] : 1:LVDS VDD on */ |
| 2454 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 2455 | /* 000010b : clear bit 1, to set bit1 */ |
| 2456 | /* 000001b : clear bit 0, to set bit0 */ |
| 2457 | /*----------------------------------------------------------------------------*/ |
| 2458 | static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2459 | struct vb_device_info *pVBInfo) |
| 2460 | { |
| 2461 | unsigned char CR4A, temp; |
| 2462 | |
| 2463 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2464 | tempbh &= 0x23; |
| 2465 | tempbl &= 0x23; |
| 2466 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2467 | |
| 2468 | if (tempbh & 0x20) { |
| 2469 | temp = (tempbl >> 4) & 0x02; |
| 2470 | |
| 2471 | /* CR B4[1] */ |
| 2472 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2473 | |
| 2474 | } |
| 2475 | |
| 2476 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
| 2477 | |
| 2478 | temp = XG21GPIODataTransfer(temp); |
| 2479 | temp &= ~tempbh; |
| 2480 | temp |= tempbl; |
| 2481 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
| 2482 | } |
| 2483 | |
Aaro Koskinen | 776115a | 2011-11-27 23:03:10 +0200 | [diff] [blame] | 2484 | static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2485 | struct vb_device_info *pVBInfo) |
| 2486 | { |
| 2487 | unsigned char CR4A, temp; |
| 2488 | unsigned short tempbh0, tempbl0; |
| 2489 | |
| 2490 | tempbh0 = tempbh; |
| 2491 | tempbl0 = tempbl; |
| 2492 | tempbh0 &= 0x20; |
| 2493 | tempbl0 &= 0x20; |
| 2494 | tempbh0 >>= 3; |
| 2495 | tempbl0 >>= 3; |
| 2496 | |
| 2497 | if (tempbh & 0x20) { |
| 2498 | temp = (tempbl >> 4) & 0x02; |
| 2499 | |
| 2500 | /* CR B4[1] */ |
| 2501 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2502 | |
| 2503 | } |
| 2504 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
| 2505 | |
| 2506 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2507 | tempbh &= 0x03; |
| 2508 | tempbl &= 0x03; |
| 2509 | tempbh <<= 2; |
| 2510 | tempbl <<= 2; /* GPIOC,GPIOD */ |
| 2511 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2512 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
| 2513 | } |
| 2514 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2515 | static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info, |
| 2516 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2517 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2518 | { |
| 2519 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2520 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2521 | if (pXGIHWDE->jChipType == XG21) { |
| 2522 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2523 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2524 | /* LVDS VDD on */ |
| 2525 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2526 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2527 | } |
| 2528 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2529 | /* LVDS signal on */ |
| 2530 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2531 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2532 | /* LVDS backlight on */ |
| 2533 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2534 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2535 | /* DVO/DVI signal on */ |
| 2536 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2537 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2538 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2539 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2540 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2541 | if (pXGIHWDE->jChipType == XG27) { |
| 2542 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2543 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2544 | /* LVDS VDD on */ |
| 2545 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2546 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2547 | } |
| 2548 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2549 | /* LVDS signal on */ |
| 2550 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2551 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2552 | /* LVDS backlight on */ |
| 2553 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2554 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2555 | /* DVO/DVI signal on */ |
| 2556 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2557 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2558 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2559 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2560 | } |
| 2561 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2562 | void XGI_DisplayOff(struct xgifb_video_info *xgifb_info, |
| 2563 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2564 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2565 | { |
| 2566 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2567 | if (pXGIHWDE->jChipType == XG21) { |
| 2568 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2569 | /* LVDS backlight off */ |
| 2570 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2571 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2572 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2573 | /* DVO/DVI signal off */ |
| 2574 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2575 | } |
| 2576 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2577 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2578 | if (pXGIHWDE->jChipType == XG27) { |
| 2579 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2580 | /* LVDS backlight off */ |
| 2581 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2582 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2583 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2584 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2585 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2586 | /* DVO/DVI signal off */ |
| 2587 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2588 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2589 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2590 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2591 | } |
| 2592 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2593 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2594 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2595 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2596 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2597 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2598 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2599 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2600 | } |
| 2601 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2602 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2603 | { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2604 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2605 | } |
| 2606 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2607 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 2608 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2609 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2610 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2611 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2612 | /* reserve CR34 for CRT1 Mode No */ |
| 2613 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2614 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 2615 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2616 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2617 | } |
| 2618 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2619 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
| 2620 | unsigned short ModeIdIndex, |
| 2621 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2622 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2623 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2624 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2625 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 2626 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 2627 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2628 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2629 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2630 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2631 | if (modeflag & HalfDCLK) |
| 2632 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2633 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2634 | if (modeflag & DoubleScanMode) |
| 2635 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2636 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2637 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 2638 | goto exit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2639 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2640 | if (pVBInfo->IF_DEF_LVDS == 0) { |
| 2641 | if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
| 2642 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2643 | if (yres == 1024) |
| 2644 | yres = 1056; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2645 | } |
| 2646 | } |
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->LCDResInfo == Panel_1280x1024) { |
| 2649 | if (yres == 400) |
| 2650 | yres = 405; |
| 2651 | else if (yres == 350) |
| 2652 | yres = 360; |
| 2653 | |
| 2654 | if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { |
| 2655 | if (yres == 360) |
| 2656 | yres = 375; |
| 2657 | } |
| 2658 | } |
| 2659 | |
| 2660 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
| 2661 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2662 | if (!(pVBInfo->LCDInfo & LCDNonExpanding)) { |
| 2663 | if (yres == 350) |
| 2664 | yres = 357; |
| 2665 | else if (yres == 400) |
| 2666 | yres = 420; |
| 2667 | else if (yres == 480) |
| 2668 | yres = 525; |
| 2669 | } |
| 2670 | } |
| 2671 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2672 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2673 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2674 | if (xres == 720) |
| 2675 | xres = 640; |
| 2676 | |
| 2677 | exit: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2678 | pVBInfo->VGAHDE = xres; |
| 2679 | pVBInfo->HDE = xres; |
| 2680 | pVBInfo->VGAVDE = yres; |
| 2681 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2682 | } |
| 2683 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2684 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2685 | { |
| 2686 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2687 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) && |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 2688 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2689 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2690 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2691 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2692 | } |
| 2693 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2694 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
| 2695 | unsigned short ModeIdIndex, |
| 2696 | unsigned short RefreshRateTableIndex, |
| 2697 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2698 | { |
| 2699 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2700 | CRT1Index; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2701 | |
| 2702 | pVBInfo->RVBHCMAX = 1; |
| 2703 | pVBInfo->RVBHCFACT = 1; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2704 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2705 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2706 | CRT1Index &= IndexMask; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2707 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[0]; |
| 2708 | temp2 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2709 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2710 | tempbx = (unsigned short) XGI_CRT1Table[CRT1Index].CR[8]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2711 | tempcx = (unsigned short) |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2712 | XGI_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2713 | tempcx &= 0x0100; |
| 2714 | tempcx = tempcx << 2; |
| 2715 | tempbx |= tempcx; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2716 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2717 | |
| 2718 | if (temp1 & 0x01) |
| 2719 | tempbx |= 0x0100; |
| 2720 | |
| 2721 | if (temp1 & 0x20) |
| 2722 | tempbx |= 0x0200; |
| 2723 | tempax += 5; |
| 2724 | |
| 2725 | if (modeflag & Charx8Dot) |
| 2726 | tempax *= 8; |
| 2727 | else |
| 2728 | tempax *= 9; |
| 2729 | |
| 2730 | pVBInfo->VGAHT = tempax; |
| 2731 | pVBInfo->HT = tempax; |
| 2732 | tempbx++; |
| 2733 | pVBInfo->VGAVT = tempbx; |
| 2734 | pVBInfo->VT = tempbx; |
| 2735 | } |
| 2736 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2737 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2738 | unsigned short RefreshRateTableIndex, |
| 2739 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2740 | { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 2741 | unsigned short tempax = 0, tempbx = 0, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2742 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 2743 | struct SiS_LCDData const *LCDPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2744 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2745 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2746 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2747 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2748 | pVBInfo->NewFlickerMode = 0; |
| 2749 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2750 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2751 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 2752 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2753 | pVBInfo); |
| 2754 | return; |
| 2755 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2756 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2757 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 2758 | LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeNo, ModeIdIndex, |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 2759 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2760 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2761 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 2762 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 2763 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2764 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2765 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2766 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2767 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2768 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2769 | tempax = 1024; |
| 2770 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2771 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2772 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2773 | if (pVBInfo->VGAVDE == 357) |
| 2774 | tempbx = 527; |
| 2775 | else if (pVBInfo->VGAVDE == 420) |
| 2776 | tempbx = 620; |
| 2777 | else if (pVBInfo->VGAVDE == 525) |
| 2778 | tempbx = 775; |
| 2779 | else if (pVBInfo->VGAVDE == 600) |
| 2780 | tempbx = 775; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2781 | else |
| 2782 | tempbx = 768; |
| 2783 | } else |
| 2784 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2785 | } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2786 | tempax = 1024; |
| 2787 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2788 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2789 | tempax = 1280; |
| 2790 | if (pVBInfo->VGAVDE == 360) |
| 2791 | tempbx = 768; |
| 2792 | else if (pVBInfo->VGAVDE == 375) |
| 2793 | tempbx = 800; |
| 2794 | else if (pVBInfo->VGAVDE == 405) |
| 2795 | tempbx = 864; |
| 2796 | else |
| 2797 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2798 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2799 | tempax = 1280; |
| 2800 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2801 | } else if (pVBInfo->LCDResInfo == Panel_1280x960) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2802 | tempax = 1280; |
| 2803 | if (pVBInfo->VGAVDE == 350) |
| 2804 | tempbx = 700; |
| 2805 | else if (pVBInfo->VGAVDE == 400) |
| 2806 | tempbx = 800; |
| 2807 | else if (pVBInfo->VGAVDE == 1024) |
| 2808 | tempbx = 960; |
| 2809 | else |
| 2810 | tempbx = 960; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2811 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2812 | tempax = 1400; |
| 2813 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2814 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2815 | if (pVBInfo->VGAVDE == 1024) { |
| 2816 | tempax = 1280; |
| 2817 | tempbx = 1024; |
| 2818 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2819 | } else if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2820 | tempax = 1600; |
| 2821 | tempbx = 1200; /* alan 10/14/2003 */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2822 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2823 | if (pVBInfo->VGAVDE == 350) |
| 2824 | tempbx = 875; |
| 2825 | else if (pVBInfo->VGAVDE == 400) |
| 2826 | tempbx = 1000; |
| 2827 | } |
| 2828 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2829 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2830 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 2831 | tempax = pVBInfo->VGAHDE; |
| 2832 | tempbx = pVBInfo->VGAVDE; |
| 2833 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2834 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2835 | pVBInfo->HDE = tempax; |
| 2836 | pVBInfo->VDE = tempbx; |
| 2837 | return; |
| 2838 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2839 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2840 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 2841 | struct SiS_TVData const *TVPtr; |
| 2842 | |
| 2843 | TVPtr = XGI_GetTVPtr(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2844 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2845 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2846 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 2847 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 2848 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 2849 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 2850 | pVBInfo->HDE = TVPtr->TVHDE; |
| 2851 | pVBInfo->VDE = TVPtr->TVVDE; |
| 2852 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 2853 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2854 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2855 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2856 | if (resinfo == 0x08) |
| 2857 | pVBInfo->NewFlickerMode = 0x40; |
| 2858 | else if (resinfo == 0x09) |
| 2859 | pVBInfo->NewFlickerMode = 0x40; |
| 2860 | else if (resinfo == 0x12) |
| 2861 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2862 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2863 | if (pVBInfo->VGAVDE == 350) |
| 2864 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2865 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2866 | tempax = ExtHiTVHT; |
| 2867 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2868 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2869 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2870 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 2871 | tempax = StHiTVHT; |
| 2872 | tempbx = StHiTVVT; |
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 | if (!(modeflag & Charx8Dot)) { |
| 2875 | tempax = StHiTextTVHT; |
| 2876 | tempbx = StHiTextTVVT; |
| 2877 | } |
| 2878 | } |
| 2879 | } |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2880 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 2881 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2882 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 2883 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 2884 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2885 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2886 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2887 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 2888 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2889 | } else if (pVBInfo->TVInfo & TVSetYPbPr525i) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2890 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 2891 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 2892 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2893 | tempax = NTSC1024x768HT; |
| 2894 | } |
| 2895 | } else { |
| 2896 | tempax = PALHT; |
| 2897 | tempbx = PALVT; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2898 | if (!(pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2899 | tempax = NTSCHT; |
| 2900 | tempbx = NTSCVT; |
| 2901 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2902 | tempax = NTSC1024x768HT; |
| 2903 | } |
| 2904 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2905 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2906 | pVBInfo->HT = tempax; |
| 2907 | pVBInfo->VT = tempbx; |
| 2908 | return; |
| 2909 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2910 | } |
| 2911 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2912 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2913 | unsigned short RefreshRateTableIndex, |
| 2914 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2915 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2916 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2917 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2918 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 2919 | pVBInfo); |
| 2920 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 2921 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2922 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2923 | if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2924 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2925 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 2926 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 2927 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2928 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2929 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 2930 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2931 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2932 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2933 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2934 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2935 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2936 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2937 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2938 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2939 | } |
| 2940 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2941 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
| 2942 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2943 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2944 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 2945 | short index; |
| 2946 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2947 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2948 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2949 | index = (modeflag & ModeTypeMask) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2950 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2951 | if (index < 0) |
| 2952 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2953 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2954 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2955 | } |
| 2956 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2957 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 2958 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2959 | unsigned short RefreshRateTableIndex, |
| 2960 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2961 | struct vb_device_info *pVBInfo) |
| 2962 | { |
| 2963 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 2964 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 2965 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2966 | modeinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2967 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2968 | |
| 2969 | index = (modeinfo >> 8) & 0xFF; |
| 2970 | |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame] | 2971 | temp = XGI330_ScreenOffset[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2972 | |
| 2973 | if (infoflag & InterlaceMode) |
| 2974 | temp = temp << 1; |
| 2975 | |
| 2976 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 2977 | |
| 2978 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 2979 | temp = ModeNo - 0x7C; |
| 2980 | colordepth = ColorDepth[temp]; |
| 2981 | temp = 0x6B; |
| 2982 | if (infoflag & InterlaceMode) |
| 2983 | temp = temp << 1; |
| 2984 | return temp * colordepth; |
| 2985 | } else { |
| 2986 | return temp * colordepth; |
| 2987 | } |
| 2988 | } |
| 2989 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2990 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 2991 | unsigned short ModeIdIndex, |
| 2992 | unsigned short RefreshRateTableIndex, |
| 2993 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2994 | struct vb_device_info *pVBInfo) |
| 2995 | { |
| 2996 | unsigned short offset; |
| 2997 | unsigned char temp; |
| 2998 | |
| 2999 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 3000 | return; |
| 3001 | |
| 3002 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3003 | HwDeviceExtension, pVBInfo); |
| 3004 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3005 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3006 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3007 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3008 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3009 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3010 | } |
| 3011 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 3012 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3013 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3014 | /* threshold high ,disable auto threshold */ |
| 3015 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 3016 | /* threshold low default 04h */ |
| 3017 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3018 | } |
| 3019 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3020 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3021 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3022 | unsigned short RefreshRateTableIndex, |
| 3023 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3024 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3025 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3026 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3027 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3028 | CRT1Index &= IndexMask; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3029 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3030 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3031 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 3032 | HwDeviceExtension, pVBInfo); |
| 3033 | XGI_SetCRT2FIFO(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3034 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3035 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3036 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3037 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3038 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 3039 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3040 | } |
| 3041 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3042 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3043 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3044 | unsigned short RefreshRateTableIndex, |
| 3045 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3046 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3047 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
| 3048 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3049 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3050 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3051 | CRT1Index &= IndexMask; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3052 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
| 3053 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
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 | /* bainy change table name */ |
| 3056 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3057 | /* BTVGA2HT 0x08,0x09 */ |
| 3058 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3059 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3060 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3061 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3062 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 3063 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3064 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3065 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 3066 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 3067 | tempcx = tempcx >> 1; |
| 3068 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 3069 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3070 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3071 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3072 | tempbx = XGI_CRT1Table[CRT1Index].CR[4]; |
| 3073 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[14] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3074 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3075 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3076 | tempcx = XGI_CRT1Table[CRT1Index].CR[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3077 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3078 | temp = XGI_CRT1Table[CRT1Index].CR[15]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3079 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 3080 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 3081 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3082 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3083 | tempbx += 4; |
| 3084 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3085 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3086 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 3087 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3088 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3089 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3090 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3091 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3092 | } else { |
| 3093 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3094 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3095 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3096 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3097 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 3098 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3099 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3100 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 3101 | pushbx = pVBInfo->VGAHDE + 16; |
| 3102 | tempcx = tempcx >> 1; |
| 3103 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 3104 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3105 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3106 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3107 | tempbx = XGI_CRT1Table[CRT1Index].CR[3]; |
| 3108 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[5] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3109 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3110 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3111 | tempcx = XGI_CRT1Table[CRT1Index].CR[4]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3112 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3113 | temp = XGI_CRT1Table[CRT1Index].CR[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3114 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 3115 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 3116 | tempbx += 16; |
| 3117 | tempcx += 16; |
| 3118 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3119 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3120 | if (tempcx > pVBInfo->VGAHT) |
| 3121 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3122 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3123 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3124 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3125 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3126 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3127 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 3128 | tempbx = pushbx; |
| 3129 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 3130 | tempax |= (tempbx & 0xFF00); |
| 3131 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3132 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3133 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3134 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3135 | tempcx = (pVBInfo->VGAVT - 1); |
| 3136 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3137 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3138 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3139 | tempbx = pVBInfo->VGAVDE - 1; |
| 3140 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3141 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3142 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 3143 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3144 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3145 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3146 | tempax = pVBInfo->VGAVDE; |
| 3147 | tempbx = pVBInfo->VGAVDE; |
| 3148 | tempcx = pVBInfo->VGAVT; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3149 | /* BTVGA2VRS 0x10,0x11 */ |
| 3150 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 3151 | /* BTVGA2VRE 0x11 */ |
| 3152 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
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 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3155 | tempbx = XGI_CRT1Table[CRT1Index].CR[10]; |
| 3156 | temp = XGI_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3157 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3158 | if (temp & 0x04) |
| 3159 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3160 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3161 | if (temp & 0x080) |
| 3162 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3163 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3164 | temp = XGI_CRT1Table[CRT1Index].CR[14]; |
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 & 0x08) |
| 3167 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3168 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3169 | temp = XGI_CRT1Table[CRT1Index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3170 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 3171 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3172 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3173 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3174 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3175 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 3176 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3177 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3178 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3179 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3180 | if (modeflag & DoubleScanMode) |
| 3181 | tempax |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3182 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3183 | if (modeflag & HalfDCLK) |
| 3184 | tempax |= 0x40; |
| 3185 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3186 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3187 | } |
| 3188 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3189 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 3190 | { |
| 3191 | unsigned long tempax, tempbx; |
| 3192 | |
| 3193 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 3194 | & 0xFFFF; |
| 3195 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 3196 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 3197 | |
| 3198 | return (unsigned short) tempax; |
| 3199 | } |
| 3200 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3201 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3202 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3203 | unsigned short RefreshRateTableIndex, |
| 3204 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3205 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3206 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
| 3207 | modeflag, CRT1Index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3208 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3209 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3210 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3211 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3212 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3213 | CRT1Index &= IndexMask; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3214 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3215 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 3216 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3217 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3218 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3219 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3220 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3221 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3222 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3223 | modeflag |= Charx8Dot; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3224 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3225 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3226 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3227 | if (modeflag & HalfDCLK) |
| 3228 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3229 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3230 | tempax = (tempax / tempcx) - 1; |
| 3231 | tempbx |= ((tempax & 0x00FF) << 8); |
| 3232 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3233 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
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 | temp = (tempbx & 0xFF00) >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3236 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3237 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3238 | if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3239 | | VB_SIS302LV | VB_XGI301C))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3240 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3241 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 3242 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) && |
| 3243 | !(pVBInfo->VBType & VB_SIS301LV) && (resinfo == 7)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3244 | temp -= 2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3245 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3246 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3247 | /* 0x05 Horizontal Display Start */ |
| 3248 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 3249 | /* 0x06 Horizontal Blank end */ |
| 3250 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3251 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3252 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 3253 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3254 | tempax = pVBInfo->VGAHT; |
| 3255 | else |
| 3256 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3257 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3258 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3259 | if (tempax >= pVBInfo->VGAHT) |
| 3260 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3261 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3262 | if (modeflag & HalfDCLK) |
| 3263 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3264 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3265 | tempax = (tempax / tempcx) - 5; |
| 3266 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3267 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3268 | temp = (tempbx & 0x00FF) - 1; |
| 3269 | if (!(modeflag & HalfDCLK)) { |
| 3270 | temp -= 6; |
| 3271 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3272 | temp -= 4; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3273 | temp -= 10; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3274 | } |
| 3275 | } |
| 3276 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3277 | tempbx = (tempbx & 0xFF00) >> 8; |
| 3278 | tempcx = (tempcx + tempbx) >> 1; |
| 3279 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3280 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3281 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3282 | temp -= 1; |
| 3283 | if (!(modeflag & HalfDCLK)) { |
| 3284 | if ((modeflag & Charx8Dot)) { |
| 3285 | temp += 4; |
| 3286 | if (pVBInfo->VGAHDE >= 800) |
| 3287 | temp -= 6; |
| 3288 | } |
| 3289 | } |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3290 | } else if (!(modeflag & HalfDCLK)) { |
| 3291 | temp -= 4; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3292 | if (pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3293 | pVBInfo->VGAHDE >= 800) { |
| 3294 | temp -= 7; |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3295 | if (pVBInfo->VGAHDE >= 1280 && |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3296 | pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3297 | (pVBInfo->LCDInfo & LCDNonExpanding)) |
| 3298 | temp += 28; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3299 | } |
| 3300 | } |
| 3301 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3302 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3303 | /* 0x07 Horizontal Retrace Start */ |
| 3304 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 3305 | /* 0x08 Horizontal Retrace End */ |
| 3306 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3307 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3308 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3309 | if (pVBInfo->TVInfo & TVSimuMode) { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3310 | if (ModeNo == 0x50) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3311 | if (pVBInfo->TVInfo & SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3312 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3313 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3314 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3315 | 0x08, 0x03); |
| 3316 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3317 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3318 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3319 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3320 | 0x08, 0x02); |
| 3321 | } |
| 3322 | } |
| 3323 | } |
| 3324 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3325 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3326 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3327 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3328 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3329 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3330 | tempbx = pVBInfo->VGAVT; |
| 3331 | push1 = tempbx; |
| 3332 | tempcx = 0x121; |
| 3333 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3334 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3335 | if (tempbx == 357) |
| 3336 | tempbx = 350; |
| 3337 | if (tempbx == 360) |
| 3338 | tempbx = 350; |
| 3339 | if (tempbx == 375) |
| 3340 | tempbx = 350; |
| 3341 | if (tempbx == 405) |
| 3342 | tempbx = 400; |
| 3343 | if (tempbx == 525) |
| 3344 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3345 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3346 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3347 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3348 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3349 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3350 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3351 | if (tempbx == 350) |
| 3352 | tempbx += 5; |
| 3353 | if (tempbx == 480) |
| 3354 | tempbx += 5; |
| 3355 | } |
| 3356 | } |
| 3357 | } |
| 3358 | tempbx--; |
| 3359 | temp = tempbx & 0x00FF; |
| 3360 | tempbx--; |
| 3361 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3362 | /* 0x10 vertical Blank Start */ |
| 3363 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3364 | tempbx = push2; |
| 3365 | tempbx--; |
| 3366 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3367 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3368 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3369 | if (tempbx & 0x0100) |
| 3370 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3371 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3372 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3373 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3374 | if (modeflag & DoubleScanMode) |
| 3375 | tempax |= 0x08000; |
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 & 0x0200) |
| 3378 | tempcx |= 0x0040; |
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 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3381 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3382 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3383 | if (tempbx & 0x0400) |
| 3384 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3385 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3386 | /* 0x11 Vertival Blank End */ |
| 3387 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3388 | |
| 3389 | tempax = push1; |
| 3390 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 3391 | tempax = tempax >> 2; |
| 3392 | push1 = tempax; /* push ax */ |
| 3393 | |
| 3394 | if (resinfo != 0x09) { |
| 3395 | tempax = tempax << 1; |
| 3396 | tempbx += tempax; |
| 3397 | } |
| 3398 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3399 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Miguel Gómez | 470c533 | 2012-07-06 12:40:50 +0200 | [diff] [blame] | 3400 | if ((pVBInfo->VBType & VB_SIS301LV) && |
| 3401 | !(pVBInfo->TVInfo & TVSetHiVision)) { |
| 3402 | if ((pVBInfo->TVInfo & TVSimuMode) && |
| 3403 | (pVBInfo->TVInfo & TVSetPAL)) { |
| 3404 | if (!(pVBInfo->VBType & VB_SIS301LV) || |
| 3405 | !(pVBInfo->TVInfo & |
| 3406 | (TVSetYPbPr525p | |
| 3407 | TVSetYPbPr750p | |
| 3408 | TVSetHiVision))) |
| 3409 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3410 | } |
| 3411 | } else { |
| 3412 | tempbx -= 10; |
| 3413 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3414 | } else if (pVBInfo->TVInfo & TVSimuMode) { |
| 3415 | if (pVBInfo->TVInfo & TVSetPAL) { |
| 3416 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 3417 | if (!(pVBInfo->TVInfo & |
| 3418 | (TVSetYPbPr525p | |
| 3419 | TVSetYPbPr750p | |
| 3420 | TVSetHiVision))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3421 | tempbx += 40; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3422 | } else { |
| 3423 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3424 | } |
| 3425 | } |
| 3426 | } |
| 3427 | tempax = push1; |
| 3428 | tempax = tempax >> 2; |
| 3429 | tempax++; |
| 3430 | tempax += tempbx; |
| 3431 | push1 = tempax; /* push ax */ |
| 3432 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3433 | if ((pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3434 | if (tempbx <= 513) { |
| 3435 | if (tempax >= 513) |
| 3436 | tempbx = 513; |
| 3437 | } |
| 3438 | } |
| 3439 | |
| 3440 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3441 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3442 | tempbx--; |
| 3443 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3444 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3445 | |
| 3446 | if (tempbx & 0x0100) |
| 3447 | tempcx |= 0x0008; |
| 3448 | |
| 3449 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3450 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3451 | |
| 3452 | tempbx++; |
| 3453 | |
| 3454 | if (tempbx & 0x0100) |
| 3455 | tempcx |= 0x0004; |
| 3456 | |
| 3457 | if (tempbx & 0x0200) |
| 3458 | tempcx |= 0x0080; |
| 3459 | |
| 3460 | if (tempbx & 0x0400) |
| 3461 | tempcx |= 0x0C00; |
| 3462 | |
| 3463 | tempbx = push1; /* pop ax */ |
| 3464 | temp = tempbx & 0x00FF; |
| 3465 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3466 | /* 0x0D vertical Retrace End */ |
| 3467 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3468 | |
| 3469 | if (tempbx & 0x0010) |
| 3470 | tempcx |= 0x2000; |
| 3471 | |
| 3472 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3473 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3474 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3475 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3476 | tempax = modeflag; |
| 3477 | temp = (tempax & 0xFF00) >> 8; |
| 3478 | |
| 3479 | temp = (temp >> 1) & 0x09; |
| 3480 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3481 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3482 | temp |= 0x01; |
| 3483 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3484 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 3485 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 3486 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3487 | |
| 3488 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 3489 | temp = 0x80; |
| 3490 | else |
| 3491 | temp = 0x00; |
| 3492 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3493 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3494 | |
| 3495 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3496 | } |
| 3497 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3498 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3499 | unsigned short RefreshRateTableIndex, |
| 3500 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3501 | struct vb_device_info *pVBInfo) |
| 3502 | { |
| 3503 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
| 3504 | modeflag, resinfo, crt2crtc; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 3505 | unsigned char const *TimingPoint; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3506 | |
| 3507 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 3508 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3509 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3510 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3511 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3512 | crt2crtc = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3513 | |
| 3514 | tempax = 0; |
| 3515 | |
| 3516 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 3517 | tempax |= 0x0800; |
| 3518 | |
| 3519 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3520 | tempax |= 0x0400; |
| 3521 | |
| 3522 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 3523 | tempax |= 0x0200; |
| 3524 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3525 | if (!(pVBInfo->TVInfo & TVSetPAL)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3526 | tempax |= 0x1000; |
| 3527 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3528 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3529 | tempax |= 0x0100; |
| 3530 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3531 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3532 | tempax &= 0xfe00; |
| 3533 | |
| 3534 | tempax = (tempax & 0xff00) >> 8; |
| 3535 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3536 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3537 | TimingPoint = XGI330_NTSCTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3538 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3539 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3540 | TimingPoint = XGI330_PALTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3541 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3542 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3543 | TimingPoint = XGI330_HiTVExtTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3544 | |
| 3545 | if (pVBInfo->VBInfo & SetInSlaveMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3546 | TimingPoint = XGI330_HiTVSt2Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3547 | |
| 3548 | if (pVBInfo->SetFlag & TVSimuMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3549 | TimingPoint = XGI330_HiTVSt1Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3550 | |
| 3551 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3552 | TimingPoint = XGI330_HiTVTextTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3553 | } |
| 3554 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3555 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 3556 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3557 | TimingPoint = XGI330_YPbPr525iTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3558 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3559 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3560 | TimingPoint = XGI330_YPbPr525pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3561 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3562 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3563 | TimingPoint = XGI330_YPbPr750pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3564 | } |
| 3565 | |
| 3566 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3567 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3568 | |
| 3569 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3570 | /* di->temp2[j] */ |
| 3571 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3572 | |
| 3573 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3574 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3575 | |
| 3576 | temp = pVBInfo->NewFlickerMode; |
| 3577 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3578 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3579 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3580 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3581 | tempax = 950; |
| 3582 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3583 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3584 | tempax = 520; |
| 3585 | else |
| 3586 | tempax = 440; |
| 3587 | |
| 3588 | if (pVBInfo->VDE <= tempax) { |
| 3589 | tempax -= pVBInfo->VDE; |
| 3590 | tempax = tempax >> 2; |
| 3591 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 3592 | push1 = tempax; |
| 3593 | temp = (tempax & 0xFF00) >> 8; |
| 3594 | temp += (unsigned short) TimingPoint[0]; |
| 3595 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3596 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3597 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3598 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3599 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3600 | | SetCRT2ToYPbPr525750)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3601 | tempcx = pVBInfo->VGAHDE; |
| 3602 | if (tempcx >= 1024) { |
| 3603 | temp = 0x17; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3604 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3605 | temp = 0x19; /* PAL */ |
| 3606 | } |
| 3607 | } |
| 3608 | } |
| 3609 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3610 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3611 | tempax = push1; |
| 3612 | temp = (tempax & 0xFF00) >> 8; |
| 3613 | temp += TimingPoint[1]; |
| 3614 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3615 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3616 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3617 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3618 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3619 | | SetCRT2ToYPbPr525750))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3620 | tempcx = pVBInfo->VGAHDE; |
| 3621 | if (tempcx >= 1024) { |
| 3622 | temp = 0x1D; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3623 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3624 | temp = 0x52; /* PAL */ |
| 3625 | } |
| 3626 | } |
| 3627 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3628 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3629 | } |
| 3630 | |
| 3631 | /* 301b */ |
| 3632 | tempcx = pVBInfo->HT; |
| 3633 | |
| 3634 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3635 | tempcx = tempcx >> 1; |
| 3636 | |
| 3637 | tempcx -= 2; |
| 3638 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3639 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3640 | |
| 3641 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3642 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3643 | |
| 3644 | tempcx = pVBInfo->HT >> 1; |
| 3645 | push1 = tempcx; /* push cx */ |
| 3646 | tempcx += 7; |
| 3647 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3648 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3649 | tempcx -= 4; |
| 3650 | |
| 3651 | temp = tempcx & 0x00FF; |
| 3652 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3653 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3654 | |
| 3655 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3656 | tempbx += tempcx; |
| 3657 | push2 = tempbx; |
| 3658 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3659 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3660 | temp = (tempbx & 0xFF00) >> 8; |
| 3661 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3662 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3663 | |
| 3664 | tempbx = push2; |
| 3665 | tempbx = tempbx + 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3666 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3667 | tempbx = tempbx - 4; |
| 3668 | tempcx = tempbx; |
| 3669 | } |
| 3670 | |
| 3671 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3672 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3673 | |
| 3674 | j += 2; |
| 3675 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 3676 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3677 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3678 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3679 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3680 | |
| 3681 | tempcx += 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3682 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3683 | tempcx -= 4; |
| 3684 | |
| 3685 | temp = tempcx & 0xFF; |
| 3686 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3687 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3688 | |
| 3689 | tempcx = push1; /* pop cx */ |
| 3690 | j += 2; |
| 3691 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3692 | tempcx -= temp; |
| 3693 | temp = tempcx & 0x00FF; |
| 3694 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3695 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3696 | |
| 3697 | tempcx -= 11; |
| 3698 | |
| 3699 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 3700 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3701 | tempcx = tempax - 1; |
| 3702 | } |
| 3703 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3704 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3705 | |
| 3706 | tempbx = pVBInfo->VDE; |
| 3707 | |
| 3708 | if (pVBInfo->VGAVDE == 360) |
| 3709 | tempbx = 746; |
| 3710 | if (pVBInfo->VGAVDE == 375) |
| 3711 | tempbx = 746; |
| 3712 | if (pVBInfo->VGAVDE == 405) |
| 3713 | tempbx = 853; |
| 3714 | |
| 3715 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3716 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3717 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3718 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3719 | (TVSetYPbPr525p | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3720 | tempbx = tempbx >> 1; |
| 3721 | } else |
| 3722 | tempbx = tempbx >> 1; |
| 3723 | } |
| 3724 | |
| 3725 | tempbx -= 2; |
| 3726 | temp = tempbx & 0x00FF; |
| 3727 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3728 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3729 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3730 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3731 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3732 | if (ModeNo == 0x2f) |
| 3733 | temp += 1; |
| 3734 | } |
| 3735 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3736 | } else if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3737 | if (ModeNo == 0x2f) |
| 3738 | temp += 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3739 | } |
| 3740 | } |
| 3741 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3742 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3743 | |
| 3744 | temp = (tempcx & 0xFF00) >> 8; |
| 3745 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 3746 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3747 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3748 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3749 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3750 | temp |= 0x10; |
| 3751 | |
| 3752 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3753 | temp |= 0x20; |
| 3754 | } |
| 3755 | } else { |
| 3756 | temp |= 0x10; |
| 3757 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3758 | temp |= 0x20; |
| 3759 | } |
| 3760 | } |
| 3761 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3762 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3763 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3764 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3765 | | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3766 | tempbx = pVBInfo->VDE; |
| 3767 | tempcx = tempbx - 2; |
| 3768 | |
| 3769 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3770 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p |
| 3771 | | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3772 | tempbx = tempbx >> 1; |
| 3773 | } |
| 3774 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3775 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3776 | temp = 0; |
| 3777 | if (tempcx & 0x0400) |
| 3778 | temp |= 0x20; |
| 3779 | |
| 3780 | if (tempbx & 0x0400) |
| 3781 | temp |= 0x40; |
| 3782 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3783 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3784 | } |
| 3785 | |
| 3786 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3787 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3788 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3789 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3790 | } |
| 3791 | |
| 3792 | tempbx = tempbx & 0x00FF; |
| 3793 | |
| 3794 | if (!(modeflag & HalfDCLK)) { |
| 3795 | tempcx = pVBInfo->VGAHDE; |
| 3796 | if (tempcx >= pVBInfo->HDE) { |
| 3797 | tempbx |= 0x2000; |
| 3798 | tempax &= 0x00FF; |
| 3799 | } |
| 3800 | } |
| 3801 | |
| 3802 | tempcx = 0x0101; |
| 3803 | |
| 3804 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 3805 | if (pVBInfo->VGAHDE >= 1024) { |
| 3806 | tempcx = 0x1920; |
| 3807 | if (pVBInfo->VGAHDE >= 1280) { |
| 3808 | tempcx = 0x1420; |
| 3809 | tempbx = tempbx & 0xDFFF; |
| 3810 | } |
| 3811 | } |
| 3812 | } |
| 3813 | |
| 3814 | if (!(tempbx & 0x2000)) { |
| 3815 | if (modeflag & HalfDCLK) |
| 3816 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 3817 | |
| 3818 | push1 = tempbx; |
| 3819 | tempeax = pVBInfo->VGAHDE; |
| 3820 | tempebx = (tempcx & 0xFF00) >> 8; |
| 3821 | longtemp = tempeax * tempebx; |
| 3822 | tempecx = tempcx & 0x00FF; |
| 3823 | longtemp = longtemp / tempecx; |
| 3824 | |
| 3825 | /* 301b */ |
| 3826 | tempecx = 8 * 1024; |
| 3827 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3828 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3829 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3830 | tempecx = tempecx * 8; |
| 3831 | } |
| 3832 | |
| 3833 | longtemp = longtemp * tempecx; |
| 3834 | tempecx = pVBInfo->HDE; |
| 3835 | temp2 = longtemp % tempecx; |
| 3836 | tempeax = longtemp / tempecx; |
| 3837 | if (temp2 != 0) |
| 3838 | tempeax += 1; |
| 3839 | |
| 3840 | tempax = (unsigned short) tempeax; |
| 3841 | |
| 3842 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3843 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3844 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3845 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 3846 | } |
| 3847 | /* end 301b */ |
| 3848 | |
| 3849 | tempbx = push1; |
| 3850 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 3851 | | (tempbx & 0x00FF)); |
| 3852 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 3853 | | (tempax & 0x00FF)); |
| 3854 | temp = (tempax & 0xFF00) >> 8; |
| 3855 | } else { |
| 3856 | temp = (tempax & 0x00FF) >> 8; |
| 3857 | } |
| 3858 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3859 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3860 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3861 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3862 | temp = tempcx & 0x00FF; |
| 3863 | |
| 3864 | if (tempbx & 0x2000) |
| 3865 | temp = 0; |
| 3866 | |
| 3867 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3868 | temp |= 0x18; |
| 3869 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3870 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3871 | if (pVBInfo->TVInfo & TVSetPAL) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3872 | tempbx = 0x0382; |
| 3873 | tempcx = 0x007e; |
| 3874 | } else { |
| 3875 | tempbx = 0x0369; |
| 3876 | tempcx = 0x0061; |
| 3877 | } |
| 3878 | |
| 3879 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3880 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3881 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3882 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3883 | |
| 3884 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 3885 | temp = temp << 2; |
| 3886 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 3887 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3888 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3889 | temp |= 0x10; |
| 3890 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3891 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3892 | temp |= 0x20; |
| 3893 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3894 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3895 | temp |= 0x60; |
| 3896 | } |
| 3897 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3898 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3899 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3900 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3901 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3902 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3903 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 3904 | TimingPoint = XGI_NTSC1024AdjTime; |
| 3905 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3906 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3907 | TimingPoint[j]); |
| 3908 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3909 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3910 | } |
| 3911 | } |
| 3912 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 3913 | /* Modify for 301C PALM Support */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3914 | if (pVBInfo->VBType & VB_XGI301C) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3915 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3916 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3917 | 0x08); /* PALM Mode */ |
| 3918 | } |
| 3919 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3920 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3921 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3922 | 0x01); |
| 3923 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3924 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3925 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3926 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3927 | } |
| 3928 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3929 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3930 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3931 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3932 | } |
| 3933 | |
| 3934 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3935 | return; |
| 3936 | } |
| 3937 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3938 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3939 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3940 | unsigned short RefreshRateTableIndex, |
| 3941 | struct vb_device_info *pVBInfo) |
| 3942 | { |
| 3943 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
| 3944 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; |
| 3945 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 3946 | struct XGI_LCDDesStruct const *LCDBDesPtr = NULL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3947 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3948 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3949 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3950 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 3951 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3952 | CRT1Index &= IndexMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3953 | |
| 3954 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3955 | return; |
| 3956 | |
| 3957 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 3958 | |
| 3959 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3960 | tempbx = tempbx >> 1; |
| 3961 | |
| 3962 | tempbx -= 1; |
| 3963 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3964 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3965 | temp = (tempbx & 0xFF00) >> 8; |
| 3966 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3967 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3968 | temp = 0x01; |
| 3969 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3970 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3971 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
| 3972 | push1 = tempbx; |
| 3973 | tempbx--; |
| 3974 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3975 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3976 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3977 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3978 | |
| 3979 | tempcx = pVBInfo->VT - 1; |
| 3980 | push2 = tempcx + 1; |
| 3981 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3982 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3983 | temp = (tempcx & 0xFF00) >> 8; |
| 3984 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3985 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3986 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 3987 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 3988 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 3989 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3990 | |
Justin P. Mattock | 558f758 | 2012-10-02 21:17:11 -0700 | [diff] [blame] | 3991 | /* Customized LCDB Does not add */ |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 3992 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
| 3993 | LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeNo, ModeIdIndex, |
| 3994 | RefreshRateTableIndex, pVBInfo); |
| 3995 | else |
| 3996 | LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeNo, |
| 3997 | ModeIdIndex, RefreshRateTableIndex, |
| 3998 | pVBInfo); |
| 3999 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4000 | tempah = pVBInfo->LCDResInfo; |
| 4001 | tempah &= PanelResInfo; |
| 4002 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4003 | if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4004 | tempbx = 1024; |
| 4005 | tempcx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4006 | } else if ((tempah == Panel_1280x1024) || |
| 4007 | (tempah == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4008 | tempbx = 1280; |
| 4009 | tempcx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 4010 | } else if (tempah == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4011 | tempbx = 1400; |
| 4012 | tempcx = 1050; |
| 4013 | } else { |
| 4014 | tempbx = 1600; |
| 4015 | tempcx = 1200; |
| 4016 | } |
| 4017 | |
| 4018 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 4019 | tempbx = pVBInfo->HDE; |
| 4020 | tempcx = pVBInfo->VDE; |
| 4021 | } |
| 4022 | |
| 4023 | pushbx = tempbx; |
| 4024 | tempax = pVBInfo->VT; |
| 4025 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 4026 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 4027 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 4028 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 4029 | tempbx = pVBInfo->LCDVDES; |
| 4030 | tempcx += tempbx; |
| 4031 | |
| 4032 | if (tempcx >= tempax) |
| 4033 | tempcx -= tempax; /* lcdvdes */ |
| 4034 | |
| 4035 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4036 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4037 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4038 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4039 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 4040 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 4041 | tempah = tempch; |
| 4042 | tempah = tempah << 3; |
| 4043 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4044 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4045 | |
| 4046 | /* getlcdsync() */ |
| 4047 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 4048 | tempcx = tempbx; |
| 4049 | tempax = pVBInfo->VT; |
| 4050 | tempbx = pVBInfo->LCDVRS; |
| 4051 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4052 | tempcx += tempbx; |
| 4053 | if (tempcx >= tempax) |
| 4054 | tempcx -= tempax; |
| 4055 | |
| 4056 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4057 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4058 | temp = (tempbx & 0xFF00) >> 8; |
| 4059 | temp = temp << 4; |
| 4060 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4061 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4062 | tempcx = pushbx; |
| 4063 | tempax = pVBInfo->HT; |
| 4064 | tempbx = pVBInfo->LCDHDES; |
| 4065 | tempbx &= 0x0FFF; |
| 4066 | |
| 4067 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 4068 | tempax = tempax >> 1; |
| 4069 | tempbx = tempbx >> 1; |
| 4070 | tempcx = tempcx >> 1; |
| 4071 | } |
| 4072 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4073 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4074 | tempbx += 1; |
| 4075 | |
| 4076 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 4077 | tempbx += 1; |
| 4078 | |
| 4079 | tempcx += tempbx; |
| 4080 | |
| 4081 | if (tempcx >= tempax) |
| 4082 | tempcx -= tempax; |
| 4083 | |
| 4084 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4085 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4086 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4087 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4088 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4089 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4090 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4091 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4092 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4093 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 4094 | tempcx = tempax; |
| 4095 | tempax = pVBInfo->HT; |
| 4096 | tempbx = pVBInfo->LCDHRS; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4097 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 4098 | tempax = tempax >> 1; |
| 4099 | tempbx = tempbx >> 1; |
| 4100 | tempcx = tempcx >> 1; |
| 4101 | } |
| 4102 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4103 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4104 | tempbx += 1; |
| 4105 | |
| 4106 | tempcx += tempbx; |
| 4107 | |
| 4108 | if (tempcx >= tempax) |
| 4109 | tempcx -= tempax; |
| 4110 | |
| 4111 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4112 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4113 | |
| 4114 | temp = (tempbx & 0xFF00) >> 8; |
| 4115 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4116 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4117 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4118 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4119 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4120 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4121 | if (pVBInfo->VGAVDE == 525) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4122 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 4123 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4124 | | VB_XGI301C)) { |
| 4125 | temp = 0xC6; |
| 4126 | } else |
| 4127 | temp = 0xC4; |
| 4128 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4129 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 4130 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4131 | } |
| 4132 | |
| 4133 | if (pVBInfo->VGAVDE == 420) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4134 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 4135 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4136 | | VB_XGI301C)) { |
| 4137 | temp = 0x4F; |
| 4138 | } else |
| 4139 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4140 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4141 | } |
| 4142 | } |
| 4143 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4144 | |
| 4145 | /* --------------------------------------------------------------------- */ |
| 4146 | /* Function : XGI_GetTap4Ptr */ |
| 4147 | /* Input : */ |
| 4148 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 4149 | /* Description : */ |
| 4150 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 4151 | static struct XGI301C_Tap4TimingStruct const |
| 4152 | *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4153 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4154 | unsigned short tempax, tempbx, i; |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 4155 | struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4156 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4157 | if (tempcx == 0) { |
| 4158 | tempax = pVBInfo->VGAHDE; |
| 4159 | tempbx = pVBInfo->HDE; |
| 4160 | } else { |
| 4161 | tempax = pVBInfo->VGAVDE; |
| 4162 | tempbx = pVBInfo->VDE; |
| 4163 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4164 | |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4165 | if (tempax <= tempbx) |
| 4166 | return &xgifb_tap4_timing[0]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4167 | else |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4168 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4169 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4170 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4171 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4172 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4173 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 4174 | if ((pVBInfo->TVInfo & TVSetYPbPr525i) || |
| 4175 | (pVBInfo->TVInfo & TVSetYPbPr525p)) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4176 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4177 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4178 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 4179 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4180 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4181 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4182 | Tap4TimingPtr = xgifb_tap4_timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4183 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4184 | i = 0; |
| 4185 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 4186 | if (Tap4TimingPtr[i].DE == tempax) |
| 4187 | break; |
| 4188 | i++; |
| 4189 | } |
| 4190 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4191 | } |
| 4192 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4193 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4194 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4195 | unsigned short i, j; |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 4196 | struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4197 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4198 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 4199 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4200 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4201 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 4202 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4203 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4204 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4205 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4206 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4207 | /* Set Vertical Scaling */ |
| 4208 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4209 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4210 | xgifb_reg_set(pVBInfo->Part2Port, |
| 4211 | i, |
| 4212 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4213 | } |
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 | /* Enable V.Scaling */ |
| 4218 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4219 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4220 | /* Enable H.Scaling */ |
| 4221 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4222 | } |
| 4223 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4224 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4225 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4226 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4227 | unsigned short i; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 4228 | unsigned char const *tempdi; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4229 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4230 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4231 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4232 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4233 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4234 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4235 | if (pVBInfo->TVInfo & TVSetPAL) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4236 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 4237 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4238 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4239 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 4240 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4241 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4242 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4243 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4244 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4245 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4246 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4247 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 4248 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 4249 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4250 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4251 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4252 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo |
| 4253 | & SetCRT2ToYPbPr525750)) { |
| 4254 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4255 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4256 | |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4257 | tempdi = XGI330_HiTVGroup3Data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4258 | if (pVBInfo->SetFlag & TVSimuMode) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4259 | tempdi = XGI330_HiTVGroup3Simu; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4260 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4261 | tempdi = XGI330_HiTVGroup3Text; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4262 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4263 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4264 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4265 | tempdi = XGI330_Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4266 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4267 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4268 | tempdi = XGI330_Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4269 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4270 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4271 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4272 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4273 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4274 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4275 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4276 | } |
| 4277 | } |
| 4278 | return; |
| 4279 | } /* {end of XGI_SetGroup3} */ |
| 4280 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4281 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4282 | unsigned short RefreshRateTableIndex, |
| 4283 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4284 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4285 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4286 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4287 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4288 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4289 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4290 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4291 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4292 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4293 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4294 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4295 | tempbx = pVBInfo->RVBHCMAX; |
| 4296 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4297 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4298 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 4299 | tempcx = pVBInfo->VGAHT - 1; |
| 4300 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4301 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4302 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4303 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 4304 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4305 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4306 | tempcx = pVBInfo->VGAVT - 1; |
| 4307 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4308 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4309 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4310 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4311 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4312 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4313 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4314 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4315 | tempcx = pVBInfo->VBInfo; |
| 4316 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4317 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4318 | if (modeflag & HalfDCLK) |
| 4319 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4320 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4321 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4322 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4323 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4324 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4325 | temp = 0; |
| 4326 | if (tempbx <= 1024) |
| 4327 | temp = 0xA0; |
| 4328 | if (tempbx == 1280) |
| 4329 | temp = 0xC0; |
| 4330 | } else if (tempcx & SetCRT2ToTV) { |
| 4331 | temp = 0xA0; |
| 4332 | if (tempbx <= 800) |
| 4333 | temp = 0x80; |
| 4334 | } else { |
| 4335 | temp = 0x80; |
| 4336 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4337 | temp = 0; |
| 4338 | if (tempbx > 800) |
| 4339 | temp = 0x60; |
| 4340 | } |
| 4341 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4342 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4343 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4344 | temp = 0x00; |
| 4345 | if (pVBInfo->VGAHDE == 1280) |
| 4346 | temp = 0x40; |
| 4347 | if (pVBInfo->VGAHDE == 1024) |
| 4348 | temp = 0x20; |
| 4349 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4350 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4351 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4352 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4353 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4354 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4355 | if (!(temp & 0xE000)) |
| 4356 | tempbx = tempbx >> 1; |
| 4357 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4358 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4359 | tempcx = pVBInfo->RVBHRS; |
| 4360 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4361 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4362 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4363 | tempeax = pVBInfo->VGAVDE; |
| 4364 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4365 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4366 | if (tempeax <= tempebx) { |
| 4367 | tempcx = (tempcx & (~0x4000)); |
| 4368 | tempeax = pVBInfo->VGAVDE; |
| 4369 | } else { |
| 4370 | tempeax -= tempebx; |
| 4371 | } |
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 | templong = (tempeax * 256 * 1024) % tempebx; |
| 4374 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 4375 | tempebx = tempeax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4376 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4377 | if (templong != 0) |
| 4378 | tempebx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4379 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4380 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4381 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
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 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4384 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4385 | tempbx = (unsigned short) (tempebx >> 16); |
| 4386 | temp = tempbx & 0x00FF; |
| 4387 | temp = temp << 4; |
| 4388 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4389 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4390 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4391 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4392 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4393 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4394 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4395 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4396 | tempax = pVBInfo->VGAHDE; |
| 4397 | if (modeflag & HalfDCLK) |
| 4398 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4399 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4400 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4401 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4402 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4403 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4404 | if (tempax > 800) |
| 4405 | tempax -= 800; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 4406 | } else if (pVBInfo->VGAHDE > 800) { |
| 4407 | if (pVBInfo->VGAHDE == 1024) |
| 4408 | tempax = (tempax * 25 / 32) - 1; |
| 4409 | else |
| 4410 | tempax = (tempax * 20 / 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4411 | } |
| 4412 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4413 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4414 | temp = (tempax & 0xFF00) >> 8; |
| 4415 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4416 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4417 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4418 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4419 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4420 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4421 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4422 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
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 | } |
| 4425 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4426 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4427 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4428 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4429 | | TVSetYPbPr525p | TVSetYPbPr750p |
| 4430 | | TVSetHiVision))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4431 | temp |= 0x0001; |
| 4432 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 4433 | && (!(pVBInfo->TVInfo |
| 4434 | & TVSimuMode))) |
| 4435 | temp &= (~0x0001); |
| 4436 | } |
| 4437 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4438 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4439 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4440 | tempbx = pVBInfo->HT; |
| 4441 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4442 | tempbx = tempbx >> 1; |
| 4443 | tempbx = (tempbx >> 1) - 2; |
| 4444 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4445 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4446 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4447 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4448 | } |
| 4449 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4450 | |
Aaro Koskinen | 8951dad | 2012-09-11 00:15:30 +0300 | [diff] [blame] | 4451 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4452 | } |
| 4453 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4454 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 4455 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4456 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4457 | } |
| 4458 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4459 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4460 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4461 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4462 | unsigned short Pindex, Pdata; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4463 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4464 | Pindex = pVBInfo->Part5Port; |
| 4465 | Pdata = pVBInfo->Part5Port + 1; |
| 4466 | if (pVBInfo->ModeType == ModeVGA) { |
| 4467 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4468 | | DisableCRT2Display))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4469 | XGINew_EnableCRT2(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4470 | } |
| 4471 | } |
| 4472 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4473 | } |
| 4474 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4475 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4476 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4477 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4478 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4479 | } |
| 4480 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4481 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4482 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4483 | { |
| 4484 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4485 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4486 | } |
| 4487 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4488 | static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, |
| 4489 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 4490 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4491 | { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4492 | unsigned short xres, yres, colordepth, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4493 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4494 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 4495 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4496 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4497 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4498 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4499 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4500 | if (!(modeflag & Charx8Dot)) { |
| 4501 | xres /= 9; |
| 4502 | xres *= 8; |
| 4503 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4504 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4505 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 4506 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4507 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4508 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 4509 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4510 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4511 | if (xres > xgifb_info->lvds_data.LVDSHDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4512 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4513 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4514 | if (yres > xgifb_info->lvds_data.LVDSVDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4515 | return 0; |
| 4516 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4517 | if (xres != xgifb_info->lvds_data.LVDSHDE || |
| 4518 | yres != xgifb_info->lvds_data.LVDSVDE) { |
| 4519 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 4520 | if (colordepth > 2) |
| 4521 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4522 | } |
| 4523 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4524 | } |
| 4525 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4526 | static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, |
| 4527 | int chip_id, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4528 | unsigned short ModeNo, |
| 4529 | unsigned short ModeIdIndex, |
| 4530 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4531 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4532 | unsigned char temp, Miscdata; |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4533 | unsigned short xres, yres, modeflag, resindex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4534 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 4535 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 4536 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4537 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4538 | temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4539 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4540 | temp &= LCDPolarity; |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4541 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4542 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4543 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4544 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4545 | temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4546 | /* SR35[7] FP VSync polarity */ |
| 4547 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 4548 | /* SR30[5] FP HSync polarity */ |
| 4549 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4550 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4551 | if (chip_id == XG27) |
| 4552 | XGI_SetXG27FPBits(pVBInfo); |
| 4553 | else |
| 4554 | XGI_SetXG21FPBits(pVBInfo); |
| 4555 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4556 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 4557 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4558 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4559 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4560 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4561 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4562 | if (!(modeflag & Charx8Dot)) |
| 4563 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4564 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4565 | LVDSHT = xgifb_info->lvds_data.LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4566 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4567 | LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4568 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4569 | if (LVDSHBS > LVDSHT) |
| 4570 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4571 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4572 | LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4573 | if (LVDSHRS > LVDSHT) |
| 4574 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4575 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4576 | LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4577 | if (LVDSHRE > LVDSHT) |
| 4578 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4579 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4580 | LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE; |
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 | LVDSVT = xgifb_info->lvds_data.LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4583 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4584 | LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4585 | if (modeflag & DoubleScanMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4586 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4587 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4588 | if (LVDSVBS > LVDSVT) |
| 4589 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4590 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4591 | LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4592 | if (LVDSVRS > LVDSVT) |
| 4593 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4594 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4595 | LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4596 | if (LVDSVRE > LVDSVT) |
| 4597 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4598 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4599 | LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4600 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4601 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4602 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4603 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4604 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4605 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4606 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4607 | /* HT SR0B[1:0] CR00 */ |
| 4608 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4609 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4610 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4611 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4612 | /* HBS SR0B[5:4] CR02 */ |
| 4613 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4614 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4615 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
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 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 4618 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4619 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 4620 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 4621 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4622 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4623 | /* HRS SR0B[7:6] CR04 */ |
| 4624 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4625 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4626 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4627 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4628 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 4629 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4630 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4631 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
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 | /* HRE SR0C[2] CR05[4:0] */ |
| 4634 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4635 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 4636 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
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 HRE SR2F[7:2] */ |
| 4639 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4640 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4641 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4642 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 4643 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4644 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 4645 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 4646 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4647 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4648 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4649 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 4650 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4651 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 4652 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 4653 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4654 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4655 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4656 | /* VBE SR0A[4] CR16 */ |
| 4657 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4658 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4659 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4660 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4661 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 4662 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4663 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 4664 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 4665 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4666 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4667 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4668 | if (chip_id == XG27) { |
| 4669 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
| 4670 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, |
| 4671 | (value & 0x700) >> 8); |
| 4672 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
| 4673 | } else { |
| 4674 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
| 4675 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, |
| 4676 | (value & 0x600) >> 9); |
| 4677 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
| 4678 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
| 4679 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4680 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4681 | /* VRE SR0A[5] CR11[3:0] */ |
| 4682 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4683 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 4684 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4685 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4686 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4687 | if (chip_id == XG27) |
| 4688 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4689 | (value << 2) & 0xFC); |
| 4690 | else |
| 4691 | /* SR3F[7] has to be 0, h/w bug */ |
| 4692 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4693 | (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4694 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4695 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4696 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4697 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4698 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4699 | 0x2B, xgifb_info->lvds_data.VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4700 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4701 | 0x2C, xgifb_info->lvds_data.VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4702 | value += 0x10; |
| 4703 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4704 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4705 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4706 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4707 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4708 | /* set data, panning = 0, shift left 1 dot*/ |
| 4709 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4710 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4711 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4712 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4713 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4714 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4715 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4716 | |
| 4717 | } |
| 4718 | |
| 4719 | /* --------------------------------------------------------------------- */ |
| 4720 | /* Function : XGI_IsLCDON */ |
| 4721 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4722 | /* Output : 0 : Skip PSC Control */ |
| 4723 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4724 | /* Description : */ |
| 4725 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4726 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4727 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4728 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4729 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4730 | tempax = pVBInfo->VBInfo; |
| 4731 | if (tempax & SetCRT2ToDualEdge) |
| 4732 | return 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4733 | else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4734 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4735 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4736 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4737 | } |
| 4738 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4739 | /* --------------------------------------------------------------------- */ |
| 4740 | /* Function : XGI_DisableChISLCD */ |
| 4741 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4742 | /* Output : 0 -> Not LCD Mode */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4743 | /* Description : */ |
| 4744 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4745 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4746 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4747 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4748 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4749 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4750 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4751 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4752 | if (tempbx & (EnableChA | DisableChA)) { |
| 4753 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 4754 | return 0; |
| 4755 | } |
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 | if (!(tempbx & (EnableChB | DisableChB))) |
| 4758 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4759 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4760 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 4761 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4762 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4763 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4764 | } |
| 4765 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4766 | /* --------------------------------------------------------------------- */ |
| 4767 | /* Function : XGI_EnableChISLCD */ |
| 4768 | /* Input : */ |
| 4769 | /* Output : 0 -> Not LCD mode */ |
| 4770 | /* Description : */ |
| 4771 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4772 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4773 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4774 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4775 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4776 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4777 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4778 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4779 | if (tempbx & (EnableChA | DisableChA)) { |
| 4780 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 4781 | return 0; |
| 4782 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4783 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4784 | if (!(tempbx & (EnableChB | DisableChB))) |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4785 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4786 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4787 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 4788 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4789 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4790 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4791 | } |
| 4792 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4793 | static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, |
| 4794 | struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4795 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4796 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 4797 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4798 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4799 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4800 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4801 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4802 | if (!(pVBInfo->VBInfo & |
| 4803 | (DisableCRT2Display | SetSimuScanMode))) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4804 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4805 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 4806 | tempah = 0x7F; /* Disable Channel A */ |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4807 | if (!(pVBInfo->VBInfo & |
| 4808 | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4809 | /* Disable Channel B */ |
| 4810 | tempah = 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4811 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4812 | if (pVBInfo->SetFlag & DisableChB) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4813 | /* force to disable Cahnnel */ |
| 4814 | tempah &= 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4815 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4816 | if (pVBInfo->SetFlag & DisableChA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4817 | /* Force to disable Channel B */ |
| 4818 | tempah &= 0x7F; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4819 | } |
| 4820 | } |
| 4821 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4822 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4823 | /* disable part4_1f */ |
| 4824 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4825 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4826 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4827 | if (((pVBInfo->VBInfo & |
| 4828 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 4829 | || (XGI_DisableChISLCD(pVBInfo)) |
| 4830 | || (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4831 | /* LVDS Driver power down */ |
| 4832 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4833 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4834 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4835 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4836 | & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4837 | | SetSimuScanMode))) { |
| 4838 | if (pVBInfo->SetFlag & GatingCRT) |
| 4839 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4840 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4841 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4842 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4843 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4844 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4845 | & XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4846 | /* Power down */ |
| 4847 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4848 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4849 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4850 | /* disable TV as primary VGA swap */ |
| 4851 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4852 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4853 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 4854 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4855 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4856 | if ((pVBInfo->SetFlag & DisableChB) || |
| 4857 | (pVBInfo->VBInfo & |
| 4858 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4859 | ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4860 | (pVBInfo->VBInfo & |
| 4861 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4862 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4863 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4864 | if ((pVBInfo->SetFlag & DisableChB) || |
| 4865 | (pVBInfo->VBInfo & |
| 4866 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4867 | (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) || |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4868 | (pVBInfo->VBInfo & |
| 4869 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 4870 | /* save Part1 index 0 */ |
| 4871 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 4872 | /* BTDAC = 1, avoid VB reset */ |
| 4873 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 4874 | /* disable CRT2 */ |
| 4875 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4876 | /* restore Part1 index 0 */ |
| 4877 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4878 | } |
| 4879 | } else { /* {301} */ |
| 4880 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4881 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 4882 | /* Disable CRT2 */ |
| 4883 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4884 | /* Disable TV asPrimary VGA swap */ |
| 4885 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4886 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4887 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4888 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4889 | | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4890 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4891 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4892 | } |
| 4893 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4894 | /* --------------------------------------------------------------------- */ |
| 4895 | /* Function : XGI_GetTVPtrIndex */ |
| 4896 | /* Input : */ |
| 4897 | /* Output : */ |
| 4898 | /* Description : bx 0 : ExtNTSC */ |
| 4899 | /* 1 : StNTSC */ |
| 4900 | /* 2 : ExtPAL */ |
| 4901 | /* 3 : StPAL */ |
| 4902 | /* 4 : ExtHiTV */ |
| 4903 | /* 5 : StHiTV */ |
| 4904 | /* 6 : Ext525i */ |
| 4905 | /* 7 : St525i */ |
| 4906 | /* 8 : Ext525p */ |
| 4907 | /* 9 : St525p */ |
| 4908 | /* A : Ext750p */ |
| 4909 | /* B : St750p */ |
| 4910 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4911 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4912 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4913 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4914 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4915 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4916 | tempbx = 2; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4917 | if (pVBInfo->TVInfo & TVSetHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4918 | tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4919 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4920 | tempbx = 6; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4921 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4922 | tempbx = 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4923 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4924 | tempbx = 10; |
| 4925 | if (pVBInfo->TVInfo & TVSimuMode) |
| 4926 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4927 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4928 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4929 | } |
| 4930 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4931 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4932 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4933 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4934 | /* Output : bx 0 : NTSC */ |
| 4935 | /* 1 : PAL */ |
| 4936 | /* 2 : PALM */ |
| 4937 | /* 3 : PALN */ |
| 4938 | /* 4 : NTSC1024x768 */ |
| 4939 | /* 5 : PAL-M 1024x768 */ |
| 4940 | /* 6-7: reserved */ |
| 4941 | /* cl 0 : YFilter1 */ |
| 4942 | /* 1 : YFilter2 */ |
| 4943 | /* ch 0 : 301A */ |
| 4944 | /* 1 : 301B/302B/301LV/302LV */ |
| 4945 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4946 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4947 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 4948 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4949 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4950 | *tempbx = 0; |
| 4951 | *tempcl = 0; |
| 4952 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4953 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4954 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4955 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4956 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4957 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4958 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4959 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4960 | if (pVBInfo->TVInfo & TVSetPALN) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4961 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4962 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4963 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 4964 | *tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4965 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4966 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4967 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4968 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4969 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4970 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4971 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 4972 | & TVSimuMode)) { |
| 4973 | *tempbx += 8; |
| 4974 | *tempcl += 1; |
| 4975 | } |
| 4976 | } |
| 4977 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4978 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4979 | | VB_SIS302LV | VB_XGI301C)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4980 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4981 | } |
| 4982 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4983 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4984 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4985 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4986 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4987 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4988 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4989 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4990 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4991 | tempbh = 0; |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 4992 | tempbl = XGI301TVDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4993 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4994 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 4995 | tempbl = tempbl >> 4; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4996 | if (pVBInfo->VBInfo & |
| 4997 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 4998 | tempbh = XGI301LCDDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4999 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5000 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5001 | tempbl = tempbh; |
| 5002 | } |
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 | tempbl &= 0x0F; |
| 5005 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5006 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5007 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5008 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 5009 | | SetCRT2ToTV)) { /* Channel B */ |
| 5010 | tempah &= 0xF0; |
| 5011 | tempah |= tempbl; |
| 5012 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5013 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 5014 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 5015 | /* Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5016 | tempah &= 0x0F; |
| 5017 | tempah |= tempbh; |
| 5018 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5019 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5020 | } |
| 5021 | } else if (pVBInfo->IF_DEF_LVDS == 1) { |
| 5022 | tempbl = 0; |
| 5023 | tempbh = 0; |
| 5024 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 5025 | tempah = XGI301LCDDelay; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5026 | tempah &= 0x0f; |
| 5027 | tempah = tempah << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5028 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5029 | tempah); |
| 5030 | } |
| 5031 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5032 | } |
| 5033 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5034 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 5035 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5036 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5037 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5038 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5039 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5040 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5041 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5042 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5043 | /* Enable Dither */ |
| 5044 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5045 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5046 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5047 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5048 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5049 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5050 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5051 | } |
| 5052 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5053 | /* --------------------------------------------------------------------- */ |
| 5054 | /* Function : XGI_SetLCDCap_B */ |
| 5055 | /* Input : cx -> LCD Capability */ |
| 5056 | /* Output : */ |
| 5057 | /* Description : */ |
| 5058 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5059 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 5060 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5061 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5062 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5063 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5064 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 5065 | | 0x0c)); |
| 5066 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5067 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5068 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 5069 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5070 | } |
| 5071 | |
Aaro Koskinen | 7f04ec3 | 2011-11-27 23:03:05 +0200 | [diff] [blame] | 5072 | static void XGI_LongWait(struct vb_device_info *pVBInfo) |
| 5073 | { |
| 5074 | unsigned short i; |
| 5075 | |
| 5076 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
| 5077 | |
| 5078 | if (!(i & 0xC0)) { |
| 5079 | for (i = 0; i < 0xFFFF; i++) { |
| 5080 | if (!(inb(pVBInfo->P3da) & 0x08)) |
| 5081 | break; |
| 5082 | } |
| 5083 | |
| 5084 | for (i = 0; i < 0xFFFF; i++) { |
| 5085 | if ((inb(pVBInfo->P3da) & 0x08)) |
| 5086 | break; |
| 5087 | } |
| 5088 | } |
| 5089 | } |
| 5090 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5091 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5092 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5093 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5094 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5095 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5096 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5097 | /* disable down spectrum D[4] */ |
| 5098 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5099 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5100 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5101 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5102 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5103 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5104 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5105 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5106 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5107 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5108 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5109 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5110 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 5111 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5112 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5113 | } |
| 5114 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5115 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 5116 | { |
| 5117 | unsigned short tempcx; |
| 5118 | |
| 5119 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 5120 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5121 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5122 | (VB_SIS301B | |
| 5123 | VB_SIS302B | |
| 5124 | VB_SIS301LV | |
| 5125 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5126 | VB_XGI301C)) { /* 301LV/302LV only */ |
| 5127 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5128 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5129 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5130 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5131 | (unsigned char) (tempcx & 0x1F)); |
| 5132 | } |
| 5133 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5134 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5135 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 5136 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 5137 | | EnablePLLSPLOW)) >> 8)); |
| 5138 | } |
| 5139 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5140 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5141 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5142 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 5143 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5144 | else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5145 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 5146 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5147 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5148 | if (tempcx & EnableSpectrum) |
| 5149 | SetSpectrum(pVBInfo); |
| 5150 | } |
| 5151 | } else { |
| 5152 | /* LVDS,CH7017 */ |
| 5153 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 5154 | } |
| 5155 | } |
| 5156 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5157 | /* --------------------------------------------------------------------- */ |
| 5158 | /* Function : XGI_SetAntiFlicker */ |
| 5159 | /* Input : */ |
| 5160 | /* Output : */ |
| 5161 | /* Description : Set TV Customized Param. */ |
| 5162 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5163 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
| 5164 | unsigned short ModeIdIndex, |
| 5165 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5166 | { |
Aaro Koskinen | 36ae035 | 2012-04-07 01:14:08 +0300 | [diff] [blame] | 5167 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5168 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5169 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5170 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 5171 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5172 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5173 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5174 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 5175 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5176 | tempah = TVAntiFlickList[tempbx]; |
| 5177 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5178 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5179 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5180 | } |
| 5181 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5182 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
| 5183 | unsigned short ModeIdIndex, |
| 5184 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5185 | { |
Aaro Koskinen | 354f49f | 2012-04-07 01:14:09 +0300 | [diff] [blame] | 5186 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5187 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5188 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5189 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5190 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 5191 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5192 | tempah = TVEdgeList[tempbx]; |
| 5193 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5194 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5195 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5196 | } |
| 5197 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5198 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
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 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5201 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5202 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5203 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5204 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5205 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5206 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 5207 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5208 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5209 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5210 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5211 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5212 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5213 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5214 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5215 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5216 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5217 | } |
| 5218 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 5219 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5220 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5221 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5222 | unsigned short tempbx, index; |
Aaro Koskinen | a68292f | 2012-11-04 21:15:07 +0200 | [diff] [blame^] | 5223 | unsigned char const *filterPtr; |
| 5224 | unsigned char tempcl, tempch, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5225 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5226 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5227 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5228 | switch (tempbx) { |
| 5229 | case 0x00: |
| 5230 | case 0x04: |
| 5231 | filterPtr = NTSCYFilter1; |
| 5232 | break; |
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 | case 0x01: |
| 5235 | filterPtr = PALYFilter1; |
| 5236 | break; |
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 | case 0x02: |
| 5239 | case 0x05: |
| 5240 | case 0x0D: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5241 | case 0x03: |
Aaro Koskinen | 2555e94 | 2011-08-31 21:46:06 +0300 | [diff] [blame] | 5242 | filterPtr = xgifb_palmn_yfilter1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5243 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5244 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5245 | case 0x08: |
| 5246 | case 0x0C: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5247 | case 0x0A: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5248 | case 0x0B: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5249 | case 0x09: |
Aaro Koskinen | 80f86f8 | 2011-08-31 21:46:05 +0300 | [diff] [blame] | 5250 | filterPtr = xgifb_yfilter2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5251 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5252 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5253 | default: |
| 5254 | return; |
| 5255 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5256 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5257 | tempal = XGI330_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5258 | if (tempcl == 0) |
| 5259 | index = tempal * 4; |
| 5260 | else |
| 5261 | index = tempal * 7; |
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 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5264 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 5265 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 5266 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 5267 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5268 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5269 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 5270 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 5271 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 5272 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5273 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5274 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5275 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5276 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5277 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 5278 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 5279 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5280 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5281 | } |
| 5282 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5283 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5284 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5285 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5286 | /* Output : */ |
| 5287 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5288 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5289 | static void XGI_OEM310Setting(unsigned short ModeNo, |
| 5290 | unsigned short ModeIdIndex, |
| 5291 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5292 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5293 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5294 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5295 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5296 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5297 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5298 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5299 | XGI_SetPhaseIncr(pVBInfo); |
| 5300 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); |
| 5301 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5302 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5303 | if (pVBInfo->VBType & VB_SIS301) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5304 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5305 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5306 | } |
| 5307 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5308 | /* --------------------------------------------------------------------- */ |
| 5309 | /* Function : XGI_SetCRT2ModeRegs */ |
| 5310 | /* Input : */ |
| 5311 | /* Output : */ |
| 5312 | /* Description : Origin code for crt2group */ |
| 5313 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5314 | static void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5315 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5316 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5317 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5318 | unsigned short tempbl; |
| 5319 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5320 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5321 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5322 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5323 | tempah = 0; |
| 5324 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5325 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5326 | tempah &= ~0x10; /* BTRAMDAC */ |
| 5327 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5328 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5329 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 5330 | | SetCRT2ToLCD)) { |
| 5331 | tempah = 0x40; /* BTDRAM */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5332 | tempcl = pVBInfo->ModeType; |
| 5333 | tempcl -= ModeVGA; |
| 5334 | if (tempcl >= 0) { |
| 5335 | /* BT Color */ |
| 5336 | tempah = (0x008 >> tempcl); |
| 5337 | if (tempah == 0) |
| 5338 | tempah = 1; |
| 5339 | tempah |= 0x040; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5340 | } |
| 5341 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 5342 | tempah ^= 0x50; /* BTDAC */ |
| 5343 | } |
| 5344 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5345 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5346 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5347 | tempah = 0x08; |
| 5348 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5349 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5350 | if (pVBInfo->VBInfo & DisableCRT2Display) |
| 5351 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5352 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5353 | tempah = 0x00; |
| 5354 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5355 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5356 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
| 5357 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 5358 | goto reg_and_or; |
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 & XGI_SetCRT2ToLCDA) && |
| 5361 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
| 5362 | tempbl &= 0xf7; |
| 5363 | tempah |= 0x01; |
| 5364 | goto reg_and_or; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5365 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5366 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5367 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 5368 | tempbl &= 0xf7; |
| 5369 | tempah |= 0x01; |
| 5370 | } |
| 5371 | |
| 5372 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD))) |
| 5373 | goto reg_and_or; |
| 5374 | |
| 5375 | tempbl &= 0xf8; |
| 5376 | tempah = 0x01; |
| 5377 | |
| 5378 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 5379 | tempah |= 0x02; |
| 5380 | |
| 5381 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5382 | tempah = tempah ^ 0x05; |
| 5383 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5384 | tempah = tempah ^ 0x01; |
| 5385 | } |
| 5386 | |
| 5387 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5388 | tempah |= 0x08; |
| 5389 | |
| 5390 | reg_and_or: |
| 5391 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
| 5392 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5393 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5394 | | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5395 | tempah &= (~0x08); |
| 5396 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 5397 | & SetInSlaveMode))) { |
| 5398 | tempah |= 0x010; |
| 5399 | } |
| 5400 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5401 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5402 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5403 | tempah |= 0x020; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5404 | if (pVBInfo->VBInfo & DriverMode) |
| 5405 | tempah = tempah ^ 0x20; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5406 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5407 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5408 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5409 | tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5410 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5411 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 5412 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5413 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5414 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5415 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 5416 | tempah |= 0x40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5417 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5418 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5419 | if ((pVBInfo->LCDResInfo == Panel_1280x1024) |
| 5420 | || (pVBInfo->LCDResInfo == Panel_1280x1024x75)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5421 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5422 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5423 | if (pVBInfo->LCDResInfo == Panel_1280x960) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5424 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5425 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5426 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
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 | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5429 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5430 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5431 | tempah = 0; |
| 5432 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5433 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5434 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 5435 | tempbl = 0xff; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5436 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5437 | tempah |= 0x04; /* shampoo 0129 */ |
| 5438 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5439 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5440 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5441 | tempah = 0x00; |
| 5442 | tempbl = 0xcf; |
| 5443 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5444 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5445 | tempah |= 0x30; |
| 5446 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5447 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5448 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5449 | tempah = 0; |
| 5450 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5451 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5452 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5453 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5454 | tempah |= 0xc0; |
| 5455 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5456 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5457 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5458 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5459 | tempah = 0; |
| 5460 | tempbl = 0x7f; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5461 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5462 | tempbl = 0xff; |
| 5463 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5464 | tempah |= 0x80; |
| 5465 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5466 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5467 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5468 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5469 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5470 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5471 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 5472 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5473 | } |
| 5474 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5475 | } |
| 5476 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5477 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5478 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 5479 | struct vb_device_info *pVBInfo) |
| 5480 | { |
| 5481 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5482 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5483 | |
| 5484 | } |
| 5485 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5486 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 5487 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5488 | { |
| 5489 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5490 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5491 | |
| 5492 | } |
| 5493 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 5494 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5495 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5496 | unsigned short flag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5497 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5498 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 5499 | return 1; |
| 5500 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5501 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5502 | if ((flag == 1) || (flag == 2)) |
| 5503 | return 1; /* 301b */ |
| 5504 | else |
| 5505 | return 0; |
| 5506 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5507 | } |
| 5508 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5509 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 5510 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5511 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5512 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5513 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, |
| 5514 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, |
| 5515 | 0x01, 0x01 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5516 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5517 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5518 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5519 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5520 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5521 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5522 | index = index >> pVBInfo->SelectCRT2Rate; |
| 5523 | index &= 0x0F; |
| 5524 | |
| 5525 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 5526 | index = 0; |
| 5527 | |
| 5528 | if (index > 0) |
| 5529 | index--; |
| 5530 | |
| 5531 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5532 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5533 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5534 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 5535 | | VB_SIS301LV | VB_SIS302LV |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5536 | | VB_XGI301C)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5537 | /* 301b */ |
| 5538 | temp = LCDARefreshIndex[ |
| 5539 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5540 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5541 | temp = LCDRefreshIndex[ |
| 5542 | pVBInfo->LCDResInfo & 0x0F]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5543 | |
| 5544 | if (index > temp) |
| 5545 | index = temp; |
| 5546 | } else { |
| 5547 | index = 0; |
| 5548 | } |
| 5549 | } |
| 5550 | } |
| 5551 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5552 | RefreshRateTableIndex = XGI330_EModeIDTable[ModeIdIndex].REFindex; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5553 | ModeNo = XGI330_RefIndex[RefreshRateTableIndex].ModeID; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5554 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5555 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 5556 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5557 | index++; |
| 5558 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5559 | /* do the similar adjustment like XGISearchCRT1Rate() */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5560 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 5561 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5562 | index++; |
| 5563 | } |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5564 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 5565 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5566 | index++; |
| 5567 | } |
| 5568 | } |
| 5569 | |
| 5570 | i = 0; |
| 5571 | do { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5572 | if (XGI330_RefIndex[RefreshRateTableIndex + i]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5573 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5574 | break; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5575 | temp = XGI330_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5576 | temp &= ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5577 | if (temp < pVBInfo->ModeType) |
| 5578 | break; |
| 5579 | i++; |
| 5580 | index--; |
| 5581 | |
| 5582 | } while (index != 0xFFFF); |
| 5583 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5584 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5585 | temp = XGI330_RefIndex[RefreshRateTableIndex + i - 1]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5586 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5587 | if (temp & InterlaceMode) |
| 5588 | i++; |
| 5589 | } |
| 5590 | } |
| 5591 | i--; |
| 5592 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
| 5593 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, |
| 5594 | RefreshRateTableIndex, &i, pVBInfo); |
| 5595 | } |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 5596 | return RefreshRateTableIndex + i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5597 | } |
| 5598 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5599 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5600 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5601 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5602 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5603 | unsigned short RefreshRateTableIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5604 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5605 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5606 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5607 | ModeIdIndex, pVBInfo); |
| 5608 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5609 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5610 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5611 | HwDeviceExtension, pVBInfo); |
| 5612 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5613 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5614 | } |
| 5615 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5616 | static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5617 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5618 | struct vb_device_info *pVBInfo) |
| 5619 | { |
| 5620 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
| 5621 | |
| 5622 | tempbx = pVBInfo->VBInfo; |
| 5623 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5624 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 5625 | pVBInfo->SelectCRT2Rate = 4; |
| 5626 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5627 | ModeIdIndex, pVBInfo); |
| 5628 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
| 5629 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5630 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5631 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5632 | RefreshRateTableIndex, pVBInfo); |
| 5633 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5634 | RefreshRateTableIndex, pVBInfo); |
| 5635 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5636 | RefreshRateTableIndex, pVBInfo); |
| 5637 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5638 | HwDeviceExtension, pVBInfo); |
| 5639 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5640 | RefreshRateTableIndex, pVBInfo); |
| 5641 | XGI_SetTap4Regs(pVBInfo); |
| 5642 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); |
| 5643 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5644 | HwDeviceExtension, pVBInfo); |
| 5645 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5646 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); |
| 5647 | XGI_AutoThreshold(pVBInfo); |
| 5648 | return 1; |
| 5649 | } |
| 5650 | |
| 5651 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 5652 | { |
| 5653 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 5654 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 5655 | 0x05, 0x00 }; |
| 5656 | |
| 5657 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 5658 | |
| 5659 | unsigned char CR17, CR63, SR31; |
| 5660 | unsigned short temp; |
| 5661 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; |
| 5662 | |
| 5663 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5664 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5665 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5666 | /* to fix XG42 single LCD sense to CRT+LCD */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5667 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5668 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5669 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 5670 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5671 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 5672 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 5673 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5674 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5675 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 5676 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5677 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5678 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5679 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5680 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5681 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5682 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5683 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5684 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5685 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5686 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5687 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5688 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5689 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5690 | |
| 5691 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5692 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5693 | |
| 5694 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5695 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5696 | CRTCData[i]); |
| 5697 | |
| 5698 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5699 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5700 | CRTCData[i]); |
| 5701 | |
| 5702 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5703 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5704 | CRTCData[i]); |
| 5705 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5706 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5707 | & 0xE0)); |
| 5708 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5709 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 5710 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 5711 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5712 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5713 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5714 | |
| 5715 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5716 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
| 5717 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); |
| 5718 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5719 | } |
| 5720 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5721 | mdelay(1); |
| 5722 | |
| 5723 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5724 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5725 | |
| 5726 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5727 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5728 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5729 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5730 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5731 | /* avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5732 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5733 | |
| 5734 | for (i = 0; i < 256; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5735 | outb(0, (pVBInfo->P3c8 + 1)); |
| 5736 | outb(0, (pVBInfo->P3c8 + 1)); |
| 5737 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5738 | } |
| 5739 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5740 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 5741 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 5742 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5743 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5744 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5745 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5746 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5747 | } |
| 5748 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5749 | static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, |
| 5750 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5751 | struct vb_device_info *pVBInfo) |
| 5752 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 5753 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5754 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5755 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5756 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5757 | if (!(pVBInfo->SetFlag & DisableChA)) { |
| 5758 | if (pVBInfo->SetFlag & EnableChA) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5759 | /* Power on */ |
| 5760 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 5761 | } else if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 5762 | /* Power on */ |
| 5763 | xgifb_reg_set(pVBInfo->Part1Port, |
| 5764 | 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5765 | } |
| 5766 | } |
| 5767 | |
| 5768 | if (!(pVBInfo->SetFlag & DisableChB)) { |
| 5769 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo |
| 5770 | & (SetCRT2ToLCD | SetCRT2ToTV |
| 5771 | | SetCRT2ToRAMDAC))) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5772 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5773 | pVBInfo->P3c4, 0x32); |
| 5774 | tempah &= 0xDF; |
| 5775 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5776 | if (!(pVBInfo->VBInfo & |
| 5777 | SetCRT2ToRAMDAC)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5778 | tempah |= 0x20; |
| 5779 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5780 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5781 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5782 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5783 | tempah = (unsigned char) xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5784 | pVBInfo->Part1Port, 0x2E); |
| 5785 | |
| 5786 | if (!(tempah & 0x80)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5787 | xgifb_reg_or(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5788 | 0x2E, 0x80); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5789 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5790 | } |
| 5791 | } |
| 5792 | |
| 5793 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
| 5794 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5795 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5796 | 0x20); /* shampoo 0129 */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5797 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5798 | if (!XGI_DisableChISLCD(pVBInfo)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5799 | if (XGI_EnableChISLCD(pVBInfo) || |
| 5800 | (pVBInfo->VBInfo & |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5801 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5802 | /* LVDS PLL power on */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5803 | xgifb_reg_and( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5804 | pVBInfo->Part4Port, |
| 5805 | 0x2A, |
| 5806 | 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5807 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5808 | /* LVDS Driver power on */ |
| 5809 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5810 | } |
| 5811 | } |
| 5812 | |
| 5813 | tempah = 0x00; |
| 5814 | |
| 5815 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5816 | tempah = 0xc0; |
| 5817 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5818 | if (!(pVBInfo->VBInfo & SetSimuScanMode) && |
| 5819 | (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 5820 | (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { |
| 5821 | tempah = tempah & 0x40; |
| 5822 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
| 5823 | tempah = tempah ^ 0xC0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5824 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5825 | if (pVBInfo->SetFlag & DisableChB) |
| 5826 | tempah &= 0xBF; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5827 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5828 | if (pVBInfo->SetFlag & DisableChA) |
| 5829 | tempah &= 0x7F; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5830 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5831 | if (pVBInfo->SetFlag & EnableChB) |
| 5832 | tempah |= 0x40; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5833 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5834 | if (pVBInfo->SetFlag & EnableChA) |
| 5835 | tempah |= 0x80; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5836 | } |
| 5837 | } |
| 5838 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5839 | /* EnablePart4_1F */ |
| 5840 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5841 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5842 | if (!(pVBInfo->SetFlag & DisableChA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5843 | if (!(pVBInfo->SetFlag & GatingCRT)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5844 | XGI_DisableGatingCRT(HwDeviceExtension, |
| 5845 | pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5846 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, |
| 5847 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5848 | } |
| 5849 | } |
| 5850 | } /* 301 */ |
| 5851 | else { /* LVDS */ |
| 5852 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5853 | | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5854 | /* enable CRT2 */ |
| 5855 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5856 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5857 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5858 | 0x2E); |
| 5859 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5860 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5861 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5862 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5863 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5864 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5865 | } |
| 5866 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5867 | static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, |
| 5868 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5869 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5870 | struct vb_device_info *pVBInfo) |
| 5871 | { |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5872 | unsigned short RefreshRateTableIndex, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5873 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5874 | XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 5875 | outb(XGI330_StandTable.MISC, pVBInfo->P3c2); |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5876 | XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo); |
| 5877 | XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo); |
| 5878 | XGI_SetGRCRegs(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5879 | XGI_ClearExt1Regs(pVBInfo); |
| 5880 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5881 | if (HwDeviceExtension->jChipType == XG27) { |
| 5882 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 5883 | XGI_SetDefaultVCLK(pVBInfo); |
| 5884 | } |
| 5885 | |
| 5886 | temp = ~ProgrammingCRT2; |
| 5887 | pVBInfo->SetFlag &= temp; |
| 5888 | pVBInfo->SelectCRT2Rate = 0; |
| 5889 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5890 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5891 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5892 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5893 | | SetInSlaveMode)) { |
| 5894 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5895 | } |
| 5896 | } |
| 5897 | |
| 5898 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5899 | ModeIdIndex, pVBInfo); |
| 5900 | if (RefreshRateTableIndex != 0xFFFF) { |
| 5901 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
| 5902 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5903 | pVBInfo, HwDeviceExtension); |
| 5904 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 5905 | RefreshRateTableIndex, pVBInfo); |
| 5906 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5907 | HwDeviceExtension, pVBInfo); |
| 5908 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5909 | RefreshRateTableIndex, pVBInfo); |
| 5910 | } |
| 5911 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5912 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5913 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5914 | if (temp & 0xA0) { |
| 5915 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5916 | if (HwDeviceExtension->jChipType == XG27) |
| 5917 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, |
| 5918 | RefreshRateTableIndex, pVBInfo); |
| 5919 | else |
| 5920 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, |
| 5921 | RefreshRateTableIndex, pVBInfo); |
| 5922 | |
| 5923 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 5924 | RefreshRateTableIndex); |
| 5925 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 5926 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
| 5927 | pVBInfo, RefreshRateTableIndex, ModeNo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5928 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5929 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5930 | xgifb_set_lvds(xgifb_info, |
| 5931 | HwDeviceExtension->jChipType, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5932 | ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5933 | } |
| 5934 | } |
| 5935 | |
| 5936 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
| 5937 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); |
| 5938 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 5939 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5940 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5941 | } |
| 5942 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5943 | unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, |
| 5944 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5945 | unsigned short ModeNo) |
| 5946 | { |
| 5947 | unsigned short ModeIdIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5948 | struct vb_device_info VBINF; |
| 5949 | struct vb_device_info *pVBInfo = &VBINF; |
Dmitry Eremin-Solenikov | 9a801f2 | 2012-03-19 21:50:13 +0400 | [diff] [blame] | 5950 | pVBInfo->BaseAddr = xgifb_info->vga_base; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5951 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5952 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5953 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5954 | pVBInfo->IF_DEF_YPbPr = 0; |
| 5955 | pVBInfo->IF_DEF_HiVision = 0; |
| 5956 | pVBInfo->IF_DEF_CRT2Monitor = 0; |
| 5957 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5958 | } else { |
| 5959 | pVBInfo->IF_DEF_YPbPr = 1; |
| 5960 | pVBInfo->IF_DEF_HiVision = 1; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 5961 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5962 | } |
| 5963 | |
| 5964 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; |
| 5965 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; |
| 5966 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; |
| 5967 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; |
| 5968 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; |
| 5969 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; |
| 5970 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; |
| 5971 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; |
| 5972 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; |
| 5973 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; |
| 5974 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; |
| 5975 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; |
| 5976 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5977 | pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04; |
| 5978 | pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10; |
| 5979 | pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12; |
| 5980 | pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14; |
| 5981 | pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5982 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5983 | /* for x86 Linux, XG21 LVDS */ |
| 5984 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5985 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5986 | pVBInfo->IF_DEF_LVDS = 1; |
| 5987 | } |
| 5988 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5989 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 5990 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5991 | pVBInfo->IF_DEF_LVDS = 1; |
| 5992 | } |
| 5993 | } |
| 5994 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5995 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5996 | XGI_GetVBType(pVBInfo); |
| 5997 | |
| 5998 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
Aaro Koskinen | ef497f4 | 2011-11-27 23:03:21 +0200 | [diff] [blame] | 5999 | if (ModeNo & 0x80) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6000 | ModeNo = ModeNo & 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 6001 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6002 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6003 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6004 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
| 6005 | |
| 6006 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 6007 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 6008 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6009 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 6010 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 6011 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6012 | XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6013 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6014 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6015 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6016 | ModeIdIndex, pVBInfo); |
| 6017 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 6018 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6019 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 6020 | HwDeviceExtension, pVBInfo); |
| 6021 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 6022 | } else if (!(pVBInfo->VBInfo & SwitchCRT2)) { |
| 6023 | XGI_SetCRT1Group(xgifb_info, |
| 6024 | HwDeviceExtension, ModeNo, |
| 6025 | ModeIdIndex, pVBInfo); |
| 6026 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 6027 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 6028 | HwDeviceExtension, |
| 6029 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6030 | } |
| 6031 | } |
| 6032 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6033 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6034 | switch (HwDeviceExtension->ujVBChipID) { |
| 6035 | case VB_CHIP_301: |
| 6036 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 6037 | pVBInfo); /*add for CRT2 */ |
| 6038 | break; |
| 6039 | |
| 6040 | case VB_CHIP_302: |
| 6041 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 6042 | pVBInfo); /*add for CRT2 */ |
| 6043 | break; |
| 6044 | |
| 6045 | default: |
| 6046 | break; |
| 6047 | } |
| 6048 | } |
| 6049 | |
| 6050 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
| 6051 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6052 | XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6053 | } /* !XG20 */ |
| 6054 | else { |
| 6055 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6056 | if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 6057 | ModeIdIndex, |
| 6058 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6059 | return 0; |
| 6060 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 6061 | pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex]. |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 6062 | Ext_ModeFlag & ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6063 | |
| 6064 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 6065 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6066 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6067 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6068 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6069 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
| 6070 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6071 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 6072 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6073 | } |
| 6074 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6075 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
| 6076 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 6077 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6078 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 6079 | |
| 6080 | return 1; |
| 6081 | } |