apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * XG20, XG21, XG40, XG42 frame buffer device |
| 3 | * for Linux kernels 2.5.x, 2.6.x |
| 4 | * Base on TW's sis fbdev code. |
| 5 | */ |
| 6 | |
Sam Hansen | 96c6604 | 2012-01-22 00:48:25 -0800 | [diff] [blame] | 7 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 8 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 9 | #include <linux/module.h> |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 10 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 11 | #ifdef CONFIG_MTRR |
| 12 | #include <asm/mtrr.h> |
| 13 | #endif |
| 14 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 15 | #include "XGI_main.h" |
Aaro Koskinen | d542af5 | 2011-04-18 22:14:06 +0300 | [diff] [blame] | 16 | #include "vb_init.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 17 | #include "vb_util.h" |
Aaro Koskinen | d542af5 | 2011-04-18 22:14:06 +0300 | [diff] [blame] | 18 | #include "vb_setmode.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 19 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 20 | #define Index_CR_GPIO_Reg1 0x48 |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 21 | #define Index_CR_GPIO_Reg3 0x4a |
| 22 | |
| 23 | #define GPIOG_EN (1<<6) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 24 | #define GPIOG_READ (1<<1) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 25 | |
Aaro Koskinen | 2d2c880 | 2011-12-06 00:10:49 +0200 | [diff] [blame] | 26 | static char *forcecrt2type; |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 27 | static char *mode; |
Aaro Koskinen | c322830 | 2011-08-29 23:14:32 +0300 | [diff] [blame] | 28 | static int vesa = -1; |
Aaro Koskinen | 7548a83 | 2011-10-11 21:47:17 +0300 | [diff] [blame] | 29 | static unsigned int refresh_rate; |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 30 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 31 | /* -------------------- Macro definitions ---------------------------- */ |
| 32 | |
Miguel Gómez | 96cd1f8 | 2012-06-18 13:12:02 +0200 | [diff] [blame] | 33 | #ifdef DEBUG |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 34 | static void dumpVGAReg(void) |
| 35 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 36 | u8 i, reg; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 37 | |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 38 | xgifb_reg_set(XGISR, 0x05, 0x86); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 39 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 40 | for (i = 0; i < 0x4f; i++) { |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 41 | reg = xgifb_reg_get(XGISR, i); |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 42 | pr_debug("o 3c4 %x\n", i); |
| 43 | pr_debug("i 3c5 => %x\n", reg); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 44 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 45 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 46 | for (i = 0; i < 0xF0; i++) { |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 47 | reg = xgifb_reg_get(XGICR, i); |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 48 | pr_debug("o 3d4 %x\n", i); |
| 49 | pr_debug("i 3d5 => %x\n", reg); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 50 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 51 | } |
| 52 | #else |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 53 | static inline void dumpVGAReg(void) |
| 54 | { |
| 55 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 56 | #endif |
| 57 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 58 | /* --------------- Hardware Access Routines -------------------------- */ |
| 59 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 60 | static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr, |
| 61 | struct xgi_hw_device_info *HwDeviceExtension, |
| 62 | unsigned char modeno, unsigned char rateindex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 63 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 64 | unsigned short ModeNo = modeno; |
| 65 | unsigned short ModeIdIndex = 0, ClockIndex = 0; |
| 66 | unsigned short RefreshRateTableIndex = 0; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 67 | int Clock; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 68 | InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 69 | |
Aaro Koskinen | aca03bc | 2012-04-07 01:13:50 +0300 | [diff] [blame] | 70 | XGI_SearchModeID(ModeNo, &ModeIdIndex, XGI_Pr); |
| 71 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 72 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 73 | ModeIdIndex, XGI_Pr); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 74 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 75 | ClockIndex = XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 76 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 77 | Clock = XGI_Pr->VCLKData[ClockIndex].CLOCK * 1000; |
| 78 | |
| 79 | return Clock; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 80 | } |
| 81 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 82 | static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, |
| 83 | struct xgi_hw_device_info *HwDeviceExtension, |
| 84 | unsigned char modeno, unsigned char rateindex, |
| 85 | u32 *left_margin, u32 *right_margin, u32 *upper_margin, |
| 86 | u32 *lower_margin, u32 *hsync_len, u32 *vsync_len, u32 *sync, |
| 87 | u32 *vmode) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 88 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 89 | unsigned short ModeNo = modeno; |
Aaro Koskinen | 051ff1b | 2012-04-07 01:13:48 +0300 | [diff] [blame] | 90 | unsigned short ModeIdIndex, index = 0; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 91 | unsigned short RefreshRateTableIndex = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 92 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 93 | unsigned short VRE, VBE, VRS, VBS, VDE, VT; |
| 94 | unsigned short HRE, HBE, HRS, HBS, HDE, HT; |
| 95 | unsigned char sr_data, cr_data, cr_data2; |
| 96 | unsigned long cr_data3; |
| 97 | int A, B, C, D, E, F, temp, j; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 98 | InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr); |
Aaro Koskinen | 051ff1b | 2012-04-07 01:13:48 +0300 | [diff] [blame] | 99 | if (!XGI_SearchModeID(ModeNo, &ModeIdIndex, XGI_Pr)) |
| 100 | return 0; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 101 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
| 102 | ModeIdIndex, XGI_Pr); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 103 | index = XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 104 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 105 | sr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[5]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 106 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 107 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[0]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 108 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 109 | /* Horizontal total */ |
| 110 | HT = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8); |
| 111 | A = HT + 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 112 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 113 | HDE = (XGI_Pr->RefIndex[RefreshRateTableIndex].XRes >> 3) - 1; |
| 114 | E = HDE + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 115 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 116 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[3]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 117 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 118 | /* Horizontal retrace (=sync) start */ |
| 119 | HRS = (cr_data & 0xff) | ((unsigned short) (sr_data & 0xC0) << 2); |
| 120 | F = HRS - E - 3; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 121 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 122 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[1]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 123 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 124 | /* Horizontal blank start */ |
| 125 | HBS = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x30) << 4); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 126 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 127 | sr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[6]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 128 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 129 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[2]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 130 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 131 | cr_data2 = XGI_Pr->XGINEWUB_CRT1Table[index].CR[4]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 132 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 133 | /* Horizontal blank end */ |
| 134 | HBE = (cr_data & 0x1f) | ((unsigned short) (cr_data2 & 0x80) >> 2) |
| 135 | | ((unsigned short) (sr_data & 0x03) << 6); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 136 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 137 | /* Horizontal retrace (=sync) end */ |
| 138 | HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 139 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 140 | temp = HBE - ((E - 1) & 255); |
| 141 | B = (temp > 0) ? temp : (temp + 256); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 142 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 143 | temp = HRE - ((E + F + 3) & 63); |
| 144 | C = (temp > 0) ? temp : (temp + 64); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 145 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 146 | D = B - F - C; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 147 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 148 | *left_margin = D * 8; |
| 149 | *right_margin = F * 8; |
| 150 | *hsync_len = C * 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 151 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 152 | sr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[14]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 153 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 154 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[8]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 155 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 156 | cr_data2 = XGI_Pr->XGINEWUB_CRT1Table[index].CR[9]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 157 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 158 | /* Vertical total */ |
| 159 | VT = (cr_data & 0xFF) | ((unsigned short) (cr_data2 & 0x01) << 8) |
| 160 | | ((unsigned short) (cr_data2 & 0x20) << 4) |
| 161 | | ((unsigned short) (sr_data & 0x01) << 10); |
| 162 | A = VT + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 163 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 164 | VDE = XGI_Pr->RefIndex[RefreshRateTableIndex].YRes - 1; |
| 165 | E = VDE + 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 166 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 167 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[10]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 168 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 169 | /* Vertical retrace (=sync) start */ |
| 170 | VRS = (cr_data & 0xff) | ((unsigned short) (cr_data2 & 0x04) << 6) |
| 171 | | ((unsigned short) (cr_data2 & 0x80) << 2) |
| 172 | | ((unsigned short) (sr_data & 0x08) << 7); |
| 173 | F = VRS + 1 - E; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 174 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 175 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[12]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 176 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 177 | cr_data3 = (XGI_Pr->XGINEWUB_CRT1Table[index].CR[14] & 0x80) << 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 178 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 179 | /* Vertical blank start */ |
| 180 | VBS = (cr_data & 0xff) | ((unsigned short) (cr_data2 & 0x08) << 5) |
| 181 | | ((unsigned short) (cr_data3 & 0x20) << 4) |
| 182 | | ((unsigned short) (sr_data & 0x04) << 8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 183 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 184 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[13]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 185 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 186 | /* Vertical blank end */ |
| 187 | VBE = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x10) << 4); |
| 188 | temp = VBE - ((E - 1) & 511); |
| 189 | B = (temp > 0) ? temp : (temp + 512); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 190 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 191 | cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[11]; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 192 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 193 | /* Vertical retrace (=sync) end */ |
| 194 | VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1); |
| 195 | temp = VRE - ((E + F - 1) & 31); |
| 196 | C = (temp > 0) ? temp : (temp + 32); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 197 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 198 | D = B - F - C; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 199 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 200 | *upper_margin = D; |
| 201 | *lower_margin = F; |
| 202 | *vsync_len = C; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 203 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 204 | if (XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x8000) |
| 205 | *sync &= ~FB_SYNC_VERT_HIGH_ACT; |
| 206 | else |
| 207 | *sync |= FB_SYNC_VERT_HIGH_ACT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 208 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 209 | if (XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x4000) |
| 210 | *sync &= ~FB_SYNC_HOR_HIGH_ACT; |
| 211 | else |
| 212 | *sync |= FB_SYNC_HOR_HIGH_ACT; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 213 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 214 | *vmode = FB_VMODE_NONINTERLACED; |
| 215 | if (XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x0080) |
| 216 | *vmode = FB_VMODE_INTERLACED; |
| 217 | else { |
| 218 | j = 0; |
| 219 | while (XGI_Pr->EModeIDTable[j].Ext_ModeID != 0xff) { |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 220 | if (XGI_Pr->EModeIDTable[j].Ext_ModeID == |
| 221 | XGI_Pr->RefIndex[RefreshRateTableIndex].ModeID) { |
| 222 | if (XGI_Pr->EModeIDTable[j].Ext_ModeFlag & |
| 223 | DoubleScanMode) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 224 | *vmode = FB_VMODE_DOUBLE; |
| 225 | } |
| 226 | break; |
| 227 | } |
| 228 | j++; |
| 229 | } |
| 230 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 231 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 232 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 233 | } |
| 234 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 235 | static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 236 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 237 | XGI_Pr->P3c4 = BaseAddr + 0x14; |
| 238 | XGI_Pr->P3d4 = BaseAddr + 0x24; |
| 239 | XGI_Pr->P3c0 = BaseAddr + 0x10; |
| 240 | XGI_Pr->P3ce = BaseAddr + 0x1e; |
| 241 | XGI_Pr->P3c2 = BaseAddr + 0x12; |
| 242 | XGI_Pr->P3ca = BaseAddr + 0x1a; |
| 243 | XGI_Pr->P3c6 = BaseAddr + 0x16; |
| 244 | XGI_Pr->P3c7 = BaseAddr + 0x17; |
| 245 | XGI_Pr->P3c8 = BaseAddr + 0x18; |
| 246 | XGI_Pr->P3c9 = BaseAddr + 0x19; |
| 247 | XGI_Pr->P3da = BaseAddr + 0x2A; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 248 | /* Digital video interface registers (LCD) */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 249 | XGI_Pr->Part1Port = BaseAddr + SIS_CRT2_PORT_04; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 250 | /* 301 TV Encoder registers */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 251 | XGI_Pr->Part2Port = BaseAddr + SIS_CRT2_PORT_10; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 252 | /* 301 Macrovision registers */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 253 | XGI_Pr->Part3Port = BaseAddr + SIS_CRT2_PORT_12; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 254 | /* 301 VGA2 (and LCD) registers */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 255 | XGI_Pr->Part4Port = BaseAddr + SIS_CRT2_PORT_14; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 256 | /* 301 palette address port registers */ |
Peter Huewe | 6896b94 | 2012-02-09 21:11:46 +0100 | [diff] [blame] | 257 | XGI_Pr->Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 258 | |
| 259 | } |
| 260 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 261 | /* ------------------ Internal helper routines ----------------- */ |
| 262 | |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 263 | static int XGIfb_GetXG21DefaultLVDSModeIdx(struct xgifb_video_info *xgifb_info) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 264 | { |
Miguel Gómez | 791fef1 | 2012-07-06 12:40:42 +0200 | [diff] [blame] | 265 | int i = 0; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 266 | |
Miguel Gómez | 791fef1 | 2012-07-06 12:40:42 +0200 | [diff] [blame] | 267 | while ((XGIbios_mode[i].mode_no != 0) |
| 268 | && (XGIbios_mode[i].xres <= xgifb_info->lvds_data.LVDSHDE)) { |
| 269 | if ((XGIbios_mode[i].xres == xgifb_info->lvds_data.LVDSHDE) |
| 270 | && (XGIbios_mode[i].yres == xgifb_info->lvds_data.LVDSVDE) |
| 271 | && (XGIbios_mode[i].bpp == 8)) { |
| 272 | return i; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 273 | } |
Miguel Gómez | 791fef1 | 2012-07-06 12:40:42 +0200 | [diff] [blame] | 274 | i++; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 275 | } |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 276 | |
Miguel Gómez | 791fef1 | 2012-07-06 12:40:42 +0200 | [diff] [blame] | 277 | return -1; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 278 | } |
| 279 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 280 | static void XGIfb_search_mode(struct xgifb_video_info *xgifb_info, |
| 281 | const char *name) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 282 | { |
Aaro Koskinen | f9e5de0 | 2012-04-07 01:13:55 +0300 | [diff] [blame] | 283 | unsigned int xres; |
| 284 | unsigned int yres; |
| 285 | unsigned int bpp; |
| 286 | int i; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 287 | |
Aaro Koskinen | f9e5de0 | 2012-04-07 01:13:55 +0300 | [diff] [blame] | 288 | if (sscanf(name, "%ux%ux%u", &xres, &yres, &bpp) != 3) |
| 289 | goto invalid_mode; |
| 290 | |
| 291 | if (bpp == 24) |
| 292 | bpp = 32; /* That's for people who mix up color and fb depth. */ |
| 293 | |
| 294 | for (i = 0; XGIbios_mode[i].mode_no != 0; i++) |
| 295 | if (XGIbios_mode[i].xres == xres && |
| 296 | XGIbios_mode[i].yres == yres && |
| 297 | XGIbios_mode[i].bpp == bpp) { |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 298 | xgifb_info->mode_idx = i; |
Aaro Koskinen | f9e5de0 | 2012-04-07 01:13:55 +0300 | [diff] [blame] | 299 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 300 | } |
Aaro Koskinen | f9e5de0 | 2012-04-07 01:13:55 +0300 | [diff] [blame] | 301 | invalid_mode: |
| 302 | pr_info("Invalid mode '%s'\n", name); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 303 | } |
| 304 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 305 | static void XGIfb_search_vesamode(struct xgifb_video_info *xgifb_info, |
| 306 | unsigned int vesamode) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 307 | { |
Miguel Gómez | 4362f5b | 2012-07-06 12:40:43 +0200 | [diff] [blame] | 308 | int i = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 309 | |
Aaro Koskinen | c322830 | 2011-08-29 23:14:32 +0300 | [diff] [blame] | 310 | if (vesamode == 0) |
| 311 | goto invalid; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 312 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 313 | vesamode &= 0x1dff; /* Clean VESA mode number from other flags */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 314 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 315 | while (XGIbios_mode[i].mode_no != 0) { |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 316 | if ((XGIbios_mode[i].vesa_mode_no_1 == vesamode) || |
| 317 | (XGIbios_mode[i].vesa_mode_no_2 == vesamode)) { |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 318 | xgifb_info->mode_idx = i; |
Miguel Gómez | 4362f5b | 2012-07-06 12:40:43 +0200 | [diff] [blame] | 319 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 320 | } |
| 321 | i++; |
| 322 | } |
Aaro Koskinen | c322830 | 2011-08-29 23:14:32 +0300 | [diff] [blame] | 323 | |
| 324 | invalid: |
Miguel Gómez | 4362f5b | 2012-07-06 12:40:43 +0200 | [diff] [blame] | 325 | pr_info("Invalid VESA mode 0x%x'\n", vesamode); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 326 | } |
| 327 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 328 | static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 329 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 330 | u16 xres, yres; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 331 | struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; |
Aaro Koskinen | a09f347 | 2012-09-12 00:44:37 +0300 | [diff] [blame] | 332 | unsigned long required_mem; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 333 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 334 | if (xgifb_info->chip == XG21) { |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 335 | if (xgifb_info->display2 == XGIFB_DISP_LCD) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 336 | xres = xgifb_info->lvds_data.LVDSHDE; |
| 337 | yres = xgifb_info->lvds_data.LVDSVDE; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 338 | if (XGIbios_mode[myindex].xres > xres) |
| 339 | return -1; |
| 340 | if (XGIbios_mode[myindex].yres > yres) |
| 341 | return -1; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 342 | if ((XGIbios_mode[myindex].xres < xres) && |
| 343 | (XGIbios_mode[myindex].yres < yres)) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 344 | if (XGIbios_mode[myindex].bpp > 8) |
| 345 | return -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 346 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 347 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 348 | } |
Aaro Koskinen | a09f347 | 2012-09-12 00:44:37 +0300 | [diff] [blame] | 349 | goto check_memory; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 350 | |
| 351 | } |
| 352 | |
| 353 | /* FIXME: for now, all is valid on XG27 */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 354 | if (xgifb_info->chip == XG27) |
Aaro Koskinen | a09f347 | 2012-09-12 00:44:37 +0300 | [diff] [blame] | 355 | goto check_memory; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 356 | |
| 357 | if (!(XGIbios_mode[myindex].chipset & MD_XGI315)) |
| 358 | return -1; |
| 359 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 360 | switch (xgifb_info->display2) { |
| 361 | case XGIFB_DISP_LCD: |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 362 | switch (hw_info->ulCRT2LCDType) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 363 | case LCD_640x480: |
| 364 | xres = 640; |
| 365 | yres = 480; |
| 366 | break; |
| 367 | case LCD_800x600: |
| 368 | xres = 800; |
| 369 | yres = 600; |
| 370 | break; |
| 371 | case LCD_1024x600: |
| 372 | xres = 1024; |
| 373 | yres = 600; |
| 374 | break; |
| 375 | case LCD_1024x768: |
| 376 | xres = 1024; |
| 377 | yres = 768; |
| 378 | break; |
| 379 | case LCD_1152x768: |
| 380 | xres = 1152; |
| 381 | yres = 768; |
| 382 | break; |
| 383 | case LCD_1280x960: |
| 384 | xres = 1280; |
| 385 | yres = 960; |
| 386 | break; |
| 387 | case LCD_1280x768: |
| 388 | xres = 1280; |
| 389 | yres = 768; |
| 390 | break; |
| 391 | case LCD_1280x1024: |
| 392 | xres = 1280; |
| 393 | yres = 1024; |
| 394 | break; |
| 395 | case LCD_1400x1050: |
| 396 | xres = 1400; |
| 397 | yres = 1050; |
| 398 | break; |
| 399 | case LCD_1600x1200: |
| 400 | xres = 1600; |
| 401 | yres = 1200; |
| 402 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 403 | default: |
| 404 | xres = 0; |
| 405 | yres = 0; |
| 406 | break; |
| 407 | } |
| 408 | if (XGIbios_mode[myindex].xres > xres) |
| 409 | return -1; |
| 410 | if (XGIbios_mode[myindex].yres > yres) |
| 411 | return -1; |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 412 | if ((hw_info->ulExternalChip == 0x01) || /* LVDS */ |
| 413 | (hw_info->ulExternalChip == 0x05)) { /* LVDS+Chrontel */ |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 414 | switch (XGIbios_mode[myindex].xres) { |
| 415 | case 512: |
| 416 | if (XGIbios_mode[myindex].yres != 512) |
| 417 | return -1; |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 418 | if (hw_info->ulCRT2LCDType == LCD_1024x600) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 419 | return -1; |
| 420 | break; |
| 421 | case 640: |
| 422 | if ((XGIbios_mode[myindex].yres != 400) |
| 423 | && (XGIbios_mode[myindex].yres |
| 424 | != 480)) |
| 425 | return -1; |
| 426 | break; |
| 427 | case 800: |
| 428 | if (XGIbios_mode[myindex].yres != 600) |
| 429 | return -1; |
| 430 | break; |
| 431 | case 1024: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 432 | if ((XGIbios_mode[myindex].yres != 600) && |
| 433 | (XGIbios_mode[myindex].yres != 768)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 434 | return -1; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 435 | if ((XGIbios_mode[myindex].yres == 600) && |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 436 | (hw_info->ulCRT2LCDType != LCD_1024x600)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 437 | return -1; |
| 438 | break; |
| 439 | case 1152: |
| 440 | if ((XGIbios_mode[myindex].yres) != 768) |
| 441 | return -1; |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 442 | if (hw_info->ulCRT2LCDType != LCD_1152x768) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 443 | return -1; |
| 444 | break; |
| 445 | case 1280: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 446 | if ((XGIbios_mode[myindex].yres != 768) && |
| 447 | (XGIbios_mode[myindex].yres != 1024)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 448 | return -1; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 449 | if ((XGIbios_mode[myindex].yres == 768) && |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 450 | (hw_info->ulCRT2LCDType != LCD_1280x768)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 451 | return -1; |
| 452 | break; |
| 453 | case 1400: |
| 454 | if (XGIbios_mode[myindex].yres != 1050) |
| 455 | return -1; |
| 456 | break; |
| 457 | case 1600: |
| 458 | if (XGIbios_mode[myindex].yres != 1200) |
| 459 | return -1; |
| 460 | break; |
| 461 | default: |
| 462 | return -1; |
| 463 | } |
| 464 | } else { |
| 465 | switch (XGIbios_mode[myindex].xres) { |
| 466 | case 512: |
| 467 | if (XGIbios_mode[myindex].yres != 512) |
| 468 | return -1; |
| 469 | break; |
| 470 | case 640: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 471 | if ((XGIbios_mode[myindex].yres != 400) && |
| 472 | (XGIbios_mode[myindex].yres != 480)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 473 | return -1; |
| 474 | break; |
| 475 | case 800: |
| 476 | if (XGIbios_mode[myindex].yres != 600) |
| 477 | return -1; |
| 478 | break; |
| 479 | case 1024: |
| 480 | if (XGIbios_mode[myindex].yres != 768) |
| 481 | return -1; |
| 482 | break; |
| 483 | case 1280: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 484 | if ((XGIbios_mode[myindex].yres != 960) && |
| 485 | (XGIbios_mode[myindex].yres != 1024)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 486 | return -1; |
| 487 | if (XGIbios_mode[myindex].yres == 960) { |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 488 | if (hw_info->ulCRT2LCDType == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 489 | LCD_1400x1050) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 490 | return -1; |
| 491 | } |
| 492 | break; |
| 493 | case 1400: |
| 494 | if (XGIbios_mode[myindex].yres != 1050) |
| 495 | return -1; |
| 496 | break; |
| 497 | case 1600: |
| 498 | if (XGIbios_mode[myindex].yres != 1200) |
| 499 | return -1; |
| 500 | break; |
| 501 | default: |
| 502 | return -1; |
| 503 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 504 | } |
| 505 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 506 | case XGIFB_DISP_TV: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 507 | switch (XGIbios_mode[myindex].xres) { |
| 508 | case 512: |
| 509 | case 640: |
| 510 | case 800: |
| 511 | break; |
| 512 | case 720: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 513 | if (xgifb_info->TV_type == TVMODE_NTSC) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 514 | if (XGIbios_mode[myindex].yres != 480) |
| 515 | return -1; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 516 | } else if (xgifb_info->TV_type == TVMODE_PAL) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 517 | if (XGIbios_mode[myindex].yres != 576) |
| 518 | return -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 519 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 520 | /* LVDS/CHRONTEL does not support 720 */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 521 | if (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL || |
| 522 | xgifb_info->hasVB == HASVB_CHRONTEL) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 523 | return -1; |
| 524 | } |
| 525 | break; |
| 526 | case 1024: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 527 | if (xgifb_info->TV_type == TVMODE_NTSC) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 528 | if (XGIbios_mode[myindex].bpp == 32) |
| 529 | return -1; |
| 530 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 531 | break; |
| 532 | default: |
| 533 | return -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 534 | } |
| 535 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 536 | case XGIFB_DISP_CRT: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 537 | if (XGIbios_mode[myindex].xres > 1280) |
| 538 | return -1; |
| 539 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 540 | case XGIFB_DISP_NONE: |
| 541 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 542 | } |
Aaro Koskinen | a09f347 | 2012-09-12 00:44:37 +0300 | [diff] [blame] | 543 | |
| 544 | check_memory: |
| 545 | required_mem = XGIbios_mode[myindex].xres * XGIbios_mode[myindex].yres * |
| 546 | XGIbios_mode[myindex].bpp / 8; |
| 547 | if (required_mem > xgifb_info->video_size) |
| 548 | return -1; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 549 | return myindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 550 | |
| 551 | } |
| 552 | |
| 553 | static void XGIfb_search_crt2type(const char *name) |
| 554 | { |
| 555 | int i = 0; |
| 556 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 557 | if (name == NULL) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 558 | return; |
| 559 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 560 | while (XGI_crt2type[i].type_no != -1) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 561 | if (!strcmp(name, XGI_crt2type[i].name)) { |
| 562 | XGIfb_crt2type = XGI_crt2type[i].type_no; |
| 563 | XGIfb_tvplug = XGI_crt2type[i].tvplug_no; |
| 564 | break; |
| 565 | } |
| 566 | i++; |
| 567 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 568 | if (XGIfb_crt2type < 0) |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 569 | pr_info("Invalid CRT2 type: %s\n", name); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 570 | } |
| 571 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 572 | static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, |
| 573 | unsigned int rate) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 574 | { |
| 575 | u16 xres, yres; |
| 576 | int i = 0; |
| 577 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 578 | xres = XGIbios_mode[xgifb_info->mode_idx].xres; |
| 579 | yres = XGIbios_mode[xgifb_info->mode_idx].yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 580 | |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 581 | xgifb_info->rate_idx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 582 | while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) { |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 583 | if ((XGIfb_vrate[i].xres == xres) && |
| 584 | (XGIfb_vrate[i].yres == yres)) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 585 | if (XGIfb_vrate[i].refresh == rate) { |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 586 | xgifb_info->rate_idx = XGIfb_vrate[i].idx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 587 | break; |
| 588 | } else if (XGIfb_vrate[i].refresh > rate) { |
| 589 | if ((XGIfb_vrate[i].refresh - rate) <= 3) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 590 | pr_debug("Adjusting rate from %d up to %d\n", |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 591 | rate, XGIfb_vrate[i].refresh); |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 592 | xgifb_info->rate_idx = |
| 593 | XGIfb_vrate[i].idx; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 594 | xgifb_info->refresh_rate = |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 595 | XGIfb_vrate[i].refresh; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 596 | } else if (((rate - XGIfb_vrate[i - 1].refresh) |
| 597 | <= 2) && (XGIfb_vrate[i].idx |
| 598 | != 1)) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 599 | pr_debug("Adjusting rate from %d down to %d\n", |
Miguel Gómez | 3bcc246 | 2012-07-06 12:40:53 +0200 | [diff] [blame] | 600 | rate, |
| 601 | XGIfb_vrate[i-1].refresh); |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 602 | xgifb_info->rate_idx = |
| 603 | XGIfb_vrate[i - 1].idx; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 604 | xgifb_info->refresh_rate = |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 605 | XGIfb_vrate[i - 1].refresh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 606 | } |
| 607 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 608 | } else if ((rate - XGIfb_vrate[i].refresh) <= 2) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 609 | pr_debug("Adjusting rate from %d down to %d\n", |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 610 | rate, XGIfb_vrate[i].refresh); |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 611 | xgifb_info->rate_idx = XGIfb_vrate[i].idx; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 612 | break; |
| 613 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 614 | } |
| 615 | i++; |
| 616 | } |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 617 | if (xgifb_info->rate_idx > 0) { |
| 618 | return xgifb_info->rate_idx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 619 | } else { |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 620 | pr_info("Unsupported rate %d for %dx%d\n", |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 621 | rate, xres, yres); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 622 | return 0; |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | static void XGIfb_search_tvstd(const char *name) |
| 627 | { |
| 628 | int i = 0; |
| 629 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 630 | if (name == NULL) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 631 | return; |
| 632 | |
| 633 | while (XGI_tvtype[i].type_no != -1) { |
| 634 | if (!strcmp(name, XGI_tvtype[i].name)) { |
| 635 | XGIfb_tvmode = XGI_tvtype[i].type_no; |
| 636 | break; |
| 637 | } |
| 638 | i++; |
| 639 | } |
| 640 | } |
| 641 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 642 | /* ----------- FBDev related routines for all series ----------- */ |
| 643 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 644 | static void XGIfb_bpp_to_var(struct xgifb_video_info *xgifb_info, |
| 645 | struct fb_var_screeninfo *var) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 646 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 647 | switch (var->bits_per_pixel) { |
| 648 | case 8: |
| 649 | var->red.offset = var->green.offset = var->blue.offset = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 650 | var->red.length = var->green.length = var->blue.length = 6; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 651 | xgifb_info->video_cmap_len = 256; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 652 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 653 | case 16: |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 654 | var->red.offset = 11; |
| 655 | var->red.length = 5; |
| 656 | var->green.offset = 5; |
| 657 | var->green.length = 6; |
| 658 | var->blue.offset = 0; |
| 659 | var->blue.length = 5; |
| 660 | var->transp.offset = 0; |
| 661 | var->transp.length = 0; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 662 | xgifb_info->video_cmap_len = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 663 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 664 | case 32: |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 665 | var->red.offset = 16; |
| 666 | var->red.length = 8; |
| 667 | var->green.offset = 8; |
| 668 | var->green.length = 8; |
| 669 | var->blue.offset = 0; |
| 670 | var->blue.length = 8; |
| 671 | var->transp.offset = 24; |
| 672 | var->transp.length = 8; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 673 | xgifb_info->video_cmap_len = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 674 | break; |
| 675 | } |
| 676 | } |
| 677 | |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 678 | /* --------------------- SetMode routines ------------------------- */ |
| 679 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 680 | static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 681 | { |
| 682 | u8 cr30 = 0, cr31 = 0; |
| 683 | |
| 684 | cr31 = xgifb_reg_get(XGICR, 0x31); |
| 685 | cr31 &= ~0x60; |
| 686 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 687 | switch (xgifb_info->display2) { |
| 688 | case XGIFB_DISP_CRT: |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 689 | cr30 = (SIS_VB_OUTPUT_CRT2 | SIS_SIMULTANEOUS_VIEW_ENABLE); |
| 690 | cr31 |= SIS_DRIVER_MODE; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 691 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 692 | case XGIFB_DISP_LCD: |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 693 | cr30 = (SIS_VB_OUTPUT_LCD | SIS_SIMULTANEOUS_VIEW_ENABLE); |
| 694 | cr31 |= SIS_DRIVER_MODE; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 695 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 696 | case XGIFB_DISP_TV: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 697 | if (xgifb_info->TV_type == TVMODE_HIVISION) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 698 | cr30 = (SIS_VB_OUTPUT_HIVISION |
| 699 | | SIS_SIMULTANEOUS_VIEW_ENABLE); |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 700 | else if (xgifb_info->TV_plug == TVPLUG_SVIDEO) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 701 | cr30 = (SIS_VB_OUTPUT_SVIDEO |
| 702 | | SIS_SIMULTANEOUS_VIEW_ENABLE); |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 703 | else if (xgifb_info->TV_plug == TVPLUG_COMPOSITE) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 704 | cr30 = (SIS_VB_OUTPUT_COMPOSITE |
| 705 | | SIS_SIMULTANEOUS_VIEW_ENABLE); |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 706 | else if (xgifb_info->TV_plug == TVPLUG_SCART) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 707 | cr30 = (SIS_VB_OUTPUT_SCART |
| 708 | | SIS_SIMULTANEOUS_VIEW_ENABLE); |
| 709 | cr31 |= SIS_DRIVER_MODE; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 710 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 711 | if (XGIfb_tvmode == 1 || xgifb_info->TV_type == TVMODE_PAL) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 712 | cr31 |= 0x01; |
| 713 | else |
| 714 | cr31 &= ~0x01; |
| 715 | break; |
| 716 | default: /* disable CRT2 */ |
| 717 | cr30 = 0x00; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 718 | cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30); |
| 722 | xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31); |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 723 | xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33, |
| 724 | (xgifb_info->rate_idx & 0x0F)); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 725 | } |
| 726 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 727 | static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 728 | { |
| 729 | u8 reg; |
| 730 | unsigned char doit = 1; |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 731 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 732 | if (xgifb_info->video_bpp == 8) { |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 733 | /* |
| 734 | * We can't switch off CRT1 on LVDS/Chrontel |
| 735 | * in 8bpp Modes |
| 736 | */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 737 | if ((xgifb_info->hasVB == HASVB_LVDS) || |
| 738 | (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL)) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 739 | doit = 0; |
| 740 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 741 | /* |
| 742 | * We can't switch off CRT1 on 301B-DH |
| 743 | * in 8bpp Modes if using LCD |
| 744 | */ |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 745 | if (xgifb_info->display2 == XGIFB_DISP_LCD) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 746 | doit = 0; |
| 747 | } |
| 748 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 749 | /* We can't switch off CRT1 if bridge is in slave mode */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 750 | if (xgifb_info->hasVB != HASVB_NONE) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 751 | reg = xgifb_reg_get(XGIPART1, 0x00); |
| 752 | |
| 753 | if ((reg & 0x50) == 0x10) |
| 754 | doit = 0; |
| 755 | |
| 756 | } else { |
| 757 | XGIfb_crt1off = 0; |
| 758 | } |
| 759 | |
| 760 | reg = xgifb_reg_get(XGICR, 0x17); |
| 761 | if ((XGIfb_crt1off) && (doit)) |
| 762 | reg &= ~0x80; |
| 763 | else |
| 764 | reg |= 0x80; |
| 765 | xgifb_reg_set(XGICR, 0x17, reg); |
| 766 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 767 | xgifb_reg_and(XGISR, IND_SIS_RAMDAC_CONTROL, ~0x04); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 768 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 769 | if (xgifb_info->display2 == XGIFB_DISP_TV && |
| 770 | xgifb_info->hasVB == HASVB_301) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 771 | |
| 772 | reg = xgifb_reg_get(XGIPART4, 0x01); |
| 773 | |
| 774 | if (reg < 0xB0) { /* Set filter for XGI301 */ |
Aaro Koskinen | 84a6c46 | 2011-10-11 21:47:28 +0300 | [diff] [blame] | 775 | int filter_tb; |
| 776 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 777 | switch (xgifb_info->video_width) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 778 | case 320: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 779 | filter_tb = (xgifb_info->TV_type == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 780 | TVMODE_NTSC) ? 4 : 12; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 781 | break; |
| 782 | case 640: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 783 | filter_tb = (xgifb_info->TV_type == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 784 | TVMODE_NTSC) ? 5 : 13; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 785 | break; |
| 786 | case 720: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 787 | filter_tb = (xgifb_info->TV_type == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 788 | TVMODE_NTSC) ? 6 : 14; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 789 | break; |
| 790 | case 800: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 791 | filter_tb = (xgifb_info->TV_type == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 792 | TVMODE_NTSC) ? 7 : 15; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 793 | break; |
| 794 | default: |
Aaro Koskinen | 84a6c46 | 2011-10-11 21:47:28 +0300 | [diff] [blame] | 795 | filter_tb = 0; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 796 | filter = -1; |
| 797 | break; |
| 798 | } |
Aaro Koskinen | 39f10bf | 2011-10-11 21:47:25 +0300 | [diff] [blame] | 799 | xgifb_reg_or(XGIPART1, |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 800 | SIS_CRT2_WENABLE_315, |
Aaro Koskinen | 39f10bf | 2011-10-11 21:47:25 +0300 | [diff] [blame] | 801 | 0x01); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 802 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 803 | if (xgifb_info->TV_type == TVMODE_NTSC) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 804 | |
| 805 | xgifb_reg_and(XGIPART2, 0x3a, 0x1f); |
| 806 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 807 | if (xgifb_info->TV_plug == TVPLUG_SVIDEO) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 808 | |
| 809 | xgifb_reg_and(XGIPART2, 0x30, 0xdf); |
| 810 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 811 | } else if (xgifb_info->TV_plug |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 812 | == TVPLUG_COMPOSITE) { |
| 813 | |
| 814 | xgifb_reg_or(XGIPART2, 0x30, 0x20); |
| 815 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 816 | switch (xgifb_info->video_width) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 817 | case 640: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 818 | xgifb_reg_set(XGIPART2, |
| 819 | 0x35, |
| 820 | 0xEB); |
| 821 | xgifb_reg_set(XGIPART2, |
| 822 | 0x36, |
| 823 | 0x04); |
| 824 | xgifb_reg_set(XGIPART2, |
| 825 | 0x37, |
| 826 | 0x25); |
| 827 | xgifb_reg_set(XGIPART2, |
| 828 | 0x38, |
| 829 | 0x18); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 830 | break; |
| 831 | case 720: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 832 | xgifb_reg_set(XGIPART2, |
| 833 | 0x35, |
| 834 | 0xEE); |
| 835 | xgifb_reg_set(XGIPART2, |
| 836 | 0x36, |
| 837 | 0x0C); |
| 838 | xgifb_reg_set(XGIPART2, |
| 839 | 0x37, |
| 840 | 0x22); |
| 841 | xgifb_reg_set(XGIPART2, |
| 842 | 0x38, |
| 843 | 0x08); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 844 | break; |
| 845 | case 800: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 846 | xgifb_reg_set(XGIPART2, |
| 847 | 0x35, |
| 848 | 0xEB); |
| 849 | xgifb_reg_set(XGIPART2, |
| 850 | 0x36, |
| 851 | 0x15); |
| 852 | xgifb_reg_set(XGIPART2, |
| 853 | 0x37, |
| 854 | 0x25); |
| 855 | xgifb_reg_set(XGIPART2, |
| 856 | 0x38, |
| 857 | 0xF6); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 858 | break; |
| 859 | } |
| 860 | } |
| 861 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 862 | } else if (xgifb_info->TV_type == TVMODE_PAL) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 863 | |
| 864 | xgifb_reg_and(XGIPART2, 0x3A, 0x1F); |
| 865 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 866 | if (xgifb_info->TV_plug == TVPLUG_SVIDEO) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 867 | |
| 868 | xgifb_reg_and(XGIPART2, 0x30, 0xDF); |
| 869 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 870 | } else if (xgifb_info->TV_plug |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 871 | == TVPLUG_COMPOSITE) { |
| 872 | |
| 873 | xgifb_reg_or(XGIPART2, 0x30, 0x20); |
| 874 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 875 | switch (xgifb_info->video_width) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 876 | case 640: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 877 | xgifb_reg_set(XGIPART2, |
| 878 | 0x35, |
| 879 | 0xF1); |
| 880 | xgifb_reg_set(XGIPART2, |
| 881 | 0x36, |
| 882 | 0xF7); |
| 883 | xgifb_reg_set(XGIPART2, |
| 884 | 0x37, |
| 885 | 0x1F); |
| 886 | xgifb_reg_set(XGIPART2, |
| 887 | 0x38, |
| 888 | 0x32); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 889 | break; |
| 890 | case 720: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 891 | xgifb_reg_set(XGIPART2, |
| 892 | 0x35, |
| 893 | 0xF3); |
| 894 | xgifb_reg_set(XGIPART2, |
| 895 | 0x36, |
| 896 | 0x00); |
| 897 | xgifb_reg_set(XGIPART2, |
| 898 | 0x37, |
| 899 | 0x1D); |
| 900 | xgifb_reg_set(XGIPART2, |
| 901 | 0x38, |
| 902 | 0x20); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 903 | break; |
| 904 | case 800: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 905 | xgifb_reg_set(XGIPART2, |
| 906 | 0x35, |
| 907 | 0xFC); |
| 908 | xgifb_reg_set(XGIPART2, |
| 909 | 0x36, |
| 910 | 0xFB); |
| 911 | xgifb_reg_set(XGIPART2, |
| 912 | 0x37, |
| 913 | 0x14); |
| 914 | xgifb_reg_set(XGIPART2, |
| 915 | 0x38, |
| 916 | 0x2A); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 917 | break; |
| 918 | } |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | if ((filter >= 0) && (filter <= 7)) { |
Andy Shevchenko | 977310b | 2012-08-02 19:05:52 +0300 | [diff] [blame] | 923 | pr_debug("FilterTable[%d]-%d: %*ph\n", |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 924 | filter_tb, filter, |
Andy Shevchenko | 977310b | 2012-08-02 19:05:52 +0300 | [diff] [blame] | 925 | 4, XGI_TV_filter[filter_tb]. |
| 926 | filter[filter]); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 927 | xgifb_reg_set( |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 928 | XGIPART2, |
| 929 | 0x35, |
| 930 | (XGI_TV_filter[filter_tb]. |
| 931 | filter[filter][0])); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 932 | xgifb_reg_set( |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 933 | XGIPART2, |
| 934 | 0x36, |
| 935 | (XGI_TV_filter[filter_tb]. |
| 936 | filter[filter][1])); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 937 | xgifb_reg_set( |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 938 | XGIPART2, |
| 939 | 0x37, |
| 940 | (XGI_TV_filter[filter_tb]. |
| 941 | filter[filter][2])); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 942 | xgifb_reg_set( |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 943 | XGIPART2, |
| 944 | 0x38, |
| 945 | (XGI_TV_filter[filter_tb]. |
| 946 | filter[filter][3])); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 947 | } |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 948 | } |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 949 | } |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 950 | } |
| 951 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 952 | static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 953 | struct fb_info *info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 954 | { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 955 | struct xgifb_video_info *xgifb_info = info->par; |
| 956 | struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 957 | unsigned int htotal = var->left_margin + var->xres + var->right_margin |
| 958 | + var->hsync_len; |
| 959 | unsigned int vtotal = var->upper_margin + var->yres + var->lower_margin |
| 960 | + var->vsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 961 | #if defined(__powerpc__) |
Dmitry Eremin-Solenikov | ef23b21 | 2012-03-19 21:50:11 +0400 | [diff] [blame] | 962 | u8 cr_data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 963 | #endif |
| 964 | unsigned int drate = 0, hrate = 0; |
| 965 | int found_mode = 0; |
| 966 | int old_mode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 967 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 968 | info->var.xres_virtual = var->xres_virtual; |
| 969 | info->var.yres_virtual = var->yres_virtual; |
| 970 | info->var.bits_per_pixel = var->bits_per_pixel; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 971 | |
| 972 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) |
| 973 | vtotal <<= 1; |
| 974 | else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) |
| 975 | vtotal <<= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 976 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 977 | if (!htotal || !vtotal) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 978 | pr_debug("Invalid 'var' information\n"); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 979 | return -EINVAL; |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 980 | } pr_debug("var->pixclock=%d, htotal=%d, vtotal=%d\n", |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 981 | var->pixclock, htotal, vtotal); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 982 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 983 | if (var->pixclock && htotal && vtotal) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 984 | drate = 1000000000 / var->pixclock; |
| 985 | hrate = (drate * 1000) / htotal; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 986 | xgifb_info->refresh_rate = (unsigned int) (hrate * 2 |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 987 | / vtotal); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 988 | } else { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 989 | xgifb_info->refresh_rate = 60; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 990 | } |
| 991 | |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 992 | pr_debug("Change mode to %dx%dx%d-%dHz\n", |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 993 | var->xres, |
| 994 | var->yres, |
| 995 | var->bits_per_pixel, |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 996 | xgifb_info->refresh_rate); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 997 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 998 | old_mode = xgifb_info->mode_idx; |
| 999 | xgifb_info->mode_idx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1000 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1001 | while ((XGIbios_mode[xgifb_info->mode_idx].mode_no != 0) && |
| 1002 | (XGIbios_mode[xgifb_info->mode_idx].xres <= var->xres)) { |
| 1003 | if ((XGIbios_mode[xgifb_info->mode_idx].xres == var->xres) && |
| 1004 | (XGIbios_mode[xgifb_info->mode_idx].yres == var->yres) && |
| 1005 | (XGIbios_mode[xgifb_info->mode_idx].bpp |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1006 | == var->bits_per_pixel)) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1007 | found_mode = 1; |
| 1008 | break; |
| 1009 | } |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1010 | xgifb_info->mode_idx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1011 | } |
| 1012 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1013 | if (found_mode) |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1014 | xgifb_info->mode_idx = XGIfb_validate_mode(xgifb_info, |
| 1015 | xgifb_info->mode_idx); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1016 | else |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1017 | xgifb_info->mode_idx = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1018 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1019 | if (xgifb_info->mode_idx < 0) { |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1020 | pr_err("Mode %dx%dx%d not supported\n", |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1021 | var->xres, var->yres, var->bits_per_pixel); |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1022 | xgifb_info->mode_idx = old_mode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1023 | return -EINVAL; |
| 1024 | } |
| 1025 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1026 | if (XGIfb_search_refresh_rate(xgifb_info, |
| 1027 | xgifb_info->refresh_rate) == 0) { |
Aaro Koskinen | f47f12d | 2012-04-07 01:13:54 +0300 | [diff] [blame] | 1028 | xgifb_info->rate_idx = 1; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1029 | xgifb_info->refresh_rate = 60; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1030 | } |
| 1031 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1032 | if (isactive) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1033 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1034 | XGIfb_pre_setmode(xgifb_info); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 1035 | if (XGISetModeNew(xgifb_info, hw_info, |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1036 | XGIbios_mode[xgifb_info->mode_idx].mode_no) |
| 1037 | == 0) { |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1038 | pr_err("Setting mode[0x%x] failed\n", |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1039 | XGIbios_mode[xgifb_info->mode_idx].mode_no); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1040 | return -EINVAL; |
| 1041 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1042 | info->fix.line_length = ((info->var.xres_virtual |
| 1043 | * info->var.bits_per_pixel) >> 6); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1044 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1045 | xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1046 | |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1047 | xgifb_reg_set(XGICR, 0x13, (info->fix.line_length & 0x00ff)); |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1048 | xgifb_reg_set(XGISR, |
| 1049 | 0x0E, |
| 1050 | (info->fix.line_length & 0xff00) >> 8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1051 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1052 | XGIfb_post_setmode(xgifb_info); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1053 | |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1054 | pr_debug("Set new mode: %dx%dx%d-%d\n", |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 1055 | XGIbios_mode[xgifb_info->mode_idx].xres, |
| 1056 | XGIbios_mode[xgifb_info->mode_idx].yres, |
| 1057 | XGIbios_mode[xgifb_info->mode_idx].bpp, |
| 1058 | xgifb_info->refresh_rate); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1059 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1060 | xgifb_info->video_bpp = XGIbios_mode[xgifb_info->mode_idx].bpp; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1061 | xgifb_info->video_vwidth = info->var.xres_virtual; |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1062 | xgifb_info->video_width = |
| 1063 | XGIbios_mode[xgifb_info->mode_idx].xres; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1064 | xgifb_info->video_vheight = info->var.yres_virtual; |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1065 | xgifb_info->video_height = |
| 1066 | XGIbios_mode[xgifb_info->mode_idx].yres; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1067 | xgifb_info->org_x = xgifb_info->org_y = 0; |
| 1068 | xgifb_info->video_linelength = info->var.xres_virtual |
| 1069 | * (xgifb_info->video_bpp >> 3); |
| 1070 | switch (xgifb_info->video_bpp) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1071 | case 8: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1072 | xgifb_info->DstColor = 0x0000; |
| 1073 | xgifb_info->XGI310_AccelDepth = 0x00000000; |
| 1074 | xgifb_info->video_cmap_len = 256; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1075 | #if defined(__powerpc__) |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1076 | cr_data = xgifb_reg_get(XGICR, 0x4D); |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1077 | xgifb_reg_set(XGICR, 0x4D, (cr_data & 0xE0)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1078 | #endif |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1079 | break; |
| 1080 | case 16: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1081 | xgifb_info->DstColor = 0x8000; |
| 1082 | xgifb_info->XGI310_AccelDepth = 0x00010000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1083 | #if defined(__powerpc__) |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1084 | cr_data = xgifb_reg_get(XGICR, 0x4D); |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1085 | xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x0B)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1086 | #endif |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1087 | xgifb_info->video_cmap_len = 16; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1088 | break; |
| 1089 | case 32: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1090 | xgifb_info->DstColor = 0xC000; |
| 1091 | xgifb_info->XGI310_AccelDepth = 0x00020000; |
| 1092 | xgifb_info->video_cmap_len = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1093 | #if defined(__powerpc__) |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1094 | cr_data = xgifb_reg_get(XGICR, 0x4D); |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1095 | xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x15)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1096 | #endif |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1097 | break; |
| 1098 | default: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1099 | xgifb_info->video_cmap_len = 16; |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1100 | pr_err("Unsupported depth %d\n", |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1101 | xgifb_info->video_bpp); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1102 | break; |
| 1103 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1104 | } |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1105 | XGIfb_bpp_to_var(xgifb_info, var); /*update ARGB info*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1106 | |
| 1107 | dumpVGAReg(); |
| 1108 | return 0; |
| 1109 | } |
| 1110 | |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1111 | static int XGIfb_pan_var(struct fb_var_screeninfo *var, struct fb_info *info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1112 | { |
Linus Torvalds | acff987 | 2011-10-30 15:30:01 -0700 | [diff] [blame] | 1113 | struct xgifb_video_info *xgifb_info = info->par; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1114 | unsigned int base; |
| 1115 | |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1116 | base = var->yoffset * info->var.xres_virtual + var->xoffset; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1117 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1118 | /* calculate base bpp dep. */ |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1119 | switch (info->var.bits_per_pixel) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1120 | case 16: |
| 1121 | base >>= 1; |
| 1122 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1123 | case 32: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1124 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1125 | case 8: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1126 | default: |
| 1127 | base >>= 2; |
| 1128 | break; |
| 1129 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1130 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1131 | xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1132 | |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1133 | xgifb_reg_set(XGICR, 0x0D, base & 0xFF); |
| 1134 | xgifb_reg_set(XGICR, 0x0C, (base >> 8) & 0xFF); |
| 1135 | xgifb_reg_set(XGISR, 0x0D, (base >> 16) & 0xFF); |
| 1136 | xgifb_reg_set(XGISR, 0x37, (base >> 24) & 0x03); |
Aaro Koskinen | 65283d4 | 2011-04-18 22:14:02 +0300 | [diff] [blame] | 1137 | xgifb_reg_and_or(XGISR, 0x37, 0xDF, (base >> 21) & 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1138 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1139 | if (xgifb_info->display2 != XGIFB_DISP_NONE) { |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1140 | xgifb_reg_or(XGIPART1, SIS_CRT2_WENABLE_315, 0x01); |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1141 | xgifb_reg_set(XGIPART1, 0x06, (base & 0xFF)); |
| 1142 | xgifb_reg_set(XGIPART1, 0x05, ((base >> 8) & 0xFF)); |
| 1143 | xgifb_reg_set(XGIPART1, 0x04, ((base >> 16) & 0xFF)); |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1144 | xgifb_reg_and_or(XGIPART1, |
| 1145 | 0x02, |
| 1146 | 0x7F, |
| 1147 | ((base >> 24) & 0x01) << 7); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1148 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1149 | return 0; |
| 1150 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1151 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1152 | static int XGIfb_open(struct fb_info *info, int user) |
| 1153 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1154 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | static int XGIfb_release(struct fb_info *info, int user) |
| 1158 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1159 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | static int XGIfb_get_cmap_len(const struct fb_var_screeninfo *var) |
| 1163 | { |
| 1164 | int rc = 16; |
| 1165 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1166 | switch (var->bits_per_pixel) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1167 | case 8: |
| 1168 | rc = 256; |
| 1169 | break; |
| 1170 | case 16: |
| 1171 | rc = 16; |
| 1172 | break; |
| 1173 | case 32: |
| 1174 | rc = 16; |
| 1175 | break; |
| 1176 | } |
| 1177 | return rc; |
| 1178 | } |
| 1179 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1180 | static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green, |
| 1181 | unsigned blue, unsigned transp, struct fb_info *info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1182 | { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1183 | struct xgifb_video_info *xgifb_info = info->par; |
| 1184 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1185 | if (regno >= XGIfb_get_cmap_len(&info->var)) |
| 1186 | return 1; |
| 1187 | |
| 1188 | switch (info->var.bits_per_pixel) { |
| 1189 | case 8: |
Aaro Koskinen | e3d5ceb | 2011-04-18 22:13:57 +0300 | [diff] [blame] | 1190 | outb(regno, XGIDACA); |
| 1191 | outb((red >> 10), XGIDACD); |
| 1192 | outb((green >> 10), XGIDACD); |
| 1193 | outb((blue >> 10), XGIDACD); |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1194 | if (xgifb_info->display2 != XGIFB_DISP_NONE) { |
Aaro Koskinen | e3d5ceb | 2011-04-18 22:13:57 +0300 | [diff] [blame] | 1195 | outb(regno, XGIDAC2A); |
| 1196 | outb((red >> 8), XGIDAC2D); |
| 1197 | outb((green >> 8), XGIDAC2D); |
| 1198 | outb((blue >> 8), XGIDAC2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1199 | } |
| 1200 | break; |
| 1201 | case 16: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1202 | ((u32 *) (info->pseudo_palette))[regno] = ((red & 0xf800)) |
| 1203 | | ((green & 0xfc00) >> 5) | ((blue & 0xf800) |
| 1204 | >> 11); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1205 | break; |
| 1206 | case 32: |
| 1207 | red >>= 8; |
| 1208 | green >>= 8; |
| 1209 | blue >>= 8; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1210 | ((u32 *) (info->pseudo_palette))[regno] = (red << 16) | (green |
| 1211 | << 8) | (blue); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1212 | break; |
| 1213 | } |
| 1214 | return 0; |
| 1215 | } |
| 1216 | |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1217 | /* ----------- FBDev related routines for all series ---------- */ |
| 1218 | |
| 1219 | static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con, |
| 1220 | struct fb_info *info) |
| 1221 | { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1222 | struct xgifb_video_info *xgifb_info = info->par; |
| 1223 | |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1224 | memset(fix, 0, sizeof(struct fb_fix_screeninfo)); |
| 1225 | |
Peter Huewe | 176f784 | 2012-06-14 00:21:39 +0200 | [diff] [blame] | 1226 | strncpy(fix->id, "XGI", sizeof(fix->id) - 1); |
| 1227 | |
Peter Huewe | 95649c4 | 2012-06-14 00:21:40 +0200 | [diff] [blame] | 1228 | /* if register_framebuffer has been called, we must lock */ |
| 1229 | if (atomic_read(&info->count)) |
| 1230 | mutex_lock(&info->mm_lock); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1231 | |
Peter Huewe | 95649c4 | 2012-06-14 00:21:40 +0200 | [diff] [blame] | 1232 | fix->smem_start = xgifb_info->video_base; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1233 | fix->smem_len = xgifb_info->video_size; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1234 | |
Peter Huewe | 95649c4 | 2012-06-14 00:21:40 +0200 | [diff] [blame] | 1235 | /* if register_framebuffer has been called, we can unlock */ |
| 1236 | if (atomic_read(&info->count)) |
| 1237 | mutex_unlock(&info->mm_lock); |
| 1238 | |
Aaro Koskinen | de351ba | 2011-08-19 22:40:27 +0300 | [diff] [blame] | 1239 | fix->type = FB_TYPE_PACKED_PIXELS; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1240 | fix->type_aux = 0; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1241 | if (xgifb_info->video_bpp == 8) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1242 | fix->visual = FB_VISUAL_PSEUDOCOLOR; |
| 1243 | else |
| 1244 | fix->visual = FB_VISUAL_DIRECTCOLOR; |
| 1245 | fix->xpanstep = 0; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1246 | if (XGIfb_ypan) |
| 1247 | fix->ypanstep = 1; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1248 | fix->ywrapstep = 0; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1249 | fix->line_length = xgifb_info->video_linelength; |
| 1250 | fix->mmio_start = xgifb_info->mmio_base; |
| 1251 | fix->mmio_len = xgifb_info->mmio_size; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1252 | fix->accel = FB_ACCEL_SIS_XABRE; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1253 | |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1254 | return 0; |
| 1255 | } |
| 1256 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1257 | static int XGIfb_set_par(struct fb_info *info) |
| 1258 | { |
| 1259 | int err; |
| 1260 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1261 | err = XGIfb_do_set_var(&info->var, 1, info); |
| 1262 | if (err) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1263 | return err; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1264 | XGIfb_get_fix(&info->fix, -1, info); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1265 | return 0; |
| 1266 | } |
| 1267 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1268 | static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1269 | { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1270 | struct xgifb_video_info *xgifb_info = info->par; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1271 | unsigned int htotal = var->left_margin + var->xres + var->right_margin |
| 1272 | + var->hsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1273 | unsigned int vtotal = 0; |
| 1274 | unsigned int drate = 0, hrate = 0; |
| 1275 | int found_mode = 0; |
| 1276 | int refresh_rate, search_idx; |
| 1277 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1278 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) { |
| 1279 | vtotal = var->upper_margin + var->yres + var->lower_margin |
| 1280 | + var->vsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1281 | vtotal <<= 1; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1282 | } else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { |
| 1283 | vtotal = var->upper_margin + var->yres + var->lower_margin |
| 1284 | + var->vsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1285 | vtotal <<= 2; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1286 | } else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { |
| 1287 | vtotal = var->upper_margin + (var->yres / 2) |
| 1288 | + var->lower_margin + var->vsync_len; |
| 1289 | } else |
| 1290 | vtotal = var->upper_margin + var->yres + var->lower_margin |
| 1291 | + var->vsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1292 | |
Miguel Gómez | 47cee13 | 2012-06-18 13:12:03 +0200 | [diff] [blame] | 1293 | if (!(htotal) || !(vtotal)) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1294 | pr_debug("No valid timing data\n"); |
Miguel Gómez | 47cee13 | 2012-06-18 13:12:03 +0200 | [diff] [blame] | 1295 | return -EINVAL; |
| 1296 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1297 | |
| 1298 | if (var->pixclock && htotal && vtotal) { |
| 1299 | drate = 1000000000 / var->pixclock; |
| 1300 | hrate = (drate * 1000) / htotal; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1301 | xgifb_info->refresh_rate = |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1302 | (unsigned int) (hrate * 2 / vtotal); |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1303 | pr_debug( |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1304 | "%s: pixclock = %d ,htotal=%d, vtotal=%d\n" |
| 1305 | "%s: drate=%d, hrate=%d, refresh_rate=%d\n", |
| 1306 | __func__, var->pixclock, htotal, vtotal, |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1307 | __func__, drate, hrate, xgifb_info->refresh_rate); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1308 | } else { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1309 | xgifb_info->refresh_rate = 60; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1310 | } |
| 1311 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1312 | /* Calculation wrong for 1024x600 - force it to 60Hz */ |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1313 | if ((var->xres == 1024) && (var->yres == 600)) |
| 1314 | refresh_rate = 60; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1315 | |
| 1316 | search_idx = 0; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1317 | while ((XGIbios_mode[search_idx].mode_no != 0) && |
| 1318 | (XGIbios_mode[search_idx].xres <= var->xres)) { |
| 1319 | if ((XGIbios_mode[search_idx].xres == var->xres) && |
| 1320 | (XGIbios_mode[search_idx].yres == var->yres) && |
| 1321 | (XGIbios_mode[search_idx].bpp == var->bits_per_pixel)) { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1322 | if (XGIfb_validate_mode(xgifb_info, search_idx) > 0) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1323 | found_mode = 1; |
| 1324 | break; |
| 1325 | } |
| 1326 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1327 | search_idx++; |
| 1328 | } |
| 1329 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1330 | if (!found_mode) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1331 | |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1332 | pr_err("%dx%dx%d is no valid mode\n", |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1333 | var->xres, var->yres, var->bits_per_pixel); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1334 | search_idx = 0; |
| 1335 | while (XGIbios_mode[search_idx].mode_no != 0) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1336 | if ((var->xres <= XGIbios_mode[search_idx].xres) && |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1337 | (var->yres <= XGIbios_mode[search_idx].yres) && |
| 1338 | (var->bits_per_pixel == |
| 1339 | XGIbios_mode[search_idx].bpp)) { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1340 | if (XGIfb_validate_mode(xgifb_info, |
| 1341 | search_idx) > 0) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1342 | found_mode = 1; |
| 1343 | break; |
| 1344 | } |
| 1345 | } |
| 1346 | search_idx++; |
| 1347 | } |
| 1348 | if (found_mode) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1349 | var->xres = XGIbios_mode[search_idx].xres; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1350 | var->yres = XGIbios_mode[search_idx].yres; |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1351 | pr_debug("Adapted to mode %dx%dx%d\n", |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1352 | var->xres, var->yres, var->bits_per_pixel); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1353 | |
| 1354 | } else { |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1355 | pr_err("Failed to find similar mode to %dx%dx%d\n", |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1356 | var->xres, var->yres, var->bits_per_pixel); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1357 | return -EINVAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1358 | } |
| 1359 | } |
| 1360 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1361 | /* Adapt RGB settings */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1362 | XGIfb_bpp_to_var(xgifb_info, var); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1363 | |
| 1364 | /* Sanity check for offsets */ |
| 1365 | if (var->xoffset < 0) |
| 1366 | var->xoffset = 0; |
| 1367 | if (var->yoffset < 0) |
| 1368 | var->yoffset = 0; |
| 1369 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1370 | if (!XGIfb_ypan) { |
| 1371 | if (var->xres != var->xres_virtual) |
| 1372 | var->xres_virtual = var->xres; |
| 1373 | if (var->yres != var->yres_virtual) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1374 | var->yres_virtual = var->yres; |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1375 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1376 | |
| 1377 | /* Truncate offsets to maximum if too high */ |
| 1378 | if (var->xoffset > var->xres_virtual - var->xres) |
| 1379 | var->xoffset = var->xres_virtual - var->xres - 1; |
| 1380 | |
| 1381 | if (var->yoffset > var->yres_virtual - var->yres) |
| 1382 | var->yoffset = var->yres_virtual - var->yres - 1; |
| 1383 | |
| 1384 | /* Set everything else to 0 */ |
| 1385 | var->red.msb_right = |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1386 | var->green.msb_right = |
| 1387 | var->blue.msb_right = |
| 1388 | var->transp.offset = var->transp.length = var->transp.msb_right = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1389 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1390 | return 0; |
| 1391 | } |
| 1392 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1393 | static int XGIfb_pan_display(struct fb_var_screeninfo *var, |
| 1394 | struct fb_info *info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1395 | { |
| 1396 | int err; |
| 1397 | |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1398 | if (var->xoffset > (info->var.xres_virtual - info->var.xres)) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1399 | return -EINVAL; |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1400 | if (var->yoffset > (info->var.yres_virtual - info->var.yres)) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1401 | return -EINVAL; |
| 1402 | |
| 1403 | if (var->vmode & FB_VMODE_YWRAP) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1404 | if (var->yoffset < 0 || var->yoffset >= info->var.yres_virtual |
| 1405 | || var->xoffset) |
| 1406 | return -EINVAL; |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 1407 | } else if (var->xoffset + info->var.xres > info->var.xres_virtual |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1408 | || var->yoffset + info->var.yres |
Aaro Koskinen | d3ae576 | 2012-09-11 00:15:27 +0300 | [diff] [blame] | 1409 | > info->var.yres_virtual) { |
| 1410 | return -EINVAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1411 | } |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1412 | err = XGIfb_pan_var(var, info); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1413 | if (err < 0) |
| 1414 | return err; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1415 | |
| 1416 | info->var.xoffset = var->xoffset; |
| 1417 | info->var.yoffset = var->yoffset; |
| 1418 | if (var->vmode & FB_VMODE_YWRAP) |
| 1419 | info->var.vmode |= FB_VMODE_YWRAP; |
| 1420 | else |
| 1421 | info->var.vmode &= ~FB_VMODE_YWRAP; |
| 1422 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1423 | return 0; |
| 1424 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1425 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1426 | static int XGIfb_blank(int blank, struct fb_info *info) |
| 1427 | { |
Aaro Koskinen | f2df8c0 | 2011-10-11 21:47:30 +0300 | [diff] [blame] | 1428 | struct xgifb_video_info *xgifb_info = info->par; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1429 | u8 reg; |
| 1430 | |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1431 | reg = xgifb_reg_get(XGICR, 0x17); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1432 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1433 | if (blank > 0) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1434 | reg &= 0x7f; |
| 1435 | else |
| 1436 | reg |= 0x80; |
| 1437 | |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1438 | xgifb_reg_set(XGICR, 0x17, reg); |
| 1439 | xgifb_reg_set(XGISR, 0x00, 0x01); /* Synchronous Reset */ |
| 1440 | xgifb_reg_set(XGISR, 0x00, 0x03); /* End Reset */ |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1441 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1442 | } |
| 1443 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1444 | static struct fb_ops XGIfb_ops = { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1445 | .owner = THIS_MODULE, |
| 1446 | .fb_open = XGIfb_open, |
| 1447 | .fb_release = XGIfb_release, |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1448 | .fb_check_var = XGIfb_check_var, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1449 | .fb_set_par = XGIfb_set_par, |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1450 | .fb_setcolreg = XGIfb_setcolreg, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1451 | .fb_pan_display = XGIfb_pan_display, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1452 | .fb_blank = XGIfb_blank, |
Aaro Koskinen | 1b40296 | 2011-02-28 20:59:22 +0200 | [diff] [blame] | 1453 | .fb_fillrect = cfb_fillrect, |
Aaro Koskinen | 85c3c56 | 2011-02-28 20:59:21 +0200 | [diff] [blame] | 1454 | .fb_copyarea = cfb_copyarea, |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1455 | .fb_imageblit = cfb_imageblit, |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1456 | }; |
| 1457 | |
| 1458 | /* ---------------- Chip generation dependent routines ---------------- */ |
| 1459 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1460 | /* for XGI 315/550/650/740/330 */ |
| 1461 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1462 | static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1463 | { |
| 1464 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1465 | u8 ChannelNum, tmp; |
| 1466 | u8 reg = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1467 | |
| 1468 | /* xorg driver sets 32MB * 1 channel */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1469 | if (xgifb_info->chip == XG27) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1470 | xgifb_reg_set(XGISR, IND_SIS_DRAM_SIZE, 0x51); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1471 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1472 | reg = xgifb_reg_get(XGISR, IND_SIS_DRAM_SIZE); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1473 | switch ((reg & XGI_DRAM_SIZE_MASK) >> 4) { |
| 1474 | case XGI_DRAM_SIZE_1MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1475 | xgifb_info->video_size = 0x100000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1476 | break; |
| 1477 | case XGI_DRAM_SIZE_2MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1478 | xgifb_info->video_size = 0x200000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1479 | break; |
| 1480 | case XGI_DRAM_SIZE_4MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1481 | xgifb_info->video_size = 0x400000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1482 | break; |
| 1483 | case XGI_DRAM_SIZE_8MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1484 | xgifb_info->video_size = 0x800000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1485 | break; |
| 1486 | case XGI_DRAM_SIZE_16MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1487 | xgifb_info->video_size = 0x1000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1488 | break; |
| 1489 | case XGI_DRAM_SIZE_32MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1490 | xgifb_info->video_size = 0x2000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1491 | break; |
| 1492 | case XGI_DRAM_SIZE_64MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1493 | xgifb_info->video_size = 0x4000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1494 | break; |
| 1495 | case XGI_DRAM_SIZE_128MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1496 | xgifb_info->video_size = 0x8000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1497 | break; |
| 1498 | case XGI_DRAM_SIZE_256MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1499 | xgifb_info->video_size = 0x10000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1500 | break; |
| 1501 | default: |
| 1502 | return -1; |
| 1503 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1504 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1505 | tmp = (reg & 0x0c) >> 2; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1506 | switch (xgifb_info->chip) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1507 | case XG20: |
| 1508 | case XG21: |
| 1509 | case XG27: |
| 1510 | ChannelNum = 1; |
| 1511 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1512 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1513 | case XG42: |
| 1514 | if (reg & 0x04) |
| 1515 | ChannelNum = 2; |
| 1516 | else |
| 1517 | ChannelNum = 1; |
| 1518 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1519 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1520 | case XG40: |
| 1521 | default: |
| 1522 | if (tmp == 2) |
| 1523 | ChannelNum = 2; |
| 1524 | else if (tmp == 3) |
| 1525 | ChannelNum = 3; |
| 1526 | else |
| 1527 | ChannelNum = 1; |
| 1528 | break; |
| 1529 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1530 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1531 | xgifb_info->video_size = xgifb_info->video_size * ChannelNum; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1532 | |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1533 | pr_info("SR14=%x DramSzie %x ChannelNum %x\n", |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1534 | reg, |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1535 | xgifb_info->video_size, ChannelNum); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1536 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1537 | |
| 1538 | } |
| 1539 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1540 | static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1541 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1542 | u8 cr32, temp = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1543 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1544 | xgifb_info->TV_plug = xgifb_info->TV_type = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1545 | |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1546 | cr32 = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR32); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1547 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1548 | if ((cr32 & SIS_CRT1) && !XGIfb_crt1off) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1549 | XGIfb_crt1off = 0; |
| 1550 | else { |
| 1551 | if (cr32 & 0x5F) |
| 1552 | XGIfb_crt1off = 1; |
| 1553 | else |
| 1554 | XGIfb_crt1off = 0; |
| 1555 | } |
| 1556 | |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1557 | if (!xgifb_info->display2_force) { |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1558 | if (cr32 & SIS_VB_TV) |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1559 | xgifb_info->display2 = XGIFB_DISP_TV; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1560 | else if (cr32 & SIS_VB_LCD) |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1561 | xgifb_info->display2 = XGIFB_DISP_LCD; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1562 | else if (cr32 & SIS_VB_CRT2) |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1563 | xgifb_info->display2 = XGIFB_DISP_CRT; |
| 1564 | else |
| 1565 | xgifb_info->display2 = XGIFB_DISP_NONE; |
| 1566 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1567 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1568 | if (XGIfb_tvplug != -1) |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1569 | /* Override with option */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1570 | xgifb_info->TV_plug = XGIfb_tvplug; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1571 | else if (cr32 & SIS_VB_HIVISION) { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1572 | xgifb_info->TV_type = TVMODE_HIVISION; |
| 1573 | xgifb_info->TV_plug = TVPLUG_SVIDEO; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1574 | } else if (cr32 & SIS_VB_SVIDEO) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1575 | xgifb_info->TV_plug = TVPLUG_SVIDEO; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1576 | else if (cr32 & SIS_VB_COMPOSITE) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1577 | xgifb_info->TV_plug = TVPLUG_COMPOSITE; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1578 | else if (cr32 & SIS_VB_SCART) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1579 | xgifb_info->TV_plug = TVPLUG_SCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1580 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1581 | if (xgifb_info->TV_type == 0) { |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1582 | temp = xgifb_reg_get(XGICR, 0x38); |
Aaro Koskinen | ebe7846 | 2011-03-13 12:26:08 +0200 | [diff] [blame] | 1583 | if (temp & 0x10) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1584 | xgifb_info->TV_type = TVMODE_PAL; |
Aaro Koskinen | ebe7846 | 2011-03-13 12:26:08 +0200 | [diff] [blame] | 1585 | else |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1586 | xgifb_info->TV_type = TVMODE_NTSC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1587 | } |
| 1588 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1589 | /* Copy forceCRT1 option to CRT1off if option is given */ |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1590 | if (XGIfb_forcecrt1 != -1) { |
| 1591 | if (XGIfb_forcecrt1) |
| 1592 | XGIfb_crt1off = 0; |
| 1593 | else |
| 1594 | XGIfb_crt1off = 1; |
| 1595 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1596 | } |
| 1597 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1598 | static int XGIfb_has_VB(struct xgifb_video_info *xgifb_info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1599 | { |
| 1600 | u8 vb_chipid; |
| 1601 | |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1602 | vb_chipid = xgifb_reg_get(XGIPART4, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1603 | switch (vb_chipid) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1604 | case 0x01: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1605 | xgifb_info->hasVB = HASVB_301; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1606 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1607 | case 0x02: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1608 | xgifb_info->hasVB = HASVB_302; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1609 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1610 | default: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1611 | xgifb_info->hasVB = HASVB_NONE; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 1612 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1613 | } |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 1614 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1615 | } |
| 1616 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1617 | static void XGIfb_get_VB_type(struct xgifb_video_info *xgifb_info) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1618 | { |
| 1619 | u8 reg; |
| 1620 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1621 | if (!XGIfb_has_VB(xgifb_info)) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1622 | reg = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR37); |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1623 | switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) { |
| 1624 | case SIS_EXTERNAL_CHIP_LVDS: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1625 | xgifb_info->hasVB = HASVB_LVDS; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1626 | break; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1627 | case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1628 | xgifb_info->hasVB = HASVB_LVDS_CHRONTEL; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1629 | break; |
| 1630 | default: |
| 1631 | break; |
| 1632 | } |
| 1633 | } |
| 1634 | } |
| 1635 | |
Aaro Koskinen | d27c6bc | 2011-08-29 23:14:23 +0300 | [diff] [blame] | 1636 | static int __init xgifb_optval(char *fullopt, int validx) |
| 1637 | { |
| 1638 | unsigned long lres; |
| 1639 | |
| 1640 | if (kstrtoul(fullopt + validx, 0, &lres) < 0 || lres > INT_MAX) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1641 | pr_err("Invalid value for option: %s\n", fullopt); |
Aaro Koskinen | d27c6bc | 2011-08-29 23:14:23 +0300 | [diff] [blame] | 1642 | return 0; |
| 1643 | } |
| 1644 | return lres; |
| 1645 | } |
| 1646 | |
Ruslan Pisarev | 032abf7 | 2011-07-21 11:59:11 +0300 | [diff] [blame] | 1647 | static int __init XGIfb_setup(char *options) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1648 | { |
| 1649 | char *this_opt; |
| 1650 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1651 | if (!options || !*options) |
| 1652 | return 0; |
| 1653 | |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1654 | pr_info("Options: %s\n", options); |
Aaro Koskinen | 79bea04 | 2011-08-29 23:14:21 +0300 | [diff] [blame] | 1655 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1656 | while ((this_opt = strsep(&options, ",")) != NULL) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1657 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1658 | if (!*this_opt) |
| 1659 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1660 | |
| 1661 | if (!strncmp(this_opt, "mode:", 5)) { |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1662 | mode = this_opt + 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1663 | } else if (!strncmp(this_opt, "vesa:", 5)) { |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1664 | vesa = xgifb_optval(this_opt, 5); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1665 | } else if (!strncmp(this_opt, "vrate:", 6)) { |
Aaro Koskinen | 7548a83 | 2011-10-11 21:47:17 +0300 | [diff] [blame] | 1666 | refresh_rate = xgifb_optval(this_opt, 6); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1667 | } else if (!strncmp(this_opt, "rate:", 5)) { |
Aaro Koskinen | 7548a83 | 2011-10-11 21:47:17 +0300 | [diff] [blame] | 1668 | refresh_rate = xgifb_optval(this_opt, 5); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1669 | } else if (!strncmp(this_opt, "crt1off", 7)) { |
| 1670 | XGIfb_crt1off = 1; |
| 1671 | } else if (!strncmp(this_opt, "filter:", 7)) { |
Aaro Koskinen | d27c6bc | 2011-08-29 23:14:23 +0300 | [diff] [blame] | 1672 | filter = xgifb_optval(this_opt, 7); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1673 | } else if (!strncmp(this_opt, "forcecrt2type:", 14)) { |
| 1674 | XGIfb_search_crt2type(this_opt + 14); |
| 1675 | } else if (!strncmp(this_opt, "forcecrt1:", 10)) { |
Aaro Koskinen | d27c6bc | 2011-08-29 23:14:23 +0300 | [diff] [blame] | 1676 | XGIfb_forcecrt1 = xgifb_optval(this_opt, 10); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1677 | } else if (!strncmp(this_opt, "tvmode:", 7)) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1678 | XGIfb_search_tvstd(this_opt + 7); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1679 | } else if (!strncmp(this_opt, "tvstandard:", 11)) { |
| 1680 | XGIfb_search_tvstd(this_opt + 7); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1681 | } else if (!strncmp(this_opt, "dstn", 4)) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1682 | enable_dstn = 1; |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1683 | /* DSTN overrules forcecrt2type */ |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1684 | XGIfb_crt2type = XGIFB_DISP_LCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1685 | } else if (!strncmp(this_opt, "noypan", 6)) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1686 | XGIfb_ypan = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1687 | } else { |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1688 | mode = this_opt; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1689 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1690 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1691 | return 0; |
| 1692 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1693 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 1694 | static int __devinit xgifb_probe(struct pci_dev *pdev, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1695 | const struct pci_device_id *ent) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1696 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1697 | u8 reg, reg1; |
| 1698 | u8 CR48, CR38; |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1699 | int ret; |
Aaro Koskinen | 19c1e88 | 2011-10-11 21:47:14 +0300 | [diff] [blame] | 1700 | struct fb_info *fb_info; |
Aaro Koskinen | fcbdda9 | 2011-10-11 21:47:20 +0300 | [diff] [blame] | 1701 | struct xgifb_video_info *xgifb_info; |
| 1702 | struct xgi_hw_device_info *hw_info; |
Aaro Koskinen | 6b2a7e0 | 2012-09-12 00:44:38 +0300 | [diff] [blame^] | 1703 | unsigned long video_size_max; |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1704 | |
Aaro Koskinen | fcbdda9 | 2011-10-11 21:47:20 +0300 | [diff] [blame] | 1705 | fb_info = framebuffer_alloc(sizeof(*xgifb_info), &pdev->dev); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1706 | if (!fb_info) |
| 1707 | return -ENOMEM; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1708 | |
Aaro Koskinen | fcbdda9 | 2011-10-11 21:47:20 +0300 | [diff] [blame] | 1709 | xgifb_info = fb_info->par; |
| 1710 | hw_info = &xgifb_info->hw_info; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1711 | xgifb_info->fb_info = fb_info; |
| 1712 | xgifb_info->chip_id = pdev->device; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1713 | pci_read_config_byte(pdev, |
| 1714 | PCI_REVISION_ID, |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1715 | &xgifb_info->revision_id); |
| 1716 | hw_info->jChipRevision = xgifb_info->revision_id; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1717 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1718 | xgifb_info->pcibus = pdev->bus->number; |
| 1719 | xgifb_info->pcislot = PCI_SLOT(pdev->devfn); |
| 1720 | xgifb_info->pcifunc = PCI_FUNC(pdev->devfn); |
| 1721 | xgifb_info->subsysvendor = pdev->subsystem_vendor; |
| 1722 | xgifb_info->subsysdevice = pdev->subsystem_device; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1723 | |
Aaro Koskinen | 6b2a7e0 | 2012-09-12 00:44:38 +0300 | [diff] [blame^] | 1724 | video_size_max = pci_resource_len(pdev, 0); |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1725 | xgifb_info->video_base = pci_resource_start(pdev, 0); |
| 1726 | xgifb_info->mmio_base = pci_resource_start(pdev, 1); |
| 1727 | xgifb_info->mmio_size = pci_resource_len(pdev, 1); |
| 1728 | xgifb_info->vga_base = pci_resource_start(pdev, 2) + 0x30; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1729 | dev_info(&pdev->dev, "Relocate IO address: %Lx [%08lx]\n", |
| 1730 | (u64) pci_resource_start(pdev, 2), |
| 1731 | xgifb_info->vga_base); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1732 | |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1733 | if (pci_enable_device(pdev)) { |
| 1734 | ret = -EIO; |
| 1735 | goto error; |
| 1736 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1737 | |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1738 | if (XGIfb_crt2type != -1) { |
| 1739 | xgifb_info->display2 = XGIfb_crt2type; |
| 1740 | xgifb_info->display2_force = true; |
| 1741 | } |
| 1742 | |
Dmitry Eremin-Solenikov | 9a801f2 | 2012-03-19 21:50:13 +0400 | [diff] [blame] | 1743 | XGIRegInit(&xgifb_info->dev_info, xgifb_info->vga_base); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1744 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1745 | xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); |
| 1746 | reg1 = xgifb_reg_get(XGISR, IND_SIS_PASSWORD); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1747 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1748 | if (reg1 != 0xa1) { /*I/O error */ |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1749 | dev_err(&pdev->dev, "I/O error\n"); |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1750 | ret = -EIO; |
Miguel Gómez | 05e0603 | 2012-06-06 16:22:06 +0200 | [diff] [blame] | 1751 | goto error_disable; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1752 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1753 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1754 | switch (xgifb_info->chip_id) { |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1755 | case PCI_DEVICE_ID_XGI_20: |
Aaro Koskinen | e67f4d4 | 2011-04-18 22:14:00 +0300 | [diff] [blame] | 1756 | xgifb_reg_or(XGICR, Index_CR_GPIO_Reg3, GPIOG_EN); |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1757 | CR48 = xgifb_reg_get(XGICR, Index_CR_GPIO_Reg1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1758 | if (CR48&GPIOG_READ) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1759 | xgifb_info->chip = XG21; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1760 | else |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1761 | xgifb_info->chip = XG20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1762 | break; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1763 | case PCI_DEVICE_ID_XGI_40: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1764 | xgifb_info->chip = XG40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1765 | break; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1766 | case PCI_DEVICE_ID_XGI_42: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1767 | xgifb_info->chip = XG42; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1768 | break; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1769 | case PCI_DEVICE_ID_XGI_27: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1770 | xgifb_info->chip = XG27; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1771 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1772 | default: |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1773 | ret = -ENODEV; |
Miguel Gómez | 05e0603 | 2012-06-06 16:22:06 +0200 | [diff] [blame] | 1774 | goto error_disable; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1775 | } |
| 1776 | |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1777 | dev_info(&pdev->dev, "chipid = %x\n", xgifb_info->chip); |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1778 | hw_info->jChipType = xgifb_info->chip; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1779 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1780 | if (XGIfb_get_dram_size(xgifb_info)) { |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1781 | dev_err(&pdev->dev, |
| 1782 | "Fatal error: Unable to determine RAM size.\n"); |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1783 | ret = -ENODEV; |
Miguel Gómez | 05e0603 | 2012-06-06 16:22:06 +0200 | [diff] [blame] | 1784 | goto error_disable; |
Aaro Koskinen | 6b2a7e0 | 2012-09-12 00:44:38 +0300 | [diff] [blame^] | 1785 | } else if (xgifb_info->video_size > video_size_max) { |
| 1786 | xgifb_info->video_size = video_size_max; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1787 | } |
| 1788 | |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1789 | /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ |
| 1790 | xgifb_reg_or(XGISR, |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1791 | IND_SIS_PCI_ADDRESS_SET, |
| 1792 | (SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE)); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1793 | /* Enable 2D accelerator engine */ |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1794 | xgifb_reg_or(XGISR, IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1795 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1796 | hw_info->ulVideoMemorySize = xgifb_info->video_size; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1797 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1798 | if (!request_mem_region(xgifb_info->video_base, |
| 1799 | xgifb_info->video_size, |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1800 | "XGIfb FB")) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1801 | dev_err(&pdev->dev, "Unable request memory size %x\n", |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1802 | xgifb_info->video_size); |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1803 | dev_err(&pdev->dev, |
| 1804 | "Fatal error: Unable to reserve frame buffer memory. " |
| 1805 | "Is there another framebuffer driver active?\n"); |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1806 | ret = -ENODEV; |
Miguel Gómez | 05e0603 | 2012-06-06 16:22:06 +0200 | [diff] [blame] | 1807 | goto error_disable; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1808 | } |
| 1809 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1810 | if (!request_mem_region(xgifb_info->mmio_base, |
| 1811 | xgifb_info->mmio_size, |
Aaro Koskinen | 1b3909e | 2011-02-17 23:29:17 +0200 | [diff] [blame] | 1812 | "XGIfb MMIO")) { |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1813 | dev_err(&pdev->dev, |
| 1814 | "Fatal error: Unable to reserve MMIO region\n"); |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1815 | ret = -ENODEV; |
Aaro Koskinen | 5c0ef2a | 2011-02-17 23:29:15 +0200 | [diff] [blame] | 1816 | goto error_0; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1817 | } |
| 1818 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1819 | xgifb_info->video_vbase = hw_info->pjVideoMemoryAddress = |
| 1820 | ioremap(xgifb_info->video_base, xgifb_info->video_size); |
| 1821 | xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base, |
| 1822 | xgifb_info->mmio_size); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1823 | |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1824 | dev_info(&pdev->dev, |
| 1825 | "Framebuffer at 0x%Lx, mapped to 0x%p, size %dk\n", |
| 1826 | (u64) xgifb_info->video_base, |
| 1827 | xgifb_info->video_vbase, |
| 1828 | xgifb_info->video_size / 1024); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1829 | |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1830 | dev_info(&pdev->dev, |
| 1831 | "MMIO at 0x%Lx, mapped to 0x%p, size %ldk\n", |
| 1832 | (u64) xgifb_info->mmio_base, xgifb_info->mmio_vbase, |
| 1833 | xgifb_info->mmio_size / 1024); |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1834 | |
Aaro Koskinen | fcbdda9 | 2011-10-11 21:47:20 +0300 | [diff] [blame] | 1835 | pci_set_drvdata(pdev, xgifb_info); |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1836 | if (!XGIInitNew(pdev)) |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1837 | dev_err(&pdev->dev, "XGIInitNew() failed!\n"); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1838 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1839 | xgifb_info->mtrr = (unsigned int) 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1840 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1841 | xgifb_info->hasVB = HASVB_NONE; |
| 1842 | if ((xgifb_info->chip == XG20) || |
| 1843 | (xgifb_info->chip == XG27)) { |
| 1844 | xgifb_info->hasVB = HASVB_NONE; |
| 1845 | } else if (xgifb_info->chip == XG21) { |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1846 | CR38 = xgifb_reg_get(XGICR, 0x38); |
Sam Hansen | cae9a7b | 2012-01-22 16:48:51 -0800 | [diff] [blame] | 1847 | if ((CR38&0xE0) == 0xC0) |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1848 | xgifb_info->display2 = XGIFB_DISP_LCD; |
Sam Hansen | cae9a7b | 2012-01-22 16:48:51 -0800 | [diff] [blame] | 1849 | else if ((CR38&0xE0) == 0x60) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1850 | xgifb_info->hasVB = HASVB_CHRONTEL; |
Sam Hansen | cae9a7b | 2012-01-22 16:48:51 -0800 | [diff] [blame] | 1851 | else |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1852 | xgifb_info->hasVB = HASVB_NONE; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1853 | } else { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1854 | XGIfb_get_VB_type(xgifb_info); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1855 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1856 | |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1857 | hw_info->ujVBChipID = VB_CHIP_UNKNOWN; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1858 | |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1859 | hw_info->ulExternalChip = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1860 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1861 | switch (xgifb_info->hasVB) { |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1862 | case HASVB_301: |
| 1863 | reg = xgifb_reg_get(XGIPART4, 0x01); |
| 1864 | if (reg >= 0xE0) { |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1865 | hw_info->ujVBChipID = VB_CHIP_302LV; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1866 | dev_info(&pdev->dev, |
| 1867 | "XGI302LV bridge detected (revision 0x%02x)\n", |
| 1868 | reg); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1869 | } else if (reg >= 0xD0) { |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1870 | hw_info->ujVBChipID = VB_CHIP_301LV; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1871 | dev_info(&pdev->dev, |
| 1872 | "XGI301LV bridge detected (revision 0x%02x)\n", |
| 1873 | reg); |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1874 | } else { |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1875 | hw_info->ujVBChipID = VB_CHIP_301; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1876 | dev_info(&pdev->dev, "XGI301 bridge detected\n"); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1877 | } |
| 1878 | break; |
| 1879 | case HASVB_302: |
| 1880 | reg = xgifb_reg_get(XGIPART4, 0x01); |
| 1881 | if (reg >= 0xE0) { |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1882 | hw_info->ujVBChipID = VB_CHIP_302LV; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1883 | dev_info(&pdev->dev, |
| 1884 | "XGI302LV bridge detected (revision 0x%02x)\n", |
| 1885 | reg); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1886 | } else if (reg >= 0xD0) { |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1887 | hw_info->ujVBChipID = VB_CHIP_301LV; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1888 | dev_info(&pdev->dev, |
| 1889 | "XGI302LV bridge detected (revision 0x%02x)\n", |
| 1890 | reg); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1891 | } else if (reg >= 0xB0) { |
| 1892 | reg1 = xgifb_reg_get(XGIPART4, 0x23); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1893 | |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1894 | hw_info->ujVBChipID = VB_CHIP_302B; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1895 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1896 | } else { |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1897 | hw_info->ujVBChipID = VB_CHIP_302; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1898 | dev_info(&pdev->dev, "XGI302 bridge detected\n"); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1899 | } |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1900 | break; |
| 1901 | case HASVB_LVDS: |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1902 | hw_info->ulExternalChip = 0x1; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1903 | dev_info(&pdev->dev, "LVDS transmitter detected\n"); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1904 | break; |
| 1905 | case HASVB_TRUMPION: |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1906 | hw_info->ulExternalChip = 0x2; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1907 | dev_info(&pdev->dev, "Trumpion Zurac LVDS scaler detected\n"); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1908 | break; |
| 1909 | case HASVB_CHRONTEL: |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1910 | hw_info->ulExternalChip = 0x4; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1911 | dev_info(&pdev->dev, "Chrontel TV encoder detected\n"); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1912 | break; |
| 1913 | case HASVB_LVDS_CHRONTEL: |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1914 | hw_info->ulExternalChip = 0x5; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1915 | dev_info(&pdev->dev, |
| 1916 | "LVDS transmitter and Chrontel TV encoder detected\n"); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1917 | break; |
| 1918 | default: |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1919 | dev_info(&pdev->dev, "No or unknown bridge type detected\n"); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1920 | break; |
| 1921 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1922 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1923 | if (xgifb_info->hasVB != HASVB_NONE) |
| 1924 | XGIfb_detect_VB(xgifb_info); |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1925 | else if (xgifb_info->chip != XG21) |
| 1926 | xgifb_info->display2 = XGIFB_DISP_NONE; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1927 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1928 | if (xgifb_info->display2 == XGIFB_DISP_LCD) { |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1929 | if (!enable_dstn) { |
| 1930 | reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL); |
| 1931 | reg &= 0x0f; |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 1932 | hw_info->ulCRT2LCDType = XGI310paneltype[reg]; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1933 | } |
| 1934 | } |
| 1935 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1936 | xgifb_info->mode_idx = -1; |
| 1937 | |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1938 | if (mode) |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1939 | XGIfb_search_mode(xgifb_info, mode); |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1940 | else if (vesa != -1) |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1941 | XGIfb_search_vesamode(xgifb_info, vesa); |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1942 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1943 | if (xgifb_info->mode_idx >= 0) |
| 1944 | xgifb_info->mode_idx = |
| 1945 | XGIfb_validate_mode(xgifb_info, xgifb_info->mode_idx); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1946 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1947 | if (xgifb_info->mode_idx < 0) { |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1948 | if (xgifb_info->display2 == XGIFB_DISP_LCD && |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1949 | xgifb_info->chip == XG21) |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1950 | xgifb_info->mode_idx = |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 1951 | XGIfb_GetXG21DefaultLVDSModeIdx(xgifb_info); |
Aaro Koskinen | c8bec1f | 2011-08-29 23:14:30 +0300 | [diff] [blame] | 1952 | else |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1953 | xgifb_info->mode_idx = DEFAULT_MODE; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1954 | } |
| 1955 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1956 | if (xgifb_info->mode_idx < 0) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1957 | dev_err(&pdev->dev, "No supported video mode found\n"); |
Aaro Koskinen | de736db | 2011-08-29 23:14:29 +0300 | [diff] [blame] | 1958 | goto error_1; |
| 1959 | } |
| 1960 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1961 | /* set default refresh rate */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1962 | xgifb_info->refresh_rate = refresh_rate; |
| 1963 | if (xgifb_info->refresh_rate == 0) |
| 1964 | xgifb_info->refresh_rate = 60; |
| 1965 | if (XGIfb_search_refresh_rate(xgifb_info, |
| 1966 | xgifb_info->refresh_rate) == 0) { |
Aaro Koskinen | f47f12d | 2012-04-07 01:13:54 +0300 | [diff] [blame] | 1967 | xgifb_info->rate_idx = 1; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1968 | xgifb_info->refresh_rate = 60; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1969 | } |
| 1970 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1971 | xgifb_info->video_bpp = XGIbios_mode[xgifb_info->mode_idx].bpp; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1972 | xgifb_info->video_vwidth = |
| 1973 | xgifb_info->video_width = |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1974 | XGIbios_mode[xgifb_info->mode_idx].xres; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1975 | xgifb_info->video_vheight = |
| 1976 | xgifb_info->video_height = |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1977 | XGIbios_mode[xgifb_info->mode_idx].yres; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1978 | xgifb_info->org_x = xgifb_info->org_y = 0; |
| 1979 | xgifb_info->video_linelength = |
| 1980 | xgifb_info->video_width * |
| 1981 | (xgifb_info->video_bpp >> 3); |
| 1982 | switch (xgifb_info->video_bpp) { |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1983 | case 8: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1984 | xgifb_info->DstColor = 0x0000; |
| 1985 | xgifb_info->XGI310_AccelDepth = 0x00000000; |
| 1986 | xgifb_info->video_cmap_len = 256; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1987 | break; |
| 1988 | case 16: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1989 | xgifb_info->DstColor = 0x8000; |
| 1990 | xgifb_info->XGI310_AccelDepth = 0x00010000; |
| 1991 | xgifb_info->video_cmap_len = 16; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1992 | break; |
| 1993 | case 32: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1994 | xgifb_info->DstColor = 0xC000; |
| 1995 | xgifb_info->XGI310_AccelDepth = 0x00020000; |
| 1996 | xgifb_info->video_cmap_len = 16; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 1997 | break; |
| 1998 | default: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1999 | xgifb_info->video_cmap_len = 16; |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 2000 | pr_info("Unsupported depth %d\n", |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 2001 | xgifb_info->video_bpp); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2002 | break; |
| 2003 | } |
| 2004 | |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 2005 | pr_info("Default mode is %dx%dx%d (%dHz)\n", |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 2006 | xgifb_info->video_width, |
| 2007 | xgifb_info->video_height, |
| 2008 | xgifb_info->video_bpp, |
| 2009 | xgifb_info->refresh_rate); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2010 | |
Aaro Koskinen | e9865d4 | 2011-10-11 21:47:26 +0300 | [diff] [blame] | 2011 | fb_info->var.red.length = 8; |
| 2012 | fb_info->var.green.length = 8; |
| 2013 | fb_info->var.blue.length = 8; |
| 2014 | fb_info->var.activate = FB_ACTIVATE_NOW; |
| 2015 | fb_info->var.height = -1; |
| 2016 | fb_info->var.width = -1; |
| 2017 | fb_info->var.vmode = FB_VMODE_NONINTERLACED; |
| 2018 | fb_info->var.xres = xgifb_info->video_width; |
| 2019 | fb_info->var.xres_virtual = xgifb_info->video_width; |
| 2020 | fb_info->var.yres = xgifb_info->video_height; |
| 2021 | fb_info->var.yres_virtual = xgifb_info->video_height; |
| 2022 | fb_info->var.bits_per_pixel = xgifb_info->video_bpp; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2023 | |
Aaro Koskinen | e9865d4 | 2011-10-11 21:47:26 +0300 | [diff] [blame] | 2024 | XGIfb_bpp_to_var(xgifb_info, &fb_info->var); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2025 | |
Aaro Koskinen | e9865d4 | 2011-10-11 21:47:26 +0300 | [diff] [blame] | 2026 | fb_info->var.pixclock = (u32) (1000000000 / |
Aaro Koskinen | f2df8c0 | 2011-10-11 21:47:30 +0300 | [diff] [blame] | 2027 | XGIfb_mode_rate_to_dclock(&xgifb_info->dev_info, |
| 2028 | hw_info, |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 2029 | XGIbios_mode[xgifb_info->mode_idx].mode_no, |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 2030 | xgifb_info->rate_idx)); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2031 | |
Aaro Koskinen | f2df8c0 | 2011-10-11 21:47:30 +0300 | [diff] [blame] | 2032 | if (XGIfb_mode_rate_to_ddata(&xgifb_info->dev_info, hw_info, |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 2033 | XGIbios_mode[xgifb_info->mode_idx].mode_no, |
| 2034 | xgifb_info->rate_idx, |
Aaro Koskinen | e9865d4 | 2011-10-11 21:47:26 +0300 | [diff] [blame] | 2035 | &fb_info->var.left_margin, |
| 2036 | &fb_info->var.right_margin, |
| 2037 | &fb_info->var.upper_margin, |
| 2038 | &fb_info->var.lower_margin, |
| 2039 | &fb_info->var.hsync_len, |
| 2040 | &fb_info->var.vsync_len, |
| 2041 | &fb_info->var.sync, |
| 2042 | &fb_info->var.vmode)) { |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2043 | |
Aaro Koskinen | e9865d4 | 2011-10-11 21:47:26 +0300 | [diff] [blame] | 2044 | if ((fb_info->var.vmode & FB_VMODE_MASK) == |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2045 | FB_VMODE_INTERLACED) { |
Aaro Koskinen | e9865d4 | 2011-10-11 21:47:26 +0300 | [diff] [blame] | 2046 | fb_info->var.yres <<= 1; |
| 2047 | fb_info->var.yres_virtual <<= 1; |
| 2048 | } else if ((fb_info->var.vmode & FB_VMODE_MASK) == |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2049 | FB_VMODE_DOUBLE) { |
Aaro Koskinen | e9865d4 | 2011-10-11 21:47:26 +0300 | [diff] [blame] | 2050 | fb_info->var.pixclock >>= 1; |
| 2051 | fb_info->var.yres >>= 1; |
| 2052 | fb_info->var.yres_virtual >>= 1; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2053 | } |
| 2054 | |
| 2055 | } |
| 2056 | |
| 2057 | fb_info->flags = FBINFO_FLAG_DEFAULT; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 2058 | fb_info->screen_base = xgifb_info->video_vbase; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2059 | fb_info->fbops = &XGIfb_ops; |
| 2060 | XGIfb_get_fix(&fb_info->fix, -1, fb_info); |
Aaro Koskinen | 76cabaa | 2011-10-11 21:47:24 +0300 | [diff] [blame] | 2061 | fb_info->pseudo_palette = xgifb_info->pseudo_palette; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2062 | |
| 2063 | fb_alloc_cmap(&fb_info->cmap, 256 , 0); |
| 2064 | |
| 2065 | #ifdef CONFIG_MTRR |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 2066 | xgifb_info->mtrr = mtrr_add(xgifb_info->video_base, |
| 2067 | xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1); |
| 2068 | if (xgifb_info->mtrr >= 0) |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 2069 | dev_info(&pdev->dev, "Added MTRR\n"); |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2070 | #endif |
| 2071 | |
| 2072 | if (register_framebuffer(fb_info) < 0) { |
| 2073 | ret = -EINVAL; |
Aaro Koskinen | 3028474 | 2011-09-11 00:29:53 +0300 | [diff] [blame] | 2074 | goto error_mtrr; |
Aaro Koskinen | e1521a1 | 2011-08-19 22:40:26 +0300 | [diff] [blame] | 2075 | } |
| 2076 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2077 | dumpVGAReg(); |
| 2078 | |
| 2079 | return 0; |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 2080 | |
Aaro Koskinen | 3028474 | 2011-09-11 00:29:53 +0300 | [diff] [blame] | 2081 | error_mtrr: |
| 2082 | #ifdef CONFIG_MTRR |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 2083 | if (xgifb_info->mtrr >= 0) |
| 2084 | mtrr_del(xgifb_info->mtrr, xgifb_info->video_base, |
| 2085 | xgifb_info->video_size); |
Aaro Koskinen | 3028474 | 2011-09-11 00:29:53 +0300 | [diff] [blame] | 2086 | #endif /* CONFIG_MTRR */ |
Aaro Koskinen | 5c0ef2a | 2011-02-17 23:29:15 +0200 | [diff] [blame] | 2087 | error_1: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 2088 | iounmap(xgifb_info->mmio_vbase); |
| 2089 | iounmap(xgifb_info->video_vbase); |
| 2090 | release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size); |
Aaro Koskinen | 5c0ef2a | 2011-02-17 23:29:15 +0200 | [diff] [blame] | 2091 | error_0: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 2092 | release_mem_region(xgifb_info->video_base, xgifb_info->video_size); |
Miguel Gómez | 05e0603 | 2012-06-06 16:22:06 +0200 | [diff] [blame] | 2093 | error_disable: |
| 2094 | pci_disable_device(pdev); |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 2095 | error: |
| 2096 | framebuffer_release(fb_info); |
| 2097 | return ret; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2098 | } |
| 2099 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2100 | /*****************************************************/ |
| 2101 | /* PCI DEVICE HANDLING */ |
| 2102 | /*****************************************************/ |
| 2103 | |
| 2104 | static void __devexit xgifb_remove(struct pci_dev *pdev) |
| 2105 | { |
Aaro Koskinen | ab886ff | 2011-10-11 21:47:18 +0300 | [diff] [blame] | 2106 | struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev); |
Aaro Koskinen | 19c1e88 | 2011-10-11 21:47:14 +0300 | [diff] [blame] | 2107 | struct fb_info *fb_info = xgifb_info->fb_info; |
Aaro Koskinen | 54301b5 | 2011-10-11 21:47:13 +0300 | [diff] [blame] | 2108 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 2109 | unregister_framebuffer(fb_info); |
Aaro Koskinen | 3028474 | 2011-09-11 00:29:53 +0300 | [diff] [blame] | 2110 | #ifdef CONFIG_MTRR |
Aaro Koskinen | 54301b5 | 2011-10-11 21:47:13 +0300 | [diff] [blame] | 2111 | if (xgifb_info->mtrr >= 0) |
| 2112 | mtrr_del(xgifb_info->mtrr, xgifb_info->video_base, |
| 2113 | xgifb_info->video_size); |
Aaro Koskinen | 3028474 | 2011-09-11 00:29:53 +0300 | [diff] [blame] | 2114 | #endif /* CONFIG_MTRR */ |
Aaro Koskinen | 54301b5 | 2011-10-11 21:47:13 +0300 | [diff] [blame] | 2115 | iounmap(xgifb_info->mmio_vbase); |
| 2116 | iounmap(xgifb_info->video_vbase); |
| 2117 | release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size); |
| 2118 | release_mem_region(xgifb_info->video_base, xgifb_info->video_size); |
Miguel Gómez | bf55b48 | 2012-06-06 16:22:07 +0200 | [diff] [blame] | 2119 | pci_disable_device(pdev); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 2120 | framebuffer_release(fb_info); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2121 | pci_set_drvdata(pdev, NULL); |
Aaro Koskinen | 45dcfaf | 2011-02-17 23:29:16 +0200 | [diff] [blame] | 2122 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2123 | |
| 2124 | static struct pci_driver xgifb_driver = { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 2125 | .name = "xgifb", |
| 2126 | .id_table = xgifb_pci_table, |
| 2127 | .probe = xgifb_probe, |
| 2128 | .remove = __devexit_p(xgifb_remove) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2129 | }; |
| 2130 | |
Miguel Gómez | d049053 | 2012-06-06 16:22:05 +0200 | [diff] [blame] | 2131 | |
| 2132 | |
| 2133 | /*****************************************************/ |
| 2134 | /* MODULE */ |
| 2135 | /*****************************************************/ |
| 2136 | |
| 2137 | module_param(mode, charp, 0); |
| 2138 | MODULE_PARM_DESC(mode, |
Miguel Gómez | 560e878 | 2012-06-18 13:11:59 +0200 | [diff] [blame] | 2139 | "Selects the desired default display mode in the format XxYxDepth " |
| 2140 | "(eg. 1024x768x16)."); |
Miguel Gómez | d049053 | 2012-06-06 16:22:05 +0200 | [diff] [blame] | 2141 | |
| 2142 | module_param(forcecrt2type, charp, 0); |
| 2143 | MODULE_PARM_DESC(forcecrt2type, |
Miguel Gómez | 560e878 | 2012-06-18 13:11:59 +0200 | [diff] [blame] | 2144 | "Force the second display output type. Possible values are NONE, " |
| 2145 | "LCD, TV, VGA, SVIDEO or COMPOSITE."); |
Miguel Gómez | d049053 | 2012-06-06 16:22:05 +0200 | [diff] [blame] | 2146 | |
| 2147 | module_param(vesa, int, 0); |
| 2148 | MODULE_PARM_DESC(vesa, |
Miguel Gómez | 560e878 | 2012-06-18 13:11:59 +0200 | [diff] [blame] | 2149 | "Selects the desired default display mode by VESA mode number " |
| 2150 | "(eg. 0x117)."); |
Miguel Gómez | d049053 | 2012-06-06 16:22:05 +0200 | [diff] [blame] | 2151 | |
| 2152 | module_param(filter, int, 0); |
| 2153 | MODULE_PARM_DESC(filter, |
Miguel Gómez | 560e878 | 2012-06-18 13:11:59 +0200 | [diff] [blame] | 2154 | "Selects TV flicker filter type (only for systems with a SiS301 video bridge). " |
| 2155 | "Possible values 0-7. Default: [no filter])."); |
Miguel Gómez | d049053 | 2012-06-06 16:22:05 +0200 | [diff] [blame] | 2156 | |
Ruslan Pisarev | 032abf7 | 2011-07-21 11:59:11 +0300 | [diff] [blame] | 2157 | static int __init xgifb_init(void) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2158 | { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2159 | char *option = NULL; |
| 2160 | |
Aaro Koskinen | 2d2c880 | 2011-12-06 00:10:49 +0200 | [diff] [blame] | 2161 | if (forcecrt2type != NULL) |
| 2162 | XGIfb_search_crt2type(forcecrt2type); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2163 | if (fb_get_options("xgifb", &option)) |
| 2164 | return -ENODEV; |
| 2165 | XGIfb_setup(option); |
Javier Martinez Canillas | 328f55b | 2010-09-08 00:07:57 -0400 | [diff] [blame] | 2166 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 2167 | return pci_register_driver(&xgifb_driver); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2168 | } |
| 2169 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2170 | static void __exit xgifb_remove_module(void) |
| 2171 | { |
| 2172 | pci_unregister_driver(&xgifb_driver); |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 2173 | pr_debug("Module unloaded\n"); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2174 | } |
| 2175 | |
Miguel Gómez | d049053 | 2012-06-06 16:22:05 +0200 | [diff] [blame] | 2176 | MODULE_DESCRIPTION("Z7 Z9 Z9S Z11 framebuffer device driver"); |
| 2177 | MODULE_LICENSE("GPL"); |
| 2178 | MODULE_AUTHOR("XGITECH , Others"); |
| 2179 | module_init(xgifb_init); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 2180 | module_exit(xgifb_remove_module); |