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