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 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 66 | static void XGI_SetSeqRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 67 | { |
Peter Huewe | 76a5899 | 2013-02-03 22:54:34 +0100 | [diff] [blame] | 68 | unsigned char SRdata, i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 69 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 70 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 71 | |
Peter Huewe | 76a5899 | 2013-02-03 22:54:34 +0100 | [diff] [blame] | 72 | for (i = 0; i < 4; i++) { |
| 73 | /* Get SR1,2,3,4 from file */ |
| 74 | /* SR1 is with screen off 0x20 */ |
| 75 | SRdata = XGI330_StandTable.SR[i]; |
| 76 | 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] | 77 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 78 | } |
| 79 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 80 | static void XGI_SetCRTCRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 81 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 82 | unsigned char CRTCdata; |
| 83 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 84 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 85 | CRTCdata = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 86 | CRTCdata &= 0x7f; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 87 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 88 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 89 | for (i = 0; i <= 0x18; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 90 | /* Get CRTC from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 91 | CRTCdata = XGI330_StandTable.CRTC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 92 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 93 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 94 | } |
| 95 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 96 | static void XGI_SetATTRegs(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 97 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 98 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 99 | unsigned char ARdata; |
| 100 | unsigned short i, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 101 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 102 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 103 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 104 | for (i = 0; i <= 0x13; i++) { |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 105 | ARdata = XGI330_StandTable.ATTR[i]; |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 106 | |
| 107 | if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */ |
| 108 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 109 | ARdata = 0; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 110 | } else if ((pVBInfo->VBInfo & |
Miguel Gómez | 661a638 | 2012-07-06 12:40:45 +0200 | [diff] [blame] | 111 | (SetCRT2ToTV | SetCRT2ToLCD)) && |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 112 | (pVBInfo->VBInfo & SetInSlaveMode)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 113 | ARdata = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 114 | } |
| 115 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 116 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 117 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 118 | outb(i, pVBInfo->P3c0); /* set index */ |
| 119 | outb(ARdata, pVBInfo->P3c0); /* set data */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 120 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 121 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 122 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 123 | outb(0x14, pVBInfo->P3c0); /* set index */ |
| 124 | outb(0x00, pVBInfo->P3c0); /* set data */ |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 125 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 126 | outb(0x20, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 127 | } |
| 128 | |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 129 | static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 130 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 131 | unsigned char GRdata; |
| 132 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 133 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 134 | for (i = 0; i <= 0x08; i++) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 135 | /* Get GR from file */ |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 136 | GRdata = XGI330_StandTable.GRC[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 137 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 138 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 139 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 140 | if (pVBInfo->ModeType > ModeVGA) { |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 141 | GRdata = xgifb_reg_get(pVBInfo->P3ce, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 142 | GRdata &= 0xBF; /* 256 color disable */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 143 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 144 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 145 | } |
| 146 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 147 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 148 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 149 | unsigned short i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 150 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 151 | for (i = 0x0A; i <= 0x0E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 152 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 153 | } |
| 154 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 155 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 156 | { |
| 157 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 158 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 159 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[0].SR2B); |
| 160 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[0].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 161 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 162 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 163 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[1].SR2B); |
| 164 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[1].SR2C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 165 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 166 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 167 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 168 | } |
| 169 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 170 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 171 | unsigned short RefreshRateTableIndex, unsigned short *i, |
| 172 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 173 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 174 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 175 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 176 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 177 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 178 | tempbx = XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 179 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 180 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame] | 181 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
| 182 | tempax |= SupportRAMDAC2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 183 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame] | 184 | if (pVBInfo->VBType & VB_XGI301C) |
| 185 | tempax |= SupportCRT2in301C; |
| 186 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 187 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame] | 188 | /* 301b */ |
| 189 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 190 | tempax |= SupportLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 191 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame] | 192 | if (pVBInfo->LCDResInfo != Panel_1280x1024 && |
| 193 | pVBInfo->LCDResInfo != Panel_1280x960 && |
| 194 | (pVBInfo->LCDInfo & LCDNonExpanding) && |
| 195 | resinfo >= 9) |
| 196 | return 0; |
| 197 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 198 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame] | 199 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */ |
| 200 | tempax |= SupportHiVision; |
| 201 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 202 | ((resinfo == 4) || |
| 203 | (resinfo == 3 && (pVBInfo->SetFlag & TVSimuMode)) || |
| 204 | (resinfo > 7))) |
| 205 | return 0; |
| 206 | } else if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | |
| 207 | SetCRT2ToSCART | SetCRT2ToYPbPr525750 | |
| 208 | SetCRT2ToHiVision)) { |
| 209 | tempax |= SupportTV; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 210 | |
Aaro Koskinen | 0903b0d | 2013-05-29 23:59:03 +0300 | [diff] [blame] | 211 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | |
| 212 | VB_SIS302LV | VB_XGI301C)) |
| 213 | tempax |= SupportTV1024; |
| 214 | |
| 215 | if (!(pVBInfo->VBInfo & TVSetPAL) && |
| 216 | (modeflag & NoSupportSimuTV) && |
| 217 | (pVBInfo->VBInfo & SetInSlaveMode) && |
| 218 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
| 219 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 220 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 221 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 222 | for (; XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 223 | tempbx; (*i)--) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 224 | infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 225 | Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 226 | if (infoflag & tempax) |
| 227 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 228 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 229 | if ((*i) == 0) |
| 230 | break; |
| 231 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 232 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 233 | for ((*i) = 0;; (*i)++) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 234 | infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 235 | Ext_InfoFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 236 | if (XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 237 | != tempbx) { |
| 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | if (infoflag & tempax) |
| 242 | return 1; |
| 243 | } |
| 244 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 245 | } |
| 246 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 247 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 248 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 249 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 250 | unsigned short sync, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 251 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 252 | /* di+0x00 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 253 | sync = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 254 | sync &= 0xC0; |
| 255 | temp = 0x2F; |
| 256 | temp |= sync; |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 257 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 258 | } |
| 259 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 260 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 261 | struct xgi_hw_device_info *HwDeviceExtension) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 262 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 263 | unsigned char data, data1, pushax; |
| 264 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 265 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 266 | /* unlock cr0-7 */ |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 267 | data = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 268 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 269 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 270 | |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 271 | data = pVBInfo->TimingH.data[0]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 272 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 273 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 274 | for (i = 0x01; i <= 0x04; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 275 | data = pVBInfo->TimingH.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 276 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 277 | } |
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 = 0x05; i <= 0x06; 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->P3c4, (unsigned short) (i + 6), 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 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 284 | j = xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 285 | j &= 0x1F; |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 286 | data = pVBInfo->TimingH.data[7]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 287 | data &= 0xE0; |
| 288 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 289 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 290 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 291 | if (HwDeviceExtension->jChipType >= XG20) { |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 292 | data = xgifb_reg_get(pVBInfo->P3d4, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 293 | data = data - 1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 294 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 295 | data = xgifb_reg_get(pVBInfo->P3d4, 0x05); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 296 | data1 = data; |
| 297 | data1 &= 0xE0; |
| 298 | data &= 0x1F; |
| 299 | if (data == 0) { |
| 300 | pushax = data; |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 301 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0c); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 302 | data &= 0xFB; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 303 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 304 | data = pushax; |
| 305 | } |
| 306 | data = data - 1; |
| 307 | data |= data1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 308 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 309 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 310 | data = data >> 5; |
| 311 | data = data + 3; |
| 312 | if (data > 7) |
| 313 | data = data - 7; |
| 314 | data = data << 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 315 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 316 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 317 | } |
| 318 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 319 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 320 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 321 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 322 | unsigned char data; |
| 323 | unsigned short i, j; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 324 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 325 | for (i = 0x00; i <= 0x01; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 326 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 327 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 328 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 329 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 330 | for (i = 0x02; i <= 0x03; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 331 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 332 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 333 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 334 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 335 | for (i = 0x04; i <= 0x05; i++) { |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 336 | data = pVBInfo->TimingV.data[i]; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 337 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 338 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 339 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 340 | j = xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 341 | j &= 0xC0; |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 342 | data = pVBInfo->TimingV.data[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 343 | data &= 0x3F; |
| 344 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 345 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 346 | |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 347 | data = pVBInfo->TimingV.data[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 348 | data &= 0x80; |
| 349 | data = data >> 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 350 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 351 | i = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 352 | i &= DoubleScanMode; |
| 353 | if (i) |
| 354 | data |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 355 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 356 | j = xgifb_reg_get(pVBInfo->P3d4, 0x09); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 357 | j &= 0x5F; |
| 358 | data |= j; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 359 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 360 | } |
| 361 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 362 | static void XGI_SetCRT1CRTC(unsigned short ModeIdIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 363 | unsigned short RefreshRateTableIndex, |
| 364 | struct vb_device_info *pVBInfo, |
| 365 | struct xgi_hw_device_info *HwDeviceExtension) |
| 366 | { |
| 367 | unsigned char index, data; |
| 368 | unsigned short i; |
| 369 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 370 | /* Get index */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 371 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 372 | index = index & IndexMask; |
| 373 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 374 | data = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 375 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 376 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 377 | |
| 378 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 379 | pVBInfo->TimingH.data[i] |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 380 | = XGI_CRT1Table[index].CR[i]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 381 | |
| 382 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 383 | pVBInfo->TimingV.data[i] |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 384 | = XGI_CRT1Table[index].CR[i + 8]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 385 | |
| 386 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 387 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 388 | XGI_SetCRT1Timing_V(ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 389 | |
| 390 | if (pVBInfo->ModeType > 0x03) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 391 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 392 | } |
| 393 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 394 | /* --------------------------------------------------------------------- */ |
| 395 | /* Function : XGI_SetXG21CRTC */ |
| 396 | /* Input : Stand or enhance CRTC table */ |
| 397 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ |
| 398 | /* Description : Set LCD timing */ |
| 399 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 400 | static void XGI_SetXG21CRTC(unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 401 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 402 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 403 | unsigned char index, Tempax, Tempbx, Tempcx, Tempdx; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 404 | unsigned short Temp1, Temp2, Temp3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 405 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 406 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 407 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 408 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 409 | Tempcx = Tempax; /* Tempcx: HRS */ |
| 410 | /* SR2E[7:0]->HRS */ |
| 411 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 412 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 413 | Tempdx = XGI_CRT1Table[index].CR[5]; /* SRB */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 414 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ |
| 415 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ |
| 416 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ |
| 417 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 418 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 419 | Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 420 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 421 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 422 | Tempbx = XGI_CRT1Table[index].CR[6]; /* SRC */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 423 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ |
| 424 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ |
| 425 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 426 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 427 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
| 428 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 429 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 430 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
| 431 | if (Tempax < Tempcx) /* HRE < HRS */ |
| 432 | Temp2 |= 0x40; /* Temp2 + 0x40 */ |
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 &= 0xFF; |
| 435 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ |
| 436 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ |
| 437 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ |
| 438 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ |
| 439 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
| 440 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 441 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 442 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 443 | /* CR10 VRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 444 | Tempax = XGI_CRT1Table[index].CR[10]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 445 | Tempbx = Tempax; /* Tempbx: VRS */ |
| 446 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ |
| 447 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
| 448 | /* CR7[2][7] VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 449 | Tempax = XGI_CRT1Table[index].CR[9]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 450 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
| 451 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ |
| 452 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ |
| 453 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ |
| 454 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 455 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 456 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
| 457 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ |
| 458 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
| 459 | Tempax &= 0x80; |
| 460 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ |
| 461 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ |
| 462 | /* Tempax: SRA */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 463 | Tempax = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 464 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
| 465 | Temp2 = Tempax; |
| 466 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ |
| 467 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 468 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 469 | /* Tempax: CR11 VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 470 | Tempax = XGI_CRT1Table[index].CR[11]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 471 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 472 | /* Tempbx: SRA */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 473 | Tempbx = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 474 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
| 475 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 476 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 477 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ |
| 478 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 479 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 480 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
| 481 | if (Tempax < Temp3) /* VRE < VRS */ |
| 482 | Temp2 |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 483 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 484 | Temp2 &= 0xFF; |
| 485 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ |
| 486 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ |
| 487 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ |
| 488 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ |
| 489 | Tempbx = (unsigned char) Temp1; |
| 490 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ |
| 491 | Tempax &= 0x7F; |
| 492 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
| 493 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 494 | } |
| 495 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 496 | static void XGI_SetXG27CRTC(unsigned short RefreshRateTableIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 497 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 498 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 499 | unsigned short index, Tempax, Tempbx, Tempcx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 500 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 501 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 502 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 503 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 504 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
| 505 | /* SR2E[7:0]->HRS */ |
| 506 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); |
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 | /* SR0B */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 509 | Tempax = XGI_CRT1Table[index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 510 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 511 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 512 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 513 | Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 514 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ |
| 515 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 516 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 517 | Tempax = XGI_CRT1Table[index].CR[6]; /* SRC */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 518 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ |
| 519 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ |
| 520 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 521 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 522 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
| 523 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 524 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 525 | /* Tempax: CR4 HRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 526 | Tempax = XGI_CRT1Table[index].CR[3]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 527 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
| 528 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ |
| 529 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 530 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 531 | Tempax = XGI_CRT1Table[index].CR[5]; /* SR0B */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 532 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
| 533 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ |
| 534 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ |
| 535 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
| 536 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); |
| 537 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 538 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 539 | /* CR10 VRS */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 540 | Tempax = XGI_CRT1Table[index].CR[10]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 541 | /* SR34[7:0]->VRS[7:0] */ |
| 542 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 543 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 544 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
| 545 | /* CR7[7][2] VRS[9][8] */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 546 | Tempax = XGI_CRT1Table[index].CR[9]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 547 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
| 548 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ |
| 549 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ |
| 550 | /* SR35[0]: VRS[8] */ |
| 551 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); |
| 552 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
| 553 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ |
| 554 | /* Tempax: SR0A */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 555 | Tempax = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 556 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
| 557 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 558 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 559 | /* Tempax: CR11 VRE */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 560 | Tempax = XGI_CRT1Table[index].CR[11]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 561 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
| 562 | /* Tempbx: SR0A */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 563 | Tempbx = XGI_CRT1Table[index].CR[14]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 564 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
| 565 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ |
| 566 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ |
| 567 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ |
| 568 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ |
| 569 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 570 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 571 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
| 572 | Tempbx |= 0x20; /* VRE + 0x20 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 573 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 574 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
| 575 | Tempax = (Tempbx << 2) & 0xFF; |
| 576 | /* SR3F[7:2]:VRE[5:0] */ |
| 577 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); |
| 578 | Tempax = Tempcx >> 8; |
| 579 | /* SR35[2:0]:VRS[10:8] */ |
| 580 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 581 | } |
| 582 | |
Aaro Koskinen | a2d08cf | 2011-11-27 23:03:08 +0200 | [diff] [blame] | 583 | static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
| 584 | { |
| 585 | unsigned char temp; |
| 586 | |
| 587 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
| 588 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 589 | temp = (temp & 3) << 6; |
| 590 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
| 591 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); |
| 592 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ |
| 593 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 594 | |
| 595 | } |
| 596 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 597 | static void xgifb_set_lcd(int chip_id, |
| 598 | struct vb_device_info *pVBInfo, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 599 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 600 | { |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 601 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 602 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 603 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
| 604 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); |
| 605 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); |
| 606 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 607 | |
| 608 | if (chip_id == XG27) { |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 609 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 610 | if ((temp & 0x03) == 0) { /* dual 12 */ |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 611 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
| 612 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); |
| 613 | } |
| 614 | } |
| 615 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 616 | if (chip_id == XG27) { |
| 617 | XGI_SetXG27FPBits(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 618 | } else { |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 619 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
| 620 | if (temp & 0x01) { |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 621 | /* 18 bits FP */ |
| 622 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); |
| 623 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); |
| 624 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 625 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 626 | |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 627 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 628 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 629 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
| 630 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 631 | |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 632 | temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
| 633 | if (temp & 0x4000) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 634 | /* Hsync polarity */ |
| 635 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); |
Peter Huewe | e2e544c | 2013-02-03 04:08:46 +0100 | [diff] [blame] | 636 | if (temp & 0x8000) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 637 | /* Vsync polarity */ |
| 638 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | /* --------------------------------------------------------------------- */ |
| 642 | /* Function : XGI_UpdateXG21CRTC */ |
| 643 | /* Input : */ |
| 644 | /* Output : CRT1 CRTC */ |
| 645 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ |
| 646 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 647 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
| 648 | struct vb_device_info *pVBInfo, |
| 649 | unsigned short RefreshRateTableIndex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 650 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 651 | int index = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 652 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 653 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 654 | if (ModeNo == 0x2E && |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 655 | (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 656 | RES640x480x60)) |
| 657 | index = 12; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 658 | else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 659 | Ext_CRT1CRTC == RES640x480x72)) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 660 | index = 13; |
| 661 | else if (ModeNo == 0x2F) |
| 662 | index = 14; |
| 663 | else if (ModeNo == 0x50) |
| 664 | index = 15; |
| 665 | else if (ModeNo == 0x59) |
| 666 | index = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 667 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 668 | if (index != -1) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 669 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 670 | XGI_UpdateCRT1Table[index].CR02); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 671 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 672 | XGI_UpdateCRT1Table[index].CR03); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 673 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 674 | XGI_UpdateCRT1Table[index].CR15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 675 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
Aaro Koskinen | 7c5c07a | 2012-11-04 21:14:55 +0200 | [diff] [blame] | 676 | XGI_UpdateCRT1Table[index].CR16); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 677 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 678 | } |
| 679 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 680 | static void XGI_SetCRT1DE(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 681 | unsigned short RefreshRateTableIndex, |
| 682 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 683 | { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 684 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 685 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 686 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 687 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 688 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 689 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 690 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 691 | tempax = XGI330_ModeResInfo[resindex].HTotal; |
| 692 | tempbx = XGI330_ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 693 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 694 | if (modeflag & HalfDCLK) |
| 695 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 696 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 697 | if (modeflag & HalfDCLK) |
| 698 | tempax = tempax << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 699 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 700 | temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 701 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 702 | if (temp & InterlaceMode) |
| 703 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 704 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 705 | if (modeflag & DoubleScanMode) |
| 706 | tempbx = tempbx << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 707 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 708 | tempcx = 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 709 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 710 | tempax /= tempcx; |
| 711 | tempax -= 1; |
| 712 | tempbx -= 1; |
| 713 | tempcx = tempax; |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 714 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
| 715 | data = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 716 | data &= 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 717 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
| 718 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 719 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 720 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 721 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 722 | tempax = 0; |
| 723 | tempbx = tempbx >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 724 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 725 | if (tempbx & 0x01) |
| 726 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 727 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 728 | if (tempbx & 0x02) |
| 729 | tempax |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 730 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 731 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 732 | data = xgifb_reg_get(pVBInfo->P3d4, 0x07); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 733 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 734 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 735 | if (tempbx & 0x04) |
| 736 | tempax |= 0x02; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 737 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 738 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 739 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 740 | } |
| 741 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 742 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
| 743 | unsigned short ModeIdIndex, |
| 744 | unsigned short RefreshRateTableIndex, |
| 745 | struct xgi_hw_device_info *HwDeviceExtension, |
| 746 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 747 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 748 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 749 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 750 | /* GetOffset */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 751 | temp = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 752 | temp = temp >> 8; |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame] | 753 | temp = XGI330_ScreenOffset[temp]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 754 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 755 | temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 756 | temp2 &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 757 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 758 | if (temp2) |
| 759 | temp = temp << 1; |
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 | temp2 = pVBInfo->ModeType - ModeEGA; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 762 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 763 | switch (temp2) { |
| 764 | case 0: |
| 765 | temp2 = 1; |
| 766 | break; |
| 767 | case 1: |
| 768 | temp2 = 2; |
| 769 | break; |
| 770 | case 2: |
| 771 | temp2 = 4; |
| 772 | break; |
| 773 | case 3: |
| 774 | temp2 = 4; |
| 775 | break; |
| 776 | case 4: |
| 777 | temp2 = 6; |
| 778 | break; |
| 779 | case 5: |
| 780 | temp2 = 8; |
| 781 | break; |
| 782 | default: |
| 783 | break; |
| 784 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 785 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 786 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
| 787 | temp = temp * temp2 + temp2 / 2; |
| 788 | else |
| 789 | temp *= temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 790 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 791 | /* SetOffset */ |
| 792 | DisplayUnit = temp; |
| 793 | temp2 = temp; |
| 794 | temp = temp >> 8; /* ah */ |
| 795 | temp &= 0x0F; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 796 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 797 | i &= 0xF0; |
| 798 | i |= temp; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 799 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 800 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 801 | temp = (unsigned char) temp2; |
| 802 | temp &= 0xFF; /* al */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 803 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 804 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 805 | /* SetDisplayUnit */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 806 | temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 807 | temp2 &= InterlaceMode; |
| 808 | if (temp2) |
| 809 | DisplayUnit >>= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 810 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 811 | DisplayUnit = DisplayUnit << 5; |
| 812 | ah = (DisplayUnit & 0xff00) >> 8; |
| 813 | al = DisplayUnit & 0x00ff; |
| 814 | if (al == 0) |
| 815 | ah += 1; |
| 816 | else |
| 817 | ah += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 818 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 819 | if (HwDeviceExtension->jChipType >= XG20) |
| 820 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) |
| 821 | ah -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 822 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 823 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 824 | } |
| 825 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 826 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeIdIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 827 | unsigned short RefreshRateTableIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 828 | struct vb_device_info *pVBInfo) |
| 829 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 830 | unsigned short VCLKIndex, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 831 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 832 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 833 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 834 | |
Aaro Koskinen | 7ac54d0 | 2013-02-09 00:03:43 +0200 | [diff] [blame] | 835 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/ |
| 836 | if (pVBInfo->LCDResInfo != Panel_1024x768) |
| 837 | /* LCDXlat2VCLK */ |
| 838 | VCLKIndex = VCLK108_2_315 + 5; |
| 839 | else |
| 840 | VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */ |
| 841 | } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
| 842 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
| 843 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2; |
| 844 | else |
| 845 | VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 846 | |
Aaro Koskinen | 7ac54d0 | 2013-02-09 00:03:43 +0200 | [diff] [blame] | 847 | if (pVBInfo->SetFlag & TVSimuMode) { |
| 848 | if (modeflag & Charx8Dot) { |
| 849 | VCLKIndex = TVCLKBASE_315_25 + HiTVSimuVCLK; |
| 850 | } else { |
| 851 | VCLKIndex = TVCLKBASE_315_25 + HiTVTextVCLK; |
Aaro Koskinen | 798b4da | 2011-11-27 23:03:20 +0200 | [diff] [blame] | 852 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 853 | } |
Aaro Koskinen | 7ac54d0 | 2013-02-09 00:03:43 +0200 | [diff] [blame] | 854 | |
| 855 | /* 301lv */ |
| 856 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 857 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
| 858 | VCLKIndex = YPbPr525iVCLK_2; |
| 859 | else |
| 860 | VCLKIndex = YPbPr525iVCLK; |
| 861 | } |
| 862 | } else if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 863 | if (pVBInfo->SetFlag & RPLLDIV2XO) |
| 864 | VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2; |
| 865 | else |
| 866 | VCLKIndex = TVCLKBASE_315_25 + TVVCLK; |
| 867 | } else { /* for CRT2 */ |
| 868 | /* di+Ext_CRTVCLK */ |
| 869 | VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
| 870 | VCLKIndex &= IndexMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 871 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 872 | |
| 873 | return VCLKIndex; |
| 874 | } |
| 875 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 876 | static void XGI_SetCRT1VCLK(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 877 | struct xgi_hw_device_info *HwDeviceExtension, |
| 878 | unsigned short RefreshRateTableIndex, |
| 879 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 880 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 881 | unsigned char index, data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 882 | unsigned short vclkindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 883 | |
Aaro Koskinen | b750f51 | 2013-05-29 23:59:05 +0300 | [diff] [blame] | 884 | if ((pVBInfo->IF_DEF_LVDS == 0) && |
| 885 | (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | |
| 886 | VB_SIS302LV | VB_XGI301C)) && |
| 887 | (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 888 | vclkindex = XGI_GetVCLK2Ptr(ModeIdIndex, RefreshRateTableIndex, |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 889 | pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 890 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 891 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 892 | data = XGI_VBVCLKData[vclkindex].Part4_A; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 893 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 894 | data = XGI_VBVCLKData[vclkindex].Part4_B; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 895 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
| 896 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 897 | } else { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 898 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 899 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 900 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 901 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B); |
| 902 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 903 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 904 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 905 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 906 | if (HwDeviceExtension->jChipType >= XG20) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 907 | if (XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 908 | HalfDCLK) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 909 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 910 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 911 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 912 | index = data; |
| 913 | index &= 0xE0; |
| 914 | data &= 0x1F; |
| 915 | data = data << 1; |
| 916 | data += 1; |
| 917 | data |= index; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 918 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 919 | } |
| 920 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 921 | } |
| 922 | |
Aaro Koskinen | e85f203 | 2011-11-27 23:03:07 +0200 | [diff] [blame] | 923 | static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
| 924 | { |
| 925 | unsigned char temp; |
| 926 | |
| 927 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
| 928 | temp = (temp & 1) << 6; |
| 929 | /* SR06[6] 18bit Dither */ |
| 930 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); |
| 931 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ |
| 932 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); |
| 933 | |
| 934 | } |
| 935 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 936 | static void XGI_SetCRT1FIFO(struct xgi_hw_device_info *HwDeviceExtension, |
| 937 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 938 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 939 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 940 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 941 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 942 | data &= 0xfe; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 943 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 944 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 945 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
| 946 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
| 947 | data &= 0xC0; |
| 948 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
| 949 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
| 950 | data |= 0x01; |
| 951 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 952 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 953 | if (HwDeviceExtension->jChipType == XG21) |
| 954 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 955 | } |
| 956 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 957 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 958 | unsigned short RefreshRateTableIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 959 | struct vb_device_info *pVBInfo) |
| 960 | { |
| 961 | unsigned short data, data2 = 0; |
| 962 | short VCLK; |
| 963 | |
| 964 | unsigned char index; |
| 965 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 966 | index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 967 | index &= IndexMask; |
Aaro Koskinen | acfe093 | 2012-11-04 21:14:58 +0200 | [diff] [blame] | 968 | VCLK = XGI_VCLKData[index].CLOCK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 969 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 970 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 971 | data &= 0xf3; |
| 972 | if (VCLK >= 200) |
| 973 | data |= 0x0c; /* VCLK > 200 */ |
| 974 | |
| 975 | if (HwDeviceExtension->jChipType >= XG20) |
| 976 | data &= ~0x04; /* 2 pixel mode */ |
| 977 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 978 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 979 | |
| 980 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 981 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 982 | data &= 0xE7; |
| 983 | if (VCLK < 200) |
| 984 | data |= 0x10; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 985 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 986 | } |
| 987 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 988 | data2 = 0x00; |
| 989 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 990 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 991 | if (HwDeviceExtension->jChipType >= XG27) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 992 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 993 | |
| 994 | } |
| 995 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 996 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 997 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 998 | unsigned short RefreshRateTableIndex, |
| 999 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1000 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1001 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, |
| 1002 | xres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1003 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1004 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1005 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1006 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1007 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1008 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1009 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1010 | data = infoflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1011 | data2 = 0; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1012 | data2 |= 0x02; |
| 1013 | data3 = pVBInfo->ModeType - ModeVGA; |
| 1014 | data3 = data3 << 2; |
| 1015 | data2 |= data3; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1016 | data &= InterlaceMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1017 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1018 | if (data) |
| 1019 | data2 |= 0x20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1020 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1021 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1022 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 1023 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1024 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1025 | data = 0x0000; |
| 1026 | if (infoflag & InterlaceMode) { |
| 1027 | if (xres == 1024) |
| 1028 | data = 0x0035; |
| 1029 | else if (xres == 1280) |
| 1030 | data = 0x0048; |
| 1031 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1032 | |
Peter Huewe | 5d1c2a9 | 2013-02-03 22:54:37 +0100 | [diff] [blame] | 1033 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data); |
| 1034 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1035 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1036 | if (modeflag & HalfDCLK) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1037 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1038 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1039 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1040 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1041 | if (modeflag & LineCompareOff) |
| 1042 | data2 |= 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1043 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1044 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1045 | data = 0x60; |
Aaro Koskinen | 969f7f3 | 2012-04-07 01:14:03 +0300 | [diff] [blame] | 1046 | data = data ^ 0x60; |
| 1047 | data = data ^ 0xA0; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1048 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1049 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1050 | XGI_SetVCLKState(HwDeviceExtension, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1051 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1052 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1053 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1054 | if (HwDeviceExtension->jChipType == XG27) { |
| 1055 | if (data & 0x40) |
| 1056 | data = 0x2c; |
| 1057 | else |
| 1058 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1059 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1060 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1061 | } else if (HwDeviceExtension->jChipType >= XG20) { |
| 1062 | if (data & 0x40) |
| 1063 | data = 0x33; |
| 1064 | else |
| 1065 | data = 0x73; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1066 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
| 1067 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1068 | } else { |
| 1069 | if (data & 0x40) |
| 1070 | data = 0x2c; |
| 1071 | else |
| 1072 | data = 0x6c; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1073 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1074 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1075 | |
| 1076 | } |
| 1077 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1078 | static void XGI_WriteDAC(unsigned short dl, |
| 1079 | unsigned short ah, |
| 1080 | unsigned short al, |
| 1081 | unsigned short dh, |
| 1082 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1083 | { |
| 1084 | unsigned short temp, bh, bl; |
| 1085 | |
| 1086 | bh = ah; |
| 1087 | bl = al; |
| 1088 | |
| 1089 | if (dl != 0) { |
| 1090 | temp = bh; |
| 1091 | bh = dh; |
| 1092 | dh = temp; |
| 1093 | if (dl == 1) { |
| 1094 | temp = bl; |
| 1095 | bl = dh; |
| 1096 | dh = temp; |
| 1097 | } else { |
| 1098 | temp = bl; |
| 1099 | bl = bh; |
| 1100 | bh = temp; |
| 1101 | } |
| 1102 | } |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1103 | outb((unsigned short) dh, pVBInfo->P3c9); |
| 1104 | outb((unsigned short) bh, pVBInfo->P3c9); |
| 1105 | outb((unsigned short) bl, pVBInfo->P3c9); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1106 | } |
| 1107 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 1108 | static void XGI_LoadDAC(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1109 | { |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1110 | unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh; |
| 1111 | const unsigned short *table = XGINew_VGA_DAC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1112 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1113 | outb(0xFF, pVBInfo->P3c6); |
| 1114 | outb(0x00, pVBInfo->P3c8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1115 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1116 | for (i = 0; i < 16; i++) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1117 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1118 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1119 | for (k = 0; k < 3; k++) { |
| 1120 | data2 = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1121 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1122 | if (data & 0x01) |
| 1123 | data2 = 0x2A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1124 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1125 | if (data & 0x02) |
| 1126 | data2 += 0x15; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1127 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1128 | outb(data2, pVBInfo->P3c9); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1129 | data = data >> 2; |
| 1130 | } |
| 1131 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1132 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1133 | for (i = 16; i < 32; i++) { |
| 1134 | data = table[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1135 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1136 | for (k = 0; k < 3; k++) |
| 1137 | outb(data, pVBInfo->P3c9); |
| 1138 | } |
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 | si = 32; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1141 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1142 | for (m = 0; m < 9; m++) { |
| 1143 | di = si; |
| 1144 | bx = si + 0x04; |
| 1145 | dl = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1146 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1147 | for (n = 0; n < 3; n++) { |
| 1148 | for (o = 0; o < 5; o++) { |
| 1149 | dh = table[si]; |
| 1150 | ah = table[di]; |
| 1151 | al = table[bx]; |
| 1152 | si++; |
| 1153 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1154 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1155 | |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1156 | si -= 2; |
| 1157 | |
| 1158 | for (o = 0; o < 3; o++) { |
| 1159 | dh = table[bx]; |
| 1160 | ah = table[di]; |
| 1161 | al = table[si]; |
| 1162 | si--; |
| 1163 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); |
| 1164 | } |
| 1165 | |
| 1166 | dl++; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1167 | } |
Aaro Koskinen | 1bb52cc | 2012-04-07 01:14:06 +0300 | [diff] [blame] | 1168 | |
| 1169 | si += 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1170 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1171 | } |
| 1172 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1173 | static void XGI_GetLVDSResInfo(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1174 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1175 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1176 | unsigned short resindex, xres, yres, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1177 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1178 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1179 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1180 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1181 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1182 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1183 | |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 1184 | xres = XGI330_ModeResInfo[resindex].HTotal; |
| 1185 | yres = XGI330_ModeResInfo[resindex].VTotal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1186 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1187 | if (modeflag & HalfDCLK) |
| 1188 | xres = xres << 1; |
| 1189 | |
| 1190 | if (modeflag & DoubleScanMode) |
| 1191 | yres = yres << 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1192 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1193 | if (xres == 720) |
| 1194 | xres = 640; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1195 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1196 | pVBInfo->VGAHDE = xres; |
| 1197 | pVBInfo->HDE = xres; |
| 1198 | pVBInfo->VGAVDE = yres; |
| 1199 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1200 | } |
| 1201 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1202 | static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1203 | unsigned short ModeIdIndex, |
| 1204 | unsigned short RefreshRateTableIndex, |
| 1205 | struct vb_device_info *pVBInfo) |
| 1206 | { |
Aaro Koskinen | 6c27b37 | 2012-11-04 21:14:45 +0200 | [diff] [blame] | 1207 | unsigned short i, tempdx, tempbx, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1208 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1209 | tempbx = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1210 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1211 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1212 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1213 | i = 0; |
| 1214 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1215 | while (table[i].PANELID != 0xff) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1216 | tempdx = pVBInfo->LCDResInfo; |
| 1217 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 1218 | tempbx &= (~0x0080); |
| 1219 | tempdx = pVBInfo->LCDTypeInfo; |
| 1220 | } |
| 1221 | |
| 1222 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1223 | tempdx &= (~PanelResInfo); |
| 1224 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1225 | if (table[i].PANELID == tempdx) { |
| 1226 | tempbx = table[i].MASK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1227 | tempdx = pVBInfo->LCDInfo; |
| 1228 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1229 | if (modeflag & HalfDCLK) |
| 1230 | tempdx |= SetLCDLowResolution; |
| 1231 | |
| 1232 | tempbx &= tempdx; |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1233 | if (tempbx == table[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1234 | break; |
| 1235 | } |
| 1236 | i++; |
| 1237 | } |
| 1238 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1239 | return table[i].DATAPTR; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1240 | } |
| 1241 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1242 | static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeIdIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1243 | unsigned short RefreshRateTableIndex, |
| 1244 | struct vb_device_info *pVBInfo) |
| 1245 | { |
Aaro Koskinen | 56d276c | 2012-09-11 00:15:19 +0300 | [diff] [blame] | 1246 | unsigned short i, tempdx, tempal, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1247 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1248 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1249 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1250 | tempal = tempal & 0x3f; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1251 | tempdx = pVBInfo->TVInfo; |
| 1252 | |
| 1253 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 1254 | tempdx = tempdx | SetTVLockMode; |
| 1255 | |
| 1256 | if (modeflag & HalfDCLK) |
| 1257 | tempdx = tempdx | SetTVLowResolution; |
| 1258 | |
| 1259 | i = 0; |
| 1260 | |
Aaro Koskinen | 6265ee4 | 2012-09-11 00:15:20 +0300 | [diff] [blame] | 1261 | while (XGI_TVDataTable[i].MASK != 0xffff) { |
| 1262 | if ((tempdx & XGI_TVDataTable[i].MASK) == |
| 1263 | XGI_TVDataTable[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1264 | break; |
| 1265 | i++; |
| 1266 | } |
| 1267 | |
Aaro Koskinen | 18ba866 | 2012-09-11 00:15:22 +0300 | [diff] [blame] | 1268 | return &XGI_TVDataTable[i].DATAPTR[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1269 | } |
| 1270 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1271 | static void XGI_GetLVDSData(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1272 | unsigned short RefreshRateTableIndex, |
| 1273 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1274 | { |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1275 | struct SiS_LVDSData const *LCDPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1276 | |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1277 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 1278 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1279 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1280 | LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeIdIndex, |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1281 | RefreshRateTableIndex, pVBInfo); |
| 1282 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 1283 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 1284 | pVBInfo->HT = LCDPtr->LCDHT; |
| 1285 | pVBInfo->VT = LCDPtr->LCDVT; |
| 1286 | |
| 1287 | if (pVBInfo->LCDInfo & (SetLCDtoNonExpanding | EnableScalingLCD)) |
| 1288 | return; |
| 1289 | |
| 1290 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1291 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
| 1292 | pVBInfo->HDE = 1024; |
| 1293 | pVBInfo->VDE = 768; |
| 1294 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1295 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
| 1296 | pVBInfo->HDE = 1280; |
| 1297 | pVBInfo->VDE = 1024; |
| 1298 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
| 1299 | pVBInfo->HDE = 1400; |
| 1300 | pVBInfo->VDE = 1050; |
| 1301 | } else { |
| 1302 | pVBInfo->HDE = 1600; |
| 1303 | pVBInfo->VDE = 1200; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1304 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1305 | } |
| 1306 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1307 | static void XGI_ModCRT1Regs(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1308 | unsigned short RefreshRateTableIndex, |
| 1309 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1310 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1311 | { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1312 | unsigned short i; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1313 | struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL; |
| 1314 | struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1315 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1316 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1317 | LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeIdIndex, |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1318 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1319 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1320 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1321 | pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1322 | } |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1323 | |
| 1324 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 1325 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1326 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1327 | LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeIdIndex, |
| 1328 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1329 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1330 | pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i]; |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1331 | } |
| 1332 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1333 | XGI_SetCRT1Timing_V(ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1334 | } |
| 1335 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1336 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 1337 | { |
| 1338 | unsigned char tempal, tempah, tempbl, i; |
| 1339 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1340 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1341 | tempal = tempah & 0x0F; |
| 1342 | tempah = tempah & 0xF0; |
| 1343 | i = 0; |
| 1344 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1345 | |
| 1346 | while (tempbl != 0xFF) { |
| 1347 | if (tempbl & 0x80) { /* OEMUtil */ |
| 1348 | tempal = tempah; |
| 1349 | tempbl = tempbl & ~(0x80); |
| 1350 | } |
| 1351 | |
| 1352 | if (tempal == tempbl) |
| 1353 | break; |
| 1354 | |
| 1355 | i++; |
| 1356 | |
| 1357 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1358 | } |
| 1359 | |
| 1360 | return i; |
| 1361 | } |
| 1362 | |
| 1363 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 1364 | { |
| 1365 | unsigned short tempah, tempal, tempbl, i; |
| 1366 | |
| 1367 | tempal = pVBInfo->LCDResInfo; |
| 1368 | tempah = pVBInfo->LCDTypeInfo; |
| 1369 | |
| 1370 | i = 0; |
| 1371 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1372 | |
| 1373 | while (tempbl != 0xFF) { |
| 1374 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 1375 | tempal = tempah; |
| 1376 | tempbl &= ~0x80; |
| 1377 | } |
| 1378 | |
| 1379 | if (tempal == tempbl) |
| 1380 | break; |
| 1381 | |
| 1382 | i++; |
| 1383 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1384 | } |
| 1385 | |
| 1386 | if (tempbl == 0xFF) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1387 | pVBInfo->LCDResInfo = Panel_1024x768; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1388 | pVBInfo->LCDTypeInfo = 0; |
| 1389 | i = 0; |
| 1390 | } |
| 1391 | |
| 1392 | return i; |
| 1393 | } |
| 1394 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1395 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 1396 | unsigned short *VSyncWidth, |
| 1397 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1398 | { |
| 1399 | unsigned short Index; |
| 1400 | |
| 1401 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 1402 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 1403 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1404 | } |
| 1405 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1406 | static void XGI_SetLVDSRegs(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1407 | unsigned short RefreshRateTableIndex, |
| 1408 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1409 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1410 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 1411 | unsigned long temp, temp1, temp2, temp3, push3; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1412 | struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1413 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1414 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1415 | LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeIdIndex, |
| 1416 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1417 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1418 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 1419 | push1 = tempbx; |
| 1420 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1421 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1422 | /* GetLCDResInfo */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1423 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1424 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1425 | tempax = 1024; |
| 1426 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1427 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1428 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1429 | tempax = 1280; |
| 1430 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1431 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1432 | tempax = 1400; |
| 1433 | tempbx = 1050; |
| 1434 | } else { |
| 1435 | tempax = 1600; |
| 1436 | tempbx = 1200; |
| 1437 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1438 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1439 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 1440 | pVBInfo->HDE = tempax; |
| 1441 | pVBInfo->VDE = tempbx; |
| 1442 | pVBInfo->VGAHDE = tempax; |
| 1443 | pVBInfo->VGAVDE = tempbx; |
| 1444 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1445 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1446 | tempax = pVBInfo->HT; |
| 1447 | |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1448 | tempbx = LCDPtr1->LCDHDES; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1449 | |
| 1450 | tempcx = pVBInfo->HDE; |
| 1451 | tempbx = tempbx & 0x0fff; |
| 1452 | tempcx += tempbx; |
| 1453 | |
| 1454 | if (tempcx >= tempax) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1455 | tempcx -= tempax; |
| 1456 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1457 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1458 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1459 | tempcx = tempcx >> 3; |
| 1460 | tempbx = tempbx >> 3; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1461 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1462 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 1463 | (unsigned short) (tempbx & 0xff)); |
| 1464 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 1465 | (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1466 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1467 | tempax = pVBInfo->HT; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1468 | |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1469 | tempbx = LCDPtr1->LCDHRS; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1470 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1471 | tempcx = push2; |
| 1472 | |
| 1473 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1474 | tempcx = LCDPtr1->LCDHSync; |
| 1475 | |
| 1476 | tempcx += tempbx; |
| 1477 | |
| 1478 | if (tempcx >= tempax) |
| 1479 | tempcx -= tempax; |
| 1480 | |
| 1481 | tempax = tempbx & 0x07; |
| 1482 | tempax = tempax >> 5; |
| 1483 | tempcx = tempcx >> 3; |
| 1484 | tempbx = tempbx >> 3; |
| 1485 | |
| 1486 | tempcx &= 0x1f; |
| 1487 | tempax |= tempcx; |
| 1488 | |
| 1489 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 1490 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 1491 | (unsigned short) (tempbx & 0xff)); |
| 1492 | |
| 1493 | tempax = pVBInfo->VT; |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1494 | tempbx = LCDPtr1->LCDVDES; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1495 | tempcx = pVBInfo->VDE; |
| 1496 | |
| 1497 | tempbx = tempbx & 0x0fff; |
| 1498 | tempcx += tempbx; |
| 1499 | if (tempcx >= tempax) |
| 1500 | tempcx -= tempax; |
| 1501 | |
| 1502 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 1503 | (unsigned short) (tempbx & 0xff)); |
| 1504 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 1505 | (unsigned short) (tempcx & 0xff)); |
| 1506 | |
| 1507 | tempbx = (tempbx >> 8) & 0x07; |
| 1508 | tempcx = (tempcx >> 8) & 0x07; |
| 1509 | |
| 1510 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 1511 | (unsigned short) ((tempcx << 3) |
| 1512 | | tempbx)); |
| 1513 | |
| 1514 | tempax = pVBInfo->VT; |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1515 | tempbx = LCDPtr1->LCDVRS; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1516 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1517 | tempcx = push1; |
| 1518 | |
| 1519 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1520 | tempcx = LCDPtr1->LCDVSync; |
| 1521 | |
| 1522 | tempcx += tempbx; |
| 1523 | if (tempcx >= tempax) |
| 1524 | tempcx -= tempax; |
| 1525 | |
| 1526 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 1527 | (unsigned short) (tempbx & 0xff)); |
| 1528 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 1529 | (unsigned short) (tempcx & 0x0f)); |
| 1530 | |
| 1531 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 1532 | |
| 1533 | tempbx = pVBInfo->VGAVDE; |
| 1534 | if (tempbx != pVBInfo->VDE) |
| 1535 | tempax |= 0x40; |
| 1536 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1537 | if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1538 | tempax |= 0x40; |
| 1539 | |
| 1540 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 1541 | tempax); |
| 1542 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1543 | tempbx = pVBInfo->VDE; |
| 1544 | tempax = pVBInfo->VGAVDE; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1545 | |
| 1546 | temp = tempax; /* 0430 ylshieh */ |
| 1547 | temp1 = (temp << 18) / tempbx; |
| 1548 | |
| 1549 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 1550 | |
| 1551 | if (tempdx != 0) |
| 1552 | temp1 += 1; |
| 1553 | |
| 1554 | temp2 = temp1; |
| 1555 | push3 = temp2; |
| 1556 | |
| 1557 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 1558 | (unsigned short) (temp2 & 0xff)); |
| 1559 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 1560 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 1561 | |
| 1562 | tempbx = (unsigned short) (temp2 >> 16); |
| 1563 | tempax = tempbx & 0x03; |
| 1564 | |
| 1565 | tempbx = pVBInfo->VGAVDE; |
| 1566 | if (tempbx == pVBInfo->VDE) |
| 1567 | tempax |= 0x04; |
| 1568 | |
| 1569 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 1570 | |
| 1571 | if (pVBInfo->VBType & VB_XGI301C) { |
| 1572 | temp2 = push3; |
| 1573 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1574 | 0x3c, |
| 1575 | (unsigned short) (temp2 & 0xff)); |
| 1576 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1577 | 0x3b, |
| 1578 | (unsigned short) ((temp2 >> 8) & |
| 1579 | 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1580 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1581 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 1582 | ~0xc0, |
| 1583 | (unsigned short) ((tempbx & |
| 1584 | 0xff) << 6)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1585 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1586 | tempcx = pVBInfo->VGAVDE; |
| 1587 | if (tempcx == pVBInfo->VDE) |
| 1588 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1589 | 0x30, ~0x0c, 0x00); |
| 1590 | else |
| 1591 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1592 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1593 | } |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1594 | |
| 1595 | tempcx = pVBInfo->VGAHDE; |
| 1596 | tempbx = pVBInfo->HDE; |
| 1597 | |
| 1598 | temp1 = tempcx << 16; |
| 1599 | |
| 1600 | tempax = (unsigned short) (temp1 / tempbx); |
| 1601 | |
| 1602 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 1603 | tempax = 65535; |
| 1604 | |
| 1605 | temp3 = tempax; |
| 1606 | temp1 = pVBInfo->VGAHDE << 16; |
| 1607 | |
| 1608 | temp1 /= temp3; |
| 1609 | temp3 = temp3 << 16; |
| 1610 | temp1 -= 1; |
| 1611 | |
| 1612 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 1613 | |
| 1614 | tempax = (unsigned short) (temp3 & 0xff); |
| 1615 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 1616 | |
| 1617 | temp1 = pVBInfo->VGAVDE << 18; |
| 1618 | temp1 = temp1 / push3; |
| 1619 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 1620 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1621 | if (pVBInfo->LCDResInfo == Panel_1024x768) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1622 | tempbx -= 1; |
| 1623 | |
| 1624 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 1625 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 1626 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 1627 | (unsigned short) (tempax & 0xff)); |
| 1628 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 1629 | (unsigned short) (tempbx & 0xff)); |
| 1630 | |
| 1631 | temp3 = temp3 >> 16; |
| 1632 | |
| 1633 | if (modeflag & HalfDCLK) |
| 1634 | temp3 = temp3 >> 1; |
| 1635 | |
| 1636 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 1637 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 1638 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 1639 | (unsigned short) (temp3 & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1640 | } |
| 1641 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1642 | /* --------------------------------------------------------------------- */ |
| 1643 | /* Function : XGI_GETLCDVCLKPtr */ |
| 1644 | /* Input : */ |
| 1645 | /* Output : al -> VCLK Index */ |
| 1646 | /* Description : */ |
| 1647 | /* --------------------------------------------------------------------- */ |
| 1648 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 1649 | struct vb_device_info *pVBInfo) |
| 1650 | { |
| 1651 | unsigned short index; |
| 1652 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1653 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1654 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 1655 | |
| 1656 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 1657 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 1658 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 1659 | } else { /* LCDA */ |
| 1660 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 1661 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 1662 | } |
| 1663 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1664 | } |
| 1665 | |
| 1666 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1667 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1668 | { |
| 1669 | |
| 1670 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1671 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1672 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1673 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1674 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1675 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1676 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 1677 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1678 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 1679 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 1680 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1681 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1682 | return tempal; |
| 1683 | |
| 1684 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1685 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1686 | (VB_SIS301B | |
| 1687 | VB_SIS302B | |
| 1688 | VB_SIS301LV | |
| 1689 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1690 | VB_XGI301C)) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1691 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1692 | tempal = TVCLKBASE_315 + HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1693 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1694 | tempal = TVCLKBASE_315 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1695 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1696 | tempal = TVCLKBASE_315 + HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1697 | if (!(modeflag & Charx8Dot)) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1698 | tempal = TVCLKBASE_315 + |
| 1699 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1700 | |
| 1701 | } |
| 1702 | return tempal; |
| 1703 | } |
| 1704 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1705 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1706 | tempal = XGI_YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1707 | return tempal; |
| 1708 | } |
| 1709 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1710 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1711 | tempal = YPbPr525pVCLK; |
| 1712 | return tempal; |
| 1713 | } |
| 1714 | |
| 1715 | tempal = NTSC1024VCLK; |
| 1716 | |
| 1717 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1718 | tempal = TVCLKBASE_315 + TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1719 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1720 | tempal = TVCLKBASE_315 + TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1721 | } |
| 1722 | |
| 1723 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 1724 | return tempal; |
| 1725 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1726 | } /* {End of VB} */ |
| 1727 | |
Peter Huewe | 516354e | 2013-02-15 20:37:11 +0100 | [diff] [blame] | 1728 | inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1729 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1730 | return tempal; |
| 1731 | } |
| 1732 | |
| 1733 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 1734 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 1735 | { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1736 | if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B |
| 1737 | | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1738 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
| 1739 | (pVBInfo->SetFlag & ProgrammingCRT2)) { |
Aaro Koskinen | e8cb03d | 2012-09-11 00:15:31 +0300 | [diff] [blame] | 1740 | *di_0 = XGI_VBVCLKData[tempal].Part4_A; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1741 | *di_1 = XGI_VBVCLKData[tempal].Part4_B; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1742 | } |
| 1743 | } else { |
| 1744 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 1745 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 1746 | } |
| 1747 | } |
| 1748 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1749 | static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1750 | unsigned short RefreshRateTableIndex, |
| 1751 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1752 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1753 | unsigned char di_0, di_1, tempal; |
| 1754 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1755 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1756 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1757 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 1758 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1759 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1760 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1761 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1762 | (unsigned short) (0x10 * i)); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1763 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1764 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1765 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 1766 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1767 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1768 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 1769 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1770 | } |
| 1771 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1772 | } |
| 1773 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 1774 | static void XGI_UpdateModeInfo(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1775 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1776 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1777 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1778 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 1779 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1780 | tempcl = 0; |
| 1781 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1782 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1783 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1784 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1785 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1786 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1787 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1788 | if (!(temp & 0x40)) |
| 1789 | tempcl |= ActiveCRT1; |
| 1790 | } |
| 1791 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1792 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1793 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1794 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1795 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1796 | if (!(temp == 0x08)) { |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1797 | /* Check ChannelA */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1798 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1799 | if (tempax & 0x04) |
| 1800 | tempcl = tempcl | ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1801 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1802 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1803 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1804 | if (!(tempcl & ActiveLCD)) |
| 1805 | if (temp == 0x01) |
| 1806 | tempcl |= ActiveCRT2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1807 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1808 | if (temp == 0x04) |
| 1809 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1810 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1811 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1812 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1813 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1814 | if (!(temp & 0x08)) |
| 1815 | tempch |= ActiveAVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1816 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1817 | if (!(temp & 0x04)) |
| 1818 | tempch |= ActiveSVideo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1819 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1820 | if (temp & 0x02) |
| 1821 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1822 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1823 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1824 | if (temp & 0x01) |
| 1825 | tempch |= ActiveHiTV; |
| 1826 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1827 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1828 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1829 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1830 | pVBInfo->Part2Port, |
| 1831 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1832 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1833 | if (temp & 0x10) |
| 1834 | tempch |= ActiveYPbPr; |
| 1835 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1836 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1837 | if (tempch != 0) |
| 1838 | tempcl |= ActiveTV; |
| 1839 | } |
| 1840 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1841 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1842 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1843 | if (tempcl & ActiveLCD) { |
| 1844 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 1845 | if (temp & ActiveTV) |
| 1846 | tempcl |= ActiveTV; |
| 1847 | } |
| 1848 | } |
| 1849 | temp = tempcl; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1850 | tempbl = ~XGI_ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1851 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1852 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1853 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1854 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1855 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1856 | } |
| 1857 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 1858 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1859 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1860 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1861 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1862 | tempbx = VB_SIS302B; |
| 1863 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
| 1864 | if (flag == 0x02) |
| 1865 | goto finish; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1866 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1867 | tempbx = VB_SIS301; |
| 1868 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
| 1869 | if (flag < 0xB0) |
| 1870 | goto finish; |
| 1871 | |
| 1872 | tempbx = VB_SIS301B; |
| 1873 | if (flag < 0xC0) |
| 1874 | goto bigger_than_0xB0; |
| 1875 | |
| 1876 | tempbx = VB_XGI301C; |
| 1877 | if (flag < 0xD0) |
| 1878 | goto bigger_than_0xB0; |
| 1879 | |
| 1880 | tempbx = VB_SIS301LV; |
| 1881 | if (flag < 0xE0) |
| 1882 | goto bigger_than_0xB0; |
| 1883 | |
| 1884 | tempbx = VB_SIS302LV; |
| 1885 | tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39); |
| 1886 | if (tempah != 0xFF) |
| 1887 | tempbx = VB_XGI301C; |
| 1888 | |
| 1889 | bigger_than_0xB0: |
| 1890 | if (tempbx & (VB_SIS301B | VB_SIS302B)) { |
| 1891 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23); |
| 1892 | if (!(flag & 0x02)) |
| 1893 | tempbx = tempbx | VB_NoLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1894 | } |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1895 | |
| 1896 | finish: |
| 1897 | pVBInfo->VBType = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1898 | } |
| 1899 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1900 | static void XGI_GetVBInfo(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1901 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1902 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1903 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1904 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1905 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1906 | pVBInfo->SetFlag = 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1907 | pVBInfo->ModeType = modeflag & ModeTypeMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1908 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1909 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1910 | if (!(pVBInfo->VBType & 0xFFFF)) |
| 1911 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1912 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1913 | /* Check Display Device */ |
| 1914 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
| 1915 | tempbx = tempbx | temp; |
| 1916 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
| 1917 | push = temp; |
| 1918 | push = push << 8; |
| 1919 | tempax = temp << 8; |
| 1920 | tempbx = tempbx | tempax; |
| 1921 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA |
| 1922 | | SetInSlaveMode | DisableCRT2Display); |
| 1923 | temp = 0xFFFF ^ temp; |
| 1924 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1925 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1926 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1927 | |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1928 | if (pVBInfo->VBType & (VB_SIS302B | VB_SIS301LV | VB_SIS302LV | |
| 1929 | VB_XGI301C)) { |
| 1930 | if (temp & EnableDualEdge) { |
| 1931 | tempbx |= SetCRT2ToDualEdge; |
| 1932 | if (temp & SetToLCDA) |
| 1933 | tempbx |= XGI_SetCRT2ToLCDA; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1934 | } |
| 1935 | } |
| 1936 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 1937 | if (pVBInfo->VBType & (VB_SIS301LV|VB_SIS302LV|VB_XGI301C)) { |
| 1938 | if (temp & SetYPbPr) { |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 1939 | /* shampoo add for new scratch */ |
| 1940 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
| 1941 | temp &= YPbPrMode; |
| 1942 | tempbx |= SetCRT2ToHiVision; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1943 | |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 1944 | if (temp != YPbPrMode1080i) { |
| 1945 | tempbx &= (~SetCRT2ToHiVision); |
| 1946 | tempbx |= SetCRT2ToYPbPr525750; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1947 | } |
| 1948 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1949 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1950 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1951 | tempax = push; /* restore CR31 */ |
| 1952 | |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 1953 | temp = 0x09FC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1954 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1955 | if (!(tempbx & temp)) { |
| 1956 | tempax |= DisableCRT2Display; |
| 1957 | tempbx = 0; |
| 1958 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1959 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 1960 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 1961 | if (tempbx & XGI_SetCRT2ToLCDA) { |
| 1962 | if (tempbx & SetSimuScanMode) |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1963 | tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 1964 | SwitchCRT2)); |
| 1965 | else |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1966 | tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC | |
| 1967 | SetCRT2ToTV | SwitchCRT2)); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1968 | } |
| 1969 | } |
| 1970 | |
| 1971 | /* shampoo add */ |
| 1972 | /* for driver abnormal */ |
| 1973 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { |
Aaro Koskinen | ee76875 | 2013-05-29 23:59:16 +0300 | [diff] [blame] | 1974 | if (tempbx & SetCRT2ToRAMDAC) { |
| 1975 | tempbx &= (0xFF00 | SetCRT2ToRAMDAC | |
| 1976 | SwitchCRT2 | SetSimuScanMode); |
| 1977 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1978 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1979 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1980 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1981 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 1982 | if (tempbx & SetCRT2ToLCD) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1983 | tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1984 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1985 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1986 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1987 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1988 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1989 | if (tempbx & SetCRT2ToSCART) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1990 | tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchCRT2 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1991 | SetSimuScanMode); |
| 1992 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
| 1993 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1994 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 1995 | if (tempbx & SetCRT2ToYPbPr525750) |
| 1996 | tempbx &= (0xFF00 | SwitchCRT2 | SetSimuScanMode); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1997 | |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 1998 | if (tempbx & SetCRT2ToHiVision) |
| 1999 | tempbx &= (0xFF00 | SetCRT2ToHiVision | SwitchCRT2 | |
| 2000 | SetSimuScanMode); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2001 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2002 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 2003 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) |
| 2004 | tempbx = DisableCRT2Display; |
| 2005 | } |
| 2006 | |
| 2007 | if (!(tempbx & DisableCRT2Display)) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2008 | if ((!(tempbx & DriverMode)) || (!(modeflag & CRT2Mode))) { |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2009 | if (!(tempbx & XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2010 | tempbx |= (SetInSlaveMode | SetSimuScanMode); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2011 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2012 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2013 | /* LCD+TV can't support in slave mode |
| 2014 | * (Force LCDA+TV->LCDB) */ |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2015 | if ((tempbx & SetInSlaveMode) && (tempbx & XGI_SetCRT2ToLCDA)) { |
| 2016 | tempbx ^= (SetCRT2ToLCD | XGI_SetCRT2ToLCDA | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2017 | SetCRT2ToDualEdge); |
| 2018 | pVBInfo->SetFlag |= ReserveTVOption; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2019 | } |
| 2020 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2021 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2022 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2023 | } |
| 2024 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2025 | static void XGI_GetTVInfo(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2026 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2027 | { |
Peter Huewe | 5fc699f | 2013-02-03 04:08:45 +0100 | [diff] [blame] | 2028 | unsigned short tempbx = 0, resinfo = 0, modeflag, index1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2029 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2030 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2031 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2032 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2033 | |
Peter Huewe | 5fc699f | 2013-02-03 04:08:45 +0100 | [diff] [blame] | 2034 | tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
| 2035 | if (tempbx & TVSetPAL) { |
| 2036 | tempbx &= (SetCHTVOverScan | |
| 2037 | TVSetPALM | |
| 2038 | TVSetPALN | |
| 2039 | TVSetPAL); |
| 2040 | if (tempbx & TVSetPALM) |
| 2041 | /* set to NTSC if PAL-M */ |
| 2042 | tempbx &= ~TVSetPAL; |
| 2043 | } else |
| 2044 | tempbx &= (SetCHTVOverScan | |
| 2045 | TVSetNTSCJ | |
| 2046 | TVSetPAL); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2047 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2048 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 2049 | tempbx |= TVSetPAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2050 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 2051 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 2052 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
| 2053 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2054 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 2055 | if (index1 == YPbPrMode525i) |
| 2056 | tempbx |= TVSetYPbPr525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2057 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 2058 | if (index1 == YPbPrMode525p) |
| 2059 | tempbx = tempbx | TVSetYPbPr525p; |
| 2060 | if (index1 == YPbPrMode750p) |
| 2061 | tempbx = tempbx | TVSetYPbPr750p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2062 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2063 | |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 2064 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
| 2065 | tempbx = tempbx | TVSetHiVision | TVSetPAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2066 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2067 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 2068 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
| 2069 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2070 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2071 | if (!(tempbx & TVSetPAL) && (modeflag > 13) && (resinfo == 8)) |
| 2072 | /* NTSC 1024x768, */ |
| 2073 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2074 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2075 | tempbx |= RPLLDIV2XO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2076 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2077 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
| 2078 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2079 | tempbx &= (~RPLLDIV2XO); |
| 2080 | } else if (tempbx & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
| 2081 | tempbx &= (~RPLLDIV2XO); |
| 2082 | } else if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | |
| 2083 | VB_SIS301LV | VB_SIS302LV | |
| 2084 | VB_XGI301C))) { |
| 2085 | if (tempbx & TVSimuMode) |
| 2086 | tempbx &= (~RPLLDIV2XO); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2087 | } |
| 2088 | } |
| 2089 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2090 | } |
| 2091 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2092 | static unsigned char XGI_GetLCDInfo(unsigned short ModeIdIndex, |
| 2093 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2094 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2095 | unsigned short temp, tempax, tempbx, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2096 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2097 | pVBInfo->LCDResInfo = 0; |
| 2098 | pVBInfo->LCDTypeInfo = 0; |
| 2099 | pVBInfo->LCDInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2100 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2101 | /* si+Ext_ResInfo // */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2102 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2103 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2104 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2105 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2106 | if (tempbx == 0) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2107 | tempbx = Panel_1024x768; /* default */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2108 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 2109 | /* LCD75 */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2110 | if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2111 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2112 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2113 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2114 | tempax &= 0x0F; |
| 2115 | else |
| 2116 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2117 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2118 | if ((resinfo == 6) || (resinfo == 9)) { |
| 2119 | if (tempax >= 3) |
| 2120 | tempbx |= PanelRef75Hz; |
| 2121 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 2122 | if (tempax >= 4) |
| 2123 | tempbx |= PanelRef75Hz; |
| 2124 | } |
| 2125 | } |
| 2126 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2127 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2128 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2129 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2130 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2131 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2132 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2133 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2134 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2135 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2136 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2137 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2138 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2139 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2140 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2141 | tempbx |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2142 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2143 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2144 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2145 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2146 | |
Aaro Koskinen | 718e715 | 2013-02-09 00:03:46 +0200 | [diff] [blame] | 2147 | if (((pVBInfo->VBType & VB_SIS302LV) || |
| 2148 | (pVBInfo->VBType & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) |
| 2149 | tempbx |= SetLCDDualLink; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2150 | |
Aaro Koskinen | 718e715 | 2013-02-09 00:03:46 +0200 | [diff] [blame] | 2151 | if ((pVBInfo->LCDResInfo == Panel_1400x1050) && |
| 2152 | (pVBInfo->VBInfo & SetCRT2ToLCD) && (resinfo == 9) && |
| 2153 | (!(tempbx & EnableScalingLCD))) |
| 2154 | /* |
| 2155 | * set to center in 1280x1024 LCDB |
| 2156 | * for Panel_1400x1050 |
| 2157 | */ |
| 2158 | tempbx |= SetLCDtoNonExpanding; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2159 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2160 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2161 | if (pVBInfo->VBInfo & SetNotSimuMode) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2162 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2163 | } else { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2164 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2165 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2166 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2167 | pVBInfo->LCDInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2168 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2169 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2170 | } |
| 2171 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2172 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2173 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2174 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2175 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2176 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2177 | break; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2178 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2179 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2180 | } |
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 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2183 | } |
| 2184 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2185 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 2186 | { |
| 2187 | unsigned char ujRet = 0; |
| 2188 | unsigned char i = 0; |
| 2189 | |
| 2190 | for (i = 0; i < 8; i++) { |
| 2191 | ujRet = ujRet << 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2192 | ujRet |= (ujDate >> i) & 1; |
| 2193 | } |
| 2194 | |
| 2195 | return ujRet; |
| 2196 | } |
| 2197 | |
| 2198 | /*----------------------------------------------------------------------------*/ |
| 2199 | /* output */ |
| 2200 | /* bl[5] : LVDS signal */ |
| 2201 | /* bl[1] : LVDS backlight */ |
| 2202 | /* bl[0] : LVDS VDD */ |
| 2203 | /*----------------------------------------------------------------------------*/ |
| 2204 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 2205 | { |
| 2206 | unsigned char CR4A, temp; |
| 2207 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2208 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2209 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2210 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2211 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2212 | |
| 2213 | temp = XG21GPIODataTransfer(temp); |
| 2214 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2215 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2216 | return temp; |
| 2217 | } |
| 2218 | |
| 2219 | /*----------------------------------------------------------------------------*/ |
| 2220 | /* output */ |
| 2221 | /* bl[5] : LVDS signal */ |
| 2222 | /* bl[1] : LVDS backlight */ |
| 2223 | /* bl[0] : LVDS VDD */ |
| 2224 | /*----------------------------------------------------------------------------*/ |
| 2225 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 2226 | { |
| 2227 | unsigned char CR4A, CRB4, temp; |
| 2228 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2229 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2230 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2231 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2232 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2233 | |
| 2234 | temp &= 0x0C; |
| 2235 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2236 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2237 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2238 | temp |= ((CRB4 & 0x04) << 3); |
| 2239 | return temp; |
| 2240 | } |
| 2241 | |
Aaro Koskinen | 0ebf538 | 2011-11-27 23:03:09 +0200 | [diff] [blame] | 2242 | /*----------------------------------------------------------------------------*/ |
| 2243 | /* input */ |
| 2244 | /* bl[5] : 1;LVDS signal on */ |
| 2245 | /* bl[1] : 1;LVDS backlight on */ |
| 2246 | /* bl[0] : 1:LVDS VDD on */ |
| 2247 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 2248 | /* 000010b : clear bit 1, to set bit1 */ |
| 2249 | /* 000001b : clear bit 0, to set bit0 */ |
| 2250 | /*----------------------------------------------------------------------------*/ |
| 2251 | static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2252 | struct vb_device_info *pVBInfo) |
| 2253 | { |
| 2254 | unsigned char CR4A, temp; |
| 2255 | |
| 2256 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2257 | tempbh &= 0x23; |
| 2258 | tempbl &= 0x23; |
| 2259 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2260 | |
| 2261 | if (tempbh & 0x20) { |
| 2262 | temp = (tempbl >> 4) & 0x02; |
| 2263 | |
| 2264 | /* CR B4[1] */ |
| 2265 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2266 | |
| 2267 | } |
| 2268 | |
| 2269 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
| 2270 | |
| 2271 | temp = XG21GPIODataTransfer(temp); |
| 2272 | temp &= ~tempbh; |
| 2273 | temp |= tempbl; |
| 2274 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
| 2275 | } |
| 2276 | |
Aaro Koskinen | 776115a | 2011-11-27 23:03:10 +0200 | [diff] [blame] | 2277 | static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2278 | struct vb_device_info *pVBInfo) |
| 2279 | { |
| 2280 | unsigned char CR4A, temp; |
| 2281 | unsigned short tempbh0, tempbl0; |
| 2282 | |
| 2283 | tempbh0 = tempbh; |
| 2284 | tempbl0 = tempbl; |
| 2285 | tempbh0 &= 0x20; |
| 2286 | tempbl0 &= 0x20; |
| 2287 | tempbh0 >>= 3; |
| 2288 | tempbl0 >>= 3; |
| 2289 | |
| 2290 | if (tempbh & 0x20) { |
| 2291 | temp = (tempbl >> 4) & 0x02; |
| 2292 | |
| 2293 | /* CR B4[1] */ |
| 2294 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2295 | |
| 2296 | } |
| 2297 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
| 2298 | |
| 2299 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2300 | tempbh &= 0x03; |
| 2301 | tempbl &= 0x03; |
| 2302 | tempbh <<= 2; |
| 2303 | tempbl <<= 2; /* GPIOC,GPIOD */ |
| 2304 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2305 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
| 2306 | } |
| 2307 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2308 | static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info, |
| 2309 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2310 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2311 | { |
| 2312 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2313 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2314 | if (pXGIHWDE->jChipType == XG21) { |
| 2315 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2316 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2317 | /* LVDS VDD on */ |
| 2318 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2319 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2320 | } |
| 2321 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2322 | /* LVDS signal on */ |
| 2323 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2324 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2325 | /* LVDS backlight on */ |
| 2326 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2327 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2328 | /* DVO/DVI signal on */ |
| 2329 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2330 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2331 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2332 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2333 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2334 | if (pXGIHWDE->jChipType == XG27) { |
| 2335 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2336 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2337 | /* LVDS VDD on */ |
| 2338 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2339 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2340 | } |
| 2341 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2342 | /* LVDS signal on */ |
| 2343 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2344 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2345 | /* LVDS backlight on */ |
| 2346 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2347 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2348 | /* DVO/DVI signal on */ |
| 2349 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2350 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2351 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2352 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2353 | } |
| 2354 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2355 | void XGI_DisplayOff(struct xgifb_video_info *xgifb_info, |
| 2356 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2357 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2358 | { |
| 2359 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2360 | if (pXGIHWDE->jChipType == XG21) { |
| 2361 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2362 | /* LVDS backlight off */ |
| 2363 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2364 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2365 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2366 | /* DVO/DVI signal off */ |
| 2367 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2368 | } |
| 2369 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2370 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2371 | if (pXGIHWDE->jChipType == XG27) { |
| 2372 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2373 | /* LVDS backlight off */ |
| 2374 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2375 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2376 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2377 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2378 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2379 | /* DVO/DVI signal off */ |
| 2380 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2381 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2382 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2383 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2384 | } |
| 2385 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2386 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2387 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2388 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2389 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2390 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2391 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2392 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2393 | } |
| 2394 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2395 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2396 | { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2397 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2398 | } |
| 2399 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2400 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 2401 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2402 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2403 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2404 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2405 | /* reserve CR34 for CRT1 Mode No */ |
| 2406 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2407 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 2408 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2409 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2410 | } |
| 2411 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2412 | static void XGI_GetCRT2ResInfo(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2413 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2414 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2415 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2416 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2417 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 2418 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 2419 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2420 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2421 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2422 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2423 | if (modeflag & HalfDCLK) |
| 2424 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2425 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2426 | if (modeflag & DoubleScanMode) |
| 2427 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2428 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2429 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 2430 | goto exit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2431 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2432 | if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
| 2433 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2434 | if (yres == 1024) |
| 2435 | yres = 1056; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2436 | } |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2437 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2438 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2439 | if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
| 2440 | if (yres == 400) |
| 2441 | yres = 405; |
| 2442 | else if (yres == 350) |
| 2443 | yres = 360; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2444 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2445 | if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { |
| 2446 | if (yres == 360) |
| 2447 | yres = 375; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2448 | } |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2449 | } |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2450 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2451 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
| 2452 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2453 | if (!(pVBInfo->LCDInfo & LCDNonExpanding)) { |
| 2454 | if (yres == 350) |
| 2455 | yres = 357; |
| 2456 | else if (yres == 400) |
| 2457 | yres = 420; |
| 2458 | else if (yres == 480) |
| 2459 | yres = 525; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2460 | } |
| 2461 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2462 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2463 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2464 | if (xres == 720) |
| 2465 | xres = 640; |
| 2466 | |
| 2467 | exit: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2468 | pVBInfo->VGAHDE = xres; |
| 2469 | pVBInfo->HDE = xres; |
| 2470 | pVBInfo->VGAVDE = yres; |
| 2471 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2472 | } |
| 2473 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2474 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2475 | { |
| 2476 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2477 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) && |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 2478 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2479 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2480 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2481 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2482 | } |
| 2483 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2484 | static void XGI_GetRAMDAC2DATA(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2485 | unsigned short RefreshRateTableIndex, |
| 2486 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2487 | { |
| 2488 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2489 | CRT1Index; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2490 | |
| 2491 | pVBInfo->RVBHCMAX = 1; |
| 2492 | pVBInfo->RVBHCFACT = 1; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2493 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2494 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2495 | CRT1Index &= IndexMask; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2496 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[0]; |
| 2497 | temp2 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2498 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2499 | tempbx = (unsigned short) XGI_CRT1Table[CRT1Index].CR[8]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2500 | tempcx = (unsigned short) |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2501 | XGI_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2502 | tempcx &= 0x0100; |
| 2503 | tempcx = tempcx << 2; |
| 2504 | tempbx |= tempcx; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2505 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2506 | |
| 2507 | if (temp1 & 0x01) |
| 2508 | tempbx |= 0x0100; |
| 2509 | |
| 2510 | if (temp1 & 0x20) |
| 2511 | tempbx |= 0x0200; |
| 2512 | tempax += 5; |
| 2513 | |
| 2514 | if (modeflag & Charx8Dot) |
| 2515 | tempax *= 8; |
| 2516 | else |
| 2517 | tempax *= 9; |
| 2518 | |
| 2519 | pVBInfo->VGAHT = tempax; |
| 2520 | pVBInfo->HT = tempax; |
| 2521 | tempbx++; |
| 2522 | pVBInfo->VGAVT = tempbx; |
| 2523 | pVBInfo->VT = tempbx; |
| 2524 | } |
| 2525 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2526 | static void XGI_GetCRT2Data(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2527 | unsigned short RefreshRateTableIndex, |
| 2528 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2529 | { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 2530 | unsigned short tempax = 0, tempbx = 0, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2531 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 2532 | struct SiS_LCDData const *LCDPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2533 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2534 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2535 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2536 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2537 | pVBInfo->NewFlickerMode = 0; |
| 2538 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2539 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2540 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2541 | XGI_GetRAMDAC2DATA(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2542 | return; |
| 2543 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2544 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2545 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2546 | LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeIdIndex, |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 2547 | RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2548 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2549 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 2550 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 2551 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2552 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2553 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2554 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2555 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2556 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2557 | tempax = 1024; |
| 2558 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2559 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2560 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2561 | if (pVBInfo->VGAVDE == 357) |
| 2562 | tempbx = 527; |
| 2563 | else if (pVBInfo->VGAVDE == 420) |
| 2564 | tempbx = 620; |
| 2565 | else if (pVBInfo->VGAVDE == 525) |
| 2566 | tempbx = 775; |
| 2567 | else if (pVBInfo->VGAVDE == 600) |
| 2568 | tempbx = 775; |
Peter Huewe | 7580d7f | 2013-05-18 00:19:54 +0200 | [diff] [blame] | 2569 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2570 | } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2571 | tempax = 1024; |
| 2572 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2573 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2574 | tempax = 1280; |
| 2575 | if (pVBInfo->VGAVDE == 360) |
| 2576 | tempbx = 768; |
| 2577 | else if (pVBInfo->VGAVDE == 375) |
| 2578 | tempbx = 800; |
| 2579 | else if (pVBInfo->VGAVDE == 405) |
| 2580 | tempbx = 864; |
| 2581 | else |
| 2582 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2583 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2584 | tempax = 1280; |
| 2585 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2586 | } else if (pVBInfo->LCDResInfo == Panel_1280x960) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2587 | tempax = 1280; |
| 2588 | if (pVBInfo->VGAVDE == 350) |
| 2589 | tempbx = 700; |
| 2590 | else if (pVBInfo->VGAVDE == 400) |
| 2591 | tempbx = 800; |
| 2592 | else if (pVBInfo->VGAVDE == 1024) |
| 2593 | tempbx = 960; |
| 2594 | else |
| 2595 | tempbx = 960; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2596 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2597 | tempax = 1400; |
| 2598 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2599 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2600 | if (pVBInfo->VGAVDE == 1024) { |
| 2601 | tempax = 1280; |
| 2602 | tempbx = 1024; |
| 2603 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2604 | } else if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2605 | tempax = 1600; |
| 2606 | tempbx = 1200; /* alan 10/14/2003 */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2607 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2608 | if (pVBInfo->VGAVDE == 350) |
| 2609 | tempbx = 875; |
| 2610 | else if (pVBInfo->VGAVDE == 400) |
| 2611 | tempbx = 1000; |
| 2612 | } |
| 2613 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2614 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2615 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 2616 | tempax = pVBInfo->VGAHDE; |
| 2617 | tempbx = pVBInfo->VGAVDE; |
| 2618 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2619 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2620 | pVBInfo->HDE = tempax; |
| 2621 | pVBInfo->VDE = tempbx; |
| 2622 | return; |
| 2623 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2624 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2625 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 2626 | struct SiS_TVData const *TVPtr; |
| 2627 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2628 | TVPtr = XGI_GetTVPtr(ModeIdIndex, RefreshRateTableIndex, |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 2629 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2630 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2631 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 2632 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 2633 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 2634 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 2635 | pVBInfo->HDE = TVPtr->TVHDE; |
| 2636 | pVBInfo->VDE = TVPtr->TVVDE; |
| 2637 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 2638 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2639 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2640 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2641 | if (resinfo == 0x08) |
| 2642 | pVBInfo->NewFlickerMode = 0x40; |
| 2643 | else if (resinfo == 0x09) |
| 2644 | pVBInfo->NewFlickerMode = 0x40; |
| 2645 | else if (resinfo == 0x12) |
| 2646 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2647 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2648 | if (pVBInfo->VGAVDE == 350) |
| 2649 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2650 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2651 | tempax = ExtHiTVHT; |
| 2652 | tempbx = ExtHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2653 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2654 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2655 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 2656 | tempax = StHiTVHT; |
| 2657 | tempbx = StHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2658 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2659 | if (!(modeflag & Charx8Dot)) { |
| 2660 | tempax = StHiTextTVHT; |
| 2661 | tempbx = StHiTextTVVT; |
| 2662 | } |
| 2663 | } |
| 2664 | } |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2665 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 2666 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2667 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 2668 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 2669 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2670 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2671 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2672 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 2673 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2674 | } else if (pVBInfo->TVInfo & TVSetYPbPr525i) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2675 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 2676 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 2677 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2678 | tempax = NTSC1024x768HT; |
| 2679 | } |
| 2680 | } else { |
| 2681 | tempax = PALHT; |
| 2682 | tempbx = PALVT; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2683 | if (!(pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2684 | tempax = NTSCHT; |
| 2685 | tempbx = NTSCVT; |
| 2686 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2687 | tempax = NTSC1024x768HT; |
| 2688 | } |
| 2689 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2690 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2691 | pVBInfo->HT = tempax; |
| 2692 | pVBInfo->VT = tempbx; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2693 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2694 | } |
| 2695 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2696 | static void XGI_SetCRT2VCLK(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2697 | unsigned short RefreshRateTableIndex, |
| 2698 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2699 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2700 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2701 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2702 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2703 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 2704 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2705 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2706 | if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2707 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2708 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 2709 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 2710 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2711 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2712 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 2713 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2714 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2715 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2716 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
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 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2719 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2720 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2721 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2722 | } |
| 2723 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2724 | static unsigned short XGI_GetColorDepth(unsigned short ModeIdIndex, |
| 2725 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2726 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2727 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 2728 | short index; |
| 2729 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2730 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2731 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2732 | index = (modeflag & ModeTypeMask) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2733 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2734 | if (index < 0) |
| 2735 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2736 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2737 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2738 | } |
| 2739 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2740 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 2741 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2742 | unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2743 | struct vb_device_info *pVBInfo) |
| 2744 | { |
| 2745 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 2746 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 2747 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2748 | modeinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2749 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2750 | |
| 2751 | index = (modeinfo >> 8) & 0xFF; |
| 2752 | |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame] | 2753 | temp = XGI330_ScreenOffset[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2754 | |
| 2755 | if (infoflag & InterlaceMode) |
| 2756 | temp = temp << 1; |
| 2757 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2758 | colordepth = XGI_GetColorDepth(ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2759 | |
| 2760 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 2761 | temp = ModeNo - 0x7C; |
| 2762 | colordepth = ColorDepth[temp]; |
| 2763 | temp = 0x6B; |
| 2764 | if (infoflag & InterlaceMode) |
| 2765 | temp = temp << 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2766 | } |
Peter Huewe | 053004b | 2013-02-15 20:37:12 +0100 | [diff] [blame] | 2767 | return temp * colordepth; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2768 | } |
| 2769 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2770 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 2771 | unsigned short ModeIdIndex, |
| 2772 | unsigned short RefreshRateTableIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2773 | struct vb_device_info *pVBInfo) |
| 2774 | { |
| 2775 | unsigned short offset; |
| 2776 | unsigned char temp; |
| 2777 | |
| 2778 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2779 | return; |
| 2780 | |
| 2781 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 2782 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2783 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2784 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2785 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2786 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2787 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2788 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2789 | } |
| 2790 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 2791 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2792 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2793 | /* threshold high ,disable auto threshold */ |
| 2794 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 2795 | /* threshold low default 04h */ |
| 2796 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2797 | } |
| 2798 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2799 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2800 | unsigned short RefreshRateTableIndex, |
| 2801 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2802 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2803 | u8 tempcx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2804 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 2805 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2806 | XGI_SetCRT2FIFO(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2807 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2808 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2809 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2810 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2811 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 2812 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2813 | } |
| 2814 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2815 | static void XGI_SetGroup1(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2816 | unsigned short RefreshRateTableIndex, |
| 2817 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2818 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2819 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2820 | pushbx = 0, CRT1Index, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2821 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2822 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2823 | CRT1Index &= IndexMask; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2824 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2825 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2826 | /* bainy change table name */ |
| 2827 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2828 | /* BTVGA2HT 0x08,0x09 */ |
| 2829 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2830 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2831 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2832 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2833 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 2834 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2835 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2836 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 2837 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 2838 | tempcx = tempcx >> 1; |
| 2839 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 2840 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2841 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2842 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2843 | tempbx = XGI_CRT1Table[CRT1Index].CR[4]; |
| 2844 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[14] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2845 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2846 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2847 | tempcx = XGI_CRT1Table[CRT1Index].CR[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2848 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2849 | temp = XGI_CRT1Table[CRT1Index].CR[15]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2850 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 2851 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 2852 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2853 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2854 | tempbx += 4; |
| 2855 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2856 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2857 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 2858 | tempcx = pVBInfo->VGAHT / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2859 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2860 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2861 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2862 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2863 | } else { |
| 2864 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2865 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2866 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2867 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2868 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 2869 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2870 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2871 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 2872 | pushbx = pVBInfo->VGAHDE + 16; |
| 2873 | tempcx = tempcx >> 1; |
| 2874 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 2875 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2876 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2877 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2878 | tempbx = XGI_CRT1Table[CRT1Index].CR[3]; |
| 2879 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[5] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2880 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2881 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2882 | tempcx = XGI_CRT1Table[CRT1Index].CR[4]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2883 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2884 | temp = XGI_CRT1Table[CRT1Index].CR[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2885 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 2886 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 2887 | tempbx += 16; |
| 2888 | tempcx += 16; |
| 2889 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2890 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2891 | if (tempcx > pVBInfo->VGAHT) |
| 2892 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2893 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2894 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2895 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2896 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2897 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2898 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 2899 | tempbx = pushbx; |
| 2900 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 2901 | tempax |= (tempbx & 0xFF00); |
| 2902 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2903 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2904 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2905 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2906 | tempcx = (pVBInfo->VGAVT - 1); |
| 2907 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2908 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2909 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2910 | tempbx = pVBInfo->VGAVDE - 1; |
| 2911 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2912 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2913 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 2914 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2915 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2916 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2917 | /* BTVGA2VRS 0x10,0x11 */ |
| 2918 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 2919 | /* BTVGA2VRE 0x11 */ |
| 2920 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2921 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2922 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2923 | tempbx = XGI_CRT1Table[CRT1Index].CR[10]; |
| 2924 | temp = XGI_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2925 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2926 | if (temp & 0x04) |
| 2927 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2928 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2929 | if (temp & 0x080) |
| 2930 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2931 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2932 | temp = XGI_CRT1Table[CRT1Index].CR[14]; |
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 | if (temp & 0x08) |
| 2935 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2936 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2937 | temp = XGI_CRT1Table[CRT1Index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2938 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 2939 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2940 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2941 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2942 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2943 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 2944 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2945 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2946 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2947 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2948 | if (modeflag & DoubleScanMode) |
| 2949 | tempax |= 0x80; |
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 (modeflag & HalfDCLK) |
| 2952 | tempax |= 0x40; |
| 2953 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2954 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2955 | } |
| 2956 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2957 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 2958 | { |
| 2959 | unsigned long tempax, tempbx; |
| 2960 | |
| 2961 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 2962 | & 0xFFFF; |
| 2963 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 2964 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 2965 | |
| 2966 | return (unsigned short) tempax; |
| 2967 | } |
| 2968 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2969 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2970 | unsigned short RefreshRateTableIndex, |
| 2971 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2972 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2973 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2974 | modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2975 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2976 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2977 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2978 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2979 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2980 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 2981 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2982 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2983 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2984 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2985 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2986 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2987 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2988 | modeflag |= Charx8Dot; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2989 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2990 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2991 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2992 | if (modeflag & HalfDCLK) |
| 2993 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2994 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2995 | tempax = (tempax / tempcx) - 1; |
| 2996 | tempbx |= ((tempax & 0x00FF) << 8); |
| 2997 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2998 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
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 | temp = (tempbx & 0xFF00) >> 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3001 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3002 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3003 | if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3004 | | VB_SIS302LV | VB_XGI301C))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3005 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3006 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 3007 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) && |
| 3008 | !(pVBInfo->VBType & VB_SIS301LV) && (resinfo == 7)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3009 | temp -= 2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3010 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3011 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3012 | /* 0x05 Horizontal Display Start */ |
| 3013 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 3014 | /* 0x06 Horizontal Blank end */ |
| 3015 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3016 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3017 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 3018 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3019 | tempax = pVBInfo->VGAHT; |
| 3020 | else |
| 3021 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3022 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3023 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3024 | if (tempax >= pVBInfo->VGAHT) |
| 3025 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3026 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3027 | if (modeflag & HalfDCLK) |
| 3028 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3029 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3030 | tempax = (tempax / tempcx) - 5; |
| 3031 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3032 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3033 | temp = (tempbx & 0x00FF) - 1; |
| 3034 | if (!(modeflag & HalfDCLK)) { |
| 3035 | temp -= 6; |
| 3036 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3037 | temp -= 4; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3038 | temp -= 10; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3039 | } |
| 3040 | } |
| 3041 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3042 | tempbx = (tempbx & 0xFF00) >> 8; |
| 3043 | tempcx = (tempcx + tempbx) >> 1; |
| 3044 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3045 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3046 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3047 | temp -= 1; |
| 3048 | if (!(modeflag & HalfDCLK)) { |
| 3049 | if ((modeflag & Charx8Dot)) { |
| 3050 | temp += 4; |
| 3051 | if (pVBInfo->VGAHDE >= 800) |
| 3052 | temp -= 6; |
| 3053 | } |
| 3054 | } |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3055 | } else if (!(modeflag & HalfDCLK)) { |
| 3056 | temp -= 4; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3057 | if (pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3058 | pVBInfo->VGAHDE >= 800) { |
| 3059 | temp -= 7; |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3060 | if (pVBInfo->VGAHDE >= 1280 && |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3061 | pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3062 | (pVBInfo->LCDInfo & LCDNonExpanding)) |
| 3063 | temp += 28; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3064 | } |
| 3065 | } |
| 3066 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3067 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3068 | /* 0x07 Horizontal Retrace Start */ |
| 3069 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 3070 | /* 0x08 Horizontal Retrace End */ |
| 3071 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3072 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3073 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3074 | if (pVBInfo->TVInfo & TVSimuMode) { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3075 | if (ModeNo == 0x50) { |
Peter Huewe | 85b3847 | 2013-05-13 23:41:49 +0200 | [diff] [blame] | 3076 | if (pVBInfo->TVInfo == SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3077 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3078 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3079 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3080 | 0x08, 0x03); |
| 3081 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3082 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3083 | 0x07, 0x2f); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3084 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3085 | 0x08, 0x02); |
| 3086 | } |
| 3087 | } |
| 3088 | } |
| 3089 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3090 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3091 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3092 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3093 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3094 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3095 | tempbx = pVBInfo->VGAVT; |
| 3096 | push1 = tempbx; |
| 3097 | tempcx = 0x121; |
| 3098 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3099 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3100 | if (tempbx == 357) |
| 3101 | tempbx = 350; |
| 3102 | if (tempbx == 360) |
| 3103 | tempbx = 350; |
| 3104 | if (tempbx == 375) |
| 3105 | tempbx = 350; |
| 3106 | if (tempbx == 405) |
| 3107 | tempbx = 400; |
| 3108 | if (tempbx == 525) |
| 3109 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3110 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3111 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3112 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3113 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3114 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3115 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3116 | if (tempbx == 350) |
| 3117 | tempbx += 5; |
| 3118 | if (tempbx == 480) |
| 3119 | tempbx += 5; |
| 3120 | } |
| 3121 | } |
| 3122 | } |
| 3123 | tempbx--; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3124 | tempbx--; |
| 3125 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3126 | /* 0x10 vertical Blank Start */ |
| 3127 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3128 | tempbx = push2; |
| 3129 | tempbx--; |
| 3130 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3131 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3132 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3133 | if (tempbx & 0x0100) |
| 3134 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3135 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3136 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3137 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3138 | if (modeflag & DoubleScanMode) |
| 3139 | tempax |= 0x08000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3140 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3141 | if (tempbx & 0x0200) |
| 3142 | tempcx |= 0x0040; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3143 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3144 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3145 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3146 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3147 | if (tempbx & 0x0400) |
| 3148 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3149 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3150 | /* 0x11 Vertival Blank End */ |
| 3151 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3152 | |
| 3153 | tempax = push1; |
| 3154 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 3155 | tempax = tempax >> 2; |
| 3156 | push1 = tempax; /* push ax */ |
| 3157 | |
| 3158 | if (resinfo != 0x09) { |
| 3159 | tempax = tempax << 1; |
| 3160 | tempbx += tempax; |
| 3161 | } |
| 3162 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3163 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Miguel Gómez | 470c533 | 2012-07-06 12:40:50 +0200 | [diff] [blame] | 3164 | if ((pVBInfo->VBType & VB_SIS301LV) && |
| 3165 | !(pVBInfo->TVInfo & TVSetHiVision)) { |
| 3166 | if ((pVBInfo->TVInfo & TVSimuMode) && |
| 3167 | (pVBInfo->TVInfo & TVSetPAL)) { |
| 3168 | if (!(pVBInfo->VBType & VB_SIS301LV) || |
| 3169 | !(pVBInfo->TVInfo & |
| 3170 | (TVSetYPbPr525p | |
| 3171 | TVSetYPbPr750p | |
| 3172 | TVSetHiVision))) |
| 3173 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3174 | } |
| 3175 | } else { |
| 3176 | tempbx -= 10; |
| 3177 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3178 | } else if (pVBInfo->TVInfo & TVSimuMode) { |
| 3179 | if (pVBInfo->TVInfo & TVSetPAL) { |
| 3180 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 3181 | if (!(pVBInfo->TVInfo & |
| 3182 | (TVSetYPbPr525p | |
| 3183 | TVSetYPbPr750p | |
| 3184 | TVSetHiVision))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3185 | tempbx += 40; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3186 | } else { |
| 3187 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3188 | } |
| 3189 | } |
| 3190 | } |
| 3191 | tempax = push1; |
| 3192 | tempax = tempax >> 2; |
| 3193 | tempax++; |
| 3194 | tempax += tempbx; |
| 3195 | push1 = tempax; /* push ax */ |
| 3196 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3197 | if ((pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3198 | if (tempbx <= 513) { |
| 3199 | if (tempax >= 513) |
| 3200 | tempbx = 513; |
| 3201 | } |
| 3202 | } |
| 3203 | |
| 3204 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3205 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3206 | tempbx--; |
| 3207 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3208 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3209 | |
| 3210 | if (tempbx & 0x0100) |
| 3211 | tempcx |= 0x0008; |
| 3212 | |
| 3213 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3214 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3215 | |
| 3216 | tempbx++; |
| 3217 | |
| 3218 | if (tempbx & 0x0100) |
| 3219 | tempcx |= 0x0004; |
| 3220 | |
| 3221 | if (tempbx & 0x0200) |
| 3222 | tempcx |= 0x0080; |
| 3223 | |
| 3224 | if (tempbx & 0x0400) |
| 3225 | tempcx |= 0x0C00; |
| 3226 | |
| 3227 | tempbx = push1; /* pop ax */ |
| 3228 | temp = tempbx & 0x00FF; |
| 3229 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3230 | /* 0x0D vertical Retrace End */ |
| 3231 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3232 | |
| 3233 | if (tempbx & 0x0010) |
| 3234 | tempcx |= 0x2000; |
| 3235 | |
| 3236 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3237 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3238 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3239 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3240 | tempax = modeflag; |
| 3241 | temp = (tempax & 0xFF00) >> 8; |
| 3242 | |
| 3243 | temp = (temp >> 1) & 0x09; |
| 3244 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3245 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3246 | temp |= 0x01; |
| 3247 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3248 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 3249 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 3250 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3251 | |
| 3252 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 3253 | temp = 0x80; |
| 3254 | else |
| 3255 | temp = 0x00; |
| 3256 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3257 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3258 | } |
| 3259 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3260 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3261 | unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3262 | struct vb_device_info *pVBInfo) |
| 3263 | { |
| 3264 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 3265 | modeflag; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 3266 | unsigned char const *TimingPoint; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3267 | |
| 3268 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 3269 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3270 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3271 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3272 | |
| 3273 | tempax = 0; |
| 3274 | |
| 3275 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 3276 | tempax |= 0x0800; |
| 3277 | |
| 3278 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3279 | tempax |= 0x0400; |
| 3280 | |
| 3281 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 3282 | tempax |= 0x0200; |
| 3283 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3284 | if (!(pVBInfo->TVInfo & TVSetPAL)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3285 | tempax |= 0x1000; |
| 3286 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3287 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3288 | tempax |= 0x0100; |
| 3289 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3290 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3291 | tempax &= 0xfe00; |
| 3292 | |
| 3293 | tempax = (tempax & 0xff00) >> 8; |
| 3294 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3295 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3296 | TimingPoint = XGI330_NTSCTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3297 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3298 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3299 | TimingPoint = XGI330_PALTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3300 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3301 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3302 | TimingPoint = XGI330_HiTVExtTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3303 | |
| 3304 | if (pVBInfo->VBInfo & SetInSlaveMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3305 | TimingPoint = XGI330_HiTVSt2Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3306 | |
| 3307 | if (pVBInfo->SetFlag & TVSimuMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3308 | TimingPoint = XGI330_HiTVSt1Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3309 | |
| 3310 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3311 | TimingPoint = XGI330_HiTVTextTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3312 | } |
| 3313 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3314 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 3315 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3316 | TimingPoint = XGI330_YPbPr525iTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3317 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3318 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3319 | TimingPoint = XGI330_YPbPr525pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3320 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3321 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3322 | TimingPoint = XGI330_YPbPr750pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3323 | } |
| 3324 | |
| 3325 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3326 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3327 | |
| 3328 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3329 | /* di->temp2[j] */ |
| 3330 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3331 | |
| 3332 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3333 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3334 | |
| 3335 | temp = pVBInfo->NewFlickerMode; |
| 3336 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3337 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3338 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3339 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3340 | tempax = 520; |
| 3341 | else |
| 3342 | tempax = 440; |
| 3343 | |
| 3344 | if (pVBInfo->VDE <= tempax) { |
| 3345 | tempax -= pVBInfo->VDE; |
| 3346 | tempax = tempax >> 2; |
| 3347 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 3348 | push1 = tempax; |
| 3349 | temp = (tempax & 0xFF00) >> 8; |
| 3350 | temp += (unsigned short) TimingPoint[0]; |
| 3351 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3352 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3353 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3354 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3355 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3356 | | SetCRT2ToYPbPr525750)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3357 | tempcx = pVBInfo->VGAHDE; |
| 3358 | if (tempcx >= 1024) { |
| 3359 | temp = 0x17; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3360 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3361 | temp = 0x19; /* PAL */ |
| 3362 | } |
| 3363 | } |
| 3364 | } |
| 3365 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3366 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3367 | tempax = push1; |
| 3368 | temp = (tempax & 0xFF00) >> 8; |
| 3369 | temp += TimingPoint[1]; |
| 3370 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3371 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3372 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3373 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3374 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3375 | | SetCRT2ToYPbPr525750))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3376 | tempcx = pVBInfo->VGAHDE; |
| 3377 | if (tempcx >= 1024) { |
| 3378 | temp = 0x1D; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3379 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3380 | temp = 0x52; /* PAL */ |
| 3381 | } |
| 3382 | } |
| 3383 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3384 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3385 | } |
| 3386 | |
| 3387 | /* 301b */ |
| 3388 | tempcx = pVBInfo->HT; |
| 3389 | |
| 3390 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3391 | tempcx = tempcx >> 1; |
| 3392 | |
| 3393 | tempcx -= 2; |
| 3394 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3395 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3396 | |
| 3397 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3398 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3399 | |
| 3400 | tempcx = pVBInfo->HT >> 1; |
| 3401 | push1 = tempcx; /* push cx */ |
| 3402 | tempcx += 7; |
| 3403 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3404 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3405 | tempcx -= 4; |
| 3406 | |
| 3407 | temp = tempcx & 0x00FF; |
| 3408 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3409 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3410 | |
| 3411 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3412 | tempbx += tempcx; |
| 3413 | push2 = tempbx; |
| 3414 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3415 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3416 | temp = (tempbx & 0xFF00) >> 8; |
| 3417 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3418 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3419 | |
| 3420 | tempbx = push2; |
| 3421 | tempbx = tempbx + 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3422 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3423 | tempbx = tempbx - 4; |
| 3424 | tempcx = tempbx; |
| 3425 | } |
| 3426 | |
| 3427 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3428 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3429 | |
| 3430 | j += 2; |
| 3431 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 3432 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3433 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3434 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3435 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3436 | |
| 3437 | tempcx += 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3438 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3439 | tempcx -= 4; |
| 3440 | |
| 3441 | temp = tempcx & 0xFF; |
| 3442 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3443 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3444 | |
| 3445 | tempcx = push1; /* pop cx */ |
| 3446 | j += 2; |
| 3447 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3448 | tempcx -= temp; |
| 3449 | temp = tempcx & 0x00FF; |
| 3450 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3451 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3452 | |
| 3453 | tempcx -= 11; |
| 3454 | |
| 3455 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 3456 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3457 | tempcx = tempax - 1; |
| 3458 | } |
| 3459 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3460 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3461 | |
| 3462 | tempbx = pVBInfo->VDE; |
| 3463 | |
| 3464 | if (pVBInfo->VGAVDE == 360) |
| 3465 | tempbx = 746; |
| 3466 | if (pVBInfo->VGAVDE == 375) |
| 3467 | tempbx = 746; |
| 3468 | if (pVBInfo->VGAVDE == 405) |
| 3469 | tempbx = 853; |
| 3470 | |
| 3471 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3472 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3473 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3474 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3475 | (TVSetYPbPr525p | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3476 | tempbx = tempbx >> 1; |
| 3477 | } else |
| 3478 | tempbx = tempbx >> 1; |
| 3479 | } |
| 3480 | |
| 3481 | tempbx -= 2; |
| 3482 | temp = tempbx & 0x00FF; |
| 3483 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3484 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3485 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3486 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3487 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3488 | if (ModeNo == 0x2f) |
| 3489 | temp += 1; |
| 3490 | } |
| 3491 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3492 | } else if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3493 | if (ModeNo == 0x2f) |
| 3494 | temp += 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3495 | } |
| 3496 | } |
| 3497 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3498 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3499 | |
| 3500 | temp = (tempcx & 0xFF00) >> 8; |
| 3501 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 3502 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3503 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3504 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3505 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3506 | temp |= 0x10; |
| 3507 | |
| 3508 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3509 | temp |= 0x20; |
| 3510 | } |
| 3511 | } else { |
| 3512 | temp |= 0x10; |
| 3513 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3514 | temp |= 0x20; |
| 3515 | } |
| 3516 | } |
| 3517 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3518 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3519 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3520 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3521 | | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3522 | tempbx = pVBInfo->VDE; |
| 3523 | tempcx = tempbx - 2; |
| 3524 | |
| 3525 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3526 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p |
| 3527 | | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3528 | tempbx = tempbx >> 1; |
| 3529 | } |
| 3530 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3531 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3532 | temp = 0; |
| 3533 | if (tempcx & 0x0400) |
| 3534 | temp |= 0x20; |
| 3535 | |
| 3536 | if (tempbx & 0x0400) |
| 3537 | temp |= 0x40; |
| 3538 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3539 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3540 | } |
| 3541 | |
| 3542 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3543 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3544 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3545 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3546 | } |
| 3547 | |
| 3548 | tempbx = tempbx & 0x00FF; |
| 3549 | |
| 3550 | if (!(modeflag & HalfDCLK)) { |
| 3551 | tempcx = pVBInfo->VGAHDE; |
| 3552 | if (tempcx >= pVBInfo->HDE) { |
| 3553 | tempbx |= 0x2000; |
| 3554 | tempax &= 0x00FF; |
| 3555 | } |
| 3556 | } |
| 3557 | |
| 3558 | tempcx = 0x0101; |
| 3559 | |
| 3560 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 3561 | if (pVBInfo->VGAHDE >= 1024) { |
| 3562 | tempcx = 0x1920; |
| 3563 | if (pVBInfo->VGAHDE >= 1280) { |
| 3564 | tempcx = 0x1420; |
| 3565 | tempbx = tempbx & 0xDFFF; |
| 3566 | } |
| 3567 | } |
| 3568 | } |
| 3569 | |
| 3570 | if (!(tempbx & 0x2000)) { |
| 3571 | if (modeflag & HalfDCLK) |
| 3572 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 3573 | |
| 3574 | push1 = tempbx; |
| 3575 | tempeax = pVBInfo->VGAHDE; |
| 3576 | tempebx = (tempcx & 0xFF00) >> 8; |
| 3577 | longtemp = tempeax * tempebx; |
| 3578 | tempecx = tempcx & 0x00FF; |
| 3579 | longtemp = longtemp / tempecx; |
| 3580 | |
| 3581 | /* 301b */ |
| 3582 | tempecx = 8 * 1024; |
| 3583 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3584 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3585 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3586 | tempecx = tempecx * 8; |
| 3587 | } |
| 3588 | |
| 3589 | longtemp = longtemp * tempecx; |
| 3590 | tempecx = pVBInfo->HDE; |
| 3591 | temp2 = longtemp % tempecx; |
| 3592 | tempeax = longtemp / tempecx; |
| 3593 | if (temp2 != 0) |
| 3594 | tempeax += 1; |
| 3595 | |
| 3596 | tempax = (unsigned short) tempeax; |
| 3597 | |
| 3598 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3599 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3600 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3601 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 3602 | } |
| 3603 | /* end 301b */ |
| 3604 | |
| 3605 | tempbx = push1; |
| 3606 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 3607 | | (tempbx & 0x00FF)); |
| 3608 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 3609 | | (tempax & 0x00FF)); |
| 3610 | temp = (tempax & 0xFF00) >> 8; |
| 3611 | } else { |
| 3612 | temp = (tempax & 0x00FF) >> 8; |
| 3613 | } |
| 3614 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3615 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3616 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3617 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3618 | temp = tempcx & 0x00FF; |
| 3619 | |
| 3620 | if (tempbx & 0x2000) |
| 3621 | temp = 0; |
| 3622 | |
| 3623 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3624 | temp |= 0x18; |
| 3625 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3626 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3627 | if (pVBInfo->TVInfo & TVSetPAL) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3628 | tempbx = 0x0382; |
| 3629 | tempcx = 0x007e; |
| 3630 | } else { |
| 3631 | tempbx = 0x0369; |
| 3632 | tempcx = 0x0061; |
| 3633 | } |
| 3634 | |
| 3635 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3636 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3637 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3638 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3639 | |
| 3640 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 3641 | temp = temp << 2; |
| 3642 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 3643 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3644 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3645 | temp |= 0x10; |
| 3646 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3647 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3648 | temp |= 0x20; |
| 3649 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3650 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3651 | temp |= 0x60; |
| 3652 | } |
| 3653 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3654 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3655 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3656 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3657 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3658 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3659 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 3660 | TimingPoint = XGI_NTSC1024AdjTime; |
| 3661 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3662 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3663 | TimingPoint[j]); |
| 3664 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3665 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3666 | } |
| 3667 | } |
| 3668 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 3669 | /* Modify for 301C PALM Support */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3670 | if (pVBInfo->VBType & VB_XGI301C) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3671 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3672 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3673 | 0x08); /* PALM Mode */ |
| 3674 | } |
| 3675 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3676 | if (pVBInfo->TVInfo & TVSetPALM) { |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 3677 | tempax = xgifb_reg_get(pVBInfo->Part2Port, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3678 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3679 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3680 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3681 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3682 | } |
| 3683 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3684 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3685 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3686 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3687 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3688 | } |
| 3689 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 3690 | static void XGI_SetLCDRegs(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3691 | unsigned short RefreshRateTableIndex, |
| 3692 | struct vb_device_info *pVBInfo) |
| 3693 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 3694 | unsigned short pushbx, tempax, tempbx, tempcx, temp, tempah, |
| 3695 | tempbh, tempch; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3696 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 3697 | struct XGI_LCDDesStruct const *LCDBDesPtr = NULL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3698 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3699 | /* si+Ext_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3700 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3701 | return; |
| 3702 | |
| 3703 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 3704 | |
| 3705 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3706 | tempbx = tempbx >> 1; |
| 3707 | |
| 3708 | tempbx -= 1; |
| 3709 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3710 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3711 | temp = (tempbx & 0xFF00) >> 8; |
| 3712 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3713 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3714 | temp = 0x01; |
| 3715 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3716 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3717 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3718 | tempbx--; |
| 3719 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3720 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3721 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3722 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3723 | |
| 3724 | tempcx = pVBInfo->VT - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3725 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3726 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3727 | temp = (tempcx & 0xFF00) >> 8; |
| 3728 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3729 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3730 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 3731 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 3732 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 3733 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3734 | |
Justin P. Mattock | 558f758 | 2012-10-02 21:17:11 -0700 | [diff] [blame] | 3735 | /* Customized LCDB Does not add */ |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 3736 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 3737 | LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeIdIndex, |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 3738 | RefreshRateTableIndex, pVBInfo); |
| 3739 | else |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 3740 | LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeIdIndex, |
| 3741 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 3742 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3743 | tempah = pVBInfo->LCDResInfo; |
| 3744 | tempah &= PanelResInfo; |
| 3745 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3746 | if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3747 | tempbx = 1024; |
| 3748 | tempcx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3749 | } else if ((tempah == Panel_1280x1024) || |
| 3750 | (tempah == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3751 | tempbx = 1280; |
| 3752 | tempcx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3753 | } else if (tempah == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3754 | tempbx = 1400; |
| 3755 | tempcx = 1050; |
| 3756 | } else { |
| 3757 | tempbx = 1600; |
| 3758 | tempcx = 1200; |
| 3759 | } |
| 3760 | |
| 3761 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 3762 | tempbx = pVBInfo->HDE; |
| 3763 | tempcx = pVBInfo->VDE; |
| 3764 | } |
| 3765 | |
| 3766 | pushbx = tempbx; |
| 3767 | tempax = pVBInfo->VT; |
| 3768 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 3769 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 3770 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 3771 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 3772 | tempbx = pVBInfo->LCDVDES; |
| 3773 | tempcx += tempbx; |
| 3774 | |
| 3775 | if (tempcx >= tempax) |
| 3776 | tempcx -= tempax; /* lcdvdes */ |
| 3777 | |
| 3778 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3779 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3780 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3781 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3782 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 3783 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 3784 | tempah = tempch; |
| 3785 | tempah = tempah << 3; |
| 3786 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3787 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3788 | |
| 3789 | /* getlcdsync() */ |
| 3790 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 3791 | tempcx = tempbx; |
| 3792 | tempax = pVBInfo->VT; |
| 3793 | tempbx = pVBInfo->LCDVRS; |
| 3794 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3795 | tempcx += tempbx; |
| 3796 | if (tempcx >= tempax) |
| 3797 | tempcx -= tempax; |
| 3798 | |
| 3799 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3800 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3801 | temp = (tempbx & 0xFF00) >> 8; |
| 3802 | temp = temp << 4; |
| 3803 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3804 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3805 | tempcx = pushbx; |
| 3806 | tempax = pVBInfo->HT; |
| 3807 | tempbx = pVBInfo->LCDHDES; |
| 3808 | tempbx &= 0x0FFF; |
| 3809 | |
| 3810 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 3811 | tempax = tempax >> 1; |
| 3812 | tempbx = tempbx >> 1; |
| 3813 | tempcx = tempcx >> 1; |
| 3814 | } |
| 3815 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3816 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3817 | tempbx += 1; |
| 3818 | |
| 3819 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 3820 | tempbx += 1; |
| 3821 | |
| 3822 | tempcx += tempbx; |
| 3823 | |
| 3824 | if (tempcx >= tempax) |
| 3825 | tempcx -= tempax; |
| 3826 | |
| 3827 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3828 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3829 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3830 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3831 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3832 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3833 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3834 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3835 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3836 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 3837 | tempcx = tempax; |
| 3838 | tempax = pVBInfo->HT; |
| 3839 | tempbx = pVBInfo->LCDHRS; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3840 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 3841 | tempax = tempax >> 1; |
| 3842 | tempbx = tempbx >> 1; |
| 3843 | tempcx = tempcx >> 1; |
| 3844 | } |
| 3845 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3846 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3847 | tempbx += 1; |
| 3848 | |
| 3849 | tempcx += tempbx; |
| 3850 | |
| 3851 | if (tempcx >= tempax) |
| 3852 | tempcx -= tempax; |
| 3853 | |
| 3854 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3855 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3856 | |
| 3857 | temp = (tempbx & 0xFF00) >> 8; |
| 3858 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3859 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3860 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3861 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3862 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3863 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3864 | if (pVBInfo->VGAVDE == 525) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3865 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 3866 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3867 | | VB_XGI301C)) { |
| 3868 | temp = 0xC6; |
| 3869 | } else |
| 3870 | temp = 0xC4; |
| 3871 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3872 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 3873 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3874 | } |
| 3875 | |
| 3876 | if (pVBInfo->VGAVDE == 420) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3877 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 3878 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3879 | | VB_XGI301C)) { |
| 3880 | temp = 0x4F; |
| 3881 | } else |
| 3882 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3883 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3884 | } |
| 3885 | } |
| 3886 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3887 | |
| 3888 | /* --------------------------------------------------------------------- */ |
| 3889 | /* Function : XGI_GetTap4Ptr */ |
| 3890 | /* Input : */ |
| 3891 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 3892 | /* Description : */ |
| 3893 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 3894 | static struct XGI301C_Tap4TimingStruct const |
| 3895 | *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3896 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3897 | unsigned short tempax, tempbx, i; |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 3898 | struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3899 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3900 | if (tempcx == 0) { |
| 3901 | tempax = pVBInfo->VGAHDE; |
| 3902 | tempbx = pVBInfo->HDE; |
| 3903 | } else { |
| 3904 | tempax = pVBInfo->VGAVDE; |
| 3905 | tempbx = pVBInfo->VDE; |
| 3906 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3907 | |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3908 | if (tempax <= tempbx) |
| 3909 | return &xgifb_tap4_timing[0]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3910 | else |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3911 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3912 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3913 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3914 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3915 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3916 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 3917 | if ((pVBInfo->TVInfo & TVSetYPbPr525i) || |
| 3918 | (pVBInfo->TVInfo & TVSetYPbPr525p)) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3919 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3920 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3921 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 3922 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3923 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3924 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3925 | Tap4TimingPtr = xgifb_tap4_timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3926 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3927 | i = 0; |
| 3928 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 3929 | if (Tap4TimingPtr[i].DE == tempax) |
| 3930 | break; |
| 3931 | i++; |
| 3932 | } |
| 3933 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3934 | } |
| 3935 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3936 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3937 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3938 | unsigned short i, j; |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 3939 | struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3940 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3941 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 3942 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3943 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3944 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 3945 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3946 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3947 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3948 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3949 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3950 | /* Set Vertical Scaling */ |
| 3951 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3952 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3953 | xgifb_reg_set(pVBInfo->Part2Port, |
| 3954 | i, |
| 3955 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3956 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3957 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3958 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3959 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3960 | /* Enable V.Scaling */ |
| 3961 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3962 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3963 | /* Enable H.Scaling */ |
| 3964 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3965 | } |
| 3966 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 3967 | static void XGI_SetGroup3(unsigned short ModeIdIndex, |
| 3968 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3969 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3970 | unsigned short i; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 3971 | unsigned char const *tempdi; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3972 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3973 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3974 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3975 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3976 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3977 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3978 | if (pVBInfo->TVInfo & TVSetPAL) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3979 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 3980 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3981 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3982 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 3983 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3984 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3985 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3986 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 3987 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3988 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3989 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3990 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 3991 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 3992 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3993 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3994 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3995 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo |
| 3996 | & SetCRT2ToYPbPr525750)) { |
| 3997 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3998 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3999 | |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4000 | tempdi = XGI330_HiTVGroup3Data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4001 | if (pVBInfo->SetFlag & TVSimuMode) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4002 | tempdi = XGI330_HiTVGroup3Simu; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4003 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4004 | tempdi = XGI330_HiTVGroup3Text; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 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->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4008 | tempdi = XGI330_Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4009 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4010 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4011 | tempdi = XGI330_Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4012 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4013 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4014 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4015 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4016 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4017 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4018 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4019 | } |
| 4020 | } |
Aaro Koskinen | 2351d1f | 2013-05-29 23:59:13 +0300 | [diff] [blame] | 4021 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4022 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4023 | static void XGI_SetGroup4(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4024 | unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4025 | struct vb_device_info *pVBInfo) |
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 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4028 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4029 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4030 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4031 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4032 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4033 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4034 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4035 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4036 | tempbx = pVBInfo->RVBHCMAX; |
| 4037 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4038 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4039 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 4040 | tempcx = pVBInfo->VGAHT - 1; |
| 4041 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4042 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4043 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4044 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 4045 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4046 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4047 | tempcx = pVBInfo->VGAVT - 1; |
| 4048 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4049 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4050 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4051 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4052 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4053 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4054 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4055 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4056 | tempcx = pVBInfo->VBInfo; |
| 4057 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4058 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4059 | if (modeflag & HalfDCLK) |
| 4060 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4061 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4062 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4063 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4064 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4065 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4066 | temp = 0; |
| 4067 | if (tempbx <= 1024) |
| 4068 | temp = 0xA0; |
| 4069 | if (tempbx == 1280) |
| 4070 | temp = 0xC0; |
| 4071 | } else if (tempcx & SetCRT2ToTV) { |
| 4072 | temp = 0xA0; |
| 4073 | if (tempbx <= 800) |
| 4074 | temp = 0x80; |
| 4075 | } else { |
| 4076 | temp = 0x80; |
| 4077 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4078 | temp = 0; |
| 4079 | if (tempbx > 800) |
| 4080 | temp = 0x60; |
| 4081 | } |
| 4082 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4083 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4084 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4085 | temp = 0x00; |
| 4086 | if (pVBInfo->VGAHDE == 1280) |
| 4087 | temp = 0x40; |
| 4088 | if (pVBInfo->VGAHDE == 1024) |
| 4089 | temp = 0x20; |
| 4090 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4091 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4092 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4093 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4094 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4095 | tempcx = pVBInfo->RVBHRS; |
| 4096 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4097 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
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 | tempeax = pVBInfo->VGAVDE; |
| 4100 | tempcx |= 0x04000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4101 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4102 | if (tempeax <= tempebx) { |
| 4103 | tempcx = (tempcx & (~0x4000)); |
| 4104 | tempeax = pVBInfo->VGAVDE; |
| 4105 | } else { |
| 4106 | tempeax -= tempebx; |
| 4107 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4108 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4109 | templong = (tempeax * 256 * 1024) % tempebx; |
| 4110 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 4111 | tempebx = tempeax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4112 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4113 | if (templong != 0) |
| 4114 | tempebx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4115 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4116 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4117 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4118 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4119 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4120 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4121 | tempbx = (unsigned short) (tempebx >> 16); |
| 4122 | temp = tempbx & 0x00FF; |
| 4123 | temp = temp << 4; |
| 4124 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4125 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4126 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4127 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4128 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4129 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4130 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4131 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4132 | tempax = pVBInfo->VGAHDE; |
| 4133 | if (modeflag & HalfDCLK) |
| 4134 | tempax = tempax >> 1; |
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 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4137 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4138 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4139 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4140 | if (tempax > 800) |
| 4141 | tempax -= 800; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 4142 | } else if (pVBInfo->VGAHDE > 800) { |
| 4143 | if (pVBInfo->VGAHDE == 1024) |
| 4144 | tempax = (tempax * 25 / 32) - 1; |
| 4145 | else |
| 4146 | tempax = (tempax * 20 / 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4147 | } |
| 4148 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4149 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4150 | temp = (tempax & 0xFF00) >> 8; |
| 4151 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4152 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4153 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4154 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4155 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4156 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4157 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4158 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4159 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4160 | } |
| 4161 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4162 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4163 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4164 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4165 | | TVSetYPbPr525p | TVSetYPbPr750p |
| 4166 | | TVSetHiVision))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4167 | temp |= 0x0001; |
| 4168 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 4169 | && (!(pVBInfo->TVInfo |
| 4170 | & TVSimuMode))) |
| 4171 | temp &= (~0x0001); |
| 4172 | } |
| 4173 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4174 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4175 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4176 | tempbx = pVBInfo->HT; |
| 4177 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4178 | tempbx = tempbx >> 1; |
| 4179 | tempbx = (tempbx >> 1) - 2; |
| 4180 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4181 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4182 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4183 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4184 | } |
| 4185 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4186 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4187 | XGI_SetCRT2VCLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4188 | } |
| 4189 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4190 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 4191 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4192 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4193 | } |
| 4194 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4195 | static void XGI_SetGroup5(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4196 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4197 | if (pVBInfo->ModeType == ModeVGA) { |
| 4198 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4199 | | DisableCRT2Display))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4200 | XGINew_EnableCRT2(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4201 | } |
| 4202 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4203 | } |
| 4204 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 4205 | static void XGI_DisableGatingCRT(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4206 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4207 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4208 | } |
| 4209 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4210 | static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, |
| 4211 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 4212 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4213 | { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4214 | unsigned short xres, yres, colordepth, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4215 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4216 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 4217 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4218 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4219 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4220 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4221 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4222 | if (!(modeflag & Charx8Dot)) { |
| 4223 | xres /= 9; |
| 4224 | xres *= 8; |
| 4225 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4226 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4227 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 4228 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4229 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4230 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 4231 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4232 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4233 | if (xres > xgifb_info->lvds_data.LVDSHDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4234 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4235 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4236 | if (yres > xgifb_info->lvds_data.LVDSVDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4237 | return 0; |
| 4238 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4239 | if (xres != xgifb_info->lvds_data.LVDSHDE || |
| 4240 | yres != xgifb_info->lvds_data.LVDSVDE) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4241 | colordepth = XGI_GetColorDepth(ModeIdIndex, pVBInfo); |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4242 | if (colordepth > 2) |
| 4243 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4244 | } |
| 4245 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4246 | } |
| 4247 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4248 | static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, |
| 4249 | int chip_id, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4250 | unsigned short ModeIdIndex, |
| 4251 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4252 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4253 | unsigned char temp, Miscdata; |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4254 | unsigned short xres, yres, modeflag, resindex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4255 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 4256 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 4257 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4258 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4259 | temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4260 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4261 | temp &= LCDPolarity; |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 4262 | Miscdata = inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4263 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4264 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4265 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4266 | temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4267 | /* SR35[7] FP VSync polarity */ |
| 4268 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 4269 | /* SR30[5] FP HSync polarity */ |
| 4270 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4271 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4272 | if (chip_id == XG27) |
| 4273 | XGI_SetXG27FPBits(pVBInfo); |
| 4274 | else |
| 4275 | XGI_SetXG21FPBits(pVBInfo); |
| 4276 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4277 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 4278 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4279 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4280 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4281 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
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 (!(modeflag & Charx8Dot)) |
| 4284 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4285 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4286 | LVDSHT = xgifb_info->lvds_data.LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4287 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4288 | LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4289 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4290 | if (LVDSHBS > LVDSHT) |
| 4291 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4292 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4293 | LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4294 | if (LVDSHRS > LVDSHT) |
| 4295 | LVDSHRS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4296 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4297 | LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4298 | if (LVDSHRE > LVDSHT) |
| 4299 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4300 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4301 | LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4302 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4303 | LVDSVT = xgifb_info->lvds_data.LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4304 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4305 | LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4306 | if (modeflag & DoubleScanMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4307 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4308 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4309 | if (LVDSVBS > LVDSVT) |
| 4310 | LVDSVBS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4311 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4312 | LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4313 | if (LVDSVRS > LVDSVT) |
| 4314 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4315 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4316 | LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4317 | if (LVDSVRE > LVDSVT) |
| 4318 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4319 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4320 | LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4321 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 4322 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4323 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4324 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4325 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4326 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4327 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4328 | /* HT SR0B[1:0] CR00 */ |
| 4329 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4330 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4331 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4332 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4333 | /* HBS SR0B[5:4] CR02 */ |
| 4334 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4335 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4336 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4337 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4338 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 4339 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4340 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 4341 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 4342 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4343 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4344 | /* HRS SR0B[7:6] CR04 */ |
| 4345 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4346 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4347 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
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 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 4350 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4351 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4352 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4353 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4354 | /* HRE SR0C[2] CR05[4:0] */ |
| 4355 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4356 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 4357 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4358 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4359 | /* Panel HRE SR2F[7:2] */ |
| 4360 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4361 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4362 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4363 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 4364 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4365 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 4366 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 4367 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4368 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4369 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4370 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 4371 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4372 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 4373 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 4374 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4375 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4376 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4377 | /* VBE SR0A[4] CR16 */ |
| 4378 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4379 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4380 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4381 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4382 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 4383 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4384 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 4385 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 4386 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4387 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4388 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4389 | if (chip_id == XG27) { |
| 4390 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
| 4391 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, |
| 4392 | (value & 0x700) >> 8); |
| 4393 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
| 4394 | } else { |
| 4395 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
| 4396 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, |
| 4397 | (value & 0x600) >> 9); |
| 4398 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
| 4399 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
| 4400 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4401 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4402 | /* VRE SR0A[5] CR11[3:0] */ |
| 4403 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4404 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 4405 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4406 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4407 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4408 | if (chip_id == XG27) |
| 4409 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4410 | (value << 2) & 0xFC); |
| 4411 | else |
| 4412 | /* SR3F[7] has to be 0, h/w bug */ |
| 4413 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4414 | (value << 2) & 0x7C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4415 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4416 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4417 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4418 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4419 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4420 | 0x2B, xgifb_info->lvds_data.VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4421 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4422 | 0x2C, xgifb_info->lvds_data.VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4423 | value += 0x10; |
| 4424 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4425 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4426 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4427 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4428 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4429 | /* set data, panning = 0, shift left 1 dot*/ |
| 4430 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4431 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4432 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4433 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4434 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4435 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4436 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4437 | |
| 4438 | } |
| 4439 | |
| 4440 | /* --------------------------------------------------------------------- */ |
| 4441 | /* Function : XGI_IsLCDON */ |
| 4442 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4443 | /* Output : 0 : Skip PSC Control */ |
| 4444 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4445 | /* Description : */ |
| 4446 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4447 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4448 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4449 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4450 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4451 | tempax = pVBInfo->VBInfo; |
| 4452 | if (tempax & SetCRT2ToDualEdge) |
| 4453 | return 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4454 | else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4455 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4456 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4457 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4458 | } |
| 4459 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4460 | static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, |
| 4461 | struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4462 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4463 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 4464 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4465 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4466 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4467 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4468 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4469 | if (!(pVBInfo->VBInfo & |
| 4470 | (DisableCRT2Display | SetSimuScanMode))) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4471 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | 41fc5f0 | 2013-05-29 23:59:12 +0300 | [diff] [blame] | 4472 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4473 | tempah = 0x7F; /* Disable Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4474 | } |
| 4475 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4476 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4477 | /* disable part4_1f */ |
| 4478 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4479 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4480 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4481 | if (((pVBInfo->VBInfo & |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 4482 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) || |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 4483 | (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4484 | /* LVDS Driver power down */ |
| 4485 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4486 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4487 | |
Aaro Koskinen | d172463 | 2013-05-29 23:59:09 +0300 | [diff] [blame] | 4488 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA | |
| 4489 | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4490 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4491 | |
Aaro Koskinen | 41fc5f0 | 2013-05-29 23:59:12 +0300 | [diff] [blame] | 4492 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
| 4493 | /* Power down */ |
| 4494 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4495 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4496 | /* disable TV as primary VGA swap */ |
| 4497 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4498 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4499 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 4500 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4501 | |
Aaro Koskinen | c4f9c31 | 2013-05-29 23:59:07 +0300 | [diff] [blame] | 4502 | if ((pVBInfo->VBInfo & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4503 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4504 | ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4505 | (pVBInfo->VBInfo & |
| 4506 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4507 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4508 | |
Aaro Koskinen | c4f9c31 | 2013-05-29 23:59:07 +0300 | [diff] [blame] | 4509 | if ((pVBInfo->VBInfo & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4510 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4511 | (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) || |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4512 | (pVBInfo->VBInfo & |
| 4513 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 4514 | /* save Part1 index 0 */ |
| 4515 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 4516 | /* BTDAC = 1, avoid VB reset */ |
| 4517 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 4518 | /* disable CRT2 */ |
| 4519 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4520 | /* restore Part1 index 0 */ |
| 4521 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4522 | } |
| 4523 | } else { /* {301} */ |
| 4524 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4525 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 4526 | /* Disable CRT2 */ |
| 4527 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4528 | /* Disable TV asPrimary VGA swap */ |
| 4529 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4530 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4531 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4532 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4533 | | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4534 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4535 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4536 | } |
| 4537 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4538 | /* --------------------------------------------------------------------- */ |
| 4539 | /* Function : XGI_GetTVPtrIndex */ |
| 4540 | /* Input : */ |
| 4541 | /* Output : */ |
| 4542 | /* Description : bx 0 : ExtNTSC */ |
| 4543 | /* 1 : StNTSC */ |
| 4544 | /* 2 : ExtPAL */ |
| 4545 | /* 3 : StPAL */ |
| 4546 | /* 4 : ExtHiTV */ |
| 4547 | /* 5 : StHiTV */ |
| 4548 | /* 6 : Ext525i */ |
| 4549 | /* 7 : St525i */ |
| 4550 | /* 8 : Ext525p */ |
| 4551 | /* 9 : St525p */ |
| 4552 | /* A : Ext750p */ |
| 4553 | /* B : St750p */ |
| 4554 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4555 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4556 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4557 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4558 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4559 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4560 | tempbx = 2; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4561 | if (pVBInfo->TVInfo & TVSetHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4562 | tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4563 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4564 | tempbx = 6; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4565 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4566 | tempbx = 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4567 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4568 | tempbx = 10; |
| 4569 | if (pVBInfo->TVInfo & TVSimuMode) |
| 4570 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4571 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4572 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4573 | } |
| 4574 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4575 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4576 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4577 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4578 | /* Output : bx 0 : NTSC */ |
| 4579 | /* 1 : PAL */ |
| 4580 | /* 2 : PALM */ |
| 4581 | /* 3 : PALN */ |
| 4582 | /* 4 : NTSC1024x768 */ |
| 4583 | /* 5 : PAL-M 1024x768 */ |
| 4584 | /* 6-7: reserved */ |
| 4585 | /* cl 0 : YFilter1 */ |
| 4586 | /* 1 : YFilter2 */ |
| 4587 | /* ch 0 : 301A */ |
| 4588 | /* 1 : 301B/302B/301LV/302LV */ |
| 4589 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4590 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4591 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 4592 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4593 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4594 | *tempbx = 0; |
| 4595 | *tempcl = 0; |
| 4596 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4597 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4598 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4599 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4600 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4601 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4602 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4603 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4604 | if (pVBInfo->TVInfo & TVSetPALN) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4605 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4606 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4607 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 4608 | *tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4609 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4610 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4611 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4612 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4613 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4614 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4615 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 4616 | & TVSimuMode)) { |
| 4617 | *tempbx += 8; |
| 4618 | *tempcl += 1; |
| 4619 | } |
| 4620 | } |
| 4621 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4622 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4623 | | VB_SIS302LV | VB_XGI301C)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4624 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4625 | } |
| 4626 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4627 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4628 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4629 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4630 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4631 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4632 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4633 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4634 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4635 | tempbh = 0; |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 4636 | tempbl = XGI301TVDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4637 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4638 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 4639 | tempbl = tempbl >> 4; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4640 | if (pVBInfo->VBInfo & |
| 4641 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 4642 | tempbh = XGI301LCDDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4643 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4644 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4645 | tempbl = tempbh; |
| 4646 | } |
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 | tempbl &= 0x0F; |
| 4649 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4650 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4651 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4652 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 4653 | | SetCRT2ToTV)) { /* Channel B */ |
| 4654 | tempah &= 0xF0; |
| 4655 | tempah |= tempbl; |
| 4656 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4657 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4658 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 4659 | /* Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4660 | tempah &= 0x0F; |
| 4661 | tempah |= tempbh; |
| 4662 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4663 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4664 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4665 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4666 | } |
| 4667 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4668 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 4669 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4670 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4671 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4672 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4673 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4674 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4675 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4676 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4677 | /* Enable Dither */ |
| 4678 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4679 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4680 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4681 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4682 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4683 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4684 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4685 | } |
| 4686 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4687 | /* --------------------------------------------------------------------- */ |
| 4688 | /* Function : XGI_SetLCDCap_B */ |
| 4689 | /* Input : cx -> LCD Capability */ |
| 4690 | /* Output : */ |
| 4691 | /* Description : */ |
| 4692 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4693 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 4694 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4695 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4696 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4697 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4698 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 4699 | | 0x0c)); |
| 4700 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4701 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4702 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 4703 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4704 | } |
| 4705 | |
Aaro Koskinen | 7f04ec3 | 2011-11-27 23:03:05 +0200 | [diff] [blame] | 4706 | static void XGI_LongWait(struct vb_device_info *pVBInfo) |
| 4707 | { |
| 4708 | unsigned short i; |
| 4709 | |
| 4710 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
| 4711 | |
| 4712 | if (!(i & 0xC0)) { |
| 4713 | for (i = 0; i < 0xFFFF; i++) { |
| 4714 | if (!(inb(pVBInfo->P3da) & 0x08)) |
| 4715 | break; |
| 4716 | } |
| 4717 | |
| 4718 | for (i = 0; i < 0xFFFF; i++) { |
| 4719 | if ((inb(pVBInfo->P3da) & 0x08)) |
| 4720 | break; |
| 4721 | } |
| 4722 | } |
| 4723 | } |
| 4724 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4725 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4726 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4727 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4728 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4729 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4730 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4731 | /* disable down spectrum D[4] */ |
| 4732 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4733 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4734 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4735 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4736 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4737 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4738 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4739 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4740 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4741 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4742 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4743 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4744 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 4745 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4746 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4747 | } |
| 4748 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4749 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 4750 | { |
| 4751 | unsigned short tempcx; |
| 4752 | |
| 4753 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 4754 | |
Peter Huewe | f951dd0 | 2013-02-05 00:29:47 +0100 | [diff] [blame] | 4755 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | |
| 4756 | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4757 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4758 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4759 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4760 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4761 | (unsigned char) (tempcx & 0x1F)); |
| 4762 | } |
| 4763 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4764 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4765 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 4766 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 4767 | | EnablePLLSPLOW)) >> 8)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4768 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4769 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 4770 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4771 | else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4772 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 4773 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4774 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4775 | if (tempcx & EnableSpectrum) |
| 4776 | SetSpectrum(pVBInfo); |
| 4777 | } |
| 4778 | } else { |
| 4779 | /* LVDS,CH7017 */ |
| 4780 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 4781 | } |
| 4782 | } |
| 4783 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4784 | /* --------------------------------------------------------------------- */ |
| 4785 | /* Function : XGI_SetAntiFlicker */ |
| 4786 | /* Input : */ |
| 4787 | /* Output : */ |
| 4788 | /* Description : Set TV Customized Param. */ |
| 4789 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4790 | static void XGI_SetAntiFlicker(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4791 | { |
Aaro Koskinen | 36ae035 | 2012-04-07 01:14:08 +0300 | [diff] [blame] | 4792 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4793 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4794 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4795 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4796 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4797 | return; |
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 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 4800 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4801 | tempah = TVAntiFlickList[tempbx]; |
| 4802 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4803 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4804 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4805 | } |
| 4806 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4807 | static void XGI_SetEdgeEnhance(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4808 | { |
Aaro Koskinen | 354f49f | 2012-04-07 01:14:09 +0300 | [diff] [blame] | 4809 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4810 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4811 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4812 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4813 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 4814 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4815 | tempah = TVEdgeList[tempbx]; |
| 4816 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4817 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4818 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4819 | } |
| 4820 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4821 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4822 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4823 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4824 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4825 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4826 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4827 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4828 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4829 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 4830 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4831 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4832 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4833 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4834 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4835 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4836 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4837 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4838 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4839 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4840 | } |
| 4841 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4842 | static void XGI_SetYFilter(unsigned short ModeIdIndex, |
| 4843 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4844 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4845 | unsigned short tempbx, index; |
Aaro Koskinen | a68292f | 2012-11-04 21:15:07 +0200 | [diff] [blame] | 4846 | unsigned char const *filterPtr; |
| 4847 | unsigned char tempcl, tempch, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4848 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4849 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4850 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4851 | switch (tempbx) { |
| 4852 | case 0x00: |
| 4853 | case 0x04: |
| 4854 | filterPtr = NTSCYFilter1; |
| 4855 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4856 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4857 | case 0x01: |
| 4858 | filterPtr = PALYFilter1; |
| 4859 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4860 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4861 | case 0x02: |
| 4862 | case 0x05: |
| 4863 | case 0x0D: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4864 | case 0x03: |
Aaro Koskinen | 2555e94 | 2011-08-31 21:46:06 +0300 | [diff] [blame] | 4865 | filterPtr = xgifb_palmn_yfilter1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4866 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4867 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4868 | case 0x08: |
| 4869 | case 0x0C: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4870 | case 0x0A: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4871 | case 0x0B: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4872 | case 0x09: |
Aaro Koskinen | 80f86f8 | 2011-08-31 21:46:05 +0300 | [diff] [blame] | 4873 | filterPtr = xgifb_yfilter2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4874 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4875 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4876 | default: |
| 4877 | return; |
| 4878 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4879 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4880 | tempal = XGI330_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4881 | if (tempcl == 0) |
| 4882 | index = tempal * 4; |
| 4883 | else |
| 4884 | index = tempal * 7; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4885 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4886 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4887 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 4888 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 4889 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 4890 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4891 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4892 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 4893 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 4894 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 4895 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4896 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4897 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4898 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4899 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4900 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 4901 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 4902 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4903 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4904 | } |
| 4905 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4906 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4907 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4908 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4909 | /* Output : */ |
| 4910 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4911 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4912 | static void XGI_OEM310Setting(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4913 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4914 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4915 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4916 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4917 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4918 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4919 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4920 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4921 | XGI_SetPhaseIncr(pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4922 | XGI_SetYFilter(ModeIdIndex, pVBInfo); |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4923 | XGI_SetAntiFlicker(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4924 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4925 | if (pVBInfo->VBType & VB_SIS301) |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4926 | XGI_SetEdgeEnhance(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4927 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4928 | } |
| 4929 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4930 | /* --------------------------------------------------------------------- */ |
| 4931 | /* Function : XGI_SetCRT2ModeRegs */ |
| 4932 | /* Input : */ |
| 4933 | /* Output : */ |
| 4934 | /* Description : Origin code for crt2group */ |
| 4935 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 4936 | static void XGI_SetCRT2ModeRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4937 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4938 | unsigned short tempbl; |
| 4939 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4940 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4941 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4942 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4943 | tempah = 0; |
| 4944 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4945 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4946 | tempah &= ~0x10; /* BTRAMDAC */ |
| 4947 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4948 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4949 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 4950 | | SetCRT2ToLCD)) { |
| 4951 | tempah = 0x40; /* BTDRAM */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4952 | tempcl = pVBInfo->ModeType; |
| 4953 | tempcl -= ModeVGA; |
| 4954 | if (tempcl >= 0) { |
| 4955 | /* BT Color */ |
| 4956 | tempah = (0x008 >> tempcl); |
| 4957 | if (tempah == 0) |
| 4958 | tempah = 1; |
| 4959 | tempah |= 0x040; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4960 | } |
| 4961 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 4962 | tempah ^= 0x50; /* BTDAC */ |
| 4963 | } |
| 4964 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4965 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4966 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4967 | tempah = 0x08; |
| 4968 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4969 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4970 | if (pVBInfo->VBInfo & DisableCRT2Display) |
| 4971 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4972 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4973 | tempah = 0x00; |
| 4974 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4975 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4976 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
| 4977 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 4978 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4979 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4980 | if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 4981 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
| 4982 | tempbl &= 0xf7; |
| 4983 | tempah |= 0x01; |
| 4984 | goto reg_and_or; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4985 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4986 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4987 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 4988 | tempbl &= 0xf7; |
| 4989 | tempah |= 0x01; |
| 4990 | } |
| 4991 | |
| 4992 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD))) |
| 4993 | goto reg_and_or; |
| 4994 | |
| 4995 | tempbl &= 0xf8; |
| 4996 | tempah = 0x01; |
| 4997 | |
| 4998 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 4999 | tempah |= 0x02; |
| 5000 | |
| 5001 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5002 | tempah = tempah ^ 0x05; |
| 5003 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 5004 | tempah = tempah ^ 0x01; |
| 5005 | } |
| 5006 | |
| 5007 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5008 | tempah |= 0x08; |
| 5009 | |
| 5010 | reg_and_or: |
| 5011 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
| 5012 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5013 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5014 | | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5015 | tempah &= (~0x08); |
| 5016 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 5017 | & SetInSlaveMode))) { |
| 5018 | tempah |= 0x010; |
| 5019 | } |
| 5020 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5021 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5022 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5023 | tempah |= 0x020; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5024 | if (pVBInfo->VBInfo & DriverMode) |
| 5025 | tempah = tempah ^ 0x20; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5026 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5027 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5028 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5029 | tempah = 0; |
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 | if (pVBInfo->LCDInfo & SetLCDDualLink) |
| 5032 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5033 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5034 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5035 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 5036 | tempah |= 0x40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5037 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5038 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5039 | if ((pVBInfo->LCDResInfo == Panel_1280x1024) |
| 5040 | || (pVBInfo->LCDResInfo == Panel_1280x1024x75)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5041 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5042 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5043 | if (pVBInfo->LCDResInfo == Panel_1280x960) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5044 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5045 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5046 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5047 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5048 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5049 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5050 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5051 | tempah = 0; |
| 5052 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5053 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5054 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 5055 | tempbl = 0xff; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5056 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5057 | tempah |= 0x04; /* shampoo 0129 */ |
| 5058 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5059 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5060 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5061 | tempah = 0x00; |
| 5062 | tempbl = 0xcf; |
| 5063 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5064 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5065 | tempah |= 0x30; |
| 5066 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5067 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5068 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5069 | tempah = 0; |
| 5070 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5071 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5072 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5073 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5074 | tempah |= 0xc0; |
| 5075 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5076 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5077 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5078 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5079 | tempah = 0; |
| 5080 | tempbl = 0x7f; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5081 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5082 | tempbl = 0xff; |
| 5083 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5084 | tempah |= 0x80; |
| 5085 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5086 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5087 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5088 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5089 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5090 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5091 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 5092 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5093 | } |
| 5094 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5095 | } |
| 5096 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5097 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5098 | void XGI_UnLockCRT2(struct vb_device_info *pVBInfo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5099 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5100 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5101 | } |
| 5102 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5103 | void XGI_LockCRT2(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5104 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5105 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5106 | } |
| 5107 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5108 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 5109 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5110 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5111 | { |
Peter Huewe | f2c2260 | 2013-02-03 22:54:30 +0100 | [diff] [blame] | 5112 | const u8 LCDARefreshIndex[] = { |
| 5113 | 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5114 | |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 5115 | unsigned short RefreshRateTableIndex, i, index, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5116 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5117 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5118 | index = index >> pVBInfo->SelectCRT2Rate; |
| 5119 | index &= 0x0F; |
| 5120 | |
| 5121 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 5122 | index = 0; |
| 5123 | |
| 5124 | if (index > 0) |
| 5125 | index--; |
| 5126 | |
| 5127 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5128 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | b0b4a8a | 2013-05-29 23:59:04 +0300 | [diff] [blame] | 5129 | temp = LCDARefreshIndex[pVBInfo->LCDResInfo & 0x07]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5130 | |
Aaro Koskinen | b0b4a8a | 2013-05-29 23:59:04 +0300 | [diff] [blame] | 5131 | if (index > temp) |
| 5132 | index = temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5133 | } |
| 5134 | } |
| 5135 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5136 | RefreshRateTableIndex = XGI330_EModeIDTable[ModeIdIndex].REFindex; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5137 | ModeNo = XGI330_RefIndex[RefreshRateTableIndex].ModeID; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5138 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5139 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 5140 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5141 | index++; |
| 5142 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5143 | /* do the similar adjustment like XGISearchCRT1Rate() */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5144 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 5145 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5146 | index++; |
| 5147 | } |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5148 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 5149 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5150 | index++; |
| 5151 | } |
| 5152 | } |
| 5153 | |
| 5154 | i = 0; |
| 5155 | do { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5156 | if (XGI330_RefIndex[RefreshRateTableIndex + i]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5157 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5158 | break; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5159 | temp = XGI330_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5160 | temp &= ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5161 | if (temp < pVBInfo->ModeType) |
| 5162 | break; |
| 5163 | i++; |
| 5164 | index--; |
| 5165 | |
| 5166 | } while (index != 0xFFFF); |
| 5167 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5168 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5169 | temp = XGI330_RefIndex[RefreshRateTableIndex + i - 1]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5170 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5171 | if (temp & InterlaceMode) |
| 5172 | i++; |
| 5173 | } |
| 5174 | } |
| 5175 | i--; |
| 5176 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5177 | temp = XGI_AjustCRT2Rate(ModeIdIndex, RefreshRateTableIndex, |
| 5178 | &i, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5179 | } |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 5180 | return RefreshRateTableIndex + i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5181 | } |
| 5182 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5183 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5184 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5185 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5186 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5187 | unsigned short RefreshRateTableIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5188 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5189 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5190 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5191 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5192 | XGI_GetLVDSResInfo(ModeIdIndex, pVBInfo); |
| 5193 | XGI_GetLVDSData(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5194 | XGI_ModCRT1Regs(ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, |
| 5195 | pVBInfo); |
| 5196 | XGI_SetLVDSRegs(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5197 | XGI_SetCRT2ECLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5198 | } |
| 5199 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5200 | static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5201 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5202 | struct vb_device_info *pVBInfo) |
| 5203 | { |
Peter Huewe | a9e29e6 | 2013-02-03 04:08:44 +0100 | [diff] [blame] | 5204 | unsigned short ModeIdIndex, RefreshRateTableIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5205 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5206 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5207 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 5208 | pVBInfo->SelectCRT2Rate = 4; |
| 5209 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5210 | ModeIdIndex, pVBInfo); |
| 5211 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5212 | XGI_GetCRT2ResInfo(ModeIdIndex, pVBInfo); |
| 5213 | XGI_GetCRT2Data(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5214 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5215 | XGI_SetGroup1(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5216 | XGI_SetLockRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5217 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5218 | XGI_SetLCDRegs(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5219 | XGI_SetTap4Regs(pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5220 | XGI_SetGroup3(ModeIdIndex, pVBInfo); |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5221 | XGI_SetGroup4(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5222 | XGI_SetCRT2VCLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5223 | XGI_SetGroup5(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5224 | XGI_AutoThreshold(pVBInfo); |
| 5225 | return 1; |
| 5226 | } |
| 5227 | |
| 5228 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 5229 | { |
| 5230 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 5231 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 5232 | 0x05, 0x00 }; |
| 5233 | |
| 5234 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 5235 | |
| 5236 | unsigned char CR17, CR63, SR31; |
| 5237 | unsigned short temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5238 | |
| 5239 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5240 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5241 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5242 | /* to fix XG42 single LCD sense to CRT+LCD */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5243 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5244 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5245 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 5246 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5247 | SR31 = xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 5248 | CR63 = xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 5249 | SR01 = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5250 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5251 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 5252 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5253 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5254 | CR17 = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5255 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5256 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5257 | SR1F = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5258 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5259 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5260 | SR07 = xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5261 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5262 | SR06 = xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5263 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5264 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5265 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5266 | |
| 5267 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5268 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5269 | |
| 5270 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5271 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5272 | CRTCData[i]); |
| 5273 | |
| 5274 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5275 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5276 | CRTCData[i]); |
| 5277 | |
| 5278 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5279 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5280 | CRTCData[i]); |
| 5281 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5282 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5283 | & 0xE0)); |
| 5284 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5285 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 5286 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 5287 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5288 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5289 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5290 | |
Peter Huewe | 771f3ee | 2013-02-15 20:37:13 +0100 | [diff] [blame] | 5291 | for (i = 0; i < 256 * 3; i++) { |
| 5292 | outb(0x0F, (pVBInfo->P3c8 + 1)); /* DAC_TEST_PARMS */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5293 | } |
| 5294 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5295 | mdelay(1); |
| 5296 | |
| 5297 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5298 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5299 | |
| 5300 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5301 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5302 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5303 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5304 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5305 | /* avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5306 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5307 | |
Peter Huewe | 771f3ee | 2013-02-15 20:37:13 +0100 | [diff] [blame] | 5308 | for (i = 0; i < 256 * 3; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5309 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5310 | } |
| 5311 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5312 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 5313 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 5314 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5315 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5316 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5317 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5318 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5319 | } |
| 5320 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5321 | static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, |
| 5322 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5323 | struct vb_device_info *pVBInfo) |
| 5324 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 5325 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5326 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5327 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5328 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | a2526d1 | 2013-05-29 23:59:10 +0300 | [diff] [blame] | 5329 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
Aaro Koskinen | d172463 | 2013-05-29 23:59:09 +0300 | [diff] [blame] | 5330 | /* Power on */ |
| 5331 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5332 | |
Aaro Koskinen | b8e34b3 | 2013-05-29 23:59:08 +0300 | [diff] [blame] | 5333 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV | |
| 5334 | SetCRT2ToRAMDAC)) { |
Aaro Koskinen | c4f9c31 | 2013-05-29 23:59:07 +0300 | [diff] [blame] | 5335 | tempah = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
| 5336 | tempah &= 0xDF; |
| 5337 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5338 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) |
| 5339 | tempah |= 0x20; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5340 | } |
Aaro Koskinen | c4f9c31 | 2013-05-29 23:59:07 +0300 | [diff] [blame] | 5341 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
| 5342 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
| 5343 | |
| 5344 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E); |
| 5345 | |
| 5346 | if (!(tempah & 0x80)) |
| 5347 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
| 5348 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5349 | } |
| 5350 | |
Aaro Koskinen | a2526d1 | 2013-05-29 23:59:10 +0300 | [diff] [blame] | 5351 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5352 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5353 | 0x20); /* shampoo 0129 */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5354 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 056b540 | 2013-05-29 23:59:11 +0300 | [diff] [blame] | 5355 | if (pVBInfo->VBInfo & |
| 5356 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
| 5357 | /* LVDS PLL power on */ |
| 5358 | xgifb_reg_and(pVBInfo->Part4Port, 0x2A, |
| 5359 | 0x7F); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5360 | /* LVDS Driver power on */ |
| 5361 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5362 | } |
| 5363 | } |
| 5364 | |
| 5365 | tempah = 0x00; |
| 5366 | |
| 5367 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5368 | tempah = 0xc0; |
| 5369 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5370 | if (!(pVBInfo->VBInfo & SetSimuScanMode) && |
| 5371 | (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 5372 | (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { |
| 5373 | tempah = tempah & 0x40; |
| 5374 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
| 5375 | tempah = tempah ^ 0xC0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5376 | } |
| 5377 | } |
| 5378 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5379 | /* EnablePart4_1F */ |
| 5380 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5381 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5382 | XGI_DisableGatingCRT(pVBInfo); |
Aaro Koskinen | d172463 | 2013-05-29 23:59:09 +0300 | [diff] [blame] | 5383 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5384 | } /* 301 */ |
| 5385 | else { /* LVDS */ |
| 5386 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5387 | | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5388 | /* enable CRT2 */ |
| 5389 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5390 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5391 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5392 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5393 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5394 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5395 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5396 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5397 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5398 | } |
| 5399 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5400 | static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, |
| 5401 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5402 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5403 | struct vb_device_info *pVBInfo) |
| 5404 | { |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5405 | unsigned short RefreshRateTableIndex, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5406 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5407 | XGI_SetSeqRegs(pVBInfo); |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 5408 | outb(XGI330_StandTable.MISC, pVBInfo->P3c2); |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5409 | XGI_SetCRTCRegs(pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5410 | XGI_SetATTRegs(ModeIdIndex, pVBInfo); |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5411 | XGI_SetGRCRegs(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5412 | XGI_ClearExt1Regs(pVBInfo); |
| 5413 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5414 | if (HwDeviceExtension->jChipType == XG27) { |
| 5415 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 5416 | XGI_SetDefaultVCLK(pVBInfo); |
| 5417 | } |
| 5418 | |
| 5419 | temp = ~ProgrammingCRT2; |
| 5420 | pVBInfo->SetFlag &= temp; |
| 5421 | pVBInfo->SelectCRT2Rate = 0; |
| 5422 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5423 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5424 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5425 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5426 | | SetInSlaveMode)) { |
| 5427 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5428 | } |
| 5429 | } |
| 5430 | |
| 5431 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5432 | ModeIdIndex, pVBInfo); |
| 5433 | if (RefreshRateTableIndex != 0xFFFF) { |
| 5434 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5435 | XGI_SetCRT1CRTC(ModeIdIndex, RefreshRateTableIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5436 | pVBInfo, HwDeviceExtension); |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5437 | XGI_SetCRT1DE(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5438 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5439 | HwDeviceExtension, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5440 | XGI_SetCRT1VCLK(ModeIdIndex, HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5441 | RefreshRateTableIndex, pVBInfo); |
| 5442 | } |
| 5443 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5444 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5445 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5446 | if (temp & 0xA0) { |
| 5447 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5448 | if (HwDeviceExtension->jChipType == XG27) |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5449 | XGI_SetXG27CRTC(RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5450 | else |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5451 | XGI_SetXG21CRTC(RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5452 | |
| 5453 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 5454 | RefreshRateTableIndex); |
| 5455 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 5456 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5457 | pVBInfo, RefreshRateTableIndex); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5458 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5459 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5460 | xgifb_set_lvds(xgifb_info, |
| 5461 | HwDeviceExtension->jChipType, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5462 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5463 | } |
| 5464 | } |
| 5465 | |
| 5466 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5467 | XGI_SetCRT1FIFO(HwDeviceExtension, pVBInfo); |
| 5468 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeIdIndex, |
| 5469 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5470 | XGI_LoadDAC(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5471 | } |
| 5472 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5473 | unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, |
| 5474 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5475 | unsigned short ModeNo) |
| 5476 | { |
| 5477 | unsigned short ModeIdIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5478 | struct vb_device_info VBINF; |
| 5479 | struct vb_device_info *pVBInfo = &VBINF; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5480 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5481 | |
Aaro Koskinen | ee76875 | 2013-05-29 23:59:16 +0300 | [diff] [blame] | 5482 | if (HwDeviceExtension->jChipType >= XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5483 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5484 | |
Aaro Koskinen | 56810a9 | 2013-01-21 02:57:47 +0200 | [diff] [blame] | 5485 | XGIRegInit(pVBInfo, xgifb_info->vga_base); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5486 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5487 | /* for x86 Linux, XG21 LVDS */ |
| 5488 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5489 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5490 | pVBInfo->IF_DEF_LVDS = 1; |
| 5491 | } |
| 5492 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5493 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 5494 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5495 | pVBInfo->IF_DEF_LVDS = 1; |
| 5496 | } |
| 5497 | } |
| 5498 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5499 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
Aaro Koskinen | ef497f4 | 2011-11-27 23:03:21 +0200 | [diff] [blame] | 5500 | if (ModeNo & 0x80) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5501 | ModeNo = ModeNo & 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5502 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5503 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5504 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5505 | XGI_UnLockCRT2(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5506 | |
| 5507 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 5508 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5509 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5510 | XGI_GetVBInfo(ModeIdIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5511 | XGI_GetTVInfo(ModeIdIndex, pVBInfo); |
| 5512 | XGI_GetLCDInfo(ModeIdIndex, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5513 | XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5514 | |
Peter Huewe | e44adfd | 2013-02-03 22:54:39 +0100 | [diff] [blame] | 5515 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA) || |
| 5516 | (!(pVBInfo->VBInfo & SwitchCRT2))) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5517 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5518 | ModeIdIndex, pVBInfo); |
| 5519 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5520 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5521 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 5522 | HwDeviceExtension, pVBInfo); |
| 5523 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5524 | } |
| 5525 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5526 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5527 | switch (HwDeviceExtension->ujVBChipID) { |
Peter Huewe | e44adfd | 2013-02-03 22:54:39 +0100 | [diff] [blame] | 5528 | case VB_CHIP_301: /* fall through */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5529 | case VB_CHIP_302: |
| 5530 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 5531 | pVBInfo); /*add for CRT2 */ |
| 5532 | break; |
| 5533 | |
| 5534 | default: |
| 5535 | break; |
| 5536 | } |
| 5537 | } |
| 5538 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5539 | XGI_SetCRT2ModeRegs(pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5540 | XGI_OEM310Setting(ModeIdIndex, pVBInfo); /*0212*/ |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5541 | XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5542 | } /* !XG20 */ |
| 5543 | else { |
| 5544 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5545 | if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5546 | ModeIdIndex, |
| 5547 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5548 | return 0; |
| 5549 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5550 | pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex]. |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5551 | Ext_ModeFlag & ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5552 | |
| 5553 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 5554 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5555 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5556 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5557 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5558 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
| 5559 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5560 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5561 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5562 | } |
| 5563 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5564 | XGI_UpdateModeInfo(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5565 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 5566 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame^] | 5567 | XGI_LockCRT2(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5568 | |
| 5569 | return 1; |
| 5570 | } |