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 | { |
| 308 | int i = 0, j = 0; |
| 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; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 319 | j = 1; |
| 320 | break; |
| 321 | } |
| 322 | i++; |
| 323 | } |
Aaro Koskinen | c322830 | 2011-08-29 23:14:32 +0300 | [diff] [blame] | 324 | |
| 325 | invalid: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 326 | if (!j) |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 327 | pr_info("Invalid VESA mode 0x%x'\n", vesamode); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 328 | } |
| 329 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 330 | 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] | 331 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 332 | u16 xres, yres; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 333 | struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 334 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 335 | if (xgifb_info->chip == XG21) { |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 336 | if (xgifb_info->display2 == XGIFB_DISP_LCD) { |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 337 | xres = xgifb_info->lvds_data.LVDSHDE; |
| 338 | yres = xgifb_info->lvds_data.LVDSVDE; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 339 | if (XGIbios_mode[myindex].xres > xres) |
| 340 | return -1; |
| 341 | if (XGIbios_mode[myindex].yres > yres) |
| 342 | return -1; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 343 | if ((XGIbios_mode[myindex].xres < xres) && |
| 344 | (XGIbios_mode[myindex].yres < yres)) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 345 | if (XGIbios_mode[myindex].bpp > 8) |
| 346 | return -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 347 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 348 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 349 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 350 | return myindex; |
| 351 | |
| 352 | } |
| 353 | |
| 354 | /* FIXME: for now, all is valid on XG27 */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 355 | if (xgifb_info->chip == XG27) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 356 | return myindex; |
| 357 | |
| 358 | if (!(XGIbios_mode[myindex].chipset & MD_XGI315)) |
| 359 | return -1; |
| 360 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 361 | switch (xgifb_info->display2) { |
| 362 | case XGIFB_DISP_LCD: |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 363 | switch (hw_info->ulCRT2LCDType) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 364 | case LCD_640x480: |
| 365 | xres = 640; |
| 366 | yres = 480; |
| 367 | break; |
| 368 | case LCD_800x600: |
| 369 | xres = 800; |
| 370 | yres = 600; |
| 371 | break; |
| 372 | case LCD_1024x600: |
| 373 | xres = 1024; |
| 374 | yres = 600; |
| 375 | break; |
| 376 | case LCD_1024x768: |
| 377 | xres = 1024; |
| 378 | yres = 768; |
| 379 | break; |
| 380 | case LCD_1152x768: |
| 381 | xres = 1152; |
| 382 | yres = 768; |
| 383 | break; |
| 384 | case LCD_1280x960: |
| 385 | xres = 1280; |
| 386 | yres = 960; |
| 387 | break; |
| 388 | case LCD_1280x768: |
| 389 | xres = 1280; |
| 390 | yres = 768; |
| 391 | break; |
| 392 | case LCD_1280x1024: |
| 393 | xres = 1280; |
| 394 | yres = 1024; |
| 395 | break; |
| 396 | case LCD_1400x1050: |
| 397 | xres = 1400; |
| 398 | yres = 1050; |
| 399 | break; |
| 400 | case LCD_1600x1200: |
| 401 | xres = 1600; |
| 402 | yres = 1200; |
| 403 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 404 | default: |
| 405 | xres = 0; |
| 406 | yres = 0; |
| 407 | break; |
| 408 | } |
| 409 | if (XGIbios_mode[myindex].xres > xres) |
| 410 | return -1; |
| 411 | if (XGIbios_mode[myindex].yres > yres) |
| 412 | return -1; |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 413 | if ((hw_info->ulExternalChip == 0x01) || /* LVDS */ |
| 414 | (hw_info->ulExternalChip == 0x05)) { /* LVDS+Chrontel */ |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 415 | switch (XGIbios_mode[myindex].xres) { |
| 416 | case 512: |
| 417 | if (XGIbios_mode[myindex].yres != 512) |
| 418 | return -1; |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 419 | if (hw_info->ulCRT2LCDType == LCD_1024x600) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 420 | return -1; |
| 421 | break; |
| 422 | case 640: |
| 423 | if ((XGIbios_mode[myindex].yres != 400) |
| 424 | && (XGIbios_mode[myindex].yres |
| 425 | != 480)) |
| 426 | return -1; |
| 427 | break; |
| 428 | case 800: |
| 429 | if (XGIbios_mode[myindex].yres != 600) |
| 430 | return -1; |
| 431 | break; |
| 432 | case 1024: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 433 | if ((XGIbios_mode[myindex].yres != 600) && |
| 434 | (XGIbios_mode[myindex].yres != 768)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 435 | return -1; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 436 | if ((XGIbios_mode[myindex].yres == 600) && |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 437 | (hw_info->ulCRT2LCDType != LCD_1024x600)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 438 | return -1; |
| 439 | break; |
| 440 | case 1152: |
| 441 | if ((XGIbios_mode[myindex].yres) != 768) |
| 442 | return -1; |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 443 | if (hw_info->ulCRT2LCDType != LCD_1152x768) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 444 | return -1; |
| 445 | break; |
| 446 | case 1280: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 447 | if ((XGIbios_mode[myindex].yres != 768) && |
| 448 | (XGIbios_mode[myindex].yres != 1024)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 449 | return -1; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 450 | if ((XGIbios_mode[myindex].yres == 768) && |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 451 | (hw_info->ulCRT2LCDType != LCD_1280x768)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 452 | return -1; |
| 453 | break; |
| 454 | case 1400: |
| 455 | if (XGIbios_mode[myindex].yres != 1050) |
| 456 | return -1; |
| 457 | break; |
| 458 | case 1600: |
| 459 | if (XGIbios_mode[myindex].yres != 1200) |
| 460 | return -1; |
| 461 | break; |
| 462 | default: |
| 463 | return -1; |
| 464 | } |
| 465 | } else { |
| 466 | switch (XGIbios_mode[myindex].xres) { |
| 467 | case 512: |
| 468 | if (XGIbios_mode[myindex].yres != 512) |
| 469 | return -1; |
| 470 | break; |
| 471 | case 640: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 472 | if ((XGIbios_mode[myindex].yres != 400) && |
| 473 | (XGIbios_mode[myindex].yres != 480)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 474 | return -1; |
| 475 | break; |
| 476 | case 800: |
| 477 | if (XGIbios_mode[myindex].yres != 600) |
| 478 | return -1; |
| 479 | break; |
| 480 | case 1024: |
| 481 | if (XGIbios_mode[myindex].yres != 768) |
| 482 | return -1; |
| 483 | break; |
| 484 | case 1280: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 485 | if ((XGIbios_mode[myindex].yres != 960) && |
| 486 | (XGIbios_mode[myindex].yres != 1024)) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 487 | return -1; |
| 488 | if (XGIbios_mode[myindex].yres == 960) { |
Aaro Koskinen | c62f2e4 | 2011-10-11 21:47:15 +0300 | [diff] [blame] | 489 | if (hw_info->ulCRT2LCDType == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 490 | LCD_1400x1050) |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 491 | return -1; |
| 492 | } |
| 493 | break; |
| 494 | case 1400: |
| 495 | if (XGIbios_mode[myindex].yres != 1050) |
| 496 | return -1; |
| 497 | break; |
| 498 | case 1600: |
| 499 | if (XGIbios_mode[myindex].yres != 1200) |
| 500 | return -1; |
| 501 | break; |
| 502 | default: |
| 503 | return -1; |
| 504 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 505 | } |
| 506 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 507 | case XGIFB_DISP_TV: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 508 | switch (XGIbios_mode[myindex].xres) { |
| 509 | case 512: |
| 510 | case 640: |
| 511 | case 800: |
| 512 | break; |
| 513 | case 720: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 514 | if (xgifb_info->TV_type == TVMODE_NTSC) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 515 | if (XGIbios_mode[myindex].yres != 480) |
| 516 | return -1; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 517 | } else if (xgifb_info->TV_type == TVMODE_PAL) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 518 | if (XGIbios_mode[myindex].yres != 576) |
| 519 | return -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 520 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 521 | /* LVDS/CHRONTEL does not support 720 */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 522 | if (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL || |
| 523 | xgifb_info->hasVB == HASVB_CHRONTEL) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 524 | return -1; |
| 525 | } |
| 526 | break; |
| 527 | case 1024: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 528 | if (xgifb_info->TV_type == TVMODE_NTSC) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 529 | if (XGIbios_mode[myindex].bpp == 32) |
| 530 | return -1; |
| 531 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 532 | break; |
| 533 | default: |
| 534 | return -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 535 | } |
| 536 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 537 | case XGIFB_DISP_CRT: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 538 | if (XGIbios_mode[myindex].xres > 1280) |
| 539 | return -1; |
| 540 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 541 | case XGIFB_DISP_NONE: |
| 542 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 543 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 544 | return myindex; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 545 | |
| 546 | } |
| 547 | |
| 548 | static void XGIfb_search_crt2type(const char *name) |
| 549 | { |
| 550 | int i = 0; |
| 551 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 552 | if (name == NULL) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 553 | return; |
| 554 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 555 | while (XGI_crt2type[i].type_no != -1) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 556 | if (!strcmp(name, XGI_crt2type[i].name)) { |
| 557 | XGIfb_crt2type = XGI_crt2type[i].type_no; |
| 558 | XGIfb_tvplug = XGI_crt2type[i].tvplug_no; |
| 559 | break; |
| 560 | } |
| 561 | i++; |
| 562 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 563 | if (XGIfb_crt2type < 0) |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 564 | pr_info("Invalid CRT2 type: %s\n", name); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 565 | } |
| 566 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 567 | static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info, |
| 568 | unsigned int rate) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 569 | { |
| 570 | u16 xres, yres; |
| 571 | int i = 0; |
| 572 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 573 | xres = XGIbios_mode[xgifb_info->mode_idx].xres; |
| 574 | yres = XGIbios_mode[xgifb_info->mode_idx].yres; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 575 | |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 576 | xgifb_info->rate_idx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 577 | while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) { |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 578 | if ((XGIfb_vrate[i].xres == xres) && |
| 579 | (XGIfb_vrate[i].yres == yres)) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 580 | if (XGIfb_vrate[i].refresh == rate) { |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 581 | xgifb_info->rate_idx = XGIfb_vrate[i].idx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 582 | break; |
| 583 | } else if (XGIfb_vrate[i].refresh > rate) { |
| 584 | if ((XGIfb_vrate[i].refresh - rate) <= 3) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 585 | pr_debug("Adjusting rate from %d up to %d\n", |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 586 | rate, XGIfb_vrate[i].refresh); |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 587 | xgifb_info->rate_idx = |
| 588 | XGIfb_vrate[i].idx; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 589 | xgifb_info->refresh_rate = |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 590 | XGIfb_vrate[i].refresh; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 591 | } else if (((rate - XGIfb_vrate[i - 1].refresh) |
| 592 | <= 2) && (XGIfb_vrate[i].idx |
| 593 | != 1)) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 594 | pr_debug("Adjusting rate from %d down to %d\n", |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 595 | rate, XGIfb_vrate[i-1].refresh); |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 596 | xgifb_info->rate_idx = |
| 597 | XGIfb_vrate[i - 1].idx; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 598 | xgifb_info->refresh_rate = |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 599 | XGIfb_vrate[i - 1].refresh; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 600 | } |
| 601 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 602 | } else if ((rate - XGIfb_vrate[i].refresh) <= 2) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 603 | pr_debug("Adjusting rate from %d down to %d\n", |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 604 | rate, XGIfb_vrate[i].refresh); |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 605 | xgifb_info->rate_idx = XGIfb_vrate[i].idx; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 606 | break; |
| 607 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 608 | } |
| 609 | i++; |
| 610 | } |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 611 | if (xgifb_info->rate_idx > 0) { |
| 612 | return xgifb_info->rate_idx; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 613 | } else { |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 614 | pr_info("Unsupported rate %d for %dx%d\n", |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 615 | rate, xres, yres); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 616 | return 0; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | static void XGIfb_search_tvstd(const char *name) |
| 621 | { |
| 622 | int i = 0; |
| 623 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 624 | if (name == NULL) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 625 | return; |
| 626 | |
| 627 | while (XGI_tvtype[i].type_no != -1) { |
| 628 | if (!strcmp(name, XGI_tvtype[i].name)) { |
| 629 | XGIfb_tvmode = XGI_tvtype[i].type_no; |
| 630 | break; |
| 631 | } |
| 632 | i++; |
| 633 | } |
| 634 | } |
| 635 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 636 | /* ----------- FBDev related routines for all series ----------- */ |
| 637 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 638 | static void XGIfb_bpp_to_var(struct xgifb_video_info *xgifb_info, |
| 639 | struct fb_var_screeninfo *var) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 640 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 641 | switch (var->bits_per_pixel) { |
| 642 | case 8: |
| 643 | var->red.offset = var->green.offset = var->blue.offset = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 644 | var->red.length = var->green.length = var->blue.length = 6; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 645 | xgifb_info->video_cmap_len = 256; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 646 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 647 | case 16: |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 648 | var->red.offset = 11; |
| 649 | var->red.length = 5; |
| 650 | var->green.offset = 5; |
| 651 | var->green.length = 6; |
| 652 | var->blue.offset = 0; |
| 653 | var->blue.length = 5; |
| 654 | var->transp.offset = 0; |
| 655 | var->transp.length = 0; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 656 | xgifb_info->video_cmap_len = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 657 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 658 | case 32: |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 659 | var->red.offset = 16; |
| 660 | var->red.length = 8; |
| 661 | var->green.offset = 8; |
| 662 | var->green.length = 8; |
| 663 | var->blue.offset = 0; |
| 664 | var->blue.length = 8; |
| 665 | var->transp.offset = 24; |
| 666 | var->transp.length = 8; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 667 | xgifb_info->video_cmap_len = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 668 | break; |
| 669 | } |
| 670 | } |
| 671 | |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 672 | /* --------------------- SetMode routines ------------------------- */ |
| 673 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 674 | static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 675 | { |
| 676 | u8 cr30 = 0, cr31 = 0; |
| 677 | |
| 678 | cr31 = xgifb_reg_get(XGICR, 0x31); |
| 679 | cr31 &= ~0x60; |
| 680 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 681 | switch (xgifb_info->display2) { |
| 682 | case XGIFB_DISP_CRT: |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 683 | cr30 = (SIS_VB_OUTPUT_CRT2 | SIS_SIMULTANEOUS_VIEW_ENABLE); |
| 684 | cr31 |= SIS_DRIVER_MODE; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 685 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 686 | case XGIFB_DISP_LCD: |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 687 | cr30 = (SIS_VB_OUTPUT_LCD | SIS_SIMULTANEOUS_VIEW_ENABLE); |
| 688 | cr31 |= SIS_DRIVER_MODE; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 689 | break; |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 690 | case XGIFB_DISP_TV: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 691 | if (xgifb_info->TV_type == TVMODE_HIVISION) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 692 | cr30 = (SIS_VB_OUTPUT_HIVISION |
| 693 | | SIS_SIMULTANEOUS_VIEW_ENABLE); |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 694 | else if (xgifb_info->TV_plug == TVPLUG_SVIDEO) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 695 | cr30 = (SIS_VB_OUTPUT_SVIDEO |
| 696 | | SIS_SIMULTANEOUS_VIEW_ENABLE); |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 697 | else if (xgifb_info->TV_plug == TVPLUG_COMPOSITE) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 698 | cr30 = (SIS_VB_OUTPUT_COMPOSITE |
| 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_SCART) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 701 | cr30 = (SIS_VB_OUTPUT_SCART |
| 702 | | SIS_SIMULTANEOUS_VIEW_ENABLE); |
| 703 | cr31 |= SIS_DRIVER_MODE; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 704 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 705 | if (XGIfb_tvmode == 1 || xgifb_info->TV_type == TVMODE_PAL) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 706 | cr31 |= 0x01; |
| 707 | else |
| 708 | cr31 &= ~0x01; |
| 709 | break; |
| 710 | default: /* disable CRT2 */ |
| 711 | cr30 = 0x00; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 712 | cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30); |
| 716 | xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31); |
Aaro Koskinen | 5aa55d9 | 2011-10-11 21:47:23 +0300 | [diff] [blame] | 717 | xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33, |
| 718 | (xgifb_info->rate_idx & 0x0F)); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 719 | } |
| 720 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 721 | static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 722 | { |
| 723 | u8 reg; |
| 724 | unsigned char doit = 1; |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 725 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 726 | if (xgifb_info->video_bpp == 8) { |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 727 | /* |
| 728 | * We can't switch off CRT1 on LVDS/Chrontel |
| 729 | * in 8bpp Modes |
| 730 | */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 731 | if ((xgifb_info->hasVB == HASVB_LVDS) || |
| 732 | (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL)) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 733 | doit = 0; |
| 734 | } |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 735 | /* |
| 736 | * We can't switch off CRT1 on 301B-DH |
| 737 | * in 8bpp Modes if using LCD |
| 738 | */ |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 739 | if (xgifb_info->display2 == XGIFB_DISP_LCD) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 740 | doit = 0; |
| 741 | } |
| 742 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 743 | /* We can't switch off CRT1 if bridge is in slave mode */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 744 | if (xgifb_info->hasVB != HASVB_NONE) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 745 | reg = xgifb_reg_get(XGIPART1, 0x00); |
| 746 | |
| 747 | if ((reg & 0x50) == 0x10) |
| 748 | doit = 0; |
| 749 | |
| 750 | } else { |
| 751 | XGIfb_crt1off = 0; |
| 752 | } |
| 753 | |
| 754 | reg = xgifb_reg_get(XGICR, 0x17); |
| 755 | if ((XGIfb_crt1off) && (doit)) |
| 756 | reg &= ~0x80; |
| 757 | else |
| 758 | reg |= 0x80; |
| 759 | xgifb_reg_set(XGICR, 0x17, reg); |
| 760 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 761 | xgifb_reg_and(XGISR, IND_SIS_RAMDAC_CONTROL, ~0x04); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 762 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 763 | if (xgifb_info->display2 == XGIFB_DISP_TV && |
| 764 | xgifb_info->hasVB == HASVB_301) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 765 | |
| 766 | reg = xgifb_reg_get(XGIPART4, 0x01); |
| 767 | |
| 768 | if (reg < 0xB0) { /* Set filter for XGI301 */ |
Aaro Koskinen | 84a6c46 | 2011-10-11 21:47:28 +0300 | [diff] [blame] | 769 | int filter_tb; |
| 770 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 771 | switch (xgifb_info->video_width) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 772 | case 320: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 773 | filter_tb = (xgifb_info->TV_type == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 774 | TVMODE_NTSC) ? 4 : 12; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 775 | break; |
| 776 | case 640: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 777 | filter_tb = (xgifb_info->TV_type == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 778 | TVMODE_NTSC) ? 5 : 13; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 779 | break; |
| 780 | case 720: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 781 | filter_tb = (xgifb_info->TV_type == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 782 | TVMODE_NTSC) ? 6 : 14; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 783 | break; |
| 784 | case 800: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 785 | filter_tb = (xgifb_info->TV_type == |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 786 | TVMODE_NTSC) ? 7 : 15; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 787 | break; |
| 788 | default: |
Aaro Koskinen | 84a6c46 | 2011-10-11 21:47:28 +0300 | [diff] [blame] | 789 | filter_tb = 0; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 790 | filter = -1; |
| 791 | break; |
| 792 | } |
Aaro Koskinen | 39f10bf | 2011-10-11 21:47:25 +0300 | [diff] [blame] | 793 | xgifb_reg_or(XGIPART1, |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 794 | SIS_CRT2_WENABLE_315, |
Aaro Koskinen | 39f10bf | 2011-10-11 21:47:25 +0300 | [diff] [blame] | 795 | 0x01); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 796 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 797 | if (xgifb_info->TV_type == TVMODE_NTSC) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 798 | |
| 799 | xgifb_reg_and(XGIPART2, 0x3a, 0x1f); |
| 800 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 801 | if (xgifb_info->TV_plug == TVPLUG_SVIDEO) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 802 | |
| 803 | xgifb_reg_and(XGIPART2, 0x30, 0xdf); |
| 804 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 805 | } else if (xgifb_info->TV_plug |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 806 | == TVPLUG_COMPOSITE) { |
| 807 | |
| 808 | xgifb_reg_or(XGIPART2, 0x30, 0x20); |
| 809 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 810 | switch (xgifb_info->video_width) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 811 | case 640: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 812 | xgifb_reg_set(XGIPART2, |
| 813 | 0x35, |
| 814 | 0xEB); |
| 815 | xgifb_reg_set(XGIPART2, |
| 816 | 0x36, |
| 817 | 0x04); |
| 818 | xgifb_reg_set(XGIPART2, |
| 819 | 0x37, |
| 820 | 0x25); |
| 821 | xgifb_reg_set(XGIPART2, |
| 822 | 0x38, |
| 823 | 0x18); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 824 | break; |
| 825 | case 720: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 826 | xgifb_reg_set(XGIPART2, |
| 827 | 0x35, |
| 828 | 0xEE); |
| 829 | xgifb_reg_set(XGIPART2, |
| 830 | 0x36, |
| 831 | 0x0C); |
| 832 | xgifb_reg_set(XGIPART2, |
| 833 | 0x37, |
| 834 | 0x22); |
| 835 | xgifb_reg_set(XGIPART2, |
| 836 | 0x38, |
| 837 | 0x08); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 838 | break; |
| 839 | case 800: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 840 | xgifb_reg_set(XGIPART2, |
| 841 | 0x35, |
| 842 | 0xEB); |
| 843 | xgifb_reg_set(XGIPART2, |
| 844 | 0x36, |
| 845 | 0x15); |
| 846 | xgifb_reg_set(XGIPART2, |
| 847 | 0x37, |
| 848 | 0x25); |
| 849 | xgifb_reg_set(XGIPART2, |
| 850 | 0x38, |
| 851 | 0xF6); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 852 | break; |
| 853 | } |
| 854 | } |
| 855 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 856 | } else if (xgifb_info->TV_type == TVMODE_PAL) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 857 | |
| 858 | xgifb_reg_and(XGIPART2, 0x3A, 0x1F); |
| 859 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 860 | if (xgifb_info->TV_plug == TVPLUG_SVIDEO) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 861 | |
| 862 | xgifb_reg_and(XGIPART2, 0x30, 0xDF); |
| 863 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 864 | } else if (xgifb_info->TV_plug |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 865 | == TVPLUG_COMPOSITE) { |
| 866 | |
| 867 | xgifb_reg_or(XGIPART2, 0x30, 0x20); |
| 868 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 869 | switch (xgifb_info->video_width) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 870 | case 640: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 871 | xgifb_reg_set(XGIPART2, |
| 872 | 0x35, |
| 873 | 0xF1); |
| 874 | xgifb_reg_set(XGIPART2, |
| 875 | 0x36, |
| 876 | 0xF7); |
| 877 | xgifb_reg_set(XGIPART2, |
| 878 | 0x37, |
| 879 | 0x1F); |
| 880 | xgifb_reg_set(XGIPART2, |
| 881 | 0x38, |
| 882 | 0x32); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 883 | break; |
| 884 | case 720: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 885 | xgifb_reg_set(XGIPART2, |
| 886 | 0x35, |
| 887 | 0xF3); |
| 888 | xgifb_reg_set(XGIPART2, |
| 889 | 0x36, |
| 890 | 0x00); |
| 891 | xgifb_reg_set(XGIPART2, |
| 892 | 0x37, |
| 893 | 0x1D); |
| 894 | xgifb_reg_set(XGIPART2, |
| 895 | 0x38, |
| 896 | 0x20); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 897 | break; |
| 898 | case 800: |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 899 | xgifb_reg_set(XGIPART2, |
| 900 | 0x35, |
| 901 | 0xFC); |
| 902 | xgifb_reg_set(XGIPART2, |
| 903 | 0x36, |
| 904 | 0xFB); |
| 905 | xgifb_reg_set(XGIPART2, |
| 906 | 0x37, |
| 907 | 0x14); |
| 908 | xgifb_reg_set(XGIPART2, |
| 909 | 0x38, |
| 910 | 0x2A); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 911 | break; |
| 912 | } |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | if ((filter >= 0) && (filter <= 7)) { |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 917 | pr_debug("FilterTable[%d]-%d: %02x %02x %02x %02x\n", |
| 918 | filter_tb, filter, |
| 919 | XGI_TV_filter[filter_tb]. |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 920 | filter[filter][0], |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 921 | XGI_TV_filter[filter_tb]. |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 922 | filter[filter][1], |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 923 | XGI_TV_filter[filter_tb]. |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 924 | filter[filter][2], |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 925 | XGI_TV_filter[filter_tb]. |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 926 | filter[filter][3] |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 927 | ); |
| 928 | xgifb_reg_set( |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 929 | XGIPART2, |
| 930 | 0x35, |
| 931 | (XGI_TV_filter[filter_tb]. |
| 932 | filter[filter][0])); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 933 | xgifb_reg_set( |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 934 | XGIPART2, |
| 935 | 0x36, |
| 936 | (XGI_TV_filter[filter_tb]. |
| 937 | filter[filter][1])); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 938 | xgifb_reg_set( |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 939 | XGIPART2, |
| 940 | 0x37, |
| 941 | (XGI_TV_filter[filter_tb]. |
| 942 | filter[filter][2])); |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 943 | xgifb_reg_set( |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 944 | XGIPART2, |
| 945 | 0x38, |
| 946 | (XGI_TV_filter[filter_tb]. |
| 947 | filter[filter][3])); |
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 | } |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 951 | } |
| 952 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 953 | 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] | 954 | struct fb_info *info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 955 | { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 956 | struct xgifb_video_info *xgifb_info = info->par; |
| 957 | struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 958 | unsigned int htotal = var->left_margin + var->xres + var->right_margin |
| 959 | + var->hsync_len; |
| 960 | unsigned int vtotal = var->upper_margin + var->yres + var->lower_margin |
| 961 | + var->vsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 962 | #if defined(__powerpc__) |
Dmitry Eremin-Solenikov | ef23b21 | 2012-03-19 21:50:11 +0400 | [diff] [blame] | 963 | u8 cr_data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 964 | #endif |
| 965 | unsigned int drate = 0, hrate = 0; |
| 966 | int found_mode = 0; |
| 967 | int old_mode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 968 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 969 | info->var.xres_virtual = var->xres_virtual; |
| 970 | info->var.yres_virtual = var->yres_virtual; |
| 971 | info->var.bits_per_pixel = var->bits_per_pixel; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 972 | |
| 973 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) |
| 974 | vtotal <<= 1; |
| 975 | else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) |
| 976 | vtotal <<= 2; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 977 | else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 978 | } |
| 979 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 980 | if (!htotal || !vtotal) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 981 | pr_debug("Invalid 'var' information\n"); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 982 | return -EINVAL; |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 983 | } pr_debug("var->pixclock=%d, htotal=%d, vtotal=%d\n", |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 984 | var->pixclock, htotal, vtotal); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 985 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 986 | if (var->pixclock && htotal && vtotal) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 987 | drate = 1000000000 / var->pixclock; |
| 988 | hrate = (drate * 1000) / htotal; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 989 | xgifb_info->refresh_rate = (unsigned int) (hrate * 2 |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 990 | / vtotal); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 991 | } else { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 992 | xgifb_info->refresh_rate = 60; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 993 | } |
| 994 | |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 995 | pr_debug("Change mode to %dx%dx%d-%dHz\n", |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 996 | var->xres, |
| 997 | var->yres, |
| 998 | var->bits_per_pixel, |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 999 | xgifb_info->refresh_rate); |
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 | old_mode = xgifb_info->mode_idx; |
| 1002 | xgifb_info->mode_idx = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1003 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1004 | while ((XGIbios_mode[xgifb_info->mode_idx].mode_no != 0) && |
| 1005 | (XGIbios_mode[xgifb_info->mode_idx].xres <= var->xres)) { |
| 1006 | if ((XGIbios_mode[xgifb_info->mode_idx].xres == var->xres) && |
| 1007 | (XGIbios_mode[xgifb_info->mode_idx].yres == var->yres) && |
| 1008 | (XGIbios_mode[xgifb_info->mode_idx].bpp |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1009 | == var->bits_per_pixel)) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1010 | found_mode = 1; |
| 1011 | break; |
| 1012 | } |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1013 | xgifb_info->mode_idx++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1014 | } |
| 1015 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1016 | if (found_mode) |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1017 | xgifb_info->mode_idx = XGIfb_validate_mode(xgifb_info, |
| 1018 | xgifb_info->mode_idx); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1019 | else |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1020 | xgifb_info->mode_idx = -1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1021 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1022 | if (xgifb_info->mode_idx < 0) { |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1023 | pr_err("Mode %dx%dx%d not supported\n", |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1024 | var->xres, var->yres, var->bits_per_pixel); |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1025 | xgifb_info->mode_idx = old_mode; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1026 | return -EINVAL; |
| 1027 | } |
| 1028 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1029 | if (XGIfb_search_refresh_rate(xgifb_info, |
| 1030 | xgifb_info->refresh_rate) == 0) { |
Aaro Koskinen | f47f12d | 2012-04-07 01:13:54 +0300 | [diff] [blame] | 1031 | xgifb_info->rate_idx = 1; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1032 | xgifb_info->refresh_rate = 60; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1033 | } |
| 1034 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1035 | if (isactive) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1036 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1037 | XGIfb_pre_setmode(xgifb_info); |
Aaro Koskinen | fab04b9 | 2011-12-06 00:10:45 +0200 | [diff] [blame] | 1038 | if (XGISetModeNew(xgifb_info, hw_info, |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1039 | XGIbios_mode[xgifb_info->mode_idx].mode_no) |
| 1040 | == 0) { |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1041 | pr_err("Setting mode[0x%x] failed\n", |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1042 | XGIbios_mode[xgifb_info->mode_idx].mode_no); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1043 | return -EINVAL; |
| 1044 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1045 | info->fix.line_length = ((info->var.xres_virtual |
| 1046 | * info->var.bits_per_pixel) >> 6); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1047 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1048 | xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1049 | |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1050 | xgifb_reg_set(XGICR, 0x13, (info->fix.line_length & 0x00ff)); |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1051 | xgifb_reg_set(XGISR, |
| 1052 | 0x0E, |
| 1053 | (info->fix.line_length & 0xff00) >> 8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1054 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1055 | XGIfb_post_setmode(xgifb_info); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1056 | |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1057 | pr_debug("Set new mode: %dx%dx%d-%d\n", |
Miguel Gómez | d56b4c3 | 2012-06-18 13:12:01 +0200 | [diff] [blame] | 1058 | XGIbios_mode[xgifb_info->mode_idx].xres, |
| 1059 | XGIbios_mode[xgifb_info->mode_idx].yres, |
| 1060 | XGIbios_mode[xgifb_info->mode_idx].bpp, |
| 1061 | xgifb_info->refresh_rate); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1062 | |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1063 | xgifb_info->video_bpp = XGIbios_mode[xgifb_info->mode_idx].bpp; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1064 | xgifb_info->video_vwidth = info->var.xres_virtual; |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1065 | xgifb_info->video_width = |
| 1066 | XGIbios_mode[xgifb_info->mode_idx].xres; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1067 | xgifb_info->video_vheight = info->var.yres_virtual; |
Aaro Koskinen | ccf265a | 2011-10-11 21:47:22 +0300 | [diff] [blame] | 1068 | xgifb_info->video_height = |
| 1069 | XGIbios_mode[xgifb_info->mode_idx].yres; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1070 | xgifb_info->org_x = xgifb_info->org_y = 0; |
| 1071 | xgifb_info->video_linelength = info->var.xres_virtual |
| 1072 | * (xgifb_info->video_bpp >> 3); |
| 1073 | switch (xgifb_info->video_bpp) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1074 | case 8: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1075 | xgifb_info->DstColor = 0x0000; |
| 1076 | xgifb_info->XGI310_AccelDepth = 0x00000000; |
| 1077 | xgifb_info->video_cmap_len = 256; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1078 | #if defined(__powerpc__) |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1079 | cr_data = xgifb_reg_get(XGICR, 0x4D); |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1080 | xgifb_reg_set(XGICR, 0x4D, (cr_data & 0xE0)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1081 | #endif |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1082 | break; |
| 1083 | case 16: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1084 | xgifb_info->DstColor = 0x8000; |
| 1085 | xgifb_info->XGI310_AccelDepth = 0x00010000; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1086 | #if defined(__powerpc__) |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1087 | cr_data = xgifb_reg_get(XGICR, 0x4D); |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1088 | xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x0B)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1089 | #endif |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1090 | xgifb_info->video_cmap_len = 16; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1091 | break; |
| 1092 | case 32: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1093 | xgifb_info->DstColor = 0xC000; |
| 1094 | xgifb_info->XGI310_AccelDepth = 0x00020000; |
| 1095 | xgifb_info->video_cmap_len = 16; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1096 | #if defined(__powerpc__) |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1097 | cr_data = xgifb_reg_get(XGICR, 0x4D); |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1098 | xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x15)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1099 | #endif |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1100 | break; |
| 1101 | default: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1102 | xgifb_info->video_cmap_len = 16; |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1103 | pr_err("Unsupported depth %d\n", |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1104 | xgifb_info->video_bpp); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1105 | break; |
| 1106 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1107 | } |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1108 | XGIfb_bpp_to_var(xgifb_info, var); /*update ARGB info*/ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1109 | |
| 1110 | dumpVGAReg(); |
| 1111 | return 0; |
| 1112 | } |
| 1113 | |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1114 | 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] | 1115 | { |
Linus Torvalds | acff987 | 2011-10-30 15:30:01 -0700 | [diff] [blame] | 1116 | struct xgifb_video_info *xgifb_info = info->par; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1117 | unsigned int base; |
| 1118 | |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1119 | base = var->yoffset * info->var.xres_virtual + var->xoffset; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1120 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1121 | /* calculate base bpp dep. */ |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1122 | switch (info->var.bits_per_pixel) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1123 | case 16: |
| 1124 | base >>= 1; |
| 1125 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1126 | case 32: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1127 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1128 | case 8: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1129 | default: |
| 1130 | base >>= 2; |
| 1131 | break; |
| 1132 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1133 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1134 | xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1135 | |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1136 | xgifb_reg_set(XGICR, 0x0D, base & 0xFF); |
| 1137 | xgifb_reg_set(XGICR, 0x0C, (base >> 8) & 0xFF); |
| 1138 | xgifb_reg_set(XGISR, 0x0D, (base >> 16) & 0xFF); |
| 1139 | xgifb_reg_set(XGISR, 0x37, (base >> 24) & 0x03); |
Aaro Koskinen | 65283d4 | 2011-04-18 22:14:02 +0300 | [diff] [blame] | 1140 | xgifb_reg_and_or(XGISR, 0x37, 0xDF, (base >> 21) & 0x04); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1141 | |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1142 | if (xgifb_info->display2 != XGIFB_DISP_NONE) { |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1143 | xgifb_reg_or(XGIPART1, SIS_CRT2_WENABLE_315, 0x01); |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1144 | xgifb_reg_set(XGIPART1, 0x06, (base & 0xFF)); |
| 1145 | xgifb_reg_set(XGIPART1, 0x05, ((base >> 8) & 0xFF)); |
| 1146 | xgifb_reg_set(XGIPART1, 0x04, ((base >> 16) & 0xFF)); |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1147 | xgifb_reg_and_or(XGIPART1, |
| 1148 | 0x02, |
| 1149 | 0x7F, |
| 1150 | ((base >> 24) & 0x01) << 7); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1151 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1152 | return 0; |
| 1153 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1154 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1155 | static int XGIfb_open(struct fb_info *info, int user) |
| 1156 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1157 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1158 | } |
| 1159 | |
| 1160 | static int XGIfb_release(struct fb_info *info, int user) |
| 1161 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1162 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1163 | } |
| 1164 | |
| 1165 | static int XGIfb_get_cmap_len(const struct fb_var_screeninfo *var) |
| 1166 | { |
| 1167 | int rc = 16; |
| 1168 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1169 | switch (var->bits_per_pixel) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1170 | case 8: |
| 1171 | rc = 256; |
| 1172 | break; |
| 1173 | case 16: |
| 1174 | rc = 16; |
| 1175 | break; |
| 1176 | case 32: |
| 1177 | rc = 16; |
| 1178 | break; |
| 1179 | } |
| 1180 | return rc; |
| 1181 | } |
| 1182 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1183 | static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green, |
| 1184 | unsigned blue, unsigned transp, struct fb_info *info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1185 | { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1186 | struct xgifb_video_info *xgifb_info = info->par; |
| 1187 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1188 | if (regno >= XGIfb_get_cmap_len(&info->var)) |
| 1189 | return 1; |
| 1190 | |
| 1191 | switch (info->var.bits_per_pixel) { |
| 1192 | case 8: |
Aaro Koskinen | e3d5ceb | 2011-04-18 22:13:57 +0300 | [diff] [blame] | 1193 | outb(regno, XGIDACA); |
| 1194 | outb((red >> 10), XGIDACD); |
| 1195 | outb((green >> 10), XGIDACD); |
| 1196 | outb((blue >> 10), XGIDACD); |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1197 | if (xgifb_info->display2 != XGIFB_DISP_NONE) { |
Aaro Koskinen | e3d5ceb | 2011-04-18 22:13:57 +0300 | [diff] [blame] | 1198 | outb(regno, XGIDAC2A); |
| 1199 | outb((red >> 8), XGIDAC2D); |
| 1200 | outb((green >> 8), XGIDAC2D); |
| 1201 | outb((blue >> 8), XGIDAC2D); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1202 | } |
| 1203 | break; |
| 1204 | case 16: |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1205 | ((u32 *) (info->pseudo_palette))[regno] = ((red & 0xf800)) |
| 1206 | | ((green & 0xfc00) >> 5) | ((blue & 0xf800) |
| 1207 | >> 11); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1208 | break; |
| 1209 | case 32: |
| 1210 | red >>= 8; |
| 1211 | green >>= 8; |
| 1212 | blue >>= 8; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1213 | ((u32 *) (info->pseudo_palette))[regno] = (red << 16) | (green |
| 1214 | << 8) | (blue); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1215 | break; |
| 1216 | } |
| 1217 | return 0; |
| 1218 | } |
| 1219 | |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1220 | /* ----------- FBDev related routines for all series ---------- */ |
| 1221 | |
| 1222 | static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con, |
| 1223 | struct fb_info *info) |
| 1224 | { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1225 | struct xgifb_video_info *xgifb_info = info->par; |
| 1226 | |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1227 | memset(fix, 0, sizeof(struct fb_fix_screeninfo)); |
| 1228 | |
Peter Huewe | 176f784 | 2012-06-14 00:21:39 +0200 | [diff] [blame] | 1229 | strncpy(fix->id, "XGI", sizeof(fix->id) - 1); |
| 1230 | |
Peter Huewe | 95649c4 | 2012-06-14 00:21:40 +0200 | [diff] [blame] | 1231 | /* if register_framebuffer has been called, we must lock */ |
| 1232 | if (atomic_read(&info->count)) |
| 1233 | mutex_lock(&info->mm_lock); |
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 | fix->smem_start = xgifb_info->video_base; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1236 | fix->smem_len = xgifb_info->video_size; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1237 | |
Peter Huewe | 95649c4 | 2012-06-14 00:21:40 +0200 | [diff] [blame] | 1238 | /* if register_framebuffer has been called, we can unlock */ |
| 1239 | if (atomic_read(&info->count)) |
| 1240 | mutex_unlock(&info->mm_lock); |
| 1241 | |
Aaro Koskinen | de351ba | 2011-08-19 22:40:27 +0300 | [diff] [blame] | 1242 | fix->type = FB_TYPE_PACKED_PIXELS; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1243 | fix->type_aux = 0; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1244 | if (xgifb_info->video_bpp == 8) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1245 | fix->visual = FB_VISUAL_PSEUDOCOLOR; |
| 1246 | else |
| 1247 | fix->visual = FB_VISUAL_DIRECTCOLOR; |
| 1248 | fix->xpanstep = 0; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1249 | if (XGIfb_ypan) |
| 1250 | fix->ypanstep = 1; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1251 | fix->ywrapstep = 0; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1252 | fix->line_length = xgifb_info->video_linelength; |
| 1253 | fix->mmio_start = xgifb_info->mmio_base; |
| 1254 | fix->mmio_len = xgifb_info->mmio_size; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1255 | fix->accel = FB_ACCEL_SIS_XABRE; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1256 | |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1257 | return 0; |
| 1258 | } |
| 1259 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1260 | static int XGIfb_set_par(struct fb_info *info) |
| 1261 | { |
| 1262 | int err; |
| 1263 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1264 | err = XGIfb_do_set_var(&info->var, 1, info); |
| 1265 | if (err) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1266 | return err; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1267 | XGIfb_get_fix(&info->fix, -1, info); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1268 | return 0; |
| 1269 | } |
| 1270 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1271 | 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] | 1272 | { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1273 | struct xgifb_video_info *xgifb_info = info->par; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1274 | unsigned int htotal = var->left_margin + var->xres + var->right_margin |
| 1275 | + var->hsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1276 | unsigned int vtotal = 0; |
| 1277 | unsigned int drate = 0, hrate = 0; |
| 1278 | int found_mode = 0; |
| 1279 | int refresh_rate, search_idx; |
| 1280 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1281 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) { |
| 1282 | vtotal = var->upper_margin + var->yres + var->lower_margin |
| 1283 | + var->vsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1284 | vtotal <<= 1; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1285 | } else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) { |
| 1286 | vtotal = var->upper_margin + var->yres + var->lower_margin |
| 1287 | + var->vsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1288 | vtotal <<= 2; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1289 | } else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { |
| 1290 | vtotal = var->upper_margin + (var->yres / 2) |
| 1291 | + var->lower_margin + var->vsync_len; |
| 1292 | } else |
| 1293 | vtotal = var->upper_margin + var->yres + var->lower_margin |
| 1294 | + var->vsync_len; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1295 | |
Miguel Gómez | 47cee13 | 2012-06-18 13:12:03 +0200 | [diff] [blame] | 1296 | if (!(htotal) || !(vtotal)) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1297 | pr_debug("No valid timing data\n"); |
Miguel Gómez | 47cee13 | 2012-06-18 13:12:03 +0200 | [diff] [blame] | 1298 | return -EINVAL; |
| 1299 | } |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1300 | |
| 1301 | if (var->pixclock && htotal && vtotal) { |
| 1302 | drate = 1000000000 / var->pixclock; |
| 1303 | hrate = (drate * 1000) / htotal; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1304 | xgifb_info->refresh_rate = |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1305 | (unsigned int) (hrate * 2 / vtotal); |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1306 | pr_debug( |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1307 | "%s: pixclock = %d ,htotal=%d, vtotal=%d\n" |
| 1308 | "%s: drate=%d, hrate=%d, refresh_rate=%d\n", |
| 1309 | __func__, var->pixclock, htotal, vtotal, |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1310 | __func__, drate, hrate, xgifb_info->refresh_rate); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1311 | } else { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1312 | xgifb_info->refresh_rate = 60; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1313 | } |
| 1314 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1315 | /* Calculation wrong for 1024x600 - force it to 60Hz */ |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1316 | if ((var->xres == 1024) && (var->yres == 600)) |
| 1317 | refresh_rate = 60; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1318 | |
| 1319 | search_idx = 0; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1320 | while ((XGIbios_mode[search_idx].mode_no != 0) && |
| 1321 | (XGIbios_mode[search_idx].xres <= var->xres)) { |
| 1322 | if ((XGIbios_mode[search_idx].xres == var->xres) && |
| 1323 | (XGIbios_mode[search_idx].yres == var->yres) && |
| 1324 | (XGIbios_mode[search_idx].bpp == var->bits_per_pixel)) { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1325 | if (XGIfb_validate_mode(xgifb_info, search_idx) > 0) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1326 | found_mode = 1; |
| 1327 | break; |
| 1328 | } |
| 1329 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1330 | search_idx++; |
| 1331 | } |
| 1332 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1333 | if (!found_mode) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1334 | |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1335 | pr_err("%dx%dx%d is no valid mode\n", |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1336 | var->xres, var->yres, var->bits_per_pixel); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1337 | search_idx = 0; |
| 1338 | while (XGIbios_mode[search_idx].mode_no != 0) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1339 | if ((var->xres <= XGIbios_mode[search_idx].xres) && |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1340 | (var->yres <= XGIbios_mode[search_idx].yres) && |
| 1341 | (var->bits_per_pixel == |
| 1342 | XGIbios_mode[search_idx].bpp)) { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1343 | if (XGIfb_validate_mode(xgifb_info, |
| 1344 | search_idx) > 0) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1345 | found_mode = 1; |
| 1346 | break; |
| 1347 | } |
| 1348 | } |
| 1349 | search_idx++; |
| 1350 | } |
| 1351 | if (found_mode) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1352 | var->xres = XGIbios_mode[search_idx].xres; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1353 | var->yres = XGIbios_mode[search_idx].yres; |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1354 | pr_debug("Adapted to mode %dx%dx%d\n", |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1355 | var->xres, var->yres, var->bits_per_pixel); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1356 | |
| 1357 | } else { |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1358 | 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] | 1359 | var->xres, var->yres, var->bits_per_pixel); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1360 | return -EINVAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1361 | } |
| 1362 | } |
| 1363 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1364 | /* Adapt RGB settings */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1365 | XGIfb_bpp_to_var(xgifb_info, var); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1366 | |
| 1367 | /* Sanity check for offsets */ |
| 1368 | if (var->xoffset < 0) |
| 1369 | var->xoffset = 0; |
| 1370 | if (var->yoffset < 0) |
| 1371 | var->yoffset = 0; |
| 1372 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1373 | if (!XGIfb_ypan) { |
| 1374 | if (var->xres != var->xres_virtual) |
| 1375 | var->xres_virtual = var->xres; |
| 1376 | if (var->yres != var->yres_virtual) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1377 | var->yres_virtual = var->yres; |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1378 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1379 | |
| 1380 | /* Truncate offsets to maximum if too high */ |
| 1381 | if (var->xoffset > var->xres_virtual - var->xres) |
| 1382 | var->xoffset = var->xres_virtual - var->xres - 1; |
| 1383 | |
| 1384 | if (var->yoffset > var->yres_virtual - var->yres) |
| 1385 | var->yoffset = var->yres_virtual - var->yres - 1; |
| 1386 | |
| 1387 | /* Set everything else to 0 */ |
| 1388 | var->red.msb_right = |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1389 | var->green.msb_right = |
| 1390 | var->blue.msb_right = |
| 1391 | var->transp.offset = var->transp.length = var->transp.msb_right = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1392 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1393 | return 0; |
| 1394 | } |
| 1395 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1396 | static int XGIfb_pan_display(struct fb_var_screeninfo *var, |
| 1397 | struct fb_info *info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1398 | { |
| 1399 | int err; |
| 1400 | |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1401 | if (var->xoffset > (info->var.xres_virtual - info->var.xres)) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1402 | return -EINVAL; |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1403 | if (var->yoffset > (info->var.yres_virtual - info->var.yres)) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1404 | return -EINVAL; |
| 1405 | |
| 1406 | if (var->vmode & FB_VMODE_YWRAP) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1407 | if (var->yoffset < 0 || var->yoffset >= info->var.yres_virtual |
| 1408 | || var->xoffset) |
| 1409 | return -EINVAL; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1410 | } else { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1411 | if (var->xoffset + info->var.xres > info->var.xres_virtual |
| 1412 | || var->yoffset + info->var.yres |
| 1413 | > info->var.yres_virtual) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1414 | return -EINVAL; |
| 1415 | } |
Laurent Pinchart | 0d5c6ca | 2011-05-25 11:34:52 +0200 | [diff] [blame] | 1416 | err = XGIfb_pan_var(var, info); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1417 | if (err < 0) |
| 1418 | return err; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1419 | |
| 1420 | info->var.xoffset = var->xoffset; |
| 1421 | info->var.yoffset = var->yoffset; |
| 1422 | if (var->vmode & FB_VMODE_YWRAP) |
| 1423 | info->var.vmode |= FB_VMODE_YWRAP; |
| 1424 | else |
| 1425 | info->var.vmode &= ~FB_VMODE_YWRAP; |
| 1426 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1427 | return 0; |
| 1428 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1429 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1430 | static int XGIfb_blank(int blank, struct fb_info *info) |
| 1431 | { |
Aaro Koskinen | f2df8c0 | 2011-10-11 21:47:30 +0300 | [diff] [blame] | 1432 | struct xgifb_video_info *xgifb_info = info->par; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1433 | u8 reg; |
| 1434 | |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1435 | reg = xgifb_reg_get(XGICR, 0x17); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1436 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1437 | if (blank > 0) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1438 | reg &= 0x7f; |
| 1439 | else |
| 1440 | reg |= 0x80; |
| 1441 | |
Aaro Koskinen | b6e2dc3 | 2011-04-18 22:13:59 +0300 | [diff] [blame] | 1442 | xgifb_reg_set(XGICR, 0x17, reg); |
| 1443 | xgifb_reg_set(XGISR, 0x00, 0x01); /* Synchronous Reset */ |
| 1444 | xgifb_reg_set(XGISR, 0x00, 0x03); /* End Reset */ |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1445 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1446 | } |
| 1447 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1448 | static struct fb_ops XGIfb_ops = { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1449 | .owner = THIS_MODULE, |
| 1450 | .fb_open = XGIfb_open, |
| 1451 | .fb_release = XGIfb_release, |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1452 | .fb_check_var = XGIfb_check_var, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1453 | .fb_set_par = XGIfb_set_par, |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1454 | .fb_setcolreg = XGIfb_setcolreg, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1455 | .fb_pan_display = XGIfb_pan_display, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1456 | .fb_blank = XGIfb_blank, |
Aaro Koskinen | 1b40296 | 2011-02-28 20:59:22 +0200 | [diff] [blame] | 1457 | .fb_fillrect = cfb_fillrect, |
Aaro Koskinen | 85c3c56 | 2011-02-28 20:59:21 +0200 | [diff] [blame] | 1458 | .fb_copyarea = cfb_copyarea, |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1459 | .fb_imageblit = cfb_imageblit, |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1460 | }; |
| 1461 | |
| 1462 | /* ---------------- Chip generation dependent routines ---------------- */ |
| 1463 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1464 | /* for XGI 315/550/650/740/330 */ |
| 1465 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1466 | 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] | 1467 | { |
| 1468 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1469 | u8 ChannelNum, tmp; |
| 1470 | u8 reg = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1471 | |
| 1472 | /* xorg driver sets 32MB * 1 channel */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1473 | if (xgifb_info->chip == XG27) |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1474 | xgifb_reg_set(XGISR, IND_SIS_DRAM_SIZE, 0x51); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1475 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1476 | reg = xgifb_reg_get(XGISR, IND_SIS_DRAM_SIZE); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1477 | switch ((reg & XGI_DRAM_SIZE_MASK) >> 4) { |
| 1478 | case XGI_DRAM_SIZE_1MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1479 | xgifb_info->video_size = 0x100000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1480 | break; |
| 1481 | case XGI_DRAM_SIZE_2MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1482 | xgifb_info->video_size = 0x200000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1483 | break; |
| 1484 | case XGI_DRAM_SIZE_4MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1485 | xgifb_info->video_size = 0x400000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1486 | break; |
| 1487 | case XGI_DRAM_SIZE_8MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1488 | xgifb_info->video_size = 0x800000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1489 | break; |
| 1490 | case XGI_DRAM_SIZE_16MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1491 | xgifb_info->video_size = 0x1000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1492 | break; |
| 1493 | case XGI_DRAM_SIZE_32MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1494 | xgifb_info->video_size = 0x2000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1495 | break; |
| 1496 | case XGI_DRAM_SIZE_64MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1497 | xgifb_info->video_size = 0x4000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1498 | break; |
| 1499 | case XGI_DRAM_SIZE_128MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1500 | xgifb_info->video_size = 0x8000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1501 | break; |
| 1502 | case XGI_DRAM_SIZE_256MB: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1503 | xgifb_info->video_size = 0x10000000; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1504 | break; |
| 1505 | default: |
| 1506 | return -1; |
| 1507 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1508 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1509 | tmp = (reg & 0x0c) >> 2; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1510 | switch (xgifb_info->chip) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1511 | case XG20: |
| 1512 | case XG21: |
| 1513 | case XG27: |
| 1514 | ChannelNum = 1; |
| 1515 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1516 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1517 | case XG42: |
| 1518 | if (reg & 0x04) |
| 1519 | ChannelNum = 2; |
| 1520 | else |
| 1521 | ChannelNum = 1; |
| 1522 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1523 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1524 | case XG40: |
| 1525 | default: |
| 1526 | if (tmp == 2) |
| 1527 | ChannelNum = 2; |
| 1528 | else if (tmp == 3) |
| 1529 | ChannelNum = 3; |
| 1530 | else |
| 1531 | ChannelNum = 1; |
| 1532 | break; |
| 1533 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1534 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1535 | xgifb_info->video_size = xgifb_info->video_size * ChannelNum; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1536 | |
Sam Hansen | 4a6b151 | 2012-01-22 16:48:53 -0800 | [diff] [blame] | 1537 | pr_info("SR14=%x DramSzie %x ChannelNum %x\n", |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1538 | reg, |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1539 | xgifb_info->video_size, ChannelNum); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1540 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1541 | |
| 1542 | } |
| 1543 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1544 | static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1545 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1546 | u8 cr32, temp = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1547 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1548 | xgifb_info->TV_plug = xgifb_info->TV_type = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1549 | |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1550 | cr32 = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR32); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1551 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1552 | if ((cr32 & SIS_CRT1) && !XGIfb_crt1off) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1553 | XGIfb_crt1off = 0; |
| 1554 | else { |
| 1555 | if (cr32 & 0x5F) |
| 1556 | XGIfb_crt1off = 1; |
| 1557 | else |
| 1558 | XGIfb_crt1off = 0; |
| 1559 | } |
| 1560 | |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1561 | if (!xgifb_info->display2_force) { |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1562 | if (cr32 & SIS_VB_TV) |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1563 | xgifb_info->display2 = XGIFB_DISP_TV; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1564 | else if (cr32 & SIS_VB_LCD) |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1565 | xgifb_info->display2 = XGIFB_DISP_LCD; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1566 | else if (cr32 & SIS_VB_CRT2) |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1567 | xgifb_info->display2 = XGIFB_DISP_CRT; |
| 1568 | else |
| 1569 | xgifb_info->display2 = XGIFB_DISP_NONE; |
| 1570 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1571 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1572 | if (XGIfb_tvplug != -1) |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1573 | /* Override with option */ |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1574 | xgifb_info->TV_plug = XGIfb_tvplug; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1575 | else if (cr32 & SIS_VB_HIVISION) { |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1576 | xgifb_info->TV_type = TVMODE_HIVISION; |
| 1577 | xgifb_info->TV_plug = TVPLUG_SVIDEO; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1578 | } else if (cr32 & SIS_VB_SVIDEO) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1579 | xgifb_info->TV_plug = TVPLUG_SVIDEO; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1580 | else if (cr32 & SIS_VB_COMPOSITE) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1581 | xgifb_info->TV_plug = TVPLUG_COMPOSITE; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1582 | else if (cr32 & SIS_VB_SCART) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1583 | xgifb_info->TV_plug = TVPLUG_SCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1584 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1585 | if (xgifb_info->TV_type == 0) { |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1586 | temp = xgifb_reg_get(XGICR, 0x38); |
Aaro Koskinen | ebe7846 | 2011-03-13 12:26:08 +0200 | [diff] [blame] | 1587 | if (temp & 0x10) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1588 | xgifb_info->TV_type = TVMODE_PAL; |
Aaro Koskinen | ebe7846 | 2011-03-13 12:26:08 +0200 | [diff] [blame] | 1589 | else |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1590 | xgifb_info->TV_type = TVMODE_NTSC; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1591 | } |
| 1592 | |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1593 | /* Copy forceCRT1 option to CRT1off if option is given */ |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1594 | if (XGIfb_forcecrt1 != -1) { |
| 1595 | if (XGIfb_forcecrt1) |
| 1596 | XGIfb_crt1off = 0; |
| 1597 | else |
| 1598 | XGIfb_crt1off = 1; |
| 1599 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1600 | } |
| 1601 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1602 | static int XGIfb_has_VB(struct xgifb_video_info *xgifb_info) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1603 | { |
| 1604 | u8 vb_chipid; |
| 1605 | |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1606 | vb_chipid = xgifb_reg_get(XGIPART4, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1607 | switch (vb_chipid) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1608 | case 0x01: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1609 | xgifb_info->hasVB = HASVB_301; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1610 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1611 | case 0x02: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1612 | xgifb_info->hasVB = HASVB_302; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1613 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1614 | default: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1615 | xgifb_info->hasVB = HASVB_NONE; |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 1616 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1617 | } |
Bill Pemberton | dda08c5 | 2010-06-17 13:10:42 -0400 | [diff] [blame] | 1618 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1619 | } |
| 1620 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1621 | static void XGIfb_get_VB_type(struct xgifb_video_info *xgifb_info) |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1622 | { |
| 1623 | u8 reg; |
| 1624 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1625 | if (!XGIfb_has_VB(xgifb_info)) { |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1626 | reg = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR37); |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1627 | switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) { |
| 1628 | case SIS_EXTERNAL_CHIP_LVDS: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1629 | xgifb_info->hasVB = HASVB_LVDS; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1630 | break; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1631 | case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1632 | xgifb_info->hasVB = HASVB_LVDS_CHRONTEL; |
Aaro Koskinen | c4fa7df | 2011-04-18 22:14:05 +0300 | [diff] [blame] | 1633 | break; |
| 1634 | default: |
| 1635 | break; |
| 1636 | } |
| 1637 | } |
| 1638 | } |
| 1639 | |
Aaro Koskinen | d27c6bc | 2011-08-29 23:14:23 +0300 | [diff] [blame] | 1640 | static int __init xgifb_optval(char *fullopt, int validx) |
| 1641 | { |
| 1642 | unsigned long lres; |
| 1643 | |
| 1644 | if (kstrtoul(fullopt + validx, 0, &lres) < 0 || lres > INT_MAX) { |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1645 | pr_err("Invalid value for option: %s\n", fullopt); |
Aaro Koskinen | d27c6bc | 2011-08-29 23:14:23 +0300 | [diff] [blame] | 1646 | return 0; |
| 1647 | } |
| 1648 | return lres; |
| 1649 | } |
| 1650 | |
Ruslan Pisarev | 032abf7 | 2011-07-21 11:59:11 +0300 | [diff] [blame] | 1651 | static int __init XGIfb_setup(char *options) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1652 | { |
| 1653 | char *this_opt; |
| 1654 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1655 | if (!options || !*options) |
| 1656 | return 0; |
| 1657 | |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1658 | pr_info("Options: %s\n", options); |
Aaro Koskinen | 79bea04 | 2011-08-29 23:14:21 +0300 | [diff] [blame] | 1659 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1660 | while ((this_opt = strsep(&options, ",")) != NULL) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1661 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1662 | if (!*this_opt) |
| 1663 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1664 | |
| 1665 | if (!strncmp(this_opt, "mode:", 5)) { |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1666 | mode = this_opt + 5; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1667 | } else if (!strncmp(this_opt, "vesa:", 5)) { |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1668 | vesa = xgifb_optval(this_opt, 5); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1669 | } else if (!strncmp(this_opt, "vrate:", 6)) { |
Aaro Koskinen | 7548a83 | 2011-10-11 21:47:17 +0300 | [diff] [blame] | 1670 | refresh_rate = xgifb_optval(this_opt, 6); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1671 | } else if (!strncmp(this_opt, "rate:", 5)) { |
Aaro Koskinen | 7548a83 | 2011-10-11 21:47:17 +0300 | [diff] [blame] | 1672 | refresh_rate = xgifb_optval(this_opt, 5); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1673 | } else if (!strncmp(this_opt, "crt1off", 7)) { |
| 1674 | XGIfb_crt1off = 1; |
| 1675 | } else if (!strncmp(this_opt, "filter:", 7)) { |
Aaro Koskinen | d27c6bc | 2011-08-29 23:14:23 +0300 | [diff] [blame] | 1676 | filter = xgifb_optval(this_opt, 7); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1677 | } else if (!strncmp(this_opt, "forcecrt2type:", 14)) { |
| 1678 | XGIfb_search_crt2type(this_opt + 14); |
| 1679 | } else if (!strncmp(this_opt, "forcecrt1:", 10)) { |
Aaro Koskinen | d27c6bc | 2011-08-29 23:14:23 +0300 | [diff] [blame] | 1680 | XGIfb_forcecrt1 = xgifb_optval(this_opt, 10); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1681 | } else if (!strncmp(this_opt, "tvmode:", 7)) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1682 | XGIfb_search_tvstd(this_opt + 7); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1683 | } else if (!strncmp(this_opt, "tvstandard:", 11)) { |
| 1684 | XGIfb_search_tvstd(this_opt + 7); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1685 | } else if (!strncmp(this_opt, "dstn", 4)) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1686 | enable_dstn = 1; |
Miguel Gómez | 949eb0a | 2012-07-06 12:40:36 +0200 | [diff] [blame] | 1687 | /* DSTN overrules forcecrt2type */ |
Aaro Koskinen | 289ea52 | 2011-10-11 21:47:37 +0300 | [diff] [blame] | 1688 | XGIfb_crt2type = XGIFB_DISP_LCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1689 | } else if (!strncmp(this_opt, "noypan", 6)) { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1690 | XGIfb_ypan = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1691 | } else { |
Aaro Koskinen | dfbdf80 | 2011-08-29 23:14:25 +0300 | [diff] [blame] | 1692 | mode = this_opt; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1693 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1694 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1695 | return 0; |
| 1696 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1697 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 1698 | static int __devinit xgifb_probe(struct pci_dev *pdev, |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1699 | const struct pci_device_id *ent) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1700 | { |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1701 | u8 reg, reg1; |
| 1702 | u8 CR48, CR38; |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1703 | int ret; |
Aaro Koskinen | 19c1e88 | 2011-10-11 21:47:14 +0300 | [diff] [blame] | 1704 | struct fb_info *fb_info; |
Aaro Koskinen | fcbdda9 | 2011-10-11 21:47:20 +0300 | [diff] [blame] | 1705 | struct xgifb_video_info *xgifb_info; |
| 1706 | struct xgi_hw_device_info *hw_info; |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1707 | |
Aaro Koskinen | fcbdda9 | 2011-10-11 21:47:20 +0300 | [diff] [blame] | 1708 | fb_info = framebuffer_alloc(sizeof(*xgifb_info), &pdev->dev); |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1709 | if (!fb_info) |
| 1710 | return -ENOMEM; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1711 | |
Aaro Koskinen | fcbdda9 | 2011-10-11 21:47:20 +0300 | [diff] [blame] | 1712 | xgifb_info = fb_info->par; |
| 1713 | hw_info = &xgifb_info->hw_info; |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1714 | xgifb_info->fb_info = fb_info; |
| 1715 | xgifb_info->chip_id = pdev->device; |
Kenji Toyama | a12c27c | 2011-04-26 12:13:43 +0800 | [diff] [blame] | 1716 | pci_read_config_byte(pdev, |
| 1717 | PCI_REVISION_ID, |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1718 | &xgifb_info->revision_id); |
| 1719 | hw_info->jChipRevision = xgifb_info->revision_id; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1720 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1721 | xgifb_info->pcibus = pdev->bus->number; |
| 1722 | xgifb_info->pcislot = PCI_SLOT(pdev->devfn); |
| 1723 | xgifb_info->pcifunc = PCI_FUNC(pdev->devfn); |
| 1724 | xgifb_info->subsysvendor = pdev->subsystem_vendor; |
| 1725 | xgifb_info->subsysdevice = pdev->subsystem_device; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1726 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1727 | xgifb_info->video_base = pci_resource_start(pdev, 0); |
| 1728 | xgifb_info->mmio_base = pci_resource_start(pdev, 1); |
| 1729 | xgifb_info->mmio_size = pci_resource_len(pdev, 1); |
| 1730 | xgifb_info->vga_base = pci_resource_start(pdev, 2) + 0x30; |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1731 | dev_info(&pdev->dev, "Relocate IO address: %Lx [%08lx]\n", |
| 1732 | (u64) pci_resource_start(pdev, 2), |
| 1733 | xgifb_info->vga_base); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1734 | |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1735 | if (pci_enable_device(pdev)) { |
| 1736 | ret = -EIO; |
| 1737 | goto error; |
| 1738 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1739 | |
Aaro Koskinen | 25aa75f | 2011-12-06 00:10:48 +0200 | [diff] [blame] | 1740 | if (XGIfb_crt2type != -1) { |
| 1741 | xgifb_info->display2 = XGIfb_crt2type; |
| 1742 | xgifb_info->display2_force = true; |
| 1743 | } |
| 1744 | |
Dmitry Eremin-Solenikov | 9a801f2 | 2012-03-19 21:50:13 +0400 | [diff] [blame] | 1745 | XGIRegInit(&xgifb_info->dev_info, xgifb_info->vga_base); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1746 | |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1747 | xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD); |
| 1748 | reg1 = xgifb_reg_get(XGISR, IND_SIS_PASSWORD); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1749 | |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1750 | if (reg1 != 0xa1) { /*I/O error */ |
Miguel Gómez | be25aef | 2012-07-06 12:40:40 +0200 | [diff] [blame] | 1751 | dev_err(&pdev->dev, "I/O error\n"); |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1752 | ret = -EIO; |
Miguel Gómez | 05e0603 | 2012-06-06 16:22:06 +0200 | [diff] [blame] | 1753 | goto error_disable; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1754 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1755 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1756 | switch (xgifb_info->chip_id) { |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1757 | case PCI_DEVICE_ID_XGI_20: |
Aaro Koskinen | e67f4d4 | 2011-04-18 22:14:00 +0300 | [diff] [blame] | 1758 | xgifb_reg_or(XGICR, Index_CR_GPIO_Reg3, GPIOG_EN); |
Aaro Koskinen | 7e119b7 | 2011-04-18 22:13:58 +0300 | [diff] [blame] | 1759 | CR48 = xgifb_reg_get(XGICR, Index_CR_GPIO_Reg1); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1760 | if (CR48&GPIOG_READ) |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1761 | xgifb_info->chip = XG21; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1762 | else |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1763 | xgifb_info->chip = XG20; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1764 | break; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1765 | case PCI_DEVICE_ID_XGI_40: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1766 | xgifb_info->chip = XG40; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1767 | break; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1768 | case PCI_DEVICE_ID_XGI_42: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1769 | xgifb_info->chip = XG42; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1770 | break; |
Peter Huewe | fc39dcb | 2012-01-15 19:22:12 +0100 | [diff] [blame] | 1771 | case PCI_DEVICE_ID_XGI_27: |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1772 | xgifb_info->chip = XG27; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1773 | break; |
Prashant P. Shah | b654f87 | 2010-09-06 17:34:26 +0530 | [diff] [blame] | 1774 | default: |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1775 | ret = -ENODEV; |
Miguel Gómez | 05e0603 | 2012-06-06 16:22:06 +0200 | [diff] [blame] | 1776 | goto error_disable; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1777 | } |
| 1778 | |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1779 | dev_info(&pdev->dev, "chipid = %x\n", xgifb_info->chip); |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1780 | hw_info->jChipType = xgifb_info->chip; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1781 | |
Aaro Koskinen | fd26d42 | 2011-10-11 21:47:19 +0300 | [diff] [blame] | 1782 | if (XGIfb_get_dram_size(xgifb_info)) { |
Miguel Gómez | 1918570 | 2012-06-18 13:12:06 +0200 | [diff] [blame] | 1783 | dev_err(&pdev->dev, |
| 1784 | "Fatal error: Unable to determine RAM size.\n"); |
Aaro Koskinen | bb29223 | 2011-02-17 23:29:11 +0200 | [diff] [blame] | 1785 | ret = -ENODEV; |
Miguel Gómez | 05e0603 | 2012-06-06 16:22:06 +0200 | [diff] [blame] | 1786 | goto error_disable; |
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); |