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" |
Aaro Koskinen | 56810a9 | 2013-01-21 02:57:47 +0200 | [diff] [blame] | 5 | #include "vb_init.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6 | #include "vb_util.h" |
| 7 | #include "vb_table.h" |
Miguel Gómez | e054102 | 2012-06-18 13:12:05 +0200 | [diff] [blame] | 8 | #include "vb_setmode.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 9 | |
| 10 | #define IndexMask 0xff |
Peter Huewe | 9507259 | 2012-06-14 00:21:48 +0200 | [diff] [blame] | 11 | #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 12 | |
Aaro Koskinen | 624554d | 2011-10-11 21:47:35 +0300 | [diff] [blame] | 13 | static const unsigned short XGINew_VGA_DAC[] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 14 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
| 15 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, |
| 16 | 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18, |
| 17 | 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F, |
| 18 | 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F, |
| 19 | 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00, |
| 20 | 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18, |
| 21 | 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04, |
| 22 | 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10, |
| 23 | 0x0B, 0x0C, 0x0D, 0x0F, 0x10}; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 24 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 25 | void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 26 | { |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 27 | pVBInfo->MCLKData = XGI340New_MCLKData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 28 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 29 | pVBInfo->LCDResInfo = 0; |
| 30 | pVBInfo->LCDTypeInfo = 0; |
| 31 | pVBInfo->LCDInfo = 0; |
| 32 | pVBInfo->VBInfo = 0; |
| 33 | pVBInfo->TVInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 34 | |
Aaro Koskinen | 597d96b | 2013-03-27 23:53:15 +0200 | [diff] [blame] | 35 | pVBInfo->SR18 = XGI340_SR18; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 36 | pVBInfo->CR40 = XGI340_cr41; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 37 | |
Aaro Koskinen | ce76de5 | 2013-05-29 23:59:02 +0300 | [diff] [blame] | 38 | if (ChipType < XG20) |
| 39 | XGI_GetVBType(pVBInfo); |
| 40 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 41 | /* 310 customization related */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 42 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 43 | pVBInfo->LCDCapList = XGI_LCDDLCapList; |
| 44 | else |
| 45 | pVBInfo->LCDCapList = XGI_LCDCapList; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 46 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 47 | if (ChipType >= XG20) |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 48 | pVBInfo->XGINew_CR97 = 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 49 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 50 | if (ChipType == XG27) { |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 51 | unsigned char temp; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 52 | pVBInfo->MCLKData = XGI27New_MCLKData; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 53 | pVBInfo->CR40 = XGI27_cr41; |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 54 | pVBInfo->XGINew_CR97 = 0xc1; |
Aaro Koskinen | 597d96b | 2013-03-27 23:53:15 +0200 | [diff] [blame] | 55 | pVBInfo->SR18 = XG27_SR18; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 56 | |
Dmitry Eremin-Solenikov | 6490311 | 2012-03-19 21:50:09 +0400 | [diff] [blame] | 57 | /*Z11m DDR*/ |
| 58 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B); |
| 59 | /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */ |
| 60 | if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08)) |
Peter Huewe | 6d12dae | 2012-06-14 00:21:52 +0200 | [diff] [blame] | 61 | pVBInfo->XGINew_CR97 = 0x80; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 62 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 63 | |
| 64 | } |
| 65 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 66 | static void XGI_SetSeqRegs(unsigned short ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 67 | unsigned short ModeIdIndex, |
| 68 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 69 | { |
Peter Huewe | 76a5899 | 2013-02-03 22:54:34 +0100 | [diff] [blame] | 70 | unsigned char SRdata, i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 71 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 72 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 73 | |
Peter Huewe | 76a5899 | 2013-02-03 22:54:34 +0100 | [diff] [blame] | 74 | for (i = 0; i < 4; i++) { |
| 75 | /* Get SR1,2,3,4 from file */ |
| 76 | /* SR1 is with screen off 0x20 */ |
| 77 | SRdata = XGI330_StandTable.SR[i]; |
| 78 | xgifb_reg_set(pVBInfo->P3c4, i+1, SRdata); /* Set SR 1 2 3 4 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 79 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 80 | } |
| 81 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 82 | static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 83 | struct vb_device_info *pVBInfo) |
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 | unsigned char CRTCdata; |
| 86 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 87 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 88 | CRTCdata = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 89 | CRTCdata &= 0x7f; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 90 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 91 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 92 | for (i = 0; i <= 0x18; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 93 | /* Get CRTC from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 94 | CRTCdata = XGI330_StandTable.CRTC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 95 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 96 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 97 | } |
| 98 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 99 | static void XGI_SetATTRegs(unsigned short ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 100 | unsigned short ModeIdIndex, |
| 101 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 102 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 103 | unsigned char ARdata; |
| 104 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 105 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 106 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 107 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 108 | for (i = 0; i <= 0x13; i++) { |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 109 | ARdata = XGI330_StandTable.ATTR[i]; |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 110 | |
| 111 | if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */ |
| 112 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 113 | ARdata = 0; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 114 | } else if ((pVBInfo->VBInfo & |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 115 | (SetCRT2ToTV | SetCRT2ToLCD)) && |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 116 | (pVBInfo->VBInfo & SetInSlaveMode)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 117 | ARdata = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 118 | } |
| 119 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 120 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 121 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 122 | outb(i, pVBInfo->P3c0); /* set index */ |
| 123 | outb(ARdata, pVBInfo->P3c0); /* set data */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 124 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 125 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 126 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 127 | outb(0x14, pVBInfo->P3c0); /* set index */ |
| 128 | outb(0x00, pVBInfo->P3c0); /* set data */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 129 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 130 | outb(0x20, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 131 | } |
| 132 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 133 | static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 134 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 135 | unsigned char GRdata; |
| 136 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 137 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 138 | for (i = 0; i <= 0x08; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 139 | /* Get GR from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 140 | GRdata = XGI330_StandTable.GRC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 141 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 142 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 143 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 144 | if (pVBInfo->ModeType > ModeVGA) { |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 145 | GRdata = xgifb_reg_get(pVBInfo->P3ce, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 146 | GRdata &= 0xBF; /* 256 color disable */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 147 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 148 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 149 | } |
| 150 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 151 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 152 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 153 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 154 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 155 | for (i = 0x0A; i <= 0x0E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 156 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 157 | } |
| 158 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 159 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 160 | { |
| 161 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 162 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 163 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[0].SR2B); |
| 164 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[0].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 165 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 166 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 167 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[1].SR2B); |
| 168 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[1].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 169 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 170 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 171 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 172 | } |
| 173 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 174 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 175 | unsigned short ModeIdIndex, |
| 176 | unsigned short RefreshRateTableIndex, unsigned short *i, |
| 177 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 178 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 179 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 180 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 181 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 182 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 183 | tempbx = XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 184 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 185 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame^] | 186 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 187 | tempax |= SupportRAMDAC2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 188 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame^] | 189 | if (pVBInfo->VBType & VB_XGI301C) |
| 190 | tempax |= SupportCRT2in301C; |
| 191 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 192 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame^] | 193 | /* 301b */ |
| 194 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 195 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 196 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame^] | 197 | if (pVBInfo->LCDResInfo != Panel_1280x1024 && |
| 198 | pVBInfo->LCDResInfo != Panel_1280x960 && |
| 199 | (pVBInfo->LCDInfo & LCDNonExpanding) && |
| 200 | resinfo >= 9) |
| 201 | return 0; |
| 202 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 203 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame^] | 204 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */ |
| 205 | tempax |= SupportHiVision; |
| 206 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 207 | ((resinfo == 4) || |
| 208 | (resinfo == 3 && (pVBInfo->SetFlag & TVSimuMode)) || |
| 209 | (resinfo > 7))) |
| 210 | return 0; |
| 211 | } else if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | |
| 212 | SetCRT2ToSCART | SetCRT2ToYPbPr525750 | |
| 213 | SetCRT2ToHiVision)) { |
| 214 | tempax |= SupportTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 215 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame^] | 216 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | |
| 217 | VB_SIS302LV | VB_XGI301C)) |
| 218 | tempax |= SupportTV1024; |
| 219 | |
| 220 | if (!(pVBInfo->VBInfo & TVSetPAL) && |
| 221 | (modeflag & NoSupportSimuTV) && |
| 222 | (pVBInfo->VBInfo & SetInSlaveMode) && |
| 223 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
| 224 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 225 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 226 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 227 | for (; XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 228 | tempbx; (*i)--) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 229 | infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 230 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 231 | if (infoflag & tempax) |
| 232 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 233 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 234 | if ((*i) == 0) |
| 235 | break; |
| 236 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 237 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 238 | for ((*i) = 0;; (*i)++) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 239 | infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 240 | Ext_InfoFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 241 | if (XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 242 | != tempbx) { |
| 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | if (infoflag & tempax) |
| 247 | return 1; |
| 248 | } |
| 249 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 250 | } |
| 251 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 252 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 253 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 254 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 255 | unsigned short sync, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 256 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 257 | /* di+0x00 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 258 | sync = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 259 | sync &= 0xC0; |
| 260 | temp = 0x2F; |
| 261 | temp |= sync; |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 262 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 263 | } |
| 264 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 265 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 266 | struct xgi_hw_device_info *HwDeviceExtension) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 267 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 268 | unsigned char data, data1, pushax; |
| 269 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 270 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 271 | /* unlock cr0-7 */ |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 272 | data = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 273 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 274 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 275 | |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 276 | data = pVBInfo->TimingH.data[0]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 277 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 278 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 279 | for (i = 0x01; i <= 0x04; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 280 | data = pVBInfo->TimingH.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 281 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 282 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 283 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 284 | for (i = 0x05; i <= 0x06; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 285 | data = pVBInfo->TimingH.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 286 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 287 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 288 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 289 | j = xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 290 | j &= 0x1F; |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 291 | data = pVBInfo->TimingH.data[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 292 | data &= 0xE0; |
| 293 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 294 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 295 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 296 | if (HwDeviceExtension->jChipType >= XG20) { |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 297 | data = xgifb_reg_get(pVBInfo->P3d4, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 298 | data = data - 1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 299 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 300 | data = xgifb_reg_get(pVBInfo->P3d4, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 301 | data1 = data; |
| 302 | data1 &= 0xE0; |
| 303 | data &= 0x1F; |
| 304 | if (data == 0) { |
| 305 | pushax = data; |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 306 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0c); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 307 | data &= 0xFB; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 308 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 309 | data = pushax; |
| 310 | } |
| 311 | data = data - 1; |
| 312 | data |= data1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 313 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 314 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 315 | data = data >> 5; |
| 316 | data = data + 3; |
| 317 | if (data > 7) |
| 318 | data = data - 7; |
| 319 | data = data << 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 320 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 321 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 322 | } |
| 323 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 324 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
| 325 | unsigned short ModeNo, |
| 326 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 327 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 328 | unsigned char data; |
| 329 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 330 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 331 | for (i = 0x00; i <= 0x01; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 332 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 333 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 334 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 335 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 336 | for (i = 0x02; i <= 0x03; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 337 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 338 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 339 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 340 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 341 | for (i = 0x04; i <= 0x05; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 342 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 343 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 344 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 345 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 346 | j = xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 347 | j &= 0xC0; |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 348 | data = pVBInfo->TimingV.data[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 349 | data &= 0x3F; |
| 350 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 351 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 352 | |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 353 | data = pVBInfo->TimingV.data[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 354 | data &= 0x80; |
| 355 | data = data >> 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 356 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 357 | i = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 358 | i &= DoubleScanMode; |
| 359 | if (i) |
| 360 | data |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 361 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 362 | j = xgifb_reg_get(pVBInfo->P3d4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 363 | j &= 0x5F; |
| 364 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 365 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 366 | } |
| 367 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 368 | static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
| 369 | unsigned short RefreshRateTableIndex, |
| 370 | struct vb_device_info *pVBInfo, |
| 371 | struct xgi_hw_device_info *HwDeviceExtension) |
| 372 | { |
| 373 | unsigned char index, data; |
| 374 | unsigned short i; |
| 375 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 376 | /* Get index */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 377 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 378 | index = index & IndexMask; |
| 379 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 380 | data = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 381 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 382 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 383 | |
| 384 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 385 | pVBInfo->TimingH.data[i] |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 386 | = XGI_CRT1Table[index].CR[i]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 387 | |
| 388 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 389 | pVBInfo->TimingV.data[i] |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 390 | = XGI_CRT1Table[index].CR[i + 8]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 391 | |
| 392 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 393 | |
| 394 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
| 395 | |
| 396 | if (pVBInfo->ModeType > 0x03) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 397 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 398 | } |
| 399 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 400 | /* --------------------------------------------------------------------- */ |
| 401 | /* Function : XGI_SetXG21CRTC */ |
| 402 | /* Input : Stand or enhance CRTC table */ |
| 403 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ |
| 404 | /* Description : Set LCD timing */ |
| 405 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 406 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 407 | unsigned short RefreshRateTableIndex, |
| 408 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 409 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 410 | unsigned char index, Tempax, Tempbx, Tempcx, Tempdx; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 411 | unsigned short Temp1, Temp2, Temp3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 412 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 413 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 414 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 415 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 416 | Tempcx = Tempax; /* Tempcx: HRS */ |
| 417 | /* SR2E[7:0]->HRS */ |
| 418 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 419 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 420 | Tempdx = XGI_CRT1Table[index].CR[5]; /* SRB */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 421 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ |
| 422 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ |
| 423 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ |
| 424 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 425 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 426 | Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 427 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 428 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 429 | Tempbx = XGI_CRT1Table[index].CR[6]; /* SRC */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 430 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ |
| 431 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ |
| 432 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 433 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 434 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
| 435 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 436 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 437 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
| 438 | if (Tempax < Tempcx) /* HRE < HRS */ |
| 439 | Temp2 |= 0x40; /* Temp2 + 0x40 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 440 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 441 | Temp2 &= 0xFF; |
| 442 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ |
| 443 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ |
| 444 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ |
| 445 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ |
| 446 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
| 447 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 448 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 449 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 450 | /* CR10 VRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 451 | Tempax = XGI_CRT1Table[index].CR[10]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 452 | Tempbx = Tempax; /* Tempbx: VRS */ |
| 453 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ |
| 454 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
| 455 | /* CR7[2][7] VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 456 | Tempax = XGI_CRT1Table[index].CR[9]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 457 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
| 458 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ |
| 459 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ |
| 460 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ |
| 461 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 462 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 463 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
| 464 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ |
| 465 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 466 | Tempax &= 0x80; |
| 467 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 468 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
| 469 | /* Tempax: SRA */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 470 | Tempax = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 471 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
| 472 | Temp2 = Tempax; |
| 473 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ |
| 474 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 475 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 476 | /* Tempax: CR11 VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 477 | Tempax = XGI_CRT1Table[index].CR[11]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 478 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 479 | /* Tempbx: SRA */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 480 | Tempbx = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 481 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
| 482 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 483 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 484 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ |
| 485 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 486 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 487 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
| 488 | if (Tempax < Temp3) /* VRE < VRS */ |
| 489 | Temp2 |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 490 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 491 | Temp2 &= 0xFF; |
| 492 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ |
| 493 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ |
| 494 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 495 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ |
| 496 | Tempbx = (unsigned char) Temp1; |
| 497 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ |
| 498 | Tempax &= 0x7F; |
| 499 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 500 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 501 | } |
| 502 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 503 | static void XGI_SetXG27CRTC(unsigned short ModeNo, |
| 504 | unsigned short ModeIdIndex, |
| 505 | unsigned short RefreshRateTableIndex, |
| 506 | struct vb_device_info *pVBInfo) |
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 | unsigned short index, Tempax, Tempbx, Tempcx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 509 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 510 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 511 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 512 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 513 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
| 514 | /* SR2E[7:0]->HRS */ |
| 515 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 516 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 517 | /* SR0B */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 518 | Tempax = XGI_CRT1Table[index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 519 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 520 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 521 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 522 | Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 523 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
| 524 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 525 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 526 | Tempax = XGI_CRT1Table[index].CR[6]; /* SRC */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 527 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ |
| 528 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ |
| 529 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 530 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 531 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
| 532 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 533 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 534 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 535 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 536 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
| 537 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ |
| 538 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 539 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 540 | Tempax = XGI_CRT1Table[index].CR[5]; /* SR0B */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 541 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 542 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ |
| 543 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ |
| 544 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
| 545 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 546 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 547 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 548 | /* CR10 VRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 549 | Tempax = XGI_CRT1Table[index].CR[10]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 550 | /* SR34[7:0]->VRS[7:0] */ |
| 551 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 552 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 553 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
| 554 | /* CR7[7][2] VRS[9][8] */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 555 | Tempax = XGI_CRT1Table[index].CR[9]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 556 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
| 557 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ |
| 558 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ |
| 559 | /* SR35[0]: VRS[8] */ |
| 560 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
| 561 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
| 562 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ |
| 563 | /* Tempax: SR0A */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 564 | Tempax = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 565 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
| 566 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 567 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 568 | /* Tempax: CR11 VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 569 | Tempax = XGI_CRT1Table[index].CR[11]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 570 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 571 | /* Tempbx: SR0A */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 572 | Tempbx = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 573 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
| 574 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 575 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 576 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ |
| 577 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ |
| 578 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ |
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 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
| 581 | Tempbx |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 582 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 583 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
| 584 | Tempax = (Tempbx << 2) & 0xFF; |
| 585 | /* SR3F[7:2]:VRE[5:0] */ |
| 586 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
| 587 | Tempax = Tempcx >> 8; |
| 588 | /* SR35[2:0]:VRS[10:8] */ |
| 589 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 590 | } |
| 591 | |
Aaro Koskinen | a2d08cf | 2011-11-27 23:03:08 +0200 | [diff] [blame] | 592 | static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
| 593 | { |
| 594 | unsigned char temp; |
| 595 | |
| 596 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 597 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 598 | temp = (temp & 3) << 6; |
| 599 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 600 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 601 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 602 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 603 | |
| 604 | } |
| 605 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 606 | static void xgifb_set_lcd(int chip_id, |
| 607 | struct vb_device_info *pVBInfo, |
| 608 | unsigned short RefreshRateTableIndex, |
| 609 | unsigned short ModeNo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 610 | { |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 611 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 612 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 613 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 614 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 615 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 616 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 617 | |
| 618 | if (chip_id == XG27) { |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 619 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 620 | if ((temp & 0x03) == 0) { /* dual 12 */ |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 621 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 622 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
| 623 | } |
| 624 | } |
| 625 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 626 | if (chip_id == XG27) { |
| 627 | XGI_SetXG27FPBits(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 628 | } else { |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 629 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 630 | if (temp & 0x01) { |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 631 | /* 18 bits FP */ |
| 632 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); |
| 633 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
| 634 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 635 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 636 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 637 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 638 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 639 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 640 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 641 | |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 642 | temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 643 | if (temp & 0x4000) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 644 | /* Hsync polarity */ |
| 645 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 646 | if (temp & 0x8000) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 647 | /* Vsync polarity */ |
| 648 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | /* --------------------------------------------------------------------- */ |
| 652 | /* Function : XGI_UpdateXG21CRTC */ |
| 653 | /* Input : */ |
| 654 | /* Output : CRT1 CRTC */ |
| 655 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 656 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 657 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 658 | struct vb_device_info *pVBInfo, |
| 659 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 660 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 661 | int index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 662 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 663 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 664 | if (ModeNo == 0x2E && |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 665 | (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 666 | RES640x480x60)) |
| 667 | index = 12; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 668 | else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 669 | Ext_CRT1CRTC == RES640x480x72)) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 670 | index = 13; |
| 671 | else if (ModeNo == 0x2F) |
| 672 | index = 14; |
| 673 | else if (ModeNo == 0x50) |
| 674 | index = 15; |
| 675 | else if (ModeNo == 0x59) |
| 676 | index = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 677 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 678 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 679 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 680 | XGI_UpdateCRT1Table[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 681 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 682 | XGI_UpdateCRT1Table[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 683 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 684 | XGI_UpdateCRT1Table[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 685 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 686 | XGI_UpdateCRT1Table[index].CR16); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 687 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 688 | } |
| 689 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 690 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 691 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 692 | unsigned short RefreshRateTableIndex, |
| 693 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 694 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 695 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 696 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 697 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 698 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 699 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 700 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 701 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 702 | tempax = XGI330_ModeResInfo[resindex].HTotal; |
| 703 | tempbx = XGI330_ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 704 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 705 | if (modeflag & HalfDCLK) |
| 706 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 707 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 708 | if (modeflag & HalfDCLK) |
| 709 | tempax = tempax << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 710 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 711 | temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 712 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 713 | if (temp & InterlaceMode) |
| 714 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 715 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 716 | if (modeflag & DoubleScanMode) |
| 717 | tempbx = tempbx << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 718 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 719 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 720 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 721 | tempax /= tempcx; |
| 722 | tempax -= 1; |
| 723 | tempbx -= 1; |
| 724 | tempcx = tempax; |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 725 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 726 | data = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 727 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 728 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 729 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 730 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 731 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 732 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 733 | tempax = 0; |
| 734 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 735 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 736 | if (tempbx & 0x01) |
| 737 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 738 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 739 | if (tempbx & 0x02) |
| 740 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 741 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 742 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 743 | data = xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 744 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 745 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 746 | if (tempbx & 0x04) |
| 747 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 748 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 749 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 750 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 751 | } |
| 752 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 753 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 754 | unsigned short ModeIdIndex, |
| 755 | unsigned short RefreshRateTableIndex, |
| 756 | struct xgi_hw_device_info *HwDeviceExtension, |
| 757 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 758 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 759 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 760 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 761 | /* GetOffset */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 762 | temp = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 763 | temp = temp >> 8; |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame] | 764 | temp = XGI330_ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 765 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 766 | temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 767 | temp2 &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 768 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 769 | if (temp2) |
| 770 | temp = temp << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 771 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 772 | temp2 = pVBInfo->ModeType - ModeEGA; |
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 | switch (temp2) { |
| 775 | case 0: |
| 776 | temp2 = 1; |
| 777 | break; |
| 778 | case 1: |
| 779 | temp2 = 2; |
| 780 | break; |
| 781 | case 2: |
| 782 | temp2 = 4; |
| 783 | break; |
| 784 | case 3: |
| 785 | temp2 = 4; |
| 786 | break; |
| 787 | case 4: |
| 788 | temp2 = 6; |
| 789 | break; |
| 790 | case 5: |
| 791 | temp2 = 8; |
| 792 | break; |
| 793 | default: |
| 794 | break; |
| 795 | } |
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 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 798 | temp = temp * temp2 + temp2 / 2; |
| 799 | else |
| 800 | temp *= temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 801 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 802 | /* SetOffset */ |
| 803 | DisplayUnit = temp; |
| 804 | temp2 = temp; |
| 805 | temp = temp >> 8; /* ah */ |
| 806 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 807 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 808 | i &= 0xF0; |
| 809 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 810 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 811 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 812 | temp = (unsigned char) temp2; |
| 813 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 814 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 815 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 816 | /* SetDisplayUnit */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 817 | temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 818 | temp2 &= InterlaceMode; |
| 819 | if (temp2) |
| 820 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 821 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 822 | DisplayUnit = DisplayUnit << 5; |
| 823 | ah = (DisplayUnit & 0xff00) >> 8; |
| 824 | al = DisplayUnit & 0x00ff; |
| 825 | if (al == 0) |
| 826 | ah += 1; |
| 827 | else |
| 828 | ah += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 829 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 830 | if (HwDeviceExtension->jChipType >= XG20) |
| 831 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 832 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 833 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 834 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 835 | } |
| 836 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 837 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
| 838 | unsigned short ModeIdIndex, |
| 839 | unsigned short RefreshRateTableIndex, |
| 840 | struct xgi_hw_device_info *HwDeviceExtension, |
| 841 | struct vb_device_info *pVBInfo) |
| 842 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 843 | unsigned short VCLKIndex, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 844 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 845 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 846 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 847 | |
Aaro Koskinen | 7ac54d0 | 2013-02-09 00:03:43 +0200 | [diff] [blame] | 848 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ |
| 849 | if (pVBInfo->LCDResInfo != Panel_1024x768) |
| 850 | /* LCDXlat2VCLK */ |
| 851 | VCLKIndex = VCLK108_2_315 + 5; |
| 852 | else |
| 853 | VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */ |
| 854 | } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
| 855 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
| 856 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2; |
| 857 | else |
| 858 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 859 | |
Aaro Koskinen | 7ac54d0 | 2013-02-09 00:03:43 +0200 | [diff] [blame] | 860 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 861 | if (modeflag & Charx8Dot) { |
| 862 | VCLKIndex = TVCLKBASE_315_25 + HiTVSimuVCLK; |
| 863 | } else { |
| 864 | VCLKIndex = TVCLKBASE_315_25 + HiTVTextVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 865 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 866 | } |
Aaro Koskinen | 7ac54d0 | 2013-02-09 00:03:43 +0200 | [diff] [blame] | 867 | |
| 868 | /* 301lv */ |
| 869 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 870 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
| 871 | VCLKIndex = YPbPr525iVCLK_2; |
| 872 | else |
| 873 | VCLKIndex = YPbPr525iVCLK; |
| 874 | } |
| 875 | } else if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 876 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
| 877 | VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2; |
| 878 | else |
| 879 | VCLKIndex = TVCLKBASE_315_25 + TVVCLK; |
| 880 | } else { /* for CRT2 */ |
| 881 | /* di+Ext_CRTVCLK */ |
| 882 | VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 883 | VCLKIndex &= IndexMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 884 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 885 | |
| 886 | return VCLKIndex; |
| 887 | } |
| 888 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 889 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
| 890 | unsigned short ModeIdIndex, |
| 891 | struct xgi_hw_device_info *HwDeviceExtension, |
| 892 | unsigned short RefreshRateTableIndex, |
| 893 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 894 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 895 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 896 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 897 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 898 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 899 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 900 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 901 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 902 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B); |
| 903 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 904 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 905 | } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 906 | | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 907 | & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 908 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, |
| 909 | RefreshRateTableIndex, HwDeviceExtension, |
| 910 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 911 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 912 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 913 | data = XGI_VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 914 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 915 | data = XGI_VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 916 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 917 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 918 | } else { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 919 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 920 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 921 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 922 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B); |
| 923 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 924 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 925 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 926 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 927 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 928 | if (XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 929 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 930 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 931 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 932 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 933 | index = data; |
| 934 | index &= 0xE0; |
| 935 | data &= 0x1F; |
| 936 | data = data << 1; |
| 937 | data += 1; |
| 938 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 939 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 940 | } |
| 941 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 942 | } |
| 943 | |
Aaro Koskinen | e85f203 | 2011-11-27 23:03:07 +0200 | [diff] [blame] | 944 | static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
| 945 | { |
| 946 | unsigned char temp; |
| 947 | |
| 948 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
| 949 | temp = (temp & 1) << 6; |
| 950 | /* SR06[6] 18bit Dither */ |
| 951 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 952 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 953 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 954 | |
| 955 | } |
| 956 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 957 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 958 | struct xgi_hw_device_info *HwDeviceExtension, |
| 959 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 960 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 961 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 962 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 963 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 964 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 965 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 966 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 967 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
| 968 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
| 969 | data &= 0xC0; |
| 970 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
| 971 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
| 972 | data |= 0x01; |
| 973 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 974 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 975 | if (HwDeviceExtension->jChipType == XG21) |
| 976 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 977 | } |
| 978 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 979 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
| 980 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, |
| 981 | struct vb_device_info *pVBInfo) |
| 982 | { |
| 983 | unsigned short data, data2 = 0; |
| 984 | short VCLK; |
| 985 | |
| 986 | unsigned char index; |
| 987 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 988 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 989 | index &= IndexMask; |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 990 | VCLK = XGI_VCLKData[index].CLOCK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 991 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 992 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 993 | data &= 0xf3; |
| 994 | if (VCLK >= 200) |
| 995 | data |= 0x0c; /* VCLK > 200 */ |
| 996 | |
| 997 | if (HwDeviceExtension->jChipType >= XG20) |
| 998 | data &= ~0x04; /* 2 pixel mode */ |
| 999 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1000 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1001 | |
| 1002 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1003 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1004 | data &= 0xE7; |
| 1005 | if (VCLK < 200) |
| 1006 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1007 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1008 | } |
| 1009 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1010 | data2 = 0x00; |
| 1011 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1012 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1013 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1014 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1015 | |
| 1016 | } |
| 1017 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1018 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1019 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1020 | unsigned short RefreshRateTableIndex, |
| 1021 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1022 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1023 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1024 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1025 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1026 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1027 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1028 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1029 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1030 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1031 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1032 | data = infoflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1033 | data2 = 0; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1034 | data2 |= 0x02; |
| 1035 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1036 | data3 = data3 << 2; |
| 1037 | data2 |= data3; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1038 | data &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1039 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1040 | if (data) |
| 1041 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1042 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1043 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1044 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 1045 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1046 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1047 | data = 0x0000; |
| 1048 | if (infoflag & InterlaceMode) { |
| 1049 | if (xres == 1024) |
| 1050 | data = 0x0035; |
| 1051 | else if (xres == 1280) |
| 1052 | data = 0x0048; |
| 1053 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1054 | |
Peter Huewe | 5d1c2a9 | 2013-02-03 22:54:37 +0100 | [diff] [blame] | 1055 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data); |
| 1056 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1057 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1058 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1059 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1060 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1061 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1062 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1063 | if (modeflag & LineCompareOff) |
| 1064 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1065 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1066 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1067 | data = 0x60; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1068 | data = data ^ 0x60; |
| 1069 | data = data ^ 0xA0; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1070 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1071 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1072 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, |
| 1073 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1074 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1075 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1076 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1077 | if (HwDeviceExtension->jChipType == XG27) { |
| 1078 | if (data & 0x40) |
| 1079 | data = 0x2c; |
| 1080 | else |
| 1081 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1082 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1083 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1084 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1085 | if (data & 0x40) |
| 1086 | data = 0x33; |
| 1087 | else |
| 1088 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1089 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1090 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1091 | } else { |
| 1092 | if (data & 0x40) |
| 1093 | data = 0x2c; |
| 1094 | else |
| 1095 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1096 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1097 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1098 | |
| 1099 | } |
| 1100 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1101 | static void XGI_WriteDAC(unsigned short dl, |
| 1102 | unsigned short ah, |
| 1103 | unsigned short al, |
| 1104 | unsigned short dh, |
| 1105 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1106 | { |
| 1107 | unsigned short temp, bh, bl; |
| 1108 | |
| 1109 | bh = ah; |
| 1110 | bl = al; |
| 1111 | |
| 1112 | if (dl != 0) { |
| 1113 | temp = bh; |
| 1114 | bh = dh; |
| 1115 | dh = temp; |
| 1116 | if (dl == 1) { |
| 1117 | temp = bl; |
| 1118 | bl = dh; |
| 1119 | dh = temp; |
| 1120 | } else { |
| 1121 | temp = bl; |
| 1122 | bl = bh; |
| 1123 | bh = temp; |
| 1124 | } |
| 1125 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1126 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1127 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1128 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1129 | } |
| 1130 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1131 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1132 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1133 | { |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1134 | unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh; |
| 1135 | const unsigned short *table = XGINew_VGA_DAC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1136 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1137 | outb(0xFF, pVBInfo->P3c6); |
| 1138 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1139 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1140 | for (i = 0; i < 16; i++) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1141 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1142 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1143 | for (k = 0; k < 3; k++) { |
| 1144 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1145 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1146 | if (data & 0x01) |
| 1147 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1148 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1149 | if (data & 0x02) |
| 1150 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1151 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1152 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1153 | data = data >> 2; |
| 1154 | } |
| 1155 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1156 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1157 | for (i = 16; i < 32; i++) { |
| 1158 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1159 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1160 | for (k = 0; k < 3; k++) |
| 1161 | outb(data, pVBInfo->P3c9); |
| 1162 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1163 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1164 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1165 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1166 | for (m = 0; m < 9; m++) { |
| 1167 | di = si; |
| 1168 | bx = si + 0x04; |
| 1169 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1170 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1171 | for (n = 0; n < 3; n++) { |
| 1172 | for (o = 0; o < 5; o++) { |
| 1173 | dh = table[si]; |
| 1174 | ah = table[di]; |
| 1175 | al = table[bx]; |
| 1176 | si++; |
| 1177 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1178 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1179 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1180 | si -= 2; |
| 1181 | |
| 1182 | for (o = 0; o < 3; o++) { |
| 1183 | dh = table[bx]; |
| 1184 | ah = table[di]; |
| 1185 | al = table[si]; |
| 1186 | si--; |
| 1187 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1188 | } |
| 1189 | |
| 1190 | dl++; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1191 | } |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1192 | |
| 1193 | si += 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1194 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1195 | } |
| 1196 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1197 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
| 1198 | unsigned short ModeIdIndex, |
| 1199 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1200 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1201 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1202 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1203 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1204 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1205 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1206 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1207 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1208 | |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 1209 | xres = XGI330_ModeResInfo[resindex].HTotal; |
| 1210 | yres = XGI330_ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1211 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1212 | if (modeflag & HalfDCLK) |
| 1213 | xres = xres << 1; |
| 1214 | |
| 1215 | if (modeflag & DoubleScanMode) |
| 1216 | yres = yres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1217 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1218 | if (xres == 720) |
| 1219 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1220 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1221 | pVBInfo->VGAHDE = xres; |
| 1222 | pVBInfo->HDE = xres; |
| 1223 | pVBInfo->VGAVDE = yres; |
| 1224 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1225 | } |
| 1226 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1227 | static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table, |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1228 | unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1229 | unsigned short ModeIdIndex, |
| 1230 | unsigned short RefreshRateTableIndex, |
| 1231 | struct vb_device_info *pVBInfo) |
| 1232 | { |
Aaro Koskinen | 6c27b37 | 2012-11-04 21:14:45 +0200 | [diff] [blame] | 1233 | unsigned short i, tempdx, tempbx, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1234 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1235 | tempbx = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1236 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1237 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1238 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1239 | i = 0; |
| 1240 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1241 | while (table[i].PANELID != 0xff) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1242 | tempdx = pVBInfo->LCDResInfo; |
| 1243 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 1244 | tempbx &= (~0x0080); |
| 1245 | tempdx = pVBInfo->LCDTypeInfo; |
| 1246 | } |
| 1247 | |
| 1248 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1249 | tempdx &= (~PanelResInfo); |
| 1250 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1251 | if (table[i].PANELID == tempdx) { |
| 1252 | tempbx = table[i].MASK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1253 | tempdx = pVBInfo->LCDInfo; |
| 1254 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1255 | if (modeflag & HalfDCLK) |
| 1256 | tempdx |= SetLCDLowResolution; |
| 1257 | |
| 1258 | tempbx &= tempdx; |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1259 | if (tempbx == table[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1260 | break; |
| 1261 | } |
| 1262 | i++; |
| 1263 | } |
| 1264 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1265 | return table[i].DATAPTR; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1266 | } |
| 1267 | |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 1268 | static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1269 | unsigned short ModeIdIndex, |
| 1270 | unsigned short RefreshRateTableIndex, |
| 1271 | struct vb_device_info *pVBInfo) |
| 1272 | { |
Aaro Koskinen | 56d276c | 2012-09-11 00:15:19 +0300 | [diff] [blame] | 1273 | unsigned short i, tempdx, tempal, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1274 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1275 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1276 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1277 | tempal = tempal & 0x3f; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1278 | tempdx = pVBInfo->TVInfo; |
| 1279 | |
| 1280 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 1281 | tempdx = tempdx | SetTVLockMode; |
| 1282 | |
| 1283 | if (modeflag & HalfDCLK) |
| 1284 | tempdx = tempdx | SetTVLowResolution; |
| 1285 | |
| 1286 | i = 0; |
| 1287 | |
Aaro Koskinen | 6265ee4 | 2012-09-11 00:15:20 +0300 | [diff] [blame] | 1288 | while (XGI_TVDataTable[i].MASK != 0xffff) { |
| 1289 | if ((tempdx & XGI_TVDataTable[i].MASK) == |
| 1290 | XGI_TVDataTable[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1291 | break; |
| 1292 | i++; |
| 1293 | } |
| 1294 | |
Aaro Koskinen | 18ba866 | 2012-09-11 00:15:22 +0300 | [diff] [blame] | 1295 | return &XGI_TVDataTable[i].DATAPTR[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1296 | } |
| 1297 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1298 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1299 | unsigned short RefreshRateTableIndex, |
| 1300 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1301 | { |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1302 | struct SiS_LVDSData const *LCDPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1303 | |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1304 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 1305 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1306 | |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1307 | LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeNo, ModeIdIndex, |
| 1308 | RefreshRateTableIndex, pVBInfo); |
| 1309 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 1310 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 1311 | pVBInfo->HT = LCDPtr->LCDHT; |
| 1312 | pVBInfo->VT = LCDPtr->LCDVT; |
| 1313 | |
| 1314 | if (pVBInfo->LCDInfo & (SetLCDtoNonExpanding | EnableScalingLCD)) |
| 1315 | return; |
| 1316 | |
| 1317 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1318 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
| 1319 | pVBInfo->HDE = 1024; |
| 1320 | pVBInfo->VDE = 768; |
| 1321 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1322 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
| 1323 | pVBInfo->HDE = 1280; |
| 1324 | pVBInfo->VDE = 1024; |
| 1325 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
| 1326 | pVBInfo->HDE = 1400; |
| 1327 | pVBInfo->VDE = 1050; |
| 1328 | } else { |
| 1329 | pVBInfo->HDE = 1600; |
| 1330 | pVBInfo->VDE = 1200; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1331 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1332 | } |
| 1333 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1334 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1335 | unsigned short RefreshRateTableIndex, |
| 1336 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1337 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1338 | { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1339 | unsigned short i; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1340 | struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL; |
| 1341 | struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1342 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1343 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1344 | LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeNo, ModeIdIndex, |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1345 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1346 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1347 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1348 | pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1349 | } |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1350 | |
| 1351 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 1352 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1353 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1354 | LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeNo, |
| 1355 | ModeIdIndex, RefreshRateTableIndex, |
| 1356 | pVBInfo); |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1357 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1358 | pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i]; |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1359 | } |
| 1360 | |
| 1361 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1362 | } |
| 1363 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1364 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 1365 | { |
| 1366 | unsigned char tempal, tempah, tempbl, i; |
| 1367 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1368 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1369 | tempal = tempah & 0x0F; |
| 1370 | tempah = tempah & 0xF0; |
| 1371 | i = 0; |
| 1372 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1373 | |
| 1374 | while (tempbl != 0xFF) { |
| 1375 | if (tempbl & 0x80) { /* OEMUtil */ |
| 1376 | tempal = tempah; |
| 1377 | tempbl = tempbl & ~(0x80); |
| 1378 | } |
| 1379 | |
| 1380 | if (tempal == tempbl) |
| 1381 | break; |
| 1382 | |
| 1383 | i++; |
| 1384 | |
| 1385 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1386 | } |
| 1387 | |
| 1388 | return i; |
| 1389 | } |
| 1390 | |
| 1391 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 1392 | { |
| 1393 | unsigned short tempah, tempal, tempbl, i; |
| 1394 | |
| 1395 | tempal = pVBInfo->LCDResInfo; |
| 1396 | tempah = pVBInfo->LCDTypeInfo; |
| 1397 | |
| 1398 | i = 0; |
| 1399 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1400 | |
| 1401 | while (tempbl != 0xFF) { |
| 1402 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 1403 | tempal = tempah; |
| 1404 | tempbl &= ~0x80; |
| 1405 | } |
| 1406 | |
| 1407 | if (tempal == tempbl) |
| 1408 | break; |
| 1409 | |
| 1410 | i++; |
| 1411 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1412 | } |
| 1413 | |
| 1414 | if (tempbl == 0xFF) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1415 | pVBInfo->LCDResInfo = Panel_1024x768; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1416 | pVBInfo->LCDTypeInfo = 0; |
| 1417 | i = 0; |
| 1418 | } |
| 1419 | |
| 1420 | return i; |
| 1421 | } |
| 1422 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1423 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 1424 | unsigned short *VSyncWidth, |
| 1425 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1426 | { |
| 1427 | unsigned short Index; |
| 1428 | |
| 1429 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 1430 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 1431 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
| 1432 | |
| 1433 | return; |
| 1434 | } |
| 1435 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1436 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1437 | unsigned short RefreshRateTableIndex, |
| 1438 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1439 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1440 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 1441 | unsigned long temp, temp1, temp2, temp3, push3; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1442 | struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1443 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1444 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1445 | LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, ModeIdIndex, |
| 1446 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1447 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1448 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 1449 | push1 = tempbx; |
| 1450 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1451 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1452 | /* GetLCDResInfo */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1453 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1454 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1455 | tempax = 1024; |
| 1456 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1457 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1458 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1459 | tempax = 1280; |
| 1460 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1461 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1462 | tempax = 1400; |
| 1463 | tempbx = 1050; |
| 1464 | } else { |
| 1465 | tempax = 1600; |
| 1466 | tempbx = 1200; |
| 1467 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1468 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1469 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 1470 | pVBInfo->HDE = tempax; |
| 1471 | pVBInfo->VDE = tempbx; |
| 1472 | pVBInfo->VGAHDE = tempax; |
| 1473 | pVBInfo->VGAVDE = tempbx; |
| 1474 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1475 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1476 | tempax = pVBInfo->HT; |
| 1477 | |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1478 | tempbx = LCDPtr1->LCDHDES; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1479 | |
| 1480 | tempcx = pVBInfo->HDE; |
| 1481 | tempbx = tempbx & 0x0fff; |
| 1482 | tempcx += tempbx; |
| 1483 | |
| 1484 | if (tempcx >= tempax) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1485 | tempcx -= tempax; |
| 1486 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1487 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1488 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1489 | tempcx = tempcx >> 3; |
| 1490 | tempbx = tempbx >> 3; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1491 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1492 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 1493 | (unsigned short) (tempbx & 0xff)); |
| 1494 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 1495 | (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1496 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1497 | tempax = pVBInfo->HT; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1498 | |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1499 | tempbx = LCDPtr1->LCDHRS; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1500 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1501 | tempcx = push2; |
| 1502 | |
| 1503 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1504 | tempcx = LCDPtr1->LCDHSync; |
| 1505 | |
| 1506 | tempcx += tempbx; |
| 1507 | |
| 1508 | if (tempcx >= tempax) |
| 1509 | tempcx -= tempax; |
| 1510 | |
| 1511 | tempax = tempbx & 0x07; |
| 1512 | tempax = tempax >> 5; |
| 1513 | tempcx = tempcx >> 3; |
| 1514 | tempbx = tempbx >> 3; |
| 1515 | |
| 1516 | tempcx &= 0x1f; |
| 1517 | tempax |= tempcx; |
| 1518 | |
| 1519 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 1520 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 1521 | (unsigned short) (tempbx & 0xff)); |
| 1522 | |
| 1523 | tempax = pVBInfo->VT; |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1524 | tempbx = LCDPtr1->LCDVDES; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1525 | tempcx = pVBInfo->VDE; |
| 1526 | |
| 1527 | tempbx = tempbx & 0x0fff; |
| 1528 | tempcx += tempbx; |
| 1529 | if (tempcx >= tempax) |
| 1530 | tempcx -= tempax; |
| 1531 | |
| 1532 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 1533 | (unsigned short) (tempbx & 0xff)); |
| 1534 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 1535 | (unsigned short) (tempcx & 0xff)); |
| 1536 | |
| 1537 | tempbx = (tempbx >> 8) & 0x07; |
| 1538 | tempcx = (tempcx >> 8) & 0x07; |
| 1539 | |
| 1540 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 1541 | (unsigned short) ((tempcx << 3) |
| 1542 | | tempbx)); |
| 1543 | |
| 1544 | tempax = pVBInfo->VT; |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1545 | tempbx = LCDPtr1->LCDVRS; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1546 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1547 | tempcx = push1; |
| 1548 | |
| 1549 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1550 | tempcx = LCDPtr1->LCDVSync; |
| 1551 | |
| 1552 | tempcx += tempbx; |
| 1553 | if (tempcx >= tempax) |
| 1554 | tempcx -= tempax; |
| 1555 | |
| 1556 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 1557 | (unsigned short) (tempbx & 0xff)); |
| 1558 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 1559 | (unsigned short) (tempcx & 0x0f)); |
| 1560 | |
| 1561 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 1562 | |
| 1563 | tempbx = pVBInfo->VGAVDE; |
| 1564 | if (tempbx != pVBInfo->VDE) |
| 1565 | tempax |= 0x40; |
| 1566 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1567 | if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1568 | tempax |= 0x40; |
| 1569 | |
| 1570 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 1571 | tempax); |
| 1572 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1573 | tempbx = pVBInfo->VDE; |
| 1574 | tempax = pVBInfo->VGAVDE; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1575 | |
| 1576 | temp = tempax; /* 0430 ylshieh */ |
| 1577 | temp1 = (temp << 18) / tempbx; |
| 1578 | |
| 1579 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 1580 | |
| 1581 | if (tempdx != 0) |
| 1582 | temp1 += 1; |
| 1583 | |
| 1584 | temp2 = temp1; |
| 1585 | push3 = temp2; |
| 1586 | |
| 1587 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 1588 | (unsigned short) (temp2 & 0xff)); |
| 1589 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 1590 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 1591 | |
| 1592 | tempbx = (unsigned short) (temp2 >> 16); |
| 1593 | tempax = tempbx & 0x03; |
| 1594 | |
| 1595 | tempbx = pVBInfo->VGAVDE; |
| 1596 | if (tempbx == pVBInfo->VDE) |
| 1597 | tempax |= 0x04; |
| 1598 | |
| 1599 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 1600 | |
| 1601 | if (pVBInfo->VBType & VB_XGI301C) { |
| 1602 | temp2 = push3; |
| 1603 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1604 | 0x3c, |
| 1605 | (unsigned short) (temp2 & 0xff)); |
| 1606 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1607 | 0x3b, |
| 1608 | (unsigned short) ((temp2 >> 8) & |
| 1609 | 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1610 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1611 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 1612 | ~0xc0, |
| 1613 | (unsigned short) ((tempbx & |
| 1614 | 0xff) << 6)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1615 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1616 | tempcx = pVBInfo->VGAVDE; |
| 1617 | if (tempcx == pVBInfo->VDE) |
| 1618 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1619 | 0x30, ~0x0c, 0x00); |
| 1620 | else |
| 1621 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1622 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1623 | } |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1624 | |
| 1625 | tempcx = pVBInfo->VGAHDE; |
| 1626 | tempbx = pVBInfo->HDE; |
| 1627 | |
| 1628 | temp1 = tempcx << 16; |
| 1629 | |
| 1630 | tempax = (unsigned short) (temp1 / tempbx); |
| 1631 | |
| 1632 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 1633 | tempax = 65535; |
| 1634 | |
| 1635 | temp3 = tempax; |
| 1636 | temp1 = pVBInfo->VGAHDE << 16; |
| 1637 | |
| 1638 | temp1 /= temp3; |
| 1639 | temp3 = temp3 << 16; |
| 1640 | temp1 -= 1; |
| 1641 | |
| 1642 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 1643 | |
| 1644 | tempax = (unsigned short) (temp3 & 0xff); |
| 1645 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 1646 | |
| 1647 | temp1 = pVBInfo->VGAVDE << 18; |
| 1648 | temp1 = temp1 / push3; |
| 1649 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 1650 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1651 | if (pVBInfo->LCDResInfo == Panel_1024x768) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1652 | tempbx -= 1; |
| 1653 | |
| 1654 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 1655 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 1656 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 1657 | (unsigned short) (tempax & 0xff)); |
| 1658 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 1659 | (unsigned short) (tempbx & 0xff)); |
| 1660 | |
| 1661 | temp3 = temp3 >> 16; |
| 1662 | |
| 1663 | if (modeflag & HalfDCLK) |
| 1664 | temp3 = temp3 >> 1; |
| 1665 | |
| 1666 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 1667 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 1668 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 1669 | (unsigned short) (temp3 & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1670 | } |
| 1671 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1672 | /* --------------------------------------------------------------------- */ |
| 1673 | /* Function : XGI_GETLCDVCLKPtr */ |
| 1674 | /* Input : */ |
| 1675 | /* Output : al -> VCLK Index */ |
| 1676 | /* Description : */ |
| 1677 | /* --------------------------------------------------------------------- */ |
| 1678 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 1679 | struct vb_device_info *pVBInfo) |
| 1680 | { |
| 1681 | unsigned short index; |
| 1682 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1683 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1684 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 1685 | |
| 1686 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 1687 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 1688 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 1689 | } else { /* LCDA */ |
| 1690 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 1691 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 1692 | } |
| 1693 | } |
| 1694 | return; |
| 1695 | } |
| 1696 | |
| 1697 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
| 1698 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 1699 | struct vb_device_info *pVBInfo) |
| 1700 | { |
| 1701 | |
| 1702 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1703 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1704 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1705 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1706 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1707 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1708 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 1709 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1710 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 1711 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 1712 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1713 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1714 | return tempal; |
| 1715 | |
| 1716 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1717 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1718 | (VB_SIS301B | |
| 1719 | VB_SIS302B | |
| 1720 | VB_SIS301LV | |
| 1721 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1722 | VB_XGI301C)) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1723 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1724 | tempal = TVCLKBASE_315 + HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1725 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1726 | tempal = TVCLKBASE_315 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1727 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1728 | tempal = TVCLKBASE_315 + HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1729 | if (!(modeflag & Charx8Dot)) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1730 | tempal = TVCLKBASE_315 + |
| 1731 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1732 | |
| 1733 | } |
| 1734 | return tempal; |
| 1735 | } |
| 1736 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1737 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1738 | tempal = XGI_YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1739 | return tempal; |
| 1740 | } |
| 1741 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1742 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1743 | tempal = YPbPr525pVCLK; |
| 1744 | return tempal; |
| 1745 | } |
| 1746 | |
| 1747 | tempal = NTSC1024VCLK; |
| 1748 | |
| 1749 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1750 | tempal = TVCLKBASE_315 + TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1751 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1752 | tempal = TVCLKBASE_315 + TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1753 | } |
| 1754 | |
| 1755 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 1756 | return tempal; |
| 1757 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1758 | } /* {End of VB} */ |
| 1759 | |
Peter Huewe | 516354e | 2013-02-15 20:37:11 +0100 | [diff] [blame] | 1760 | inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1761 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1762 | return tempal; |
| 1763 | } |
| 1764 | |
| 1765 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 1766 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 1767 | { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1768 | if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B |
| 1769 | | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1770 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
| 1771 | (pVBInfo->SetFlag & ProgrammingCRT2)) { |
Aaro Koskinen | e8cb03d | 2012-09-11 00:15:31 +0300 | [diff] [blame] | 1772 | *di_0 = XGI_VBVCLKData[tempal].Part4_A; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1773 | *di_1 = XGI_VBVCLKData[tempal].Part4_B; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1774 | } |
| 1775 | } else { |
| 1776 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 1777 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 1778 | } |
| 1779 | } |
| 1780 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1781 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1782 | unsigned short RefreshRateTableIndex, |
| 1783 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1784 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1785 | unsigned char di_0, di_1, tempal; |
| 1786 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1787 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1788 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 1789 | pVBInfo); |
| 1790 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 1791 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1792 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1793 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1794 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1795 | (unsigned short) (0x10 * i)); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1796 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1797 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1798 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 1799 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1800 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1801 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 1802 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1803 | } |
| 1804 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1805 | } |
| 1806 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 1807 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1808 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1809 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1810 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1811 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1812 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 1813 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1814 | tempcl = 0; |
| 1815 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1816 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1817 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1818 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1819 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1820 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1821 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1822 | if (!(temp & 0x40)) |
| 1823 | tempcl |= ActiveCRT1; |
| 1824 | } |
| 1825 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1826 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1827 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1828 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1829 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1830 | if (!(temp == 0x08)) { |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1831 | /* Check ChannelA */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1832 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1833 | if (tempax & 0x04) |
| 1834 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1835 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1836 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1837 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1838 | if (!(tempcl & ActiveLCD)) |
| 1839 | if (temp == 0x01) |
| 1840 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1841 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1842 | if (temp == 0x04) |
| 1843 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1844 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1845 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1846 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1847 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1848 | if (!(temp & 0x08)) |
| 1849 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1850 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1851 | if (!(temp & 0x04)) |
| 1852 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1853 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1854 | if (temp & 0x02) |
| 1855 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1856 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1857 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1858 | if (temp & 0x01) |
| 1859 | tempch |= ActiveHiTV; |
| 1860 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1861 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1862 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1863 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1864 | pVBInfo->Part2Port, |
| 1865 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1866 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1867 | if (temp & 0x10) |
| 1868 | tempch |= ActiveYPbPr; |
| 1869 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1870 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1871 | if (tempch != 0) |
| 1872 | tempcl |= ActiveTV; |
| 1873 | } |
| 1874 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1875 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1876 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1877 | if (tempcl & ActiveLCD) { |
| 1878 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 1879 | if (temp & ActiveTV) |
| 1880 | tempcl |= ActiveTV; |
| 1881 | } |
| 1882 | } |
| 1883 | temp = tempcl; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1884 | tempbl = ~XGI_ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1885 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1886 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1887 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1888 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1889 | } else { |
| 1890 | return; |
| 1891 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1892 | } |
| 1893 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 1894 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1895 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1896 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1897 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1898 | tempbx = VB_SIS302B; |
| 1899 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
| 1900 | if (flag == 0x02) |
| 1901 | goto finish; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1902 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1903 | tempbx = VB_SIS301; |
| 1904 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
| 1905 | if (flag < 0xB0) |
| 1906 | goto finish; |
| 1907 | |
| 1908 | tempbx = VB_SIS301B; |
| 1909 | if (flag < 0xC0) |
| 1910 | goto bigger_than_0xB0; |
| 1911 | |
| 1912 | tempbx = VB_XGI301C; |
| 1913 | if (flag < 0xD0) |
| 1914 | goto bigger_than_0xB0; |
| 1915 | |
| 1916 | tempbx = VB_SIS301LV; |
| 1917 | if (flag < 0xE0) |
| 1918 | goto bigger_than_0xB0; |
| 1919 | |
| 1920 | tempbx = VB_SIS302LV; |
| 1921 | tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39); |
| 1922 | if (tempah != 0xFF) |
| 1923 | tempbx = VB_XGI301C; |
| 1924 | |
| 1925 | bigger_than_0xB0: |
| 1926 | if (tempbx & (VB_SIS301B | VB_SIS302B)) { |
| 1927 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23); |
| 1928 | if (!(flag & 0x02)) |
| 1929 | tempbx = tempbx | VB_NoLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1930 | } |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1931 | |
| 1932 | finish: |
| 1933 | pVBInfo->VBType = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1934 | } |
| 1935 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 1936 | static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1937 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1938 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1939 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1940 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1941 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1942 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1943 | pVBInfo->SetFlag = 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1944 | pVBInfo->ModeType = modeflag & ModeTypeMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1945 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1946 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1947 | if (!(pVBInfo->VBType & 0xFFFF)) |
| 1948 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1949 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1950 | /* Check Display Device */ |
| 1951 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
| 1952 | tempbx = tempbx | temp; |
| 1953 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
| 1954 | push = temp; |
| 1955 | push = push << 8; |
| 1956 | tempax = temp << 8; |
| 1957 | tempbx = tempbx | tempax; |
| 1958 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA |
| 1959 | | SetInSlaveMode | DisableCRT2Display); |
| 1960 | temp = 0xFFFF ^ temp; |
| 1961 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1962 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1963 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1964 | |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1965 | if (pVBInfo->VBType & (VB_SIS302B | VB_SIS301LV | VB_SIS302LV | |
| 1966 | VB_XGI301C)) { |
| 1967 | if (temp & EnableDualEdge) { |
| 1968 | tempbx |= SetCRT2ToDualEdge; |
| 1969 | if (temp & SetToLCDA) |
| 1970 | tempbx |= XGI_SetCRT2ToLCDA; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1971 | } |
| 1972 | } |
| 1973 | |
| 1974 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1975 | if (pVBInfo->VBType & (VB_SIS301LV|VB_SIS302LV|VB_XGI301C)) { |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1976 | if (temp & SetYPbPr) { |
| 1977 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1978 | /* shampoo add for new scratch */ |
| 1979 | temp = xgifb_reg_get(pVBInfo->P3d4, |
| 1980 | 0x35); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1981 | temp &= YPbPrMode; |
| 1982 | tempbx |= SetCRT2ToHiVision; |
| 1983 | |
| 1984 | if (temp != YPbPrMode1080i) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1985 | tempbx &= (~SetCRT2ToHiVision); |
| 1986 | tempbx |= SetCRT2ToYPbPr525750; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1987 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1988 | } |
| 1989 | } |
| 1990 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1991 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1992 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1993 | tempax = push; /* restore CR31 */ |
| 1994 | |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1995 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 1996 | if (pVBInfo->IF_DEF_HiVision == 1) |
| 1997 | temp = 0x09FC; |
| 1998 | else |
| 1999 | temp = 0x097C; |
| 2000 | } else if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2001 | temp = 0x01FC; |
| 2002 | } else { |
| 2003 | temp = 0x017C; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2004 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2005 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2006 | if (!(tempbx & temp)) { |
| 2007 | tempax |= DisableCRT2Display; |
| 2008 | tempbx = 0; |
| 2009 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2010 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2011 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 2012 | if (tempbx & XGI_SetCRT2ToLCDA) { |
| 2013 | if (tempbx & SetSimuScanMode) |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2014 | tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2015 | SwitchCRT2)); |
| 2016 | else |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2017 | tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC | |
| 2018 | SetCRT2ToTV | SwitchCRT2)); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2019 | } |
| 2020 | } |
| 2021 | |
| 2022 | /* shampoo add */ |
| 2023 | /* for driver abnormal */ |
| 2024 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { |
| 2025 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 2026 | if (tempbx & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2027 | tempbx &= (0xFF00 | SetCRT2ToRAMDAC | |
| 2028 | SwitchCRT2 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2029 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2030 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2031 | } else { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2032 | tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2033 | SetCRT2ToTV)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2034 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2035 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2036 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2037 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 2038 | if (tempbx & SetCRT2ToLCD) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2039 | tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2040 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2041 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2042 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2043 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2044 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2045 | if (tempbx & SetCRT2ToSCART) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2046 | tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchCRT2 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2047 | SetSimuScanMode); |
| 2048 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
| 2049 | } |
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 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 2052 | if (tempbx & SetCRT2ToYPbPr525750) |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2053 | tempbx &= (0xFF00 | SwitchCRT2 | SetSimuScanMode); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2054 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2055 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2056 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 2057 | if (tempbx & SetCRT2ToHiVision) |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2058 | tempbx &= (0xFF00 | SetCRT2ToHiVision | SwitchCRT2 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2059 | SetSimuScanMode); |
| 2060 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2061 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2062 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 2063 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) |
| 2064 | tempbx = DisableCRT2Display; |
| 2065 | } |
| 2066 | |
| 2067 | if (!(tempbx & DisableCRT2Display)) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2068 | if ((!(tempbx & DriverMode)) || (!(modeflag & CRT2Mode))) { |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2069 | if (!(tempbx & XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2070 | tempbx |= (SetInSlaveMode | SetSimuScanMode); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2071 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2072 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2073 | /* LCD+TV can't support in slave mode |
| 2074 | * (Force LCDA+TV->LCDB) */ |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2075 | if ((tempbx & SetInSlaveMode) && (tempbx & XGI_SetCRT2ToLCDA)) { |
| 2076 | tempbx ^= (SetCRT2ToLCD | XGI_SetCRT2ToLCDA | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2077 | SetCRT2ToDualEdge); |
| 2078 | pVBInfo->SetFlag |= ReserveTVOption; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2079 | } |
| 2080 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2081 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2082 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2083 | } |
| 2084 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2085 | static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2086 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2087 | { |
Peter Huewe | 5fc699f | 2013-02-03 04:08:45 +0100 | [diff] [blame] | 2088 | unsigned short tempbx = 0, resinfo = 0, modeflag, index1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2089 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2090 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2091 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2092 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2093 | |
Peter Huewe | 5fc699f | 2013-02-03 04:08:45 +0100 | [diff] [blame] | 2094 | tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
| 2095 | if (tempbx & TVSetPAL) { |
| 2096 | tempbx &= (SetCHTVOverScan | |
| 2097 | TVSetPALM | |
| 2098 | TVSetPALN | |
| 2099 | TVSetPAL); |
| 2100 | if (tempbx & TVSetPALM) |
| 2101 | /* set to NTSC if PAL-M */ |
| 2102 | tempbx &= ~TVSetPAL; |
| 2103 | } else |
| 2104 | tempbx &= (SetCHTVOverScan | |
| 2105 | TVSetNTSCJ | |
| 2106 | TVSetPAL); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2107 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2108 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 2109 | tempbx |= TVSetPAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2110 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2111 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2112 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2113 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2114 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2115 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2116 | if (index1 == YPbPrMode525i) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2117 | tempbx |= TVSetYPbPr525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2118 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2119 | if (index1 == YPbPrMode525p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2120 | tempbx = tempbx | TVSetYPbPr525p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2121 | if (index1 == YPbPrMode750p) |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2122 | tempbx = tempbx | TVSetYPbPr750p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2123 | } |
| 2124 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2125 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2126 | if (pVBInfo->IF_DEF_HiVision == 1) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2127 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
| 2128 | tempbx = tempbx | TVSetHiVision | TVSetPAL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2129 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2130 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2131 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 2132 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
| 2133 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2134 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2135 | if (!(tempbx & TVSetPAL) && (modeflag > 13) && (resinfo == 8)) |
| 2136 | /* NTSC 1024x768, */ |
| 2137 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2138 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2139 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2140 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2141 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
| 2142 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2143 | tempbx &= (~RPLLDIV2XO); |
| 2144 | } else if (tempbx & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
| 2145 | tempbx &= (~RPLLDIV2XO); |
| 2146 | } else if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | |
| 2147 | VB_SIS301LV | VB_SIS302LV | |
| 2148 | VB_XGI301C))) { |
| 2149 | if (tempbx & TVSimuMode) |
| 2150 | tempbx &= (~RPLLDIV2XO); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2151 | } |
| 2152 | } |
| 2153 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2154 | } |
| 2155 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 2156 | static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, |
| 2157 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2158 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2159 | unsigned short temp, tempax, tempbx, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2160 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2161 | pVBInfo->LCDResInfo = 0; |
| 2162 | pVBInfo->LCDTypeInfo = 0; |
| 2163 | pVBInfo->LCDInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2164 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2165 | /* si+Ext_ResInfo // */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2166 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2167 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2168 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2169 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2170 | if (tempbx == 0) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2171 | tempbx = Panel_1024x768; /* default */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2172 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 2173 | /* LCD75 */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2174 | if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2175 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2176 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2177 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2178 | tempax &= 0x0F; |
| 2179 | else |
| 2180 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2181 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2182 | if ((resinfo == 6) || (resinfo == 9)) { |
| 2183 | if (tempax >= 3) |
| 2184 | tempbx |= PanelRef75Hz; |
| 2185 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 2186 | if (tempax >= 4) |
| 2187 | tempbx |= PanelRef75Hz; |
| 2188 | } |
| 2189 | } |
| 2190 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2191 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2192 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2193 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2194 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2195 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2196 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2197 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2198 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2199 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2200 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2201 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2202 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2203 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2204 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2205 | tempbx |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2206 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2207 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2208 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2209 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2210 | |
Aaro Koskinen | 718e715 | 2013-02-09 00:03:46 +0200 | [diff] [blame] | 2211 | if (((pVBInfo->VBType & VB_SIS302LV) || |
| 2212 | (pVBInfo->VBType & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) |
| 2213 | tempbx |= SetLCDDualLink; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2214 | |
Aaro Koskinen | 718e715 | 2013-02-09 00:03:46 +0200 | [diff] [blame] | 2215 | if ((pVBInfo->LCDResInfo == Panel_1400x1050) && |
| 2216 | (pVBInfo->VBInfo & SetCRT2ToLCD) && (resinfo == 9) && |
| 2217 | (!(tempbx & EnableScalingLCD))) |
| 2218 | /* |
| 2219 | * set to center in 1280x1024 LCDB |
| 2220 | * for Panel_1400x1050 |
| 2221 | */ |
| 2222 | tempbx |= SetLCDtoNonExpanding; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2223 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2224 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2225 | if (pVBInfo->VBInfo & SetNotSimuMode) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2226 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2227 | } else { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2228 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2229 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2230 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2231 | pVBInfo->LCDInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2232 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2233 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2234 | } |
| 2235 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2236 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2237 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2238 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2239 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2240 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2241 | break; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2242 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2243 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2244 | } |
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 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2247 | } |
| 2248 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2249 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 2250 | { |
| 2251 | unsigned char ujRet = 0; |
| 2252 | unsigned char i = 0; |
| 2253 | |
| 2254 | for (i = 0; i < 8; i++) { |
| 2255 | ujRet = ujRet << 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2256 | ujRet |= (ujDate >> i) & 1; |
| 2257 | } |
| 2258 | |
| 2259 | return ujRet; |
| 2260 | } |
| 2261 | |
| 2262 | /*----------------------------------------------------------------------------*/ |
| 2263 | /* output */ |
| 2264 | /* bl[5] : LVDS signal */ |
| 2265 | /* bl[1] : LVDS backlight */ |
| 2266 | /* bl[0] : LVDS VDD */ |
| 2267 | /*----------------------------------------------------------------------------*/ |
| 2268 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 2269 | { |
| 2270 | unsigned char CR4A, temp; |
| 2271 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2272 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2273 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2274 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2275 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2276 | |
| 2277 | temp = XG21GPIODataTransfer(temp); |
| 2278 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2279 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2280 | return temp; |
| 2281 | } |
| 2282 | |
| 2283 | /*----------------------------------------------------------------------------*/ |
| 2284 | /* output */ |
| 2285 | /* bl[5] : LVDS signal */ |
| 2286 | /* bl[1] : LVDS backlight */ |
| 2287 | /* bl[0] : LVDS VDD */ |
| 2288 | /*----------------------------------------------------------------------------*/ |
| 2289 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 2290 | { |
| 2291 | unsigned char CR4A, CRB4, temp; |
| 2292 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2293 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2294 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2295 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2296 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2297 | |
| 2298 | temp &= 0x0C; |
| 2299 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2300 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2301 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2302 | temp |= ((CRB4 & 0x04) << 3); |
| 2303 | return temp; |
| 2304 | } |
| 2305 | |
Aaro Koskinen | 0ebf538 | 2011-11-27 23:03:09 +0200 | [diff] [blame] | 2306 | /*----------------------------------------------------------------------------*/ |
| 2307 | /* input */ |
| 2308 | /* bl[5] : 1;LVDS signal on */ |
| 2309 | /* bl[1] : 1;LVDS backlight on */ |
| 2310 | /* bl[0] : 1:LVDS VDD on */ |
| 2311 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 2312 | /* 000010b : clear bit 1, to set bit1 */ |
| 2313 | /* 000001b : clear bit 0, to set bit0 */ |
| 2314 | /*----------------------------------------------------------------------------*/ |
| 2315 | static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2316 | struct vb_device_info *pVBInfo) |
| 2317 | { |
| 2318 | unsigned char CR4A, temp; |
| 2319 | |
| 2320 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2321 | tempbh &= 0x23; |
| 2322 | tempbl &= 0x23; |
| 2323 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2324 | |
| 2325 | if (tempbh & 0x20) { |
| 2326 | temp = (tempbl >> 4) & 0x02; |
| 2327 | |
| 2328 | /* CR B4[1] */ |
| 2329 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2330 | |
| 2331 | } |
| 2332 | |
| 2333 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
| 2334 | |
| 2335 | temp = XG21GPIODataTransfer(temp); |
| 2336 | temp &= ~tempbh; |
| 2337 | temp |= tempbl; |
| 2338 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
| 2339 | } |
| 2340 | |
Aaro Koskinen | 776115a | 2011-11-27 23:03:10 +0200 | [diff] [blame] | 2341 | static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2342 | struct vb_device_info *pVBInfo) |
| 2343 | { |
| 2344 | unsigned char CR4A, temp; |
| 2345 | unsigned short tempbh0, tempbl0; |
| 2346 | |
| 2347 | tempbh0 = tempbh; |
| 2348 | tempbl0 = tempbl; |
| 2349 | tempbh0 &= 0x20; |
| 2350 | tempbl0 &= 0x20; |
| 2351 | tempbh0 >>= 3; |
| 2352 | tempbl0 >>= 3; |
| 2353 | |
| 2354 | if (tempbh & 0x20) { |
| 2355 | temp = (tempbl >> 4) & 0x02; |
| 2356 | |
| 2357 | /* CR B4[1] */ |
| 2358 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2359 | |
| 2360 | } |
| 2361 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
| 2362 | |
| 2363 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2364 | tempbh &= 0x03; |
| 2365 | tempbl &= 0x03; |
| 2366 | tempbh <<= 2; |
| 2367 | tempbl <<= 2; /* GPIOC,GPIOD */ |
| 2368 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2369 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
| 2370 | } |
| 2371 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2372 | static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info, |
| 2373 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2374 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2375 | { |
| 2376 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2377 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2378 | if (pXGIHWDE->jChipType == XG21) { |
| 2379 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2380 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2381 | /* LVDS VDD on */ |
| 2382 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2383 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2384 | } |
| 2385 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2386 | /* LVDS signal on */ |
| 2387 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2388 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2389 | /* LVDS backlight on */ |
| 2390 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2391 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2392 | /* DVO/DVI signal on */ |
| 2393 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2394 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2395 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2396 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2397 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2398 | if (pXGIHWDE->jChipType == XG27) { |
| 2399 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2400 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2401 | /* LVDS VDD on */ |
| 2402 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2403 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2404 | } |
| 2405 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2406 | /* LVDS signal on */ |
| 2407 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2408 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2409 | /* LVDS backlight on */ |
| 2410 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2411 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2412 | /* DVO/DVI signal on */ |
| 2413 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2414 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2415 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2416 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2417 | } |
| 2418 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2419 | void XGI_DisplayOff(struct xgifb_video_info *xgifb_info, |
| 2420 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2421 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2422 | { |
| 2423 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2424 | if (pXGIHWDE->jChipType == XG21) { |
| 2425 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2426 | /* LVDS backlight off */ |
| 2427 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2428 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2429 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2430 | /* DVO/DVI signal off */ |
| 2431 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2432 | } |
| 2433 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2434 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2435 | if (pXGIHWDE->jChipType == XG27) { |
| 2436 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2437 | /* LVDS backlight off */ |
| 2438 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2439 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2440 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2441 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2442 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2443 | /* DVO/DVI signal off */ |
| 2444 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2445 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2446 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2447 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2448 | } |
| 2449 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2450 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2451 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2452 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2453 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2454 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2455 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2456 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2457 | } |
| 2458 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2459 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2460 | { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2461 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2462 | } |
| 2463 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2464 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 2465 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2466 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2467 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2468 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2469 | /* reserve CR34 for CRT1 Mode No */ |
| 2470 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2471 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 2472 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2473 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2474 | } |
| 2475 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2476 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
| 2477 | unsigned short ModeIdIndex, |
| 2478 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2479 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2480 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2481 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2482 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 2483 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 2484 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2485 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2486 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2487 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2488 | if (modeflag & HalfDCLK) |
| 2489 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2490 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2491 | if (modeflag & DoubleScanMode) |
| 2492 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2493 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2494 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 2495 | goto exit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2496 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2497 | if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
| 2498 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2499 | if (yres == 1024) |
| 2500 | yres = 1056; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2501 | } |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2502 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2503 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2504 | if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
| 2505 | if (yres == 400) |
| 2506 | yres = 405; |
| 2507 | else if (yres == 350) |
| 2508 | yres = 360; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2509 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2510 | if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { |
| 2511 | if (yres == 360) |
| 2512 | yres = 375; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2513 | } |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2514 | } |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2515 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2516 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
| 2517 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2518 | if (!(pVBInfo->LCDInfo & LCDNonExpanding)) { |
| 2519 | if (yres == 350) |
| 2520 | yres = 357; |
| 2521 | else if (yres == 400) |
| 2522 | yres = 420; |
| 2523 | else if (yres == 480) |
| 2524 | yres = 525; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2525 | } |
| 2526 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2527 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2528 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2529 | if (xres == 720) |
| 2530 | xres = 640; |
| 2531 | |
| 2532 | exit: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2533 | pVBInfo->VGAHDE = xres; |
| 2534 | pVBInfo->HDE = xres; |
| 2535 | pVBInfo->VGAVDE = yres; |
| 2536 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2537 | } |
| 2538 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2539 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2540 | { |
| 2541 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2542 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) && |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 2543 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2544 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2545 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2546 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2547 | } |
| 2548 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2549 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
| 2550 | unsigned short ModeIdIndex, |
| 2551 | unsigned short RefreshRateTableIndex, |
| 2552 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2553 | { |
| 2554 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2555 | CRT1Index; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2556 | |
| 2557 | pVBInfo->RVBHCMAX = 1; |
| 2558 | pVBInfo->RVBHCFACT = 1; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2559 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2560 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2561 | CRT1Index &= IndexMask; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2562 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[0]; |
| 2563 | temp2 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2564 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2565 | tempbx = (unsigned short) XGI_CRT1Table[CRT1Index].CR[8]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2566 | tempcx = (unsigned short) |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2567 | XGI_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2568 | tempcx &= 0x0100; |
| 2569 | tempcx = tempcx << 2; |
| 2570 | tempbx |= tempcx; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2571 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2572 | |
| 2573 | if (temp1 & 0x01) |
| 2574 | tempbx |= 0x0100; |
| 2575 | |
| 2576 | if (temp1 & 0x20) |
| 2577 | tempbx |= 0x0200; |
| 2578 | tempax += 5; |
| 2579 | |
| 2580 | if (modeflag & Charx8Dot) |
| 2581 | tempax *= 8; |
| 2582 | else |
| 2583 | tempax *= 9; |
| 2584 | |
| 2585 | pVBInfo->VGAHT = tempax; |
| 2586 | pVBInfo->HT = tempax; |
| 2587 | tempbx++; |
| 2588 | pVBInfo->VGAVT = tempbx; |
| 2589 | pVBInfo->VT = tempbx; |
| 2590 | } |
| 2591 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2592 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2593 | unsigned short RefreshRateTableIndex, |
| 2594 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2595 | { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 2596 | unsigned short tempax = 0, tempbx = 0, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2597 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 2598 | struct SiS_LCDData const *LCDPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2599 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2600 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2601 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2602 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2603 | pVBInfo->NewFlickerMode = 0; |
| 2604 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2605 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2606 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 2607 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2608 | pVBInfo); |
| 2609 | return; |
| 2610 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2611 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2612 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 2613 | LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeNo, ModeIdIndex, |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 2614 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2615 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2616 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 2617 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 2618 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2619 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2620 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2621 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2622 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2623 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2624 | tempax = 1024; |
| 2625 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2626 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2627 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2628 | if (pVBInfo->VGAVDE == 357) |
| 2629 | tempbx = 527; |
| 2630 | else if (pVBInfo->VGAVDE == 420) |
| 2631 | tempbx = 620; |
| 2632 | else if (pVBInfo->VGAVDE == 525) |
| 2633 | tempbx = 775; |
| 2634 | else if (pVBInfo->VGAVDE == 600) |
| 2635 | tempbx = 775; |
Peter Huewe | 7580d7f | 2013-05-18 00:19:54 +0200 | [diff] [blame] | 2636 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2637 | } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2638 | tempax = 1024; |
| 2639 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2640 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2641 | tempax = 1280; |
| 2642 | if (pVBInfo->VGAVDE == 360) |
| 2643 | tempbx = 768; |
| 2644 | else if (pVBInfo->VGAVDE == 375) |
| 2645 | tempbx = 800; |
| 2646 | else if (pVBInfo->VGAVDE == 405) |
| 2647 | tempbx = 864; |
| 2648 | else |
| 2649 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2650 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2651 | tempax = 1280; |
| 2652 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2653 | } else if (pVBInfo->LCDResInfo == Panel_1280x960) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2654 | tempax = 1280; |
| 2655 | if (pVBInfo->VGAVDE == 350) |
| 2656 | tempbx = 700; |
| 2657 | else if (pVBInfo->VGAVDE == 400) |
| 2658 | tempbx = 800; |
| 2659 | else if (pVBInfo->VGAVDE == 1024) |
| 2660 | tempbx = 960; |
| 2661 | else |
| 2662 | tempbx = 960; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2663 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2664 | tempax = 1400; |
| 2665 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2666 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2667 | if (pVBInfo->VGAVDE == 1024) { |
| 2668 | tempax = 1280; |
| 2669 | tempbx = 1024; |
| 2670 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2671 | } else if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2672 | tempax = 1600; |
| 2673 | tempbx = 1200; /* alan 10/14/2003 */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2674 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2675 | if (pVBInfo->VGAVDE == 350) |
| 2676 | tempbx = 875; |
| 2677 | else if (pVBInfo->VGAVDE == 400) |
| 2678 | tempbx = 1000; |
| 2679 | } |
| 2680 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2681 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2682 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 2683 | tempax = pVBInfo->VGAHDE; |
| 2684 | tempbx = pVBInfo->VGAVDE; |
| 2685 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2686 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2687 | pVBInfo->HDE = tempax; |
| 2688 | pVBInfo->VDE = tempbx; |
| 2689 | return; |
| 2690 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2691 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2692 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 2693 | struct SiS_TVData const *TVPtr; |
| 2694 | |
| 2695 | TVPtr = XGI_GetTVPtr(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2696 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2697 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2698 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 2699 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 2700 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 2701 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 2702 | pVBInfo->HDE = TVPtr->TVHDE; |
| 2703 | pVBInfo->VDE = TVPtr->TVVDE; |
| 2704 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 2705 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2706 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2707 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2708 | if (resinfo == 0x08) |
| 2709 | pVBInfo->NewFlickerMode = 0x40; |
| 2710 | else if (resinfo == 0x09) |
| 2711 | pVBInfo->NewFlickerMode = 0x40; |
| 2712 | else if (resinfo == 0x12) |
| 2713 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2714 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2715 | if (pVBInfo->VGAVDE == 350) |
| 2716 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2717 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2718 | tempax = ExtHiTVHT; |
| 2719 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2720 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2721 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2722 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 2723 | tempax = StHiTVHT; |
| 2724 | tempbx = StHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2725 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2726 | if (!(modeflag & Charx8Dot)) { |
| 2727 | tempax = StHiTextTVHT; |
| 2728 | tempbx = StHiTextTVVT; |
| 2729 | } |
| 2730 | } |
| 2731 | } |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2732 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 2733 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2734 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 2735 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 2736 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2737 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2738 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2739 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 2740 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2741 | } else if (pVBInfo->TVInfo & TVSetYPbPr525i) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2742 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 2743 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 2744 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2745 | tempax = NTSC1024x768HT; |
| 2746 | } |
| 2747 | } else { |
| 2748 | tempax = PALHT; |
| 2749 | tempbx = PALVT; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2750 | if (!(pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2751 | tempax = NTSCHT; |
| 2752 | tempbx = NTSCVT; |
| 2753 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2754 | tempax = NTSC1024x768HT; |
| 2755 | } |
| 2756 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2757 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2758 | pVBInfo->HT = tempax; |
| 2759 | pVBInfo->VT = tempbx; |
| 2760 | return; |
| 2761 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2762 | } |
| 2763 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2764 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2765 | unsigned short RefreshRateTableIndex, |
| 2766 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2767 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2768 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2769 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2770 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
| 2771 | pVBInfo); |
| 2772 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 2773 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2774 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2775 | if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2776 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2777 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 2778 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 2779 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2780 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2781 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 2782 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2783 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2784 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2785 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2786 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2787 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2788 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2789 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2790 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2791 | } |
| 2792 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2793 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
| 2794 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2795 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2796 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 2797 | short index; |
| 2798 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2799 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2800 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2801 | index = (modeflag & ModeTypeMask) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2802 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2803 | if (index < 0) |
| 2804 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2805 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2806 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2807 | } |
| 2808 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2809 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 2810 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2811 | unsigned short RefreshRateTableIndex, |
| 2812 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2813 | struct vb_device_info *pVBInfo) |
| 2814 | { |
| 2815 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 2816 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 2817 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2818 | modeinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2819 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2820 | |
| 2821 | index = (modeinfo >> 8) & 0xFF; |
| 2822 | |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame] | 2823 | temp = XGI330_ScreenOffset[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2824 | |
| 2825 | if (infoflag & InterlaceMode) |
| 2826 | temp = temp << 1; |
| 2827 | |
| 2828 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 2829 | |
| 2830 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 2831 | temp = ModeNo - 0x7C; |
| 2832 | colordepth = ColorDepth[temp]; |
| 2833 | temp = 0x6B; |
| 2834 | if (infoflag & InterlaceMode) |
| 2835 | temp = temp << 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2836 | } |
Peter Huewe | 053004b | 2013-02-15 20:37:12 +0100 | [diff] [blame] | 2837 | return temp * colordepth; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2838 | } |
| 2839 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2840 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 2841 | unsigned short ModeIdIndex, |
| 2842 | unsigned short RefreshRateTableIndex, |
| 2843 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2844 | struct vb_device_info *pVBInfo) |
| 2845 | { |
| 2846 | unsigned short offset; |
| 2847 | unsigned char temp; |
| 2848 | |
| 2849 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2850 | return; |
| 2851 | |
| 2852 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2853 | HwDeviceExtension, pVBInfo); |
| 2854 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2855 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2856 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2857 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2858 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2859 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2860 | } |
| 2861 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 2862 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2863 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2864 | /* threshold high ,disable auto threshold */ |
| 2865 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 2866 | /* threshold low default 04h */ |
| 2867 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2868 | } |
| 2869 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2870 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2871 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2872 | unsigned short RefreshRateTableIndex, |
| 2873 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2874 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2875 | u8 tempcx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2876 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2877 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 2878 | HwDeviceExtension, pVBInfo); |
| 2879 | XGI_SetCRT2FIFO(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2880 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2881 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2882 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2883 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2884 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 2885 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2886 | } |
| 2887 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2888 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2889 | struct xgi_hw_device_info *HwDeviceExtension, |
| 2890 | unsigned short RefreshRateTableIndex, |
| 2891 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2892 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2893 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2894 | pushbx = 0, CRT1Index, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2895 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2896 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2897 | CRT1Index &= IndexMask; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2898 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2899 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2900 | /* bainy change table name */ |
| 2901 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2902 | /* BTVGA2HT 0x08,0x09 */ |
| 2903 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2904 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2905 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2906 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2907 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 2908 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2909 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2910 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 2911 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 2912 | tempcx = tempcx >> 1; |
| 2913 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 2914 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2915 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2916 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2917 | tempbx = XGI_CRT1Table[CRT1Index].CR[4]; |
| 2918 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[14] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2919 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2920 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2921 | tempcx = XGI_CRT1Table[CRT1Index].CR[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2922 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2923 | temp = XGI_CRT1Table[CRT1Index].CR[15]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2924 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 2925 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 2926 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2927 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2928 | tempbx += 4; |
| 2929 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2930 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2931 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 2932 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2933 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2934 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2935 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2936 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2937 | } else { |
| 2938 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2939 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2940 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2941 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2942 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 2943 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2944 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2945 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 2946 | pushbx = pVBInfo->VGAHDE + 16; |
| 2947 | tempcx = tempcx >> 1; |
| 2948 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 2949 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2950 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2951 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2952 | tempbx = XGI_CRT1Table[CRT1Index].CR[3]; |
| 2953 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[5] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2954 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2955 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2956 | tempcx = XGI_CRT1Table[CRT1Index].CR[4]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2957 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2958 | temp = XGI_CRT1Table[CRT1Index].CR[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2959 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 2960 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 2961 | tempbx += 16; |
| 2962 | tempcx += 16; |
| 2963 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2964 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2965 | if (tempcx > pVBInfo->VGAHT) |
| 2966 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2967 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2968 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2969 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2970 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2971 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2972 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 2973 | tempbx = pushbx; |
| 2974 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 2975 | tempax |= (tempbx & 0xFF00); |
| 2976 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2977 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2978 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2979 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2980 | tempcx = (pVBInfo->VGAVT - 1); |
| 2981 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2982 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2983 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2984 | tempbx = pVBInfo->VGAVDE - 1; |
| 2985 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2986 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2987 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 2988 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2989 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2990 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2991 | /* BTVGA2VRS 0x10,0x11 */ |
| 2992 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 2993 | /* BTVGA2VRE 0x11 */ |
| 2994 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2995 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2996 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2997 | tempbx = XGI_CRT1Table[CRT1Index].CR[10]; |
| 2998 | temp = XGI_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2999 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3000 | if (temp & 0x04) |
| 3001 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3002 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3003 | if (temp & 0x080) |
| 3004 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3005 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3006 | temp = XGI_CRT1Table[CRT1Index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3007 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3008 | if (temp & 0x08) |
| 3009 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3010 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 3011 | temp = XGI_CRT1Table[CRT1Index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3012 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 3013 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3014 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3015 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3016 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3017 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 3018 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3019 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3020 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3021 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3022 | if (modeflag & DoubleScanMode) |
| 3023 | tempax |= 0x80; |
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 | if (modeflag & HalfDCLK) |
| 3026 | tempax |= 0x40; |
| 3027 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3028 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3029 | } |
| 3030 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 3031 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 3032 | { |
| 3033 | unsigned long tempax, tempbx; |
| 3034 | |
| 3035 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 3036 | & 0xFFFF; |
| 3037 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 3038 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 3039 | |
| 3040 | return (unsigned short) tempax; |
| 3041 | } |
| 3042 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3043 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3044 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3045 | unsigned short RefreshRateTableIndex, |
| 3046 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3047 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3048 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 3049 | modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3050 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3051 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3052 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 3053 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
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 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 3056 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3057 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3058 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3059 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3060 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3061 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3062 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3063 | modeflag |= Charx8Dot; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3064 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3065 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3066 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3067 | if (modeflag & HalfDCLK) |
| 3068 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3069 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3070 | tempax = (tempax / tempcx) - 1; |
| 3071 | tempbx |= ((tempax & 0x00FF) << 8); |
| 3072 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3073 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3074 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3075 | temp = (tempbx & 0xFF00) >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3076 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3077 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3078 | if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3079 | | VB_SIS302LV | VB_XGI301C))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3080 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3081 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 3082 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) && |
| 3083 | !(pVBInfo->VBType & VB_SIS301LV) && (resinfo == 7)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3084 | temp -= 2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3085 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3086 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3087 | /* 0x05 Horizontal Display Start */ |
| 3088 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 3089 | /* 0x06 Horizontal Blank end */ |
| 3090 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3091 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3092 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 3093 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3094 | tempax = pVBInfo->VGAHT; |
| 3095 | else |
| 3096 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3097 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3098 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3099 | if (tempax >= pVBInfo->VGAHT) |
| 3100 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3101 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3102 | if (modeflag & HalfDCLK) |
| 3103 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3104 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3105 | tempax = (tempax / tempcx) - 5; |
| 3106 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3107 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3108 | temp = (tempbx & 0x00FF) - 1; |
| 3109 | if (!(modeflag & HalfDCLK)) { |
| 3110 | temp -= 6; |
| 3111 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3112 | temp -= 4; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3113 | temp -= 10; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3114 | } |
| 3115 | } |
| 3116 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3117 | tempbx = (tempbx & 0xFF00) >> 8; |
| 3118 | tempcx = (tempcx + tempbx) >> 1; |
| 3119 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3120 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3121 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3122 | temp -= 1; |
| 3123 | if (!(modeflag & HalfDCLK)) { |
| 3124 | if ((modeflag & Charx8Dot)) { |
| 3125 | temp += 4; |
| 3126 | if (pVBInfo->VGAHDE >= 800) |
| 3127 | temp -= 6; |
| 3128 | } |
| 3129 | } |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3130 | } else if (!(modeflag & HalfDCLK)) { |
| 3131 | temp -= 4; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3132 | if (pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3133 | pVBInfo->VGAHDE >= 800) { |
| 3134 | temp -= 7; |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3135 | if (pVBInfo->VGAHDE >= 1280 && |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3136 | pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3137 | (pVBInfo->LCDInfo & LCDNonExpanding)) |
| 3138 | temp += 28; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3139 | } |
| 3140 | } |
| 3141 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3142 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3143 | /* 0x07 Horizontal Retrace Start */ |
| 3144 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 3145 | /* 0x08 Horizontal Retrace End */ |
| 3146 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3147 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3148 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3149 | if (pVBInfo->TVInfo & TVSimuMode) { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3150 | if (ModeNo == 0x50) { |
Peter Huewe | 85b3847 | 2013-05-13 23:41:49 +0200 | [diff] [blame] | 3151 | if (pVBInfo->TVInfo == SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3152 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3153 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3154 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3155 | 0x08, 0x03); |
| 3156 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3157 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3158 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3159 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3160 | 0x08, 0x02); |
| 3161 | } |
| 3162 | } |
| 3163 | } |
| 3164 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3165 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3166 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3167 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3168 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3169 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3170 | tempbx = pVBInfo->VGAVT; |
| 3171 | push1 = tempbx; |
| 3172 | tempcx = 0x121; |
| 3173 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3174 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3175 | if (tempbx == 357) |
| 3176 | tempbx = 350; |
| 3177 | if (tempbx == 360) |
| 3178 | tempbx = 350; |
| 3179 | if (tempbx == 375) |
| 3180 | tempbx = 350; |
| 3181 | if (tempbx == 405) |
| 3182 | tempbx = 400; |
| 3183 | if (tempbx == 525) |
| 3184 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3185 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3186 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3187 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3188 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3189 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3190 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3191 | if (tempbx == 350) |
| 3192 | tempbx += 5; |
| 3193 | if (tempbx == 480) |
| 3194 | tempbx += 5; |
| 3195 | } |
| 3196 | } |
| 3197 | } |
| 3198 | tempbx--; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3199 | tempbx--; |
| 3200 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3201 | /* 0x10 vertical Blank Start */ |
| 3202 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3203 | tempbx = push2; |
| 3204 | tempbx--; |
| 3205 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3206 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3207 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3208 | if (tempbx & 0x0100) |
| 3209 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3210 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3211 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3212 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3213 | if (modeflag & DoubleScanMode) |
| 3214 | tempax |= 0x08000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3215 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3216 | if (tempbx & 0x0200) |
| 3217 | tempcx |= 0x0040; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3218 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3219 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3220 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3221 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3222 | if (tempbx & 0x0400) |
| 3223 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3224 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3225 | /* 0x11 Vertival Blank End */ |
| 3226 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3227 | |
| 3228 | tempax = push1; |
| 3229 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 3230 | tempax = tempax >> 2; |
| 3231 | push1 = tempax; /* push ax */ |
| 3232 | |
| 3233 | if (resinfo != 0x09) { |
| 3234 | tempax = tempax << 1; |
| 3235 | tempbx += tempax; |
| 3236 | } |
| 3237 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3238 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Miguel Gómez | 470c533 | 2012-07-06 12:40:50 +0200 | [diff] [blame] | 3239 | if ((pVBInfo->VBType & VB_SIS301LV) && |
| 3240 | !(pVBInfo->TVInfo & TVSetHiVision)) { |
| 3241 | if ((pVBInfo->TVInfo & TVSimuMode) && |
| 3242 | (pVBInfo->TVInfo & TVSetPAL)) { |
| 3243 | if (!(pVBInfo->VBType & VB_SIS301LV) || |
| 3244 | !(pVBInfo->TVInfo & |
| 3245 | (TVSetYPbPr525p | |
| 3246 | TVSetYPbPr750p | |
| 3247 | TVSetHiVision))) |
| 3248 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3249 | } |
| 3250 | } else { |
| 3251 | tempbx -= 10; |
| 3252 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3253 | } else if (pVBInfo->TVInfo & TVSimuMode) { |
| 3254 | if (pVBInfo->TVInfo & TVSetPAL) { |
| 3255 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 3256 | if (!(pVBInfo->TVInfo & |
| 3257 | (TVSetYPbPr525p | |
| 3258 | TVSetYPbPr750p | |
| 3259 | TVSetHiVision))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3260 | tempbx += 40; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3261 | } else { |
| 3262 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3263 | } |
| 3264 | } |
| 3265 | } |
| 3266 | tempax = push1; |
| 3267 | tempax = tempax >> 2; |
| 3268 | tempax++; |
| 3269 | tempax += tempbx; |
| 3270 | push1 = tempax; /* push ax */ |
| 3271 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3272 | if ((pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3273 | if (tempbx <= 513) { |
| 3274 | if (tempax >= 513) |
| 3275 | tempbx = 513; |
| 3276 | } |
| 3277 | } |
| 3278 | |
| 3279 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3280 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3281 | tempbx--; |
| 3282 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3283 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3284 | |
| 3285 | if (tempbx & 0x0100) |
| 3286 | tempcx |= 0x0008; |
| 3287 | |
| 3288 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3289 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3290 | |
| 3291 | tempbx++; |
| 3292 | |
| 3293 | if (tempbx & 0x0100) |
| 3294 | tempcx |= 0x0004; |
| 3295 | |
| 3296 | if (tempbx & 0x0200) |
| 3297 | tempcx |= 0x0080; |
| 3298 | |
| 3299 | if (tempbx & 0x0400) |
| 3300 | tempcx |= 0x0C00; |
| 3301 | |
| 3302 | tempbx = push1; /* pop ax */ |
| 3303 | temp = tempbx & 0x00FF; |
| 3304 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3305 | /* 0x0D vertical Retrace End */ |
| 3306 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3307 | |
| 3308 | if (tempbx & 0x0010) |
| 3309 | tempcx |= 0x2000; |
| 3310 | |
| 3311 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3312 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3313 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3314 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3315 | tempax = modeflag; |
| 3316 | temp = (tempax & 0xFF00) >> 8; |
| 3317 | |
| 3318 | temp = (temp >> 1) & 0x09; |
| 3319 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3320 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3321 | temp |= 0x01; |
| 3322 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3323 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 3324 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 3325 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3326 | |
| 3327 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 3328 | temp = 0x80; |
| 3329 | else |
| 3330 | temp = 0x00; |
| 3331 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3332 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3333 | |
| 3334 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3335 | } |
| 3336 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3337 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3338 | unsigned short RefreshRateTableIndex, |
| 3339 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3340 | struct vb_device_info *pVBInfo) |
| 3341 | { |
| 3342 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 3343 | modeflag; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 3344 | unsigned char const *TimingPoint; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3345 | |
| 3346 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 3347 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3348 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3349 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3350 | |
| 3351 | tempax = 0; |
| 3352 | |
| 3353 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 3354 | tempax |= 0x0800; |
| 3355 | |
| 3356 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3357 | tempax |= 0x0400; |
| 3358 | |
| 3359 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 3360 | tempax |= 0x0200; |
| 3361 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3362 | if (!(pVBInfo->TVInfo & TVSetPAL)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3363 | tempax |= 0x1000; |
| 3364 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3365 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3366 | tempax |= 0x0100; |
| 3367 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3368 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3369 | tempax &= 0xfe00; |
| 3370 | |
| 3371 | tempax = (tempax & 0xff00) >> 8; |
| 3372 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3373 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3374 | TimingPoint = XGI330_NTSCTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3375 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3376 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3377 | TimingPoint = XGI330_PALTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3378 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3379 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3380 | TimingPoint = XGI330_HiTVExtTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3381 | |
| 3382 | if (pVBInfo->VBInfo & SetInSlaveMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3383 | TimingPoint = XGI330_HiTVSt2Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3384 | |
| 3385 | if (pVBInfo->SetFlag & TVSimuMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3386 | TimingPoint = XGI330_HiTVSt1Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3387 | |
| 3388 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3389 | TimingPoint = XGI330_HiTVTextTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3390 | } |
| 3391 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3392 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 3393 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3394 | TimingPoint = XGI330_YPbPr525iTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3395 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3396 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3397 | TimingPoint = XGI330_YPbPr525pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3398 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3399 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3400 | TimingPoint = XGI330_YPbPr750pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3401 | } |
| 3402 | |
| 3403 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3404 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3405 | |
| 3406 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3407 | /* di->temp2[j] */ |
| 3408 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3409 | |
| 3410 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3411 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3412 | |
| 3413 | temp = pVBInfo->NewFlickerMode; |
| 3414 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3415 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3416 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3417 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3418 | tempax = 520; |
| 3419 | else |
| 3420 | tempax = 440; |
| 3421 | |
| 3422 | if (pVBInfo->VDE <= tempax) { |
| 3423 | tempax -= pVBInfo->VDE; |
| 3424 | tempax = tempax >> 2; |
| 3425 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 3426 | push1 = tempax; |
| 3427 | temp = (tempax & 0xFF00) >> 8; |
| 3428 | temp += (unsigned short) TimingPoint[0]; |
| 3429 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3430 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3431 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3432 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3433 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3434 | | SetCRT2ToYPbPr525750)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3435 | tempcx = pVBInfo->VGAHDE; |
| 3436 | if (tempcx >= 1024) { |
| 3437 | temp = 0x17; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3438 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3439 | temp = 0x19; /* PAL */ |
| 3440 | } |
| 3441 | } |
| 3442 | } |
| 3443 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3444 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3445 | tempax = push1; |
| 3446 | temp = (tempax & 0xFF00) >> 8; |
| 3447 | temp += TimingPoint[1]; |
| 3448 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3449 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3450 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3451 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3452 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3453 | | SetCRT2ToYPbPr525750))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3454 | tempcx = pVBInfo->VGAHDE; |
| 3455 | if (tempcx >= 1024) { |
| 3456 | temp = 0x1D; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3457 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3458 | temp = 0x52; /* PAL */ |
| 3459 | } |
| 3460 | } |
| 3461 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3462 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3463 | } |
| 3464 | |
| 3465 | /* 301b */ |
| 3466 | tempcx = pVBInfo->HT; |
| 3467 | |
| 3468 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3469 | tempcx = tempcx >> 1; |
| 3470 | |
| 3471 | tempcx -= 2; |
| 3472 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3473 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3474 | |
| 3475 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3476 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3477 | |
| 3478 | tempcx = pVBInfo->HT >> 1; |
| 3479 | push1 = tempcx; /* push cx */ |
| 3480 | tempcx += 7; |
| 3481 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3482 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3483 | tempcx -= 4; |
| 3484 | |
| 3485 | temp = tempcx & 0x00FF; |
| 3486 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3487 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3488 | |
| 3489 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3490 | tempbx += tempcx; |
| 3491 | push2 = tempbx; |
| 3492 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3493 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3494 | temp = (tempbx & 0xFF00) >> 8; |
| 3495 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3496 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3497 | |
| 3498 | tempbx = push2; |
| 3499 | tempbx = tempbx + 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3500 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3501 | tempbx = tempbx - 4; |
| 3502 | tempcx = tempbx; |
| 3503 | } |
| 3504 | |
| 3505 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3506 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3507 | |
| 3508 | j += 2; |
| 3509 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 3510 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3511 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3512 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3513 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3514 | |
| 3515 | tempcx += 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3516 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3517 | tempcx -= 4; |
| 3518 | |
| 3519 | temp = tempcx & 0xFF; |
| 3520 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3521 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3522 | |
| 3523 | tempcx = push1; /* pop cx */ |
| 3524 | j += 2; |
| 3525 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3526 | tempcx -= temp; |
| 3527 | temp = tempcx & 0x00FF; |
| 3528 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3529 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3530 | |
| 3531 | tempcx -= 11; |
| 3532 | |
| 3533 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 3534 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3535 | tempcx = tempax - 1; |
| 3536 | } |
| 3537 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3538 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3539 | |
| 3540 | tempbx = pVBInfo->VDE; |
| 3541 | |
| 3542 | if (pVBInfo->VGAVDE == 360) |
| 3543 | tempbx = 746; |
| 3544 | if (pVBInfo->VGAVDE == 375) |
| 3545 | tempbx = 746; |
| 3546 | if (pVBInfo->VGAVDE == 405) |
| 3547 | tempbx = 853; |
| 3548 | |
| 3549 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3550 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3551 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3552 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3553 | (TVSetYPbPr525p | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3554 | tempbx = tempbx >> 1; |
| 3555 | } else |
| 3556 | tempbx = tempbx >> 1; |
| 3557 | } |
| 3558 | |
| 3559 | tempbx -= 2; |
| 3560 | temp = tempbx & 0x00FF; |
| 3561 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3562 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3563 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3564 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3565 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3566 | if (ModeNo == 0x2f) |
| 3567 | temp += 1; |
| 3568 | } |
| 3569 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3570 | } else if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3571 | if (ModeNo == 0x2f) |
| 3572 | temp += 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3573 | } |
| 3574 | } |
| 3575 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3576 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3577 | |
| 3578 | temp = (tempcx & 0xFF00) >> 8; |
| 3579 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 3580 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3581 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3582 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3583 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3584 | temp |= 0x10; |
| 3585 | |
| 3586 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3587 | temp |= 0x20; |
| 3588 | } |
| 3589 | } else { |
| 3590 | temp |= 0x10; |
| 3591 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3592 | temp |= 0x20; |
| 3593 | } |
| 3594 | } |
| 3595 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3596 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3597 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3598 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3599 | | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3600 | tempbx = pVBInfo->VDE; |
| 3601 | tempcx = tempbx - 2; |
| 3602 | |
| 3603 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3604 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p |
| 3605 | | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3606 | tempbx = tempbx >> 1; |
| 3607 | } |
| 3608 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3609 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3610 | temp = 0; |
| 3611 | if (tempcx & 0x0400) |
| 3612 | temp |= 0x20; |
| 3613 | |
| 3614 | if (tempbx & 0x0400) |
| 3615 | temp |= 0x40; |
| 3616 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3617 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3618 | } |
| 3619 | |
| 3620 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3621 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3622 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3623 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3624 | } |
| 3625 | |
| 3626 | tempbx = tempbx & 0x00FF; |
| 3627 | |
| 3628 | if (!(modeflag & HalfDCLK)) { |
| 3629 | tempcx = pVBInfo->VGAHDE; |
| 3630 | if (tempcx >= pVBInfo->HDE) { |
| 3631 | tempbx |= 0x2000; |
| 3632 | tempax &= 0x00FF; |
| 3633 | } |
| 3634 | } |
| 3635 | |
| 3636 | tempcx = 0x0101; |
| 3637 | |
| 3638 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 3639 | if (pVBInfo->VGAHDE >= 1024) { |
| 3640 | tempcx = 0x1920; |
| 3641 | if (pVBInfo->VGAHDE >= 1280) { |
| 3642 | tempcx = 0x1420; |
| 3643 | tempbx = tempbx & 0xDFFF; |
| 3644 | } |
| 3645 | } |
| 3646 | } |
| 3647 | |
| 3648 | if (!(tempbx & 0x2000)) { |
| 3649 | if (modeflag & HalfDCLK) |
| 3650 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 3651 | |
| 3652 | push1 = tempbx; |
| 3653 | tempeax = pVBInfo->VGAHDE; |
| 3654 | tempebx = (tempcx & 0xFF00) >> 8; |
| 3655 | longtemp = tempeax * tempebx; |
| 3656 | tempecx = tempcx & 0x00FF; |
| 3657 | longtemp = longtemp / tempecx; |
| 3658 | |
| 3659 | /* 301b */ |
| 3660 | tempecx = 8 * 1024; |
| 3661 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3662 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3663 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3664 | tempecx = tempecx * 8; |
| 3665 | } |
| 3666 | |
| 3667 | longtemp = longtemp * tempecx; |
| 3668 | tempecx = pVBInfo->HDE; |
| 3669 | temp2 = longtemp % tempecx; |
| 3670 | tempeax = longtemp / tempecx; |
| 3671 | if (temp2 != 0) |
| 3672 | tempeax += 1; |
| 3673 | |
| 3674 | tempax = (unsigned short) tempeax; |
| 3675 | |
| 3676 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3677 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3678 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3679 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 3680 | } |
| 3681 | /* end 301b */ |
| 3682 | |
| 3683 | tempbx = push1; |
| 3684 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 3685 | | (tempbx & 0x00FF)); |
| 3686 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 3687 | | (tempax & 0x00FF)); |
| 3688 | temp = (tempax & 0xFF00) >> 8; |
| 3689 | } else { |
| 3690 | temp = (tempax & 0x00FF) >> 8; |
| 3691 | } |
| 3692 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3693 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3694 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3695 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3696 | temp = tempcx & 0x00FF; |
| 3697 | |
| 3698 | if (tempbx & 0x2000) |
| 3699 | temp = 0; |
| 3700 | |
| 3701 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3702 | temp |= 0x18; |
| 3703 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3704 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3705 | if (pVBInfo->TVInfo & TVSetPAL) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3706 | tempbx = 0x0382; |
| 3707 | tempcx = 0x007e; |
| 3708 | } else { |
| 3709 | tempbx = 0x0369; |
| 3710 | tempcx = 0x0061; |
| 3711 | } |
| 3712 | |
| 3713 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3714 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3715 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3716 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3717 | |
| 3718 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 3719 | temp = temp << 2; |
| 3720 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 3721 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3722 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3723 | temp |= 0x10; |
| 3724 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3725 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3726 | temp |= 0x20; |
| 3727 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3728 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3729 | temp |= 0x60; |
| 3730 | } |
| 3731 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3732 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3733 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3734 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3735 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3736 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3737 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 3738 | TimingPoint = XGI_NTSC1024AdjTime; |
| 3739 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3740 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3741 | TimingPoint[j]); |
| 3742 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3743 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3744 | } |
| 3745 | } |
| 3746 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 3747 | /* Modify for 301C PALM Support */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3748 | if (pVBInfo->VBType & VB_XGI301C) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3749 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3750 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3751 | 0x08); /* PALM Mode */ |
| 3752 | } |
| 3753 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3754 | if (pVBInfo->TVInfo & TVSetPALM) { |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 3755 | tempax = xgifb_reg_get(pVBInfo->Part2Port, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3756 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3757 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3758 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3759 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3760 | } |
| 3761 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3762 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3763 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3764 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3765 | } |
| 3766 | |
| 3767 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3768 | return; |
| 3769 | } |
| 3770 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3771 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3772 | struct xgi_hw_device_info *HwDeviceExtension, |
| 3773 | unsigned short RefreshRateTableIndex, |
| 3774 | struct vb_device_info *pVBInfo) |
| 3775 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 3776 | unsigned short pushbx, tempax, tempbx, tempcx, temp, tempah, |
| 3777 | tempbh, tempch; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3778 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 3779 | struct XGI_LCDDesStruct const *LCDBDesPtr = NULL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3780 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3781 | /* si+Ext_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3782 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3783 | return; |
| 3784 | |
| 3785 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 3786 | |
| 3787 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3788 | tempbx = tempbx >> 1; |
| 3789 | |
| 3790 | tempbx -= 1; |
| 3791 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3792 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3793 | temp = (tempbx & 0xFF00) >> 8; |
| 3794 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3795 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3796 | temp = 0x01; |
| 3797 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3798 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3799 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3800 | tempbx--; |
| 3801 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3802 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3803 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3804 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3805 | |
| 3806 | tempcx = pVBInfo->VT - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3807 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3808 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3809 | temp = (tempcx & 0xFF00) >> 8; |
| 3810 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3811 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3812 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 3813 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 3814 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 3815 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3816 | |
Justin P. Mattock | 558f758 | 2012-10-02 21:17:11 -0700 | [diff] [blame] | 3817 | /* Customized LCDB Does not add */ |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 3818 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
| 3819 | LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeNo, ModeIdIndex, |
| 3820 | RefreshRateTableIndex, pVBInfo); |
| 3821 | else |
| 3822 | LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeNo, |
| 3823 | ModeIdIndex, RefreshRateTableIndex, |
| 3824 | pVBInfo); |
| 3825 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3826 | tempah = pVBInfo->LCDResInfo; |
| 3827 | tempah &= PanelResInfo; |
| 3828 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3829 | if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3830 | tempbx = 1024; |
| 3831 | tempcx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3832 | } else if ((tempah == Panel_1280x1024) || |
| 3833 | (tempah == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3834 | tempbx = 1280; |
| 3835 | tempcx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3836 | } else if (tempah == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3837 | tempbx = 1400; |
| 3838 | tempcx = 1050; |
| 3839 | } else { |
| 3840 | tempbx = 1600; |
| 3841 | tempcx = 1200; |
| 3842 | } |
| 3843 | |
| 3844 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 3845 | tempbx = pVBInfo->HDE; |
| 3846 | tempcx = pVBInfo->VDE; |
| 3847 | } |
| 3848 | |
| 3849 | pushbx = tempbx; |
| 3850 | tempax = pVBInfo->VT; |
| 3851 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 3852 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 3853 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 3854 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 3855 | tempbx = pVBInfo->LCDVDES; |
| 3856 | tempcx += tempbx; |
| 3857 | |
| 3858 | if (tempcx >= tempax) |
| 3859 | tempcx -= tempax; /* lcdvdes */ |
| 3860 | |
| 3861 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3862 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3863 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3864 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3865 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 3866 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 3867 | tempah = tempch; |
| 3868 | tempah = tempah << 3; |
| 3869 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3870 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3871 | |
| 3872 | /* getlcdsync() */ |
| 3873 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 3874 | tempcx = tempbx; |
| 3875 | tempax = pVBInfo->VT; |
| 3876 | tempbx = pVBInfo->LCDVRS; |
| 3877 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3878 | tempcx += tempbx; |
| 3879 | if (tempcx >= tempax) |
| 3880 | tempcx -= tempax; |
| 3881 | |
| 3882 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3883 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3884 | temp = (tempbx & 0xFF00) >> 8; |
| 3885 | temp = temp << 4; |
| 3886 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3887 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3888 | tempcx = pushbx; |
| 3889 | tempax = pVBInfo->HT; |
| 3890 | tempbx = pVBInfo->LCDHDES; |
| 3891 | tempbx &= 0x0FFF; |
| 3892 | |
| 3893 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 3894 | tempax = tempax >> 1; |
| 3895 | tempbx = tempbx >> 1; |
| 3896 | tempcx = tempcx >> 1; |
| 3897 | } |
| 3898 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3899 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3900 | tempbx += 1; |
| 3901 | |
| 3902 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 3903 | tempbx += 1; |
| 3904 | |
| 3905 | tempcx += tempbx; |
| 3906 | |
| 3907 | if (tempcx >= tempax) |
| 3908 | tempcx -= tempax; |
| 3909 | |
| 3910 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3911 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3912 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3913 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3914 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3915 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3916 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3917 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3918 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3919 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 3920 | tempcx = tempax; |
| 3921 | tempax = pVBInfo->HT; |
| 3922 | tempbx = pVBInfo->LCDHRS; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3923 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 3924 | tempax = tempax >> 1; |
| 3925 | tempbx = tempbx >> 1; |
| 3926 | tempcx = tempcx >> 1; |
| 3927 | } |
| 3928 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3929 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3930 | tempbx += 1; |
| 3931 | |
| 3932 | tempcx += tempbx; |
| 3933 | |
| 3934 | if (tempcx >= tempax) |
| 3935 | tempcx -= tempax; |
| 3936 | |
| 3937 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3938 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3939 | |
| 3940 | temp = (tempbx & 0xFF00) >> 8; |
| 3941 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3942 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3943 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3944 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3945 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3946 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3947 | if (pVBInfo->VGAVDE == 525) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3948 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 3949 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3950 | | VB_XGI301C)) { |
| 3951 | temp = 0xC6; |
| 3952 | } else |
| 3953 | temp = 0xC4; |
| 3954 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3955 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 3956 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3957 | } |
| 3958 | |
| 3959 | if (pVBInfo->VGAVDE == 420) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3960 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 3961 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3962 | | VB_XGI301C)) { |
| 3963 | temp = 0x4F; |
| 3964 | } else |
| 3965 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3966 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3967 | } |
| 3968 | } |
| 3969 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3970 | |
| 3971 | /* --------------------------------------------------------------------- */ |
| 3972 | /* Function : XGI_GetTap4Ptr */ |
| 3973 | /* Input : */ |
| 3974 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 3975 | /* Description : */ |
| 3976 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 3977 | static struct XGI301C_Tap4TimingStruct const |
| 3978 | *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3979 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3980 | unsigned short tempax, tempbx, i; |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 3981 | struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3982 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3983 | if (tempcx == 0) { |
| 3984 | tempax = pVBInfo->VGAHDE; |
| 3985 | tempbx = pVBInfo->HDE; |
| 3986 | } else { |
| 3987 | tempax = pVBInfo->VGAVDE; |
| 3988 | tempbx = pVBInfo->VDE; |
| 3989 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3990 | |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3991 | if (tempax <= tempbx) |
| 3992 | return &xgifb_tap4_timing[0]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3993 | else |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3994 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3995 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3996 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3997 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3998 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3999 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 4000 | if ((pVBInfo->TVInfo & TVSetYPbPr525i) || |
| 4001 | (pVBInfo->TVInfo & TVSetYPbPr525p)) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4002 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4003 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4004 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 4005 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4006 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4007 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 4008 | Tap4TimingPtr = xgifb_tap4_timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4009 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4010 | i = 0; |
| 4011 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 4012 | if (Tap4TimingPtr[i].DE == tempax) |
| 4013 | break; |
| 4014 | i++; |
| 4015 | } |
| 4016 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4017 | } |
| 4018 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4019 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4020 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4021 | unsigned short i, j; |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 4022 | struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4023 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4024 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 4025 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4026 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4027 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 4028 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4029 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4030 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4031 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4032 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4033 | /* Set Vertical Scaling */ |
| 4034 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4035 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4036 | xgifb_reg_set(pVBInfo->Part2Port, |
| 4037 | i, |
| 4038 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4039 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4040 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4041 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4042 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4043 | /* Enable V.Scaling */ |
| 4044 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4045 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4046 | /* Enable H.Scaling */ |
| 4047 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4048 | } |
| 4049 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4050 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4051 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4052 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4053 | unsigned short i; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 4054 | unsigned char const *tempdi; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4055 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4056 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4057 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4058 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4059 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4060 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4061 | if (pVBInfo->TVInfo & TVSetPAL) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4062 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 4063 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4064 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4065 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 4066 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4067 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4068 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4069 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4070 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4071 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4072 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4073 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 4074 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 4075 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4076 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4077 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4078 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo |
| 4079 | & SetCRT2ToYPbPr525750)) { |
| 4080 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4081 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4082 | |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4083 | tempdi = XGI330_HiTVGroup3Data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4084 | if (pVBInfo->SetFlag & TVSimuMode) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4085 | tempdi = XGI330_HiTVGroup3Simu; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4086 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4087 | tempdi = XGI330_HiTVGroup3Text; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4088 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4089 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4090 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4091 | tempdi = XGI330_Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4092 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4093 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4094 | tempdi = XGI330_Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4095 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4096 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4097 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4098 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4099 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4100 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4101 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4102 | } |
| 4103 | } |
| 4104 | return; |
| 4105 | } /* {end of XGI_SetGroup3} */ |
| 4106 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4107 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4108 | unsigned short RefreshRateTableIndex, |
| 4109 | struct xgi_hw_device_info *HwDeviceExtension, |
| 4110 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4111 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4112 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4113 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4114 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4115 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4116 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4117 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4118 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4119 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4120 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4121 | tempbx = pVBInfo->RVBHCMAX; |
| 4122 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4123 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4124 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 4125 | tempcx = pVBInfo->VGAHT - 1; |
| 4126 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4127 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4128 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4129 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 4130 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4131 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4132 | tempcx = pVBInfo->VGAVT - 1; |
| 4133 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4134 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4135 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4136 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4137 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4138 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4139 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4140 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4141 | tempcx = pVBInfo->VBInfo; |
| 4142 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4143 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4144 | if (modeflag & HalfDCLK) |
| 4145 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4146 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4147 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4148 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4149 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4150 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4151 | temp = 0; |
| 4152 | if (tempbx <= 1024) |
| 4153 | temp = 0xA0; |
| 4154 | if (tempbx == 1280) |
| 4155 | temp = 0xC0; |
| 4156 | } else if (tempcx & SetCRT2ToTV) { |
| 4157 | temp = 0xA0; |
| 4158 | if (tempbx <= 800) |
| 4159 | temp = 0x80; |
| 4160 | } else { |
| 4161 | temp = 0x80; |
| 4162 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4163 | temp = 0; |
| 4164 | if (tempbx > 800) |
| 4165 | temp = 0x60; |
| 4166 | } |
| 4167 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4168 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4169 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4170 | temp = 0x00; |
| 4171 | if (pVBInfo->VGAHDE == 1280) |
| 4172 | temp = 0x40; |
| 4173 | if (pVBInfo->VGAHDE == 1024) |
| 4174 | temp = 0x20; |
| 4175 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4176 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4177 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4178 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4179 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4180 | tempcx = pVBInfo->RVBHRS; |
| 4181 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4182 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
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 | tempeax = pVBInfo->VGAVDE; |
| 4185 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4186 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4187 | if (tempeax <= tempebx) { |
| 4188 | tempcx = (tempcx & (~0x4000)); |
| 4189 | tempeax = pVBInfo->VGAVDE; |
| 4190 | } else { |
| 4191 | tempeax -= tempebx; |
| 4192 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4193 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4194 | templong = (tempeax * 256 * 1024) % tempebx; |
| 4195 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 4196 | tempebx = tempeax; |
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 (templong != 0) |
| 4199 | tempebx++; |
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 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4202 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4203 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4204 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4205 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4206 | tempbx = (unsigned short) (tempebx >> 16); |
| 4207 | temp = tempbx & 0x00FF; |
| 4208 | temp = temp << 4; |
| 4209 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4210 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4211 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4212 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4213 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4214 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4215 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4216 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4217 | tempax = pVBInfo->VGAHDE; |
| 4218 | if (modeflag & HalfDCLK) |
| 4219 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4220 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4221 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4222 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4223 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4224 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4225 | if (tempax > 800) |
| 4226 | tempax -= 800; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 4227 | } else if (pVBInfo->VGAHDE > 800) { |
| 4228 | if (pVBInfo->VGAHDE == 1024) |
| 4229 | tempax = (tempax * 25 / 32) - 1; |
| 4230 | else |
| 4231 | tempax = (tempax * 20 / 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4232 | } |
| 4233 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4234 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4235 | temp = (tempax & 0xFF00) >> 8; |
| 4236 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4237 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4238 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4239 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4240 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4241 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4242 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4243 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4244 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4245 | } |
| 4246 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4247 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4248 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4249 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4250 | | TVSetYPbPr525p | TVSetYPbPr750p |
| 4251 | | TVSetHiVision))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4252 | temp |= 0x0001; |
| 4253 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 4254 | && (!(pVBInfo->TVInfo |
| 4255 | & TVSimuMode))) |
| 4256 | temp &= (~0x0001); |
| 4257 | } |
| 4258 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4259 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4260 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4261 | tempbx = pVBInfo->HT; |
| 4262 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4263 | tempbx = tempbx >> 1; |
| 4264 | tempbx = (tempbx >> 1) - 2; |
| 4265 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4266 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4267 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4268 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4269 | } |
| 4270 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4271 | |
Aaro Koskinen | 8951dad | 2012-09-11 00:15:30 +0300 | [diff] [blame] | 4272 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4273 | } |
| 4274 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4275 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 4276 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4277 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4278 | } |
| 4279 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4280 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4281 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4282 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4283 | if (pVBInfo->ModeType == ModeVGA) { |
| 4284 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4285 | | DisableCRT2Display))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4286 | XGINew_EnableCRT2(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4287 | } |
| 4288 | } |
| 4289 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4290 | } |
| 4291 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4292 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4293 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4294 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4295 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4296 | } |
| 4297 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4298 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4299 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4300 | { |
| 4301 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4302 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4303 | } |
| 4304 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4305 | static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, |
| 4306 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 4307 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4308 | { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4309 | unsigned short xres, yres, colordepth, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4310 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4311 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 4312 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4313 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4314 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4315 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4316 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4317 | if (!(modeflag & Charx8Dot)) { |
| 4318 | xres /= 9; |
| 4319 | xres *= 8; |
| 4320 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4321 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4322 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 4323 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4324 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4325 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 4326 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4327 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4328 | if (xres > xgifb_info->lvds_data.LVDSHDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4329 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4330 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4331 | if (yres > xgifb_info->lvds_data.LVDSVDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4332 | return 0; |
| 4333 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4334 | if (xres != xgifb_info->lvds_data.LVDSHDE || |
| 4335 | yres != xgifb_info->lvds_data.LVDSVDE) { |
| 4336 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
| 4337 | if (colordepth > 2) |
| 4338 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4339 | } |
| 4340 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4341 | } |
| 4342 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4343 | static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, |
| 4344 | int chip_id, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4345 | unsigned short ModeNo, |
| 4346 | unsigned short ModeIdIndex, |
| 4347 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4348 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4349 | unsigned char temp, Miscdata; |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4350 | unsigned short xres, yres, modeflag, resindex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4351 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 4352 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 4353 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4354 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4355 | temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4356 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4357 | temp &= LCDPolarity; |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 4358 | Miscdata = inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4359 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4360 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4361 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4362 | temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4363 | /* SR35[7] FP VSync polarity */ |
| 4364 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 4365 | /* SR30[5] FP HSync polarity */ |
| 4366 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4367 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4368 | if (chip_id == XG27) |
| 4369 | XGI_SetXG27FPBits(pVBInfo); |
| 4370 | else |
| 4371 | XGI_SetXG21FPBits(pVBInfo); |
| 4372 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4373 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 4374 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4375 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4376 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4377 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4378 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4379 | if (!(modeflag & Charx8Dot)) |
| 4380 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4381 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4382 | LVDSHT = xgifb_info->lvds_data.LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4383 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4384 | LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4385 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4386 | if (LVDSHBS > LVDSHT) |
| 4387 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4388 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4389 | LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4390 | if (LVDSHRS > LVDSHT) |
| 4391 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4392 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4393 | LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4394 | if (LVDSHRE > LVDSHT) |
| 4395 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4396 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4397 | LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4398 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4399 | LVDSVT = xgifb_info->lvds_data.LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4400 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4401 | LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4402 | if (modeflag & DoubleScanMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4403 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4404 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4405 | if (LVDSVBS > LVDSVT) |
| 4406 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4407 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4408 | LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4409 | if (LVDSVRS > LVDSVT) |
| 4410 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4411 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4412 | LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4413 | if (LVDSVRE > LVDSVT) |
| 4414 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4415 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4416 | LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4417 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 4418 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4419 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4420 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4421 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4422 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
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 | /* HT SR0B[1:0] CR00 */ |
| 4425 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4426 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4427 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4428 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4429 | /* HBS SR0B[5:4] CR02 */ |
| 4430 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4431 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4432 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4433 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4434 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 4435 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4436 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 4437 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 4438 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4439 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4440 | /* HRS SR0B[7:6] CR04 */ |
| 4441 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4442 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4443 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4444 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4445 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 4446 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4447 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4448 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4449 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4450 | /* HRE SR0C[2] CR05[4:0] */ |
| 4451 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4452 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 4453 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4454 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4455 | /* Panel HRE SR2F[7:2] */ |
| 4456 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4457 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4458 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4459 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 4460 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4461 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 4462 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 4463 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4464 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4465 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4466 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 4467 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4468 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 4469 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 4470 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4471 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4472 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4473 | /* VBE SR0A[4] CR16 */ |
| 4474 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4475 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4476 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4477 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4478 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 4479 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4480 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 4481 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 4482 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4483 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4484 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4485 | if (chip_id == XG27) { |
| 4486 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
| 4487 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, |
| 4488 | (value & 0x700) >> 8); |
| 4489 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
| 4490 | } else { |
| 4491 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
| 4492 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, |
| 4493 | (value & 0x600) >> 9); |
| 4494 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
| 4495 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
| 4496 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4497 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4498 | /* VRE SR0A[5] CR11[3:0] */ |
| 4499 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4500 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 4501 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4502 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4503 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4504 | if (chip_id == XG27) |
| 4505 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4506 | (value << 2) & 0xFC); |
| 4507 | else |
| 4508 | /* SR3F[7] has to be 0, h/w bug */ |
| 4509 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4510 | (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4511 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4512 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4513 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4514 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4515 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4516 | 0x2B, xgifb_info->lvds_data.VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4517 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4518 | 0x2C, xgifb_info->lvds_data.VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4519 | value += 0x10; |
| 4520 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4521 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4522 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4523 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4524 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4525 | /* set data, panning = 0, shift left 1 dot*/ |
| 4526 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4527 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4528 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4529 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4530 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4531 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4532 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4533 | |
| 4534 | } |
| 4535 | |
| 4536 | /* --------------------------------------------------------------------- */ |
| 4537 | /* Function : XGI_IsLCDON */ |
| 4538 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4539 | /* Output : 0 : Skip PSC Control */ |
| 4540 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4541 | /* Description : */ |
| 4542 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4543 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4544 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4545 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4546 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4547 | tempax = pVBInfo->VBInfo; |
| 4548 | if (tempax & SetCRT2ToDualEdge) |
| 4549 | return 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4550 | else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4551 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4552 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4553 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4554 | } |
| 4555 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4556 | /* --------------------------------------------------------------------- */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4557 | /* Function : XGI_EnableChISLCD */ |
| 4558 | /* Input : */ |
| 4559 | /* Output : 0 -> Not LCD mode */ |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 4560 | /* Description : if bool enable = true -> enable, else disable */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4561 | /* --------------------------------------------------------------------- */ |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 4562 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo, |
| 4563 | bool enable) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4564 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4565 | unsigned short tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4566 | |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 4567 | if (enable) |
| 4568 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
| 4569 | else |
| 4570 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
| 4571 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4572 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4573 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4574 | if (tempbx & (EnableChA | DisableChA)) { |
| 4575 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ |
| 4576 | return 0; |
| 4577 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4578 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4579 | if (!(tempbx & (EnableChB | DisableChB))) |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4580 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4581 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4582 | if (tempah & 0x01) /* Chk LCDB Mode */ |
| 4583 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4584 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4585 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4586 | } |
| 4587 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4588 | static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, |
| 4589 | struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4590 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4591 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 4592 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4593 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4594 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4595 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4596 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4597 | if (!(pVBInfo->VBInfo & |
| 4598 | (DisableCRT2Display | SetSimuScanMode))) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4599 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4600 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 4601 | tempah = 0x7F; /* Disable Channel A */ |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4602 | if (!(pVBInfo->VBInfo & |
| 4603 | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4604 | /* Disable Channel B */ |
| 4605 | tempah = 0xBF; |
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 | if (pVBInfo->SetFlag & DisableChB) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4608 | /* force to disable Cahnnel */ |
| 4609 | tempah &= 0xBF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4610 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4611 | if (pVBInfo->SetFlag & DisableChA) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4612 | /* Force to disable Channel B */ |
| 4613 | tempah &= 0x7F; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4614 | } |
| 4615 | } |
| 4616 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4617 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4618 | /* disable part4_1f */ |
| 4619 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4620 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4621 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4622 | if (((pVBInfo->VBInfo & |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 4623 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) || |
| 4624 | (XGI_EnableChISLCD(pVBInfo, false)) || |
| 4625 | (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4626 | /* LVDS Driver power down */ |
| 4627 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4628 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4629 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4630 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4631 | & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4632 | | SetSimuScanMode))) { |
| 4633 | if (pVBInfo->SetFlag & GatingCRT) |
| 4634 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4635 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4636 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4637 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4638 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4639 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4640 | & XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4641 | /* Power down */ |
| 4642 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4643 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4644 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4645 | /* disable TV as primary VGA swap */ |
| 4646 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4647 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4648 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 4649 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4650 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4651 | if ((pVBInfo->SetFlag & DisableChB) || |
| 4652 | (pVBInfo->VBInfo & |
| 4653 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4654 | ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4655 | (pVBInfo->VBInfo & |
| 4656 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4657 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4658 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4659 | if ((pVBInfo->SetFlag & DisableChB) || |
| 4660 | (pVBInfo->VBInfo & |
| 4661 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4662 | (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) || |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4663 | (pVBInfo->VBInfo & |
| 4664 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 4665 | /* save Part1 index 0 */ |
| 4666 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 4667 | /* BTDAC = 1, avoid VB reset */ |
| 4668 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 4669 | /* disable CRT2 */ |
| 4670 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4671 | /* restore Part1 index 0 */ |
| 4672 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4673 | } |
| 4674 | } else { /* {301} */ |
| 4675 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4676 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 4677 | /* Disable CRT2 */ |
| 4678 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4679 | /* Disable TV asPrimary VGA swap */ |
| 4680 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4681 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4682 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4683 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4684 | | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4685 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4686 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4687 | } |
| 4688 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4689 | /* --------------------------------------------------------------------- */ |
| 4690 | /* Function : XGI_GetTVPtrIndex */ |
| 4691 | /* Input : */ |
| 4692 | /* Output : */ |
| 4693 | /* Description : bx 0 : ExtNTSC */ |
| 4694 | /* 1 : StNTSC */ |
| 4695 | /* 2 : ExtPAL */ |
| 4696 | /* 3 : StPAL */ |
| 4697 | /* 4 : ExtHiTV */ |
| 4698 | /* 5 : StHiTV */ |
| 4699 | /* 6 : Ext525i */ |
| 4700 | /* 7 : St525i */ |
| 4701 | /* 8 : Ext525p */ |
| 4702 | /* 9 : St525p */ |
| 4703 | /* A : Ext750p */ |
| 4704 | /* B : St750p */ |
| 4705 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4706 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4707 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4708 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4709 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4710 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4711 | tempbx = 2; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4712 | if (pVBInfo->TVInfo & TVSetHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4713 | tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4714 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4715 | tempbx = 6; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4716 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4717 | tempbx = 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4718 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4719 | tempbx = 10; |
| 4720 | if (pVBInfo->TVInfo & TVSimuMode) |
| 4721 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4722 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4723 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4724 | } |
| 4725 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4726 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4727 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4728 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4729 | /* Output : bx 0 : NTSC */ |
| 4730 | /* 1 : PAL */ |
| 4731 | /* 2 : PALM */ |
| 4732 | /* 3 : PALN */ |
| 4733 | /* 4 : NTSC1024x768 */ |
| 4734 | /* 5 : PAL-M 1024x768 */ |
| 4735 | /* 6-7: reserved */ |
| 4736 | /* cl 0 : YFilter1 */ |
| 4737 | /* 1 : YFilter2 */ |
| 4738 | /* ch 0 : 301A */ |
| 4739 | /* 1 : 301B/302B/301LV/302LV */ |
| 4740 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4741 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4742 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 4743 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4744 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4745 | *tempbx = 0; |
| 4746 | *tempcl = 0; |
| 4747 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4748 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4749 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4750 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4751 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4752 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4753 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4754 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4755 | if (pVBInfo->TVInfo & TVSetPALN) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4756 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4757 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4758 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 4759 | *tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4760 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4761 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4762 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4763 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4764 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4765 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4766 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 4767 | & TVSimuMode)) { |
| 4768 | *tempbx += 8; |
| 4769 | *tempcl += 1; |
| 4770 | } |
| 4771 | } |
| 4772 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4773 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4774 | | VB_SIS302LV | VB_XGI301C)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4775 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4776 | } |
| 4777 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4778 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4779 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4780 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4781 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4782 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4783 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4784 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4785 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4786 | tempbh = 0; |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 4787 | tempbl = XGI301TVDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4788 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4789 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 4790 | tempbl = tempbl >> 4; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4791 | if (pVBInfo->VBInfo & |
| 4792 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 4793 | tempbh = XGI301LCDDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4794 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4795 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4796 | tempbl = tempbh; |
| 4797 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4798 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4799 | tempbl &= 0x0F; |
| 4800 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4801 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4802 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4803 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 4804 | | SetCRT2ToTV)) { /* Channel B */ |
| 4805 | tempah &= 0xF0; |
| 4806 | tempah |= tempbl; |
| 4807 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4808 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4809 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 4810 | /* Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4811 | tempah &= 0x0F; |
| 4812 | tempah |= tempbh; |
| 4813 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4814 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4815 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4816 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4817 | } |
| 4818 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4819 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 4820 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4821 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4822 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4823 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4824 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4825 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4826 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4827 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4828 | /* Enable Dither */ |
| 4829 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4830 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4831 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4832 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4833 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4834 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4835 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4836 | } |
| 4837 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4838 | /* --------------------------------------------------------------------- */ |
| 4839 | /* Function : XGI_SetLCDCap_B */ |
| 4840 | /* Input : cx -> LCD Capability */ |
| 4841 | /* Output : */ |
| 4842 | /* Description : */ |
| 4843 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4844 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 4845 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4846 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4847 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4848 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4849 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 4850 | | 0x0c)); |
| 4851 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4852 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4853 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 4854 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4855 | } |
| 4856 | |
Aaro Koskinen | 7f04ec3 | 2011-11-27 23:03:05 +0200 | [diff] [blame] | 4857 | static void XGI_LongWait(struct vb_device_info *pVBInfo) |
| 4858 | { |
| 4859 | unsigned short i; |
| 4860 | |
| 4861 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
| 4862 | |
| 4863 | if (!(i & 0xC0)) { |
| 4864 | for (i = 0; i < 0xFFFF; i++) { |
| 4865 | if (!(inb(pVBInfo->P3da) & 0x08)) |
| 4866 | break; |
| 4867 | } |
| 4868 | |
| 4869 | for (i = 0; i < 0xFFFF; i++) { |
| 4870 | if ((inb(pVBInfo->P3da) & 0x08)) |
| 4871 | break; |
| 4872 | } |
| 4873 | } |
| 4874 | } |
| 4875 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4876 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4877 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4878 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4879 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4880 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4881 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4882 | /* disable down spectrum D[4] */ |
| 4883 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4884 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4885 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4886 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4887 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4888 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4889 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4890 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4891 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4892 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4893 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4894 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4895 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 4896 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4897 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4898 | } |
| 4899 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4900 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 4901 | { |
| 4902 | unsigned short tempcx; |
| 4903 | |
| 4904 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 4905 | |
Peter Huewe | f951dd0 | 2013-02-05 00:29:47 +0100 | [diff] [blame] | 4906 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | |
| 4907 | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4908 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4909 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4910 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4911 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4912 | (unsigned char) (tempcx & 0x1F)); |
| 4913 | } |
| 4914 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4915 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4916 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 4917 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 4918 | | EnablePLLSPLOW)) >> 8)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4919 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4920 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 4921 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4922 | else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4923 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 4924 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4925 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4926 | if (tempcx & EnableSpectrum) |
| 4927 | SetSpectrum(pVBInfo); |
| 4928 | } |
| 4929 | } else { |
| 4930 | /* LVDS,CH7017 */ |
| 4931 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 4932 | } |
| 4933 | } |
| 4934 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4935 | /* --------------------------------------------------------------------- */ |
| 4936 | /* Function : XGI_SetAntiFlicker */ |
| 4937 | /* Input : */ |
| 4938 | /* Output : */ |
| 4939 | /* Description : Set TV Customized Param. */ |
| 4940 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4941 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
| 4942 | unsigned short ModeIdIndex, |
| 4943 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4944 | { |
Aaro Koskinen | 36ae035 | 2012-04-07 01:14:08 +0300 | [diff] [blame] | 4945 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4946 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4947 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4948 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4949 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4950 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4951 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4952 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 4953 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4954 | tempah = TVAntiFlickList[tempbx]; |
| 4955 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4956 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4957 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4958 | } |
| 4959 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4960 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
| 4961 | unsigned short ModeIdIndex, |
| 4962 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4963 | { |
Aaro Koskinen | 354f49f | 2012-04-07 01:14:09 +0300 | [diff] [blame] | 4964 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4965 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4966 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4967 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4968 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 4969 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4970 | tempah = TVEdgeList[tempbx]; |
| 4971 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4972 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4973 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4974 | } |
| 4975 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4976 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4977 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4978 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4979 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4980 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4981 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4982 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4983 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4984 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 4985 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4986 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4987 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4988 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4989 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4990 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4991 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4992 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4993 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4994 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4995 | } |
| 4996 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4997 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4998 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4999 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5000 | unsigned short tempbx, index; |
Aaro Koskinen | a68292f | 2012-11-04 21:15:07 +0200 | [diff] [blame] | 5001 | unsigned char const *filterPtr; |
| 5002 | unsigned char tempcl, tempch, tempal; |
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 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5005 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5006 | switch (tempbx) { |
| 5007 | case 0x00: |
| 5008 | case 0x04: |
| 5009 | filterPtr = NTSCYFilter1; |
| 5010 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5011 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5012 | case 0x01: |
| 5013 | filterPtr = PALYFilter1; |
| 5014 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5015 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5016 | case 0x02: |
| 5017 | case 0x05: |
| 5018 | case 0x0D: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5019 | case 0x03: |
Aaro Koskinen | 2555e94 | 2011-08-31 21:46:06 +0300 | [diff] [blame] | 5020 | filterPtr = xgifb_palmn_yfilter1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5021 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5022 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5023 | case 0x08: |
| 5024 | case 0x0C: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5025 | case 0x0A: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5026 | case 0x0B: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5027 | case 0x09: |
Aaro Koskinen | 80f86f8 | 2011-08-31 21:46:05 +0300 | [diff] [blame] | 5028 | filterPtr = xgifb_yfilter2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5029 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5030 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5031 | default: |
| 5032 | return; |
| 5033 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5034 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5035 | tempal = XGI330_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5036 | if (tempcl == 0) |
| 5037 | index = tempal * 4; |
| 5038 | else |
| 5039 | index = tempal * 7; |
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 ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5042 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 5043 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 5044 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 5045 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5046 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5047 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 5048 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 5049 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 5050 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5051 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5052 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5053 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5054 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5055 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 5056 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 5057 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5058 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5059 | } |
| 5060 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5061 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5062 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5063 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5064 | /* Output : */ |
| 5065 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5066 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5067 | static void XGI_OEM310Setting(unsigned short ModeNo, |
| 5068 | unsigned short ModeIdIndex, |
| 5069 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5070 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5071 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5072 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5073 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5074 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5075 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5076 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5077 | XGI_SetPhaseIncr(pVBInfo); |
| 5078 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); |
| 5079 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5080 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5081 | if (pVBInfo->VBType & VB_SIS301) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5082 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5083 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5084 | } |
| 5085 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5086 | /* --------------------------------------------------------------------- */ |
| 5087 | /* Function : XGI_SetCRT2ModeRegs */ |
| 5088 | /* Input : */ |
| 5089 | /* Output : */ |
| 5090 | /* Description : Origin code for crt2group */ |
| 5091 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5092 | static void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5093 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5094 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5095 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5096 | unsigned short tempbl; |
| 5097 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5098 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5099 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5100 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5101 | tempah = 0; |
| 5102 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5103 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5104 | tempah &= ~0x10; /* BTRAMDAC */ |
| 5105 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5106 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5107 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 5108 | | SetCRT2ToLCD)) { |
| 5109 | tempah = 0x40; /* BTDRAM */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5110 | tempcl = pVBInfo->ModeType; |
| 5111 | tempcl -= ModeVGA; |
| 5112 | if (tempcl >= 0) { |
| 5113 | /* BT Color */ |
| 5114 | tempah = (0x008 >> tempcl); |
| 5115 | if (tempah == 0) |
| 5116 | tempah = 1; |
| 5117 | tempah |= 0x040; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5118 | } |
| 5119 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 5120 | tempah ^= 0x50; /* BTDAC */ |
| 5121 | } |
| 5122 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5123 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5124 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5125 | tempah = 0x08; |
| 5126 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5127 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5128 | if (pVBInfo->VBInfo & DisableCRT2Display) |
| 5129 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5130 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5131 | tempah = 0x00; |
| 5132 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5133 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5134 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
| 5135 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 5136 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5137 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5138 | if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 5139 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
| 5140 | tempbl &= 0xf7; |
| 5141 | tempah |= 0x01; |
| 5142 | goto reg_and_or; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5143 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5144 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 5145 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 5146 | tempbl &= 0xf7; |
| 5147 | tempah |= 0x01; |
| 5148 | } |
| 5149 | |
| 5150 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD))) |
| 5151 | goto reg_and_or; |
| 5152 | |
| 5153 | tempbl &= 0xf8; |
| 5154 | tempah = 0x01; |
| 5155 | |
| 5156 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 5157 | tempah |= 0x02; |
| 5158 | |
| 5159 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5160 | tempah = tempah ^ 0x05; |
| 5161 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5162 | tempah = tempah ^ 0x01; |
| 5163 | } |
| 5164 | |
| 5165 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5166 | tempah |= 0x08; |
| 5167 | |
| 5168 | reg_and_or: |
| 5169 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
| 5170 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5171 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5172 | | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5173 | tempah &= (~0x08); |
| 5174 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 5175 | & SetInSlaveMode))) { |
| 5176 | tempah |= 0x010; |
| 5177 | } |
| 5178 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5179 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5180 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5181 | tempah |= 0x020; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5182 | if (pVBInfo->VBInfo & DriverMode) |
| 5183 | tempah = tempah ^ 0x20; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5184 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5185 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5186 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5187 | tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5188 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5189 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 5190 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5191 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5192 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5193 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 5194 | tempah |= 0x40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5195 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5196 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5197 | if ((pVBInfo->LCDResInfo == Panel_1280x1024) |
| 5198 | || (pVBInfo->LCDResInfo == Panel_1280x1024x75)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5199 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5200 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5201 | if (pVBInfo->LCDResInfo == Panel_1280x960) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5202 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5203 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5204 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5205 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5206 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5207 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5208 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5209 | tempah = 0; |
| 5210 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5211 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5212 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 5213 | tempbl = 0xff; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5214 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5215 | tempah |= 0x04; /* shampoo 0129 */ |
| 5216 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5217 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5218 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5219 | tempah = 0x00; |
| 5220 | tempbl = 0xcf; |
| 5221 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5222 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5223 | tempah |= 0x30; |
| 5224 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5225 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5226 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5227 | tempah = 0; |
| 5228 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5229 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5230 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5231 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5232 | tempah |= 0xc0; |
| 5233 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5234 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5235 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5236 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5237 | tempah = 0; |
| 5238 | tempbl = 0x7f; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5239 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5240 | tempbl = 0xff; |
| 5241 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5242 | tempah |= 0x80; |
| 5243 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5244 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5245 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5246 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5247 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5248 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5249 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 5250 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5251 | } |
| 5252 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5253 | } |
| 5254 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5255 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5256 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 5257 | struct vb_device_info *pVBInfo) |
| 5258 | { |
| 5259 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5260 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5261 | |
| 5262 | } |
| 5263 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5264 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
| 5265 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5266 | { |
| 5267 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5268 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5269 | |
| 5270 | } |
| 5271 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5272 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 5273 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5274 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5275 | { |
Peter Huewe | f2c2260 | 2013-02-03 22:54:30 +0100 | [diff] [blame] | 5276 | const u8 LCDARefreshIndex[] = { |
| 5277 | 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5278 | |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 5279 | unsigned short RefreshRateTableIndex, i, index, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5280 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5281 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5282 | index = index >> pVBInfo->SelectCRT2Rate; |
| 5283 | index &= 0x0F; |
| 5284 | |
| 5285 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 5286 | index = 0; |
| 5287 | |
| 5288 | if (index > 0) |
| 5289 | index--; |
| 5290 | |
| 5291 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5292 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5293 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Peter Huewe | f2c2260 | 2013-02-03 22:54:30 +0100 | [diff] [blame] | 5294 | temp = LCDARefreshIndex[ |
| 5295 | pVBInfo->LCDResInfo & 0x07]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5296 | |
| 5297 | if (index > temp) |
| 5298 | index = temp; |
| 5299 | } else { |
| 5300 | index = 0; |
| 5301 | } |
| 5302 | } |
| 5303 | } |
| 5304 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5305 | RefreshRateTableIndex = XGI330_EModeIDTable[ModeIdIndex].REFindex; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5306 | ModeNo = XGI330_RefIndex[RefreshRateTableIndex].ModeID; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5307 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5308 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 5309 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5310 | index++; |
| 5311 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5312 | /* do the similar adjustment like XGISearchCRT1Rate() */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5313 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 5314 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5315 | index++; |
| 5316 | } |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5317 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 5318 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5319 | index++; |
| 5320 | } |
| 5321 | } |
| 5322 | |
| 5323 | i = 0; |
| 5324 | do { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5325 | if (XGI330_RefIndex[RefreshRateTableIndex + i]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5326 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5327 | break; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5328 | temp = XGI330_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5329 | temp &= ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5330 | if (temp < pVBInfo->ModeType) |
| 5331 | break; |
| 5332 | i++; |
| 5333 | index--; |
| 5334 | |
| 5335 | } while (index != 0xFFFF); |
| 5336 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5337 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5338 | temp = XGI330_RefIndex[RefreshRateTableIndex + i - 1]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5339 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5340 | if (temp & InterlaceMode) |
| 5341 | i++; |
| 5342 | } |
| 5343 | } |
| 5344 | i--; |
| 5345 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
| 5346 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, |
| 5347 | RefreshRateTableIndex, &i, pVBInfo); |
| 5348 | } |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 5349 | return RefreshRateTableIndex + i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5350 | } |
| 5351 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5352 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5353 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5354 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5355 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5356 | unsigned short RefreshRateTableIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5357 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5358 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5359 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5360 | ModeIdIndex, pVBInfo); |
| 5361 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5362 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5363 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5364 | HwDeviceExtension, pVBInfo); |
| 5365 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5366 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5367 | } |
| 5368 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5369 | static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5370 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5371 | struct vb_device_info *pVBInfo) |
| 5372 | { |
Peter Huewe | a9e29e6 | 2013-02-03 04:08:44 +0100 | [diff] [blame] | 5373 | unsigned short ModeIdIndex, RefreshRateTableIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5374 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5375 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5376 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 5377 | pVBInfo->SelectCRT2Rate = 4; |
| 5378 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5379 | ModeIdIndex, pVBInfo); |
| 5380 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
| 5381 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5382 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5383 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5384 | RefreshRateTableIndex, pVBInfo); |
| 5385 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5386 | RefreshRateTableIndex, pVBInfo); |
| 5387 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5388 | RefreshRateTableIndex, pVBInfo); |
| 5389 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5390 | HwDeviceExtension, pVBInfo); |
| 5391 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5392 | RefreshRateTableIndex, pVBInfo); |
| 5393 | XGI_SetTap4Regs(pVBInfo); |
| 5394 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); |
| 5395 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5396 | HwDeviceExtension, pVBInfo); |
| 5397 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5398 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); |
| 5399 | XGI_AutoThreshold(pVBInfo); |
| 5400 | return 1; |
| 5401 | } |
| 5402 | |
| 5403 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 5404 | { |
| 5405 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 5406 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 5407 | 0x05, 0x00 }; |
| 5408 | |
| 5409 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 5410 | |
| 5411 | unsigned char CR17, CR63, SR31; |
| 5412 | unsigned short temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5413 | |
| 5414 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5415 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5416 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5417 | /* to fix XG42 single LCD sense to CRT+LCD */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5418 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5419 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5420 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 5421 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5422 | SR31 = xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 5423 | CR63 = xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 5424 | SR01 = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5425 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5426 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 5427 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5428 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5429 | CR17 = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5430 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5431 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5432 | SR1F = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5433 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5434 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5435 | SR07 = xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5436 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5437 | SR06 = xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5438 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5439 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5440 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5441 | |
| 5442 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5443 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5444 | |
| 5445 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5446 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5447 | CRTCData[i]); |
| 5448 | |
| 5449 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5450 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5451 | CRTCData[i]); |
| 5452 | |
| 5453 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5454 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5455 | CRTCData[i]); |
| 5456 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5457 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5458 | & 0xE0)); |
| 5459 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5460 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 5461 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 5462 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5463 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5464 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5465 | |
Peter Huewe | 771f3ee | 2013-02-15 20:37:13 +0100 | [diff] [blame] | 5466 | for (i = 0; i < 256 * 3; i++) { |
| 5467 | outb(0x0F, (pVBInfo->P3c8 + 1)); /* DAC_TEST_PARMS */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5468 | } |
| 5469 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5470 | mdelay(1); |
| 5471 | |
| 5472 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5473 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5474 | |
| 5475 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5476 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5477 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5478 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5479 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5480 | /* avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5481 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5482 | |
Peter Huewe | 771f3ee | 2013-02-15 20:37:13 +0100 | [diff] [blame] | 5483 | for (i = 0; i < 256 * 3; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5484 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5485 | } |
| 5486 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5487 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 5488 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 5489 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5490 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5491 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5492 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5493 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5494 | } |
| 5495 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5496 | static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, |
| 5497 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5498 | struct vb_device_info *pVBInfo) |
| 5499 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 5500 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5501 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5502 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5503 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5504 | if (!(pVBInfo->SetFlag & DisableChA)) { |
Peter Huewe | 66b43eb | 2013-02-15 20:37:09 +0100 | [diff] [blame] | 5505 | if ((pVBInfo->SetFlag & EnableChA) || |
| 5506 | (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5507 | /* Power on */ |
| 5508 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5509 | } |
| 5510 | } |
| 5511 | |
| 5512 | if (!(pVBInfo->SetFlag & DisableChB)) { |
| 5513 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo |
| 5514 | & (SetCRT2ToLCD | SetCRT2ToTV |
| 5515 | | SetCRT2ToRAMDAC))) { |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5516 | tempah = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5517 | tempah &= 0xDF; |
| 5518 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5519 | if (!(pVBInfo->VBInfo & |
| 5520 | SetCRT2ToRAMDAC)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5521 | tempah |= 0x20; |
| 5522 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5523 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5524 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5525 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5526 | tempah = xgifb_reg_get(pVBInfo->Part1Port, |
| 5527 | 0x2E); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5528 | |
| 5529 | if (!(tempah & 0x80)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5530 | xgifb_reg_or(pVBInfo->Part1Port, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5531 | 0x2E, 0x80); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5532 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5533 | } |
| 5534 | } |
| 5535 | |
| 5536 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
| 5537 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5538 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5539 | 0x20); /* shampoo 0129 */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5540 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 5541 | if (!XGI_EnableChISLCD(pVBInfo, false)) { |
| 5542 | if (XGI_EnableChISLCD(pVBInfo, true) || |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5543 | (pVBInfo->VBInfo & |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5544 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5545 | /* LVDS PLL power on */ |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5546 | xgifb_reg_and( |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5547 | pVBInfo->Part4Port, |
| 5548 | 0x2A, |
| 5549 | 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5550 | } |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5551 | /* LVDS Driver power on */ |
| 5552 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5553 | } |
| 5554 | } |
| 5555 | |
| 5556 | tempah = 0x00; |
| 5557 | |
| 5558 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5559 | tempah = 0xc0; |
| 5560 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5561 | if (!(pVBInfo->VBInfo & SetSimuScanMode) && |
| 5562 | (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 5563 | (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { |
| 5564 | tempah = tempah & 0x40; |
| 5565 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
| 5566 | tempah = tempah ^ 0xC0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5567 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5568 | if (pVBInfo->SetFlag & DisableChB) |
| 5569 | tempah &= 0xBF; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5570 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5571 | if (pVBInfo->SetFlag & DisableChA) |
| 5572 | tempah &= 0x7F; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5573 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5574 | if (pVBInfo->SetFlag & EnableChB) |
| 5575 | tempah |= 0x40; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5576 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5577 | if (pVBInfo->SetFlag & EnableChA) |
| 5578 | tempah |= 0x80; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5579 | } |
| 5580 | } |
| 5581 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5582 | /* EnablePart4_1F */ |
| 5583 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5584 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5585 | if (!(pVBInfo->SetFlag & DisableChA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5586 | if (!(pVBInfo->SetFlag & GatingCRT)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5587 | XGI_DisableGatingCRT(HwDeviceExtension, |
| 5588 | pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5589 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, |
| 5590 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5591 | } |
| 5592 | } |
| 5593 | } /* 301 */ |
| 5594 | else { /* LVDS */ |
| 5595 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5596 | | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5597 | /* enable CRT2 */ |
| 5598 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5599 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5600 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5601 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5602 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5603 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5604 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5605 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5606 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5607 | } |
| 5608 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5609 | static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, |
| 5610 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5611 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5612 | struct vb_device_info *pVBInfo) |
| 5613 | { |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5614 | unsigned short RefreshRateTableIndex, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5615 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5616 | XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 5617 | outb(XGI330_StandTable.MISC, pVBInfo->P3c2); |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5618 | XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo); |
| 5619 | XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo); |
| 5620 | XGI_SetGRCRegs(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5621 | XGI_ClearExt1Regs(pVBInfo); |
| 5622 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5623 | if (HwDeviceExtension->jChipType == XG27) { |
| 5624 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 5625 | XGI_SetDefaultVCLK(pVBInfo); |
| 5626 | } |
| 5627 | |
| 5628 | temp = ~ProgrammingCRT2; |
| 5629 | pVBInfo->SetFlag &= temp; |
| 5630 | pVBInfo->SelectCRT2Rate = 0; |
| 5631 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5632 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5633 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5634 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5635 | | SetInSlaveMode)) { |
| 5636 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5637 | } |
| 5638 | } |
| 5639 | |
| 5640 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5641 | ModeIdIndex, pVBInfo); |
| 5642 | if (RefreshRateTableIndex != 0xFFFF) { |
| 5643 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
| 5644 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5645 | pVBInfo, HwDeviceExtension); |
| 5646 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 5647 | RefreshRateTableIndex, pVBInfo); |
| 5648 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5649 | HwDeviceExtension, pVBInfo); |
| 5650 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, |
| 5651 | RefreshRateTableIndex, pVBInfo); |
| 5652 | } |
| 5653 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5654 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5655 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5656 | if (temp & 0xA0) { |
| 5657 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5658 | if (HwDeviceExtension->jChipType == XG27) |
| 5659 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, |
| 5660 | RefreshRateTableIndex, pVBInfo); |
| 5661 | else |
| 5662 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, |
| 5663 | RefreshRateTableIndex, pVBInfo); |
| 5664 | |
| 5665 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 5666 | RefreshRateTableIndex); |
| 5667 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 5668 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
| 5669 | pVBInfo, RefreshRateTableIndex, ModeNo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5670 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5671 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5672 | xgifb_set_lvds(xgifb_info, |
| 5673 | HwDeviceExtension->jChipType, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5674 | ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5675 | } |
| 5676 | } |
| 5677 | |
| 5678 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
| 5679 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); |
| 5680 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, |
| 5681 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5682 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5683 | } |
| 5684 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5685 | unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, |
| 5686 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5687 | unsigned short ModeNo) |
| 5688 | { |
| 5689 | unsigned short ModeIdIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5690 | struct vb_device_info VBINF; |
| 5691 | struct vb_device_info *pVBInfo = &VBINF; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5692 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5693 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5694 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5695 | pVBInfo->IF_DEF_YPbPr = 0; |
| 5696 | pVBInfo->IF_DEF_HiVision = 0; |
| 5697 | pVBInfo->IF_DEF_CRT2Monitor = 0; |
| 5698 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5699 | } else { |
| 5700 | pVBInfo->IF_DEF_YPbPr = 1; |
| 5701 | pVBInfo->IF_DEF_HiVision = 1; |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 5702 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5703 | } |
| 5704 | |
Aaro Koskinen | 56810a9 | 2013-01-21 02:57:47 +0200 | [diff] [blame] | 5705 | XGIRegInit(pVBInfo, xgifb_info->vga_base); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5706 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5707 | /* for x86 Linux, XG21 LVDS */ |
| 5708 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5709 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5710 | pVBInfo->IF_DEF_LVDS = 1; |
| 5711 | } |
| 5712 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5713 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 5714 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5715 | pVBInfo->IF_DEF_LVDS = 1; |
| 5716 | } |
| 5717 | } |
| 5718 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5719 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
Aaro Koskinen | ef497f4 | 2011-11-27 23:03:21 +0200 | [diff] [blame] | 5720 | if (ModeNo & 0x80) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5721 | ModeNo = ModeNo & 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5722 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5723 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5724 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5725 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
| 5726 | |
| 5727 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 5728 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5729 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5730 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 5731 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); |
| 5732 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5733 | XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5734 | |
Peter Huewe | e44adfd | 2013-02-03 22:54:39 +0100 | [diff] [blame] | 5735 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA) || |
| 5736 | (!(pVBInfo->VBInfo & SwitchCRT2))) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5737 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5738 | ModeIdIndex, pVBInfo); |
| 5739 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5740 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5741 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 5742 | HwDeviceExtension, pVBInfo); |
| 5743 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5744 | } |
| 5745 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5746 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5747 | switch (HwDeviceExtension->ujVBChipID) { |
Peter Huewe | e44adfd | 2013-02-03 22:54:39 +0100 | [diff] [blame] | 5748 | case VB_CHIP_301: /* fall through */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5749 | case VB_CHIP_302: |
| 5750 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 5751 | pVBInfo); /*add for CRT2 */ |
| 5752 | break; |
| 5753 | |
| 5754 | default: |
| 5755 | break; |
| 5756 | } |
| 5757 | } |
| 5758 | |
| 5759 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
| 5760 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5761 | XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5762 | } /* !XG20 */ |
| 5763 | else { |
| 5764 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5765 | if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5766 | ModeIdIndex, |
| 5767 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5768 | return 0; |
| 5769 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5770 | pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex]. |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5771 | Ext_ModeFlag & ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5772 | |
| 5773 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 5774 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5775 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5776 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5777 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5778 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
| 5779 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5780 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5781 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5782 | } |
| 5783 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5784 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
| 5785 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 5786 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5787 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5788 | |
| 5789 | return 1; |
| 5790 | } |