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