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