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, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1204 | struct vb_device_info *pVBInfo) |
| 1205 | { |
Aaro Koskinen | 6c27b37 | 2012-11-04 21:14:45 +0200 | [diff] [blame] | 1206 | unsigned short i, tempdx, tempbx, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1207 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1208 | tempbx = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1209 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1210 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1211 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1212 | i = 0; |
| 1213 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1214 | while (table[i].PANELID != 0xff) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1215 | tempdx = pVBInfo->LCDResInfo; |
| 1216 | if (tempbx & 0x0080) { /* OEMUtil */ |
| 1217 | tempbx &= (~0x0080); |
| 1218 | tempdx = pVBInfo->LCDTypeInfo; |
| 1219 | } |
| 1220 | |
| 1221 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1222 | tempdx &= (~PanelResInfo); |
| 1223 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1224 | if (table[i].PANELID == tempdx) { |
| 1225 | tempbx = table[i].MASK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1226 | tempdx = pVBInfo->LCDInfo; |
| 1227 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1228 | if (modeflag & HalfDCLK) |
| 1229 | tempdx |= SetLCDLowResolution; |
| 1230 | |
| 1231 | tempbx &= tempdx; |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1232 | if (tempbx == table[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1233 | break; |
| 1234 | } |
| 1235 | i++; |
| 1236 | } |
| 1237 | |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1238 | return table[i].DATAPTR; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1239 | } |
| 1240 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1241 | static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeIdIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1242 | unsigned short RefreshRateTableIndex, |
| 1243 | struct vb_device_info *pVBInfo) |
| 1244 | { |
Aaro Koskinen | 56d276c | 2012-09-11 00:15:19 +0300 | [diff] [blame] | 1245 | unsigned short i, tempdx, tempal, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1246 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1247 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1248 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1249 | tempal = tempal & 0x3f; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1250 | tempdx = pVBInfo->TVInfo; |
| 1251 | |
| 1252 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 1253 | tempdx = tempdx | SetTVLockMode; |
| 1254 | |
| 1255 | if (modeflag & HalfDCLK) |
| 1256 | tempdx = tempdx | SetTVLowResolution; |
| 1257 | |
| 1258 | i = 0; |
| 1259 | |
Aaro Koskinen | 6265ee4 | 2012-09-11 00:15:20 +0300 | [diff] [blame] | 1260 | while (XGI_TVDataTable[i].MASK != 0xffff) { |
| 1261 | if ((tempdx & XGI_TVDataTable[i].MASK) == |
| 1262 | XGI_TVDataTable[i].CAP) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1263 | break; |
| 1264 | i++; |
| 1265 | } |
| 1266 | |
Aaro Koskinen | 18ba866 | 2012-09-11 00:15:22 +0300 | [diff] [blame] | 1267 | return &XGI_TVDataTable[i].DATAPTR[tempal]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1268 | } |
| 1269 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1270 | static void XGI_GetLVDSData(unsigned short ModeIdIndex, |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 1271 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1272 | { |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1273 | struct SiS_LVDSData const *LCDPtr; |
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 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 1276 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1277 | |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 1278 | LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeIdIndex, pVBInfo); |
Aaro Koskinen | 6008f87 | 2012-11-04 21:14:49 +0200 | [diff] [blame] | 1279 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 1280 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 1281 | pVBInfo->HT = LCDPtr->LCDHT; |
| 1282 | pVBInfo->VT = LCDPtr->LCDVT; |
| 1283 | |
| 1284 | if (pVBInfo->LCDInfo & (SetLCDtoNonExpanding | EnableScalingLCD)) |
| 1285 | return; |
| 1286 | |
| 1287 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1288 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
| 1289 | pVBInfo->HDE = 1024; |
| 1290 | pVBInfo->VDE = 768; |
| 1291 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1292 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
| 1293 | pVBInfo->HDE = 1280; |
| 1294 | pVBInfo->VDE = 1024; |
| 1295 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
| 1296 | pVBInfo->HDE = 1400; |
| 1297 | pVBInfo->VDE = 1050; |
| 1298 | } else { |
| 1299 | pVBInfo->HDE = 1600; |
| 1300 | pVBInfo->VDE = 1200; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1301 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1302 | } |
| 1303 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1304 | static void XGI_ModCRT1Regs(unsigned short ModeIdIndex, |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 1305 | struct xgi_hw_device_info *HwDeviceExtension, |
| 1306 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1307 | { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 1308 | unsigned short i; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1309 | struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL; |
| 1310 | struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1311 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1312 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1313 | LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeIdIndex, |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 1314 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1315 | |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1316 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1317 | pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1318 | } |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1319 | |
| 1320 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
| 1321 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1322 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1323 | LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeIdIndex, |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 1324 | pVBInfo); |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1325 | for (i = 0; i < 7; i++) |
Aaro Koskinen | 6154e7f | 2012-11-04 21:14:50 +0200 | [diff] [blame] | 1326 | pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i]; |
Aaro Koskinen | aef6bc7 | 2011-08-31 21:46:15 +0300 | [diff] [blame] | 1327 | } |
| 1328 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1329 | XGI_SetCRT1Timing_V(ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1330 | } |
| 1331 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1332 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
| 1333 | { |
| 1334 | unsigned char tempal, tempah, tempbl, i; |
| 1335 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1336 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1337 | tempal = tempah & 0x0F; |
| 1338 | tempah = tempah & 0xF0; |
| 1339 | i = 0; |
| 1340 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1341 | |
| 1342 | while (tempbl != 0xFF) { |
| 1343 | if (tempbl & 0x80) { /* OEMUtil */ |
| 1344 | tempal = tempah; |
| 1345 | tempbl = tempbl & ~(0x80); |
| 1346 | } |
| 1347 | |
| 1348 | if (tempal == tempbl) |
| 1349 | break; |
| 1350 | |
| 1351 | i++; |
| 1352 | |
| 1353 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1354 | } |
| 1355 | |
| 1356 | return i; |
| 1357 | } |
| 1358 | |
| 1359 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
| 1360 | { |
| 1361 | unsigned short tempah, tempal, tempbl, i; |
| 1362 | |
| 1363 | tempal = pVBInfo->LCDResInfo; |
| 1364 | tempah = pVBInfo->LCDTypeInfo; |
| 1365 | |
| 1366 | i = 0; |
| 1367 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1368 | |
| 1369 | while (tempbl != 0xFF) { |
| 1370 | if ((tempbl & 0x80) && (tempbl != 0x80)) { |
| 1371 | tempal = tempah; |
| 1372 | tempbl &= ~0x80; |
| 1373 | } |
| 1374 | |
| 1375 | if (tempal == tempbl) |
| 1376 | break; |
| 1377 | |
| 1378 | i++; |
| 1379 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
| 1380 | } |
| 1381 | |
| 1382 | if (tempbl == 0xFF) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1383 | pVBInfo->LCDResInfo = Panel_1024x768; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1384 | pVBInfo->LCDTypeInfo = 0; |
| 1385 | i = 0; |
| 1386 | } |
| 1387 | |
| 1388 | return i; |
| 1389 | } |
| 1390 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1391 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
| 1392 | unsigned short *VSyncWidth, |
| 1393 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1394 | { |
| 1395 | unsigned short Index; |
| 1396 | |
| 1397 | Index = XGI_GetLCDCapPtr(pVBInfo); |
| 1398 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; |
| 1399 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1400 | } |
| 1401 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1402 | static void XGI_SetLVDSRegs(unsigned short ModeIdIndex, |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 1403 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1404 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1405 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; |
| 1406 | unsigned long temp, temp1, temp2, temp3, push3; |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 1407 | struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1408 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1409 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 1410 | LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeIdIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1411 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1412 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 1413 | push1 = tempbx; |
| 1414 | push2 = tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1415 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1416 | /* GetLCDResInfo */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1417 | if ((pVBInfo->LCDResInfo == Panel_1024x768) || |
| 1418 | (pVBInfo->LCDResInfo == Panel_1024x768x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1419 | tempax = 1024; |
| 1420 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1421 | } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) || |
| 1422 | (pVBInfo->LCDResInfo == Panel_1280x1024x75)) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1423 | tempax = 1280; |
| 1424 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1425 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1426 | tempax = 1400; |
| 1427 | tempbx = 1050; |
| 1428 | } else { |
| 1429 | tempax = 1600; |
| 1430 | tempbx = 1200; |
| 1431 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1432 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1433 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
| 1434 | pVBInfo->HDE = tempax; |
| 1435 | pVBInfo->VDE = tempbx; |
| 1436 | pVBInfo->VGAHDE = tempax; |
| 1437 | pVBInfo->VGAVDE = tempbx; |
| 1438 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1439 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1440 | tempax = pVBInfo->HT; |
| 1441 | |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1442 | tempbx = LCDPtr1->LCDHDES; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1443 | |
| 1444 | tempcx = pVBInfo->HDE; |
| 1445 | tempbx = tempbx & 0x0fff; |
| 1446 | tempcx += tempbx; |
| 1447 | |
| 1448 | if (tempcx >= tempax) |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1449 | tempcx -= tempax; |
| 1450 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1451 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1452 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1453 | tempcx = tempcx >> 3; |
| 1454 | tempbx = tempbx >> 3; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1455 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1456 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
| 1457 | (unsigned short) (tempbx & 0xff)); |
| 1458 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
| 1459 | (unsigned short) (tempcx & 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1460 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1461 | tempax = pVBInfo->HT; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1462 | |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1463 | tempbx = LCDPtr1->LCDHRS; |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1464 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1465 | tempcx = push2; |
| 1466 | |
| 1467 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1468 | tempcx = LCDPtr1->LCDHSync; |
| 1469 | |
| 1470 | tempcx += tempbx; |
| 1471 | |
| 1472 | if (tempcx >= tempax) |
| 1473 | tempcx -= tempax; |
| 1474 | |
| 1475 | tempax = tempbx & 0x07; |
| 1476 | tempax = tempax >> 5; |
| 1477 | tempcx = tempcx >> 3; |
| 1478 | tempbx = tempbx >> 3; |
| 1479 | |
| 1480 | tempcx &= 0x1f; |
| 1481 | tempax |= tempcx; |
| 1482 | |
| 1483 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
| 1484 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, |
| 1485 | (unsigned short) (tempbx & 0xff)); |
| 1486 | |
| 1487 | tempax = pVBInfo->VT; |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1488 | tempbx = LCDPtr1->LCDVDES; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1489 | tempcx = pVBInfo->VDE; |
| 1490 | |
| 1491 | tempbx = tempbx & 0x0fff; |
| 1492 | tempcx += tempbx; |
| 1493 | if (tempcx >= tempax) |
| 1494 | tempcx -= tempax; |
| 1495 | |
| 1496 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
| 1497 | (unsigned short) (tempbx & 0xff)); |
| 1498 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
| 1499 | (unsigned short) (tempcx & 0xff)); |
| 1500 | |
| 1501 | tempbx = (tempbx >> 8) & 0x07; |
| 1502 | tempcx = (tempcx >> 8) & 0x07; |
| 1503 | |
| 1504 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
| 1505 | (unsigned short) ((tempcx << 3) |
| 1506 | | tempbx)); |
| 1507 | |
| 1508 | tempax = pVBInfo->VT; |
Peter Huewe | 826215d | 2013-02-05 00:29:46 +0100 | [diff] [blame] | 1509 | tempbx = LCDPtr1->LCDVRS; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1510 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1511 | tempcx = push1; |
| 1512 | |
| 1513 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
| 1514 | tempcx = LCDPtr1->LCDVSync; |
| 1515 | |
| 1516 | tempcx += tempbx; |
| 1517 | if (tempcx >= tempax) |
| 1518 | tempcx -= tempax; |
| 1519 | |
| 1520 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
| 1521 | (unsigned short) (tempbx & 0xff)); |
| 1522 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
| 1523 | (unsigned short) (tempcx & 0x0f)); |
| 1524 | |
| 1525 | tempax = ((tempbx >> 8) & 0x07) << 3; |
| 1526 | |
| 1527 | tempbx = pVBInfo->VGAVDE; |
| 1528 | if (tempbx != pVBInfo->VDE) |
| 1529 | tempax |= 0x40; |
| 1530 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1531 | if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1532 | tempax |= 0x40; |
| 1533 | |
| 1534 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
| 1535 | tempax); |
| 1536 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1537 | tempbx = pVBInfo->VDE; |
| 1538 | tempax = pVBInfo->VGAVDE; |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1539 | |
| 1540 | temp = tempax; /* 0430 ylshieh */ |
| 1541 | temp1 = (temp << 18) / tempbx; |
| 1542 | |
| 1543 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
| 1544 | |
| 1545 | if (tempdx != 0) |
| 1546 | temp1 += 1; |
| 1547 | |
| 1548 | temp2 = temp1; |
| 1549 | push3 = temp2; |
| 1550 | |
| 1551 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
| 1552 | (unsigned short) (temp2 & 0xff)); |
| 1553 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
| 1554 | (unsigned short) ((temp2 >> 8) & 0xff)); |
| 1555 | |
| 1556 | tempbx = (unsigned short) (temp2 >> 16); |
| 1557 | tempax = tempbx & 0x03; |
| 1558 | |
| 1559 | tempbx = pVBInfo->VGAVDE; |
| 1560 | if (tempbx == pVBInfo->VDE) |
| 1561 | tempax |= 0x04; |
| 1562 | |
| 1563 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
| 1564 | |
| 1565 | if (pVBInfo->VBType & VB_XGI301C) { |
| 1566 | temp2 = push3; |
| 1567 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1568 | 0x3c, |
| 1569 | (unsigned short) (temp2 & 0xff)); |
| 1570 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1571 | 0x3b, |
| 1572 | (unsigned short) ((temp2 >> 8) & |
| 1573 | 0xff)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1574 | tempbx = (unsigned short) (temp2 >> 16); |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1575 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
| 1576 | ~0xc0, |
| 1577 | (unsigned short) ((tempbx & |
| 1578 | 0xff) << 6)); |
Aaro Koskinen | a35cd0b | 2011-08-31 21:45:56 +0300 | [diff] [blame] | 1579 | |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1580 | tempcx = pVBInfo->VGAVDE; |
| 1581 | if (tempcx == pVBInfo->VDE) |
| 1582 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1583 | 0x30, ~0x0c, 0x00); |
| 1584 | else |
| 1585 | xgifb_reg_and_or(pVBInfo->Part4Port, |
| 1586 | 0x30, ~0x0c, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1587 | } |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1588 | |
| 1589 | tempcx = pVBInfo->VGAHDE; |
| 1590 | tempbx = pVBInfo->HDE; |
| 1591 | |
| 1592 | temp1 = tempcx << 16; |
| 1593 | |
| 1594 | tempax = (unsigned short) (temp1 / tempbx); |
| 1595 | |
| 1596 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
| 1597 | tempax = 65535; |
| 1598 | |
| 1599 | temp3 = tempax; |
| 1600 | temp1 = pVBInfo->VGAHDE << 16; |
| 1601 | |
| 1602 | temp1 /= temp3; |
| 1603 | temp3 = temp3 << 16; |
| 1604 | temp1 -= 1; |
| 1605 | |
| 1606 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
| 1607 | |
| 1608 | tempax = (unsigned short) (temp3 & 0xff); |
| 1609 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
| 1610 | |
| 1611 | temp1 = pVBInfo->VGAVDE << 18; |
| 1612 | temp1 = temp1 / push3; |
| 1613 | tempbx = (unsigned short) (temp1 & 0xffff); |
| 1614 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 1615 | if (pVBInfo->LCDResInfo == Panel_1024x768) |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 1616 | tempbx -= 1; |
| 1617 | |
| 1618 | tempax = ((tempbx >> 8) & 0xff) << 3; |
| 1619 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); |
| 1620 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
| 1621 | (unsigned short) (tempax & 0xff)); |
| 1622 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
| 1623 | (unsigned short) (tempbx & 0xff)); |
| 1624 | |
| 1625 | temp3 = temp3 >> 16; |
| 1626 | |
| 1627 | if (modeflag & HalfDCLK) |
| 1628 | temp3 = temp3 >> 1; |
| 1629 | |
| 1630 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
| 1631 | (unsigned short) ((temp3 >> 8) & 0xff)); |
| 1632 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
| 1633 | (unsigned short) (temp3 & 0xff)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1634 | } |
| 1635 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1636 | /* --------------------------------------------------------------------- */ |
| 1637 | /* Function : XGI_GETLCDVCLKPtr */ |
| 1638 | /* Input : */ |
| 1639 | /* Output : al -> VCLK Index */ |
| 1640 | /* Description : */ |
| 1641 | /* --------------------------------------------------------------------- */ |
| 1642 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
| 1643 | struct vb_device_info *pVBInfo) |
| 1644 | { |
| 1645 | unsigned short index; |
| 1646 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1647 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1648 | index = XGI_GetLCDCapPtr1(pVBInfo); |
| 1649 | |
| 1650 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
| 1651 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; |
| 1652 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; |
| 1653 | } else { /* LCDA */ |
| 1654 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; |
| 1655 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; |
| 1656 | } |
| 1657 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1658 | } |
| 1659 | |
| 1660 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1661 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1662 | { |
| 1663 | |
| 1664 | unsigned short index, modeflag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1665 | unsigned char tempal; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1666 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 1667 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1668 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1669 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1670 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
| 1671 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1672 | index = XGI_GetLCDCapPtr(pVBInfo); |
| 1673 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; |
| 1674 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1675 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1676 | return tempal; |
| 1677 | |
| 1678 | /* {TV} */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1679 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1680 | (VB_SIS301B | |
| 1681 | VB_SIS302B | |
| 1682 | VB_SIS301LV | |
| 1683 | VB_SIS302LV | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1684 | VB_XGI301C)) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1685 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1686 | tempal = TVCLKBASE_315 + HiTVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1687 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1688 | tempal = TVCLKBASE_315 + HiTVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1689 | if (pVBInfo->TVInfo & TVSimuMode) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1690 | tempal = TVCLKBASE_315 + HiTVSimuVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1691 | if (!(modeflag & Charx8Dot)) |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1692 | tempal = TVCLKBASE_315 + |
| 1693 | HiTVTextVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1694 | |
| 1695 | } |
| 1696 | return tempal; |
| 1697 | } |
| 1698 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1699 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1700 | tempal = XGI_YPbPr750pVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1701 | return tempal; |
| 1702 | } |
| 1703 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1704 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1705 | tempal = YPbPr525pVCLK; |
| 1706 | return tempal; |
| 1707 | } |
| 1708 | |
| 1709 | tempal = NTSC1024VCLK; |
| 1710 | |
| 1711 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1712 | tempal = TVCLKBASE_315 + TVVCLKDIV2; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1713 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) |
Peter Huewe | ccc8cb2 | 2012-02-09 21:11:48 +0100 | [diff] [blame] | 1714 | tempal = TVCLKBASE_315 + TVVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1715 | } |
| 1716 | |
| 1717 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 1718 | return tempal; |
| 1719 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1720 | } /* {End of VB} */ |
| 1721 | |
Peter Huewe | 516354e | 2013-02-15 20:37:11 +0100 | [diff] [blame] | 1722 | inb((pVBInfo->P3ca + 0x02)); |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 1723 | tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1724 | return tempal; |
| 1725 | } |
| 1726 | |
| 1727 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
| 1728 | unsigned char *di_1, struct vb_device_info *pVBInfo) |
| 1729 | { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1730 | if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B |
| 1731 | | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 1732 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
| 1733 | (pVBInfo->SetFlag & ProgrammingCRT2)) { |
Aaro Koskinen | e8cb03d | 2012-09-11 00:15:31 +0300 | [diff] [blame] | 1734 | *di_0 = XGI_VBVCLKData[tempal].Part4_A; |
Aaro Koskinen | a7e46d8b | 2012-09-11 00:15:32 +0300 | [diff] [blame] | 1735 | *di_1 = XGI_VBVCLKData[tempal].Part4_B; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 1736 | } |
| 1737 | } else { |
| 1738 | *di_0 = XGI_VCLKData[tempal].SR2B; |
| 1739 | *di_1 = XGI_VCLKData[tempal].SR2C; |
| 1740 | } |
| 1741 | } |
| 1742 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1743 | static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1744 | unsigned short RefreshRateTableIndex, |
| 1745 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1746 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1747 | unsigned char di_0, di_1, tempal; |
| 1748 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1749 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1750 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1751 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 1752 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1753 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1754 | for (i = 0; i < 4; i++) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1755 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1756 | (unsigned short) (0x10 * i)); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1757 | if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1758 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1759 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
| 1760 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1761 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1762 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
| 1763 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1764 | } |
| 1765 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1766 | } |
| 1767 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 1768 | static void XGI_UpdateModeInfo(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1769 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1770 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1771 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1772 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 1773 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1774 | tempcl = 0; |
| 1775 | tempch = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1776 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1777 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1778 | if (!(temp & 0x20)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1779 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1780 | if (temp & 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1781 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1782 | if (!(temp & 0x40)) |
| 1783 | tempcl |= ActiveCRT1; |
| 1784 | } |
| 1785 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1786 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1787 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1788 | temp &= 0x0f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1789 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1790 | if (!(temp == 0x08)) { |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1791 | /* Check ChannelA */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1792 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1793 | if (tempax & 0x04) |
| 1794 | tempcl = tempcl | ActiveLCD; |
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 | temp &= 0x05; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1797 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1798 | if (!(tempcl & ActiveLCD)) |
| 1799 | if (temp == 0x01) |
| 1800 | tempcl |= ActiveCRT2; |
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 | if (temp == 0x04) |
| 1803 | tempcl |= ActiveLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1804 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1805 | if (temp == 0x05) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1806 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
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 & 0x08)) |
| 1809 | tempch |= ActiveAVideo; |
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 & 0x04)) |
| 1812 | tempch |= ActiveSVideo; |
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 & 0x02) |
| 1815 | tempch |= ActiveSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1816 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1817 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1818 | if (temp & 0x01) |
| 1819 | tempch |= ActiveHiTV; |
| 1820 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1821 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1822 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1823 | temp = xgifb_reg_get( |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1824 | pVBInfo->Part2Port, |
| 1825 | 0x4d); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1826 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1827 | if (temp & 0x10) |
| 1828 | tempch |= ActiveYPbPr; |
| 1829 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1830 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1831 | if (tempch != 0) |
| 1832 | tempcl |= ActiveTV; |
| 1833 | } |
| 1834 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1835 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1836 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1837 | if (tempcl & ActiveLCD) { |
| 1838 | if ((pVBInfo->SetFlag & ReserveTVOption)) { |
| 1839 | if (temp & ActiveTV) |
| 1840 | tempcl |= ActiveTV; |
| 1841 | } |
| 1842 | } |
| 1843 | temp = tempcl; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 1844 | tempbl = ~XGI_ModeSwitchStatus; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1845 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1846 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1847 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1848 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1849 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1850 | } |
| 1851 | |
Bill Pemberton | 80adad8 | 2010-06-17 13:10:51 -0400 | [diff] [blame] | 1852 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1853 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1854 | unsigned short flag, tempbx, tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1855 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1856 | tempbx = VB_SIS302B; |
| 1857 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
| 1858 | if (flag == 0x02) |
| 1859 | goto finish; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1860 | |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1861 | tempbx = VB_SIS301; |
| 1862 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
| 1863 | if (flag < 0xB0) |
| 1864 | goto finish; |
| 1865 | |
| 1866 | tempbx = VB_SIS301B; |
| 1867 | if (flag < 0xC0) |
| 1868 | goto bigger_than_0xB0; |
| 1869 | |
| 1870 | tempbx = VB_XGI301C; |
| 1871 | if (flag < 0xD0) |
| 1872 | goto bigger_than_0xB0; |
| 1873 | |
| 1874 | tempbx = VB_SIS301LV; |
| 1875 | if (flag < 0xE0) |
| 1876 | goto bigger_than_0xB0; |
| 1877 | |
| 1878 | tempbx = VB_SIS302LV; |
| 1879 | tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39); |
| 1880 | if (tempah != 0xFF) |
| 1881 | tempbx = VB_XGI301C; |
| 1882 | |
| 1883 | bigger_than_0xB0: |
| 1884 | if (tempbx & (VB_SIS301B | VB_SIS302B)) { |
| 1885 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23); |
| 1886 | if (!(flag & 0x02)) |
| 1887 | tempbx = tempbx | VB_NoLCD; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1888 | } |
Miguel Gómez | 7eec23a | 2012-07-06 12:40:47 +0200 | [diff] [blame] | 1889 | |
| 1890 | finish: |
| 1891 | pVBInfo->VBType = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1892 | } |
| 1893 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 1894 | static void XGI_GetVBInfo(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1895 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1896 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1897 | unsigned short tempax, push, tempbx, temp, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1898 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 1899 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1900 | pVBInfo->SetFlag = 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 1901 | pVBInfo->ModeType = modeflag & ModeTypeMask; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1902 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1903 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1904 | if (!(pVBInfo->VBType & 0xFFFF)) |
| 1905 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1906 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1907 | /* Check Display Device */ |
| 1908 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); |
| 1909 | tempbx = tempbx | temp; |
| 1910 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
| 1911 | push = temp; |
| 1912 | push = push << 8; |
| 1913 | tempax = temp << 8; |
| 1914 | tempbx = tempbx | tempax; |
| 1915 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA |
| 1916 | | SetInSlaveMode | DisableCRT2Display); |
| 1917 | temp = 0xFFFF ^ temp; |
| 1918 | tempbx &= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1919 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1920 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1921 | |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1922 | if (pVBInfo->VBType & (VB_SIS302B | VB_SIS301LV | VB_SIS302LV | |
| 1923 | VB_XGI301C)) { |
| 1924 | if (temp & EnableDualEdge) { |
| 1925 | tempbx |= SetCRT2ToDualEdge; |
| 1926 | if (temp & SetToLCDA) |
| 1927 | tempbx |= XGI_SetCRT2ToLCDA; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1928 | } |
| 1929 | } |
| 1930 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 1931 | if (pVBInfo->VBType & (VB_SIS301LV|VB_SIS302LV|VB_XGI301C)) { |
| 1932 | if (temp & SetYPbPr) { |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 1933 | /* shampoo add for new scratch */ |
| 1934 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
| 1935 | temp &= YPbPrMode; |
| 1936 | tempbx |= SetCRT2ToHiVision; |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1937 | |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 1938 | if (temp != YPbPrMode1080i) { |
| 1939 | tempbx &= (~SetCRT2ToHiVision); |
| 1940 | tempbx |= SetCRT2ToYPbPr525750; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1941 | } |
| 1942 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1943 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1944 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1945 | tempax = push; /* restore CR31 */ |
| 1946 | |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 1947 | temp = 0x09FC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1948 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1949 | if (!(tempbx & temp)) { |
| 1950 | tempax |= DisableCRT2Display; |
| 1951 | tempbx = 0; |
| 1952 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1953 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 1954 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 1955 | if (tempbx & XGI_SetCRT2ToLCDA) { |
| 1956 | if (tempbx & SetSimuScanMode) |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1957 | tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 1958 | SwitchCRT2)); |
| 1959 | else |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1960 | tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC | |
| 1961 | SetCRT2ToTV | SwitchCRT2)); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1962 | } |
| 1963 | } |
| 1964 | |
| 1965 | /* shampoo add */ |
| 1966 | /* for driver abnormal */ |
| 1967 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { |
Aaro Koskinen | ee76875 | 2013-05-29 23:59:16 +0300 | [diff] [blame] | 1968 | if (tempbx & SetCRT2ToRAMDAC) { |
| 1969 | tempbx &= (0xFF00 | SetCRT2ToRAMDAC | |
| 1970 | SwitchCRT2 | SetSimuScanMode); |
| 1971 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1972 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1973 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1974 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1975 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
| 1976 | if (tempbx & SetCRT2ToLCD) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1977 | tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchCRT2 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 1978 | SetSimuScanMode); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 1979 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 1980 | } |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1981 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1982 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1983 | if (tempbx & SetCRT2ToSCART) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 1984 | tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchCRT2 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1985 | SetSimuScanMode); |
| 1986 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750)); |
| 1987 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1988 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 1989 | if (tempbx & SetCRT2ToYPbPr525750) |
| 1990 | tempbx &= (0xFF00 | SwitchCRT2 | SetSimuScanMode); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1991 | |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 1992 | if (tempbx & SetCRT2ToHiVision) |
| 1993 | tempbx &= (0xFF00 | SetCRT2ToHiVision | SwitchCRT2 | |
| 1994 | SetSimuScanMode); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1995 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 1996 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
| 1997 | if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) |
| 1998 | tempbx = DisableCRT2Display; |
| 1999 | } |
| 2000 | |
| 2001 | if (!(tempbx & DisableCRT2Display)) { |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2002 | if ((!(tempbx & DriverMode)) || (!(modeflag & CRT2Mode))) { |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 2003 | if (!(tempbx & XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2004 | tempbx |= (SetInSlaveMode | SetSimuScanMode); |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2005 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2006 | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2007 | /* LCD+TV can't support in slave mode |
| 2008 | * (Force LCDA+TV->LCDB) */ |
Aaro Koskinen | 1b149ed | 2013-02-09 00:03:44 +0200 | [diff] [blame] | 2009 | if ((tempbx & SetInSlaveMode) && (tempbx & XGI_SetCRT2ToLCDA)) { |
| 2010 | tempbx ^= (SetCRT2ToLCD | XGI_SetCRT2ToLCDA | |
Miguel Gómez | f931735 | 2012-07-06 12:40:48 +0200 | [diff] [blame] | 2011 | SetCRT2ToDualEdge); |
| 2012 | pVBInfo->SetFlag |= ReserveTVOption; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2013 | } |
| 2014 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2015 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2016 | pVBInfo->VBInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2017 | } |
| 2018 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2019 | static void XGI_GetTVInfo(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2020 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2021 | { |
Peter Huewe | 5fc699f | 2013-02-03 04:08:45 +0100 | [diff] [blame] | 2022 | unsigned short tempbx = 0, resinfo = 0, modeflag, index1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2023 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2024 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2025 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2026 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
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 | tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
| 2029 | if (tempbx & TVSetPAL) { |
| 2030 | tempbx &= (SetCHTVOverScan | |
| 2031 | TVSetPALM | |
| 2032 | TVSetPALN | |
| 2033 | TVSetPAL); |
| 2034 | if (tempbx & TVSetPALM) |
| 2035 | /* set to NTSC if PAL-M */ |
| 2036 | tempbx &= ~TVSetPAL; |
| 2037 | } else |
| 2038 | tempbx &= (SetCHTVOverScan | |
| 2039 | TVSetNTSCJ | |
| 2040 | TVSetPAL); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2041 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2042 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 2043 | tempbx |= TVSetPAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2044 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 2045 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 2046 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
| 2047 | index1 &= YPbPrMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2048 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 2049 | if (index1 == YPbPrMode525i) |
| 2050 | tempbx |= TVSetYPbPr525i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2051 | |
Aaro Koskinen | a4ce0e7 | 2013-05-29 23:59:14 +0300 | [diff] [blame] | 2052 | if (index1 == YPbPrMode525p) |
| 2053 | tempbx = tempbx | TVSetYPbPr525p; |
| 2054 | if (index1 == YPbPrMode750p) |
| 2055 | tempbx = tempbx | TVSetYPbPr750p; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2056 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2057 | |
Aaro Koskinen | aee0ac9 | 2013-05-29 23:59:15 +0300 | [diff] [blame] | 2058 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
| 2059 | tempbx = tempbx | TVSetHiVision | TVSetPAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2060 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2061 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
| 2062 | (!(pVBInfo->VBInfo & SetNotSimuMode))) |
| 2063 | tempbx |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2064 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2065 | if (!(tempbx & TVSetPAL) && (modeflag > 13) && (resinfo == 8)) |
| 2066 | /* NTSC 1024x768, */ |
| 2067 | tempbx |= NTSC1024x768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2068 | |
Aaro Koskinen | a8b3529 | 2013-02-09 00:03:45 +0200 | [diff] [blame] | 2069 | tempbx |= RPLLDIV2XO; |
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 (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
| 2072 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2073 | tempbx &= (~RPLLDIV2XO); |
| 2074 | } else if (tempbx & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
| 2075 | tempbx &= (~RPLLDIV2XO); |
| 2076 | } else if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | |
| 2077 | VB_SIS301LV | VB_SIS302LV | |
| 2078 | VB_XGI301C))) { |
| 2079 | if (tempbx & TVSimuMode) |
| 2080 | tempbx &= (~RPLLDIV2XO); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2081 | } |
| 2082 | } |
| 2083 | pVBInfo->TVInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2084 | } |
| 2085 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2086 | static unsigned char XGI_GetLCDInfo(unsigned short ModeIdIndex, |
| 2087 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2088 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2089 | unsigned short temp, tempax, tempbx, resinfo = 0, LCDIdIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2090 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2091 | pVBInfo->LCDResInfo = 0; |
| 2092 | pVBInfo->LCDTypeInfo = 0; |
| 2093 | pVBInfo->LCDInfo = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2094 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2095 | /* si+Ext_ResInfo // */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2096 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2097 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2098 | tempbx = temp & 0x0F; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2099 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2100 | if (tempbx == 0) |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2101 | tempbx = Panel_1024x768; /* default */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2102 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 2103 | /* LCD75 */ |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2104 | if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2105 | if (pVBInfo->VBInfo & DriverMode) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2106 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2107 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2108 | tempax &= 0x0F; |
| 2109 | else |
| 2110 | tempax = tempax >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2111 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2112 | if ((resinfo == 6) || (resinfo == 9)) { |
| 2113 | if (tempax >= 3) |
| 2114 | tempbx |= PanelRef75Hz; |
| 2115 | } else if ((resinfo == 7) || (resinfo == 8)) { |
| 2116 | if (tempax >= 4) |
| 2117 | tempbx |= PanelRef75Hz; |
| 2118 | } |
| 2119 | } |
| 2120 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2121 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2122 | pVBInfo->LCDResInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2123 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2124 | /* End of LCD75 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2125 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2126 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2127 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2128 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2129 | tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2130 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2131 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2132 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2133 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
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 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2136 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2137 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
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 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2140 | |
Aaro Koskinen | 718e715 | 2013-02-09 00:03:46 +0200 | [diff] [blame] | 2141 | if (((pVBInfo->VBType & VB_SIS302LV) || |
| 2142 | (pVBInfo->VBType & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) |
| 2143 | tempbx |= SetLCDDualLink; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2144 | |
Aaro Koskinen | 718e715 | 2013-02-09 00:03:46 +0200 | [diff] [blame] | 2145 | if ((pVBInfo->LCDResInfo == Panel_1400x1050) && |
| 2146 | (pVBInfo->VBInfo & SetCRT2ToLCD) && (resinfo == 9) && |
| 2147 | (!(tempbx & EnableScalingLCD))) |
| 2148 | /* |
| 2149 | * set to center in 1280x1024 LCDB |
| 2150 | * for Panel_1400x1050 |
| 2151 | */ |
| 2152 | tempbx |= SetLCDtoNonExpanding; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2153 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2154 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 2155 | if (pVBInfo->VBInfo & SetNotSimuMode) |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2156 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2157 | } else { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2158 | tempbx |= XGI_LCDVESATiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2159 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2160 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2161 | pVBInfo->LCDInfo = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2162 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2163 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2164 | } |
| 2165 | |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2166 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2167 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2168 | { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2169 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2170 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2171 | break; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2172 | if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2173 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2174 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2175 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2176 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2177 | } |
| 2178 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2179 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
| 2180 | { |
| 2181 | unsigned char ujRet = 0; |
| 2182 | unsigned char i = 0; |
| 2183 | |
| 2184 | for (i = 0; i < 8; i++) { |
| 2185 | ujRet = ujRet << 1; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2186 | ujRet |= (ujDate >> i) & 1; |
| 2187 | } |
| 2188 | |
| 2189 | return ujRet; |
| 2190 | } |
| 2191 | |
| 2192 | /*----------------------------------------------------------------------------*/ |
| 2193 | /* output */ |
| 2194 | /* bl[5] : LVDS signal */ |
| 2195 | /* bl[1] : LVDS backlight */ |
| 2196 | /* bl[0] : LVDS VDD */ |
| 2197 | /*----------------------------------------------------------------------------*/ |
| 2198 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
| 2199 | { |
| 2200 | unsigned char CR4A, temp; |
| 2201 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2202 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2203 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2204 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2205 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2206 | |
| 2207 | temp = XG21GPIODataTransfer(temp); |
| 2208 | temp &= 0x23; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2209 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2210 | return temp; |
| 2211 | } |
| 2212 | |
| 2213 | /*----------------------------------------------------------------------------*/ |
| 2214 | /* output */ |
| 2215 | /* bl[5] : LVDS signal */ |
| 2216 | /* bl[1] : LVDS backlight */ |
| 2217 | /* bl[0] : LVDS VDD */ |
| 2218 | /*----------------------------------------------------------------------------*/ |
| 2219 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
| 2220 | { |
| 2221 | unsigned char CR4A, CRB4, temp; |
| 2222 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2223 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 2224 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2225 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2226 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2227 | |
| 2228 | temp &= 0x0C; |
| 2229 | temp >>= 2; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2230 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 2231 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2232 | temp |= ((CRB4 & 0x04) << 3); |
| 2233 | return temp; |
| 2234 | } |
| 2235 | |
Aaro Koskinen | 0ebf538 | 2011-11-27 23:03:09 +0200 | [diff] [blame] | 2236 | /*----------------------------------------------------------------------------*/ |
| 2237 | /* input */ |
| 2238 | /* bl[5] : 1;LVDS signal on */ |
| 2239 | /* bl[1] : 1;LVDS backlight on */ |
| 2240 | /* bl[0] : 1:LVDS VDD on */ |
| 2241 | /* bh: 100000b : clear bit 5, to set bit5 */ |
| 2242 | /* 000010b : clear bit 1, to set bit1 */ |
| 2243 | /* 000001b : clear bit 0, to set bit0 */ |
| 2244 | /*----------------------------------------------------------------------------*/ |
| 2245 | static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2246 | struct vb_device_info *pVBInfo) |
| 2247 | { |
| 2248 | unsigned char CR4A, temp; |
| 2249 | |
| 2250 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2251 | tempbh &= 0x23; |
| 2252 | tempbl &= 0x23; |
| 2253 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2254 | |
| 2255 | if (tempbh & 0x20) { |
| 2256 | temp = (tempbl >> 4) & 0x02; |
| 2257 | |
| 2258 | /* CR B4[1] */ |
| 2259 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2260 | |
| 2261 | } |
| 2262 | |
| 2263 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
| 2264 | |
| 2265 | temp = XG21GPIODataTransfer(temp); |
| 2266 | temp &= ~tempbh; |
| 2267 | temp |= tempbl; |
| 2268 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
| 2269 | } |
| 2270 | |
Aaro Koskinen | 776115a | 2011-11-27 23:03:10 +0200 | [diff] [blame] | 2271 | static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
| 2272 | struct vb_device_info *pVBInfo) |
| 2273 | { |
| 2274 | unsigned char CR4A, temp; |
| 2275 | unsigned short tempbh0, tempbl0; |
| 2276 | |
| 2277 | tempbh0 = tempbh; |
| 2278 | tempbl0 = tempbl; |
| 2279 | tempbh0 &= 0x20; |
| 2280 | tempbl0 &= 0x20; |
| 2281 | tempbh0 >>= 3; |
| 2282 | tempbl0 >>= 3; |
| 2283 | |
| 2284 | if (tempbh & 0x20) { |
| 2285 | temp = (tempbl >> 4) & 0x02; |
| 2286 | |
| 2287 | /* CR B4[1] */ |
| 2288 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); |
| 2289 | |
| 2290 | } |
| 2291 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
| 2292 | |
| 2293 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
| 2294 | tempbh &= 0x03; |
| 2295 | tempbl &= 0x03; |
| 2296 | tempbh <<= 2; |
| 2297 | tempbl <<= 2; /* GPIOC,GPIOD */ |
| 2298 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
| 2299 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
| 2300 | } |
| 2301 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2302 | static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info, |
| 2303 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2304 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2305 | { |
| 2306 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2307 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2308 | if (pXGIHWDE->jChipType == XG21) { |
| 2309 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2310 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2311 | /* LVDS VDD on */ |
| 2312 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2313 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2314 | } |
| 2315 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2316 | /* LVDS signal on */ |
| 2317 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2318 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2319 | /* LVDS backlight on */ |
| 2320 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2321 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2322 | /* DVO/DVI signal on */ |
| 2323 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2324 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2325 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2326 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2327 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2328 | if (pXGIHWDE->jChipType == XG27) { |
| 2329 | if (pVBInfo->IF_DEF_LVDS == 1) { |
| 2330 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2331 | /* LVDS VDD on */ |
| 2332 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2333 | mdelay(xgifb_info->lvds_data.PSC_S2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2334 | } |
| 2335 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2336 | /* LVDS signal on */ |
| 2337 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2338 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2339 | /* LVDS backlight on */ |
| 2340 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2341 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2342 | /* DVO/DVI signal on */ |
| 2343 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2344 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2345 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2346 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2347 | } |
| 2348 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 2349 | void XGI_DisplayOff(struct xgifb_video_info *xgifb_info, |
| 2350 | struct xgi_hw_device_info *pXGIHWDE, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2351 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2352 | { |
| 2353 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2354 | if (pXGIHWDE->jChipType == XG21) { |
| 2355 | if (pVBInfo->IF_DEF_LVDS == 1) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2356 | /* LVDS backlight off */ |
| 2357 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2358 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2359 | } else { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2360 | /* DVO/DVI signal off */ |
| 2361 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2362 | } |
| 2363 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2364 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2365 | if (pXGIHWDE->jChipType == XG27) { |
| 2366 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2367 | /* LVDS backlight off */ |
| 2368 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); |
Aaro Koskinen | 886230c | 2012-09-11 00:15:13 +0300 | [diff] [blame] | 2369 | mdelay(xgifb_info->lvds_data.PSC_S3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2370 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2371 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2372 | if (pVBInfo->IF_DEF_LVDS == 0) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2373 | /* DVO/DVI signal off */ |
| 2374 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2375 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2376 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2377 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2378 | } |
| 2379 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2380 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2381 | { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2382 | while ((inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2383 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2384 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 2385 | while (!(inb(pVBInfo->P3da) & 0x01)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2386 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2387 | } |
| 2388 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2389 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2390 | { |
Aaro Koskinen | 09cb8e5 | 2011-08-31 21:46:12 +0300 | [diff] [blame] | 2391 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2392 | } |
| 2393 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2394 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
| 2395 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2396 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2397 | unsigned short temp1, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2398 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2399 | /* reserve CR34 for CRT1 Mode No */ |
| 2400 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2401 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
| 2402 | temp2 = ~(SetInSlaveMode >> 8); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2403 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2404 | } |
| 2405 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2406 | static void XGI_GetCRT2ResInfo(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2407 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2408 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2409 | unsigned short xres, yres, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2410 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2411 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 2412 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 2413 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2414 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2415 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2416 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2417 | if (modeflag & HalfDCLK) |
| 2418 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2419 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2420 | if (modeflag & DoubleScanMode) |
| 2421 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2422 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2423 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 2424 | goto exit; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2425 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2426 | if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
| 2427 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2428 | if (yres == 1024) |
| 2429 | yres = 1056; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2430 | } |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2431 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2432 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2433 | if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
| 2434 | if (yres == 400) |
| 2435 | yres = 405; |
| 2436 | else if (yres == 350) |
| 2437 | yres = 360; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2438 | |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2439 | if (pVBInfo->LCDInfo & XGI_LCDVESATiming) { |
| 2440 | if (yres == 360) |
| 2441 | yres = 375; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2442 | } |
Aaro Koskinen | 2200683 | 2013-02-09 00:03:47 +0200 | [diff] [blame] | 2443 | } |
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->LCDResInfo == Panel_1024x768) { |
| 2446 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
| 2447 | if (!(pVBInfo->LCDInfo & LCDNonExpanding)) { |
| 2448 | if (yres == 350) |
| 2449 | yres = 357; |
| 2450 | else if (yres == 400) |
| 2451 | yres = 420; |
| 2452 | else if (yres == 480) |
| 2453 | yres = 525; |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2454 | } |
| 2455 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2456 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2457 | |
Miguel Gómez | 3339db8 | 2012-07-06 12:40:49 +0200 | [diff] [blame] | 2458 | if (xres == 720) |
| 2459 | xres = 640; |
| 2460 | |
| 2461 | exit: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2462 | pVBInfo->VGAHDE = xres; |
| 2463 | pVBInfo->HDE = xres; |
| 2464 | pVBInfo->VGAVDE = yres; |
| 2465 | pVBInfo->VDE = yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2466 | } |
| 2467 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2468 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2469 | { |
| 2470 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2471 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) && |
Dan Carpenter | a65fd09 | 2011-01-04 09:02:27 +0300 | [diff] [blame] | 2472 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2473 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2474 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2475 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2476 | } |
| 2477 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2478 | static void XGI_GetRAMDAC2DATA(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2479 | unsigned short RefreshRateTableIndex, |
| 2480 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2481 | { |
| 2482 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2483 | CRT1Index; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2484 | |
| 2485 | pVBInfo->RVBHCMAX = 1; |
| 2486 | pVBInfo->RVBHCFACT = 1; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2487 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2488 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2489 | CRT1Index &= IndexMask; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2490 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[0]; |
| 2491 | temp2 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[5]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2492 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2493 | tempbx = (unsigned short) XGI_CRT1Table[CRT1Index].CR[8]; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2494 | tempcx = (unsigned short) |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2495 | XGI_CRT1Table[CRT1Index].CR[14] << 8; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2496 | tempcx &= 0x0100; |
| 2497 | tempcx = tempcx << 2; |
| 2498 | tempbx |= tempcx; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2499 | temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2500 | |
| 2501 | if (temp1 & 0x01) |
| 2502 | tempbx |= 0x0100; |
| 2503 | |
| 2504 | if (temp1 & 0x20) |
| 2505 | tempbx |= 0x0200; |
| 2506 | tempax += 5; |
| 2507 | |
| 2508 | if (modeflag & Charx8Dot) |
| 2509 | tempax *= 8; |
| 2510 | else |
| 2511 | tempax *= 9; |
| 2512 | |
| 2513 | pVBInfo->VGAHT = tempax; |
| 2514 | pVBInfo->HT = tempax; |
| 2515 | tempbx++; |
| 2516 | pVBInfo->VGAVT = tempbx; |
| 2517 | pVBInfo->VT = tempbx; |
| 2518 | } |
| 2519 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2520 | static void XGI_GetCRT2Data(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2521 | unsigned short RefreshRateTableIndex, |
| 2522 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2523 | { |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 2524 | unsigned short tempax = 0, tempbx = 0, modeflag, resinfo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2525 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 2526 | struct SiS_LCDData const *LCDPtr = NULL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2527 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2528 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2529 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2530 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2531 | pVBInfo->NewFlickerMode = 0; |
| 2532 | pVBInfo->RVBHRS = 50; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2533 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2534 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2535 | XGI_GetRAMDAC2DATA(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2536 | return; |
| 2537 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2538 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2539 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2540 | LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeIdIndex, |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 2541 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2542 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2543 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; |
| 2544 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; |
| 2545 | pVBInfo->VGAHT = LCDPtr->VGAHT; |
| 2546 | pVBInfo->VGAVT = LCDPtr->VGAVT; |
| 2547 | pVBInfo->HT = LCDPtr->LCDHT; |
| 2548 | pVBInfo->VT = LCDPtr->LCDVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2549 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2550 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2551 | tempax = 1024; |
| 2552 | tempbx = 768; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2553 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2554 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2555 | if (pVBInfo->VGAVDE == 357) |
| 2556 | tempbx = 527; |
| 2557 | else if (pVBInfo->VGAVDE == 420) |
| 2558 | tempbx = 620; |
| 2559 | else if (pVBInfo->VGAVDE == 525) |
| 2560 | tempbx = 775; |
| 2561 | else if (pVBInfo->VGAVDE == 600) |
| 2562 | tempbx = 775; |
Peter Huewe | 7580d7f | 2013-05-18 00:19:54 +0200 | [diff] [blame] | 2563 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2564 | } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2565 | tempax = 1024; |
| 2566 | tempbx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2567 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2568 | tempax = 1280; |
| 2569 | if (pVBInfo->VGAVDE == 360) |
| 2570 | tempbx = 768; |
| 2571 | else if (pVBInfo->VGAVDE == 375) |
| 2572 | tempbx = 800; |
| 2573 | else if (pVBInfo->VGAVDE == 405) |
| 2574 | tempbx = 864; |
| 2575 | else |
| 2576 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2577 | } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2578 | tempax = 1280; |
| 2579 | tempbx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2580 | } else if (pVBInfo->LCDResInfo == Panel_1280x960) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2581 | tempax = 1280; |
| 2582 | if (pVBInfo->VGAVDE == 350) |
| 2583 | tempbx = 700; |
| 2584 | else if (pVBInfo->VGAVDE == 400) |
| 2585 | tempbx = 800; |
| 2586 | else if (pVBInfo->VGAVDE == 1024) |
| 2587 | tempbx = 960; |
| 2588 | else |
| 2589 | tempbx = 960; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2590 | } else if (pVBInfo->LCDResInfo == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2591 | tempax = 1400; |
| 2592 | tempbx = 1050; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2593 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2594 | if (pVBInfo->VGAVDE == 1024) { |
| 2595 | tempax = 1280; |
| 2596 | tempbx = 1024; |
| 2597 | } |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 2598 | } else if (pVBInfo->LCDResInfo == Panel_1600x1200) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2599 | tempax = 1600; |
| 2600 | tempbx = 1200; /* alan 10/14/2003 */ |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 2601 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2602 | if (pVBInfo->VGAVDE == 350) |
| 2603 | tempbx = 875; |
| 2604 | else if (pVBInfo->VGAVDE == 400) |
| 2605 | tempbx = 1000; |
| 2606 | } |
| 2607 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2608 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2609 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
| 2610 | tempax = pVBInfo->VGAHDE; |
| 2611 | tempbx = pVBInfo->VGAVDE; |
| 2612 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2613 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2614 | pVBInfo->HDE = tempax; |
| 2615 | pVBInfo->VDE = tempbx; |
| 2616 | return; |
| 2617 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2618 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2619 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 2620 | struct SiS_TVData const *TVPtr; |
| 2621 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2622 | TVPtr = XGI_GetTVPtr(ModeIdIndex, RefreshRateTableIndex, |
Aaro Koskinen | 2457254 | 2012-09-11 00:15:21 +0300 | [diff] [blame] | 2623 | pVBInfo); |
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 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
| 2626 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; |
| 2627 | pVBInfo->VGAHT = TVPtr->VGAHT; |
| 2628 | pVBInfo->VGAVT = TVPtr->VGAVT; |
| 2629 | pVBInfo->HDE = TVPtr->TVHDE; |
| 2630 | pVBInfo->VDE = TVPtr->TVVDE; |
| 2631 | pVBInfo->RVBHRS = TVPtr->RVBHRS; |
| 2632 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2633 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2634 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2635 | if (resinfo == 0x08) |
| 2636 | pVBInfo->NewFlickerMode = 0x40; |
| 2637 | else if (resinfo == 0x09) |
| 2638 | pVBInfo->NewFlickerMode = 0x40; |
| 2639 | else if (resinfo == 0x12) |
| 2640 | pVBInfo->NewFlickerMode = 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2641 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2642 | if (pVBInfo->VGAVDE == 350) |
| 2643 | pVBInfo->TVInfo |= TVSimuMode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2644 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2645 | tempax = ExtHiTVHT; |
| 2646 | tempbx = ExtHiTVVT; |
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->VBInfo & SetInSlaveMode) { |
| 2649 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 2650 | tempax = StHiTVHT; |
| 2651 | tempbx = StHiTVVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2652 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2653 | if (!(modeflag & Charx8Dot)) { |
| 2654 | tempax = StHiTextTVHT; |
| 2655 | tempbx = StHiTextTVVT; |
| 2656 | } |
| 2657 | } |
| 2658 | } |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2659 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 2660 | if (pVBInfo->TVInfo & TVSetYPbPr750p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2661 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ |
| 2662 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ |
| 2663 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2664 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2665 | if (pVBInfo->TVInfo & TVSetYPbPr525p) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2666 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ |
| 2667 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2668 | } else if (pVBInfo->TVInfo & TVSetYPbPr525i) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2669 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ |
| 2670 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ |
| 2671 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2672 | tempax = NTSC1024x768HT; |
| 2673 | } |
| 2674 | } else { |
| 2675 | tempax = PALHT; |
| 2676 | tempbx = PALVT; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 2677 | if (!(pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2678 | tempax = NTSCHT; |
| 2679 | tempbx = NTSCVT; |
| 2680 | if (pVBInfo->TVInfo & NTSC1024x768) |
| 2681 | tempax = NTSC1024x768HT; |
| 2682 | } |
| 2683 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2684 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2685 | pVBInfo->HT = tempax; |
| 2686 | pVBInfo->VT = tempbx; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2687 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2688 | } |
| 2689 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2690 | static void XGI_SetCRT2VCLK(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2691 | unsigned short RefreshRateTableIndex, |
| 2692 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2693 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 2694 | unsigned char di_0, di_1, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2695 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2696 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2697 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); |
| 2698 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2699 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2700 | if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2701 | /* 301 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2702 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
| 2703 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
| 2704 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2705 | } else { /* 301b/302b/301lv/302lv */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2706 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
| 2707 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2708 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2709 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2710 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2711 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2712 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2713 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2714 | else |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 2715 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2716 | } |
| 2717 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2718 | static unsigned short XGI_GetColorDepth(unsigned short ModeIdIndex, |
| 2719 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2720 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2721 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; |
| 2722 | short index; |
| 2723 | unsigned short modeflag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2724 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2725 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2726 | index = (modeflag & ModeTypeMask) - ModeEGA; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2727 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2728 | if (index < 0) |
| 2729 | index = 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2730 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2731 | return ColorDepth[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2732 | } |
| 2733 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2734 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
| 2735 | unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2736 | unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2737 | struct vb_device_info *pVBInfo) |
| 2738 | { |
| 2739 | unsigned short temp, colordepth, modeinfo, index, infoflag, |
| 2740 | ColorDepth[] = { 0x01, 0x02, 0x04 }; |
| 2741 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2742 | modeinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2743 | infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2744 | |
| 2745 | index = (modeinfo >> 8) & 0xFF; |
| 2746 | |
Aaro Koskinen | 224114c | 2012-11-04 21:14:59 +0200 | [diff] [blame] | 2747 | temp = XGI330_ScreenOffset[index]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2748 | |
| 2749 | if (infoflag & InterlaceMode) |
| 2750 | temp = temp << 1; |
| 2751 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2752 | colordepth = XGI_GetColorDepth(ModeIdIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2753 | |
| 2754 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
| 2755 | temp = ModeNo - 0x7C; |
| 2756 | colordepth = ColorDepth[temp]; |
| 2757 | temp = 0x6B; |
| 2758 | if (infoflag & InterlaceMode) |
| 2759 | temp = temp << 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2760 | } |
Peter Huewe | 053004b | 2013-02-15 20:37:12 +0100 | [diff] [blame] | 2761 | return temp * colordepth; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2762 | } |
| 2763 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2764 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
| 2765 | unsigned short ModeIdIndex, |
| 2766 | unsigned short RefreshRateTableIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2767 | struct vb_device_info *pVBInfo) |
| 2768 | { |
| 2769 | unsigned short offset; |
| 2770 | unsigned char temp; |
| 2771 | |
| 2772 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 2773 | return; |
| 2774 | |
| 2775 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 2776 | pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2777 | temp = (unsigned char) (offset & 0xFF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2778 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2779 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2780 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2781 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2782 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2783 | } |
| 2784 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 2785 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2786 | { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2787 | /* threshold high ,disable auto threshold */ |
| 2788 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); |
| 2789 | /* threshold low default 04h */ |
| 2790 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2791 | } |
| 2792 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2793 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2794 | unsigned short RefreshRateTableIndex, |
| 2795 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2796 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2797 | u8 tempcx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2798 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 2799 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2800 | XGI_SetCRT2FIFO(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2801 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2802 | for (tempcx = 4; tempcx < 7; tempcx++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2803 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2804 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2805 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
| 2806 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2807 | } |
| 2808 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 2809 | static void XGI_SetGroup1(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2810 | unsigned short RefreshRateTableIndex, |
| 2811 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2812 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2813 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2814 | pushbx = 0, CRT1Index, modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2815 | |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 2816 | CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2817 | CRT1Index &= IndexMask; |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2818 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2819 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2820 | /* bainy change table name */ |
| 2821 | if (modeflag & HalfDCLK) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2822 | /* BTVGA2HT 0x08,0x09 */ |
| 2823 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2824 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2825 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2826 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2827 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 2828 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2829 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2830 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
| 2831 | pushbx = pVBInfo->VGAHDE / 2 + 16; |
| 2832 | tempcx = tempcx >> 1; |
| 2833 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 2834 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2835 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2836 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2837 | tempbx = XGI_CRT1Table[CRT1Index].CR[4]; |
| 2838 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[14] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2839 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2840 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2841 | tempcx = XGI_CRT1Table[CRT1Index].CR[5]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2842 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2843 | temp = XGI_CRT1Table[CRT1Index].CR[15]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2844 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 2845 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 2846 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2847 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2848 | tempbx += 4; |
| 2849 | tempcx += 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2850 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2851 | if (tempcx > (pVBInfo->VGAHT / 2)) |
| 2852 | tempcx = pVBInfo->VGAHT / 2; |
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 | temp = tempbx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2855 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2856 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2857 | } else { |
| 2858 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2859 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2860 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2861 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2862 | /* BTVGA2HDEE 0x0A,0x0C */ |
| 2863 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2864 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2865 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
| 2866 | pushbx = pVBInfo->VGAHDE + 16; |
| 2867 | tempcx = tempcx >> 1; |
| 2868 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
| 2869 | tempcx += tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2870 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2871 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2872 | tempbx = XGI_CRT1Table[CRT1Index].CR[3]; |
| 2873 | tempbx |= ((XGI_CRT1Table[CRT1Index].CR[5] & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2874 | 0xC0) << 2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2875 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2876 | tempcx = XGI_CRT1Table[CRT1Index].CR[4]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2877 | tempcx &= 0x1F; |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2878 | temp = XGI_CRT1Table[CRT1Index].CR[6]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2879 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ |
| 2880 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ |
| 2881 | tempbx += 16; |
| 2882 | tempcx += 16; |
| 2883 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2884 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2885 | if (tempcx > pVBInfo->VGAHT) |
| 2886 | tempcx = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2887 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2888 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2889 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2890 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2891 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2892 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
| 2893 | tempbx = pushbx; |
| 2894 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); |
| 2895 | tempax |= (tempbx & 0xFF00); |
| 2896 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2897 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2898 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2899 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2900 | tempcx = (pVBInfo->VGAVT - 1); |
| 2901 | temp = tempcx & 0x00FF; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2902 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2903 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2904 | tempbx = pVBInfo->VGAVDE - 1; |
| 2905 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2906 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2907 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
| 2908 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2909 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2910 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 2911 | /* BTVGA2VRS 0x10,0x11 */ |
| 2912 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; |
| 2913 | /* BTVGA2VRE 0x11 */ |
| 2914 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2915 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2916 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2917 | tempbx = XGI_CRT1Table[CRT1Index].CR[10]; |
| 2918 | temp = XGI_CRT1Table[CRT1Index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2919 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2920 | if (temp & 0x04) |
| 2921 | tempbx |= 0x0100; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2922 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2923 | if (temp & 0x080) |
| 2924 | tempbx |= 0x0200; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2925 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2926 | temp = XGI_CRT1Table[CRT1Index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2927 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2928 | if (temp & 0x08) |
| 2929 | tempbx |= 0x0400; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2930 | |
Aaro Koskinen | 7853bce | 2012-11-04 21:14:54 +0200 | [diff] [blame] | 2931 | temp = XGI_CRT1Table[CRT1Index].CR[11]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2932 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); |
| 2933 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2934 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2935 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2936 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2937 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
| 2938 | temp = ((tempcx & 0x000F) | (temp)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2939 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2940 | tempax = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2941 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2942 | if (modeflag & DoubleScanMode) |
| 2943 | tempax |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2944 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2945 | if (modeflag & HalfDCLK) |
| 2946 | tempax |= 0x40; |
| 2947 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 2948 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2949 | } |
| 2950 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 2951 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
| 2952 | { |
| 2953 | unsigned long tempax, tempbx; |
| 2954 | |
| 2955 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
| 2956 | & 0xFFFF; |
| 2957 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; |
| 2958 | tempax = (tempax * pVBInfo->HT) / tempbx; |
| 2959 | |
| 2960 | return (unsigned short) tempax; |
| 2961 | } |
| 2962 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 2963 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2964 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2965 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2966 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 2967 | modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2968 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 2969 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 2970 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
| 2971 | resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
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 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 2974 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2975 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2976 | temp = 0xFF; /* set MAX HT */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2977 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2978 | tempcx = 0x08; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2979 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2980 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2981 | modeflag |= Charx8Dot; |
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 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2984 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2985 | if (modeflag & HalfDCLK) |
| 2986 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2987 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2988 | tempax = (tempax / tempcx) - 1; |
| 2989 | tempbx |= ((tempax & 0x00FF) << 8); |
| 2990 | temp = tempax & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 2991 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2992 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2993 | temp = (tempbx & 0xFF00) >> 8; |
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 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 2996 | if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 2997 | | VB_SIS302LV | VB_XGI301C))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 2998 | temp += 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2999 | |
Aaro Koskinen | 31fb40f | 2012-09-11 00:15:15 +0300 | [diff] [blame] | 3000 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) && |
| 3001 | !(pVBInfo->VBType & VB_SIS301LV) && (resinfo == 7)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3002 | temp -= 2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3003 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3004 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3005 | /* 0x05 Horizontal Display Start */ |
| 3006 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); |
| 3007 | /* 0x06 Horizontal Blank end */ |
| 3008 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3009 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3010 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
| 3011 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
| 3012 | tempax = pVBInfo->VGAHT; |
| 3013 | else |
| 3014 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3015 | } |
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 (tempax >= pVBInfo->VGAHT) |
| 3018 | tempax = pVBInfo->VGAHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3019 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3020 | if (modeflag & HalfDCLK) |
| 3021 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3022 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3023 | tempax = (tempax / tempcx) - 5; |
| 3024 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3025 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3026 | temp = (tempbx & 0x00FF) - 1; |
| 3027 | if (!(modeflag & HalfDCLK)) { |
| 3028 | temp -= 6; |
| 3029 | if (pVBInfo->TVInfo & TVSimuMode) { |
| 3030 | temp -= 4; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3031 | temp -= 10; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3032 | } |
| 3033 | } |
| 3034 | } else { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3035 | tempbx = (tempbx & 0xFF00) >> 8; |
| 3036 | tempcx = (tempcx + tempbx) >> 1; |
| 3037 | temp = (tempcx & 0x00FF) + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3038 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3039 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3040 | temp -= 1; |
| 3041 | if (!(modeflag & HalfDCLK)) { |
| 3042 | if ((modeflag & Charx8Dot)) { |
| 3043 | temp += 4; |
| 3044 | if (pVBInfo->VGAHDE >= 800) |
| 3045 | temp -= 6; |
| 3046 | } |
| 3047 | } |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3048 | } else if (!(modeflag & HalfDCLK)) { |
| 3049 | temp -= 4; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3050 | if (pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3051 | pVBInfo->VGAHDE >= 800) { |
| 3052 | temp -= 7; |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3053 | if (pVBInfo->VGAHDE >= 1280 && |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3054 | pVBInfo->LCDResInfo != Panel_1280x960 && |
Aaro Koskinen | 6596fc0 | 2011-11-27 23:03:19 +0200 | [diff] [blame] | 3055 | (pVBInfo->LCDInfo & LCDNonExpanding)) |
| 3056 | temp += 28; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3057 | } |
| 3058 | } |
| 3059 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3060 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3061 | /* 0x07 Horizontal Retrace Start */ |
| 3062 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
| 3063 | /* 0x08 Horizontal Retrace End */ |
| 3064 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3065 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3066 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 3067 | if (pVBInfo->TVInfo & TVSimuMode) { |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3068 | if (ModeNo == 0x50) { |
Peter Huewe | 85b3847 | 2013-05-13 23:41:49 +0200 | [diff] [blame] | 3069 | if (pVBInfo->TVInfo == SetNTSCTV) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3070 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3071 | 0x07, 0x30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3072 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3073 | 0x08, 0x03); |
| 3074 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3075 | xgifb_reg_set(pVBInfo->Part1Port, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3076 | 0x07, 0x2f); |
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 | 0x08, 0x02); |
| 3079 | } |
| 3080 | } |
| 3081 | } |
| 3082 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3083 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3084 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3085 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3086 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3087 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3088 | tempbx = pVBInfo->VGAVT; |
| 3089 | push1 = tempbx; |
| 3090 | tempcx = 0x121; |
| 3091 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3092 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3093 | if (tempbx == 357) |
| 3094 | tempbx = 350; |
| 3095 | if (tempbx == 360) |
| 3096 | tempbx = 350; |
| 3097 | if (tempbx == 375) |
| 3098 | tempbx = 350; |
| 3099 | if (tempbx == 405) |
| 3100 | tempbx = 400; |
| 3101 | if (tempbx == 525) |
| 3102 | tempbx = 480; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3103 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3104 | push2 = tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3105 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3106 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3107 | if (pVBInfo->LCDResInfo == Panel_1024x768) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3108 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3109 | if (tempbx == 350) |
| 3110 | tempbx += 5; |
| 3111 | if (tempbx == 480) |
| 3112 | tempbx += 5; |
| 3113 | } |
| 3114 | } |
| 3115 | } |
| 3116 | tempbx--; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3117 | tempbx--; |
| 3118 | temp = tempbx & 0x00FF; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3119 | /* 0x10 vertical Blank Start */ |
| 3120 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3121 | tempbx = push2; |
| 3122 | tempbx--; |
| 3123 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3124 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3125 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3126 | if (tempbx & 0x0100) |
| 3127 | tempcx |= 0x0002; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3128 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3129 | tempax = 0x000B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3130 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3131 | if (modeflag & DoubleScanMode) |
| 3132 | tempax |= 0x08000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3133 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3134 | if (tempbx & 0x0200) |
| 3135 | tempcx |= 0x0040; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3136 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3137 | temp = (tempax & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3138 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3139 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3140 | if (tempbx & 0x0400) |
| 3141 | tempcx |= 0x0600; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3142 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3143 | /* 0x11 Vertival Blank End */ |
| 3144 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3145 | |
| 3146 | tempax = push1; |
| 3147 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ |
| 3148 | tempax = tempax >> 2; |
| 3149 | push1 = tempax; /* push ax */ |
| 3150 | |
| 3151 | if (resinfo != 0x09) { |
| 3152 | tempax = tempax << 1; |
| 3153 | tempbx += tempax; |
| 3154 | } |
| 3155 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3156 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Miguel Gómez | 470c533 | 2012-07-06 12:40:50 +0200 | [diff] [blame] | 3157 | if ((pVBInfo->VBType & VB_SIS301LV) && |
| 3158 | !(pVBInfo->TVInfo & TVSetHiVision)) { |
| 3159 | if ((pVBInfo->TVInfo & TVSimuMode) && |
| 3160 | (pVBInfo->TVInfo & TVSetPAL)) { |
| 3161 | if (!(pVBInfo->VBType & VB_SIS301LV) || |
| 3162 | !(pVBInfo->TVInfo & |
| 3163 | (TVSetYPbPr525p | |
| 3164 | TVSetYPbPr750p | |
| 3165 | TVSetHiVision))) |
| 3166 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3167 | } |
| 3168 | } else { |
| 3169 | tempbx -= 10; |
| 3170 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3171 | } else if (pVBInfo->TVInfo & TVSimuMode) { |
| 3172 | if (pVBInfo->TVInfo & TVSetPAL) { |
| 3173 | if (pVBInfo->VBType & VB_SIS301LV) { |
| 3174 | if (!(pVBInfo->TVInfo & |
| 3175 | (TVSetYPbPr525p | |
| 3176 | TVSetYPbPr750p | |
| 3177 | TVSetHiVision))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3178 | tempbx += 40; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3179 | } else { |
| 3180 | tempbx += 40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3181 | } |
| 3182 | } |
| 3183 | } |
| 3184 | tempax = push1; |
| 3185 | tempax = tempax >> 2; |
| 3186 | tempax++; |
| 3187 | tempax += tempbx; |
| 3188 | push1 = tempax; /* push ax */ |
| 3189 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3190 | if ((pVBInfo->TVInfo & TVSetPAL)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3191 | if (tempbx <= 513) { |
| 3192 | if (tempax >= 513) |
| 3193 | tempbx = 513; |
| 3194 | } |
| 3195 | } |
| 3196 | |
| 3197 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3198 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3199 | tempbx--; |
| 3200 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3201 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3202 | |
| 3203 | if (tempbx & 0x0100) |
| 3204 | tempcx |= 0x0008; |
| 3205 | |
| 3206 | if (tempbx & 0x0200) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3207 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3208 | |
| 3209 | tempbx++; |
| 3210 | |
| 3211 | if (tempbx & 0x0100) |
| 3212 | tempcx |= 0x0004; |
| 3213 | |
| 3214 | if (tempbx & 0x0200) |
| 3215 | tempcx |= 0x0080; |
| 3216 | |
| 3217 | if (tempbx & 0x0400) |
| 3218 | tempcx |= 0x0C00; |
| 3219 | |
| 3220 | tempbx = push1; /* pop ax */ |
| 3221 | temp = tempbx & 0x00FF; |
| 3222 | temp &= 0x0F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3223 | /* 0x0D vertical Retrace End */ |
| 3224 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3225 | |
| 3226 | if (tempbx & 0x0010) |
| 3227 | tempcx |= 0x2000; |
| 3228 | |
| 3229 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3230 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3231 | temp = (tempcx & 0x0FF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3232 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3233 | tempax = modeflag; |
| 3234 | temp = (tempax & 0xFF00) >> 8; |
| 3235 | |
| 3236 | temp = (temp >> 1) & 0x09; |
| 3237 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3238 | if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3239 | temp |= 0x01; |
| 3240 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3241 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
| 3242 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ |
| 3243 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3244 | |
| 3245 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
| 3246 | temp = 0x80; |
| 3247 | else |
| 3248 | temp = 0x00; |
| 3249 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3250 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3251 | } |
| 3252 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3253 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3254 | struct vb_device_info *pVBInfo) |
| 3255 | { |
| 3256 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 3257 | modeflag; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 3258 | unsigned char const *TimingPoint; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3259 | |
| 3260 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
| 3261 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3262 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3263 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3264 | |
| 3265 | tempax = 0; |
| 3266 | |
| 3267 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) |
| 3268 | tempax |= 0x0800; |
| 3269 | |
| 3270 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3271 | tempax |= 0x0400; |
| 3272 | |
| 3273 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
| 3274 | tempax |= 0x0200; |
| 3275 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3276 | if (!(pVBInfo->TVInfo & TVSetPAL)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3277 | tempax |= 0x1000; |
| 3278 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3279 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3280 | tempax |= 0x0100; |
| 3281 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3282 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3283 | tempax &= 0xfe00; |
| 3284 | |
| 3285 | tempax = (tempax & 0xff00) >> 8; |
| 3286 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3287 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3288 | TimingPoint = XGI330_NTSCTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3289 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3290 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3291 | TimingPoint = XGI330_PALTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3292 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3293 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3294 | TimingPoint = XGI330_HiTVExtTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3295 | |
| 3296 | if (pVBInfo->VBInfo & SetInSlaveMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3297 | TimingPoint = XGI330_HiTVSt2Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3298 | |
| 3299 | if (pVBInfo->SetFlag & TVSimuMode) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3300 | TimingPoint = XGI330_HiTVSt1Timing; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3301 | |
| 3302 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3303 | TimingPoint = XGI330_HiTVTextTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3304 | } |
| 3305 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3306 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 3307 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3308 | TimingPoint = XGI330_YPbPr525iTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3309 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3310 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3311 | TimingPoint = XGI330_YPbPr525pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3312 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3313 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3314 | TimingPoint = XGI330_YPbPr750pTiming; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3315 | } |
| 3316 | |
| 3317 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3318 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3319 | |
| 3320 | for (i = 0x39; i <= 0x45; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3321 | /* di->temp2[j] */ |
| 3322 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3323 | |
| 3324 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3325 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3326 | |
| 3327 | temp = pVBInfo->NewFlickerMode; |
| 3328 | temp &= 0x80; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3329 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3330 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3331 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3332 | tempax = 520; |
| 3333 | else |
| 3334 | tempax = 440; |
| 3335 | |
| 3336 | if (pVBInfo->VDE <= tempax) { |
| 3337 | tempax -= pVBInfo->VDE; |
| 3338 | tempax = tempax >> 2; |
| 3339 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); |
| 3340 | push1 = tempax; |
| 3341 | temp = (tempax & 0xFF00) >> 8; |
| 3342 | temp += (unsigned short) TimingPoint[0]; |
| 3343 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3344 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3345 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3346 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3347 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3348 | | SetCRT2ToYPbPr525750)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3349 | tempcx = pVBInfo->VGAHDE; |
| 3350 | if (tempcx >= 1024) { |
| 3351 | temp = 0x17; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3352 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3353 | temp = 0x19; /* PAL */ |
| 3354 | } |
| 3355 | } |
| 3356 | } |
| 3357 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3358 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3359 | tempax = push1; |
| 3360 | temp = (tempax & 0xFF00) >> 8; |
| 3361 | temp += TimingPoint[1]; |
| 3362 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3363 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3364 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3365 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
| 3366 | | SetCRT2ToSVIDEO | SetCRT2ToSCART |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3367 | | SetCRT2ToYPbPr525750))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3368 | tempcx = pVBInfo->VGAHDE; |
| 3369 | if (tempcx >= 1024) { |
| 3370 | temp = 0x1D; /* NTSC */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3371 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3372 | temp = 0x52; /* PAL */ |
| 3373 | } |
| 3374 | } |
| 3375 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3376 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3377 | } |
| 3378 | |
| 3379 | /* 301b */ |
| 3380 | tempcx = pVBInfo->HT; |
| 3381 | |
| 3382 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3383 | tempcx = tempcx >> 1; |
| 3384 | |
| 3385 | tempcx -= 2; |
| 3386 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3387 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3388 | |
| 3389 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3390 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3391 | |
| 3392 | tempcx = pVBInfo->HT >> 1; |
| 3393 | push1 = tempcx; /* push cx */ |
| 3394 | tempcx += 7; |
| 3395 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3396 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3397 | tempcx -= 4; |
| 3398 | |
| 3399 | temp = tempcx & 0x00FF; |
| 3400 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3401 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3402 | |
| 3403 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3404 | tempbx += tempcx; |
| 3405 | push2 = tempbx; |
| 3406 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3407 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3408 | temp = (tempbx & 0xFF00) >> 8; |
| 3409 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3410 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3411 | |
| 3412 | tempbx = push2; |
| 3413 | tempbx = tempbx + 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3414 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3415 | tempbx = tempbx - 4; |
| 3416 | tempcx = tempbx; |
| 3417 | } |
| 3418 | |
| 3419 | temp = (tempbx & 0x00FF) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3420 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3421 | |
| 3422 | j += 2; |
| 3423 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); |
| 3424 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3425 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3426 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3427 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3428 | |
| 3429 | tempcx += 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3430 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3431 | tempcx -= 4; |
| 3432 | |
| 3433 | temp = tempcx & 0xFF; |
| 3434 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3435 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3436 | |
| 3437 | tempcx = push1; /* pop cx */ |
| 3438 | j += 2; |
| 3439 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); |
| 3440 | tempcx -= temp; |
| 3441 | temp = tempcx & 0x00FF; |
| 3442 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3443 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3444 | |
| 3445 | tempcx -= 11; |
| 3446 | |
| 3447 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { |
| 3448 | tempax = XGI_GetVGAHT2(pVBInfo); |
| 3449 | tempcx = tempax - 1; |
| 3450 | } |
| 3451 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3452 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3453 | |
| 3454 | tempbx = pVBInfo->VDE; |
| 3455 | |
| 3456 | if (pVBInfo->VGAVDE == 360) |
| 3457 | tempbx = 746; |
| 3458 | if (pVBInfo->VGAVDE == 375) |
| 3459 | tempbx = 746; |
| 3460 | if (pVBInfo->VGAVDE == 405) |
| 3461 | tempbx = 853; |
| 3462 | |
| 3463 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3464 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3465 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3466 | if (!(pVBInfo->TVInfo & |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3467 | (TVSetYPbPr525p | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3468 | tempbx = tempbx >> 1; |
| 3469 | } else |
| 3470 | tempbx = tempbx >> 1; |
| 3471 | } |
| 3472 | |
| 3473 | tempbx -= 2; |
| 3474 | temp = tempbx & 0x00FF; |
| 3475 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3476 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3477 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3478 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3479 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3480 | if (ModeNo == 0x2f) |
| 3481 | temp += 1; |
| 3482 | } |
| 3483 | } |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 3484 | } else if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 3485 | if (ModeNo == 0x2f) |
| 3486 | temp += 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3487 | } |
| 3488 | } |
| 3489 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3490 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3491 | |
| 3492 | temp = (tempcx & 0xFF00) >> 8; |
| 3493 | temp |= ((tempbx & 0xFF00) >> 8) << 6; |
| 3494 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3495 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3496 | if (pVBInfo->VBType & VB_SIS301LV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3497 | if (pVBInfo->TVInfo & TVSetHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3498 | temp |= 0x10; |
| 3499 | |
| 3500 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3501 | temp |= 0x20; |
| 3502 | } |
| 3503 | } else { |
| 3504 | temp |= 0x10; |
| 3505 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
| 3506 | temp |= 0x20; |
| 3507 | } |
| 3508 | } |
| 3509 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3510 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3511 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3512 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3513 | | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3514 | tempbx = pVBInfo->VDE; |
| 3515 | tempcx = tempbx - 2; |
| 3516 | |
| 3517 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3518 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p |
| 3519 | | TVSetYPbPr750p))) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3520 | tempbx = tempbx >> 1; |
| 3521 | } |
| 3522 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3523 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3524 | temp = 0; |
| 3525 | if (tempcx & 0x0400) |
| 3526 | temp |= 0x20; |
| 3527 | |
| 3528 | if (tempbx & 0x0400) |
| 3529 | temp |= 0x40; |
| 3530 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3531 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3532 | } |
| 3533 | |
| 3534 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3535 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3536 | temp = (tempbx - 3) & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3537 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3538 | } |
| 3539 | |
| 3540 | tempbx = tempbx & 0x00FF; |
| 3541 | |
| 3542 | if (!(modeflag & HalfDCLK)) { |
| 3543 | tempcx = pVBInfo->VGAHDE; |
| 3544 | if (tempcx >= pVBInfo->HDE) { |
| 3545 | tempbx |= 0x2000; |
| 3546 | tempax &= 0x00FF; |
| 3547 | } |
| 3548 | } |
| 3549 | |
| 3550 | tempcx = 0x0101; |
| 3551 | |
| 3552 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
| 3553 | if (pVBInfo->VGAHDE >= 1024) { |
| 3554 | tempcx = 0x1920; |
| 3555 | if (pVBInfo->VGAHDE >= 1280) { |
| 3556 | tempcx = 0x1420; |
| 3557 | tempbx = tempbx & 0xDFFF; |
| 3558 | } |
| 3559 | } |
| 3560 | } |
| 3561 | |
| 3562 | if (!(tempbx & 0x2000)) { |
| 3563 | if (modeflag & HalfDCLK) |
| 3564 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); |
| 3565 | |
| 3566 | push1 = tempbx; |
| 3567 | tempeax = pVBInfo->VGAHDE; |
| 3568 | tempebx = (tempcx & 0xFF00) >> 8; |
| 3569 | longtemp = tempeax * tempebx; |
| 3570 | tempecx = tempcx & 0x00FF; |
| 3571 | longtemp = longtemp / tempecx; |
| 3572 | |
| 3573 | /* 301b */ |
| 3574 | tempecx = 8 * 1024; |
| 3575 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3576 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3577 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3578 | tempecx = tempecx * 8; |
| 3579 | } |
| 3580 | |
| 3581 | longtemp = longtemp * tempecx; |
| 3582 | tempecx = pVBInfo->HDE; |
| 3583 | temp2 = longtemp % tempecx; |
| 3584 | tempeax = longtemp / tempecx; |
| 3585 | if (temp2 != 0) |
| 3586 | tempeax += 1; |
| 3587 | |
| 3588 | tempax = (unsigned short) tempeax; |
| 3589 | |
| 3590 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3591 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 3592 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3593 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; |
| 3594 | } |
| 3595 | /* end 301b */ |
| 3596 | |
| 3597 | tempbx = push1; |
| 3598 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) |
| 3599 | | (tempbx & 0x00FF)); |
| 3600 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) |
| 3601 | | (tempax & 0x00FF)); |
| 3602 | temp = (tempax & 0xFF00) >> 8; |
| 3603 | } else { |
| 3604 | temp = (tempax & 0x00FF) >> 8; |
| 3605 | } |
| 3606 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3607 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3608 | temp = (tempbx & 0xFF00) >> 8; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3609 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3610 | temp = tempcx & 0x00FF; |
| 3611 | |
| 3612 | if (tempbx & 0x2000) |
| 3613 | temp = 0; |
| 3614 | |
| 3615 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3616 | temp |= 0x18; |
| 3617 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3618 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3619 | if (pVBInfo->TVInfo & TVSetPAL) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3620 | tempbx = 0x0382; |
| 3621 | tempcx = 0x007e; |
| 3622 | } else { |
| 3623 | tempbx = 0x0369; |
| 3624 | tempcx = 0x0061; |
| 3625 | } |
| 3626 | |
| 3627 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3628 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3629 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3630 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3631 | |
| 3632 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
| 3633 | temp = temp << 2; |
| 3634 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; |
| 3635 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3636 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3637 | temp |= 0x10; |
| 3638 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3639 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3640 | temp |= 0x20; |
| 3641 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3642 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3643 | temp |= 0x60; |
| 3644 | } |
| 3645 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3646 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 3647 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3648 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3649 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3650 | if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3651 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 3652 | TimingPoint = XGI_NTSC1024AdjTime; |
| 3653 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3654 | xgifb_reg_set(pVBInfo->Part2Port, i, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3655 | TimingPoint[j]); |
| 3656 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3657 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3658 | } |
| 3659 | } |
| 3660 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 3661 | /* Modify for 301C PALM Support */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3662 | if (pVBInfo->VBType & VB_XGI301C) { |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3663 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3664 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3665 | 0x08); /* PALM Mode */ |
| 3666 | } |
| 3667 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3668 | if (pVBInfo->TVInfo & TVSetPALM) { |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 3669 | tempax = xgifb_reg_get(pVBInfo->Part2Port, 0x01); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3670 | tempax--; |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3671 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3672 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 3673 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3674 | } |
| 3675 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3676 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3677 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3678 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3679 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3680 | } |
| 3681 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 3682 | static void XGI_SetLCDRegs(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3683 | struct vb_device_info *pVBInfo) |
| 3684 | { |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 3685 | unsigned short pushbx, tempax, tempbx, tempcx, temp, tempah, |
| 3686 | tempbh, tempch; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3687 | |
Aaro Koskinen | bdc9eb1 | 2012-11-04 21:14:47 +0200 | [diff] [blame] | 3688 | struct XGI_LCDDesStruct const *LCDBDesPtr = NULL; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3689 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3690 | /* si+Ext_ResInfo */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3691 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 3692 | return; |
| 3693 | |
| 3694 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
| 3695 | |
| 3696 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 3697 | tempbx = tempbx >> 1; |
| 3698 | |
| 3699 | tempbx -= 1; |
| 3700 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3701 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3702 | temp = (tempbx & 0xFF00) >> 8; |
| 3703 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3704 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3705 | temp = 0x01; |
| 3706 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3707 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3708 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3709 | tempbx--; |
| 3710 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3711 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3712 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3713 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3714 | |
| 3715 | tempcx = pVBInfo->VT - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3716 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3717 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3718 | temp = (tempcx & 0xFF00) >> 8; |
| 3719 | temp = temp << 5; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3720 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3721 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
| 3722 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); |
| 3723 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); |
| 3724 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3725 | |
Justin P. Mattock | 558f758 | 2012-10-02 21:17:11 -0700 | [diff] [blame] | 3726 | /* Customized LCDB Does not add */ |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 3727 | if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 3728 | LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeIdIndex, |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 3729 | pVBInfo); |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 3730 | else |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 3731 | LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeIdIndex, |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 3732 | pVBInfo); |
Aaro Koskinen | 9d1c629 | 2012-11-04 21:14:46 +0200 | [diff] [blame] | 3733 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3734 | tempah = pVBInfo->LCDResInfo; |
| 3735 | tempah &= PanelResInfo; |
| 3736 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3737 | if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3738 | tempbx = 1024; |
| 3739 | tempcx = 768; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3740 | } else if ((tempah == Panel_1280x1024) || |
| 3741 | (tempah == Panel_1280x1024x75)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3742 | tempbx = 1280; |
| 3743 | tempcx = 1024; |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 3744 | } else if (tempah == Panel_1400x1050) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3745 | tempbx = 1400; |
| 3746 | tempcx = 1050; |
| 3747 | } else { |
| 3748 | tempbx = 1600; |
| 3749 | tempcx = 1200; |
| 3750 | } |
| 3751 | |
| 3752 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
| 3753 | tempbx = pVBInfo->HDE; |
| 3754 | tempcx = pVBInfo->VDE; |
| 3755 | } |
| 3756 | |
| 3757 | pushbx = tempbx; |
| 3758 | tempax = pVBInfo->VT; |
| 3759 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; |
| 3760 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; |
| 3761 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; |
| 3762 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; |
| 3763 | tempbx = pVBInfo->LCDVDES; |
| 3764 | tempcx += tempbx; |
| 3765 | |
| 3766 | if (tempcx >= tempax) |
| 3767 | tempcx -= tempax; /* lcdvdes */ |
| 3768 | |
| 3769 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3770 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3771 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3772 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3773 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
| 3774 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; |
| 3775 | tempah = tempch; |
| 3776 | tempah = tempah << 3; |
| 3777 | tempah |= tempbh; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3778 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3779 | |
| 3780 | /* getlcdsync() */ |
| 3781 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 3782 | tempcx = tempbx; |
| 3783 | tempax = pVBInfo->VT; |
| 3784 | tempbx = pVBInfo->LCDVRS; |
| 3785 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3786 | tempcx += tempbx; |
| 3787 | if (tempcx >= tempax) |
| 3788 | tempcx -= tempax; |
| 3789 | |
| 3790 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3791 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3792 | temp = (tempbx & 0xFF00) >> 8; |
| 3793 | temp = temp << 4; |
| 3794 | temp |= (tempcx & 0x000F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3795 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3796 | tempcx = pushbx; |
| 3797 | tempax = pVBInfo->HT; |
| 3798 | tempbx = pVBInfo->LCDHDES; |
| 3799 | tempbx &= 0x0FFF; |
| 3800 | |
| 3801 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 3802 | tempax = tempax >> 1; |
| 3803 | tempbx = tempbx >> 1; |
| 3804 | tempcx = tempcx >> 1; |
| 3805 | } |
| 3806 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3807 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3808 | tempbx += 1; |
| 3809 | |
| 3810 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ |
| 3811 | tempbx += 1; |
| 3812 | |
| 3813 | tempcx += tempbx; |
| 3814 | |
| 3815 | if (tempcx >= tempax) |
| 3816 | tempcx -= tempax; |
| 3817 | |
| 3818 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3819 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3820 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3821 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3822 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3823 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3824 | temp = (tempcx & 0xFF00) >> 8; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3825 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3826 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3827 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
| 3828 | tempcx = tempax; |
| 3829 | tempax = pVBInfo->HT; |
| 3830 | tempbx = pVBInfo->LCDHRS; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3831 | if (XGI_IsLCDDualLink(pVBInfo)) { |
| 3832 | tempax = tempax >> 1; |
| 3833 | tempbx = tempbx >> 1; |
| 3834 | tempcx = tempcx >> 1; |
| 3835 | } |
| 3836 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3837 | if (pVBInfo->VBType & VB_SIS302LV) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3838 | tempbx += 1; |
| 3839 | |
| 3840 | tempcx += tempbx; |
| 3841 | |
| 3842 | if (tempcx >= tempax) |
| 3843 | tempcx -= tempax; |
| 3844 | |
| 3845 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3846 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3847 | |
| 3848 | temp = (tempbx & 0xFF00) >> 8; |
| 3849 | temp = temp << 4; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 3850 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3851 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3852 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3853 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 3854 | if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3855 | if (pVBInfo->VGAVDE == 525) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3856 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 3857 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3858 | | VB_XGI301C)) { |
| 3859 | temp = 0xC6; |
| 3860 | } else |
| 3861 | temp = 0xC4; |
| 3862 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3863 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
| 3864 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3865 | } |
| 3866 | |
| 3867 | if (pVBInfo->VGAVDE == 420) { |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 3868 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
| 3869 | | VB_SIS301LV | VB_SIS302LV |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3870 | | VB_XGI301C)) { |
| 3871 | temp = 0x4F; |
| 3872 | } else |
| 3873 | temp = 0x4E; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3874 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3875 | } |
| 3876 | } |
| 3877 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3878 | |
| 3879 | /* --------------------------------------------------------------------- */ |
| 3880 | /* Function : XGI_GetTap4Ptr */ |
| 3881 | /* Input : */ |
| 3882 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
| 3883 | /* Description : */ |
| 3884 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 3885 | static struct XGI301C_Tap4TimingStruct const |
| 3886 | *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3887 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3888 | unsigned short tempax, tempbx, i; |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 3889 | struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3890 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3891 | if (tempcx == 0) { |
| 3892 | tempax = pVBInfo->VGAHDE; |
| 3893 | tempbx = pVBInfo->HDE; |
| 3894 | } else { |
| 3895 | tempax = pVBInfo->VGAVDE; |
| 3896 | tempbx = pVBInfo->VDE; |
| 3897 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3898 | |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3899 | if (tempax <= tempbx) |
| 3900 | return &xgifb_tap4_timing[0]; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3901 | else |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3902 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3903 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3904 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3905 | Tap4TimingPtr = PALTap4Timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3906 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3907 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) { |
| 3908 | if ((pVBInfo->TVInfo & TVSetYPbPr525i) || |
| 3909 | (pVBInfo->TVInfo & TVSetYPbPr525p)) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3910 | Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3911 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3912 | Tap4TimingPtr = YPbPr750pTap4Timing; |
| 3913 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3914 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3915 | if (pVBInfo->VBInfo & SetCRT2ToHiVision) |
Aaro Koskinen | 11fbdcd | 2011-08-31 21:46:10 +0300 | [diff] [blame] | 3916 | Tap4TimingPtr = xgifb_tap4_timing; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3917 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3918 | i = 0; |
| 3919 | while (Tap4TimingPtr[i].DE != 0xFFFF) { |
| 3920 | if (Tap4TimingPtr[i].DE == tempax) |
| 3921 | break; |
| 3922 | i++; |
| 3923 | } |
| 3924 | return &Tap4TimingPtr[i]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3925 | } |
| 3926 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 3927 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3928 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3929 | unsigned short i, j; |
Aaro Koskinen | 1cccd9e | 2012-11-04 21:15:06 +0200 | [diff] [blame] | 3930 | struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3931 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3932 | if (!(pVBInfo->VBType & VB_XGI301C)) |
| 3933 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3934 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3935 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
| 3936 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3937 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3938 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3939 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3940 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3941 | /* Set Vertical Scaling */ |
| 3942 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3943 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3944 | xgifb_reg_set(pVBInfo->Part2Port, |
| 3945 | i, |
| 3946 | Tap4TimingPtr->Reg[j]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3947 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3948 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3949 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3950 | (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3951 | /* Enable V.Scaling */ |
| 3952 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3953 | else |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 3954 | /* Enable H.Scaling */ |
| 3955 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3956 | } |
| 3957 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 3958 | static void XGI_SetGroup3(unsigned short ModeIdIndex, |
| 3959 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3960 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3961 | unsigned short i; |
Aaro Koskinen | d21222d | 2012-09-11 00:15:29 +0300 | [diff] [blame] | 3962 | unsigned char const *tempdi; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3963 | unsigned short modeflag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3964 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 3965 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 3966 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3967 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3968 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3969 | if (pVBInfo->TVInfo & TVSetPAL) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3970 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 3971 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3972 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3973 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
| 3974 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3975 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3976 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3977 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 3978 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3979 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3980 | if (pVBInfo->TVInfo & TVSetPALM) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 3981 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
| 3982 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); |
| 3983 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); |
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 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3986 | if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo |
| 3987 | & SetCRT2ToYPbPr525750)) { |
| 3988 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3989 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3990 | |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3991 | tempdi = XGI330_HiTVGroup3Data; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3992 | if (pVBInfo->SetFlag & TVSimuMode) { |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3993 | tempdi = XGI330_HiTVGroup3Simu; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3994 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3995 | tempdi = XGI330_HiTVGroup3Text; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 3996 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3997 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 3998 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 3999 | tempdi = XGI330_Ren525pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4000 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4001 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Aaro Koskinen | 073b61e | 2012-09-11 00:15:28 +0300 | [diff] [blame] | 4002 | tempdi = XGI330_Ren750pGroup3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4003 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4004 | for (i = 0; i <= 0x3E; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4005 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4006 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4007 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4008 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4009 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4010 | } |
| 4011 | } |
Aaro Koskinen | 2351d1f | 2013-05-29 23:59:13 +0300 | [diff] [blame] | 4012 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4013 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4014 | static void XGI_SetGroup4(unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4015 | unsigned short RefreshRateTableIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4016 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4017 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4018 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4019 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4020 | unsigned long tempebx, tempeax, templong; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4021 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4022 | /* si+Ext_ResInfo */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4023 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4024 | temp = pVBInfo->RVBHCFACT; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4025 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
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 | tempbx = pVBInfo->RVBHCMAX; |
| 4028 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4029 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4030 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
| 4031 | tempcx = pVBInfo->VGAHT - 1; |
| 4032 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4033 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4034 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4035 | temp = ((tempcx & 0xFF00) >> 8) << 3; |
| 4036 | temp2 |= temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4037 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4038 | tempcx = pVBInfo->VGAVT - 1; |
| 4039 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
| 4040 | tempcx -= 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4041 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4042 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4043 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4044 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4045 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4046 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4047 | tempcx = pVBInfo->VBInfo; |
| 4048 | tempbx = pVBInfo->VGAHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4049 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4050 | if (modeflag & HalfDCLK) |
| 4051 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4052 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4053 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4054 | tempbx = tempbx >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4055 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4056 | if (tempcx & SetCRT2ToHiVision) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4057 | temp = 0; |
| 4058 | if (tempbx <= 1024) |
| 4059 | temp = 0xA0; |
| 4060 | if (tempbx == 1280) |
| 4061 | temp = 0xC0; |
| 4062 | } else if (tempcx & SetCRT2ToTV) { |
| 4063 | temp = 0xA0; |
| 4064 | if (tempbx <= 800) |
| 4065 | temp = 0x80; |
| 4066 | } else { |
| 4067 | temp = 0x80; |
| 4068 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4069 | temp = 0; |
| 4070 | if (tempbx > 800) |
| 4071 | temp = 0x60; |
| 4072 | } |
| 4073 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4074 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4075 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4076 | temp = 0x00; |
| 4077 | if (pVBInfo->VGAHDE == 1280) |
| 4078 | temp = 0x40; |
| 4079 | if (pVBInfo->VGAHDE == 1024) |
| 4080 | temp = 0x20; |
| 4081 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4082 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4083 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4084 | tempebx = pVBInfo->VDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4085 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4086 | tempcx = pVBInfo->RVBHRS; |
| 4087 | temp = tempcx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4088 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4089 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4090 | tempeax = pVBInfo->VGAVDE; |
| 4091 | tempcx |= 0x04000; |
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 | if (tempeax <= tempebx) { |
| 4094 | tempcx = (tempcx & (~0x4000)); |
| 4095 | tempeax = pVBInfo->VGAVDE; |
| 4096 | } else { |
| 4097 | tempeax -= tempebx; |
| 4098 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4099 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4100 | templong = (tempeax * 256 * 1024) % tempebx; |
| 4101 | tempeax = (tempeax * 256 * 1024) / tempebx; |
| 4102 | tempebx = tempeax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4103 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4104 | if (templong != 0) |
| 4105 | tempebx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4106 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4107 | temp = (unsigned short) (tempebx & 0x000000FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4108 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4109 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4110 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4111 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4112 | tempbx = (unsigned short) (tempebx >> 16); |
| 4113 | temp = tempbx & 0x00FF; |
| 4114 | temp = temp << 4; |
| 4115 | temp |= ((tempcx & 0xFF00) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4116 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4117 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4118 | /* 301b */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4119 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4120 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4121 | temp = 0x0028; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4122 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4123 | tempax = pVBInfo->VGAHDE; |
| 4124 | if (modeflag & HalfDCLK) |
| 4125 | tempax = tempax >> 1; |
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 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4128 | tempax = tempax >> 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4129 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4130 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
| 4131 | if (tempax > 800) |
| 4132 | tempax -= 800; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 4133 | } else if (pVBInfo->VGAHDE > 800) { |
| 4134 | if (pVBInfo->VGAHDE == 1024) |
| 4135 | tempax = (tempax * 25 / 32) - 1; |
| 4136 | else |
| 4137 | tempax = (tempax * 20 / 32) - 1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4138 | } |
| 4139 | tempax -= 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4140 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4141 | temp = (tempax & 0xFF00) >> 8; |
| 4142 | temp = ((temp & 0x0003) << 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4143 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4144 | temp = (tempax & 0x00FF); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4145 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4146 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4147 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4148 | if (pVBInfo->VGAHDE > 800) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4149 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4150 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4151 | } |
| 4152 | temp = 0x0036; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4153 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4154 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
| 4155 | if (!(pVBInfo->TVInfo & (NTSC1024x768 |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4156 | | TVSetYPbPr525p | TVSetYPbPr750p |
| 4157 | | TVSetHiVision))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4158 | temp |= 0x0001; |
| 4159 | if ((pVBInfo->VBInfo & SetInSlaveMode) |
| 4160 | && (!(pVBInfo->TVInfo |
| 4161 | & TVSimuMode))) |
| 4162 | temp &= (~0x0001); |
| 4163 | } |
| 4164 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4165 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4166 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4167 | tempbx = pVBInfo->HT; |
| 4168 | if (XGI_IsLCDDualLink(pVBInfo)) |
| 4169 | tempbx = tempbx >> 1; |
| 4170 | tempbx = (tempbx >> 1) - 2; |
| 4171 | temp = ((tempbx & 0x0700) >> 8) << 3; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4172 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4173 | temp = tempbx & 0x00FF; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4174 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4175 | } |
| 4176 | /* end 301b */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4177 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4178 | XGI_SetCRT2VCLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4179 | } |
| 4180 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4181 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
| 4182 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4183 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4184 | } |
| 4185 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4186 | static void XGI_SetGroup5(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4187 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4188 | if (pVBInfo->ModeType == ModeVGA) { |
| 4189 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4190 | | DisableCRT2Display))) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4191 | XGINew_EnableCRT2(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4192 | } |
| 4193 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4194 | } |
| 4195 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 4196 | static void XGI_DisableGatingCRT(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4197 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4198 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4199 | } |
| 4200 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4201 | static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, |
| 4202 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 4203 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4204 | { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4205 | unsigned short xres, yres, colordepth, modeflag, resindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4206 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4207 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 4208 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4209 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4210 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4211 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4212 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4213 | if (!(modeflag & Charx8Dot)) { |
| 4214 | xres /= 9; |
| 4215 | xres *= 8; |
| 4216 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4217 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4218 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) |
| 4219 | xres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4220 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4221 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) |
| 4222 | yres *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4223 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4224 | if (xres > xgifb_info->lvds_data.LVDSHDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4225 | return 0; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4226 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4227 | if (yres > xgifb_info->lvds_data.LVDSVDE) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4228 | return 0; |
| 4229 | |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4230 | if (xres != xgifb_info->lvds_data.LVDSHDE || |
| 4231 | yres != xgifb_info->lvds_data.LVDSVDE) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4232 | colordepth = XGI_GetColorDepth(ModeIdIndex, pVBInfo); |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4233 | if (colordepth > 2) |
| 4234 | return 0; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4235 | } |
| 4236 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4237 | } |
| 4238 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4239 | static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, |
| 4240 | int chip_id, |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4241 | unsigned short ModeIdIndex, |
| 4242 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4243 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4244 | unsigned char temp, Miscdata; |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4245 | unsigned short xres, yres, modeflag, resindex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4246 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; |
| 4247 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; |
| 4248 | unsigned short value; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4249 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4250 | temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4251 | (LCDPolarity << 8)) >> 8); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4252 | temp &= LCDPolarity; |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 4253 | Miscdata = inb(pVBInfo->P3cc); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4254 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4255 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4256 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4257 | temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4258 | /* SR35[7] FP VSync polarity */ |
| 4259 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); |
| 4260 | /* SR30[5] FP HSync polarity */ |
| 4261 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4262 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4263 | if (chip_id == XG27) |
| 4264 | XGI_SetXG27FPBits(pVBInfo); |
| 4265 | else |
| 4266 | XGI_SetXG21FPBits(pVBInfo); |
| 4267 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4268 | resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO; |
Aaro Koskinen | e8e6c75 | 2012-11-04 21:15:00 +0200 | [diff] [blame] | 4269 | xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */ |
| 4270 | yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4271 | /* si+St_ModeFlag */ |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4272 | modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4273 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4274 | if (!(modeflag & Charx8Dot)) |
| 4275 | xres = xres * 8 / 9; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4276 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4277 | LVDSHT = xgifb_info->lvds_data.LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4278 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4279 | LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4280 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4281 | if (LVDSHBS > LVDSHT) |
| 4282 | LVDSHBS -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4283 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4284 | LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4285 | if (LVDSHRS > LVDSHT) |
| 4286 | LVDSHRS -= 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 | LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4289 | if (LVDSHRE > LVDSHT) |
| 4290 | LVDSHRE -= LVDSHT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4291 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4292 | LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4293 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4294 | LVDSVT = xgifb_info->lvds_data.LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4295 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4296 | LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4297 | if (modeflag & DoubleScanMode) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4298 | LVDSVBS += yres / 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4299 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4300 | if (LVDSVBS > LVDSVT) |
| 4301 | LVDSVBS -= LVDSVT; |
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 | LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4304 | if (LVDSVRS > LVDSVT) |
| 4305 | LVDSVRS -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4306 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4307 | LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4308 | if (LVDSVRE > LVDSVT) |
| 4309 | LVDSVRE -= LVDSVT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4310 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4311 | LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4312 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 4313 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x11); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4314 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4315 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4316 | if (!(modeflag & Charx8Dot)) |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4317 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4318 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4319 | /* HT SR0B[1:0] CR00 */ |
| 4320 | value = (LVDSHT >> 3) - 5; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4321 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4322 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4323 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4324 | /* HBS SR0B[5:4] CR02 */ |
| 4325 | value = (LVDSHBS >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4326 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4327 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4328 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4329 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ |
| 4330 | value = (LVDSHBE >> 3) - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4331 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
| 4332 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); |
| 4333 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4334 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4335 | /* HRS SR0B[7:6] CR04 */ |
| 4336 | value = (LVDSHRS >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4337 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4338 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4339 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4340 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ |
| 4341 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4342 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4343 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4344 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4345 | /* HRE SR0C[2] CR05[4:0] */ |
| 4346 | value = (LVDSHRE >> 3) + 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4347 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
| 4348 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4349 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4350 | /* Panel HRE SR2F[7:2] */ |
| 4351 | value--; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4352 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
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 | /* VT SR0A[0] CR07[5][0] CR06 */ |
| 4355 | value = LVDSVT - 2; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4356 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
| 4357 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); |
| 4358 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4359 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4360 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4361 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ |
| 4362 | value = LVDSVBS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4363 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
| 4364 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); |
| 4365 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4366 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4367 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4368 | /* VBE SR0A[4] CR16 */ |
| 4369 | value = LVDSVBE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4370 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4371 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4372 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4373 | /* VRS SR0A[3] CR7[7][2] CR10 */ |
| 4374 | value = LVDSVRS - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4375 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
| 4376 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); |
| 4377 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4378 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4379 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4380 | if (chip_id == XG27) { |
| 4381 | /* Panel VRS SR35[2:0] SR34[7:0] */ |
| 4382 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, |
| 4383 | (value & 0x700) >> 8); |
| 4384 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
| 4385 | } else { |
| 4386 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ |
| 4387 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, |
| 4388 | (value & 0x600) >> 9); |
| 4389 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
| 4390 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
| 4391 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4392 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4393 | /* VRE SR0A[5] CR11[3:0] */ |
| 4394 | value = LVDSVRE - 1; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4395 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
| 4396 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4397 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4398 | /* Panel VRE SR3F[7:2] */ |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 4399 | if (chip_id == XG27) |
| 4400 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4401 | (value << 2) & 0xFC); |
| 4402 | else |
| 4403 | /* SR3F[7] has to be 0, h/w bug */ |
| 4404 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, |
| 4405 | (value << 2) & 0x7C); |
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 | for (temp = 0, value = 0; temp < 3; temp++) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4408 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4409 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4410 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4411 | 0x2B, xgifb_info->lvds_data.VCLKData1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4412 | xgifb_reg_set(pVBInfo->P3c4, |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4413 | 0x2C, xgifb_info->lvds_data.VCLKData2); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4414 | value += 0x10; |
| 4415 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4416 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4417 | if (!(modeflag & Charx8Dot)) { |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4418 | inb(pVBInfo->P3da); /* reset 3da */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4419 | outb(0x13, pVBInfo->P3c0); /* set index */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4420 | /* set data, panning = 0, shift left 1 dot*/ |
| 4421 | outb(0x00, pVBInfo->P3c0); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4422 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4423 | inb(pVBInfo->P3da); /* Enable Attribute */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 4424 | outb(0x20, pVBInfo->P3c0); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4425 | |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 4426 | inb(pVBInfo->P3da); /* reset 3da */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4427 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4428 | |
| 4429 | } |
| 4430 | |
| 4431 | /* --------------------------------------------------------------------- */ |
| 4432 | /* Function : XGI_IsLCDON */ |
| 4433 | /* Input : */ |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 4434 | /* Output : 0 : Skip PSC Control */ |
| 4435 | /* 1: Disable PSC */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4436 | /* Description : */ |
| 4437 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4438 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4439 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4440 | unsigned short tempax; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4441 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4442 | tempax = pVBInfo->VBInfo; |
| 4443 | if (tempax & SetCRT2ToDualEdge) |
| 4444 | return 0; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4445 | else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4446 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4447 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4448 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4449 | } |
| 4450 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4451 | static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info, |
| 4452 | struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4453 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4454 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 4455 | unsigned short tempah = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4456 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4457 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4458 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4459 | tempah = 0x3F; |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4460 | if (!(pVBInfo->VBInfo & |
| 4461 | (DisableCRT2Display | SetSimuScanMode))) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4462 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | 41fc5f0 | 2013-05-29 23:59:12 +0300 | [diff] [blame] | 4463 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4464 | tempah = 0x7F; /* Disable Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4465 | } |
| 4466 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4467 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4468 | /* disable part4_1f */ |
| 4469 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4470 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4471 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4472 | if (((pVBInfo->VBInfo & |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 4473 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) || |
Peter Huewe | 06cc47b | 2013-02-03 22:54:38 +0100 | [diff] [blame] | 4474 | (XGI_IsLCDON(pVBInfo))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4475 | /* LVDS Driver power down */ |
| 4476 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4477 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4478 | |
Aaro Koskinen | d172463 | 2013-05-29 23:59:09 +0300 | [diff] [blame] | 4479 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA | |
| 4480 | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4481 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4482 | |
Aaro Koskinen | 41fc5f0 | 2013-05-29 23:59:12 +0300 | [diff] [blame] | 4483 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
| 4484 | /* Power down */ |
| 4485 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4486 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4487 | /* disable TV as primary VGA swap */ |
| 4488 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4489 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4490 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 4491 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4492 | |
Aaro Koskinen | c4f9c31 | 2013-05-29 23:59:07 +0300 | [diff] [blame] | 4493 | if ((pVBInfo->VBInfo & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4494 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4495 | ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4496 | (pVBInfo->VBInfo & |
| 4497 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4498 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4499 | |
Aaro Koskinen | c4f9c31 | 2013-05-29 23:59:07 +0300 | [diff] [blame] | 4500 | if ((pVBInfo->VBInfo & |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4501 | (DisableCRT2Display | SetSimuScanMode)) || |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4502 | (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) || |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4503 | (pVBInfo->VBInfo & |
| 4504 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { |
| 4505 | /* save Part1 index 0 */ |
| 4506 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
| 4507 | /* BTDAC = 1, avoid VB reset */ |
| 4508 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); |
| 4509 | /* disable CRT2 */ |
| 4510 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4511 | /* restore Part1 index 0 */ |
| 4512 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4513 | } |
| 4514 | } else { /* {301} */ |
| 4515 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4516 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); |
| 4517 | /* Disable CRT2 */ |
| 4518 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); |
| 4519 | /* Disable TV asPrimary VGA swap */ |
| 4520 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4521 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4522 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4523 | if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4524 | | SetSimuScanMode)) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 4525 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4526 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4527 | } |
| 4528 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4529 | /* --------------------------------------------------------------------- */ |
| 4530 | /* Function : XGI_GetTVPtrIndex */ |
| 4531 | /* Input : */ |
| 4532 | /* Output : */ |
| 4533 | /* Description : bx 0 : ExtNTSC */ |
| 4534 | /* 1 : StNTSC */ |
| 4535 | /* 2 : ExtPAL */ |
| 4536 | /* 3 : StPAL */ |
| 4537 | /* 4 : ExtHiTV */ |
| 4538 | /* 5 : StHiTV */ |
| 4539 | /* 6 : Ext525i */ |
| 4540 | /* 7 : St525i */ |
| 4541 | /* 8 : Ext525p */ |
| 4542 | /* 9 : St525p */ |
| 4543 | /* A : Ext750p */ |
| 4544 | /* B : St750p */ |
| 4545 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4546 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4547 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4548 | unsigned short tempbx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4549 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4550 | if (pVBInfo->TVInfo & TVSetPAL) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4551 | tempbx = 2; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4552 | if (pVBInfo->TVInfo & TVSetHiVision) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4553 | tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4554 | if (pVBInfo->TVInfo & TVSetYPbPr525i) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4555 | tempbx = 6; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4556 | if (pVBInfo->TVInfo & TVSetYPbPr525p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4557 | tempbx = 8; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4558 | if (pVBInfo->TVInfo & TVSetYPbPr750p) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4559 | tempbx = 10; |
| 4560 | if (pVBInfo->TVInfo & TVSimuMode) |
| 4561 | tempbx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4562 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4563 | return tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4564 | } |
| 4565 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4566 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4567 | /* Function : XGI_GetTVPtrIndex2 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4568 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4569 | /* Output : bx 0 : NTSC */ |
| 4570 | /* 1 : PAL */ |
| 4571 | /* 2 : PALM */ |
| 4572 | /* 3 : PALN */ |
| 4573 | /* 4 : NTSC1024x768 */ |
| 4574 | /* 5 : PAL-M 1024x768 */ |
| 4575 | /* 6-7: reserved */ |
| 4576 | /* cl 0 : YFilter1 */ |
| 4577 | /* 1 : YFilter2 */ |
| 4578 | /* ch 0 : 301A */ |
| 4579 | /* 1 : 301B/302B/301LV/302LV */ |
| 4580 | /* Description : */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4581 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4582 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
| 4583 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4584 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4585 | *tempbx = 0; |
| 4586 | *tempcl = 0; |
| 4587 | *tempch = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4588 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4589 | if (pVBInfo->TVInfo & TVSetPAL) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4590 | *tempbx = 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4591 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4592 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4593 | *tempbx = 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4594 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4595 | if (pVBInfo->TVInfo & TVSetPALN) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4596 | *tempbx = 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4597 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4598 | if (pVBInfo->TVInfo & NTSC1024x768) { |
| 4599 | *tempbx = 4; |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4600 | if (pVBInfo->TVInfo & TVSetPALM) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4601 | *tempbx = 5; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4602 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4603 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4604 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4605 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4606 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo |
| 4607 | & TVSimuMode)) { |
| 4608 | *tempbx += 8; |
| 4609 | *tempcl += 1; |
| 4610 | } |
| 4611 | } |
| 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 | (*tempch)++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4616 | } |
| 4617 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4618 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4619 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4620 | unsigned char tempah, tempbl, tempbh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 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)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4624 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4625 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4626 | tempbh = 0; |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 4627 | tempbl = XGI301TVDelay; |
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 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 4630 | tempbl = tempbl >> 4; |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4631 | if (pVBInfo->VBInfo & |
| 4632 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Peter Huewe | 03f76fc | 2012-06-14 00:21:50 +0200 | [diff] [blame] | 4633 | tempbh = XGI301LCDDelay; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4634 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4635 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4636 | tempbl = tempbh; |
| 4637 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4638 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4639 | tempbl &= 0x0F; |
| 4640 | tempbh &= 0xF0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4641 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4642 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4643 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
| 4644 | | SetCRT2ToTV)) { /* Channel B */ |
| 4645 | tempah &= 0xF0; |
| 4646 | tempah |= tempbl; |
| 4647 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4648 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 4649 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 4650 | /* Channel A */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4651 | tempah &= 0x0F; |
| 4652 | tempah |= tempbh; |
| 4653 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4654 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4655 | } |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4656 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4657 | } |
| 4658 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4659 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
| 4660 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4661 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4662 | unsigned short temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4663 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4664 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4665 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4666 | if (temp & LCDRGB18Bit) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4667 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4668 | /* Enable Dither */ |
| 4669 | (unsigned short) (0x20 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4670 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4671 | } else { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4672 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4673 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4674 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4675 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4676 | } |
| 4677 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4678 | /* --------------------------------------------------------------------- */ |
| 4679 | /* Function : XGI_SetLCDCap_B */ |
| 4680 | /* Input : cx -> LCD Capability */ |
| 4681 | /* Output : */ |
| 4682 | /* Description : */ |
| 4683 | /* --------------------------------------------------------------------- */ |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4684 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
| 4685 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4686 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4687 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4688 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4689 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 4690 | | 0x0c)); |
| 4691 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4692 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4693 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
| 4694 | | 0x18)); /* Enable Dither */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4695 | } |
| 4696 | |
Aaro Koskinen | 7f04ec3 | 2011-11-27 23:03:05 +0200 | [diff] [blame] | 4697 | static void XGI_LongWait(struct vb_device_info *pVBInfo) |
| 4698 | { |
| 4699 | unsigned short i; |
| 4700 | |
| 4701 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
| 4702 | |
| 4703 | if (!(i & 0xC0)) { |
| 4704 | for (i = 0; i < 0xFFFF; i++) { |
| 4705 | if (!(inb(pVBInfo->P3da) & 0x08)) |
| 4706 | break; |
| 4707 | } |
| 4708 | |
| 4709 | for (i = 0; i < 0xFFFF; i++) { |
| 4710 | if ((inb(pVBInfo->P3da) & 0x08)) |
| 4711 | break; |
| 4712 | } |
| 4713 | } |
| 4714 | } |
| 4715 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4716 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4717 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4718 | unsigned short index; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4719 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4720 | index = XGI_GetLCDCapPtr(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4721 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4722 | /* disable down spectrum D[4] */ |
| 4723 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4724 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4725 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4726 | XGI_LongWait(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4727 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4728 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4729 | pVBInfo->LCDCapList[index].Spectrum_31); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4730 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4731 | pVBInfo->LCDCapList[index].Spectrum_32); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4732 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4733 | pVBInfo->LCDCapList[index].Spectrum_33); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4734 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4735 | pVBInfo->LCDCapList[index].Spectrum_34); |
| 4736 | XGI_LongWait(pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 4737 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4738 | } |
| 4739 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4740 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
| 4741 | { |
| 4742 | unsigned short tempcx; |
| 4743 | |
| 4744 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
| 4745 | |
Peter Huewe | f951dd0 | 2013-02-05 00:29:47 +0100 | [diff] [blame] | 4746 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | |
| 4747 | VB_SIS302LV | VB_XGI301C)) { |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4748 | if (pVBInfo->VBType & |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4749 | (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4750 | /* Set 301LV Capability */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4751 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4752 | (unsigned char) (tempcx & 0x1F)); |
| 4753 | } |
| 4754 | /* VB Driving */ |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4755 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4756 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
| 4757 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW |
| 4758 | | EnablePLLSPLOW)) >> 8)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4759 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4760 | if (pVBInfo->VBInfo & SetCRT2ToLCD) |
| 4761 | XGI_SetLCDCap_B(tempcx, pVBInfo); |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4762 | else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4763 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 4764 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4765 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4766 | if (tempcx & EnableSpectrum) |
| 4767 | SetSpectrum(pVBInfo); |
| 4768 | } |
| 4769 | } else { |
| 4770 | /* LVDS,CH7017 */ |
| 4771 | XGI_SetLCDCap_A(tempcx, pVBInfo); |
| 4772 | } |
| 4773 | } |
| 4774 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4775 | /* --------------------------------------------------------------------- */ |
| 4776 | /* Function : XGI_SetAntiFlicker */ |
| 4777 | /* Input : */ |
| 4778 | /* Output : */ |
| 4779 | /* Description : Set TV Customized Param. */ |
| 4780 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4781 | static void XGI_SetAntiFlicker(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4782 | { |
Aaro Koskinen | 36ae035 | 2012-04-07 01:14:08 +0300 | [diff] [blame] | 4783 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4784 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4785 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4786 | |
Peter Huewe | 599801f | 2012-02-09 21:11:45 +0100 | [diff] [blame] | 4787 | if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4788 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4789 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4790 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 4791 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4792 | tempah = TVAntiFlickList[tempbx]; |
| 4793 | tempah = tempah << 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4794 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4795 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4796 | } |
| 4797 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4798 | static void XGI_SetEdgeEnhance(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4799 | { |
Aaro Koskinen | 354f49f | 2012-04-07 01:14:09 +0300 | [diff] [blame] | 4800 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4801 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4802 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4803 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4804 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
| 4805 | tempbx &= 0xFE; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4806 | tempah = TVEdgeList[tempbx]; |
| 4807 | tempah = tempah << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4808 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 4809 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4810 | } |
| 4811 | |
Aaro Koskinen | 063b9c4 | 2011-03-08 22:16:13 +0200 | [diff] [blame] | 4812 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4813 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4814 | unsigned short tempbx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4815 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4816 | unsigned char tempcl, tempch; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4817 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4818 | unsigned long tempData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4819 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4820 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
| 4821 | tempData = TVPhaseList[tempbx]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4822 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4823 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4824 | & 0x000000FF)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4825 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4826 | & 0x0000FF00) >> 8)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4827 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4828 | & 0x00FF0000) >> 16)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4829 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4830 | & 0xFF000000) >> 24)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4831 | } |
| 4832 | |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4833 | static void XGI_SetYFilter(unsigned short ModeIdIndex, |
| 4834 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4835 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4836 | unsigned short tempbx, index; |
Aaro Koskinen | a68292f | 2012-11-04 21:15:07 +0200 | [diff] [blame] | 4837 | unsigned char const *filterPtr; |
| 4838 | unsigned char tempcl, tempch, tempal; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4839 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4840 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4841 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4842 | switch (tempbx) { |
| 4843 | case 0x00: |
| 4844 | case 0x04: |
| 4845 | filterPtr = NTSCYFilter1; |
| 4846 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4847 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4848 | case 0x01: |
| 4849 | filterPtr = PALYFilter1; |
| 4850 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4851 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4852 | case 0x02: |
| 4853 | case 0x05: |
| 4854 | case 0x0D: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4855 | case 0x03: |
Aaro Koskinen | 2555e94 | 2011-08-31 21:46:06 +0300 | [diff] [blame] | 4856 | filterPtr = xgifb_palmn_yfilter1; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4857 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4858 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4859 | case 0x08: |
| 4860 | case 0x0C: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4861 | case 0x0A: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4862 | case 0x0B: |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4863 | case 0x09: |
Aaro Koskinen | 80f86f8 | 2011-08-31 21:46:05 +0300 | [diff] [blame] | 4864 | filterPtr = xgifb_yfilter2; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4865 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4866 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4867 | default: |
| 4868 | return; |
| 4869 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4870 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 4871 | tempal = XGI330_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4872 | if (tempcl == 0) |
| 4873 | index = tempal * 4; |
| 4874 | else |
| 4875 | index = tempal * 7; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4876 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4877 | if ((tempcl == 0) && (tempch == 1)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4878 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
| 4879 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); |
| 4880 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); |
| 4881 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4882 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4883 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
| 4884 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); |
| 4885 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); |
| 4886 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4887 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4888 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4889 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 4890 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4891 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
| 4892 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); |
| 4893 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4894 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4895 | } |
| 4896 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4897 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4898 | /* Function : XGI_OEM310Setting */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4899 | /* Input : */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4900 | /* Output : */ |
| 4901 | /* Description : Customized Param. for 301 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4902 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4903 | static void XGI_OEM310Setting(unsigned short ModeIdIndex, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 4904 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4905 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4906 | XGI_SetDelayComp(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4907 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 4908 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4909 | XGI_SetLCDCap(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4910 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4911 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 4912 | XGI_SetPhaseIncr(pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 4913 | XGI_SetYFilter(ModeIdIndex, pVBInfo); |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4914 | XGI_SetAntiFlicker(pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4915 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 4916 | if (pVBInfo->VBType & VB_SIS301) |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 4917 | XGI_SetEdgeEnhance(pVBInfo); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4918 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4919 | } |
| 4920 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4921 | /* --------------------------------------------------------------------- */ |
| 4922 | /* Function : XGI_SetCRT2ModeRegs */ |
| 4923 | /* Input : */ |
| 4924 | /* Output : */ |
| 4925 | /* Description : Origin code for crt2group */ |
| 4926 | /* --------------------------------------------------------------------- */ |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 4927 | static void XGI_SetCRT2ModeRegs(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4928 | { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4929 | unsigned short tempbl; |
| 4930 | short tempcl; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4931 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4932 | unsigned char tempah; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4933 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4934 | tempah = 0; |
| 4935 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 4936 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4937 | tempah &= ~0x10; /* BTRAMDAC */ |
| 4938 | tempah |= 0x40; /* BTRAM */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4939 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4940 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
| 4941 | | SetCRT2ToLCD)) { |
| 4942 | tempah = 0x40; /* BTDRAM */ |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 4943 | tempcl = pVBInfo->ModeType; |
| 4944 | tempcl -= ModeVGA; |
| 4945 | if (tempcl >= 0) { |
| 4946 | /* BT Color */ |
| 4947 | tempah = (0x008 >> tempcl); |
| 4948 | if (tempah == 0) |
| 4949 | tempah = 1; |
| 4950 | tempah |= 0x040; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4951 | } |
| 4952 | if (pVBInfo->VBInfo & SetInSlaveMode) |
| 4953 | tempah ^= 0x50; /* BTDAC */ |
| 4954 | } |
| 4955 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4956 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 4957 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4958 | tempah = 0x08; |
| 4959 | tempbl = 0xf0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4960 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4961 | if (pVBInfo->VBInfo & DisableCRT2Display) |
| 4962 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4963 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4964 | tempah = 0x00; |
| 4965 | tempbl = 0xff; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4966 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4967 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
| 4968 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) |
| 4969 | goto reg_and_or; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4970 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4971 | if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 4972 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { |
| 4973 | tempbl &= 0xf7; |
| 4974 | tempah |= 0x01; |
| 4975 | goto reg_and_or; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 4976 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 4977 | |
Miguel Gómez | e123e46 | 2012-07-06 12:40:52 +0200 | [diff] [blame] | 4978 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
| 4979 | tempbl &= 0xf7; |
| 4980 | tempah |= 0x01; |
| 4981 | } |
| 4982 | |
| 4983 | if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD))) |
| 4984 | goto reg_and_or; |
| 4985 | |
| 4986 | tempbl &= 0xf8; |
| 4987 | tempah = 0x01; |
| 4988 | |
| 4989 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
| 4990 | tempah |= 0x02; |
| 4991 | |
| 4992 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 4993 | tempah = tempah ^ 0x05; |
| 4994 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
| 4995 | tempah = tempah ^ 0x01; |
| 4996 | } |
| 4997 | |
| 4998 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 4999 | tempah |= 0x08; |
| 5000 | |
| 5001 | reg_and_or: |
| 5002 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
| 5003 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5004 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5005 | | XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5006 | tempah &= (~0x08); |
| 5007 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo |
| 5008 | & SetInSlaveMode))) { |
| 5009 | tempah |= 0x010; |
| 5010 | } |
| 5011 | tempah |= 0x080; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5012 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5013 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5014 | tempah |= 0x020; |
Aaro Koskinen | 34c13ee | 2012-04-07 01:14:01 +0300 | [diff] [blame] | 5015 | if (pVBInfo->VBInfo & DriverMode) |
| 5016 | tempah = tempah ^ 0x20; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5017 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5018 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5019 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5020 | tempah = 0; |
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->LCDInfo & SetLCDDualLink) |
| 5023 | tempah |= 0x40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5024 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5025 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5026 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
| 5027 | tempah |= 0x40; |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5028 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5029 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5030 | if ((pVBInfo->LCDResInfo == Panel_1280x1024) |
| 5031 | || (pVBInfo->LCDResInfo == Panel_1280x1024x75)) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5032 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5033 | |
Peter Huewe | 255aabd | 2012-02-09 21:11:44 +0100 | [diff] [blame] | 5034 | if (pVBInfo->LCDResInfo == Panel_1280x960) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5035 | tempah |= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5036 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5037 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5038 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5039 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5040 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5041 | | VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5042 | tempah = 0; |
| 5043 | tempbl = 0xfb; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5044 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5045 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
| 5046 | tempbl = 0xff; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5047 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5048 | tempah |= 0x04; /* shampoo 0129 */ |
| 5049 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5050 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5051 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5052 | tempah = 0x00; |
| 5053 | tempbl = 0xcf; |
| 5054 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5055 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5056 | tempah |= 0x30; |
| 5057 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5058 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5059 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5060 | tempah = 0; |
| 5061 | tempbl = 0x3f; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5062 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5063 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5064 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
| 5065 | tempah |= 0xc0; |
| 5066 | } |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5067 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5068 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5069 | |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5070 | tempah = 0; |
| 5071 | tempbl = 0x7f; |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5072 | if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5073 | tempbl = 0xff; |
| 5074 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) |
| 5075 | tempah |= 0x80; |
| 5076 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5077 | |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5078 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5079 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5080 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5081 | if (pVBInfo->LCDInfo & SetLCDDualLink) { |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 5082 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
| 5083 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5084 | } |
| 5085 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5086 | } |
| 5087 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5088 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5089 | void XGI_UnLockCRT2(struct vb_device_info *pVBInfo) |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5090 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5091 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5092 | } |
| 5093 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5094 | void XGI_LockCRT2(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5095 | { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5096 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5097 | } |
| 5098 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5099 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
| 5100 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5101 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5102 | { |
Peter Huewe | f2c2260 | 2013-02-03 22:54:30 +0100 | [diff] [blame] | 5103 | const u8 LCDARefreshIndex[] = { |
| 5104 | 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5105 | |
Peter Huewe | ef9a6b9 | 2013-02-03 04:08:43 +0100 | [diff] [blame] | 5106 | unsigned short RefreshRateTableIndex, i, index, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5107 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5108 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5109 | index = index >> pVBInfo->SelectCRT2Rate; |
| 5110 | index &= 0x0F; |
| 5111 | |
| 5112 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
| 5113 | index = 0; |
| 5114 | |
| 5115 | if (index > 0) |
| 5116 | index--; |
| 5117 | |
| 5118 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5119 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { |
Aaro Koskinen | b0b4a8a | 2013-05-29 23:59:04 +0300 | [diff] [blame] | 5120 | temp = LCDARefreshIndex[pVBInfo->LCDResInfo & 0x07]; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5121 | |
Aaro Koskinen | b0b4a8a | 2013-05-29 23:59:04 +0300 | [diff] [blame] | 5122 | if (index > temp) |
| 5123 | index = temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5124 | } |
| 5125 | } |
| 5126 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5127 | RefreshRateTableIndex = XGI330_EModeIDTable[ModeIdIndex].REFindex; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5128 | ModeNo = XGI330_RefIndex[RefreshRateTableIndex].ModeID; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5129 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5130 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 800) && |
| 5131 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 600)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5132 | index++; |
| 5133 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5134 | /* do the similar adjustment like XGISearchCRT1Rate() */ |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5135 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1024) && |
| 5136 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 768)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5137 | index++; |
| 5138 | } |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5139 | if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1280) && |
| 5140 | (XGI330_RefIndex[RefreshRateTableIndex].YRes == 1024)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5141 | index++; |
| 5142 | } |
| 5143 | } |
| 5144 | |
| 5145 | i = 0; |
| 5146 | do { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5147 | if (XGI330_RefIndex[RefreshRateTableIndex + i]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5148 | ModeID != ModeNo) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5149 | break; |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5150 | temp = XGI330_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag; |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5151 | temp &= ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5152 | if (temp < pVBInfo->ModeType) |
| 5153 | break; |
| 5154 | i++; |
| 5155 | index--; |
| 5156 | |
| 5157 | } while (index != 0xFFFF); |
| 5158 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { |
| 5159 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
Aaro Koskinen | a39325d | 2012-11-04 21:14:53 +0200 | [diff] [blame] | 5160 | temp = XGI330_RefIndex[RefreshRateTableIndex + i - 1]. |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5161 | Ext_InfoFlag; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5162 | if (temp & InterlaceMode) |
| 5163 | i++; |
| 5164 | } |
| 5165 | } |
| 5166 | i--; |
| 5167 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5168 | temp = XGI_AjustCRT2Rate(ModeIdIndex, RefreshRateTableIndex, |
| 5169 | &i, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5170 | } |
Aaro Koskinen | 9a0b295 | 2011-11-27 23:03:16 +0200 | [diff] [blame] | 5171 | return RefreshRateTableIndex + i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5172 | } |
| 5173 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5174 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
Prashant P. Shah | 21df8fc | 2010-09-03 22:12:12 +0530 | [diff] [blame] | 5175 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5176 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5177 | { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5178 | unsigned short RefreshRateTableIndex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5179 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5180 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5181 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5182 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5183 | XGI_GetLVDSResInfo(ModeIdIndex, pVBInfo); |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 5184 | XGI_GetLVDSData(ModeIdIndex, pVBInfo); |
| 5185 | XGI_ModCRT1Regs(ModeIdIndex, HwDeviceExtension, pVBInfo); |
| 5186 | XGI_SetLVDSRegs(ModeIdIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5187 | XGI_SetCRT2ECLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 5188 | } |
| 5189 | |
Aaro Koskinen | fac2cc9 | 2011-11-27 23:03:13 +0200 | [diff] [blame] | 5190 | static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5191 | struct xgi_hw_device_info *HwDeviceExtension, |
| 5192 | struct vb_device_info *pVBInfo) |
| 5193 | { |
Peter Huewe | a9e29e6 | 2013-02-03 04:08:44 +0100 | [diff] [blame] | 5194 | unsigned short ModeIdIndex, RefreshRateTableIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5195 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5196 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5197 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 5198 | pVBInfo->SelectCRT2Rate = 4; |
| 5199 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5200 | ModeIdIndex, pVBInfo); |
| 5201 | XGI_SaveCRT2Info(ModeNo, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5202 | XGI_GetCRT2ResInfo(ModeIdIndex, pVBInfo); |
| 5203 | XGI_GetCRT2Data(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5204 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
| 5205 | XGI_SetGroup1(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 88a3dfd | 2013-07-16 23:13:29 +0300 | [diff] [blame^] | 5206 | XGI_SetLockRegs(ModeNo, ModeIdIndex, pVBInfo); |
| 5207 | XGI_SetGroup2(ModeNo, ModeIdIndex, pVBInfo); |
| 5208 | XGI_SetLCDRegs(ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5209 | XGI_SetTap4Regs(pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5210 | XGI_SetGroup3(ModeIdIndex, pVBInfo); |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5211 | XGI_SetGroup4(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5212 | XGI_SetCRT2VCLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5213 | XGI_SetGroup5(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5214 | XGI_AutoThreshold(pVBInfo); |
| 5215 | return 1; |
| 5216 | } |
| 5217 | |
| 5218 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
| 5219 | { |
| 5220 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
| 5221 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, |
| 5222 | 0x05, 0x00 }; |
| 5223 | |
| 5224 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
| 5225 | |
| 5226 | unsigned char CR17, CR63, SR31; |
| 5227 | unsigned short temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5228 | |
| 5229 | int i; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5230 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5231 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5232 | /* to fix XG42 single LCD sense to CRT+LCD */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5233 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5234 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5235 | pVBInfo->P3d4, 0x53) | 0x02)); |
| 5236 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5237 | SR31 = xgifb_reg_get(pVBInfo->P3c4, 0x31); |
| 5238 | CR63 = xgifb_reg_get(pVBInfo->P3d4, 0x63); |
| 5239 | SR01 = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5240 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5241 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
| 5242 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5243 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5244 | CR17 = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5245 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5246 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5247 | SR1F = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5248 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5249 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5250 | SR07 = xgifb_reg_get(pVBInfo->P3c4, 0x07); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5251 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5252 | SR06 = xgifb_reg_get(pVBInfo->P3c4, 0x06); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5253 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5254 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5255 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5256 | |
| 5257 | for (i = 0; i < 8; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5258 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5259 | |
| 5260 | for (i = 8; i < 11; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5261 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5262 | CRTCData[i]); |
| 5263 | |
| 5264 | for (i = 11; i < 13; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5265 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5266 | CRTCData[i]); |
| 5267 | |
| 5268 | for (i = 13; i < 16; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5269 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5270 | CRTCData[i]); |
| 5271 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5272 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5273 | & 0xE0)); |
| 5274 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5275 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
| 5276 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
| 5277 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5278 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5279 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5280 | |
Peter Huewe | 771f3ee | 2013-02-15 20:37:13 +0100 | [diff] [blame] | 5281 | for (i = 0; i < 256 * 3; i++) { |
| 5282 | outb(0x0F, (pVBInfo->P3c8 + 1)); /* DAC_TEST_PARMS */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5283 | } |
| 5284 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5285 | mdelay(1); |
| 5286 | |
| 5287 | XGI_WaitDisply(pVBInfo); |
Aaro Koskinen | d8ad0a6 | 2011-03-13 12:26:18 +0200 | [diff] [blame] | 5288 | temp = inb(pVBInfo->P3c2); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5289 | |
| 5290 | if (temp & 0x10) |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5291 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5292 | else |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5293 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5294 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5295 | /* avoid display something, set BLACK DAC if not restore DAC */ |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5296 | outb(0x00, pVBInfo->P3c8); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5297 | |
Peter Huewe | 771f3ee | 2013-02-15 20:37:13 +0100 | [diff] [blame] | 5298 | for (i = 0; i < 256 * 3; i++) { |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 5299 | outb(0, (pVBInfo->P3c8 + 1)); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5300 | } |
| 5301 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5302 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
| 5303 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); |
| 5304 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5305 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5306 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get( |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5307 | pVBInfo->P3d4, 0x53) & 0xFD)); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5308 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5309 | } |
| 5310 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5311 | static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, |
| 5312 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5313 | struct vb_device_info *pVBInfo) |
| 5314 | { |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 5315 | unsigned short tempah; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5316 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5317 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5318 | | VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | a2526d1 | 2013-05-29 23:59:10 +0300 | [diff] [blame] | 5319 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
Aaro Koskinen | d172463 | 2013-05-29 23:59:09 +0300 | [diff] [blame] | 5320 | /* Power on */ |
| 5321 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5322 | |
Aaro Koskinen | b8e34b3 | 2013-05-29 23:59:08 +0300 | [diff] [blame] | 5323 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV | |
| 5324 | SetCRT2ToRAMDAC)) { |
Aaro Koskinen | c4f9c31 | 2013-05-29 23:59:07 +0300 | [diff] [blame] | 5325 | tempah = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
| 5326 | tempah &= 0xDF; |
| 5327 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
| 5328 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) |
| 5329 | tempah |= 0x20; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5330 | } |
Aaro Koskinen | c4f9c31 | 2013-05-29 23:59:07 +0300 | [diff] [blame] | 5331 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
| 5332 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
| 5333 | |
| 5334 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E); |
| 5335 | |
| 5336 | if (!(tempah & 0x80)) |
| 5337 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
| 5338 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5339 | } |
| 5340 | |
Aaro Koskinen | a2526d1 | 2013-05-29 23:59:10 +0300 | [diff] [blame] | 5341 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 5342 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5343 | 0x20); /* shampoo 0129 */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5344 | if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) { |
Aaro Koskinen | 056b540 | 2013-05-29 23:59:11 +0300 | [diff] [blame] | 5345 | if (pVBInfo->VBInfo & |
| 5346 | (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) |
| 5347 | /* LVDS PLL power on */ |
| 5348 | xgifb_reg_and(pVBInfo->Part4Port, 0x2A, |
| 5349 | 0x7F); |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5350 | /* LVDS Driver power on */ |
| 5351 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5352 | } |
| 5353 | } |
| 5354 | |
| 5355 | tempah = 0x00; |
| 5356 | |
| 5357 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
| 5358 | tempah = 0xc0; |
| 5359 | |
Miguel Gómez | b1bf998 | 2012-07-06 12:40:51 +0200 | [diff] [blame] | 5360 | if (!(pVBInfo->VBInfo & SetSimuScanMode) && |
| 5361 | (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && |
| 5362 | (pVBInfo->VBInfo & SetCRT2ToDualEdge)) { |
| 5363 | tempah = tempah & 0x40; |
| 5364 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) |
| 5365 | tempah = tempah ^ 0xC0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5366 | } |
| 5367 | } |
| 5368 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5369 | /* EnablePart4_1F */ |
| 5370 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5371 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5372 | XGI_DisableGatingCRT(pVBInfo); |
Aaro Koskinen | d172463 | 2013-05-29 23:59:09 +0300 | [diff] [blame] | 5373 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5374 | } /* 301 */ |
| 5375 | else { /* LVDS */ |
| 5376 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5377 | | XGI_SetCRT2ToLCDA)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5378 | /* enable CRT2 */ |
| 5379 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5380 | |
Peter Huewe | 9388ad9 | 2013-02-15 20:37:10 +0100 | [diff] [blame] | 5381 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5382 | if (!(tempah & 0x80)) |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5383 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5384 | |
Aaro Koskinen | dc50556 | 2011-03-13 12:26:26 +0200 | [diff] [blame] | 5385 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5386 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5387 | } /* End of VB */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5388 | } |
| 5389 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5390 | static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, |
| 5391 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5392 | unsigned short ModeNo, unsigned short ModeIdIndex, |
| 5393 | struct vb_device_info *pVBInfo) |
| 5394 | { |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5395 | unsigned short RefreshRateTableIndex, temp; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5396 | |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5397 | XGI_SetSeqRegs(pVBInfo); |
Aaro Koskinen | 3625c9a | 2012-11-04 21:14:51 +0200 | [diff] [blame] | 5398 | outb(XGI330_StandTable.MISC, pVBInfo->P3c2); |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5399 | XGI_SetCRTCRegs(pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5400 | XGI_SetATTRegs(ModeIdIndex, pVBInfo); |
Aaro Koskinen | a157961 | 2012-04-07 01:14:05 +0300 | [diff] [blame] | 5401 | XGI_SetGRCRegs(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5402 | XGI_ClearExt1Regs(pVBInfo); |
| 5403 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5404 | if (HwDeviceExtension->jChipType == XG27) { |
| 5405 | if (pVBInfo->IF_DEF_LVDS == 0) |
| 5406 | XGI_SetDefaultVCLK(pVBInfo); |
| 5407 | } |
| 5408 | |
| 5409 | temp = ~ProgrammingCRT2; |
| 5410 | pVBInfo->SetFlag &= temp; |
| 5411 | pVBInfo->SelectCRT2Rate = 0; |
| 5412 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5413 | if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
| 5414 | | VB_SIS302LV | VB_XGI301C)) { |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5415 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5416 | | SetInSlaveMode)) { |
| 5417 | pVBInfo->SetFlag |= ProgrammingCRT2; |
| 5418 | } |
| 5419 | } |
| 5420 | |
| 5421 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 5422 | ModeIdIndex, pVBInfo); |
| 5423 | if (RefreshRateTableIndex != 0xFFFF) { |
| 5424 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5425 | XGI_SetCRT1CRTC(ModeIdIndex, RefreshRateTableIndex, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5426 | pVBInfo, HwDeviceExtension); |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5427 | XGI_SetCRT1DE(ModeIdIndex, RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5428 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
| 5429 | HwDeviceExtension, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5430 | XGI_SetCRT1VCLK(ModeIdIndex, HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5431 | RefreshRateTableIndex, pVBInfo); |
| 5432 | } |
| 5433 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5434 | if (HwDeviceExtension->jChipType >= XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5435 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5436 | if (temp & 0xA0) { |
| 5437 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5438 | if (HwDeviceExtension->jChipType == XG27) |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5439 | XGI_SetXG27CRTC(RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5440 | else |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5441 | XGI_SetXG21CRTC(RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5442 | |
| 5443 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
| 5444 | RefreshRateTableIndex); |
| 5445 | |
Aaro Koskinen | 105d8d0 | 2011-08-31 21:46:00 +0300 | [diff] [blame] | 5446 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5447 | pVBInfo, RefreshRateTableIndex); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5448 | |
Aaro Koskinen | 64db29f | 2011-08-31 21:46:01 +0300 | [diff] [blame] | 5449 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5450 | xgifb_set_lvds(xgifb_info, |
| 5451 | HwDeviceExtension->jChipType, |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5452 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5453 | } |
| 5454 | } |
| 5455 | |
| 5456 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5457 | XGI_SetCRT1FIFO(HwDeviceExtension, pVBInfo); |
| 5458 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeIdIndex, |
| 5459 | RefreshRateTableIndex, pVBInfo); |
Aaro Koskinen | 6b6e6a3 | 2013-07-16 23:13:27 +0300 | [diff] [blame] | 5460 | XGI_LoadDAC(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5461 | } |
| 5462 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5463 | unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, |
| 5464 | struct xgi_hw_device_info *HwDeviceExtension, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5465 | unsigned short ModeNo) |
| 5466 | { |
| 5467 | unsigned short ModeIdIndex; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5468 | struct vb_device_info VBINF; |
| 5469 | struct vb_device_info *pVBInfo = &VBINF; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5470 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5471 | |
Aaro Koskinen | ee76875 | 2013-05-29 23:59:16 +0300 | [diff] [blame] | 5472 | if (HwDeviceExtension->jChipType >= XG20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5473 | pVBInfo->VBType = 0; /*set VBType default 0*/ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5474 | |
Aaro Koskinen | 56810a9 | 2013-01-21 02:57:47 +0200 | [diff] [blame] | 5475 | XGIRegInit(pVBInfo, xgifb_info->vga_base); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5476 | |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5477 | /* for x86 Linux, XG21 LVDS */ |
| 5478 | if (HwDeviceExtension->jChipType == XG21) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5479 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5480 | pVBInfo->IF_DEF_LVDS = 1; |
| 5481 | } |
| 5482 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 5483 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
| 5484 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5485 | pVBInfo->IF_DEF_LVDS = 1; |
| 5486 | } |
| 5487 | } |
| 5488 | |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5489 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
Aaro Koskinen | ef497f4 | 2011-11-27 23:03:21 +0200 | [diff] [blame] | 5490 | if (ModeNo & 0x80) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5491 | ModeNo = ModeNo & 0x7F; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 5492 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5493 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5494 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5495 | XGI_UnLockCRT2(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5496 | |
| 5497 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
| 5498 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 5499 | if (HwDeviceExtension->jChipType < XG20) { |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5500 | XGI_GetVBInfo(ModeIdIndex, pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5501 | XGI_GetTVInfo(ModeIdIndex, pVBInfo); |
| 5502 | XGI_GetLCDInfo(ModeIdIndex, pVBInfo); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5503 | XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5504 | |
Peter Huewe | e44adfd | 2013-02-03 22:54:39 +0100 | [diff] [blame] | 5505 | if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA) || |
| 5506 | (!(pVBInfo->VBInfo & SwitchCRT2))) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5507 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5508 | ModeIdIndex, pVBInfo); |
| 5509 | |
Peter Huewe | a3d675c | 2012-02-09 21:11:47 +0100 | [diff] [blame] | 5510 | if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5511 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, |
| 5512 | HwDeviceExtension, pVBInfo); |
| 5513 | } |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5514 | } |
| 5515 | |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5516 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) { |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5517 | switch (HwDeviceExtension->ujVBChipID) { |
Peter Huewe | e44adfd | 2013-02-03 22:54:39 +0100 | [diff] [blame] | 5518 | case VB_CHIP_301: /* fall through */ |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5519 | case VB_CHIP_302: |
| 5520 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, |
| 5521 | pVBInfo); /*add for CRT2 */ |
| 5522 | break; |
| 5523 | |
| 5524 | default: |
| 5525 | break; |
| 5526 | } |
| 5527 | } |
| 5528 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5529 | XGI_SetCRT2ModeRegs(pVBInfo); |
Aaro Koskinen | 3d05f66f | 2013-07-16 23:13:26 +0300 | [diff] [blame] | 5530 | XGI_OEM310Setting(ModeIdIndex, pVBInfo); /*0212*/ |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5531 | XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5532 | } /* !XG20 */ |
| 5533 | else { |
| 5534 | if (pVBInfo->IF_DEF_LVDS == 1) |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5535 | if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo, |
Kenji Toyama | 1d7f656 | 2011-04-23 19:36:49 +0800 | [diff] [blame] | 5536 | ModeIdIndex, |
| 5537 | pVBInfo)) |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5538 | return 0; |
| 5539 | |
Aaro Koskinen | b397992 | 2012-11-04 21:14:52 +0200 | [diff] [blame] | 5540 | pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex]. |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 5541 | Ext_ModeFlag & ModeTypeMask; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5542 | |
| 5543 | pVBInfo->SetFlag = 0; |
Aaro Koskinen | 83f76a9 | 2011-08-31 21:45:58 +0300 | [diff] [blame] | 5544 | pVBInfo->VBInfo = DisableCRT2Display; |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5545 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5546 | XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5547 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5548 | XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo, |
| 5549 | ModeIdIndex, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5550 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 5551 | XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5552 | } |
| 5553 | |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5554 | XGI_UpdateModeInfo(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5555 | |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 5556 | if (HwDeviceExtension->jChipType < XG20) |
Aaro Koskinen | b053af1 | 2013-07-16 23:13:28 +0300 | [diff] [blame] | 5557 | XGI_LockCRT2(pVBInfo); |
Aaro Koskinen | cc1e239 | 2011-03-13 12:26:07 +0200 | [diff] [blame] | 5558 | |
| 5559 | return 1; |
| 5560 | } |